-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainform.cpp
More file actions
327 lines (261 loc) · 10.2 KB
/
mainform.cpp
File metadata and controls
327 lines (261 loc) · 10.2 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/////////////////////////////////////////////////////////////////////////////
// Name: mainform.cpp
// Purpose:
// Author: Sergey Talipov
// Modified by:
// Created: 18.03.2025 15:30:26
// RCS-ID:
// Copyright: 15681627-3C745D8E-630127F2
// Licence:
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "mainform.h"
////@begin XPM images
#include "tsnsoft.xpm"
////@end XPM images
/*
* MainForm type definition
*/
IMPLEMENT_CLASS( MainForm, wxFrame )
/*
* MainForm event table definition
*/
BEGIN_EVENT_TABLE( MainForm, wxFrame )
////@begin MainForm event table entries
EVT_LISTBOX( ID_LISTBOX, MainForm::OnListboxSelected )
EVT_CHOICE( ID_CHOICE, MainForm::OnChoiceSelected )
EVT_RADIOBOX( ID_RADIOBOX, MainForm::OnRadioboxSelected )
EVT_CHECKBOX( ID_CHECKBOX, MainForm::OnCheckboxClick )
EVT_BUTTON( ID_BUTTON, MainForm::OnButtonClick )
////@end MainForm event table entries
END_EVENT_TABLE()
/*
* MainForm constructors
*/
MainForm::MainForm()
{
Init();
}
MainForm::MainForm( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
Init();
Create( parent, id, caption, pos, size, style );
}
/*
* MainForm creator
*/
bool MainForm::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin MainForm creation
wxFrame::Create( parent, id, caption, pos, size, style );
CreateControls();
SetIcon(GetIconResource(wxT("tsnsoft.xpm")));
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end MainForm creation
return true;
}
/*
* MainForm destructor
*/
MainForm::~MainForm()
{
////@begin MainForm destruction
////@end MainForm destruction
}
/*
* Member initialisation
*/
void MainForm::Init()
{
////@begin MainForm member initialisation
ListBox1 = NULL;
Choice1 = NULL;
RadioBox1 = NULL;
CheckBox1 = NULL;
StaticText1 = NULL;
////@end MainForm member initialisation
}
/*
* Control creation for MainForm
*/
void MainForm::CreateControls()
{
////@begin MainForm content construction
MainForm* itemFrame1 = this;
wxGridBagSizer* itemGridBagSizer1 = new wxGridBagSizer(0, 0);
itemGridBagSizer1->SetEmptyCellSize(wxSize(10, 19));
itemFrame1->SetSizer(itemGridBagSizer1);
wxArrayString ListBox1Strings;
ListBox1Strings.Add(wxT("C"));
ListBox1Strings.Add(wxT("C++"));
ListBox1Strings.Add(wxT("Java"));
ListBox1Strings.Add(wxT("C#"));
ListBox1Strings.Add(wxT("Python"));
ListBox1Strings.Add(wxT("Delphi"));
ListBox1 = new wxListBox( itemFrame1, ID_LISTBOX, wxDefaultPosition, wxDefaultSize, ListBox1Strings, wxLB_SINGLE );
ListBox1->SetStringSelection(wxT("C++"));
itemGridBagSizer1->Add(ListBox1, wxGBPosition(1, 2), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString Choice1Strings;
Choice1Strings.Add(wxT("C"));
Choice1Strings.Add(wxT("C++"));
Choice1Strings.Add(wxT("Java"));
Choice1Strings.Add(wxT("C#"));
Choice1Strings.Add(wxT("Python"));
Choice1Strings.Add(wxT("Delphi"));
Choice1 = new wxChoice( itemFrame1, ID_CHOICE, wxDefaultPosition, wxDefaultSize, Choice1Strings, 0 );
Choice1->SetStringSelection(wxT("C++"));
itemGridBagSizer1->Add(Choice1, wxGBPosition(2, 2), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString RadioBox1Strings;
RadioBox1Strings.Add(wxT("C"));
RadioBox1Strings.Add(wxT("C++"));
RadioBox1Strings.Add(wxT("Java"));
RadioBox1Strings.Add(wxT("C#"));
RadioBox1Strings.Add(wxT("Python"));
RadioBox1Strings.Add(wxT("Delphi"));
RadioBox1 = new wxRadioBox( itemFrame1, ID_RADIOBOX, wxT("Radiobox"), wxDefaultPosition, wxDefaultSize, RadioBox1Strings, 2, wxRA_SPECIFY_ROWS );
RadioBox1->SetSelection(1);
itemGridBagSizer1->Add(RadioBox1, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
CheckBox1 = new wxCheckBox( itemFrame1, ID_CHECKBOX, wxT("C++"), wxDefaultPosition, wxDefaultSize, 0 );
CheckBox1->SetValue(false);
itemGridBagSizer1->Add(CheckBox1, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
StaticText1 = new wxStaticText( itemFrame1, wxID_STATIC, wxT("Выберите чего-нибудь"), wxDefaultPosition, wxDefaultSize, 0 );
itemGridBagSizer1->Add(StaticText1, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton6 = new wxButton( itemFrame1, ID_BUTTON, wxT("Выход"), wxDefaultPosition, wxDefaultSize, 0 );
itemGridBagSizer1->Add(itemButton6, wxGBPosition(3, 2), wxGBSpan(1, 1), wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
////@end MainForm content construction
}
/*
* Should we show tooltips?
*/
bool MainForm::ShowToolTips()
{
return true;
}
/*
* Get bitmap resources
*/
wxBitmap MainForm::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin MainForm bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end MainForm bitmap retrieval
}
/*
* Get icon resources
*/
wxIcon MainForm::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin MainForm icon retrieval
wxUnusedVar(name);
if (name == wxT("tsnsoft.xpm"))
{
wxIcon icon(tsnsoft_xpm);
return icon;
}
return wxNullIcon;
////@end MainForm icon retrieval
}
/*
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
*/
void MainForm::OnButtonClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in MainForm.
// Before editing this code, remove the block markers.
Destroy();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in MainForm.
}
/*
* wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_LISTBOX
*/
// Обработчик выбора элемента в ListBox
void MainForm::OnListboxSelected( wxCommandEvent& event )
{
int i = ListBox1->GetSelection(); // Получаем индекс выбранного элемента
wxString s = ListBox1->GetString(i); // Получаем строку выбранного элемента
UpdateSelectedValue(s); // Обрабатываем выбор пользователя
}
/*
* wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CHOICE
*/
// Обработчик выбора элемента в Choice (выпадающем списке)
void MainForm::OnChoiceSelected( wxCommandEvent& event )
{
int i = Choice1->GetSelection(); // Получаем индекс выбранного элемента
wxString s = Choice1->GetString(i); // Получаем строку выбранного элемента
UpdateSelectedValue(s); // Обрабатываем выбор пользователя
}
/*
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX
*/
// Обработчик выбора варианта в RadioBox
void MainForm::OnRadioboxSelected( wxCommandEvent& event )
{
int k = RadioBox1->GetSelection(); // Получаем индекс выбранного элемента
wxString s = RadioBox1->GetString(k); // Получаем строку выбранного элемента
UpdateSelectedValue(s); // Обрабатываем выбор пользователя
}
/*
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOX
*/
// Обработчик нажатия на CheckBox
void MainForm::OnCheckboxClick( wxCommandEvent& event )
{
StaticText1->SetBackgroundColour(wxColour(255, 255, 255));
bool b = CheckBox1->GetValue(); // Получаем текущее состояние чекбокса
if (b == true) {
StaticText1->SetLabel(wxString::FromUTF8("Да!")); // Устанавливаем "Да!" если включен
} else {
StaticText1->SetLabel(wxString::FromUTF8("Нет!")); // Устанавливаем "Нет!" если выключен
}
}
// Универсальная функция для обработки выбранного значения
void MainForm::UpdateSelectedValue(const wxString& selectedValue)
{
wxString message;
wxColour backgroundColor;
// Используем switch для определения сообщения и цвета фона
if (selectedValue == wxT("C")) {
message = wxT("C - классика программирования!");
backgroundColor = wxColour(200, 200, 255); // Светло-синий
} else if (selectedValue == wxT("C++")) {
message = wxT("C++ - мощь и производительность!");
backgroundColor = wxColour(200, 255, 200); // Светло-зеленый
} else if (selectedValue == wxT("Java")) {
message = wxT("Java - это круто!");
backgroundColor = wxColour(255, 200, 200); // Светло-красный
} else if (selectedValue == wxT("C#")) {
message = wxT("C# - .NET решение для всего!");
backgroundColor = wxColour(255, 255, 200); // Светло-желтый
} else if (selectedValue == wxT("Python")) {
message = wxT("Python - простота и элегантность!");
backgroundColor = wxColour(200, 255, 255); // Светло-голубой
} else if (selectedValue == wxT("Delphi")) {
message = wxT("Delphi - быстрая разработка приложений!");
backgroundColor = wxColour(255, 200, 255); // Светло-пурпурный
} else {
message = selectedValue;
backgroundColor = wxColour(240, 240, 240); // Стандартный серый
}
// Устанавливаем новый текст и цвет фона
StaticText1->SetLabel(message);
StaticText1->SetBackgroundColour(backgroundColor);
// Заставляем StaticText1 перерисоваться для отображения изменений
StaticText1->Refresh();
}