Use OpenMP for scanner
[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-2009 Kevin Rosenberg
11 **
12 **  This program is free software; you can redistribute it and/or modify
13 **  it under the terms of the GNU General Public License (version 2) as
14 **  published by the Free Software Foundation.
15 **
16 **  This program is distributed in the hope that it will be useful,
17 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 **  GNU General Public License for more details.
20 **
21 **  You should have received a copy of the GNU General Public License
22 **  along with this program; if not, write to the Free Software
23 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 ******************************************************************************/
25
26 #ifndef _BACKGROUND_MGR_H
27
28
29 #include "wx/wxprec.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/wx.h"
33 #endif
34 #include "wx/minifram.h"
35 #include "wx/gauge.h"
36
37 #include "ct.h"
38 #include "ctsim.h"
39 #include "docs.h"
40 #include "views.h"
41 #include "threadrecon.h"
42
43 #include <list>
44
45 #ifdef HAVE_WXTHREADS
46
47 class BackgroundManagerCanvas;
48 class BackgroundManagerTask;
49
50
51 class BackgroundManager : public wxMiniFrame
52 {
53 private:
54
55   DECLARE_DYNAMIC_CLASS(BackgroundManager)
56
57   wxCriticalSection m_criticalSection;
58   BackgroundManagerCanvas* m_pCanvas;
59   int m_iNumTasks;
60
61   typedef std::list<BackgroundManagerTask*> TaskContainer;
62   TaskContainer m_vecpTasks;
63
64   void resizeWindow();
65   BackgroundManagerTask* lookupTask (BackgroundSupervisor* pSupervisor);
66   BackgroundManagerTask* lookupTask (int iButtonID);
67
68   static int s_iNextButtonID;
69
70   wxSize m_sizeGauge;
71   wxSize m_sizeLabel;
72   wxSize m_sizeCell;
73   wxSize m_sizeBorder;
74   wxSize m_sizeCellSpacing;
75   wxSize m_sizeButton;
76
77 public:
78   BackgroundManager ();
79   ~BackgroundManager();
80
81   void OnAddTask (wxCommandEvent& event);
82   void OnRemoveTask (wxCommandEvent& event);
83   void OnUnitTick (wxCommandEvent& event);
84   void OnCloseWindow(wxCloseEvent& event);
85   void OnCancelButton(wxCommandEvent& event);
86
87   DECLARE_EVENT_TABLE()
88 };
89
90
91 class BackgroundSupervisor;
92 class BackgroundManagerTask {
93 private:
94   BackgroundSupervisor* m_pSupervisor;
95   const std::string m_strName;
96   const int m_iPosition;
97   wxGauge* m_pGauge;
98   wxStaticText* m_pLabel;
99   wxButton* m_pButton;
100   const int m_iButtonID;
101
102 public:
103   BackgroundManagerTask (BackgroundSupervisor* pSupervisor, const char* const pszName, int iPos,
104           wxGauge* pGauge, wxStaticText* pLabel, wxButton* pButton, int iButtonID)
105           : m_pSupervisor(pSupervisor), m_strName(pszName), m_iPosition(iPos), m_pGauge(pGauge),
106     m_pLabel(pLabel), m_pButton(pButton), m_iButtonID(iButtonID)
107   {}
108
109   int position() const {return m_iPosition;}
110   const std::string& name() const {return m_strName;}
111   BackgroundSupervisor* supervisor() {return m_pSupervisor;}
112
113   wxGauge* gauge() {return m_pGauge;}
114   wxStaticText* label() {return m_pLabel;}
115   wxButton* button() {return m_pButton;}
116   int buttonID() const {return m_iButtonID;}
117 };
118
119
120 class BackgroundManagerCanvas : public wxPanel {
121 private:
122   DECLARE_DYNAMIC_CLASS(BackgroundManagerCanvas)
123   BackgroundManager* m_pBackgroundManager;
124
125 public:
126   BackgroundManagerCanvas (BackgroundManager* pBkgdMgr = NULL);
127
128   DECLARE_EVENT_TABLE()
129 };
130
131 #endif // HAVE_WXTHREADS
132
133 #endif // _BACKGROUNDMGR_H
134