]> git.saurik.com Git - wxWidgets.git/blame - samples/typetest/typetest.cpp
merged in from Mahogany
[wxWidgets.git] / samples / typetest / typetest.cpp
CommitLineData
cfb88c55
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: typetest.cpp
3// Purpose: Types wxWindows 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 "typetest.h"
14#endif
15
16// For compilers that support precompilation, includes "wx/wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include "wx/wx.h"
25#endif
26
27#include "wx/time.h"
28#include "wx/date.h"
29#include "wx/variant.h"
30
31#include "typetest.h"
32
b412f9be 33#if defined(__WXGTK__) || defined(__WXMOTIF__)
cfb88c55
JS
34#include "mondrian.xpm"
35#endif
36
37// Create a new application object
38IMPLEMENT_APP (MyApp)
39
40IMPLEMENT_DYNAMIC_CLASS (MyApp, wxApp)
41
42BEGIN_EVENT_TABLE(MyApp, wxApp)
dcf924a3
RR
43 EVT_MENU(TYPES_DATE, MyApp::DoDateDemo)
44 EVT_MENU(TYPES_TIME, MyApp::DoTimeDemo)
45 EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo)
7e2c43b8 46 EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo)
dcf924a3
RR
47#if wxUSE_UNICODE
48 EVT_MENU(TYPES_UNICODE, MyApp::DoUnicodeDemo)
49#endif
cfb88c55
JS
50END_EVENT_TABLE()
51
52bool MyApp::OnInit(void)
53{
54 // Create the main frame window
55 MyFrame *frame = new MyFrame((wxFrame *) NULL, "wxWindows Types Demo",
56 wxPoint(50, 50), wxSize(450, 340));
57
58 // Give it an icon
59 frame->SetIcon(wxICON(mondrian));
60
61 // Make a menubar
62 wxMenu *file_menu = new wxMenu;
63
64 file_menu->Append(TYPES_ABOUT, "&About");
65 file_menu->AppendSeparator();
66 file_menu->Append(TYPES_DATE, "&Date test");
67 file_menu->Append(TYPES_TIME, "&Time test");
68 file_menu->Append(TYPES_VARIANT, "&Variant test");
7e2c43b8 69 file_menu->Append(TYPES_BYTEORDER, "&Byteorder test");
dcf924a3
RR
70#if wxUSE_UNICODE
71 file_menu->Append(TYPES_UNICODE, "&Unicode test");
72#endif
cfb88c55
JS
73 file_menu->AppendSeparator();
74 file_menu->Append(TYPES_QUIT, "E&xit");
75 wxMenuBar *menu_bar = new wxMenuBar;
76 menu_bar->Append(file_menu, "&File");
77 frame->SetMenuBar(menu_bar);
78
79 m_textCtrl = new wxTextCtrl(frame, -1, "", wxPoint(0, 0), wxDefaultSize, wxTE_MULTILINE);
80
81 // Show the frame
82 frame->Show(TRUE);
83
84 SetTopWindow(frame);
85
86 return TRUE;
87}
88
dcf924a3
RR
89#if wxUSE_UNICODE
90void MyApp::DoUnicodeDemo(wxCommandEvent& WXUNUSED(event))
91{
92 wxTextCtrl& textCtrl = * GetTextCtrl();
93
94 textCtrl.Clear();
95 textCtrl << "\nTest wchar_t to char (Unicode to ANSI/Multibyte) converions:";
96
97 wxString str;
98