]> git.saurik.com Git - wxWidgets.git/blame - samples/validate/validate.cpp
Made EVT_SLIDER event happen always; some doc and wxProperty updates
[wxWidgets.git] / samples / validate / validate.cpp
CommitLineData
457814b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: validate.cpp
3// Purpose: wxWindows validation sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13// #pragma implementation
14// #pragma interface
15#endif
16
17// For compilers that support precompilation, includes "wx/wx.h".
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
21#pragma hdrstop
22#endif
23
24#ifndef WX_PRECOMP
25#include "wx/wx.h"
26#endif
27
28#include "wx/valtext.h"
29
30#include "validate.h"
31
32BEGIN_EVENT_TABLE(MyFrame, wxFrame)
33 EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
34 EVT_MENU(VALIDATE_TEST_DIALOG, MyFrame::OnTestDialog)
35END_EVENT_TABLE()
36
37IMPLEMENT_APP(MyApp)
38
39MyData g_data;
40
41bool MyApp::OnInit(void)
42{
43 // Create the main frame window
c67daf87 44 MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Validation Test", 50, 50, 300, 250);
457814b5
JS
45
46 // Give it an icon
2049ba38 47#ifdef __WXMSW__
457814b5
JS
48 frame->SetIcon(wxIcon("mondrian"));
49#endif
50#ifdef __X__
51 frame->SetIcon(wxIcon("aiai.xbm"));
52#endif
53
54 // Make a menubar
55 wxMenu *file_menu = new wxMenu;
56
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);
62
63 frame->CreateStatusBar(1);
64
65 // Show the frame
66 frame->Show(TRUE);
67
68 SetTopWindow(frame);
69
70 return TRUE;
71}
72
73// My frame constructor
74MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h):
75 wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
76{}
77
cb43b372 78void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
457814b5
JS
79{
80 Close(TRUE);
81}
82
cb43b372 83void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event))
457814b5 84{
903f689b 85 MyDialog dialog(this, "Validation test dialog", wxPoint(100, 100), wxSize(340, 170));
457814b5
JS
86
87 dialog.ShowModal();
88}
89
cb43b372
RR
90MyDialog::MyDialog( wxWindow *parent, const wxString& title,
91 const wxPoint& pos, const wxSize& size, const long WXUNUSED(style) ) :
457814b5
JS
92 wxDialog(parent, VALIDATE_DIALOG_ID, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL)
93{
94 wxButton *but1 = new wxButton(this, wxID_OK, "OK", wxPoint(250, 10), wxSize(80, 30));
cb43b372 95 (void)new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(250, 60), wxSize(80, 30));
457814b5 96
cb43b372 97 (void)new wxTextCtrl(this, VALIDATE_TEXT, "",
903f689b 98 wxPoint(10, 10), wxSize(120, -1), 0, wxTextValidator(wxFILTER_ALPHA, &g_data.m_string));
457814b5 99
cb43b372 100 SetBackgroundColour(wxColour(0,0,255));
457814b5
JS
101
102 but1->SetFocus();
103 but1->SetDefault();
104}
105