Update copyright date; remove old CVS keyword
[ctsim.git] / src / backgroundmgr.h
index a900f72941b1476b3582115f873e4718de68dcf6..225a78eb073537bd1b367efe15e7eb30606c0377 100644 (file)
@@ -7,9 +7,7 @@
 **   Date Started:  February 2001
 **
 **  This is part of the CTSim program
-**  Copyright (C) 1983-2001 Kevin Rosenberg
-**
-**  $Id: backgroundmgr.h,v 1.8 2001/03/05 20:29:23 kevin Exp $
+**  Copyright (C) 1983-2009 Kevin Rosenberg
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 #include "views.h"
 #include "threadrecon.h"
 
-#include <vector>
+#include <list>
 
 #ifdef HAVE_WXTHREADS
 
 class BackgroundManagerCanvas;
+class BackgroundManagerTask;
+
 
-#if CTSIM_MDI
-//class BackgroundManager : public wxMDIChildFrame
-#endif
 class BackgroundManager : public wxMiniFrame
 {
 private:
+
   DECLARE_DYNAMIC_CLASS(BackgroundManager)
 
   wxCriticalSection m_criticalSection;
   BackgroundManagerCanvas* m_pCanvas;
   int m_iNumTasks;
 
-  typedef std::vector<BackgroundSupervisor*> TaskContainer;
-  typedef std::vector<wxGauge*>  GaugeContainer;
-  typedef std::vector<std::string*> StringContainer;
-  typedef std::vector<int> PositionContainer;
-  typedef std::vector<wxStaticText*>  LabelContainer;
-  typedef std::vector<wxButton*> ButtonContainer;
-  TaskContainer m_vecpBackgroundTasks;
-  GaugeContainer m_vecpGauges;
-  StringContainer m_vecpNames;
-  PositionContainer m_vecpPositions;
-  LabelContainer m_vecpLabels;
-  ButtonContainer m_vecpCancelButtons;
+  typedef std::list<BackgroundManagerTask*> TaskContainer;
+  TaskContainer m_vecpTasks;
+
+  void resizeWindow();
+  BackgroundManagerTask* lookupTask (BackgroundSupervisor* pSupervisor);
+  BackgroundManagerTask* lookupTask (int iButtonID);
+
+  static int s_iNextButtonID;
+
   wxSize m_sizeGauge;
   wxSize m_sizeLabel;
   wxSize m_sizeCell;
@@ -79,18 +74,9 @@ private:
   wxSize m_sizeCellSpacing;
   wxSize m_sizeButton;
 
-  void resizeWindow();
-  wxGauge* lookupGauge(BackgroundSupervisor* pTask);
-
 public:
   BackgroundManager ();
-
-  TaskContainer& getTasks() { return m_vecpBackgroundTasks;}
-  GaugeContainer& getGauges() { return m_vecpGauges;}
-  StringContainer& getNames() { return m_vecpNames;}
-  PositionContainer& getPositions() { return m_vecpPositions;}
-  LabelContainer& getLabels() { return m_vecpLabels;}
-  ButtonContainer& getCancelButtons() { return m_vecpCancelButtons;}
+  ~BackgroundManager();
 
   void OnAddTask (wxCommandEvent& event);
   void OnRemoveTask (wxCommandEvent& event);
@@ -102,6 +88,35 @@ public:
 };
 
 
+class BackgroundSupervisor;
+class BackgroundManagerTask {
+private:
+  BackgroundSupervisor* m_pSupervisor;
+  const std::string m_strName;
+  const int m_iPosition;
+  wxGauge* m_pGauge;
+  wxStaticText* m_pLabel;
+  wxButton* m_pButton;
+  const int m_iButtonID;
+
+public:
+  BackgroundManagerTask (BackgroundSupervisor* pSupervisor, const char* const pszName, int iPos,
+          wxGauge* pGauge, wxStaticText* pLabel, wxButton* pButton, int iButtonID)
+          : m_pSupervisor(pSupervisor), m_strName(pszName), m_iPosition(iPos), m_pGauge(pGauge),
+    m_pLabel(pLabel), m_pButton(pButton), m_iButtonID(iButtonID)
+  {}
+
+  int position() const {return m_iPosition;}
+  const std::string& name() const {return m_strName;}
+  BackgroundSupervisor* supervisor() {return m_pSupervisor;}
+
+  wxGauge* gauge() {return m_pGauge;}
+  wxStaticText* label() {return m_pLabel;}
+  wxButton* button() {return m_pButton;}
+  int buttonID() const {return m_iButtonID;}
+};
+
+
 class BackgroundManagerCanvas : public wxPanel {
 private:
   DECLARE_DYNAMIC_CLASS(BackgroundManagerCanvas)
@@ -109,9 +124,7 @@ private:
 
 public:
   BackgroundManagerCanvas (BackgroundManager* pBkgdMgr = NULL);
-#if 0
-  void OnPaint (wxPaintEvent& event);
-#endif
+
   DECLARE_EVENT_TABLE()
 };