1 /****************************************************************************** 2 * src/WMain.h 3 * 4 * The main window dialog class. 5 * 6 ****************************************************************************** 7 * Copyright (C) 2013-2014 Timo Bingmann <tb@panthema.net> 8 * 9 * This program is free software: you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License as published by the Free 11 * Software Foundation, either version 3 of the License, or (at your option) 12 * any later version. 13 * 14 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 * more details. 18 * 19 * You should have received a copy of the GNU General Public License along with 20 * this program. If not, see <http://www.gnu.org/licenses/>. 21 *****************************************************************************/ 22 23 #ifndef WMAIN_H 24 #define WMAIN_H 25 26 #include <wx/wx.h> 27 #include <wx/image.h> 28 29 #include "SortArray.h" 30 #include "WSortView.h" 31 #include "wxg/WMain_wxg.h" 32 33 // ---------------------------------------------------------------------------- 34 // --- Global Constants and Variables 35 36 static const size_t g_framerate = 30; 37 38 // ---------------------------------------------------------------------------- 39 40 class WMain : public WMain_wxg 41 { 42 public: 43 enum { 44 ID_RUN_FINISHED = wxID_HIGHEST + 2000 45 }; 46 47 WMain(wxWindow* parent); 48 ~WMain(); 49 50 /// launch selected algorithm 51 bool RunAlgorithm(); 52 53 /// abort running algorithm 54 void AbortAlgorithm(); 55 56 /// change array size via slider 57 void SetArraySize(size_t pos); 58 59 /// change delay 60 void SetDelay(size_t pos); 61 62 /// change sound sustain 63 void SetSoundSustain(size_t pos); 64 65 public: 66 class RefreshTimer : public wxTimer 67 { 68 WMain& wm; 69 70 public: 71 RefreshTimer(WMain* wmain); 72 virtual void Notify(); 73 }; 74 75 public: 76 virtual void OnRunButton(wxCommandEvent &event); 77 virtual void OnResetButton(wxCommandEvent &event); 78 virtual void OnStepButton(wxCommandEvent &event); 79 virtual void OnSoundButton(wxCommandEvent &event); 80 virtual void OnRandomButton(wxCommandEvent &event); 81 virtual void OnAboutButton(wxCommandEvent &event); 82 virtual void OnSpeedSliderChange(wxScrollEvent &event); 83 virtual void OnSoundSustainSliderChange(wxScrollEvent &event); 84 virtual void OnInversionLabelClick(wxCommandEvent &event); 85 virtual void OnArraySizeSliderChange(wxScrollEvent &event); 86 virtual void OnAlgoList(wxCommandEvent &event); 87 virtual void OnAlgoListDClick(wxCommandEvent &event); 88 89 virtual void OnRunFinished(wxCommandEvent&); 90 91 DECLARE_EVENT_TABLE(); 92 93 public: 94 95 /// g_framerate timer used to refresh the sortview. 96 RefreshTimer* m_reftimer; 97 98 /// the algorithm working thread 99 class SortAlgoThread* m_thread; 100 101 /// true if the algorithm terminates 102 bool m_thread_terminate; 103 104 /// array size selected for new run 105 size_t m_array_size; 106 }; 107 108 #endif // WMAIN_H 109 110 // ---------------------------------------------------------------------------- 111