]>
Commit | Line | Data |
---|---|---|
306dfc2b JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: Studio.cpp | |
3 | // Purpose: Studio application class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 27/7/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: | |
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 | #include "wx/mdi.h" | |
22 | #endif | |
23 | ||
24 | #include "wx/resource.h" | |
25 | #include "wx/config.h" | |
26 | #include "wx/laywin.h" | |
27 | ||
28 | #ifdef __WXGTK__ | |
29 | #include "folder.xpm" | |
30 | #endif | |
31 | ||
32 | #include "studio.h" | |
33 | #include "view.h" | |
34 | #include "doc.h" | |
35 | #include "mainfrm.h" | |
36 | #include "cspalette.h" | |
37 | #include "project.h" | |
38 | #include "symbols.h" | |
39 | ||
40 | #if defined(__WXGTK__) || defined(__WXMOTIF__) | |
41 | #include "bitmaps/new.xpm" | |
42 | #include "bitmaps/open.xpm" | |
43 | #include "bitmaps/save.xpm" | |
44 | #include "bitmaps/copy.xpm" | |
45 | #include "bitmaps/cut.xpm" | |
46 | #include "bitmaps/paste.xpm" | |
47 | #include "bitmaps/print.xpm" | |
48 | #include "bitmaps/help.xpm" | |
49 | #include "bitmaps/undo.xpm" | |
50 | #include "bitmaps/redo.xpm" | |
51 | ||
52 | #include "bitmaps/alignl.xpm" | |
53 | #include "bitmaps/alignr.xpm" | |
54 | #include "bitmaps/alignt.xpm" | |
55 | #include "bitmaps/alignb.xpm" | |
56 | #include "bitmaps/horiz.xpm" | |
57 | #include "bitmaps/vert.xpm" | |
58 | #include "bitmaps/copysize.xpm" | |
59 | #include "bitmaps/linearrow.xpm" | |
60 | #include "bitmaps/newpoint.xpm" | |
61 | #include "bitmaps/cutpoint.xpm" | |
62 | #include "bitmaps/straight.xpm" | |
63 | ||
64 | #include "studio.xpm" | |
65 | #endif | |
66 | ||
67 | IMPLEMENT_APP(csApp) | |
68 | ||
69 | csApp::csApp() | |
70 | { | |
71 | m_docManager = NULL; | |
72 | m_diagramPalette = NULL; | |
73 | m_diagramToolBar = NULL; | |
74 | m_projectTreeCtrl = NULL; | |
75 | m_diagramPaletteSashWindow = NULL; | |
76 | m_projectSashWindow = NULL; | |
77 | m_symbolDatabase = NULL; | |
78 | m_pointSizeComboBox = NULL; | |
79 | m_zoomComboBox = NULL; | |
80 | m_shapeEditMenu = NULL; | |
81 | ||
82 | // Configuration | |
83 | m_mainFramePos.x = 20; | |
84 | m_mainFramePos.y = 20; | |
85 | m_mainFrameSize.x = 500; | |
86 | m_mainFrameSize.y = 400; | |
87 | m_gridStyle = csGRID_STYLE_INVISIBLE; | |
88 | m_gridSpacing = 5; | |
89 | } | |
90 | ||
91 | csApp::~csApp() | |
92 | { | |
93 | } | |
94 | ||
95 | // Initialise this in OnInit, not statically | |
96 | bool csApp::OnInit(void) | |
97 | { | |
98 | if (!wxResourceParseFile("studio_resources.wxr")) | |
99 | { | |
100 | wxMessageBox("Could not find or parse resource file: studio_resources.wxr", "Studio"); | |
101 | return FALSE; | |
102 | } | |
103 | ||
104 | m_helpController.Initialize("studio.hlp"); | |
105 | ||
106 | ReadOptions(); | |
107 | ||
108 | wxOGLInitialize(); | |
109 | ||
110 | InitSymbols(); | |
111 | ||
112 | //// Create a document manager | |
113 | m_docManager = new wxDocManager; | |
114 | ||
115 | //// Create a template relating drawing documents to their views | |
116 | (void) new wxDocTemplate(m_docManager, "Diagram", "*.dia", "", "dia", "Diagram Doc", "Diagram View", | |
117 | CLASSINFO(csDiagramDocument), CLASSINFO(csDiagramView)); | |
118 | ||
119 | // Create the main frame window | |
120 | ||
121 | csFrame* frame = new csFrame(m_docManager, NULL, -1, "OGL Studio", m_mainFramePos, m_mainFrameSize, | |
122 | wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); | |
123 | ||
124 | // Give it an icon | |
125 | frame->SetIcon(wxICON(studio)); | |
126 | ||
127 | // Make a menubar | |
128 | wxMenu *fileMenu = new wxMenu; | |
129 | ||
130 | fileMenu->Append(wxID_NEW, "&New...\tCtrl+N"); | |
131 | fileMenu->Append(wxID_OPEN, "&Open...\tCtrl+O"); | |
132 | ||
133 | fileMenu->AppendSeparator(); | |
134 | ||
135 | fileMenu->Append(wxID_PRINT, "&Print...\tCtrl+P"); | |
136 | fileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); | |
137 | fileMenu->Append(wxID_PREVIEW, "Print Pre&view"); | |
138 | fileMenu->AppendSeparator(); | |
139 | fileMenu->Append(wxID_EXIT, "E&xit"); | |
140 | ||
141 | // A history of files visited. Use this menu. | |
142 | m_docManager->FileHistoryUseMenu(fileMenu); | |
143 | ||
144 | wxMenu *viewMenu = new wxMenu; | |
145 | viewMenu->Append(ID_CS_SETTINGS, "&Settings..."); | |
146 | ||
147 | wxMenu *helpMenu = new wxMenu; | |
148 | helpMenu->Append(wxID_HELP, "&Help Contents\tF1"); | |
149 | helpMenu->Append(ID_CS_ABOUT, "&About"); | |
150 | ||
151 | wxMenuBar *menuBar = new wxMenuBar; | |
152 | ||
153 | menuBar->Append(fileMenu, "&File"); | |
154 | menuBar->Append(viewMenu, "&View"); | |
155 | menuBar->Append(helpMenu, "&Help"); | |
156 | ||
157 | // Associate the menu bar with the frame | |
158 | frame->SetMenuBar(menuBar); | |
159 | ||
160 | // Load the file history | |
161 | wxConfig config("OGL Studio", "wxWindows"); | |
162 | m_docManager->FileHistoryLoad(config); | |
163 | ||
164 | frame->CreateStatusBar(); | |
165 | ||
166 | // The ordering of these is important for layout purposes | |
167 | CreateDiagramToolBar(frame); | |
168 | CreatePalette(frame); | |
169 | CreateProjectWindow(frame); | |
170 | ||
171 | FillProjectTreeCtrl(); | |
172 | ||
173 | // Create the shape editing menu | |
174 | m_shapeEditMenu = new wxMenu("", (wxFunction)studioShapeEditProc); | |
175 | m_shapeEditMenu->Append(ID_CS_EDIT_PROPERTIES, "Edit properties"); | |
176 | m_shapeEditMenu->AppendSeparator(); | |
177 | m_shapeEditMenu->Append(ID_CS_ROTATE_CLOCKWISE, "Rotate clockwise"); | |
178 | m_shapeEditMenu->Append(ID_CS_ROTATE_ANTICLOCKWISE, "Rotate anticlockwise"); | |
179 | m_shapeEditMenu->AppendSeparator(); | |
180 | m_shapeEditMenu->Append(ID_CS_CUT, "Cut"); | |
181 | ||
182 | frame->Show(TRUE); | |
183 | ||
184 | SetTopWindow(frame); | |
185 | ||
186 | return TRUE; | |
187 | } | |
188 | ||
189 | int csApp::OnExit(void) | |
190 | { | |
191 | WriteOptions(); | |
192 | ||
193 | delete m_symbolDatabase; | |
194 | m_symbolDatabase = NULL; | |
195 | ||
196 | delete m_docManager; | |
197 | m_docManager = NULL; | |
198 | ||
199 | delete m_shapeEditMenu; | |
200 | m_shapeEditMenu = NULL; | |
201 | ||
202 | wxOGLCleanUp(); | |
203 | ||
204 | return 0; | |
205 | } | |
206 | ||
207 | /* | |
208 | * Centralised code for creating a document frame. | |
209 | * Called from view.cpp, when a view is created. | |
210 | */ | |
211 | ||
212 | wxMDIChildFrame *csApp::CreateChildFrame(wxDocument *doc, wxView *view, wxMenu** editMenuRet) | |
213 | { | |
214 | //// Make a child frame | |
215 | csMDIChildFrame *subframe = new csMDIChildFrame(doc, view, ((wxDocMDIParentFrame*)GetTopWindow()), -1, "Child Frame", | |
216 | wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); | |
217 | ||
218 | #ifdef __WXMSW__ | |
219 | subframe->SetIcon(wxString("chart")); | |
220 | #endif | |
221 | #ifdef __X__ | |
222 | subframe->SetIcon(wxIcon("doc.xbm")); | |
223 | #endif | |
224 | ||
225 | //// Make a menubar | |
226 | wxMenu *fileMenu = new wxMenu; | |
227 | ||
228 | fileMenu->Append(wxID_NEW, "&New...\tCtrl+N"); | |
229 | fileMenu->Append(wxID_OPEN, "&Open...\tCtrl+O"); | |
230 | fileMenu->Append(wxID_CLOSE, "&Close\tCtrl+W"); | |
231 | fileMenu->Append(wxID_SAVE, "&Save\tCtrl+S"); | |
232 | fileMenu->Append(wxID_SAVEAS, "Save &As...\tF12"); | |
233 | ||
234 | fileMenu->AppendSeparator(); | |
235 | fileMenu->Append(wxID_PRINT, "&Print...\tCtrl+P"); | |
236 | fileMenu->Append(wxID_PRINT_SETUP, "Print &Setup..."); | |
237 | fileMenu->Append(wxID_PREVIEW, "Print Pre&view"); | |
238 | ||
239 | fileMenu->AppendSeparator(); | |
240 | fileMenu->Append(wxID_EXIT, "E&xit"); | |
241 | ||
242 | wxMenu *editMenu = NULL; | |
243 | ||
244 | editMenu = new wxMenu; | |
245 | editMenu->Append(wxID_UNDO, "&Undo\tCtrl+Z"); | |
246 | editMenu->Append(wxID_REDO, "&Redo\tCtrl+Y"); | |
247 | editMenu->AppendSeparator(); | |
248 | editMenu->Append(wxID_CUT, "Cu&t\tCtrl+X"); | |
249 | editMenu->Append(wxID_COPY, "&Copy\tCtrl+C"); | |
250 | editMenu->Append(wxID_PASTE, "&Paste\tCtrl+V"); | |
251 | editMenu->Append(wxID_DUPLICATE, "&Duplicate\tCtrl+D"); | |
252 | editMenu->AppendSeparator(); | |
253 | editMenu->Append(wxID_CLEAR, "Cle&ar\tDelete"); | |
254 | editMenu->Append(ID_CS_SELECT_ALL, "Select A&ll\tCtrl+A"); | |
255 | editMenu->AppendSeparator(); | |
256 | editMenu->Append(ID_CS_EDIT_PROPERTIES, "Edit P&roperties..."); | |
257 | ||
258 | *editMenuRet = editMenu; | |
259 | ||
260 | m_docManager->FileHistoryUseMenu(fileMenu); | |
261 | m_docManager->FileHistoryAddFilesToMenu(fileMenu); | |
262 | ||
263 | doc->GetCommandProcessor()->SetEditMenu(editMenu); | |
264 | ||
265 | wxMenu *viewMenu = new wxMenu; | |
266 | viewMenu->Append(ID_CS_SETTINGS, "&Settings..."); | |
267 | ||
268 | wxMenu *helpMenu = new wxMenu; | |
269 | helpMenu->Append(wxID_HELP, "&Help Contents\tF1"); | |
270 | helpMenu->Append(ID_CS_ABOUT, "&About"); | |
271 | ||
272 | wxMenuBar *menuBar = new wxMenuBar; | |
273 | ||
274 | menuBar->Append(fileMenu, "&File"); | |
275 | menuBar->Append(editMenu, "&Edit"); | |
276 | menuBar->Append(viewMenu, "&View"); | |
277 | menuBar->Append(helpMenu, "&Help"); | |
278 | ||
279 | //// Associate the menu bar with the frame | |
280 | subframe->SetMenuBar(menuBar); | |
281 | ||
282 | return subframe; | |
283 | } | |
284 | ||
285 | // Creates a canvas. Called by OnInit as a child of the main window | |
286 | csCanvas *csApp::CreateCanvas(wxView *view, wxFrame *parent) | |
287 | { | |
288 | int width, height; | |
289 | parent->GetClientSize(&width, &height); | |
290 | ||
291 | // Non-retained canvas | |
292 | csCanvas *canvas = new csCanvas((csDiagramView*) view, parent, 1000, wxPoint(0, 0), wxSize(width, height), 0); | |
293 | ||
294 | wxColour bgColour("WHITE"); | |
295 | canvas->SetBackgroundColour(bgColour); | |
296 | ||
297 | wxCursor cursor(wxCURSOR_HAND); | |
298 | canvas->SetCursor(cursor); | |
299 | ||
300 | // Give it scrollbars | |
301 | canvas->SetScrollbars(20, 20, 100, 100); | |
302 | ||
303 | return canvas; | |
304 | } | |
305 | ||
306 | void csApp::InitToolBar(wxToolBar* toolBar) | |
307 | { | |
308 | wxBitmap* bitmaps[10]; | |
309 | ||
310 | #ifdef __WXMSW__ | |
311 | bitmaps[0] = new wxBitmap("new", wxBITMAP_TYPE_RESOURCE); | |
312 | bitmaps[1] = new wxBitmap("open", wxBITMAP_TYPE_RESOURCE); | |
313 | bitmaps[2] = new wxBitmap("save", wxBITMAP_TYPE_RESOURCE); | |
314 | bitmaps[3] = new wxBitmap("copy", wxBITMAP_TYPE_RESOURCE); | |
315 | bitmaps[4] = new wxBitmap("cut", wxBITMAP_TYPE_RESOURCE); | |
316 | bitmaps[5] = new wxBitmap("paste", wxBITMAP_TYPE_RESOURCE); | |
317 | bitmaps[6] = new wxBitmap("print", wxBITMAP_TYPE_RESOURCE); | |
318 | bitmaps[7] = new wxBitmap("help", wxBITMAP_TYPE_RESOURCE); | |
319 | bitmaps[8] = new wxBitmap("undo", wxBITMAP_TYPE_RESOURCE); | |
320 | bitmaps[9] = new wxBitmap("redo", wxBITMAP_TYPE_RESOURCE); | |
321 | #elif defined(__WXGTK__) || defined(__WXMOTIF__) | |
322 | bitmaps[0] = new wxBitmap( new_xpm ); | |
323 | bitmaps[1] = new wxBitmap( open_xpm ); | |
324 | bitmaps[2] = new wxBitmap( save_xpm ); | |
325 | bitmaps[3] = new wxBitmap( copy_xpm ); | |
326 | bitmaps[4] = new wxBitmap( cut_xpm ); | |
327 | bitmaps[5] = new wxBitmap( paste_xpm ); | |
328 | bitmaps[6] = new wxBitmap( print_xpm ); | |
329 | bitmaps[7] = new wxBitmap( help_xpm ); | |
330 | bitmaps[8] = new wxBitmap( undo_xpm ); | |
331 | bitmaps[9] = new wxBitmap( redo_xpm ); | |
332 | #else | |
333 | #error "Not implemented for this platform." | |
334 | #endif | |
335 | ||
336 | toolBar->AddTool(wxID_NEW, *bitmaps[0], wxNullBitmap, FALSE, -1, -1, NULL, "New file"); | |
337 | toolBar->AddTool(wxID_OPEN, *bitmaps[1], wxNullBitmap, FALSE, -1, -1, NULL, "Open file"); | |
338 | toolBar->AddTool(wxID_SAVE, *bitmaps[2], wxNullBitmap, FALSE, -1, -1, NULL, "Save file"); | |
339 | toolBar->AddSeparator(); | |
340 | toolBar->AddTool(wxID_PRINT, *bitmaps[6], wxNullBitmap, FALSE, -1, -1, NULL, "Print"); | |
341 | toolBar->AddSeparator(); | |
342 | toolBar->AddTool(wxID_COPY, *bitmaps[3], wxNullBitmap, FALSE, -1, -1, NULL, "Copy"); | |
343 | toolBar->AddTool(wxID_CUT, *bitmaps[4], wxNullBitmap, FALSE, -1, -1, NULL, "Cut"); | |
344 | toolBar->AddTool(wxID_PASTE, *bitmaps[5], wxNullBitmap, FALSE, -1, -1, NULL, "Paste"); | |
345 | toolBar->AddSeparator(); | |
346 | toolBar->AddTool(wxID_UNDO, *bitmaps[8], wxNullBitmap, FALSE, -1, -1, NULL, "Undo"); | |
347 | toolBar->AddTool(wxID_REDO, *bitmaps[9], wxNullBitmap, FALSE, -1, -1, NULL, "Redo"); | |
348 | toolBar->AddSeparator(); | |
349 | toolBar->AddTool(wxID_HELP, *bitmaps[7], wxNullBitmap, FALSE, -1, -1, NULL, "Help"); | |
350 | ||
351 | toolBar->Realize(); | |
352 | ||
353 | toolBar->EnableTool(wxID_COPY, FALSE); | |
354 | toolBar->EnableTool(wxID_PASTE, FALSE); | |
355 | toolBar->EnableTool(wxID_PRINT, FALSE); | |
356 | toolBar->EnableTool(wxID_UNDO, FALSE); | |
357 | toolBar->EnableTool(wxID_REDO, FALSE); | |
358 | ||
359 | int i; | |
360 | for (i = 0; i < 10; i++) | |
361 | delete bitmaps[i]; | |
362 | } | |
363 | ||
364 | // Create and initialise the diagram toolbar | |
365 | void csApp::CreateDiagramToolBar(wxFrame* parent) | |
366 | { | |
367 | // First create a layout window | |
368 | wxSashLayoutWindow* win = new wxSashLayoutWindow(parent, ID_LAYOUT_WINDOW_DIAGRAM_TOOLBAR, wxDefaultPosition, wxSize(200, 30), wxNO_BORDER|wxSW_3D|wxCLIP_CHILDREN); | |
369 | win->SetDefaultSize(wxSize(10000, 30)); | |
370 | win->SetOrientation(wxLAYOUT_HORIZONTAL); | |
371 | win->SetAlignment(wxLAYOUT_TOP); | |
372 | win->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); | |
373 | ||
374 | m_diagramToolBarSashWindow = win; | |
375 | m_diagramToolBarSashWindow->Show(FALSE); | |
376 | ||
377 | // Create the actual toolbar | |
378 | m_diagramToolBar = new wxToolBar(win, -1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxNO_BORDER|wxTB_FLAT); | |
379 | ||
380 | wxBitmap* bitmaps[11]; | |
381 | ||
382 | #ifdef __WXMSW__ | |
383 | bitmaps[0] = new wxBitmap("alignl", wxBITMAP_TYPE_RESOURCE); | |
384 | bitmaps[1] = new wxBitmap("alignr", wxBITMAP_TYPE_RESOURCE); | |
385 | bitmaps[2] = new wxBitmap("alignt", wxBITMAP_TYPE_RESOURCE); | |
386 | bitmaps[3] = new wxBitmap("alignb", wxBITMAP_TYPE_RESOURCE); | |
387 | bitmaps[4] = new wxBitmap("horiz", wxBITMAP_TYPE_RESOURCE); | |
388 | bitmaps[5] = new wxBitmap("vert", wxBITMAP_TYPE_RESOURCE); | |
389 | bitmaps[6] = new wxBitmap("copysize", wxBITMAP_TYPE_RESOURCE); | |
390 | bitmaps[7] = new wxBitmap("linearrow", wxBITMAP_TYPE_RESOURCE); | |
391 | bitmaps[8] = new wxBitmap("newpoint", wxBITMAP_TYPE_RESOURCE); | |
392 | bitmaps[9] = new wxBitmap("cutpoint", wxBITMAP_TYPE_RESOURCE); | |
393 | bitmaps[10] = new wxBitmap("straighten", wxBITMAP_TYPE_RESOURCE); | |
394 | #elif defined(__WXGTK__) || defined(__WXMOTIF__) | |
395 | bitmaps[0] = new wxBitmap( alignl_xpm ); | |
396 | bitmaps[1] = new wxBitmap( alignr_xpm ); | |
397 | bitmaps[2] = new wxBitmap( alignt_xpm ); | |
398 | bitmaps[3] = new wxBitmap( alignb_xpm ); | |
399 | bitmaps[4] = new wxBitmap( horiz_xpm ); | |
400 | bitmaps[5] = new wxBitmap( vert_xpm ); | |
401 | bitmaps[6] = new wxBitmap( copysize_xpm ); | |
402 | bitmaps[7] = new wxBitmap( linearrow_xpm ); | |
403 | bitmaps[8] = new wxBitmap( newpoint_xpm ); | |
404 | bitmaps[9] = new wxBitmap( cutpoint_xpm ); | |
405 | bitmaps[10] = new wxBitmap( straight_xpm ); | |
406 | #else | |
407 | #error "Not implemented for this platform." | |
408 | #endif | |
409 | ||
410 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNL, *bitmaps[0], wxNullBitmap, FALSE, -1, -1, NULL, "Align left"); | |
411 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNR, *bitmaps[1], wxNullBitmap, FALSE, -1, -1, NULL, "Align right"); | |
412 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNT, *bitmaps[2], wxNullBitmap, FALSE, -1, -1, NULL, "Align top"); | |
413 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNB, *bitmaps[3], wxNullBitmap, FALSE, -1, -1, NULL, "Align bottom"); | |
414 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGN_HORIZ, *bitmaps[4], wxNullBitmap, FALSE, -1, -1, NULL, "Align horizontally"); | |
415 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGN_VERT, *bitmaps[5], wxNullBitmap, FALSE, -1, -1, NULL, "Align vertically"); | |
416 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_COPY_SIZE, *bitmaps[6], wxNullBitmap, FALSE, -1, -1, NULL, "Copy size"); | |
417 | m_diagramToolBar->AddSeparator(); | |
418 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_LINE_ARROW, *bitmaps[7], wxNullBitmap, TRUE, -1, -1, NULL, "Toggle arrow"); | |
419 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_NEW_POINT, *bitmaps[8], wxNullBitmap, FALSE, -1, -1, NULL, "New line point"); | |
420 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_CUT_POINT, *bitmaps[9], wxNullBitmap, FALSE, -1, -1, NULL, "Cut line point"); | |
421 | m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_STRAIGHTEN, *bitmaps[10], wxNullBitmap, FALSE, -1, -1, NULL, "Straighten lines"); | |
422 | ||
423 | m_diagramToolBar->Realize(); | |
424 | ||
425 | int i; | |
426 | for (i = 0; i < 11; i++) | |
427 | delete bitmaps[i]; | |
428 | ||
429 | // Create a combobox for point size | |
430 | int maxPointSize = 40; | |
431 | wxString *pointSizes = new wxString[maxPointSize]; | |
432 | for (i = 1; i <= maxPointSize; i++) | |
433 | { | |
434 | pointSizes[i-1].Printf("%d", i); | |
435 | } | |
436 | ||
437 | int controlX = 260; | |
438 | int pointSizeW = 40; | |
439 | int pointSizeH = 18; | |
440 | int zoomW = 60; | |
441 | int zoomH = 18; | |
442 | #ifdef __WXMOTIF__ | |
443 | controlX += 70; | |
444 | pointSizeW = 60; | |
445 | pointSizeH = 22; | |
446 | zoomW = 60; | |
447 | zoomH = 22; | |
448 | #endif | |
449 | ||
450 | m_pointSizeComboBox = new wxComboBox(m_diagramToolBar, ID_WINDOW_POINT_SIZE_COMBOBOX, | |
451 | "", wxPoint(controlX, 1), wxSize(pointSizeW, pointSizeH), maxPointSize, pointSizes); | |
452 | delete[] pointSizes; | |
453 | ||
454 | m_pointSizeComboBox->SetSelection(10 - 1); | |
455 | ||
456 | // Create a combobox for zooming | |
457 | int maxZoom = 200; | |
458 | int minZoom = 5; | |
459 | int increment = 5; | |
460 | int noStrings = (maxZoom - minZoom)/5 ; | |
461 | wxString *zoomStrings = new wxString[noStrings]; | |
462 | for (i = 0; i < noStrings; i ++) | |
463 | { | |
464 | zoomStrings[noStrings - i - 1].Printf("%d%%", (i*increment + minZoom)); | |
465 | } | |
466 | ||
467 | controlX += pointSizeW + 10; | |
468 | ||
469 | m_zoomComboBox = new wxComboBox(m_diagramToolBar, ID_WINDOW_ZOOM_COMBOBOX, | |
470 | "", wxPoint(controlX, 1), wxSize(zoomW, zoomH), noStrings, zoomStrings); | |
471 | delete[] zoomStrings; | |
472 | ||
473 | // i = (zoom - minZoom)/increment | |
474 | // index = noStrings - i - 1 | |
475 | // 100% | |
476 | i = (100 - minZoom)/increment; | |
477 | m_zoomComboBox->SetSelection(noStrings - i - 1); | |
478 | } | |
479 | ||
480 | // Read/write configuration information | |
481 | bool csApp::ReadOptions() | |
482 | { | |
483 | wxConfig config("OGL Studio", "wxWindows"); | |
484 | ||
485 | config.Read("mainX", & m_mainFramePos.x); | |
486 | config.Read("mainY", & m_mainFramePos.y); | |
487 | config.Read("mainWidth", & m_mainFrameSize.x); | |
488 | config.Read("mainHeight", & m_mainFrameSize.y); | |
489 | config.Read("gridStyle", & m_gridStyle); | |
490 | config.Read("gridSpacing", & m_gridSpacing); | |
491 | ||
492 | return TRUE; | |
493 | } | |
494 | ||
495 | bool csApp::WriteOptions() | |
496 | { | |
497 | wxConfig config("OGL Studio", "wxWindows"); | |
498 | ||
499 | config.Write("mainX", m_mainFramePos.x); | |
500 | config.Write("mainY", m_mainFramePos.y); | |
501 | config.Write("mainWidth", m_mainFrameSize.x); | |
502 | config.Write("mainHeight", m_mainFrameSize.y); | |
503 | config.Write("gridStyle", m_gridStyle); | |
504 | config.Write("gridSpacing", m_gridSpacing); | |
505 | ||
506 | m_docManager->FileHistorySave(config); | |
507 | ||
508 | return TRUE; | |
509 | } | |
510 |