]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/fl/fl_sample3.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fl_sample3.cpp
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"
29 #include "wx/fl/barhintspl.h"
30 #include "wx/fl/hintanimpl.h"
39 class MyApp
: public wxApp
45 class MyFrame
: public wxFrame
48 wxFrameLayout
* mpLayout
;
49 wxWindow
* mpClientWnd
;
53 wxTextCtrl
* CreateTextCtrl( const wxString
& value
);
55 MyFrame( wxWindow
* parent
, const wxChar
*title
);
58 void OnLoad( wxCommandEvent
& event
);
59 void OnStore( wxCommandEvent
& event
);
60 void OnQuit( wxCommandEvent
& event
);
62 void OnButt( wxCommandEvent
& event
);
63 void OnButt2( wxCommandEvent
& event
);
64 bool OnClose(void) { return true; }
69 /***** Implementation for class MyApp *****/
73 bool MyApp::OnInit(void)
75 // wxWidgets boiler-plate:
77 MyFrame
*frame
= new MyFrame(NULL
, _("wxFrameLayout sample"));
79 wxMenu
*file_menu
= new wxMenu
;
81 file_menu
->Append( ID_LOAD
, _("&Load layout") );
82 file_menu
->Append( ID_STORE
, _("&Store layout") );
83 file_menu
->AppendSeparator();
85 file_menu
->Append( ID_QUIT
, _("E&xit") );
87 wxMenuBar
*menu_bar
= new wxMenuBar
;
89 menu_bar
->Append(file_menu
, _("&File"));
92 frame
->CreateStatusBar(3);
93 #endif // wxUSE_STATUSBAR
94 frame
->SetMenuBar(menu_bar
);
102 /***** Immlementation for class MyFrame *****/
104 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
105 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
106 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
107 EVT_MENU( ID_QUIT
, MyFrame::OnQuit
)
108 EVT_BUTTON( ID_BUTT
, MyFrame::OnButt
)
109 EVT_BUTTON( ID_BUTT2
, MyFrame::OnButt2
)
112 MyFrame::MyFrame( wxWindow
* parent
, const wxChar
*title
)
113 : wxFrame( parent
, wxID_ANY
, title
, wxDefaultPosition
,
115 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
116 wxRESIZE_BORDER
| wxSYSTEM_MENU
| wxCAPTION
| wxCLOSE_BOX
,
120 mpClientWnd
= new wxWindow(this, wxID_ANY
);
121 mpLayout
= new wxFrameLayout( this, mpClientWnd
);
123 /// mpLayout->PushDefaultPlugins();
124 /// mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso
125 /// //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
127 cbDimInfo
sizes( 80,65, // when docked horizontally
128 80,165, // when docked vertically
129 180,30, // when floated
130 true, // the bar is fixed-size
131 5, // vertical gap (bar border)
132 5 // horizontal gap (bar border)
138 for( int i
= 1; i
<= 11; ++i
)
141 wxSprintf( buf
, wxT("%d"), i
);
142 wxString name
= wxString(wxT("Bar-"));
145 sizes
.mIsFixed
= (i
!=3); // every fifth bar is not fixed-size
147 if ( !sizes
.mIsFixed
) name
+= wxT(" (flexible)");
148 // mpLayout->AddBar( CreateTextCtrl(name), // bar window
149 if(i
!= 4 && i
!= 5 && i
!=11) {
150 mpLayout
->AddBar( new wxTextCtrl(this, wxID_ANY
, name
), // bar window
152 i
% MAX_PANES
, // alignment ( 0-top,1-bottom, etc)
153 0, // insert into 0th row (vert. position)
154 0, // offset from the start of row (in pixels)
155 name
// name to refere in customization pop-ups
158 mpLayout
->AddBar( new wxTextCtrl(this, wxID_ANY
, name
), // bar window
159 cbDimInfo( 100,100, 100,100, 100,100, true, 5, 5),
160 i
% MAX_PANES
, // alignment ( 0-top,1-bottom, etc)
161 0, // insert into 0th row (vert. position)
162 0, // offset from the start of row (in pixels)
163 name
// name to refere in customization pop-ups
166 my_butt
= new wxButton(this, ID_BUTT
, name
);
167 mpLayout
->AddBar( my_butt
, // bar window
168 cbDimInfo( 100,100, 200,200, 400,400, true, 5, 5),
169 i
% MAX_PANES
, // alignment ( 0-top,1-bottom, etc)
170 0, // insert into 0th row (vert. position)
171 0, // offset from the start of row (in pixels)
172 name
// name to refere in customization pop-ups
175 mpLayout
->AddBar( new wxButton(this, ID_BUTT2
, name
+wxT("_2")),
176 cbDimInfo( 100,100, 200,200, 400,400, true, 5, 5),
177 i
% MAX_PANES
, // alignment ( 0-top,1-bottom, etc)
178 0, // insert into 0th row (vert. position)
179 0, // offset from the start of row (in pixels)
180 name
// name to refere in customization pop-ups
184 // mpLayout->RecalcLayout(true);
192 // layout is not a window, should be released manually
197 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
199 wxTextCtrl
* pCtrl
= new wxTextCtrl( this, wxID_ANY
, value
,
200 wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE
);
202 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
207 void MyFrame::OnLoad( wxCommandEvent
& WXUNUSED(event
) )
209 wxMessageBox(_("Hey - you found a BIG question-mark !!"));
212 void MyFrame::OnStore( wxCommandEvent
& WXUNUSED(event
) )
214 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
217 void MyFrame::OnQuit( wxCommandEvent
& WXUNUSED(event
) )
219 Show( false ); // TRICK:: hide it, to avoid flickered destruction
224 void MyFrame::OnButt( wxCommandEvent
& WXUNUSED(event
) )
228 // cbBarInfo* FindBarByName( const wxString& name );
233 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString(wxT("Bar-1")));
235 mpLayout
->InverseVisibility(x
);
242 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString(wxT("Bar-6")));
247 mpLayout
->SetBarState(x
, wxCBAR_FLOATING
, true);
248 //mpLayout->RecalcLayout(true);
249 mpLayout
->RepositionFloatedBar(x
);
253 mpLayout
->SetBarState(x
, 0, true);
254 //mpLayout->RecalcLayout(true);
255 //mpLayout->RepositionFloatedBar(x);
257 // // // x->mState = wxCBAR_FLOATING;
258 // // // mpLayout->ApplyBarProperties(x);
271 void MyFrame::OnButt2( wxCommandEvent
& WXUNUSED(event
) )
275 // cbBarInfo* FindBarByName( const wxString& name );
280 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString(wxT("Bar-1")));
283 for(int a
=0;a
<MAX_BAR_STATES
;a
++)
285 x
->mDimInfo
.mSizes
[a
].x
= 200;
286 x
->mDimInfo
.mSizes
[a
].y
= 200;
288 x
->mpBarWnd
->SetSize(200,200);
289 mpLayout
->SetBarState(x
, wxCBAR_FLOATING
, true); // HACK !!!
290 mpLayout
->SetBarState(x
, 0, true); // HACK !!!
291 wxYield(); // HACK !!! needed to resize BEFORE redraw
292 mpLayout
->RefreshNow( true ); // HACK !!! needed to trigger redraw
303 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString(wxT("Bar-1")));
306 //mpLayout->InverseVisibility(x);
307 for(int a
=0;a
<MAX_BAR_STATES
;a
++)
309 // see cbPaneDrawPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event )
310 x
->mDimInfo
.mSizes
[a
].x
= 10 + 2 + 2*x
->mDimInfo
.mHorizGap
;
311 x
->mDimInfo
.mSizes
[a
].y
= 10 + 2 + 2*x
->mDimInfo
.mVertGap
;
313 x
->mpBarWnd
->SetSize(10,10);
314 mpLayout
->SetBarState(x
, wxCBAR_FLOATING
, true); // HACK !!!
315 mpLayout
->SetBarState(x
, 0, true); // HACK !!!
316 wxYield(); // HACK !!! needed to resize BEFORE redraw
317 mpLayout
->RefreshNow( true ); // HACK !!! needed to trigger redraw
319 // mpLayout->SetBarState(x, wxCBAR_FLOATING, true);
320 // mpLayout->RecalcLayout(true);
321 // mpLayout->RepositionFloatedBar(x);
322 // mpLayout->RecalcLayout(true);
323 // mpLayout->RepositionFloatedBar(x);
324 // mpLayout->SetBarState(x, 0, true);
326 // mpLayout->RefreshNow( true );
327 // mpLayout->RecalcLayout(true);