]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/fl/fl_sample2.cpp
Use a different manifest for each of x86, amd64 and ia64
[wxWidgets.git] / contrib / samples / fl / fl_sample2.cpp
CommitLineData
03206f17
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: fl_sample2.cpp
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by: Sebastian Haase (June 21, 2001)
0423ae97 6// Created: 24/11/98
03206f17
VS
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
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"
27
28// plugins used
29#include "wx/fl/barhintspl.h"
30#include "wx/fl/hintanimpl.h"
31
32#define ID_LOAD 102
33#define ID_STORE 103
34#define ID_QUIT 104
35
36
37class MyApp: public wxApp
0423ae97 38{
03206f17
VS
39public:
40 bool OnInit(void);
41};
42
43class MyFrame: public wxFrame
44{
45protected:
46 wxFrameLayout* mpLayout;
47 wxWindow* mpClientWnd;
0423ae97 48
03206f17 49 wxTextCtrl* CreateTextCtrl( const wxString& value );
0423ae97 50
03206f17 51public:
05aa1fc7 52 MyFrame( wxWindow* parent, const wxChar *title );
03206f17 53 ~MyFrame();
0423ae97 54
03206f17
VS
55 void populateMyFrame();
56 void OnLoad( wxCommandEvent& event );
57 void OnStore( wxCommandEvent& event );
58 void OnQuit( wxCommandEvent& event );
0423ae97 59
c82c42d4 60 bool OnClose(void) { return true; }
0423ae97 61
03206f17
VS
62 DECLARE_EVENT_TABLE()
63};
64
65/***** Implementation for class MyApp *****/
66
67IMPLEMENT_APP (MyApp)
68
69bool MyApp::OnInit(void)
70{
be5a51fb 71 // wxWidgets boiler-plate:
0423ae97 72
05aa1fc7 73 MyFrame *frame = new MyFrame(NULL, _("wxFrameLayout sample"));
0423ae97 74
03206f17 75 wxMenu *file_menu = new wxMenu;
0423ae97 76
05aa1fc7
JS
77 file_menu->Append( ID_LOAD, _("&Load layout") );
78 file_menu->Append( ID_STORE, _("&Store layout") );
03206f17 79 file_menu->AppendSeparator();
0423ae97 80
05aa1fc7 81 file_menu->Append( ID_QUIT, _("E&xit") );
0423ae97 82
03206f17 83 wxMenuBar *menu_bar = new wxMenuBar;
0423ae97 84
05aa1fc7 85 menu_bar->Append(file_menu, _("&File"));
0423ae97 86
d96cdd4a 87#if wxUSE_STATUSBAR
03206f17 88 frame->CreateStatusBar(3);
d96cdd4a 89#endif // wxUSE_STATUSBAR
03206f17 90 frame->SetMenuBar(menu_bar);
0423ae97 91
c82c42d4 92 frame->Show(true);
03206f17
VS
93 SetTopWindow(frame);
94 frame->populateMyFrame();
0423ae97 95
c82c42d4 96 return true;
03206f17
VS
97}
98
99/***** Immlementation for class MyFrame *****/
100
101BEGIN_EVENT_TABLE(MyFrame, wxFrame)
102 EVT_MENU( ID_LOAD, MyFrame::OnLoad )
103 EVT_MENU( ID_STORE, MyFrame::OnStore )
104 EVT_MENU( ID_QUIT, MyFrame::OnQuit )
105END_EVENT_TABLE()
106
05aa1fc7 107MyFrame::MyFrame( wxWindow* parent, const wxChar *title )
c82c42d4 108 : wxFrame( parent, wxID_ANY, title, wxDefaultPosition,
03206f17
VS
109 wxSize( 700, 500 ),
110 wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
0423ae97 111 wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX,
05aa1fc7 112 wxT("freimas") )
03206f17
VS
113{
114}
115
116void MyFrame::populateMyFrame()
117{
05aa1fc7 118 mpClientWnd = CreateTextCtrl( _("Client window") );
0423ae97 119
03206f17 120 mpLayout = new wxFrameLayout( this, mpClientWnd );
0423ae97 121
03206f17
VS
122 /// mpLayout->PushDefaultPlugins();
123 /// mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso
124 /// //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
0423ae97
MR
125
126 cbDimInfo sizes( 80,65, // when docked horizontally
127 80,165, // when docked vertically
128 180,30, // when floated
c82c42d4 129 true, // the bar is fixed-size
03206f17
VS
130 5, // vertical gap (bar border)
131 5 // horizontal gap (bar border)
0423ae97
MR
132 );
133
134 // drop-in 20 bars
03206f17
VS
135 for( int i = 1; i <= 10; ++i )
136 {
137 wxSleep(1);
138 wxYield(); // CHECK!
0423ae97 139
05aa1fc7
JS
140 wxChar buf[4];
141 wxSprintf( buf, wxT("%d"), i );
142 wxString name = wxString(wxT("Bar-"));
03206f17 143 name += buf;
0423ae97 144
03206f17 145 //sizes.mIsFixed = i % 2 > 0; // every fifth bar is not fixed-size
0423ae97 146
05aa1fc7 147 if ( !sizes.mIsFixed ) name += wxT(" (flexible)");
0423ae97
MR
148 // mpLayout->AddBar( CreateTextCtrl(name), // bar window
149 mpLayout->AddBar( new wxTextCtrl(this, wxID_ANY, name), // bar window
150 sizes, i % MAX_PANES, // alignment ( 0-top,1-bottom, etc)
151 0, // insert into 0th row (vert. position)
152 0, // offset from the start of row (in pixels)
153 name // name to refere in customization pop-ups
03206f17
VS
154 );
155
156 mpLayout->RecalcLayout(true);
0423ae97 157
03206f17
VS
158 // Layout();
159 // Refresh();
160 }
161}
162
163MyFrame::~MyFrame()
164{
165 // layout is not a window, should be released manually
0423ae97 166 if ( mpLayout )
03206f17
VS
167 delete mpLayout;
168}
169
170wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
171{
0423ae97 172 wxTextCtrl* pCtrl = new wxTextCtrl( this, wxID_ANY, value,
03206f17 173 wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE );
0423ae97 174
03206f17 175 pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) );
0423ae97 176
03206f17
VS
177 return pCtrl;
178}
179
8552e6f0 180void MyFrame::OnLoad( wxCommandEvent& WXUNUSED(event) )
03206f17 181{
05aa1fc7 182 wxMessageBox(wxT("Hey - you found a BIG question-mark !!"));
03206f17
VS
183}
184
8552e6f0 185void MyFrame::OnStore( wxCommandEvent& WXUNUSED(event) )
03206f17 186{
05aa1fc7 187 wxMessageBox(wxT("Hey - you found another BIG question-mark !!"));
03206f17
VS
188}
189
8552e6f0 190void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )
03206f17 191{
c82c42d4 192 Show( false ); // TRICK:: hide it, to avoid flickered destruction
0423ae97 193
c82c42d4 194 Close(true);
03206f17
VS
195}
196