1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fl_sample1.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"
36 class MyApp
: public wxApp
42 class MyFrame
: public wxFrame
45 wxFrameLayout
* mpLayout
;
46 wxWindow
* mpClientWnd
;
47 wxPanel
* mpInternalFrm
;
49 wxTextCtrl
* CreateTextCtrl( const wxString
& value
);
52 MyFrame( wxWindow
* parent
, const wxChar
*title
);
55 void OnLoad( wxCommandEvent
& event
);
56 void OnStore( wxCommandEvent
& event
);
57 void OnQuit( wxCommandEvent
& event
);
59 bool OnClose(void) { return true; }
64 /***** Implementation for class MyApp *****/
68 bool MyApp::OnInit(void)
70 // wxWidgets boiler-plate:
72 MyFrame
*frame
= new MyFrame(NULL
, _("wxFrameLayout sample"));
74 wxMenu
*file_menu
= new wxMenu
;
76 file_menu
->Append( ID_LOAD
, _("&Load layout") );
77 file_menu
->Append( ID_STORE
, _("&Store layout") );
78 file_menu
->AppendSeparator();
80 file_menu
->Append( ID_QUIT
, _("E&xit") );
82 wxMenuBar
*menu_bar
= new wxMenuBar
;
84 menu_bar
->Append(file_menu
, _("&File"));
87 frame
->CreateStatusBar(3);
88 #endif // wxUSE_STATUSBAR
89 frame
->SetMenuBar(menu_bar
);
98 /***** Immlementation for class MyFrame *****/
100 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
101 EVT_MENU( ID_LOAD
, MyFrame::OnLoad
)
102 EVT_MENU( ID_STORE
, MyFrame::OnStore
)
103 EVT_MENU( ID_QUIT
, MyFrame::OnQuit
)
106 MyFrame::MyFrame( wxWindow
* parent
, const wxChar
*title
)
107 : wxFrame( parent
, wxID_ANY
, title
, wxDefaultPosition
,
109 wxCLIP_CHILDREN
| wxMINIMIZE_BOX
| wxMAXIMIZE_BOX
|
110 wxTHICK_FRAME
| wxSYSTEM_MENU
| wxCAPTION
,
113 mpInternalFrm
= (wxPanel
*)this;
115 mpClientWnd
= CreateTextCtrl( _("Client window") );
117 // btw, creation of internal frame is needed for wxGtk version
118 // to act correctly (since menu-bar is a separate window there..)
120 mpLayout
= new wxFrameLayout( mpInternalFrm
, mpClientWnd
);
122 #if defined(__WXGTK__) || defined(__WXX11__)
123 // real-time dosn't work well under wxGtk yet
124 cbCommonPaneProperties props
;
125 mpLayout
->GetPaneProperties( props
);
127 props
.mRealTimeUpdatesOn
= false; // off
129 mpLayout
->SetPaneProperties( props
, wxALL_PANES
);
132 mpLayout
->PushDefaultPlugins();
133 mpLayout
->AddPlugin( CLASSINFO( cbBarHintsPlugin
) ); // facny "X"es and beveal for barso
134 //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
136 cbDimInfo
sizes( 80,65, // when docked horizontally
137 80,65, // when docked vertically
138 80,30, // when floated
139 true, // the bar is fixed-size
140 5, // vertical gap (bar border)
141 5 // horizontal gap (bar border)
145 for( int i
= 1; i
<= 20; ++i
)
148 wxSprintf( buf
, wxT("%d"), i
);
149 wxString name
= wxString(wxT("Bar-"));
152 sizes
.mIsFixed
= i
% 5 > 0; // every fifth bar is not fixed-size
154 if ( !sizes
.mIsFixed
) name
+= wxT(" (flexible)");
156 mpLayout
->AddBar( CreateTextCtrl(name
),// bar window
157 sizes
, i
% MAX_PANES
,// alignment ( 0-top,1-bottom, etc)
158 0, // insert into 0th row (vert. position)
159 0, // offset from the start of row (in pixels)
160 name
// name to refere in customization pop-ups
167 // layout is not a window, should be released manually
172 wxTextCtrl
* MyFrame::CreateTextCtrl( const wxString
& value
)
174 wxTextCtrl
* pCtrl
= new wxTextCtrl( mpInternalFrm
, wxID_ANY
, value
,
175 wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE
);
177 pCtrl
->SetBackgroundColour( wxColour( 255,255,255 ) );
182 void MyFrame::OnLoad( wxCommandEvent
& WXUNUSED(event
) )
184 wxMessageBox(wxT("Hey - you found a BIG question-mark !!"));
187 void MyFrame::OnStore( wxCommandEvent
& WXUNUSED(event
) )
189 wxMessageBox(wxT("Hey - you found another BIG question-mark !!"));
192 void MyFrame::OnQuit( wxCommandEvent
& WXUNUSED(event
) )
194 Show( false ); // TRICK:: hide it, to avoid flickered destruction