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