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

Last change on this file since 46 was 46, checked in by guyru, 6 years ago

started dice animation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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("Settins 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        button_3 = new wxToggleButton(this, ID_RESETHIGHSCORE, wxT("reset high-score table"));
39        button_1 = new wxButton(this, wxID_OK);
40        button_2 = new wxButton(this, wxID_CANCEL);
41        animate_checkbox = new wxCheckBox(this, ID_ANIMATECHECKBOX, wxT("Animate dices"));
42
43        set_properties();
44        do_layout();
45        // end wxGlade
46}
47
48BEGIN_EVENT_TABLE( SettingsDialog, wxDialog)
49        EVT_TOGGLEBUTTON(ID_RESETHIGHSCORE, SettingsDialog::OnResetHighScore)
50END_EVENT_TABLE();
51
52void SettingsDialog::set_properties()
53{
54    // begin wxGlade: SettingsDialog::set_properties
55    //SetTitle(wxT("Settings Dialog")); /*unneeded anymore -guy*/
56    //button_1->SetDefault();/*unneeded anymore -guy*/
57    // end wxGlade
58}
59
60
61void SettingsDialog::do_layout()
62{
63        wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
64        wxBoxSizer* sizer_2 = new wxBoxSizer(wxHORIZONTAL);
65        wxBoxSizer* highscoresizer = new wxBoxSizer(wxHORIZONTAL);
66        highscoresizer->Add(label_1, 0, wxALL|wxADJUST_MINSIZE, 10);
67        highscoresizer->Add(spin_ctrl, 0, wxALL|wxADJUST_MINSIZE, 10);
68        top_sizer->Add(highscoresizer, 0, 0, 0);
69        top_sizer->Add(button_3, 0,wxALL|wxALIGN_RIGHT|wxADJUST_MINSIZE, 10);
70
71        top_sizer->Add(animate_checkbox,0,wxALL,10);
72
73        sizer_2->Add(button_1, 0, wxALL|wxADJUST_MINSIZE, 10);
74        sizer_2->Add(button_2, 0, wxALL|wxADJUST_MINSIZE, 10);
75        top_sizer->Add(sizer_2, 1, 0, 0);
76        SetAutoLayout(true);
77        SetSizer(top_sizer);
78        top_sizer->Fit(this);
79        top_sizer->SetSizeHints(this);
80        Layout();
81}
82
83
84void SettingsDialog::OnResetHighScore(wxCommandEvent& event)
85{
86        if(!button_3->GetValue()){
87                button_3->SetValue(0);
88                return;
89        }
90       
91        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!\nThe new high-score table size will be as specified in this dialog."),wxT("High-score table reset"),wxYES_NO|wxICON_EXCLAMATION);
92
93        if(answer==wxNO)
94                button_3->SetValue(0);
95}
96
97void SettingsDialog::SetData(SettingsDialogData data)
98{
99        spin_ctrl->SetValue(data.highscoresize);
100        animate_checkbox->SetValue(data.animate);
101}
102
103SettingsDialogData SettingsDialog::GetData()
104{
105        SettingsDialogData data;
106        data.highscoresize = spin_ctrl->GetValue();
107        data.reset = button_3->GetValue();
108        data.animate = animate_checkbox->GetValue();
109        return data;
110}
Note: See TracBrowser for help on using the repository browser.