]>
Commit | Line | Data |
---|---|---|
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 |
37 | class MyApp: public wxApp | |
38 | { | |
39 | public: | |
c7f3b78b VZ |
40 | MyApp(); |
41 | ||
42 | virtual bool OnInit(); | |
43 | ||
c801d85f | 44 | protected: |
c7f3b78b | 45 | wxLocale m_locale; // locale we'll be using |
c801d85f KB |
46 | }; |
47 | ||
48 | // Define a new frame type | |
49 | class MyFrame: public wxFrame | |
c7f3b78b VZ |
50 | { |
51 | public: | |
52 | MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h); | |
53 | ||
54 | public: | |
55 | void OnQuit(wxCommandEvent& event); | |
56 | void OnAbout(wxCommandEvent& event); | |
57 | void OnPlay(wxCommandEvent& event); | |
58 | void OnOpen(wxCommandEvent& event); | |
59 | bool OnClose(void) { return TRUE; } | |
60 | ||
61 | DECLARE_EVENT_TABLE() | |
c801d85f KB |
62 | }; |
63 | ||
64 | // ID for the menu commands | |
c7f3b78b VZ |
65 | enum |
66 | { | |
67 | MINIMAL_QUIT, | |
68 | MINIMAL_TEXT, | |
69 | MINIMAL_ABOUT, | |
70 | MINIMAL_TEST, | |
71 | MINIMAL_OPEN | |
72 | }; | |
c801d85f KB |
73 | |
74 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
c7f3b78b VZ |
75 | EVT_MENU(MINIMAL_QUIT, MyFrame::OnQuit) |
76 | EVT_MENU(MINIMAL_ABOUT, MyFrame::OnAbout) | |
77 | EVT_MENU(MINIMAL_TEST, MyFrame::OnPlay) | |
78 | EVT_MENU(MINIMAL_OPEN, MyFrame::OnOpen) | |
c801d85f KB |
79 | END_EVENT_TABLE() |
80 | ||
81 | IMPLEMENT_APP(MyApp) | |
82 | ||
83 | ||
c7f3b78b | 84 | MyApp::MyApp() : m_locale("french", "fr", "C") |
c801d85f KB |
85 | { |
86 | // catalogs we'll be using: | |
87 | /* not needed any more, done in wxLocale ctor | |
88 | m_locale.AddCatalog("wxstd"); // 1) for library messages | |
89 | */ | |
90 | m_locale.AddCatalog("internat"); // 2) our private one | |
c7f3b78b | 91 | /* this catalog is installed in standard location on Linux systems, |
c801d85f KB |
92 | it might not be installed on yours - just ignore the errrors |
93 | or comment out this line then */ | |
94 | m_locale.AddCatalog("fileutils"); // 3) and another just for testing | |
95 | ||
96 | } | |
97 | ||
98 | // `Main program' equivalent, creating windows and returning main app frame | |
99 | bool MyApp::OnInit(void) | |
100 | { | |
101 | // Create the main frame window | |
c7f3b78b | 102 | MyFrame *frame = new MyFrame(NULL, _("Minimal wxWindows App"), 50, 50, 150, 40); |
c801d85f KB |
103 | |
104 | // Give it an icon | |
2049ba38 | 105 | #ifdef __WXMSW__ |
c801d85f | 106 | frame->SetIcon(wxIcon("mondrian")); |
47908e25 RR |
107 | #else |
108 | frame->SetIcon(wxIcon(mondrian_xpm)); | |
c801d85f KB |
109 | #endif |
110 | ||
111 | // Make a menubar | |
112 | wxMenu *file_menu = new wxMenu; | |
c7f3b78b VZ |
113 | file_menu->Append(MINIMAL_ABOUT, _("&About")); |
114 | file_menu->AppendSeparator(); | |
115 | file_menu->Append(MINIMAL_QUIT, _("E&xit")); | |
116 | ||
117 | wxMenu *test_menu = new wxMenu; | |
118 | test_menu->Append(MINIMAL_OPEN, _("&Open bogus file")); | |
119 | test_menu->Append(MINIMAL_TEST, _("&Play a game")); | |
c801d85f | 120 | |
c801d85f | 121 | wxMenuBar *menu_bar = new wxMenuBar; |
c7f3b78b VZ |
122 | menu_bar->Append(file_menu, _("&File")); |
123 | menu_bar->Append(test_menu, _("&Test")); | |
c801d85f KB |
124 | frame->SetMenuBar(menu_bar); |
125 | ||
c801d85f KB |
126 | // Show the frame |
127 | frame->Show(TRUE); | |
c801d85f KB |
128 | SetTopWindow(frame); |
129 | ||
130 | return TRUE; | |
131 | } | |
132 | ||
133 | // My frame constructor | |
c7f3b78b VZ |
134 | MyFrame::MyFrame(wxFrame *frame, const char *title, int x, int y, int w, int h) |
135 | : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) | |
136 | { | |
137 | } | |
c801d85f | 138 | |
bd7d06f2 | 139 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) |
c801d85f KB |
140 | { |
141 | Close(TRUE); | |
142 | } | |
143 | ||
bd7d06f2 | 144 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) |
c801d85f | 145 | { |
c7f3b78b VZ |
146 |