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 pathHashDialog.cpp
More file actions
45 lines (43 loc) · 1.6 KB
/
HashDialog.cpp
File metadata and controls
45 lines (43 loc) · 1.6 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
#include "HashDialog.hpp"
#include <wx/valgen.h>
HashDialog::HashDialog(const wxString& title, const MetalinkHash& hash)
: wxDialog(0, wxID_ANY, title), hash_(hash)
{
// Init variables
type_ = hash.type;
value_ = hash.value;
// Create widgets
wxStaticText* label1 = new wxStaticText(this, wxID_ANY, wxT("Type:"));
wxTextCtrl* text1 = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition,
wxDefaultSize, 0, wxTextValidator(wxFILTER_NONE, &type_));
wxStaticText* label2 = new wxStaticText(this, wxID_ANY, wxT("Value:"));
wxTextCtrl* text2 = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition,
wxDefaultSize, 0, wxTextValidator(wxFILTER_NONE, &value_));
// Create FlexGridSizer
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
gridSizer->AddGrowableCol(1);
gridSizer->Add(label1, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
gridSizer->Add(text1, 1, wxEXPAND);
gridSizer->Add(label2, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
gridSizer->Add(text2, 1, wxEXPAND);
// Create button sizer
wxSizer* btnSizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
// Create top sizer
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
topsizer->Add(gridSizer, 0, wxEXPAND | wxALL, 5);
if(btnSizer) {
topsizer->Add(btnSizer, 0, wxEXPAND | wxALL, 5);
}
SetSizerAndFit(topsizer);
Layout();
// Set initial state
SetSize(wxSize(500, -1));
text1->SetFocus();
}
MetalinkHash HashDialog::get_hash() const
{
MetalinkHash hash = hash_;
hash.type = type_;
hash.value = value_;
return hash;
}