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