]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/fl/fl_sample2.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fl_sample2.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"
37 class MyApp
: public wxApp
43 class MyFrame
: public wxFrame
46 wxFrameLayout
* mpLayout
;
47 wxWindow
* mpClientWnd
;
49 wxTextCtrl
* CreateTextCtrl( const wxString
& value
);
52 MyFrame( wxWindow
* parent
, char *title
);
55 void populateMyFrame();
56 void OnLoad( wxCommandEvent
& event
);
57 void OnStore( wxCommandEvent
& event
);
58 void OnQuit( wxCommandEvent
& event
);
60 bool OnClose(void) { return TRUE
; }
65 /***** Implementation for class MyApp *****/
69 bool MyApp::OnInit(void)
71 // wxWindows boiler-plate:
73 MyFrame
*frame
= new MyFrame(NULL
, "wxFrameLayout sample");
75 wxMenu
*file_menu
= new wxMenu
;
77 file_menu
->Append( ID_LOAD
, "&Load layout" );
78 file_menu
->Append( ID_STORE
, "&Store layout" );
79 file_menu
->AppendSeparator();
81 file_menu
->Append( ID_QUIT
, "E&xit" );
83 wxMenuBar
*menu_bar
= new wxMenuBar
;
85 menu_bar
->Append(file_menu
, "&File");
87 frame
->CreateStatusBar(3);
88 frame
->SetMenuBar(menu_bar
);
92 frame
->populateMyFrame();
97 /***** Immlementation for class MyFrame *****/
99 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
100 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
101 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
102 EVT_MENU( ID_QUIT
, MyFrame::OnQuit
)
105 MyFrame::MyFrame( wxWindow
* parent
, char *title
)
106 : wxFrame( parent
, -1, "NewTest-II", wxDefaultPosition
,
108 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
109 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
114 void MyFrame::populateMyFrame()
116 mpClientWnd
= CreateTextCtrl( "Client window" );
118 mpLayout
= new wxFrameLayout( this, mpClientWnd
);
120 /// mpLayout->PushDefaultPlugins();
121 /// mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso
122 /// //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
124 cbDimInfo
sizes( 80,65, // when docked horizontally
125 80,165, // when docked vertically
126 180,30, // when floated
127 TRUE
, // the bar is fixed-size
128 5, // vertical gap (bar border)
129 5 // horizontal gap (bar border)
133 for( int i
= 1; i
<= 10; ++i
)
139 sprintf( buf
, "%d", i
);
140 wxString name
= wxString("Bar-");
143 //sizes.mIsFixed = i % 2 > 0; // every fifth bar is not fixed-size
145 if ( !sizes
.mIsFixed
) name
+= " (flexible)";
146 // mpLayout->AddBar( CreateTextCtrl(name),// bar window
147 mpLayout
->AddBar( new wxTextCtrl(this, -1, name
),// bar window
148 sizes
, i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
149 0, // insert into 0th row (vert. position)
150 0, // offset from the start of row (in pixels)
151 name
// name to refere in customization pop-ups
154 mpLayout
->RecalcLayout(true);
163 // layout is not a window, should be released manually
168 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
170 wxTextCtrl
* pCtrl
= new wxTextCtrl( this, -1, value
,
171 wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE
);
173 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
178 void MyFrame::OnLoad( wxCommandEvent
& event
)
180 wxMessageBox("Hey - you found a BIG question-mark !!");
183 void MyFrame::OnStore( wxCommandEvent
& event
)
185 wxMessageBox("Hey - you found another BIG question-mark !!");
188 void MyFrame::OnQuit( wxCommandEvent
& event
)
190 Show( FALSE
); // TRICK:: hide it, to avoid flickered destruction