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