r572: no message
[ctsim.git] / src / backgroundmgr.cpp
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          backgroundmgr.cpp
5 **   Purpose:       Background manager class
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  February 2001
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id: backgroundmgr.cpp,v 1.1 2001/02/22 15:00:20 kevin Exp $
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27
28 #include "wx/wxprec.h"
29
30 #ifndef WX_PRECOMP
31 #include "wx/wx.h"
32 #endif
33
34 #include "ct.h"
35 #include "ctsim.h"
36 #include "docs.h"
37 #include "views.h"
38 #include "threadrecon.h"
39 #include "backgroundmgr.h"
40
41
42 #if defined(HAVE_CONFIG_H)
43 #include "config.h"
44 #endif
45
46
47 IMPLEMENT_DYNAMIC_CLASS(BackgroundManager, wxMiniFrame)
48 BEGIN_EVENT_TABLE(BackgroundManager, wxMiniFrame)
49 EVT_CLOSE(BackgroundManager::OnCloseWindow)
50 END_EVENT_TABLE()
51
52 BackgroundManager::BackgroundManager ()
53   : wxMiniFrame (theApp->getMainFrame(), -1, _T("Background Tasks"), wxPoint(0,0), wxSize(200, 100)) //, wxTHICK_FRAME)
54 {
55   m_iNumTasks = 0;
56   m_pCanvas = new BackgroundManagerCanvas (this);
57   theApp->setIconForFrame (this);
58
59   Show(true);
60  // if (m_iNumTasks == 0)
61  //   Show(false);
62 }
63
64
65 void
66 BackgroundManager::OnCloseWindow (wxCloseEvent& event)
67 {
68   if (theApp->getMainFrame()->getShuttingDown())
69     wxMiniFrame::OnCloseWindow (event);
70   else
71     event.Veto();
72 }
73
74
75 wxGauge* 
76 BackgroundManager::addTask (BackgroundTask* pTask, int iNumUnits)
77 {
78   wxSize size (50, 10);
79   wxPoint pos (4, 5);
80
81   wxGauge* pGauge = new wxGauge (m_pCanvas, -1, iNumUnits, pos, size);
82   m_vecpBackgroundTasks.push_back (pTask);
83   m_iNumTasks++;
84   return (pGauge);
85 }
86
87
88 void 
89 BackgroundManager::taskDone (BackgroundTask* pTask)
90 {
91   m_iNumTasks--;
92 }
93
94 bool
95 BackgroundManager::isCancelling (BackgroundTask* pTask)
96 {
97   return false;
98 }
99
100
101
102 IMPLEMENT_DYNAMIC_CLASS(BackgroundManagerCanvas, wxPanel)
103 BEGIN_EVENT_TABLE(BackgroundManagerCanvas, wxPanel)
104 EVT_PAINT(BackgroundManagerCanvas::OnPaint)
105 END_EVENT_TABLE()
106
107 BackgroundManagerCanvas::BackgroundManagerCanvas (BackgroundManager* pMgr)
108 : m_pBackgroundManager(pMgr), wxPanel (pMgr)
109 {
110 }
111
112
113 void
114 BackgroundManagerCanvas::OnPaint (wxPaintEvent& event)
115 {
116   wxPaintDC dc (this);
117 //  dc.DrawLine (0, 0, 30, 30);
118 //  dc.DrawLine (30,0, 0, 30);
119 }