source: trunk/OpenYahtzee/src/SettingsDialog.cpp @ 51

Last change on this file since 51 was 51, checked in by guyru, 8 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1// $Header$
2/***************************************************************************
3 *   Copyright (C) 2006 by Guy Rutenberg   *
4 *   guy@Guy_Computer   *
5 *                                                                         *
6 *   This program is free software; you can redistribute it and/or modify  *
7 *   it under the terms of the GNU General Public License as published by  *
8 *   the Free Software Foundation; either version 2 of the License, or     *
9 *   (at your option) any later version.                                   *
10 *                                                                         *
11 *   This program is distributed in the hope that it will be useful,       *
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14 *   GNU General Public License for more details.                          *
15 *                                                                         *
16 *   You should have received a copy of the GNU General Public License     *
17 *   along with this program; if not, write to the                         *
18 *   Free Software Foundation, Inc.,                                       *
19 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20 ***************************************************************************/
21
22// -*- C++ -*- generated by wxGlade 0.4 on Wed Oct 11 10:39:57 2006
23//this file was originally base on the output of wxGlades but i had to make many changes - Guy
24
25#include "SettingsDialog.h"
26#include "MainFrame.h"
27
28#include "Icon.h"
29
30SettingsDialog::SettingsDialog(wxWindow* parent, int id):
31    wxDialog(parent, wxID_ANY, wxT("Settings Dialog"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
32{
33
34        SetIcon(wxIcon(ICON));
35
36        label_1 = new wxStaticText(this, -1, wxT("High score table size:"));
37        spin_ctrl = new wxSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS,0,1024,20);
38        checkbox_reset = new wxCheckBox(this, ID_RESETHIGHSCORE, wxT("Reset high score table"));
39        animate_checkbox = new wxCheckBox(this, ID_ANIMATECHECKBOX, wxT("Animate dice"));
40
41        connect_event_table();
42        do_layout();
43        // end wxGlade
44}
45
46
47void SettingsDialog::connect_event_table()
48{
49   Connect(ID_RESETHIGHSCORE,wxEVT_COMMAND_CHECKBOX_CLICKED,wxCommandEventHandler(SettingsDialog::OnResetHighScore));
50}
51
52
53void SettingsDialog::do_layout()
54{
55        wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
56        wxBoxSizer* highscoresizer = new wxBoxSizer(wxHORIZONTAL);
57
58        highscoresizer->Add(label_1, 0, wxALL|wxADJUST_MINSIZE, 5);
59        highscoresizer->Add(spin_ctrl, 0, wxALL|wxADJUST_MINSIZE, 5);
60        top_sizer->Add(highscoresizer, 0, 0, 0);
61        top_sizer->Add(checkbox_reset, 0,wxALL, 5);
62
63        top_sizer->Add(animate_checkbox,0,wxALL,5);
64
65        top_sizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 1, wxBOTTOM, 10);
66        SetAutoLayout(true);
67        SetSizer(top_sizer);
68        top_sizer->Fit(this);
69        top_sizer->SetSizeHints(this);
70        Layout();
71}
72
73
74void SettingsDialog::OnResetHighScore(wxCommandEvent& event)
75{
76        if(!checkbox_reset->GetValue()){
77                checkbox_reset->SetValue(0);
78                return;
79        }
80       
81        int answer = wxMessageBox(wxT("Are you sure you want to reset the high score table? After reseting the high score table, you won't be able to restore it!\n\nThe new high score table size will be as specified in this dialog."),wxT("High-score table reset"),wxYES_NO|wxICON_EXCLAMATION,this);
82
83        if(answer==wxNO)
84                checkbox_reset->SetValue(0);
85}
86
87void SettingsDialog::SetData(SettingsDialogData data)
88{
89        spin_ctrl->SetValue(data.highscoresize);
90        animate_checkbox->SetValue(data.animate);
91}
92
93SettingsDialogData SettingsDialog::GetData()
94{
95        SettingsDialogData data;
96        data.highscoresize = spin_ctrl->GetValue();
97        data.reset = checkbox_reset->GetValue();
98        data.animate = animate_checkbox->GetValue();
99        return data;
100}
Note: See TracBrowser for help on using the repository browser.