]> git.saurik.com Git - wxWidgets.git/blame - samples/internat/internat.cpp
Attempting to check in this wretched cursor again. Also added SetAcceleratorTable
[wxWidgets.git] / samples / internat / internat.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: internat.cpp
c7f3b78b 3// Purpose: Demonstrates internationalisation (i18n) support
c801d85f
KB
4// Author: Vadim Zeitlin/Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
c7f3b78b 9// Licence: wxWindows license
c801d85f
KB
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/intl.h"
c7f3b78b 29#include "wx/file.h"
c801d85f
KB
30#include "wx/log.h"
31
47908e25
RR
32#ifdef __WXGTK__
33#include "mondrian.xpm"
34#endif
35
c801d85f
KB
36// Define a new application type
37class MyApp: public wxApp
38{
39public:
c7f3b78b
VZ
40 virtual bool OnInit();
41
c801d85f 42protected:
c7f3b78b 43 wxLocale m_locale; // locale we'll be using
c801d85f
KB
44};
45
46// Define a new frame type
47class MyFrame: public wxFrame
c7f3b78b
VZ
48{
49public:
50 MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h);
51
52public:
53 void OnQuit(wxCommandEvent& event);
54 void OnAbout(wxCommandEvent& event);
55 void OnPlay(wxCommandEvent& event);
56 void OnOpen(wxCommandEvent& event);
57 bool OnClose(void) { return TRUE; }
58
59 DECLARE_EVENT_TABLE()
c801d85f
KB
60};
61
62// ID for the menu commands
c7f3b78b
VZ
63enum
64{
65 MINIMAL_QUIT,
66 MINIMAL_TEXT,
67 MINIMAL_ABOUT,
68 MINIMAL_TEST,
69 MINIMAL_OPEN
70};
c801d85f
KB
71
72BEGIN_EVENT_TABLE(MyFrame, wxFrame)
c7f3b78b
VZ
73 EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit)
74 EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout)
75 EVT_MENU(MINIMAL_TEST, MyFrame::OnPlay)
76 EVT_MENU(MINIMAL_OPEN, MyFrame::OnOpen)
c801d85f
KB
77END_EVENT_TABLE()
78
79IMPLEMENT_APP(MyApp)
80
81
071cc2be
VZ
82// `Main program' equivalent, creating windows and returning main app frame
83bool MyApp::OnInit(void)
c801d85f 84{
071cc2be
VZ
85 // Initialize the catalogs we'll be using
86 m_locale.Init("french", "fr", "C");
87
c801d85f
KB
88 /* not needed any more, done in wxLocale ctor
89 m_locale.AddCatalog("wxstd"); // 1) for library messages
90 */
91 m_locale.AddCatalog("internat"); // 2) our private one
c7f3b78b 92 /* this catalog is installed in standard location on Linux systems,
c801d85f
KB
93 it might not be installed on yours - just ignore the errrors
94 or comment out this line then */
95 m_locale.AddCatalog("fileutils"); // 3) and another just for testing
96
c801d85f 97 // Create the main frame window
c7f3b78b 98 MyFrame *frame = new MyFrame(NULL, _("Minimal wxWindows App"), 50, 50, 150, 40);
c801d85f
KB
99
100 // Give it an icon
2049ba38 101#ifdef __WXMSW__
c801d85f 102 frame->SetIcon(wxIcon("mondrian"));
47908e25
RR
103#else
104 frame->SetIcon(wxIcon(mondrian_xpm));
c801d85f
KB
105#endif
106
107 // Make a menubar
108 wxMenu *file_menu = new wxMenu;
c7f3b78b
VZ
109 file_menu->Append(MINIMAL_ABOUT, _("&About"));
110 file_menu->AppendSeparator();
111 file_menu->Append(MINIMAL_QUIT, _("E&xit"));
112
113 wxMenu *test_menu = new wxMenu;
114 test_menu->Append(MINIMAL_OPEN, _("&Open bogus file"));
115 test_menu->Append(MINIMAL_TEST, _("&Play a game"));
c801d85f 116
c801d85f 117 wxMenuBar *menu_bar = new wxMenuBar;
c7f3b78b
VZ
118 menu_bar->Append(file_menu, _("&File"));
119 menu_bar->Append(test_menu, _("&Test"));
c801d85f
KB
120 frame->SetMenuBar(menu_bar);
121
c801d85f
KB
122 // Show the frame
123 frame->Show(TRUE);
c801d85f
KB
124 SetTopWindow(frame);
125
126 return TRUE;
127}
128
129// My frame constructor
c7f3b78b
VZ
130MyFrame::MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h)
131 : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
132{
133}
c801d85f 134
bd7d06f2 135void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
c801d85f
KB
136{
137 Close(TRUE);
138}
139
bd7d06f2 140void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
c801d85f 141{
c7f3b78b
VZ
142