Changeset 167 for trunk/src/highscores_dialog.cpp
- Timestamp:
- 10/03/2008 07:39:43 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/highscores_dialog.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/highscores_dialog.cpp
r166 r167 68 68 void HighscoresDialog::loadData() 69 69 { 70 highscoreslist->DeleteAllItems(); 70 71 const configuration::HighscoresList *list = m_config->getHighscores(); 71 72 … … 110 111 top_sizer->Add(highscoreslist, 1, wxALL, 10); 111 112 112 top_sizer->Add( 113 new wxButton(this,wxID_CLOSE), 114 0, //no streching 115 wxALL, //we want border around everything 116 10); 117 118 SetAutoLayout(true); 113 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); 114 115 wxSizerFlags flags = wxSizerFlags().Border(wxALL & ~wxLEFT, 10); 116 117 button_sizer->AddStretchSpacer(); 118 button_sizer->Add(new wxButton(this,wxID_CLEAR),flags); 119 button_sizer->Add(new wxButton(this,ID_CONFIGURE,wxT("Configure")),flags); 120 button_sizer->Add( new wxButton(this,wxID_CLOSE), flags); 121 122 top_sizer->Add(button_sizer,0,wxEXPAND); 123 119 124 SetSizer(top_sizer); 120 121 top_sizer->Fit(this);122 125 top_sizer->SetSizeHints(this); 123 124 Layout();125 126 } 126 127 … … 129 130 { 130 131 Connect(wxID_CLOSE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(HighscoresDialog::onClose)); 131 } 132 132 133 Connect(wxID_CLEAR, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(HighscoresDialog::onClear)); 134 Connect(ID_CONFIGURE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(HighscoresDialog::onConfigure)); 135 } 133 136 void HighscoresDialog::onClose(wxCommandEvent& event) 134 137 { … … 136 139 } 137 140 141 void HighscoresDialog::onConfigure(wxCommandEvent& event) 142 { 143 HighscoresSettingsDialog *dialog = new HighscoresSettingsDialog(this, m_config); 144 145 if (dialog->ShowModal() == wxID_OK) { 146 loadData(); 147 } 148 149 delete dialog; 150 } 151 152 void HighscoresDialog::onClear(wxCommandEvent& event) 153 { 154 int answer = wxMessageBox( 155 wxT("Are you sure you want to clear the Highscores table?\nThis action cannot be reversed."), 156 wxT("Are You Sure?"), 157 wxYES | wxNO, 158 this); 159 160 if (answer == wxYES) { 161 m_config->clearHighscores(); 162 loadData(); 163 } 164 } 165 166 167 HighscoresSettingsDialog::HighscoresSettingsDialog(wxWindow* parent, configuration::Configuration* config) : 168 wxDialog(parent, wxID_ANY, wxT("Highscores Table Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) 169 { 170 this->m_config = config; 171 doLayout(); 172 173 Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(HighscoresSettingsDialog::onOk)); 174 } 175 176 void HighscoresSettingsDialog::doLayout() 177 { 178 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); 179 180 wxBoxSizer* size_sizer = new wxBoxSizer(wxHORIZONTAL); 181 182 size_sizer->Add(new wxStaticText(this, wxID_ANY, wxT("High score table size:")), wxSizerFlags().Border(wxALL,10)); 183 184 int size = atoi(m_config->get("highscore-list-size").c_str()); 185 spin_ctrl = new wxSpinCtrl(this, wxID_ANY); 186 spin_ctrl->SetRange(10,200); 187 spin_ctrl->SetValue(size); 188 189 size_sizer->Add(spin_ctrl,wxSizerFlags().Border(wxALL & ~wxLEFT,10)); 190 191 top_sizer->Add(size_sizer); 192 top_sizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 1, wxBOTTOM, 10); 193 194 SetSizer(top_sizer); 195 top_sizer->SetSizeHints(this); 196 } 197 198 void HighscoresSettingsDialog::onOk(wxCommandEvent& event) { 199 int size = spin_ctrl->GetValue(); 200 m_config->setHighscoresSize(size); 201 event.Skip(); 202 }
Note: See TracChangeset
for help on using the changeset viewer.
