]>
Commit | Line | Data |
---|---|---|
03206f17 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: fl_sample1.cpp | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: Sebastian Haase (June 21, 2001) | |
6 | // Created: 24/11/98 | |
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 | class MyApp: public wxApp | |
37 | { | |
38 | public: | |
39 | bool OnInit(void); | |
40 | }; | |
41 | ||
42 | class MyFrame: public wxFrame | |
43 | { | |
44 | protected: | |
45 | wxFrameLayout* mpLayout; | |
46 | wxWindow* mpClientWnd; | |
47 | wxPanel* mpInternalFrm; | |
48 | ||
49 | wxTextCtrl* CreateTextCtrl( const wxString& value ); | |
50 | ||
51 | public: | |
05aa1fc7 | 52 | MyFrame( wxWindow* parent, const wxChar *title ); |
03206f17 VS |
53 | ~MyFrame(); |
54 | ||
55 | void OnLoad( wxCommandEvent& event ); | |
56 | void OnStore( wxCommandEvent& event ); | |
57 | void OnQuit( wxCommandEvent& event ); | |
58 | ||
59 | bool OnClose(void) { return TRUE; } | |
60 | ||
61 | DECLARE_EVENT_TABLE() | |
62 | }; | |
63 | ||
64 | /***** Implementation for class MyApp *****/ | |
65 | ||
66 | IMPLEMENT_APP (MyApp) | |
67 | ||
68 | bool MyApp::OnInit(void) | |
69 | { | |
70 | // wxWindows boiler-plate: | |
71 | ||
05aa1fc7 | 72 | MyFrame *frame = new MyFrame(NULL, _("wxFrameLayout sample")); |
03206f17 VS |
73 | |
74 | wxMenu *file_menu = new wxMenu; | |
75 | ||
05aa1fc7 JS |
76 | file_menu->Append( ID_LOAD, _("&Load layout") ); |
77 | file_menu->Append( ID_STORE, _("&Store layout") ); | |
03206f17 VS |
78 | file_menu->AppendSeparator(); |
79 | ||
05aa1fc7 | 80 | file_menu->Append( ID_QUIT, _("E&xit") ); |
03206f17 VS |
81 | |
82 | wxMenuBar *menu_bar = new wxMenuBar; | |
83 | ||
05aa1fc7 | 84 | menu_bar->Append(file_menu, _("&File")); |
03206f17 VS |
85 | |
86 | frame->CreateStatusBar(3); | |
87 | frame->SetMenuBar(menu_bar); | |
88 | ||
89 | frame->Show(TRUE); | |
90 | ||
91 | SetTopWindow(frame); | |
92 | ||
93 | return TRUE; | |
94 | } | |
95 | ||
96 | /***** Immlementation for class MyFrame *****/ | |
97 | ||
98 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
99 | EVT_MENU( ID_LOAD, MyFrame::OnLoad ) | |
100 | EVT_MENU( ID_STORE, MyFrame::OnStore ) | |
101 | EVT_MENU( ID_QUIT, MyFrame::OnQuit ) | |
102 | END_EVENT_TABLE() | |
103 | ||
05aa1fc7 JS |
104 | MyFrame::MyFrame( wxWindow* parent, const wxChar *title ) |
105 | : wxFrame( parent, -1, _("NewTest-II"), wxDefaultPosition, | |
03206f17 VS |
106 | wxSize( 700, 500 ), |
107 | wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | | |
108 | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION, | |
05aa1fc7 | 109 | wxT("freimas") ) |
03206f17 VS |
110 | { |
111 | mpInternalFrm = (wxPanel*)this; | |
112 | ||
05aa1fc7 | 113 | mpClientWnd = CreateTextCtrl( _("Client window") ); |
03206f17 VS |
114 | |
115 | // btw, creation of internal frame is needed for wxGtk version | |
116 | // to act correctly (since menu-bar is a separate window there..) | |
117 | ||
118 | mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd ); | |
119 | ||
120 | #if defined(__WXGTK__) || defined(__WXX11__) | |
121 | // real-time dosn't work well under wxGtk yet | |
122 | cbCommonPaneProperties props; | |
123 | mpLayout->GetPaneProperties( props ); | |
124 | ||
125 | props.mRealTimeUpdatesOn = FALSE; // off | |
126 | ||
127 | mpLayout->SetPaneProperties( props, wxALL_PANES ); | |
128 | #endif | |
129 | ||
130 | mpLayout->PushDefaultPlugins(); | |
131 | mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso | |
132 | //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); | |
133 | ||
134 | cbDimInfo sizes( 80,65, // when docked horizontally | |
135 | 80,65, // when docked vertically | |
136 | 80,30, // when floated | |
137 | TRUE, // the bar is fixed-size | |
138 | 5, // vertical gap (bar border) | |
139 | 5 // horizontal gap (bar border) | |
140 | ); | |
141 | ||
142 | // drop-in 20 bars | |
143 | for( int i = 1; i <= 20; ++i ) | |
144 | { | |
05aa1fc7 JS |
145 | wxChar buf[4]; |
146 | wxSprintf( buf, wxT("%d"), i ); | |
147 | wxString name = wxString(wxT("Bar-")); | |
03206f17 VS |
148 | name += buf; |
149 | ||
150 | sizes.mIsFixed = i % 5 > 0; // every fifth bar is not fixed-size | |
151 | ||
05aa1fc7 | 152 | if ( !sizes.mIsFixed ) name += wxT(" (flexible)"); |
03206f17 VS |
153 | |
154 | mpLayout->AddBar( CreateTextCtrl(name),// bar window | |
155 | sizes, i % MAX_PANES,// alignment ( 0-top,1-bottom, etc) | |
156 | 0, // insert into 0th row (vert. position) | |
157 | 0, // offset from the start of row (in pixels) | |
158 | name // name to refere in customization pop-ups | |
159 | ); | |
160 | } | |
161 | } | |
162 | ||
163 | MyFrame::~MyFrame() | |
164 | { | |
165 | // layout is not a window, should be released manually | |
166 | if ( mpLayout ) | |
167 | delete mpLayout; | |
168 | } | |
169 | ||
170 | wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) | |
171 | { | |
172 | wxTextCtrl* pCtrl = new wxTextCtrl( mpInternalFrm, -1, value, | |
173 | wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE ); | |
174 | ||
175 | pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) ); | |
176 | ||
177 | return pCtrl; | |
178 | } | |
179 | ||
180 | void MyFrame::OnLoad( wxCommandEvent& event ) | |
181 | { | |
05aa1fc7 | 182 | wxMessageBox(wxT("Hey - you found a BIG question-mark !!")); |
03206f17 VS |
183 | } |
184 | ||
185 | void MyFrame::OnStore( wxCommandEvent& event ) | |
186 | { | |
05aa1fc7 | 187 | wxMessageBox(wxT("Hey - you found another BIG question-mark !!")); |
03206f17 VS |
188 | } |
189 | ||
190 | void MyFrame::OnQuit( wxCommandEvent& event ) | |
191 | { | |
192 | Show( FALSE ); // TRICK:: hide it, to avoid flickered destruction | |
193 | ||
194 | Close(TRUE); | |
195 | } | |
196 |