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