7fed0ca818016dcc70f7e4fbb793573b1e0f0e92
[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$
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   BackgroundManagerTask* lookupTask (int iButtonID);
69
70   static int s_iNextButtonID;
71
72   wxSize m_sizeGauge;
73   wxSize m_sizeLabel;
74   wxSize m_sizeCell;
75   wxSize m_sizeBorder;
76   wxSize m_sizeCellSpacing;
77   wxSize m_sizeButton;
78
79 public:
80   BackgroundManager ();
81   ~BackgroundManager();
82
83   void OnAddTask (wxCommandEvent& event);
84   void OnRemoveTask (wxCommandEvent& event);
85   void OnUnitTick (wxCommandEvent& event);
86   void OnCloseWindow(wxCloseEvent& event);
87   void OnCancelButton(wxCommandEvent& event);
88
89   DECLARE_EVENT_TABLE()
90 };
91
92
93 class BackgroundSupervisor;
94 class BackgroundManagerTask {
95 private:
96   BackgroundSupervisor* m_pSupervisor;
97   const std::string m_strName;
98   const int m_iPosition;
99   wxGauge* m_pGauge;
100   wxStaticText* m_pLabel;
101   wxButton* m_pButton;
102   const int m_iButtonID;
103
104 public:
105   BackgroundManagerTask (BackgroundSupervisor* pSupervisor, const char* const pszName, int iPos,
106           wxGauge* pGauge, wxStaticText* pLabel, wxButton* pButton, int iButtonID)
107           : m_pSupervisor(pSupervisor), m_strName(pszName), m_iPosition(iPos), m_pGauge(pGauge),
108     m_pLabel(pLabel), m_pButton(pButton), m_iButtonID(iButtonID)
109   {}
110
111   int position() const {return m_iPosition;}
112   const std::string& name() const {return m_strName;}
113   BackgroundSupervisor* supervisor() {return m_pSupervisor;}
114
115   wxGauge* gauge() {return m_pGauge;}
116   wxStaticText* label() {return m_pLabel;}
117   wxButton* button() {return m_pButton;}
118   int buttonID() const {return m_iButtonID;}
119 };
120
121
122 class BackgroundManagerCanvas : public wxPanel {
123 private:
124   DECLARE_DYNAMIC_CLASS(BackgroundManagerCanvas)
125   BackgroundManager* m_pBackgroundManager;
126
127 public:
128   BackgroundManagerCanvas (BackgroundManager* pBkgdMgr = NULL);
129
130   DECLARE_EVENT_TABLE()
131 };
132
133 #endif // HAVE_WXTHREADS
134
135 #endif // _BACKGROUNDMGR_H
136