]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/fl/fl_demo1.cpp
New wxTE_ flags
[wxWidgets.git] / contrib / samples / fl / fl_demo1.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: No names yet.
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by: Sebastian Haase (June 21, 2001)
6 // Created: 04/11/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12
13 #ifdef __GNUG__
14 #pragma implementation "fl_demo1.h"
15 #endif
16
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #ifndef WX_PRECOMP
25 #include "wx/wx.h"
26 #endif
27
28 #include "wx/textctrl.h"
29
30 // fl headers
31 #include "wx/fl/controlbar.h" // core API
32
33 // extra plugins
34 #include "wx/fl/barhintspl.h" // bevel for bars with "X"s and grooves
35 #include "wx/fl/rowdragpl.h" // NC-look with draggable rows
36 #include "wx/fl/cbcustom.h" // customization plugin
37 #include "wx/fl/hintanimpl.h"
38
39 // beauty-care
40 #include "wx/fl/gcupdatesmgr.h" // smooth d&d
41 #include "wx/fl/antiflickpl.h" // double-buffered repaint of decorations
42 #include "wx/fl/dyntbar.h" // auto-layout toolbar
43 #include "wx/fl/dyntbarhnd.h" // control-bar dimension handler for it
44
45 #include "fl_demo1.h"
46
47 // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
48
49 char wxDummyChar;
50
51
52 IMPLEMENT_APP (MyApp)
53
54 bool MyApp::OnInit(void)
55 {
56 MyFrame *frame = new MyFrame(NULL);
57
58 frame->SetBackgroundColour( wxColour(192,192,192) );
59
60 wxMenu *file_menu = new wxMenu;
61
62 file_menu->Append( NEW_TEST_LOAD, _("&Load layouts") );
63 file_menu->Append( NEW_TEST_SAVE, _("&Store layouts") );
64 file_menu->Append( NEW_TEST_EXIT, _("E&xit") );
65
66 wxMenuBar *menu_bar = new wxMenuBar;
67
68 menu_bar->Append(file_menu, _("&File"));
69
70 frame->SetMenuBar(menu_bar);
71
72 #if wxUSE_STATUSBAR
73 frame->CreateStatusBar(3);
74 #endif // wxUSE_STATUSBAR
75
76 frame->Show(true);
77
78 frame->mpClientWnd->Refresh();
79
80 SetTopWindow(frame);
81
82
83 wxMessageBox(_("Hello, this demo has a bunch of yet-not-fixed-bugs and missing functionality\n\
84 The ONLY purpose is to demonstrate self-layouting toolbars,\nflat-bitmapped-buttons and 2-new FL-plugins \
85 (cbRowDragPlugin & cbBarHintsPlugin)\n\n\
86 BTW, disabled images and label-text are rendered at run-time") );
87
88 return true;
89 }
90
91 /***** Implementation for class MyFrame *****/
92
93 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
94 // EVT_CHAR_HOOK(MyFrame::OnKeyDown)
95 // EVT_PAINT( MyFrame::OnPaint )
96 EVT_MENU( NEW_TEST_SAVE, MyFrame::OnSave )
97 EVT_MENU( NEW_TEST_LOAD, MyFrame::OnLoad )
98 EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit )
99 END_EVENT_TABLE()
100
101 void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) )
102 {
103 wxMessageBox(_T("Hey - you found a BIG question-mark !!"));
104 }
105
106 void MyFrame::OnSave( wxCommandEvent& WXUNUSED(event) )
107 {
108 wxMessageBox(_("Hey - you found another BIG question-mark !!"));
109 }
110
111 void MyFrame::OnExit( wxCommandEvent& WXUNUSED(event) )
112 {
113 Destroy();
114 }
115
116 wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
117 {
118 wxTextCtrl* pCtrl =
119
120 new wxTextCtrl( this, wxID_ANY, value,
121 wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE );
122
123 pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
124
125 return pCtrl;
126 }
127
128 MyFrame::MyFrame(wxFrame *frame)
129 : wxFrame( frame, wxID_ANY, _("wxWidgets 2.0 wxFrameLayout Test Application"), wxDefaultPosition,
130 wxSize( 700, 500 ),
131 wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
132 wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION,
133 wxT("freimas") )
134 {
135 mpClientWnd = CreateTextCtrl( _("Client window") );
136
137 mpLayout = new wxFrameLayout( this, mpClientWnd );
138
139 #if defined(__WXGTK__) || defined(__WXX11__)
140 cbCommonPaneProperties props;
141 mpLayout->GetPaneProperties( props );
142
143 props.mRealTimeUpdatesOn = false; // real-time OFF!!!
144
145 mpLayout->SetPaneProperties( props, wxALL_PANES );
146 #endif
147
148 mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() );
149
150 // this is now default...
151 //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes
152
153 // setup plugins for testing
154 mpLayout->PushDefaultPlugins();
155
156 mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // fancy "X"es and bevel for bars
157 mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
158 mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
159 mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) );
160 mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );
161
162 // drop in some bars
163 cbDimInfo sizes0( 200,45, // when docked horizontally
164 200,85, // when docked vertically
165 175,35, // when floated
166 false, // the bar is not fixed-size
167 4, // vertical gap (bar border)
168 4 // horizontal gap (bar border)
169 );
170
171 cbDimInfo sizes1( 150,35, // when docked horizontally
172 150,85, // when docked vertically
173 175,35, // when floated
174 true, // the bar is not fixed-size
175 4, // vertical gap (bar border)
176 4 // horizontal gap (bar border)
177 );
178
179 cbDimInfo sizes2( 195,35, // when docked horizontally
180 185,37, // when docked vertically
181 195,35, // when floated
182 true, // the bar is not fixed-size
183 4, // vertical gap (bar border)
184 4, // horizontal gap (bar border)
185 new cbDynToolBarDimHandler()
186 );
187
188 mpLayout->AddBar( CreateTextCtrl(_("Hello")), // bar window
189 sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
190 0, // insert into 0th row (vert. position)
191 0, // offset from the start of row (in pixels)
192 _("InfoViewer1"), // name to refer in customization pop-ups
193 true
194 );
195
196 mpLayout->AddBar( CreateTextCtrl(_("Bye")), // bar window
197 sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
198 1, // insert into 0th row (vert. position)
199 0, // offset from the start of row (in pixels)
200 _("InfoViewer2"), // name to refer in customization pop-ups
201 true
202 );
203
204 mpLayout->AddBar( CreateTextCtrl(_("Fixed0")), // bar window
205 sizes1, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
206 0, // insert into 0th row (vert. position)
207 0, // offset from the start of row (in pixels)
208 _("ToolBar1"), // name to refer in customization pop-ups
209 true
210 );
211
212 wxDynamicToolBar* pToolBar = new wxDynamicToolBar();
213
214 pToolBar->Create( this, wxID_ANY );
215
216 // 1001-1006 ids of command events fired by added tool-buttons
217
218 pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") );
219 pToolBar->AddSeparator();
220 pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") );
221 pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") );
222 #if wxUSE_STATLINE
223 pToolBar->AddSeparator(new wxMySeparatorLine(pToolBar, wxID_ANY));
224 #endif // wxUSE_STATLINE
225 pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") );
226 pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") );
227 pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") );
228
229
230 mpLayout->AddBar( pToolBar, // bar window (can be NULL)
231 sizes2, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
232 0, // insert into 0th row (vert. position)
233 0, // offset from the start of row (in pixels)
234 wxT("ToolBar2"), // name to refer in customization pop-ups
235 false
236 );
237
238 mpLayout->EnableFloating( true ); // off, thinking about wxGtk...
239 }
240
241 MyFrame::~MyFrame()
242 {
243 if ( mpLayout)
244 delete mpLayout; // should be destroyed manually
245 }
246
247 #define LINE_SIZE 3
248 #if wxUSE_STATLINE
249 void wxMySeparatorLine::DoSetSize( int x, int y,
250 int width, int height,
251 int sizeFlags)
252 {
253 if (width < height)
254 {
255 x += (width - LINE_SIZE) / 2;
256 width = LINE_SIZE;
257 }
258 else
259 {
260 y += (height - LINE_SIZE) / 2;
261 height = LINE_SIZE;
262 }
263
264 wxStaticLine::DoSetSize(x, y, width, height, sizeFlags);
265 }
266 #endif // wxUSE_STATLINE