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
);
73 frame
->CreateStatusBar(3);
74 #endif // wxUSE_STATUSBAR
78 frame
->mpClientWnd
->Refresh();
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") );
91 /***** Implementation for class MyFrame *****/
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
)
101 void MyFrame::OnLoad( wxCommandEvent
& WXUNUSED(event
) )
103 wxMessageBox(_T("Hey - you found a BIG question-mark !!"));
106 void MyFrame::OnSave( wxCommandEvent
& WXUNUSED(event
) )
108 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
111 void MyFrame::OnExit( wxCommandEvent
& WXUNUSED(event
) )
116 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
120 new wxTextCtrl( this, wxID_ANY
, value
,
121 wxDefaultPosition
, wxSize(0,0), wxTE_MULTILINE
);
123 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
128 MyFrame::MyFrame(wxFrame
*frame
)
129 : wxFrame( frame
, wxID_ANY
, _("wxWidgets 2.0 wxFrameLayout Test Application"), wxDefaultPosition
,
131 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
132 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
135 mpClientWnd
= CreateTextCtrl( _("Client window") );
137 mpLayout
= new wxFrameLayout( this, mpClientWnd
);
139 #if defined(__WXGTK__) || defined(__WXX11__)
140 cbCommonPaneProperties props
;
141 mpLayout
->GetPaneProperties( props
);
143 props
.mRealTimeUpdatesOn
= false; // real-time OFF!!!
145 mpLayout
->SetPaneProperties( props
, wxALL_PANES
);
148 mpLayout
->SetUpdatesManager( new cbGCUpdatesMgr() );
150 // this is now default...
151 //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
153 // setup plugins for testing
154 mpLayout
->PushDefaultPlugins();
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
) );
163 cbDimInfo
sizes0( 200,45, // when docked horizontally
164 200,85, // when docked vertically
165 175,35, // when floated
166 false, // the bar is not fixed-size
167 4, // vertical gap (bar border)
168 4 // horizontal gap (bar border)
171 cbDimInfo
sizes1( 150,35, // when docked horizontally
172 150,85, // when docked vertically
173 175,35, // when floated
174 true, // the bar is not fixed-size
175 4, // vertical gap (bar border)
176 4 // horizontal gap (bar border)
179 cbDimInfo
sizes2( 195,35, // when docked horizontally
180 185,37, // when docked vertically
181 195,35, // when floated
182 true, // the bar is not fixed-size
183 4, // vertical gap (bar border)
184 4, // horizontal gap (bar border)
185 new cbDynToolBarDimHandler()
188 mpLayout
->AddBar( CreateTextCtrl(_("Hello")), // bar window
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)
192 _("InfoViewer1"), // name to refer in customization pop-ups
196 mpLayout
->AddBar( CreateTextCtrl(_("Bye")), // bar window
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)
200 _("InfoViewer2"), // name to refer in customization pop-ups
204 mpLayout
->AddBar( CreateTextCtrl(_("Fixed0")), // bar window
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)
208 _("ToolBar1"), // name to refer in customization pop-ups
212 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
214 pToolBar
->Create( this, wxID_ANY
);
216 // 1001-1006 ids of command events fired by added tool-buttons
218 pToolBar
->AddTool( 1001, wxString(wxT(BMP_DIR
)) + wxT("new.bmp") );
219 pToolBar
->AddSeparator();
220 pToolBar
->AddTool( 1002, wxString(wxT(BMP_DIR
)) + wxT("open.bmp") );
221 pToolBar
->AddTool( 1003, wxString(wxT(BMP_DIR
)) + wxT("save.bmp") );
223 pToolBar
->AddSeparator(new wxMySeparatorLine(pToolBar
, wxID_ANY
));
224 #endif // wxUSE_STATLINE
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") );
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)
234 wxT("ToolBar2"), // name to refer in customization pop-ups
238 mpLayout
->EnableFloating( true ); // off, thinking about wxGtk...
244 delete mpLayout
; // should be destroyed manually
249 void wxMySeparatorLine::DoSetSize( int x
, int y
,
250 int width
, int height
,
255 x
+= (width
- LINE_SIZE
) / 2;
260 y
+= (height
- LINE_SIZE
) / 2;
264 wxStaticLine::DoSetSize(x
, y
, width
, height
, sizeFlags
);
266 #endif // wxUSE_STATLINE