r623: no message
[ctsim.git] / src / backgroundmgr.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          backgroundmgr.h
5 **   Purpose:       Header file for background manager
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.h,v 1.10 2001/03/09 18:50:46 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 #ifndef _BACKGROUND_MGR_H
29
30
31 #include "wx/wxprec.h"
32
33 #ifndef WX_PRECOMP
34 #include "wx/wx.h"
35 #endif
36 #include "wx/minifram.h"
37 #include "wx/gauge.h"
38
39 #include "ct.h"
40 #include "ctsim.h"
41 #include "docs.h"
42 #include "views.h"
43 #include "threadrecon.h"
44
45 #include <list>
46
47 #ifdef HAVE_WXTHREADS
48
49 class BackgroundManagerCanvas;
50 class BackgroundManagerTask;
51
52
53 class BackgroundManager : public wxMiniFrame
54 {
55 private:
56
57   DECLARE_DYNAMIC_CLASS(BackgroundManager)
58
59   wxCriticalSection m_criticalSection;
60   BackgroundManagerCanvas* m_pCanvas;
61   int m_iNumTasks;
62
63   typedef std::list<BackgroundManagerTask*> TaskContainer;
64   TaskContainer m_vecpTasks;
65
66   void resizeWindow();
67   BackgroundManagerTask* lookupTask (BackgroundSupervisor* pSupervisor);
68
69   wxSize m_sizeGauge;
70   wxSize m_sizeLabel;
71   wxSize m_sizeCell;
72   wxSize m_sizeBorder;
73   wxSize m_sizeCellSpacing;
74   wxSize m_sizeButton;
75
76 public:
77   BackgroundManager ();
78   ~BackgroundManager();
79
80   void OnAddTask (wxCommandEvent& event);
81   void OnRemoveTask (wxCommandEvent& event);
82   void OnUnitTick (wxCommandEvent& event);
83   void OnCloseWindow(wxCloseEvent& event);
84   void OnCancelButton(wxCommandEvent& event);
85
86   DECLARE_EVENT_TABLE()
87 };
88
89
90 class BackgroundSupervisor;
91 class BackgroundManagerTask {
92 private:
93   const BackgroundSupervisor* m_pSupervisor;
94   const std::string m_strName;
95   const int m_iPosition;
96   wxGauge* m_pGauge;
97   wxStaticText* m_pLabel;
98   wxButton* m_pButton;
99
100 public:
101   BackgroundManagerTask (BackgroundSupervisor* pSupervisor, const char* const pszName, int iPos,
102           wxGauge* pGauge, wxStaticText* pLabel, wxButton* pButton)
103           : m_pSupervisor(pSupervisor), m_strName(pszName), m_iPosition(iPos), m_pGauge(pGauge), m_pLabel(pLabel), m_pButton(pButton)
104   {}
105
106   int position() const {return m_iPosition;}
107   const std::string& name() const {return m_strName;}
108   const BackgroundSupervisor* supervisor() const {return m_pSupervisor;}
109
110   wxGauge* gauge() {return m_pGauge;}
111   wxStaticText* label() {return m_pLabel;}
112   wxButton* button() {return m_pButton;}
113 };
114
115
116 class BackgroundManagerCanvas : public wxPanel {
117 private:
118   DECLARE_DYNAMIC_CLASS(BackgroundManagerCanvas)
119   BackgroundManager* m_pBackgroundManager;
120
121 public:
122   BackgroundManagerCanvas (BackgroundManager* pBkgdMgr = NULL);
123
124   DECLARE_EVENT_TABLE()
125 };
126
127 #endif // HAVE_WXTHREADS
128
129 #endif // _BACKGROUNDMGR_H
130