0
|
1 // Filename: adddialog.cpp
|
1
|
2 // Last Change: 2015-09-13 Sun 14:34:28.
|
0
|
3 //
|
1
|
4 #include <wx/valgen.h>
|
|
5 #include <wx/valtext.h>
|
0
|
6
|
|
7 #include "adddialog.h"
|
|
8
|
|
9 AddDialog::AddDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
10 : wxDialog( parent, id, title, pos, size, style )
|
|
11 {
|
|
12 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
13
|
|
14 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
15
|
1
|
16 m_staticText = new wxStaticText( this, wxID_ANY, wxT("Specify Empty text to Use user input(Ctrl-c).\nDescription is option."), wxDefaultPosition, wxDefaultSize, 0 );
|
|
17 bSizerTop->Add( m_staticText, 0, wxALL|wxEXPAND, 5 );
|
0
|
18
|
|
19 wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 0, 3, 0, 0 );
|
|
20 fgSizer->SetFlexibleDirection( wxBOTH );
|
|
21 fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
22
|
|
23 m_staticTextText = new wxStaticText( this, wxID_ANY, wxT("Text"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
24 fgSizer->Add( m_staticTextText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
|
25
|
|
26 m_textCtrlText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
27 fgSizer->Add( m_textCtrlText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
28
|
|
29 m_staticTextText2 = new wxStaticText( this, wxID_ANY, wxT("Strings to paste"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
30 fgSizer->Add( m_staticTextText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
31
|
1
|
32 m_staticTextOverwrite = new wxStaticText( this, wxID_ANY, wxT("Overwrite"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
33 fgSizer->Add( m_staticTextOverwrite, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
|
|
34
|
|
35 m_checkBoxOverwrite = new wxCheckBox( this, ID_CKOW, wxT("allow change"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
36 fgSizer->Add( m_checkBoxOverwrite, 0, wxALL, 5 );
|
0
|
37
|
1
|
38 m_staticTextOverwrite2 = new wxStaticText( this, wxID_ANY, wxT("Check if allow change by user"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
39 fgSizer->Add( m_staticTextOverwrite2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
40
|
1
|
41 m_staticTextMaxLive = new wxStaticText( this, wxID_ANY, wxT("Max LT"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
42 fgSizer->Add( m_staticTextMaxLive, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
0
|
43
|
1
|
44 m_spinCtrlMaxLive = new wxSpinCtrl( this, ID_SPNML, wxT("5"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 28800, 0 );
|
|
45 fgSizer->Add( m_spinCtrlMaxLive, 0, wxALL, 5 );
|
|
46
|
|
47 m_staticTextMaxLive2 = new wxStaticText( this, wxID_ANY, wxT("Maximum live time"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
48 fgSizer->Add( m_staticTextMaxLive2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
49
|
1
|
50 m_staticTextMaxActive = new wxStaticText( this, wxID_ANY, wxT("Max AT"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
51 fgSizer->Add( m_staticTextMaxActive, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
0
|
52
|
1
|
53 m_spinCtrlMaxActive = new wxSpinCtrl( this, ID_SPNMA, wxT("5"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 28800, 0 );
|
|
54 fgSizer->Add( m_spinCtrlMaxActive, 0, wxALL, 5 );
|
|
55
|
|
56 m_staticTextMaxActive2 = new wxStaticText( this, wxID_ANY, wxT("Maximum active time"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
57 fgSizer->Add( m_staticTextMaxActive2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
58
|
0
|
59 m_staticTextDesc = new wxStaticText( this, wxID_ANY, wxT("Desc"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
60 fgSizer->Add( m_staticTextDesc, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
|
61
|
|
62 m_textCtrlDesc = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
63 fgSizer->Add( m_textCtrlDesc, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
64
|
|
65 m_staticTextDesc2 = new wxStaticText( this, wxID_ANY, wxT("Description"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
66 fgSizer->Add( m_staticTextDesc2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
67
|
|
68 bSizerTop->Add( fgSizer, 1, wxEXPAND, 5 );
|
|
69
|
|
70 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
|
|
71
|
|
72 m_buttonAdd = new wxButton( this, wxID_OK, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
73 m_buttonAdd->SetDefault();
|
|
74 bSizerBtn->Add( m_buttonAdd, 0, wxALL, 5 );
|
|
75
|
|
76 m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
77 bSizerBtn->Add( m_buttonCancel, 0, wxALL, 5 );
|
|
78
|
|
79 bSizerTop->Add( bSizerBtn, 0, wxALIGN_RIGHT, 5 );
|
|
80
|
|
81 this->SetSizer( bSizerTop );
|
1
|
82
|
0
|
83 this->Layout();
|
|
84 bSizerTop->Fit( this );
|
|
85
|
|
86 this->Centre( wxBOTH );
|
1
|
87
|
|
88 Init();
|
|
89 SetValidators();
|
0
|
90 }
|
|
91
|
|
92 AddDialog::~AddDialog()
|
|
93 {
|
|
94 }
|
|
95
|
1
|
96 // Event Table
|
|
97 BEGIN_EVENT_TABLE( AddDialog, wxDialog )
|
|
98 EVT_CHECKBOX( ID_CKOW, AddDialog::OnCheckOverwrite )
|
|
99 END_EVENT_TABLE()
|
|
100
|
|
101 /* Event Handlers & Functions */
|
|
102 // Event Handlers
|
|
103 void AddDialog::OnCheckOverwrite( wxCommandEvent& event )
|
|
104 {
|
|
105 if ( event.IsChecked() ) {
|
|
106 m_textCtrlText->Enable( false );
|
|
107 m_textCtrlText->SetValue( wxEmptyString );
|
|
108 m_spinCtrlMaxLive->Enable( true );
|
|
109 }
|
|
110 else {
|
|
111 m_textCtrlText->Enable( true );
|
|
112 m_textCtrlText->SetValue( wxT("Something") );
|
|
113 m_spinCtrlMaxLive->Enable( false );
|
|
114 }
|
|
115 }
|
|
116
|
|
117 // Functions
|
|
118 void AddDialog::Init()
|
|
119 {
|
|
120 m_text = wxT("Something");
|
|
121 m_owrite = false;
|
|
122 m_maxat = 5;
|
|
123 m_maxlt = 20;
|
|
124 m_desc = wxEmptyString;
|
|
125 m_spinCtrlMaxLive->Enable( false );
|
|
126 }
|
|
127
|
|
128 void AddDialog::SetValidators()
|
|
129 {
|
|
130 m_textCtrlText->SetValidator( wxTextValidator( wxFILTER_NONE, &m_text ) );
|
|
131 m_checkBoxOverwrite->SetValidator( wxGenericValidator( &m_owrite ) );
|
|
132 m_spinCtrlMaxLive->SetValidator( wxGenericValidator( &m_maxlt ) );
|
|
133 m_spinCtrlMaxActive->SetValidator( wxGenericValidator( &m_maxat ) );
|
|
134 m_textCtrlDesc->SetValidator( wxTextValidator( wxFILTER_NONE, &m_desc ) );
|
|
135 }
|
|
136
|