File: choosestyle.cpp

package info (click to toggle)
jugglemaster 0.4-9
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,632 kB
  • ctags: 1,836
  • sloc: cpp: 7,264; ansic: 160; makefile: 151
file content (80 lines) | stat: -rw-r--r-- 2,370 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * JMDeluxe - Portable JuggleMaster based on wxWindows
 * (C) Gary Briggs 2003
 *
 * JuggleMaster is  free software; you can redistribute  it and/or modify
 * it under the  terms of the GNU General  Public License as published
 * by the Free  Software Foundation; either version 2  of the License,
 * or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
 * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
 * General Public License for more details.
 */ 

#include "choosestyle.h"


BEGIN_EVENT_TABLE(ChooseStyle, wxDialog)
	EVT_BUTTON(wxID_APPLY, ChooseStyle::OnApply)
	EVT_BUTTON(wxID_OK, ChooseStyle::OnOK)
END_EVENT_TABLE()

ChooseStyle::ChooseStyle(wxWindow *parent, JMLib *j)
	: wxDialog(parent, -1, wxT("Change Style"),
			wxDefaultPosition, wxDefaultSize,
			wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) {

  jmlib = j;
  JML_CHAR **style_list;
  int i;

  style_list = jmlib->getStyles();

  stylechoice = new wxChoice ( this,-1,wxDefaultPosition, wxDefaultSize);

  for(i=0;i<jmlib->numStyles();i++) {
	stylechoice->Append(wxString(style_list[i], wxConvUTF8));
  }

  stylechoice->SetSelection(0);

 // Buttons

  wxButton *ok = new wxButton(this, wxID_OK, wxT("OK"));
  wxButton *apply = new wxButton(this, wxID_APPLY, wxT("Apply"));
  wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("Cancel"));
  wxBoxSizer *buttonsizer = new wxBoxSizer(wxHORIZONTAL);
  buttonsizer->Add(ok, 1, wxALIGN_CENTRE|wxALL, 5);
  buttonsizer->Add(apply, 1, wxALIGN_CENTRE|wxALL, 5);
  buttonsizer->Add(cancel, 1, wxALIGN_CENTRE|wxALL, 5);

  wxBoxSizer *toplevel = new wxBoxSizer(wxVERTICAL);
  toplevel->Add(stylechoice,1,wxALIGN_CENTER|wxEXPAND|wxALL,5);
  toplevel->Add(buttonsizer,0,wxALIGN_CENTER|wxEXPAND|wxALL,5);

  toplevel->Fit( this );
  toplevel->SetSizeHints( this );

  SetSizer(toplevel);
  SetAutoLayout(TRUE);
  Layout();
  CentreOnParent();
  ShowModal();
}

void ChooseStyle::ApplySettings() {
  wxString newstyle(stylechoice->GetStringSelection());
  jmlib->setStyle((JML_CHAR *)(const char*)newstyle.mb_str(wxConvUTF8));
}

void ChooseStyle::OnApply(wxCommandEvent &WXUNUSED(event)) {
	ApplySettings();
}

void ChooseStyle::OnOK(wxCommandEvent &WXUNUSED(event)) {
	ApplySettings();
	EndModal(wxID_OK);
}