]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: main.cpp | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: | |
6 | // Created: 24/11/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "fl_sample.cpp" | |
14 | #pragma interface "fl_sample.cpp" | |
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 "controlbar.h" | |
29 | ||
30 | // plugins used | |
31 | #include "barhintspl.h" | |
32 | #include "hintanimpl.h" | |
33 | ||
34 | #include "wx/textctrl.h" | |
35 | ||
36 | // ADDED by alex (linker complaints...): | |
37 | #ifndef wxDUMMY_OBJ_INCLUDED | |
38 | char wxDummyChar=0; | |
39 | #endif | |
40 | ||
41 | #define ID_LOAD 102 | |
42 | #define ID_STORE 103 | |
43 | #define ID_QUIT 104 | |
44 | ||
45 | #define LAYOUT_FILE "layouts.dat" | |
46 | ||
47 | class MyApp: public wxApp | |
48 | { | |
49 | public: | |
50 | bool OnInit(void); | |
51 | }; | |
52 | ||
53 | class MyFrame: public wxFrame | |
54 | { | |
55 | protected: | |
56 | wxFrameLayout* mpLayout; | |
57 | wxWindow* mpClientWnd; | |
58 | wxPanel* mpInternalFrm; | |
59 | ||
60 | ||
61 | wxTextCtrl* CreateTextCtrl( const wxString& value ); | |
62 | ||
63 | ||
64 | public: | |
65 | MyFrame( wxWindow* parent, char *title ); | |
66 | ~MyFrame(); | |
67 | ||
68 | void OnQuit( wxCommandEvent& event ); | |
69 | ||
70 | bool OnClose(void) { return TRUE; } | |
71 | ||
72 | DECLARE_EVENT_TABLE() | |
73 | }; | |
74 | ||
75 | /***** Implementation for class MyApp *****/ | |
76 | ||
77 | IMPLEMENT_APP (MyApp) | |
78 | ||
79 | bool MyApp::OnInit(void) | |
80 | { | |
81 | // wxWindows boiler-plate: | |
82 | ||
83 | MyFrame *frame = new MyFrame(NULL, "wxFrameLayout sample"); | |
84 | ||
85 | wxMenu *file_menu = new wxMenu; | |
86 | ||
87 | file_menu->Append( ID_LOAD, "&Load layout" ); | |
88 | file_menu->Append( ID_STORE, "&Store layout" ); | |
89 | file_menu->AppendSeparator(); | |
90 | ||
91 | file_menu->Append( ID_QUIT, "E&xit" ); | |
92 | ||
93 | wxMenuBar *menu_bar = new wxMenuBar; | |
94 | ||
95 | menu_bar->Append(file_menu, "&File"); | |
96 | ||
97 | frame->CreateStatusBar(3); | |
98 | frame->SetMenuBar(menu_bar); | |
99 | ||
100 | frame->Show(TRUE); | |
101 | ||
102 | SetTopWindow(frame); | |
103 | ||
104 | return TRUE; | |
105 | } | |
106 | ||
107 | /***** Immlementation for class MyFrame *****/ | |
108 | ||
109 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
110 | ||
111 | EVT_MENU( ID_QUIT, MyFrame::OnQuit ) | |
112 | ||
113 | END_EVENT_TABLE() | |
114 | ||
115 | MyFrame::MyFrame( wxWindow* parent, char *title ) | |
116 | ||
117 | : wxFrame( parent, -1, "NewTest-II", wxDefaultPosition, | |
118 | wxSize( 700, 500 ), | |
119 | wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | | |
120 | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION, | |
121 | "freimas" ) | |
122 | { | |
123 | #ifdef __WXMSW__ | |
124 | mpInternalFrm = (wxPanel*)this; | |
125 | #else | |
126 | mpInternalFrm = new wxPanel( this, -1 ); | |
127 | #endif | |
128 | ||
129 | mpClientWnd = CreateTextCtrl( "Client window" ); | |
130 | ||
131 | // btw, creation of internal frame is needed for wxGtk version | |
132 | // to act correctly (since menu-bar is a separate window there..) | |
133 | ||
134 | mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd ); | |
135 | ||
136 | #ifdef __WXGTK__ | |
137 | ||
138 | // real-time dosn't work well under wxGtk yet | |
139 | cbCommonPaneProperties props; | |
140 | mpLayout->GetPaneProperties( props ); | |
141 | ||
142 | props.mRealTimeUpdatesOn = FALSE; // off | |
143 | ||
144 | mpLayout->SetPaneProperties( props, wxALL_PANES ); | |
145 | ||
146 | #endif | |
147 | ||
148 | mpLayout->PushDefaultPlugins(); | |
149 | mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for barso | |
150 | //mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); | |
151 | ||
152 | cbDimInfo sizes( 80,65, // when docked horizontally | |
153 | 80,65, // when docked vertically | |
154 | 80,30, // when floated | |
155 | TRUE, // the bar is fixed-size | |
156 | 5, // vertical gap (bar border) | |
157 | 5 // horizontal gap (bar border) | |
158 | ); | |
159 | ||
160 | // drop-in 20 bars | |
161 | ||
162 | for( int i = 1; i <= 10; ++i ) | |
163 | { | |
164 | char buf[4]; | |
165 | sprintf( buf, "%d", i ); | |
166 | wxString name = wxString("Bar-"); | |
167 | name += buf; | |
168 | ||
169 | sizes.mIsFixed = i % 5 > 0; // every fifth bar is not fixed-size | |
170 | ||
171 | if ( !sizes.mIsFixed ) name += " (flexible)"; | |
172 | ||
173 | mpLayout->AddBar( CreateTextCtrl(name),// bar window | |
174 | sizes, i % MAX_PANES,// alignment ( 0-top,1-bottom, etc) | |
175 | 0, // insert into 0th row (vert. position) | |
176 | 0, // offset from the start of row (in pixels) | |
177 | name // name to refere in customization pop-ups | |
178 | ); | |
179 | } | |
180 | } | |
181 | ||
182 | MyFrame::~MyFrame() | |
183 | { | |
184 | // layout is not a window, should be released manually | |
185 | ||
186 | if ( mpLayout ) delete mpLayout; | |
187 | } | |
188 | ||
189 | wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) | |
190 | { | |
191 | wxTextCtrl* pCtrl = | |
192 | ||
193 | new wxTextCtrl( mpInternalFrm, -1, value, | |
194 | wxPoint(0,0), wxSize(1,1), wxTE_MULTILINE ); | |
195 | ||
196 | pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) ); | |
197 | ||
198 | return pCtrl; | |
199 | } | |
200 | ||
201 | void MyFrame::OnQuit( wxCommandEvent& event ) | |
202 | { | |
203 | Show( FALSE ); // TRICK:: hide it, to avoid flickered destruction | |
204 | ||
205 | Close(TRUE); | |
206 | } | |
207 | ||
208 | #ifdef __HACK_MY_MSDEV40__ | |
209 | ||
210 | ////////////// new 2.0-magic (linker errors...) //////////////// | |
211 | ||
212 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) | |
213 | { | |
214 | wxCHECK_MSG( m_frameToolBar == NULL, FALSE, | |
215 | "recreating toolbar in wxFrame" ); | |
216 | ||
217 | wxToolBar* toolBar = OnCreateToolBar(style, id, name); | |
218 | if (toolBar) | |
219 | { | |
220 | SetToolBar(toolBar); | |
221 | PositionToolBar(); | |
222 | return toolBar; | |
223 | } | |
224 | else | |
225 | { | |
226 | return NULL; | |
227 | } | |
228 | } | |
229 | ||
230 | wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) | |
231 | { | |
232 | return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name); | |
233 | } | |
234 | ||
235 | #endif |