]>
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 | ||
52 | IMPLEMENT_APP (MyApp) | |
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 | ||
72 | frame->CreateStatusBar(3); | |
73 | ||
74 | frame->Show(TRUE); | |
75 | ||
76 | frame->mpClientWnd->Refresh(); | |
77 | ||
78 | SetTopWindow(frame); | |
79 | ||
80 | ||
05aa1fc7 JS |
81 | wxMessageBox(_("Hello, this demo has a bunch of yet-not-fixed-bugs and missing functionality\n\ |
82 | The ONLY purpose is to demonstrate self-layouting toolbars,\nflat-bitmapped-buttons and 2-new FL-plugins \ | |
83 | (cbRowDragPlugin & cbBarHintsPlugin)\n\n\ | |
84 | BTW, disabled images and label-text are rendered at run-time") ); | |
03206f17 VS |
85 | |
86 | return TRUE; | |
87 | } | |
88 | ||
89 | /***** Implementation for class MyFrame *****/ | |
90 | ||
91 | BEGIN_EVENT_TABLE( MyFrame, wxFrame ) | |
92 | // EVT_CHAR_HOOK(MyFrame::OnKeyDown) | |
93 | // EVT_PAINT( MyFrame::OnPaint ) | |
94 | EVT_MENU( NEW_TEST_SAVE, MyFrame::OnSave ) | |
95 | EVT_MENU( NEW_TEST_LOAD, MyFrame::OnLoad ) | |
96 | EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit ) | |
97 | END_EVENT_TABLE() | |
98 | ||
8552e6f0 | 99 | void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 100 | { |
05aa1fc7 | 101 | wxMessageBox(_T("Hey - you found a BIG question-mark !!")); |
03206f17 VS |
102 | } |
103 | ||
8552e6f0 | 104 | void MyFrame::OnSave( wxCommandEvent& WXUNUSED(event) ) |
03206f17 | 105 | { |
05aa1fc7 | 106 | wxMessageBox(_("Hey - you found another BIG question-mark !!")); |
03206f17 VS |
107 | } |
108 | ||
8552e6f0 | 109 | void MyFrame::OnExit( wxCommandEvent& WXUNUSED(event) ) |
03206f17 VS |
110 | { |
111 | Destroy(); | |
112 | } | |
113 | ||
114 | wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) | |
115 | { | |
116 | wxTextCtrl* pCtrl = | |
117 | ||
118 | new wxTextCtrl( this, -1, value, | |
119 | wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE ); | |
120 | ||
121 | pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) ); | |
122 | ||
123 | return pCtrl; | |
124 | } | |
125 | ||
126 | MyFrame::MyFrame(wxFrame *frame) | |
05aa1fc7 | 127 | : wxFrame( frame, -1, _("wxWindows 2.0 wxFrameLayout Test Application"), wxDefaultPosition, |
03206f17 VS |
128 | wxSize( 700, 500 ), |
129 | wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | | |
130 | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION, | |
05aa1fc7 | 131 | wxT("freimas") ) |
03206f17 | 132 | { |
05aa1fc7 | 133 | mpClientWnd = CreateTextCtrl( _("Client window") ); |
03206f17 VS |
134 | |
135 | mpLayout = new wxFrameLayout( this, mpClientWnd ); | |
136 | ||
137 | #if defined(__WXGTK__) || defined(__WXX11__) | |
138 | cbCommonPaneProperties props; | |
139 | mpLayout->GetPaneProperties( props ); | |
140 | ||
141 | props.mRealTimeUpdatesOn = FALSE; // real-time OFF!!! | |
142 | ||
143 | mpLayout->SetPaneProperties( props, wxALL_PANES ); | |
144 | #endif | |
145 | ||
146 | mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() ); | |
147 | ||
148 | // this is now default... | |
149 | //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes | |
150 | ||
151 | // setup plugins for testing | |
152 | mpLayout->PushDefaultPlugins(); | |
153 | ||
154 | mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // fancy "X"es and bevel for bars | |
155 | mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); | |
156 | mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) ); | |
157 | mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) ); | |
158 | mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) ); | |
159 | ||
160 | // drop in some bars | |
161 | cbDimInfo sizes0( 200,45, // when docked horizontally | |
162 | 200,85, // when docked vertically | |
163 | 175,35, // when floated | |
164 | FALSE, // the bar is not fixed-size | |
165 | 4, // vertical gap (bar border) | |
166 | 4 // horizontal gap (bar border) | |
167 | ); | |
168 | ||
169 | cbDimInfo sizes1( 150,35, // when docked horizontally | |
170 | 150,85, // when docked vertically | |
171 | 175,35, // when floated | |
172 | TRUE, // the bar is not fixed-size | |
173 | 4, // vertical gap (bar border) | |
174 | 4 // horizontal gap (bar border) | |
175 | ); | |
176 | ||
177 | cbDimInfo sizes2( 195,35, // when docked horizontally | |
178 | 185,37, // when docked vertically | |
179 | 195,35, // when floated | |
180 | TRUE, // the bar is not fixed-size | |
181 | 4, // vertical gap (bar border) | |
182 | 4, // horizontal gap (bar border) | |
183 | new cbDynToolBarDimHandler() | |
184 | ); | |
185 | ||
05aa1fc7 | 186 | mpLayout->AddBar( CreateTextCtrl(_("Hello")), // bar window |
03206f17 VS |
187 | sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
188 | 0, // insert into 0th row (vert. position) | |
189 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 190 | _("InfoViewer1"), // name to refer in customization pop-ups |
03206f17 VS |
191 | TRUE |
192 | ); | |
193 | ||
05aa1fc7 | 194 | mpLayout->AddBar( CreateTextCtrl(_("Bye")), // bar window |
03206f17 VS |
195 | sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
196 | 1, // insert into 0th row (vert. position) | |
197 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 198 | _("InfoViewer2"), // name to refer in customization pop-ups |
03206f17 VS |
199 | TRUE |
200 | ); | |
201 | ||
05aa1fc7 | 202 | mpLayout->AddBar( CreateTextCtrl(_("Fixed0")), // bar window |
03206f17 VS |
203 | sizes1, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
204 | 0, // insert into 0th row (vert. position) | |
205 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 206 | _("ToolBar1"), // name to refer in customization pop-ups |
03206f17 VS |
207 | TRUE |
208 | ); | |
209 | ||
210 | wxDynamicToolBar* pToolBar = new wxDynamicToolBar(); | |
211 | ||
212 | pToolBar->Create( this, -1 ); | |
213 | ||
214 | // 1001-1006 ids of command events fired by added tool-buttons | |
215 | ||
05aa1fc7 | 216 | pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") ); |
03206f17 | 217 | pToolBar->AddSeparator(); |
05aa1fc7 JS |
218 | pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") ); |
219 | pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") ); | |
03206f17 | 220 | pToolBar->AddSeparator(new wxMySeparatorLine(pToolBar, -1)); |
05aa1fc7 JS |
221 | pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") ); |
222 | pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") ); | |
223 | pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") ); | |
03206f17 VS |
224 | |
225 | ||
226 | mpLayout->AddBar( pToolBar, // bar window (can be NULL) | |
227 | sizes2, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) | |
228 | 0, // insert into 0th row (vert. position) | |
229 | 0, // offset from the start of row (in pixels) | |
05aa1fc7 | 230 | wxT("ToolBar2"), // name to refer in customization pop-ups |
03206f17 VS |
231 | FALSE |
232 | ); | |
233 | ||
234 | mpLayout->EnableFloating( TRUE ); // off, thinking about wxGtk... | |
235 | } | |
236 | ||
237 | MyFrame::~MyFrame() | |
238 | { | |
239 | if ( mpLayout) | |
240 | delete mpLayout; // should be destroyed manually | |
241 | } | |
242 | ||
243 | #define LINE_SIZE 3 | |
244 | void wxMySeparatorLine::DoSetSize( int x, int y, | |
245 | int width, int height, | |
246 | int sizeFlags) | |
247 | { | |
248 | if (width < height) | |
249 | { | |
250 | x += (width - LINE_SIZE) / 2; | |
251 | width = LINE_SIZE; | |
252 | } | |
253 | else | |
254 | { | |
255 | y += (height - LINE_SIZE) / 2; | |
256 | height = LINE_SIZE; | |
257 | } | |
258 | ||
259 | wxStaticLine::DoSetSize(x, y, width, height, sizeFlags); | |
260 | } |