1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Minimal wxWindows sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
14 #pragma implementation "minimal.cpp"
15 #pragma interface "minimal.cpp"
18 // For compilers that support precompilation, includes "wx/wx.h".
19 #include "wx/wxprec.h"
31 #include "wx/textctrl.h"
33 #include "controlbar.h" // core API
37 #include "barhintspl.h" // beveal for bars with "X"s and grooves
38 #include "rowdragpl.h" // NC-look with dragable rows
39 #include "cbcustom.h" // customization plugin
40 #include "hintanimpl.h"
43 #include "gcupdatesmgr.h" // smooth d&d
44 #include "antiflickpl.h" // double-buffered repaint of decorations
46 #include "dyntbar.h" // auto-layouting toolbar
47 #include "dyntbarhnd.h" // control-bar dimension handler for it
49 // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
51 #ifndef wxDUMMY_OBJ_INCLUDED
58 bool MyApp::OnInit(void)
60 MyFrame
*frame
= new MyFrame(NULL
);
62 frame
->SetBackgroundColour( wxColour(192,192,192) );
64 wxMenu
*file_menu
= new wxMenu
;
66 file_menu
->Append( NEW_TEST_EXIT
, "E&xit" );
68 wxMenuBar
*menu_bar
= new wxMenuBar
;
70 menu_bar
->Append(file_menu
, "&File");
72 frame
->SetMenuBar(menu_bar
);
74 frame
->CreateStatusBar(3);
78 frame
->mpClientWnd
->Refresh();
85 wxMessageBox("Hello, this demo has a bunch of yet-not-fixed-bugs and misssing functionality\n\
86 The ONLY purpose is to demostrate self-layouting toolbars,\n flat-bitmapped-buttons and 2-new FL-plugins\
87 (cbRowDragPlugin & cbBarHintsPlugin)\n\n\
88 BTW, disabled images and label-text are rendered at run-time" );
95 /***** Implementation for class MyFrame *****/
97 BEGIN_EVENT_TABLE( MyFrame
, wxFrame
)
99 // EVT_CHAR_HOOK(MyFrame::OnKeyDown)
100 // EVT_PAINT( MyFrame::OnPaint )
101 EVT_MENU( NEW_TEST_EXIT
, MyFrame::OnExit
)
105 void MyFrame::OnExit( wxCommandEvent
& event
)
110 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
114 new wxTextCtrl( mpInternalFrm
, -1, value
,
115 wxDefaultPosition
, wxSize(0,0), wxTE_MULTILINE
);
117 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
122 MyFrame::MyFrame(wxFrame
*frame
)
124 : wxFrame( frame
, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition
,
126 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
127 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
131 mpInternalFrm
= (wxPanel
*)this;
133 mpInternalFrm
= new wxPanel( this, -1 );
137 mpClientWnd
= CreateTextCtrl( "Client window" );
140 mpLayout
= new wxFrameLayout( mpInternalFrm
, mpClientWnd
);
145 cbCommonPaneProperties props
;
146 mpLayout
->GetPaneProperties( props
);
148 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF!!!
150 mpLayout
->SetPaneProperties( props
, wxALL_PANES
);
154 mpLayout
->SetUpdatesManager( new cbGCUpdatesMgr() );
156 // this is now default...
157 //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
159 // setup plugins for testing
161 mpLayout
->PushDefaultPlugins();
163 mpLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
165 mpLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
166 mpLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
167 mpLayout
->AddPlugin( CLASSINFO( cbAntiflickerPlugin
) );
168 mpLayout
->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin
) );
172 cbDimInfo
sizes0(200,45, // when docked horizontally
173 200,85, // when docked vertically
174 175,35, // when floated
175 FALSE
, // the bar is not fixed-size
176 4, // vertical gap (bar border)
177 4 // horizontal gap (bar border)
180 cbDimInfo
sizes1(150,35, // when docked horizontally
181 150,85, // when docked vertically
182 175,35, // when floated
183 TRUE
, // the bar is not fixed-size
184 4, // vertical gap (bar border)
185 4 // horizontal gap (bar border)
188 cbDimInfo
sizes2(175,45, // when docked horizontally
189 175,37, // when docked vertically
190 170,35, // when floated
191 TRUE
, // the bar is not fixed-size
192 4, // vertical gap (bar border)
193 4, // horizontal gap (bar border)
194 new cbDynToolBarDimHandler()
197 mpLayout
->AddBar( CreateTextCtrl("Hello"), // bar window
198 sizes0
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
199 0, // insert into 0th row (vert. position)
200 0, // offset from the start of row (in pixels)
201 "InfoViewer1", // name to refere in customization pop-ups
205 mpLayout
->AddBar( CreateTextCtrl("Bye"), // bar window
206 sizes0
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
207 1, // insert into 0th row (vert. position)
208 0, // offset from the start of row (in pixels)
209 "InfoViewer2", // name to refere in customization pop-ups
213 mpLayout
->AddBar( CreateTextCtrl("Fixed0"), // bar window
214 sizes1
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
215 0, // insert into 0th row (vert. position)
216 0, // offset from the start of row (in pixels)
217 "ToolBar1", // name to refere in customization pop-ups
221 wxDynamicToolBar
* pToolBar
= new wxDynamicToolBar();
223 pToolBar
->Create( mpInternalFrm
, -1 );
225 // 1001-1006 ids of command events fired by added tool-buttons
227 pToolBar
->AddTool( 1001, "new.bmp" );
228 pToolBar
->AddTool( 1002, "open.bmp" );
229 pToolBar
->AddTool( 1003, "save.bmp" );
231 pToolBar
->AddTool( 1004, "cut.bmp" );
232 pToolBar
->AddTool( 1005, "copy.bmp" );
233 pToolBar
->AddTool( 1006, "paste.bmp" );
236 mpLayout
->AddBar( pToolBar
, // bar window (can be NULL)
237 sizes2
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
238 0, // insert into 0th row (vert. position)
239 0, // offset from the start of row (in pixels)
240 "ToolBar2", // name to refere in customization pop-ups
244 mpLayout
->EnableFloating( TRUE
); // off, thinking bout wxGtk...
249 if ( mpLayout
) delete mpLayout
; // should be destroyed manually
252 #ifdef __HACK_MY_MSDEV40__
254 ////////////// new 2.0-magic (linker errors...) ////////////////
256 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
258 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
259 "recreating toolbar in wxFrame" );
261 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
274 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
276 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);