]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/fl/fl_sample3/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
, char *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 // wxWindows 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");
91 frame
->CreateStatusBar(3);
92 frame
->SetMenuBar(menu_bar
);
100 /***** Immlementation for class MyFrame *****/
102 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
103 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
104 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
105 EVT_MENU( ID_QUIT
, MyFrame::OnQuit
)
106 EVT_BUTTON( ID_BUTT
, MyFrame::OnButt
)
107 EVT_BUTTON( ID_BUTT2
, MyFrame::OnButt2
)
110 MyFrame::MyFrame( wxWindow
* parent
, char *title
)
111 : wxFrame( parent
, -1, "NewTest-II", wxDefaultPosition
,
113 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
114 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
118 mpClientWnd
= new wxWindow(this, -1);
119 mpLayout
= new wxFrameLayout( this, mpClientWnd
);
121 /// mpLayout->PushDefaultPlugins();
122 /// mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso
123 /// //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
125 cbDimInfo
sizes( 80,65, // when docked horizontally
126 80,165, // when docked vertically
127 180,30, // when floated
128 TRUE
, // the bar is fixed-size
129 5, // vertical gap (bar border)
130 5 // horizontal gap (bar border)
136 for( int i
= 1; i
<= 11; ++i
)
139 sprintf( buf
, "%d", i
);
140 wxString name
= wxString("Bar-");
143 sizes
.mIsFixed
= (i
!=3); // every fifth bar is not fixed-size
145 if ( !sizes
.mIsFixed
) name
+= " (flexible)";
146 // mpLayout->AddBar( CreateTextCtrl(name),// bar window
147 if(i
!= 4 && i
!= 5 && i
!=11) {
148 mpLayout
->AddBar( new wxTextCtrl(this, -1, name
),// bar window
150 i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
151 0, // insert into 0th row (vert. position)
152 0, // offset from the start of row (in pixels)
153 name
// name to refere in customization pop-ups
156 mpLayout
->AddBar( new wxTextCtrl(this, -1, name
),// bar window
157 cbDimInfo( 100,100, 100,100, 100,100, TRUE
, 5, 5),
158 i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
159 0, // insert into 0th row (vert. position)
160 0, // offset from the start of row (in pixels)
161 name
// name to refere in customization pop-ups
164 my_butt
= new wxButton(this, ID_BUTT
, name
);
165 mpLayout
->AddBar( my_butt
,// bar window
166 cbDimInfo( 100,100, 200,200, 400,400, TRUE
, 5, 5),
167 i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
168 0, // insert into 0th row (vert. position)
169 0, // offset from the start of row (in pixels)
170 name
// name to refere in customization pop-ups
173 mpLayout
->AddBar( new wxButton(this, ID_BUTT2
, name
+"_2"),
174 cbDimInfo( 100,100, 200,200, 400,400, TRUE
, 5, 5),
175 i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
176 0, // insert into 0th row (vert. position)
177 0, // offset from the start of row (in pixels)
178 name
// name to refere in customization pop-ups
182 // mpLayout->RecalcLayout(true);
190 // layout is not a window, should be released manually
195 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
197 wxTextCtrl
* pCtrl
= new wxTextCtrl( this, -1, value
,
198 wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE
);
200 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
205 void MyFrame::OnLoad( wxCommandEvent
& event
)
207 wxMessageBox("Hey - you found a BIG question-mark !!");
210 void MyFrame::OnStore( wxCommandEvent
& event
)
212 wxMessageBox("Hey - you found another BIG question-mark !!");
215 void MyFrame::OnQuit( wxCommandEvent
& event
)
217 Show( FALSE
); // TRICK:: hide it, to avoid flickered destruction
222 void MyFrame::OnButt( wxCommandEvent
& event
)
226 // cbBarInfo* FindBarByName( const wxString& name );
231 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString("Bar-1"));
233 mpLayout
->InverseVisibility(x
);
240 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString("Bar-6"));
245 mpLayout
->SetBarState(x
, wxCBAR_FLOATING
, TRUE
);
246 //mpLayout->RecalcLayout(true);
247 mpLayout
->RepositionFloatedBar(x
);
251 mpLayout
->SetBarState(x
, 0, TRUE
);
252 //mpLayout->RecalcLayout(true);
253 //mpLayout->RepositionFloatedBar(x);
255 // // // x->mState = wxCBAR_FLOATING;
256 // // // mpLayout->ApplyBarProperties(x);
269 void MyFrame::OnButt2( wxCommandEvent
& event
)
273 // cbBarInfo* FindBarByName( const wxString& name );
278 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString("Bar-1"));
281 for(int a
=0;a
<MAX_BAR_STATES
;a
++)
283 x
->mDimInfo
.mSizes
[a
].x
= 200;
284 x
->mDimInfo
.mSizes
[a
].y
= 200;
286 x
->mpBarWnd
->SetSize(200,200);
287 mpLayout
->SetBarState(x
, wxCBAR_FLOATING
, TRUE
); // HACK !!!
288 mpLayout
->SetBarState(x
, 0, TRUE
); // HACK !!!
289 wxYield(); // HACK !!! needed to resize BEFORE redraw
290 mpLayout
->RefreshNow( TRUE
); // HACK !!! needed to trigger redraw
301 cbBarInfo
* x
= mpLayout
->FindBarByName(wxString("Bar-1"));
304 //mpLayout->InverseVisibility(x);
305 for(int a
=0;a
<MAX_BAR_STATES
;a
++)
307 // see cbPaneDrawPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event )
308 x
->mDimInfo
.mSizes
[a
].x
= 10 + 2 + 2*x
->mDimInfo
.mHorizGap
;
309 x
->mDimInfo
.mSizes
[a
].y
= 10 + 2 + 2*x
->mDimInfo
.mVertGap
;
311 x
->mpBarWnd
->SetSize(10,10);
312 mpLayout
->SetBarState(x
, wxCBAR_FLOATING
, TRUE
); // HACK !!!
313 mpLayout
->SetBarState(x
, 0, TRUE
); // HACK !!!
314 wxYield(); // HACK !!! needed to resize BEFORE redraw
315 mpLayout
->RefreshNow( TRUE
); // HACK !!! needed to trigger redraw
317 // // mpLayout->SetBarState(x, wxCBAR_FLOATING, TRUE);
318 // // mpLayout->RecalcLayout(true);
319 // // // mpLayout->RepositionFloatedBar(x);
320 // // mpLayout->RecalcLayout(true);
321 // // mpLayout->RepositionFloatedBar(x);
322 // // mpLayout->SetBarState(x, 0, TRUE);
324 // // mpLayout->RefreshNow( TRUE );
325 // // mpLayout->RecalcLayout(true);