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