]>
git.saurik.com Git - wxWidgets.git/blob - samples/validate/validate.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindows validation sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 // #pragma implementation
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
28 #include "wx/valtext.h"
32 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
33 EVT_MENU(wxID_EXIT
, MyFrame::OnQuit
)
34 EVT_MENU(VALIDATE_TEST_DIALOG
, MyFrame::OnTestDialog
)
41 bool MyApp::OnInit(void)
43 // Create the main frame window
44 MyFrame
*frame
= new MyFrame((wxFrame
*) NULL
, (char *) "Validation Test", 50, 50, 300, 250);
48 frame
->SetIcon(wxIcon("mondrian"));
51 frame
->SetIcon(wxIcon("aiai.xbm"));
55 wxMenu
*file_menu
= new wxMenu
;
57 file_menu
->Append(VALIDATE_TEST_DIALOG
, "&Test dialog");
58 file_menu
->Append(wxID_EXIT
, "E&xit");
59 wxMenuBar
*menu_bar
= new wxMenuBar
;
60 menu_bar
->Append(file_menu
, "File");
61 frame
->SetMenuBar(menu_bar
);
63 frame
->CreateStatusBar(1);
73 // My frame constructor
74 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
75 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
78 void MyFrame::OnQuit(wxCommandEvent
& event
)
83 void MyFrame::OnTestDialog(wxCommandEvent
& event
)
85 MyDialog
dialog(this, "Validation test dialog", wxPoint(100, 100), wxSize(340, 170));
90 MyDialog::MyDialog(wxWindow
*parent
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
,
92 wxDialog(parent
, VALIDATE_DIALOG_ID
, title
, pos
, size
, wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
)
94 wxButton
*but1
= new wxButton(this, wxID_OK
, "OK", wxPoint(250, 10), wxSize(80, 30));
95 wxButton
*but2
= new wxButton(this, wxID_CANCEL
, "Cancel", wxPoint(250, 60), wxSize(80, 30));
97 wxTextCtrl
*txt1
= new wxTextCtrl(this, VALIDATE_TEXT
, "",
98 wxPoint(10, 10), wxSize(120, -1), 0, wxTextValidator(wxFILTER_ALPHA
, &g_data
.m_string
));
100 // SetBackgroundColour(wxColour(0,0,255));