]>
git.saurik.com Git - wxWidgets.git/blob - samples/internat/internat.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Demonstrates internationalisation support
4 // Author: Vadim Zeitlin/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"
31 // Define a new application type
32 class MyApp
: public wxApp
38 wxLocale m_locale
; // locale we'll be using
41 // Define a new frame type
42 class MyFrame
: public wxFrame
44 MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
);
47 void OnQuit(wxCommandEvent
& event
);
48 void OnAbout(wxCommandEvent
& event
);
49 bool OnClose(void) { return TRUE
; }
55 // ID for the menu commands
56 #define MINIMAL_QUIT 1
57 #define MINIMAL_TEXT 101
58 #define MINIMAL_ABOUT 102
60 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
61 EVT_MENU(MINIMAL_QUIT
, MyFrame::OnQuit
)
62 EVT_MENU(MINIMAL_ABOUT
, MyFrame::OnAbout
)
69 m_locale("french", "fr", "C")
71 // catalogs we'll be using:
72 /* not needed any more, done in wxLocale ctor
73 m_locale.AddCatalog("wxstd"); // 1) for library messages
75 m_locale
.AddCatalog("internat"); // 2) our private one
76 /* this catalog is installed in standard location on Liux systems,
77 it might not be installed on yours - just ignore the errrors
78 or comment out this line then */
79 m_locale
.AddCatalog("fileutils"); // 3) and another just for testing
83 // `Main program' equivalent, creating windows and returning main app frame
84 bool MyApp::OnInit(void)
86 // Create the main frame window
87 MyFrame
*frame
= new MyFrame(NULL
, "Minimal wxWindows App", 50, 50, 450, 340);
91 frame
->SetIcon(wxIcon("mondrian"));
94 frame
->SetIcon(wxIcon("aiai.xbm"));
98 wxMenu
*file_menu
= new wxMenu
;
100 file_menu
->Append(MINIMAL_ABOUT
, "&About");
101 file_menu
->Append(MINIMAL_QUIT
, "E&xit");
102 wxMenuBar
*menu_bar
= new wxMenuBar
;
103 menu_bar
->Append(file_menu
, "&File");
104 frame
->SetMenuBar(menu_bar
);
106 // Make a panel with a message
107 wxPanel
*panel
= new wxPanel(frame
, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL
);
112 msgString
= wxTString("you've probably entered an invalid number.");
113 else if ( num
== 9 ) // this message is not translated
114 msgString
= wxTString("You've found a bug in this program!");
115 else if ( num
!= 17 )
116 msgString
= wxTString("bad luck! try again...");
118 msgString
= wxTString("congratulations! you've won. Here is the magic phrase:");
121 wxStaticText
*msg
= new wxStaticText(panel
, 311, msgString
, wxPoint(10, 10), wxSize(-1, -1),
133 // My frame constructor
134 MyFrame::MyFrame(wxFrame
*frame
, char *title
, int x
, int y
, int w
, int h
):
135 wxFrame(frame
, -1, title
, wxPoint(x
, y
), wxSize(w
, h
))
138 void MyFrame::OnQuit(wxCommandEvent
& event
)
143 void MyFrame::OnAbout(wxCommandEvent
& event
)
145 wxMessageDialog
dialog(this, "This is a minimal sample\nA second line in the message box",
146 "About Minimal", wxYES_NO
|wxCANCEL
);