00001 00011 #ifndef __AGENTSFRAME__H__ 00012 #define __AGENTSFRAME__H__ 00013 00014 #include <wx/wx.h> 00015 #include <vector> 00016 00017 #include "../common.h" 00018 #include "../Matrix.h" 00019 #include "../configs/ConfigProcessor.h" 00020 #include "../objects/Object.h" 00021 #include "Canvas.h" 00022 #include "PaletteWindow.h" 00023 00024 // A part of the GUI 00025 namespace GUI { 00026 00033 class AgentsFrame : public wxFrame { 00034 public: 00039 AgentsFrame(ConfigApplication & config); 00040 00044 ~AgentsFrame(); 00045 00051 void StopSimulation(); 00052 00053 private: 00057 void UpdateUI(); 00062 void CreateScene(ConfigProcessor & configProcessor); 00063 00070 void CreateScene(Matrix::SizeType width, Matrix::SizeType height, 00071 const string & simulationName); 00072 00079 void RefreshSceneWindow(); 00080 00085 void SetSliderPositionAccToInterval(long interval); 00086 00091 void SetStartingWindowSize(ConfigApplication & config); 00092 00096 void CloseScene(); 00097 00102 void CreateMenu(ConfigApplication & config); 00103 00108 void CreateToolbar(bool show = true); 00109 00114 void CreateStatusbar(bool show = true); 00115 00120 void CreatePalette(bool show = true); 00121 00125 void CreateTimer(); 00126 00132 void CreateEmptyPanels(); 00133 00138 void CreateInfoPanels(ConfigApplication & config); 00139 00144 void SetSimulationNameToTitle(const string & simulationName); 00145 00150 string SimulationName2FileName(const string & simulationName) const; 00151 00160 virtual bool ProcessEvent(wxEvent & event); 00161 00165 bool IsToolbarShown() const { 00166 return (GetToolBar() != 0) ? true : false; 00167 } 00168 00172 bool IsStatusbarShown() const { 00173 return (GetStatusBar() != 0) ? true : false; 00174 } 00175 00179 bool IsPaletteShown() const { 00180 return (paletteWindow != 0 && paletteWindow->IsShown()) ? true : false; 00181 } 00182 00186 bool IsSpeedSliderShown() const { 00187 return (panel2 != 0 && panel2->IsShown()) ? true : false; 00188 } 00189 00196 ConfigApplication * GetConfigApplication() const; 00197 00202 void LoadFromConfig(const ConfigApplication & config); 00203 00209 bool CheckSimulationToBeSaved(); 00210 00217 void SetNotHoldingObject() { 00218 if (canvas != 0) { 00219 canvas->SetNotHoldingObject(); 00220 } 00221 } 00222 00226 void ResizeSimulationWindow(); 00227 00228 // Any class wishing to process wxWidgets events must use this macro 00229 DECLARE_EVENT_TABLE() 00230 00231 // Event handlers 00232 void OnWindowClose(wxCloseEvent & event); 00233 void OnSize(wxSizeEvent & event); 00234 void OnExit(wxCommandEvent & event); 00235 void OnNewSimulation(wxCommandEvent & event); 00236 void OnOpenSimulation(wxCommandEvent & event); 00237 void OnCloseSimulation(wxCommandEvent & event); 00238 void OnSaveSimulation(wxCommandEvent & event); 00239 00240 void OnZoomIn(wxCommandEvent & event); 00241 void OnZoomOut(wxCommandEvent & event); 00242 void OnObjectsPallete(wxCommandEvent & event); 00243 void OnMainToolbar(wxCommandEvent & event); 00244 void OnSpeedSlider(wxCommandEvent & event); 00245 void OnStatusBar(wxCommandEvent & event); 00246 00247 void OnStartSimulation(wxCommandEvent & event); 00248 void OnStopSimulation(wxCommandEvent & event); 00249 void OnMakeStep(wxCommandEvent & event); 00250 void OnSimulationSettings(wxCommandEvent & event); 00251 00252 void OnApplicationSettings(wxCommandEvent & event); 00253 00254 void OnHelpContents(wxCommandEvent & event); 00255 void OnAbout(wxCommandEvent & event); 00256 00257 void OnRecenter(wxCommandEvent & event); 00258 void OnTimer(wxTimerEvent& event); 00259 void OnSlider(wxScrollEvent& event); 00260 void OnRubber(wxCommandEvent & event); 00261 void OnMover(wxCommandEvent & event); 00262 00263 // We use two different panels to reduce flicker in wxGTK, because 00264 // some widgets (like wxStaticText) don't have their own X11 window, 00265 // and thus updating the text would result in a refresh of the canvas 00266 // if they belong to the same parent. 00268 wxPanel * panel1; 00270 wxPanel * panel2; 00271 // Sizers 00273 wxBoxSizer * sizer1; 00275 wxBoxSizer * sizer2; 00277 wxBoxSizer * sizer3; 00278 00280 Matrix * matrix; 00282 Canvas * canvas; 00284 wxStaticText * sliderText; 00286 wxTimer * timer; 00288 wxSlider * slider; 00290 bool running; 00291 00293 string paletteDirectoryPath; 00295 PaletteWindow * paletteWindow; 00296 00298 string helpFilePath; 00299 00300 // Constants 00302 static const int MINZOOM = 4; 00304 static const int MAXZOOM = 128; 00306 static const int TIMERCONST = 1000; 00308 static const int SLIDER_DEFAULT = 5; 00310 static const int SLIDER_MIN = 1; 00312 static const int SLIDER_MAX = 10; 00313 // These constants are needed in ResizeSimulationWindow() 00315 static const int SIM_WIDTH_INC = -2; 00317 static const int SIM_HEIGHT_INC = -145; 00319 static const int SIM_TOOLBAR_HEIGHT_INC = 38; 00321 static const int SIM_SPEEDSLIDER_HEIGHT_INC = 48; 00323 static const int SIM_STATUSBAR_HEIGHT_INC = 25; 00324 }; 00325 00326 } /* namespace GUI */ 00327 00328 #endif /* #ifndef __AGENTSFRAME__H__ */ 00329 00330 /* End of file AgentsFrame.h */