]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/samples/test/fl_test.cpp
fixed the bug with the order of 2 size events when the scrollbar[s] (dis)appear in...
[wxWidgets.git] / utils / framelayout / samples / test / fl_test.cpp
CommitLineData
bd9396d5
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: minimal.cpp
3// Purpose: Minimal wxWindows sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12
13#ifdef __GNUG__
14#pragma implementation "minimal.cpp"
15#pragma interface "minimal.cpp"
16#endif
17
18// For compilers that support precompilation, includes "wx/wx.h".
19#include "wx/wxprec.h"
20
21/*
22#ifdef __BORLANDC__
23#pragma hdrstop
24#endif
25*/
26
27#ifndef WX_PRECOMP
28#include "wx/wx.h"
29#endif
30
31#include "wx/textctrl.h"
32
33#include "controlbar.h" // core API
34#include "fl_test.h"
35
36// extra plugins
37#include "barhintspl.h" // beveal for bars with "X"s and grooves
38#include "rowdragpl.h" // NC-look with dragable rows
39#include "cbcustom.h" // customization plugin
40#include "hintanimpl.h"
41
42// beuty-care
43#include "gcupdatesmgr.h" // smooth d&d
44#include "antiflickpl.h" // double-buffered repaint of decorations
45
46#include "dyntbar.h" // auto-layouting toolbar
47#include "dyntbarhnd.h" // control-bar dimension handler for it
48
49// comment it out if it breaks, (this is my workaround for MSDev 4.0 linker)
50
299d04bc 51#ifndef wxDUMMY_OBJ_INCLUDED
bd9396d5 52char wxDummyChar;
299d04bc 53#endif
bd9396d5
HH
54
55
56IMPLEMENT_APP (MyApp)
57
58bool MyApp::OnInit(void)
59{
60 MyFrame *frame = new MyFrame(NULL);
61
62 frame->SetBackgroundColour( wxColour(192,192,192) );
63
64 wxMenu *file_menu = new wxMenu;
65
bd9396d5
HH
66 file_menu->Append( NEW_TEST_EXIT, "E&xit" );
67
68 wxMenuBar *menu_bar = new wxMenuBar;
69
70 menu_bar->Append(file_menu, "&File");
71
72 frame->SetMenuBar(menu_bar);
73
74 frame->CreateStatusBar(3);
75
76 frame->Show(TRUE);
77
78 frame->mpClientWnd->Refresh();
79
80 SetTopWindow(frame);
81
82 return TRUE;
83
84 /*
85 wxMessageBox("Hello, this demo has a bunch of yet-not-fixed-bugs and misssing functionality\n\
86The ONLY purpose is to demostrate self-layouting toolbars,\n flat-bitmapped-buttons and 2-new FL-plugins\
87 (cbRowDragPlugin & cbBarHintsPlugin)\n\n\
88BTW, disabled images and label-text are rendered at run-time" );
89*/
90
91
92 return TRUE;
93}
94
95/***** Implementation for class MyFrame *****/
96
97BEGIN_EVENT_TABLE( MyFrame, wxFrame )
98
99// EVT_CHAR_HOOK(MyFrame::OnKeyDown)
100// EVT_PAINT( MyFrame::OnPaint )
bd9396d5
HH
101 EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit )
102
103END_EVENT_TABLE()
104
bd9396d5
HH
105void MyFrame::OnExit( wxCommandEvent& event )
106{
107 Destroy();
108}
109
110wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
111{
112 wxTextCtrl* pCtrl =
113
114 new wxTextCtrl( mpInternalFrm, -1, value,
115 wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE );
116
117 pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
118
119 return pCtrl;
120}
121
122MyFrame::MyFrame(wxFrame *frame)
123
124 : wxFrame( frame, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition,
125 wxSize( 700, 500 ),
126 wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
127 wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION,
128 "freimas" )
129{
bd9396d5 130 mpInternalFrm = (wxPanel*)this;
bd9396d5
HH
131 mpClientWnd = CreateTextCtrl( "Client window" );
132
bd9396d5
HH
133
134 mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd );
135
136
137#ifdef __WXGTK__
138
139 cbCommonPaneProperties props;
140 mpLayout->GetPaneProperties( props );
141
142 props.mRealTimeUpdatesOn = FALSE; // real-time OFF!!!
143
144 mpLayout->SetPaneProperties( props, wxALL_PANES );
145
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
155 mpLayout->PushDefaultPlugins();
156
157 mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars
158
159 mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
160 mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) );
161 mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) );
162 mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );
163
164 // drop in some bars
165
166 cbDimInfo sizes0(200,45, // when docked horizontally
167 200,85, // when docked vertically
168 175,35, // when floated
169 FALSE, // the bar is not fixed-size
170 4, // vertical gap (bar border)
171 4 // horizontal gap (bar border)
172 );
173
174 cbDimInfo sizes1(150,35, // when docked horizontally
175 150,85, // when docked vertically
176 175,35, // when floated
177 TRUE, // the bar is not fixed-size
178 4, // vertical gap (bar border)
179 4 // horizontal gap (bar border)
180 );
181
182 cbDimInfo sizes2(175,45, // when docked horizontally
183 175,37, // when docked vertically
184 170,35, // when floated
185 TRUE, // the bar is not fixed-size
186 4, // vertical gap (bar border)
187 4, // horizontal gap (bar border)
188 new cbDynToolBarDimHandler()
189 );
190
191 mpLayout->AddBar( CreateTextCtrl("Hello"), // bar window
192 sizes0, wxTOP, // alignment ( 0-top,1-bottom, etc)
193 0, // insert into 0th row (vert. position)
194 0, // offset from the start of row (in pixels)
195 "InfoViewer1", // name to refere in customization pop-ups
196 TRUE
197 );
198
199 mpLayout->AddBar( CreateTextCtrl("Bye"), // bar window
200 sizes0, wxTOP, // alignment ( 0-top,1-bottom, etc)
201 1, // insert into 0th row (vert. position)
202 0, // offset from the start of row (in pixels)
203 "InfoViewer2", // name to refere in customization pop-ups
204 TRUE
205 );
206
94129723 207 mpLayout->EnableFloating( FALSE ); // off, thinking bout wxGtk...
bd9396d5
HH
208}
209
210MyFrame::~MyFrame()
211{
212 if ( mpLayout) delete mpLayout; // should be destroyed manually
213}
214
215#ifdef __HACK_MY_MSDEV40__
216
217////////////// new 2.0-magic (linker errors...) ////////////////
218
219wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
220{
221 wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
222 "recreating toolbar in wxFrame" );
223
224 wxToolBar* toolBar = OnCreateToolBar(style, id, name);
225 if (toolBar)
226 {
227 SetToolBar(toolBar);
228 PositionToolBar();
229 return toolBar;
230 }
231 else
232 {
233 return NULL;
234 }
235}
236
237wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
238{
239 return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name);
240}
241
242#endif