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 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/textctrl.h"
26 #include "wx/fl/controlbar.h" // core API
29 #include "wx/fl/barhintspl.h" // bevel for bars with "X"s and grooves
30 #include "wx/fl/rowdragpl.h" // NC-look with draggable rows
31 #include "wx/fl/cbcustom.h" // customization plugin
32 #include "wx/fl/hintanimpl.h"
35 #include "wx/fl/gcupdatesmgr.h" // smooth d&d
36 #include "wx/fl/antiflickpl.h" // double-buffered repaint of decorations
37 #include "wx/fl/dyntbar.h" // auto-layout toolbar
38 #include "wx/fl/dyntbarhnd.h" // control-bar dimension handler for it
42 // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
49 bool MyApp::OnInit(void)
51 MyFrame
*frame
= new MyFrame(NULL
);
53 frame
->SetBackgroundColour( wxColour(192,192,192) );
55 wxMenu
*file_menu
= new wxMenu
;
57 file_menu
->Append( NEW_TEST_LOAD
, _("&Load layouts") );
58 file_menu
->Append( NEW_TEST_SAVE
, _("&Store layouts") );
59 file_menu
->Append( NEW_TEST_EXIT
, _("E&xit") );
61 wxMenuBar
*menu_bar
= new wxMenuBar
;
63 menu_bar
->Append(file_menu
, _("&File"));
65 frame
->SetMenuBar(menu_bar
);
68 frame
->CreateStatusBar(3);
69 #endif // wxUSE_STATUSBAR
73 frame
->mpClientWnd
->Refresh();
78 wxMessageBox(_("Hello, this demo has a bunch of yet-not-fixed-bugs and missing functionality\n\
79 The ONLY purpose is to demonstrate self-layouting toolbars,\nflat-bitmapped-buttons and 2-new FL-plugins \
80 (cbRowDragPlugin & cbBarHintsPlugin)\n\n\
81 BTW, disabled images and label-text are rendered at run-time") );
86 /***** Implementation for class MyFrame *****/
88 BEGIN_EVENT_TABLE( MyFrame
, wxFrame
)
89 // EVT_CHAR_HOOK(MyFrame::OnKeyDown)
90 // EVT_PAINT( MyFrame::OnPaint )
91 EVT_MENU( NEW_TEST_SAVE
, MyFrame::OnSave
)
92 EVT_MENU( NEW_TEST_LOAD
, MyFrame::OnLoad
)
93 EVT_MENU( NEW_TEST_EXIT
, MyFrame::OnExit
)
96 void MyFrame::OnLoad( wxCommandEvent
& WXUNUSED(event
) )
98 wxMessageBox(_T("Hey - you found a BIG question-mark !!"));
101 void MyFrame::OnSave( wxCommandEvent
& WXUNUSED(event
) )
103 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
106 void MyFrame::OnExit( wxCommandEvent
& WXUNUSED(event
) )
111 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
115 new wxTextCtrl( this, wxID_ANY
, value
,
116 wxDefaultPosition
, wxSize(0,0), wxTE_MULTILINE
);
118 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
123 MyFrame::MyFrame(wxFrame
*frame
)
124 : wxFrame( frame
, wxID_ANY
, _("wxWidgets 2.0 wxFrameLayout Test Application"), wxDefaultPosition
,
126 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
127 wxRESIZE_BORDER
| wxSYSTEM_MENU
| wxCAPTION
| wxCLOSE_BOX
,
130 mpClientWnd
= CreateTextCtrl( _("Client window") );
132 mpLayout
= new wxFrameLayout( this, mpClientWnd
);
134 #if defined(__WXGTK__) || defined(__WXX11__)
135 cbCommonPaneProperties props
;
136 mpLayout
->GetPaneProperties( props
);
138 props
.mRealTimeUpdatesOn
= false; // real-time OFF!!!
140 mpLayout
->SetPaneProperties( props
, wxALL_PANES
);
143 mpLayout
->SetUpdatesManager( new cbGCUpdatesMgr() );
145 // this is now default...
146 //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
148 // setup plugins for testing
149 mpLayout
->PushDefaultPlugins();
151 mpLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // fancy "X"es and bevel for bars
152 mpLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
153 mpLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
154 mpLayout
->AddPlugin( CLASSINFO( cbAntiflickerPlugin
) );
155 mpLayout
->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin
) );
158 cbDimInfo
sizes0( 200,45, // when docked horizontally
159 200,85, // when docked vertically
160 175,35, // when floated
161 false, // the bar is not fixed-size
162 4, // vertical gap (bar border)
163 4 // horizontal gap (bar border)
166 cbDimInfo
sizes1( 150,35, // when docked horizontally
167 150,85, // when docked vertically
168 175,35, // when floated
169 true, // the bar is not fixed-size
170 4, // vertical gap (bar border)
171 4 // horizontal gap (bar border)
174 cbDimInfo
sizes2( 195,35, // when docked horizontally
175 185,37, // when docked vertically
176 195,35, // when floated
177 true, // the bar is not fixed-size
178 4, // vertical gap (bar border)
179 4, // horizontal gap (bar border)
180 new cbDynToolBarDimHandler()
183 mpLayout
->AddBar( CreateTextCtrl(_("Hello")), // bar window
184 sizes0
, FL_ALIGN_TOP
, // alignment ( 0-top,1-bottom, etc)
185 0, // insert into 0th row (vert. position)
186 0, // offset from the start of row (in pixels)
187 _("InfoViewer1"), // name to refer in customization pop-ups
191 mpLayout
->AddBar( CreateTextCtrl(_("Bye")), // bar window
192 sizes0
, FL_ALIGN_TOP
, // alignment ( 0-top,1-bottom, etc)
193 1, // insert into 0th row (vert. position)
194 0, // offset from the start of row (in pixels)
195 _("InfoViewer2"), // name to refer in customization pop-ups
199 mpLayout
->AddBar( CreateTextCtrl(_("Fixed0")), // bar window
200 sizes1
, FL_ALIGN_TOP
, // alignment ( 0-top,1-bottom, etc)
201 0, // insert into 0th row (vert. position)
202 0, // offset from the start of row (in pixels)
203 _("ToolBar1"), // name to refer in customization pop-ups
207 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
209 pToolBar
->Create( this, wxID_ANY
);
211 // 1001-1006 ids of command events fired by added tool-buttons
213 pToolBar
->AddTool( 1001, wxString(wxT(BMP_DIR
)) + wxT("new.bmp") );
214 pToolBar
->AddSeparator();
215 pToolBar
->AddTool( 1002, wxString(wxT(BMP_DIR
)) + wxT("open.bmp") );
216 pToolBar
->AddTool( 1003, wxString(wxT(BMP_DIR
)) + wxT("save.bmp") );
218 pToolBar
->AddSeparator(new wxMySeparatorLine(pToolBar
, wxID_ANY
));
219 #endif // wxUSE_STATLINE
220 pToolBar
->AddTool( 1004, wxString(wxT(BMP_DIR
)) + wxT("cut.bmp") );
221 pToolBar
->AddTool( 1005, wxString(wxT(BMP_DIR
)) + wxT("copy.bmp") );
222 pToolBar
->AddTool( 1006, wxString(wxT(BMP_DIR
)) + wxT("paste.bmp") );
225 mpLayout
->AddBar( pToolBar
, // bar window (can be NULL)
226 sizes2
, FL_ALIGN_TOP
, // alignment ( 0-top,1-bottom, etc)
227 0, // insert into 0th row (vert. position)
228 0, // offset from the start of row (in pixels)
229 wxT("ToolBar2"), // name to refer in customization pop-ups
233 mpLayout
->EnableFloating( true ); // off, thinking about wxGtk...
239 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
);
261 #endif // wxUSE_STATLINE