]>
Commit | Line | Data |
---|---|---|
03206f17 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: fl_sample1.cpp | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: Sebastian Haase (June 21, 2001) | |
0423ae97 | 6 | // Created: 24/11/98 |
03206f17 VS |
7 | // RCS-ID: $Id$ |
8 | // Copyright: (c) Aleksandras Gluchovas | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // For compilers that support precompilation, includes "wx/wx.h". | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/wx.h" | |
21 | #endif | |
22 | ||
23 | #include "wx/textctrl.h" | |
24 | ||
25 | // fl headers | |
26 | #include "wx/fl/controlbar.h" | |
27 | ||
28 | // plugins used | |
29 | #include "wx/fl/barhintspl.h" | |
30 | #include "wx/fl/hintanimpl.h" | |
31 | ||
32 | #define ID_LOAD 102 | |
33 | #define ID_STORE 103 | |
34 | #define ID_QUIT 104 | |
35 | ||
36 | class MyApp: public wxApp | |
0423ae97 | 37 | { |
03206f17 VS |
38 | public: |
39 | bool OnInit(void); | |
40 | }; | |
41 | ||
42 | class MyFrame: public wxFrame | |
43 | { | |
44 | protected: | |
45 | wxFrameLayout* mpLayout; | |
46 | wxWindow* mpClientWnd; | |
47 | wxPanel* mpInternalFrm; | |
0423ae97 | 48 | |
03206f17 | 49 | wxTextCtrl* CreateTextCtrl( const wxString& value ); |
0423ae97 | 50 | |
03206f17 | 51 | public: |
05aa1fc7 | 52 | MyFrame( wxWindow* parent, const wxChar *title ); |
03206f17 | 53 | ~MyFrame(); |
0423ae97 | 54 | |
03206f17 VS |
55 | void OnLoad( wxCommandEvent& event ); |
56 | void OnStore( wxCommandEvent& event ); | |
57 | void OnQuit( wxCommandEvent& event ); | |
0423ae97 | 58 | |
c82c42d4 | 59 | bool OnClose(void) { return true; } |
0423ae97 | 60 | |
03206f17 VS |
61 | DECLARE_EVENT_TABLE() |
62 | }; | |
63 | ||
64 | /***** Implementation for class MyApp *****/ | |
65 | ||
66 | IMPLEMENT_APP (MyApp) | |
67 | ||
68 | bool MyApp::OnInit(void) | |
69 | { | |
be5a51fb | 70 | // wxWidgets boiler-plate: |
0423ae97 | 71 | |
05aa1fc7 | 72 | MyFrame *frame = new MyFrame(NULL, _("wxFrameLayout sample")); |
0423ae97 | 73 | |
03206f17 | 74 | wxMenu *file_menu = new wxMenu; |
0423ae97 | 75 | |
05aa1fc7 JS |
76 | file_menu->Append( ID_LOAD, _("&Load layout") ); |
77 | file_menu->Append( ID_STORE, _("&Store layout") ); | |
03206f17 | 78 | file_menu->AppendSeparator(); |
0423ae97 | 79 | |
05aa1fc7 | 80 | file_menu->Append( ID_QUIT, _("E&xit") ); |
0423ae97 | 81 | |
03206f17 | 82 | wxMenuBar *menu_bar = new wxMenuBar; |
0423ae97 | 83 | |
05aa1fc7 | 84 | menu_bar->Append(file_menu, _("&File")); |
0423ae97 | 85 | |
d96cdd4a | 86 | #if wxUSE_STATUSBAR |
03206f17 | 87 | frame->CreateStatusBar(3); |
d96cdd4a | 88 | #endif // wxUSE_STATUSBAR |
03206f17 | 89 | frame->SetMenuBar(menu_bar); |
0423ae97 | 90 | |
c82c42d4 | 91 | frame->Show(true); |
0423ae97 | 92 | |
03206f17 | 93 | SetTopWindow(frame); |
0423ae97 | 94 | |
c82c42d4 | 95 | return true; |
03206f17 VS |
96 | } |
97 | ||
98 | /***** Immlementation for class MyFrame *****/ | |
99 | ||
100 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
101 | EVT_MENU( ID_LOAD, MyFrame::OnLoad ) | |
102 | EVT_MENU( ID_STORE, MyFrame::OnStore ) | |
103 | EVT_MENU( ID_QUIT, MyFrame::OnQuit ) | |
104 | END_EVENT_TABLE() | |
105 | ||
05aa1fc7 | 106 | MyFrame::MyFrame( wxWindow* parent, const wxChar *title ) |
c82c42d4 | 107 | : wxFrame( parent, wxID_ANY, title, wxDefaultPosition, |
03206f17 VS |
108 | wxSize( 700, 500 ), |
109 | wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | | |
0423ae97 | 110 | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX, |
05aa1fc7 | 111 | wxT("freimas") ) |
03206f17 VS |
112 | { |
113 | mpInternalFrm = (wxPanel*)this; | |
0423ae97 | 114 | |
05aa1fc7 | 115 | mpClientWnd = CreateTextCtrl( _("Client window") ); |
0423ae97 | 116 | |
03206f17 VS |
117 | // btw, creation of internal frame is needed for wxGtk version |
118 | // to act correctly (since menu-bar is a separate window there..) | |
0423ae97 | 119 | |
03206f17 | 120 | mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd ); |
0423ae97 | 121 | |
03206f17 VS |
122 | #if defined(__WXGTK__) || defined(__WXX11__) |
123 | // real-time dosn't work well under wxGtk yet | |
124 | cbCommonPaneProperties props; | |
125 | mpLayout->GetPaneProperties( props ); | |
0423ae97 | 126 | |
c82c42d4 | 127 | props.mRealTimeUpdatesOn = false; // off |
0423ae97 MR |
128 | |
129 | mpLayout->SetPaneProperties( props, wxALL_PANES ); | |
03206f17 | 130 | #endif |
0423ae97 | 131 | |
03206f17 VS |
132 | mpLayout->PushDefaultPlugins(); |
133 | mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso | |
134 | //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); | |
0423ae97 MR |
135 | |
136 | cbDimInfo sizes( 80,65, // when docked horizontally | |
137 | 80,65, // when docked vertically | |
138 | 80,30, // when floated | |
c82c42d4 | 139 | true, // the bar is fixed-size |
03206f17 VS |
140 | 5, // vertical gap (bar border) |
141 | 5 // horizontal gap (bar border) | |
0423ae97 MR |
142 | ); |
143 | ||
03206f17 VS |
144 | // drop-in 20 bars |
145 | for( int i = 1; i <= 20; ++i ) | |
146 | { | |
05aa1fc7 JS |
147 | wxChar buf[4]; |
148 | wxSprintf( buf, wxT("%d"), i ); | |
149 | wxString name = wxString(wxT("Bar-")); | |
03206f17 | 150 | name += buf; |
0423ae97 | 151 | |
03206f17 | 152 | sizes.mIsFixed = i % 5 > 0; // every fifth bar is not fixed-size |
0423ae97 | 153 | |
05aa1fc7 | 154 | if ( !sizes.mIsFixed ) name += wxT(" (flexible)"); |
0423ae97 | 155 | |
03206f17 VS |
156 | mpLayout->AddBar( CreateTextCtrl(name),// bar window |
157 | sizes, i % MAX_PANES,// alignment ( 0-top,1-bottom, etc) | |
158 | 0, // insert into 0th row (vert. position) | |
159 | 0, // offset from the start of row (in pixels) | |
160 | name // name to refere in customization pop-ups | |
161 | ); | |
162 | } | |
163 | } | |
164 | ||
165 | MyFrame::~MyFrame() | |
166 | { | |
167 | // layout is not a window, should be released manually | |
0423ae97 | 168 | if ( mpLayout ) |
03206f17 VS |
169 | delete mpLayout; |
170 | } | |
171 | ||
172 | wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) | |
173 | { | |
0423ae97 | 174 | wxTextCtrl* pCtrl = new wxTextCtrl( mpInternalFrm, wxID_ANY, value, |
03206f17 | 175 | wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE ); |
0423ae97 | 176 | |
03206f17 | 177 | pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) ); |
0423ae97 | 178 | |
03206f17 VS |
179 | return pCtrl; |
180 | } | |
181 | ||
8552e6f0 | 182 | void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 183 | { |
05aa1fc7 | 184 | wxMessageBox(wxT("Hey - you found a BIG question-mark !!")); |
03206f17 VS |
185 | } |
186 | ||
8552e6f0 | 187 | void MyFrame::OnStore( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 188 | { |
05aa1fc7 | 189 | wxMessageBox(wxT("Hey - you found another BIG question-mark !!")); |
03206f17 VS |
190 | } |
191 | ||
8552e6f0 | 192 | void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 193 | { |
c82c42d4 | 194 | Show( false ); // TRICK:: hide it, to avoid flickered destruction |
0423ae97 | 195 | |
c82c42d4 | 196 | Close(true); |
03206f17 VS |
197 | } |
198 |