0
|
1 // Filename: adddialog.cpp
|
3
|
2 // Last Change: 2015-09-23 Wed 19:59:41.
|
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
|
3
|
19 //
|
0
|
20 wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 0, 3, 0, 0 );
|
|
21 fgSizer->SetFlexibleDirection( wxBOTH );
|
|
22 fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
23
|
3
|
24 // Text
|
0
|
25 m_staticTextText = new wxStaticText( this, wxID_ANY, wxT("Text"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
26 fgSizer->Add( m_staticTextText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
|
27
|
|
28 m_textCtrlText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
29 fgSizer->Add( m_textCtrlText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
30
|
|
31 m_staticTextText2 = new wxStaticText( this, wxID_ANY, wxT("Strings to paste"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
32 fgSizer->Add( m_staticTextText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
33
|
3
|
34 // Overwrite
|
1
|
35 m_staticTextOverwrite = new wxStaticText( this, wxID_ANY, wxT("Overwrite"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
36 fgSizer->Add( m_staticTextOverwrite, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
|
|
37
|
|
38 m_checkBoxOverwrite = new wxCheckBox( this, ID_CKOW, wxT("allow change"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
39 fgSizer->Add( m_checkBoxOverwrite, 0, wxALL, 5 );
|
0
|
40
|
1
|
41 m_staticTextOverwrite2 = new wxStaticText( this, wxID_ANY, wxT("Check if allow change by user"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
42 fgSizer->Add( m_staticTextOverwrite2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
43
|
3
|
44 // Max Live Time
|
1
|
45 m_staticTextMaxLive = new wxStaticText( this, wxID_ANY, wxT("Max LT"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
46 fgSizer->Add( m_staticTextMaxLive, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
0
|
47
|
1
|
48 m_spinCtrlMaxLive = new wxSpinCtrl( this, ID_SPNML, wxT("5"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 28800, 0 );
|
|
49 fgSizer->Add( m_spinCtrlMaxLive, 0, wxALL, 5 );
|
|
50
|
|
51 m_staticTextMaxLive2 = new wxStaticText( this, wxID_ANY, wxT("Maximum live time"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
52 fgSizer->Add( m_staticTextMaxLive2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
53
|
3
|
54 // Max Active Time
|
1
|
55 m_staticTextMaxActive = new wxStaticText( this, wxID_ANY, wxT("Max AT"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
56 fgSizer->Add( m_staticTextMaxActive, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
0
|
57
|
1
|
58 m_spinCtrlMaxActive = new wxSpinCtrl( this, ID_SPNMA, wxT("5"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 28800, 0 );
|
|
59 fgSizer->Add( m_spinCtrlMaxActive, 0, wxALL, 5 );
|
|
60
|
|
61 m_staticTextMaxActive2 = new wxStaticText( this, wxID_ANY, wxT("Maximum active time"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
62 fgSizer->Add( m_staticTextMaxActive2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
63
|
3
|
64 // Remember
|
|
65 m_staticTextRemember = new wxStaticText( this, wxID_ANY, wxT("Remember"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
66 fgSizer->Add( m_staticTextRemember, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
|
|
67
|
|
68 m_checkBoxRemember = new wxCheckBox( this, ID_CKOW, wxT("reserve text"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
69 fgSizer->Add( m_checkBoxRemember, 0, wxALL, 5 );
|
|
70
|
|
71 m_staticTextRemember2 = new wxStaticText( this, wxID_ANY, wxT("Check if add text to history"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
72 fgSizer->Add( m_staticTextRemember2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
73
|
|
74 // Description
|
0
|
75 m_staticTextDesc = new wxStaticText( this, wxID_ANY, wxT("Desc"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
76 fgSizer->Add( m_staticTextDesc, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
|
|
77
|
|
78 m_textCtrlDesc = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
79 fgSizer->Add( m_textCtrlDesc, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
80
|
|
81 m_staticTextDesc2 = new wxStaticText( this, wxID_ANY, wxT("Description"), wxDefaultPosition, wxDefaultSize, 0 );
|
1
|
82 fgSizer->Add( m_staticTextDesc2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
0
|
83
|
|
84 bSizerTop->Add( fgSizer, 1, wxEXPAND, 5 );
|
|
85
|
3
|
86 // Buttons
|
0
|
87 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
|
|
88
|
|
89 m_buttonAdd = new wxButton( this, wxID_OK, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
90 m_buttonAdd->SetDefault();
|
|
91 bSizerBtn->Add( m_buttonAdd, 0, wxALL, 5 );
|
|
92
|
|
93 m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
94 bSizerBtn->Add( m_buttonCancel, 0, wxALL, 5 );
|
|
95
|
|
96 bSizerTop->Add( bSizerBtn, 0, wxALIGN_RIGHT, 5 );
|
|
97
|
|
98 this->SetSizer( bSizerTop );
|
1
|
99
|
0
|
100 this->Layout();
|
|
101 bSizerTop->Fit( this );
|
|
102
|
|
103 this->Centre( wxBOTH );
|
1
|
104
|
|
105 Init();
|
|
106 SetValidators();
|
0
|
107 }
|
|
108
|
|
109 AddDialog::~AddDialog()
|
|
110 {
|
|
111 }
|
|
112
|
1
|
113 // Event Table
|
|
114 BEGIN_EVENT_TABLE( AddDialog, wxDialog )
|
|
115 EVT_CHECKBOX( ID_CKOW, AddDialog::OnCheckOverwrite )
|
|
116 END_EVENT_TABLE()
|
|
117
|
|
118 /* Event Handlers & Functions */
|
|
119 // Event Handlers
|
|
120 void AddDialog::OnCheckOverwrite( wxCommandEvent& event )
|
|
121 {
|
|
122 if ( event.IsChecked() ) {
|
|
123 m_textCtrlText->Enable( false );
|
|
124 m_textCtrlText->SetValue( wxEmptyString );
|
|
125 m_spinCtrlMaxLive->Enable( true );
|
|
126 }
|
|
127 else {
|
|
128 m_textCtrlText->Enable( true );
|
|
129 m_textCtrlText->SetValue( wxT("Something") );
|
|
130 m_spinCtrlMaxLive->Enable( false );
|
|
131 }
|
|
132 }
|
|
133
|
|
134 // Functions
|
|
135 void AddDialog::Init()
|
|
136 {
|
|
137 m_text = wxT("Something");
|
|
138 m_owrite = false;
|
|
139 m_maxat = 5;
|
|
140 m_maxlt = 20;
|
3
|
141 m_remember = false;
|
1
|
142 m_desc = wxEmptyString;
|
|
143 m_spinCtrlMaxLive->Enable( false );
|
|
144 }
|
|
145
|
|
146 void AddDialog::SetValidators()
|
|
147 {
|
|
148 m_textCtrlText->SetValidator( wxTextValidator( wxFILTER_NONE, &m_text ) );
|
|
149 m_checkBoxOverwrite->SetValidator( wxGenericValidator( &m_owrite ) );
|
|
150 m_spinCtrlMaxLive->SetValidator( wxGenericValidator( &m_maxlt ) );
|
|
151 m_spinCtrlMaxActive->SetValidator( wxGenericValidator( &m_maxat ) );
|
3
|
152 m_checkBoxRemember->SetValidator( wxGenericValidator( &m_remember ) );
|
1
|
153 m_textCtrlDesc->SetValidator( wxTextValidator( wxFILTER_NONE, &m_desc ) );
|
|
154 }
|
|
155
|