NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
grouppanel.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2019 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include "grouppanel.hpp"
20#include "../../kernel/core/ui/language.hpp"
21
22extern Language _guilang;
23#define ELEMENT_BORDER 5
24
35GroupPanel::GroupPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, bool useVerticalSizer) : wxScrolledWindow(parent, id, pos, size, style | wxVSCROLL)
36{
37 verticalSizer = nullptr;
38 horizontalSizer = nullptr;
39
40 // Create the horizontal and the vertical sizers
41 horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
42 verticalSizer = new wxBoxSizer(wxVERTICAL);
43
44 if (useVerticalSizer)
45 {
46 // Add the vertical sizer as a subsizer
47 // of the horizontal sizer
48 horizontalSizer->Add(verticalSizer, 1, wxALIGN_TOP | wxEXPAND | wxALL, 0);
49
50 // Set the horizontal sizer as main
51 // sizer for the panel
52 this->SetSizer(horizontalSizer);
53
55 }
56 else
57 {
58 // Add the horizontal sizer as a subsizer
59 // of the vertical sizer
60 verticalSizer->Add(horizontalSizer, 1, wxALIGN_TOP | wxEXPAND | wxALL, 0);
61
62 // Set the vertical sizer as main
63 // sizer for the panel
64 this->SetSizer(verticalSizer);
65
67 }
68}
69
70
79{
80 return verticalSizer;
81}
82
83
92{
93 return horizontalSizer;
94}
95
96
105{
106 return mainSizer;
107}
108
109
120void GroupPanel::AddSpacer(int nSize, wxSizer* sizer)
121{
122 if (!sizer)
123 sizer = mainSizer;
124
125 sizer->AddSpacer(nSize);
126}
127
128
140wxStaticText* GroupPanel::AddStaticText(wxWindow* parent, wxSizer* sizer, const wxString& text, int id, int alignment)
141{
142 wxStaticText* staticText = new wxStaticText(parent, id, text, wxDefaultPosition, wxDefaultSize, 0);
143 sizer->Add(staticText, 0, alignment | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, ELEMENT_BORDER);
144
145 return staticText;
146}
147
148
161wxStaticBoxSizer* GroupPanel::createGroup(const wxString& sGroupName, int orient, wxWindow* parent, wxSizer* sizer, int expand)
162{
163 if (!parent)
164 {
165 parent = this;
166 sizer = mainSizer;
167 }
168
169 // Create a new static box sizer
170 wxStaticBoxSizer* groupSizer = new wxStaticBoxSizer(orient, parent, sGroupName);
171
172 // Add the group to the main sizer
173 sizer->Add(groupSizer, expand, wxEXPAND | wxALL, ELEMENT_BORDER);
174
175 return groupSizer;
176}
177
178
189wxBoxSizer* GroupPanel::createGroup(int orient, wxSizer* sizer, int expand)
190{
191 if (!sizer)
192 sizer = mainSizer;
193
194 // Create a new static box sizer
195 wxBoxSizer* groupSizer = new wxBoxSizer(orient);
196
197 // Add the group to the main sizer
198 sizer->Add(groupSizer, expand, wxEXPAND | wxALL, 0);
199
200 return groupSizer;
201}
202
203
215wxCollapsiblePane* GroupPanel::createCollapsibleGroup(const wxString& label, wxWindow* parent, wxSizer* sizer)
216{
217 if (!parent)
218 {
219 parent = this;
220 sizer = mainSizer;
221 }
222
223 wxCollapsiblePane* collpane = new wxCollapsiblePane(parent, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, wxCP_NO_TLW_RESIZE | wxCP_DEFAULT_STYLE);
224
225 // add the pane with a zero proportion value to the sizer which contains it
226 sizer->Add(collpane, 1, wxEXPAND | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 1);
227
228 return collpane;
229}
230
231
245wxTextCtrl* GroupPanel::CreatePathInput(wxWindow* parent, wxSizer* sizer, const wxString& description, int buttonID, int id)
246{
247 // Create the text above the input line
248 wxStaticText* inputStaticText = new wxStaticText(parent, wxID_STATIC, description, wxDefaultPosition, wxDefaultSize, 0);
249 sizer->Add(inputStaticText, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, ELEMENT_BORDER);
250
251 // Create a horizontal sizer for the input
252 // line and the buttoon
253 wxBoxSizer* hSizer = new wxBoxSizer(wxHORIZONTAL);
254 sizer->Add(hSizer, wxALIGN_LEFT);
255
256 // Create the input line
257 wxTextCtrl* textCtrl = new wxTextCtrl(parent, id, wxEmptyString, wxDefaultPosition, wxSize(310, -1), wxTE_PROCESS_ENTER);
258
259 // Create the button
260 wxButton* button = new wxButton(parent, buttonID, _guilang.get("GUI_OPTIONS_CHOOSE"));
261
262 // Add both to the horizontal sizer
263 hSizer->Add(textCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, ELEMENT_BORDER);
264 hSizer->Add(button, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, ELEMENT_BORDER);
265
266 return textCtrl;
267}
268
269
285TextField* GroupPanel::CreateTextInput(wxWindow* parent, wxSizer* sizer, const wxString& description, const wxString& sDefault, int nStyle, int id, const wxSize& size, int alignment)
286{
287 wxStaticText* inputStaticText = nullptr;
288 // Create the text above the input line, if it exists
289 if (description.length())
290 {
291 inputStaticText = new wxStaticText(parent, wxID_STATIC, description, wxDefaultPosition, wxDefaultSize, 0);
292 sizer->Add(inputStaticText, 0, alignment | wxLEFT | wxTOP | wxRIGHT | wxADJUST_MINSIZE | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
293 }
294
295 // Create the input line
296 TextField* textCtrl = new TextField(parent, id, sDefault, size, nStyle);
297 textCtrl->m_label = inputStaticText;
298 sizer->Add(textCtrl, 0, alignment | wxALL | wxEXPAND | wxFIXED_MINSIZE | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
299
300 return textCtrl;
301}
302
303
316wxCheckBox* GroupPanel::CreateCheckBox(wxWindow* parent, wxSizer* sizer, const wxString& description, int id, int alignment)
317{
318 // Create the checkbox and assign it to the passed sizer
319 wxCheckBox* checkBox = new wxCheckBox(parent, id, description, wxDefaultPosition, wxDefaultSize, 0);
320 sizer->Add(checkBox, 0, alignment | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
321
322 return checkBox;
323}
324
325
342SpinBut* GroupPanel::CreateSpinControl(wxWindow* parent, wxSizer* sizer, const wxString& description, int nMin, int nMax, int nInitial, int id, int alignment)
343{
344 // Create a horizontal sizer for the
345 // spin control and its assigned text
346 wxBoxSizer* spinCtrlSizer = new wxBoxSizer(wxHORIZONTAL);
347 sizer->Add(spinCtrlSizer, 0, alignment | wxALL, ELEMENT_BORDER);
348
349 // Create the spin control
350 SpinBut* spinCtrl = new SpinBut(parent, id, wxSize(60, -1), nMin, nMax, nInitial);
351
352 // Create the assigned static text
353 wxStaticText* spinCtrlStaticText = new wxStaticText(parent, wxID_STATIC, description, wxDefaultPosition, wxDefaultSize, 0);
354 spinCtrl->m_label = spinCtrlStaticText;
355
356 // Add both to the horizontal sizer
357 spinCtrlSizer->Add(spinCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 0);
358 spinCtrlSizer->Add(spinCtrlStaticText, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxADJUST_MINSIZE | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 3);
359
360 return spinCtrl;
361}
362
363
376wxListView* GroupPanel::CreateListView(wxWindow* parent, wxSizer* sizer, int nStyle /*= wxLC_REPORT*/, wxSize size /*= wxDefaultSize*/, int id)
377{
378 // Create the listview and assign it to the passed sizer
379 wxListView* listView = new wxListView(parent, id, wxDefaultPosition, size, nStyle);
380 sizer->Add(listView, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND | wxFIXED_MINSIZE, ELEMENT_BORDER);
381
382 return listView;
383}
384
385
399wxTreeListCtrl* GroupPanel::CreateTreeListCtrl(wxWindow* parent, wxSizer* sizer, int nStyle, wxSize size, int id, int alignment)
400{
401 // Create the listview and assign it to the passed sizer
402 wxTreeListCtrl* listCtrl = new wxTreeListCtrl(parent, id, wxDefaultPosition, size, nStyle);
403 listCtrl->SetMinClientSize(wxSize(100,200));
404 sizer->Add(listCtrl, 1, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
405
406 return listCtrl;
407}
408
409
424wxcode::wxTreeListCtrl* GroupPanel::CreateWxcTreeListCtrl(wxWindow* parent, wxSizer* sizer, int nStyle, wxSize size, int id, int alignment)
425{
426 // Create the listview and assign it to the passed sizer
427 wxcode::wxTreeListCtrl* listCtrl = new wxcode::wxTreeListCtrl(parent, id, wxDefaultPosition, size, nStyle);
428 listCtrl->SetMinClientSize(wxSize(100,200));
429 sizer->Add(listCtrl, 1, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
430
431 return listCtrl;
432}
433
434
447wxButton* GroupPanel::CreateButton(wxWindow* parent, wxSizer* sizer, const wxString& description, int id, int alignment)
448{
449 wxButton* button = new wxButton(parent, id, description);
450
451 if (sizer == mainSizer)
452 sizer->Add(button, 0, alignment | wxALL | wxFIXED_MINSIZE | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
453 else
454 sizer->Add(button, 1, alignment | wxALL | wxFIXED_MINSIZE | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
455
456 return button;
457}
458
459
474wxRadioBox* GroupPanel::CreateRadioBox(wxWindow* parent, wxSizer* sizer, const wxString& description, const wxArrayString& choices, int style, int id, int alignment)
475{
476 wxRadioBox* box = new wxRadioBox(parent, id, description, wxDefaultPosition, wxDefaultSize, choices, 0, style);
477 sizer->Add(box, 0, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
478
479 return box;
480}
481
482
495wxChoice* GroupPanel::CreateChoices(wxWindow* parent, wxSizer*sizer, const wxArrayString& choices, int id, int alignment)
496{
497 wxChoice* box = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize, choices);
498
499 if (dynamic_cast<wxBoxSizer*>(sizer) && dynamic_cast<wxBoxSizer*>(sizer)->GetOrientation() == wxHORIZONTAL)
500 sizer->Add(box, 1, alignment | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
501 else
502 sizer->Add(box, 0, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
503
504 return box;
505}
506
507
520wxComboBox* GroupPanel::CreateComboBox(wxWindow* parent, wxSizer*sizer, const wxArrayString& choices, int id, int alignment)
521{
522 wxComboBox* box = new wxComboBox(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, choices);
523
524 if (dynamic_cast<wxBoxSizer*>(sizer) && dynamic_cast<wxBoxSizer*>(sizer)->GetOrientation() == wxHORIZONTAL)
525 sizer->Add(box, 1, alignment | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
526 else
527 sizer->Add(box, 0, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
528
529 return box;
530}
531
532
545wxGauge* GroupPanel::CreateGauge(wxWindow* parent, wxSizer*sizer, int style, int id, int alignment)
546{
547 wxGauge* gauge = new wxGauge(parent, id, 100, wxDefaultPosition, wxDefaultSize, style);
548 sizer->Add(gauge, 0, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
549
550 return gauge;
551}
552
553
566wxStaticBitmap* GroupPanel::CreateBitmap(wxWindow* parent, wxSizer* sizer, const wxString& filename, int id, int alignment)
567{
568 wxStaticBitmap* bitmap = new wxStaticBitmap(parent, id, wxBitmap(filename, wxBITMAP_TYPE_ANY));
569 sizer->Add(bitmap, 0, alignment | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
570
571 return bitmap;
572}
573
574
590wxSlider* GroupPanel::CreateSlider(wxWindow* parent, wxSizer* sizer, int nMin, int nMax, int nInitial, int style, int id, int alignment)
591{
592 wxSlider* slider = new wxSlider(parent, id, nInitial, nMin, nMax, wxDefaultPosition, wxDefaultSize, style);
593 sizer->Add(slider, 0, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, ELEMENT_BORDER);
594
595 return slider;
596}
597
wxStaticText * AddStaticText(wxWindow *parent, wxSizer *sizer, const wxString &text, int id=wxID_STATIC, int alignment=wxALIGN_CENTER_VERTICAL)
Add some static test to the current sizer and window.
Definition: grouppanel.cpp:140
wxBoxSizer * mainSizer
Definition: grouppanel.hpp:192
wxListView * CreateListView(wxWindow *parent, wxSizer *sizer, int nStyle=wxLC_REPORT, wxSize size=wxDefaultSize, int id=wxID_ANY)
This member function creates the layout for a listview control.
Definition: grouppanel.cpp:376
wxGauge * CreateGauge(wxWindow *parent, wxSizer *sizer, int style, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a progress bar.
Definition: grouppanel.cpp:545
wxStaticBitmap * CreateBitmap(wxWindow *parent, wxSizer *sizer, const wxString &filename, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a static bitmap.
Definition: grouppanel.cpp:566
SpinBut * CreateSpinControl(wxWindow *parent, wxSizer *sizer, const wxString &description, int nMin, int nMax, int nInitial, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a spin control including the assigned text.
Definition: grouppanel.cpp:342
wxTreeListCtrl * CreateTreeListCtrl(wxWindow *parent, wxSizer *sizer, int nStyle=wxTL_SINGLE, wxSize size=wxDefaultSize, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a treelist control.
Definition: grouppanel.cpp:399
wxTextCtrl * CreatePathInput(wxWindow *parent, wxSizer *sizer, const wxString &description, int buttonID, int id=wxID_ANY)
This member function creates the layout for a path input dialog including the "choose" button.
Definition: grouppanel.cpp:245
void AddSpacer(int nSize=10, wxSizer *sizer=nullptr)
Add extra space between the last added (main) element and the next element to be added.
Definition: grouppanel.cpp:120
wxChoice * CreateChoices(wxWindow *parent, wxSizer *sizer, const wxArrayString &choices, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a dropdown list.
Definition: grouppanel.cpp:495
wxRadioBox * CreateRadioBox(wxWindow *parent, wxSizer *sizer, const wxString &description, const wxArrayString &choices, int style=wxHORIZONTAL, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a radio box.
Definition: grouppanel.cpp:474
wxBoxSizer * horizontalSizer
Definition: grouppanel.hpp:191
wxcode::wxTreeListCtrl * CreateWxcTreeListCtrl(wxWindow *parent, wxSizer *sizer, int nStyle=wxTR_TWIST_BUTTONS|wxTR_FULL_ROW_HIGHLIGHT|wxTR_EXTENDED, wxSize size=wxDefaultSize, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a treelist control in the wxCode variant.
Definition: grouppanel.cpp:424
wxSlider * CreateSlider(wxWindow *parent, wxSizer *sizer, int nMin, int nMax, int nInitial, int style, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a slider.
Definition: grouppanel.cpp:590
wxCheckBox * CreateCheckBox(wxWindow *parent, wxSizer *sizer, const wxString &description, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a usual checkbox.
Definition: grouppanel.cpp:316
wxBoxSizer * getMainSizer()
Return the pointer to the current main layout sizer.
Definition: grouppanel.cpp:104
wxStaticBoxSizer * createGroup(const wxString &sGroupName, int orient=wxVERTICAL, wxWindow *parent=nullptr, wxSizer *sizer=nullptr, int expand=0)
Member function to create a group (a static box with a label) in the panel.
Definition: grouppanel.cpp:161
wxComboBox * CreateComboBox(wxWindow *parent, wxSizer *sizer, const wxArrayString &choices, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a combobox.
Definition: grouppanel.cpp:520
wxBoxSizer * getVerticalSizer()
Return the pointer to the vertical sizer.
Definition: grouppanel.cpp:78
wxBoxSizer * getHorizontalSizer()
Return the pointer to the horizontal sizer.
Definition: grouppanel.cpp:91
wxCollapsiblePane * createCollapsibleGroup(const wxString &label, wxWindow *parent=nullptr, wxSizer *sizer=nullptr)
Member function to create a collapsible group.
Definition: grouppanel.cpp:215
wxButton * CreateButton(wxWindow *parent, wxSizer *sizer, const wxString &description, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a button.
Definition: grouppanel.cpp:447
TextField * CreateTextInput(wxWindow *parent, wxSizer *sizer, const wxString &description, const wxString &sDefault=wxEmptyString, int nStyle=0, int id=wxID_ANY, const wxSize &size=wxSize(310,-1), int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a text input.
Definition: grouppanel.cpp:285
GroupPanel(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, bool useVerticalSizer=true)
Constructor.
Definition: grouppanel.cpp:35
wxBoxSizer * verticalSizer
Definition: grouppanel.hpp:190
This class handles the internal language system and returns the language strings of the selected lang...
Definition: language.hpp:38
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
Definition: language.cpp:292
This class is a extension to the standard wxSpinCtrl to combine it with a read- and changeable label.
Definition: grouppanel.hpp:38
wxStaticText * m_label
Definition: grouppanel.hpp:40
This class is a extension to the standard wxTextCtrl to combine it with a read- and changeable label.
Definition: grouppanel.hpp:113
wxStaticText * m_label
Definition: grouppanel.hpp:115
Language _guilang
#define ELEMENT_BORDER
Definition: grouppanel.cpp:23