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

« back to all changes in this revision

Viewing changes to src/templates/common/wx-main-s.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 <wx/wxprec.h>
 
2
 
 
3
#ifdef __BORLANDC__
 
4
    #pragma hdrstop
 
5
#endif
 
6
 
 
7
#ifndef WX_PRECOMP
 
8
    #include <wx/wx.h>
 
9
#endif
 
10
 
 
11
//helper functions
 
12
enum wxbuildinfoformat {
 
13
    short_f, long_f };
 
14
 
 
15
wxString wxbuildinfo(wxbuildinfoformat format)
 
16
{
 
17
    wxString wxbuild(wxVERSION_STRING);
 
18
 
 
19
    if (format == long_f )
 
20
    {
 
21
#if defined(__WXMSW__)
 
22
        wxbuild << _T("-Windows");
 
23
#elif defined(__UNIX__)
 
24
        wxbuild << _T("-Linux");
 
25
#endif
 
26
 
 
27
#if wxUSE_UNICODE
 
28
        wxbuild << _T("-unicode build");
 
29
#else
 
30
        wxbuild << _T("-ANSI build");
 
31
#endif // wxUSE_UNICODE
 
32
    }
 
33
 
 
34
    return wxbuild;
 
35
}
 
36
 
 
37
//wxWidgets Application
 
38
class MyApp : public wxApp
 
39
{
 
40
public:
 
41
    virtual bool OnInit();
 
42
};
 
43
IMPLEMENT_APP(MyApp);
 
44
 
 
45
class MyFrame: public wxFrame
 
46
{
 
47
public:
 
48
    MyFrame(wxFrame *frame, const wxString& title);
 
49
    ~MyFrame();
 
50
private:
 
51
    void OnQuit(wxCommandEvent& event);
 
52
    void OnAbout(wxCommandEvent& event);
 
53
    DECLARE_EVENT_TABLE();
 
54
};
 
55
 
 
56
bool MyApp::OnInit()
 
57
{
 
58
    MyFrame* frame = new MyFrame(0L, _("wxWidgets Application Template"));
 
59
    frame->Show();
 
60
    return true;
 
61
}
 
62
 
 
63
int idMenuQuit = wxNewId();
 
64
int idMenuAbout = wxNewId();
 
65
 
 
66
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 
67
    EVT_MENU(idMenuQuit, MyFrame::OnQuit)
 
68
    EVT_MENU(idMenuAbout, MyFrame::OnAbout)
 
69
END_EVENT_TABLE()
 
70
 
 
71
MyFrame::MyFrame(wxFrame *frame, const wxString& title)
 
72
        : wxFrame(frame, -1, title)
 
73
{
 
74
#if wxUSE_MENUS
 
75
    // create a menu bar
 
76
    wxMenuBar* mbar = new wxMenuBar();
 
77
    wxMenu* fileMenu = new wxMenu(_T(""));
 
78
    fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application"));
 
79
    mbar->Append(fileMenu, _("&File"));
 
80
 
 
81
    wxMenu* helpMenu = new wxMenu(_T(""));
 
82
    helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application"));
 
83
    mbar->Append(helpMenu, _("&Help"));
 
84
 
 
85
    SetMenuBar(mbar);
 
86
#endif // wxUSE_MENUS
 
87
 
 
88
#if wxUSE_STATUSBAR
 
89
    // create a status bar with some information about the used wxWidgets version
 
90
    CreateStatusBar(2);
 
91
    SetStatusText(_("Hello Code::Blocks user !"),0);
 
92
    SetStatusText(wxbuildinfo(short_f),1);
 
93
#endif // wxUSE_STATUSBAR
 
94
}
 
95
 
 
96
MyFrame::~MyFrame()
 
97
{
 
98
}
 
99
 
 
100
void MyFrame::OnQuit(wxCommandEvent& event)
 
101
{
 
102
    Close();
 
103
}
 
104
 
 
105
void MyFrame::OnAbout(wxCommandEvent& event)
 
106
{
 
107
    wxString msg = wxbuildinfo(long_f);
 
108
    wxMessageBox(msg, _("Welcome to..."));
 
109
}
 
110