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
,
130 mpInternalFrm
= (wxPanel
*)this;
131 mpClientWnd
= CreateTextCtrl( "Client window" );
134 mpLayout
= new wxFrameLayout( mpInternalFrm
, mpClientWnd
);
139 cbCommonPaneProperties props
;
140 mpLayout
->GetPaneProperties( props
);
142 props
.mRealTimeUpdatesOn
= FALSE
; // real-time OFF!!!
144 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
155 mpLayout
->PushDefaultPlugins();
157 mpLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for bars
159 mpLayout
->AddPlugin( CLASSINFO( cbHintAnimationPlugin
) );
160 mpLayout
->AddPlugin( CLASSINFO( cbRowDragPlugin
) );
161 mpLayout
->AddPlugin( CLASSINFO( cbAntiflickerPlugin
) );
162 mpLayout
->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin
) );
166 cbDimInfo
sizes0(200,45, // when docked horizontally
167 200,85, // when docked vertically
168 175,35, // when floated
169 FALSE
, // the bar is not fixed-size
170 4, // vertical gap (bar border)
171 4 // horizontal gap (bar border)
174 cbDimInfo
sizes1(150,35, // when docked horizontally
175 150,85, // when docked vertically
176 175,35, // when floated
177 TRUE
, // the bar is not fixed-size
178 4, // vertical gap (bar border)
179 4 // horizontal gap (bar border)
182 cbDimInfo
sizes2(175,45, // when docked horizontally
183 175,37, // when docked vertically
184 170,35, // when floated
185 TRUE
, // the bar is not fixed-size
186 4, // vertical gap (bar border)
187 4, // horizontal gap (bar border)
188 new cbDynToolBarDimHandler()
191 mpLayout
->AddBar( CreateTextCtrl("Hello"), // bar window
192 sizes0
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
193 0, // insert into 0th row (vert. position)
194 0, // offset from the start of row (in pixels)
195 "InfoViewer1", // name to refere in customization pop-ups
199 mpLayout
->AddBar( CreateTextCtrl("Bye"), // bar window
200 sizes0
, wxTOP
, // alignment ( 0-top,1-bottom, etc)
201 1, // insert into 0th row (vert. position)
202 0, // offset from the start of row (in pixels)
203 "InfoViewer2", // name to refere in customization pop-ups
207 mpLayout
->EnableFloating( FALSE
); // off, thinking bout wxGtk...
212 if ( mpLayout
) delete mpLayout
; // should be destroyed manually
215 #ifdef __HACK_MY_MSDEV40__
217 ////////////// new 2.0-magic (linker errors...) ////////////////
219 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
221 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
222 "recreating toolbar in wxFrame" );
224 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
237 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
239 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);