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