home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / contrib / samples / ogl / studio / studio.cpp < prev    next >
C/C++ Source or Header  |  2002-03-21  |  18KB  |  523 lines

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