~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/templates/common/wx-main-sh.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "main.h"
 
2
 
 
3
//helper functions
 
4
enum wxbuildinfoformat {
 
5
    short_f, long_f };
 
6
 
 
7
wxString wxbuildinfo(wxbuildinfoformat format)
 
8
{
 
9
    wxString wxbuild(wxVERSION_STRING);
 
10
 
 
11
    if (format == long_f )
 
12
    {
 
13
#if defined(__WXMSW__)
 
14
        wxbuild << _T("-Windows");
 
15
#elif defined(__UNIX__)
 
16
        wxbuild << _T("-Linux");
 
17
#endif
 
18
 
 
19
#if wxUSE_UNICODE
 
20
        wxbuild << _T("-unicode build");
 
21
#else
 
22
        wxbuild << _T("-ANSI build");
 
23
#endif // wxUSE_UNICODE
 
24
    }
 
25
 
 
26
    return wxbuild;
 
27
}
 
28
 
 
29
//wxApplication
 
30
IMPLEMENT_APP(MyApp);
 
31
 
 
32
bool MyApp::OnInit()
 
33
{
 
34
    MyFrame* frame = new MyFrame(0L, _("wxWidgets Application Template"));
 
35
    frame->Show();
 
36
    return true;
 
37
}
 
38
 
 
39
int idMenuQuit = wxNewId();
 
40
int idMenuAbout = wxNewId();
 
41
 
 
42
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 
43
    EVT_MENU(idMenuQuit, MyFrame::OnQuit)
 
44
    EVT_MENU(idMenuAbout, MyFrame::OnAbout)
 
45
END_EVENT_TABLE()
 
46
 
 
47
MyFrame::MyFrame(wxFrame *frame, const wxString& title)
 
48
    : wxFrame(frame, -1, title)
 
49
{
 
50
#if wxUSE_MENUS
 
51
    // create a menu bar
 
52
    wxMenuBar* mbar = new wxMenuBar();
 
53
    wxMenu* fileMenu = new wxMenu(_T(""));
 
54
    fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application"));
 
55
    mbar->Append(fileMenu, _("&File"));
 
56
 
 
57
    wxMenu* helpMenu = new wxMenu(_T(""));
 
58
    helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application"));
 
59
    mbar->Append(helpMenu, _("&Help"));
 
60
 
 
61
    SetMenuBar(mbar);
 
62
#endif // wxUSE_MENUS
 
63
 
 
64
#if wxUSE_STATUSBAR
 
65
    // create a status bar with some information about the used wxWidgets version
 
66
    CreateStatusBar(2);
 
67
    SetStatusText(_("Hello Code::Blocks user !"),0);
 
68
    SetStatusText(wxbuildinfo(short_f),1);
 
69
#endif // wxUSE_STATUSBAR
 
70
}
 
71
 
 
72
MyFrame::~MyFrame()
 
73
{
 
74
}
 
75
 
 
76
void MyFrame::OnQuit(wxCommandEvent& event)
 
77
{
 
78
    Close();
 
79
}
 
80
 
 
81
void MyFrame::OnAbout(wxCommandEvent& event)
 
82
{
 
83
    wxString msg = wxbuildinfo(long_f);
 
84
    wxMessageBox(msg, _("Welcome to..."));
 
85
}
 
86