1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by: Sebastian Haase (June 21, 2001)
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
14 #pragma implementation "fl_demo1.h"
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
28 #include "wx/textctrl.h"
31 #include "wx/fl/controlbar.h" // core API
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"
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
47 // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
54 bool MyApp::OnInit(void)
56 MyFrame
*frame
= new MyFrame(NULL
);
58 frame
->SetBackgroundColour( wxColour(192,192,192) );
60 wxMenu
*file_menu
= new wxMenu
;
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" );
66 wxMenuBar
*menu_bar
= new wxMenuBar
;
68 menu_bar
->Append(file_menu
, "&File");
70 frame
->SetMenuBar(menu_bar
);
72 frame
->CreateStatusBar(3);
76 frame
->mpClientWnd
->Refresh();
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" );
89 /***** Implementation for class MyFrame *****/
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
)
99 void MyFrame::OnLoad( wxCommandEvent
& event
)
101 wxMessageBox("Hey - you found a BIG question-mark !!");
104 void MyFrame::OnSave( wxCommandEvent
& event
)
106 wxMessageBox("Hey - you found another BIG question-mark !!");
109 void MyFrame::OnExit( wxCommandEvent
& event
)
114 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
118 new wxTextCtrl( this, -1, value
,
119 wxDefaultPosition
, wxSize(0,0), wxTE_MULTILINE
);
121 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
126 MyFrame::MyFrame(wxFrame
*frame
)
127 : wxFrame( frame
, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition
,
129 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
130 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
133 mpClientWnd
= CreateTextCtrl( "Client window" );
135 mpLayout
= new wxFrameLayout( this, mpClientWnd
);
138 cbCommonPaneProperties props
;
139 mpLayout
->GetPaneProperties( props
);
141 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF!!!
143 mpLayout
->SetPaneProperties( props
, wxALL_PANES
);
146 mpLayout
->SetUpdatesManager( new cbGCUpdatesMgr() );
148 // this is now default...
149 //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
151 // setup plugins for testing
152 mpLayout
->PushDefaultPlugins();
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
) );
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)
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)
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()
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
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
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
210 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
212 pToolBar
->Create( this, -1 );
214 // 1001-1006 ids of command events fired by added tool-buttons
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" );
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
234 mpLayout
->EnableFloating( TRUE
); // off, thinking about wxGtk...
240 delete mpLayout
; // should be destroyed manually
244 void wxMySeparatorLine::DoSetSize( int x
, int y
,
245 int width
, int height
,
250 x
+= (width
- LINE_SIZE
) / 2;
255 y
+= (height
- LINE_SIZE
) / 2;
259 wxStaticLine::DoSetSize(x
, y
, width
, height
, sizeFlags
);