]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/fl/fl_demo1/fl_demo1.cpp
checked in forgottern parts of MSLU changes
[wxWidgets.git] / contrib / samples / fl / fl_demo1 / fl_demo1.cpp
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
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" );
65
66 wxMenuBar *menu_bar = new wxMenuBar;
67
68 menu_bar->Append(file_menu, "&File");
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
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" );
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
99 void MyFrame::OnLoad( wxCommandEvent& event )
100 {
101 wxMessageBox("Hey - you found a BIG question-mark !!");
102 }
103
104 void MyFrame::OnSave( wxCommandEvent& event )
105 {
106 wxMessageBox("Hey - you found another BIG question-mark !!");
107 }
108
109 void MyFrame::OnExit( wxCommandEvent& event )
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)
127 : wxFrame( frame, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition,
128 wxSize( 700, 500 ),
129 wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
130 wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION,
131 "freimas" )
132 {
133 mpClientWnd = CreateTextCtrl( "Client window" );
134
135 mpLayout = new wxFrameLayout( this, mpClientWnd );
136
137 #ifdef __WXGTK__
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
186 mpLayout->AddBar( CreateTextCtrl("Hello"), // bar window
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)
190 "InfoViewer1", // name to refer in customization pop-ups
191 TRUE
192 );
193
194 mpLayout->AddBar( CreateTextCtrl("Bye"), // bar window
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)
198 "InfoViewer2", // name to refer in customization pop-ups
199 TRUE
200 );
201
202 mpLayout->AddBar( CreateTextCtrl("Fixed0"), // bar window
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)
206 "ToolBar1", // name to refer in customization pop-ups
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
216 pToolBar->AddTool( 1001, BMP_DIR "new.bmp" );
217 pToolBar->AddSeparator();
218 pToolBar->AddTool( 1002, BMP_DIR "open.bmp" );
219 pToolBar->AddTool( 1003, BMP_DIR "save.bmp" );
220 pToolBar->AddSeparator(new wxMySeparatorLine(pToolBar, -1));
221 pToolBar->AddTool( 1004, BMP_DIR "cut.bmp" );
222 pToolBar->AddTool( 1005, BMP_DIR "copy.bmp" );
223 pToolBar->AddTool( 1006, BMP_DIR "paste.bmp" );
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)
230 "ToolBar2", // name to refer in customization pop-ups
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 }