This repository was archived by the owner on Jul 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGeneralPanel.cpp
More file actions
73 lines (68 loc) · 2.78 KB
/
GeneralPanel.cpp
File metadata and controls
73 lines (68 loc) · 2.78 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
#include "GeneralPanel.hpp"
#include "common.hpp"
BEGIN_EVENT_TABLE(GeneralPanel, wxScrolledWindow)
EVT_TEXT(ID_Identity, GeneralPanel::on_change)
EVT_TEXT(ID_Description, GeneralPanel::on_change)
EVT_TEXT(ID_Version, GeneralPanel::on_change)
EVT_TEXT(ID_Size, GeneralPanel::on_change)
END_EVENT_TABLE()
GeneralPanel::GeneralPanel(wxWindow* parent, MetalinkEditor& editor)
: wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL),
editor_(editor), ignore_updates_(false)
{
create_widgets();
update();
}
void GeneralPanel::create_widgets()
{
// Create widgets
wxStaticText* label1 = new wxStaticText(this, wxID_ANY, wxT("Identity:"));
txt_identity_ = new wxTextCtrl(this, ID_Identity);
wxStaticText* label2 = new wxStaticText(this, wxID_ANY,
wxT("Description:"));
txt_desc_ = new wxTextCtrl(this, ID_Description);
wxStaticText* label3 = new wxStaticText(this, wxID_ANY, wxT("Version:"));
txt_version_ = new wxTextCtrl(this, ID_Version);
wxStaticText* label4 = new wxStaticText(this, wxID_ANY, wxT("File size:"));
txt_size_ = new wxTextCtrl(this, ID_Size, wxT(""), wxDefaultPosition,
wxDefaultSize, 0, wxTextValidator(wxFILTER_NUMERIC));
// Create FlexGridSizer
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
gridSizer->AddGrowableCol(1);
gridSizer->Add(label1, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
gridSizer->Add(txt_identity_, 1, wxEXPAND);
gridSizer->Add(label2, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
gridSizer->Add(txt_desc_, 1, wxEXPAND);
gridSizer->Add(label3, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
gridSizer->Add(txt_version_, 1, wxEXPAND);
gridSizer->Add(label4, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
gridSizer->Add(txt_size_, 1, wxEXPAND);
// Create top sizer
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
topsizer->Add(gridSizer, 0, wxEXPAND | wxALL, 5);
SetSizer(topsizer);
Layout();
// Set properties
SetScrollRate(5, 5);
}
void GeneralPanel::update()
{
if(ignore_updates_) return;
MetalinkFile file = editor_.get_file();
txt_identity_->ChangeValue(file.get_identity());
txt_desc_->ChangeValue(file.get_description());
txt_version_->ChangeValue(file.get_version());
txt_size_->ChangeValue(file.get_size());
}
void GeneralPanel::on_change(wxCommandEvent& WXUNUSED(event))
{
ignore_updates_ = true;
MetalinkFile file = editor_.get_file();
file.set_identity(txt_identity_->GetValue());
file.set_description(txt_desc_->GetValue());
file.set_version(txt_version_->GetValue());
file.set_size(txt_size_->GetValue());
editor_.set_file(file);
ignore_updates_ = false;
}