]>
Commit | Line | Data |
---|---|---|
03206f17 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: No names yet. | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: Sebastian Haase (June 21, 2001) | |
6 | // Created: 04/11/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | ||
13 | #ifdef __GNUG__ | |
14 | #pragma implementation "fl_demo1.h" | |
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/textctrl.h" | |
29 | ||
30 | // fl headers | |
31 | #include "wx/fl/controlbar.h" // core API | |
32 | ||
33 | // extra plugins | |
34 | #include "wx/fl/barhintspl.h" // bevel for bars with "X"s and grooves | |
35 | #include "wx/fl/rowdragpl.h" // NC-look with draggable rows | |
36 | #include "wx/fl/cbcustom.h" // customization plugin | |
37 | #include "wx/fl/hintanimpl.h" | |
38 | ||
39 | // beauty-care | |
40 | #include "wx/fl/gcupdatesmgr.h" // smooth d&d | |
41 | #include "wx/fl/antiflickpl.h" // double-buffered repaint of decorations | |
42 | #include "wx/fl/dyntbar.h" // auto-layout toolbar | |
43 | #include "wx/fl/dyntbarhnd.h" // control-bar dimension handler for it | |
44 | ||
45 | #include "fl_demo1.h" | |
46 | ||
47 | // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker) | |
48 | ||
49 | char wxDummyChar; | |
50 | ||
51 | ||
c82c42d4 | 52 | IMPLEMENT_APP (MyApp) |
03206f17 VS |
53 | |
54 | bool MyApp::OnInit(void) | |
55 | { | |
56 | MyFrame *frame = new MyFrame(NULL); | |
57 | ||
58 | frame->SetBackgroundColour( wxColour(192,192,192) ); | |
59 | ||
60 | wxMenu *file_menu = new wxMenu; | |
61 | ||
05aa1fc7 JS |
62 | file_menu->Append( NEW_TEST_LOAD, _("&Load layouts") ); |
63 | file_menu->Append( NEW_TEST_SAVE, _("&Store layouts") ); | |
64 | file_menu->Append( NEW_TEST_EXIT, _("E&xit") ); | |
03206f17 VS |
65 | |
66 | wxMenuBar *menu_bar = new wxMenuBar; | |
67 | ||
05aa1fc7 | 68 | menu_bar->Append(file_menu, _("&File")); |
03206f17 VS |
69 | |
70 | frame->SetMenuBar(menu_bar); | |
71 | ||
d96cdd4a | 72 | #if wxUSE_STATUSBAR |
03206f17 | 73 | frame->CreateStatusBar(3); |
d96cdd4a | 74 | #endif // wxUSE_STATUSBAR |
03206f17 | 75 | |
c82c42d4 | 76 | frame->Show(true); |
03206f17 VS |
77 | |
78 | frame->mpClientWnd->Refresh(); | |
79 | ||
80 | SetTopWindow(frame); | |
81 | ||
82 | ||
05aa1fc7 JS |
83 | wxMessageBox(_("Hello, this demo has a bunch of yet-not-fixed-bugs and missing functionality\n\ |
84 | The ONLY purpose is to demonstrate self-layouting toolbars,\nflat-bitmapped-buttons and 2-new FL-plugins \ | |
85 | (cbRowDragPlugin & cbBarHintsPlugin)\n\n\ | |
86 | BTW, disabled images and label-text are rendered at run-time") ); | |
03206f17 | 87 | |
c82c42d4 | 88 | return true; |
03206f17 VS |
89 | } |
90 | ||
91 | /***** Implementation for class MyFrame *****/ | |
92 | ||
93 | BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
94 | // EVT_CHAR_HOOK(MyFrame::OnKeyDown) | |
95 | // EVT_PAINT( MyFrame::OnPaint ) | |
96 | EVT_MENU( NEW_TEST_SAVE, MyFrame::OnSave ) | |
97 | EVT_MENU( NEW_TEST_LOAD, MyFrame::OnLoad ) | |
98 | EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit ) | |
99 | END_EVENT_TABLE() | |
100 | ||
8552e6f0 | 101 | void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) ) |
c82c42d4 | 102 | { |
05aa1fc7 | 103 | wxMessageBox(_T("Hey - you found a BIG question-mark !!")); |
03206f17 VS |
104 | } |
105 | ||
8552e6f0 | 106 | void MyFrame::OnSave( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 107 | { |
05aa1fc7 | 108 | wxMessageBox(_("Hey - you found another BIG question-mark !!")); |
03206f17 VS |
109 | } |
110 | ||
8552e6f0 | 111 | void MyFrame::OnExit( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
112 | { |
113 | Destroy(); | |
114 | } | |
115 | ||
116 | wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) | |
117 | { | |
118 | wxTextCtrl* pCtrl = | |
119 | ||
c82c42d4 | 120 | new wxTextCtrl( this, wxID_ANY, value, |
03206f17 VS |
121 | wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE ); |
122 | ||
123 | pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) ); | |
124 | ||
125 | return pCtrl; | |
126 | } | |
127 | ||
128 | MyFrame::MyFrame(wxFrame *frame) | |
c82c42d4 | 129 | : wxFrame( frame, wxID_ANY, _("wxWidgets 2.0 wxFrameLayout Test Application"), wxDefaultPosition, |
03206f17 VS |
130 | wxSize( 700, 500 ), |
131 | wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | | |
132 | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION, | |
05aa1fc7 | 133 | wxT("freimas") ) |
03206f17 | 134 | { |
05aa1fc7 | 135 | mpClientWnd = CreateTextCtrl( _("Client window") ); |
03206f17 VS |
136 | |
137 | mpLayout = new wxFrameLayout( this, mpClientWnd ); | |
138 | ||
139 | #if defined(__WXGTK__) || defined(__WXX11__) | |
140 | cbCommonPaneProperties props; | |
141 | mpLayout->GetPaneProperties( props ); | |
142 | ||
c82c42d4 | 143 | props.mRealTimeUpdatesOn = false; // real-time OFF!!! |
03206f17 VS |
144 | |
145 | mpLayout->SetPaneProperties( props, wxALL_PANES ); | |
146 | #endif | |
147 | ||
148 | mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() ); | |
149 | ||
150 | // this is now default... | |
151 | //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes | |
152 | ||
153 | // setup plugins for testing | |
154 | mpLayout->PushDefaultPlugins(); | |
155 | ||
156 | mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // fancy "X"es and bevel for bars | |
157 | mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); | |
158 | mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) ); | |
159 | mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) ); | |
160 | mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) ); | |
161 | ||
162 | // drop in some bars | |
163 | cbDimInfo sizes0( 200,45, // when docked horizontally | |
164 | 200,85, // when docked vertically | |
165 | 175,35, // when floated | |
c82c42d4 | 166 | false, // the bar is not fixed-size |
03206f17 VS |
167 | 4, // vertical gap (bar border) |
168 | 4 // horizontal gap (bar border) | |
169 | ); | |
170 | ||
171 | cbDimInfo sizes1( 150,35, // when docked horizontally | |
172 | 150,85, // when docked vertically | |
173 | 175,35, // when floated | |
c82c42d4 | 174 | true, // the bar is not fixed-size |
03206f17 VS |
175 | 4, // vertical gap (bar border) |
176 | 4 // horizontal gap (bar border) | |
177 | ); | |
178 | ||
179 | cbDimInfo sizes2( 195,35, // when docked horizontally | |
180 | 185,37, // when docked vertically | |
181 | 195,35, // when floated | |
c82c42d4 | 182 | true, // the bar is not fixed-size |
03206f17 VS |
183 | 4, // vertical gap (bar border) |
184 | 4, // horizontal gap (bar border) | |
185 | new cbDynToolBarDimHandler() | |
186 | ); | |
187 | ||
05aa1fc7 | 188 | mpLayout->AddBar( CreateTextCtrl(_("Hello")), // bar window |
03206f17 VS |
189 | sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
190 | 0, // insert into 0th row (vert. position) | |
191 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 192 | _("InfoViewer1"), // name to refer in customization pop-ups |
c82c42d4 | 193 | true |
03206f17 VS |
194 | ); |
195 | ||
05aa1fc7 | 196 | mpLayout->AddBar( CreateTextCtrl(_("Bye")), // bar window |
03206f17 VS |
197 | sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
198 | 1, // insert into 0th row (vert. position) | |
199 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 200 | _("InfoViewer2"), // name to refer in customization pop-ups |
c82c42d4 | 201 | true |
03206f17 VS |
202 | ); |
203 | ||
05aa1fc7 | 204 | mpLayout->AddBar( CreateTextCtrl(_("Fixed0")), // bar window |
03206f17 VS |
205 | sizes1, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
206 | 0, // insert into 0th row (vert. position) | |
207 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 208 | _("ToolBar1"), // name to refer in customization pop-ups |
c82c42d4 | 209 | true |
03206f17 VS |
210 | ); |
211 | ||
212 | wxDynamicToolBar* pToolBar = new wxDynamicToolBar(); | |
213 | ||
c82c42d4 | 214 | pToolBar->Create( this, wxID_ANY ); |
03206f17 VS |
215 | |
216 | // 1001-1006 ids of command events fired by added tool-buttons | |
217 | ||
05aa1fc7 | 218 | pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") ); |
03206f17 | 219 | pToolBar->AddSeparator(); |
05aa1fc7 JS |
220 | pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") ); |
221 | pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") ); | |
8833e26c | 222 | #if wxUSE_STATLINE |
c82c42d4 | 223 | pToolBar->AddSeparator(new wxMySeparatorLine(pToolBar, wxID_ANY)); |
8833e26c | 224 | #endif // wxUSE_STATLINE |
05aa1fc7 JS |
225 | pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") ); |
226 | pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") ); | |
227 | pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") ); | |
03206f17 VS |
228 | |
229 | ||
230 | mpLayout->AddBar( pToolBar, // bar window (can be NULL) | |
231 | sizes2, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) | |
232 | 0, // insert into 0th row (vert. position) | |
233 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 234 | wxT("ToolBar2"), // name to refer in customization pop-ups |
c82c42d4 | 235 | false |
03206f17 VS |
236 | ); |
237 | ||
c82c42d4 | 238 | mpLayout->EnableFloating( true ); // off, thinking about wxGtk... |
03206f17 VS |
239 | } |
240 | ||
241 | MyFrame::~MyFrame() | |
242 | { | |
243 | if ( mpLayout) | |
244 | delete mpLayout; // should be destroyed manually | |
245 | } | |
246 | ||
247 | #define LINE_SIZE 3 | |
8833e26c | 248 | #if wxUSE_STATLINE |
03206f17 VS |
249 | void wxMySeparatorLine::DoSetSize( int x, int y, |
250 | int width, int height, | |
251 | int sizeFlags) | |
252 | { | |
253 | if (width < height) | |
254 | { | |
255 | x += (width - LINE_SIZE) / 2; | |
256 | width = LINE_SIZE; | |
257 | } | |
258 | else | |
259 | { | |
260 | y += (height - LINE_SIZE) / 2; | |
261 | height = LINE_SIZE; | |
262 | } | |
263 | ||
264 | wxStaticLine::DoSetSize(x, y, width, height, sizeFlags); | |
265 | } | |
8833e26c | 266 | #endif // wxUSE_STATLINE |