home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / draw / vdrwcmdw.cpp < prev    next >
C/C++ Source or Header  |  1998-07-07  |  23KB  |  656 lines

  1. //================================================================
  2. //  vdrwcmdw.cxx:     Source file for drawApp cmdwin class
  3. //  Copyright (C) 1995,1996  Bruce E. Wampler
  4. //================================================================
  5. #include <v/vnotice.h>  // so we can use notice
  6. #include <v/vfilesel.h> // for file selection
  7. #include <v/vutil.h>
  8. #include <v/vynreply.h>
  9. #include <v/vkeys.h>
  10.  
  11. #include "vdrwcmdw.h"   // our header
  12. #include "vdrwcnv.h"            // myCanvasPane class
  13. #include "vdrwdlg.h"    // for draw dialog
  14.  
  15. //-------------------------------------------------------------
  16. // MENUS and COMMAND BARS
  17. //-------------------------------------------------------------
  18.     // Define the File and Edit pulldown menus
  19.     static vMenu FileMenu[] =
  20.       {
  21.         {"&New", M_New, isSens, notChk, noKeyLbl, noKey, noSub},
  22.         {"&Open...", M_Open, isSens, notChk, noKeyLbl, noKey, noSub},
  23.         {"&Save", M_Save, isSens, notChk, noKeyLbl, noKey, noSub},
  24.         {"Save &as...", M_SaveAs, isSens,notChk,noKeyLbl,noKey,noSub},
  25.         {"&Close", m_CloseFile, isSens,notChk,noKeyLbl,noKey,noSub},
  26.         {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  27.         {"&Print", M_Print, isSens, notChk, noKeyLbl, noKey, noSub},
  28.         {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  29.         {"E&xit", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
  30.         {NULL}
  31.       };
  32.  
  33.     static vMenu EditMenu[] =
  34.       {
  35.         {"&Clear", m_Clr, isSens, notChk, noKeyLbl, noKey,noSub},
  36.         {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  37.         {"&Global Quick Pick", m_DrawAllDialog, isSens, notChk, noKeyLbl, noKey, noSub},
  38.         {NULL}
  39.       };
  40.  
  41.     static vMenu PenMenu[] =
  42.       {
  43.         {"&Solid", m_PenSolid, isSens, isChk, noKeyLbl, noKey,noSub},
  44.         {"&Transparent", m_PenTransparent, isSens, notChk, noKeyLbl, noKey,noSub},
  45.         {"&Dash", m_PenDash, isSens, notChk, noKeyLbl, noKey,noSub},
  46.         {"D&ot", m_PenDot, isSens, notChk, noKeyLbl, noKey,noSub},
  47.         {"D&ashDot", m_PenDashDot, isSens, notChk, noKeyLbl, noKey,noSub},
  48.         {NULL}
  49.       };
  50.  
  51.     static vMenu BrushMenu[] =
  52.       {
  53.         {"&Solid", m_BrushSolid, isSens, isChk, noKeyLbl, noKey,noSub},
  54.         {"&Transparent", m_BrushTransparent, isSens, notChk, noKeyLbl, noKey,noSub},
  55.         {"&Horizontal Hatch", m_BrushHoriz, isSens, notChk, noKeyLbl, noKey,noSub},
  56.         {"&Vertical Hatch", m_BrushVert, isSens, notChk, noKeyLbl, noKey,noSub},
  57.         {"&LeftDiag Hatch", m_BrushLeft, isSens, notChk, noKeyLbl, noKey,noSub},
  58.         {"&RightDiag Hatch", m_BrushRight, isSens, notChk, noKeyLbl, noKey,noSub},
  59.         {"&Cross Hatch", m_BrushCross, isSens, notChk, noKeyLbl, noKey,noSub},
  60.         {"&DiagCross Hatch", m_BrushDiagCross, isSens, notChk, noKeyLbl, noKey,noSub},
  61.         {NULL}
  62.       };
  63.  
  64.     static vMenu DrawMenu[] =
  65.       {
  66.         {"&Point            ", m_DrawPoint, isSens, notChk, "Alt-P", 'p',noSub,VKM_Alt},
  67.         {"&Line             ", m_DrawLine, isSens, isChk, "Alt-L", 'l', noSub, VKM_Alt},
  68.         {"&Rectangle        ", m_DrawRect, isSens, notChk, "Alt-R",'r',noSub, VKM_Alt},
  69.         {"R&ounded Rectangle", m_DrawRdRect, isSens, notChk, "Alt-O", 'o',noSub,VKM_Alt},
  70.         {"&Ellipse          ", m_DrawEllipse, isSens, notChk, "Alt-E", 'e',noSub,VKM_Alt},
  71.         {"&Triangle         ", m_DrawPoly, isSens, notChk, "Alt-T",'t',noSub,VKM_Alt},
  72. #ifdef ICON
  73.         {"Icon", m_DrawIcon, isSens, notChk, noKeyLbl, noKey,noSub},
  74. #endif
  75.         {NULL}
  76.       };
  77.  
  78.     // Define the main menu
  79.     vMenu MainMenu[] =
  80.       {
  81.         {"&File",M_File,isSens,notUsed,notUsed,noKey,&FileMenu[0]},
  82.         {"&Edit",M_Edit,isSens,notUsed,notUsed,noKey,&EditMenu[0]},
  83.         {"&Pen",90,isSens,notUsed,notUsed,noKey,&PenMenu[0]},
  84.         {"&Brush",91,isSens,notUsed,notUsed,noKey,&BrushMenu[0]},
  85.         {"&Draw",92,isSens,notUsed,notUsed,noKey,&DrawMenu[0]},
  86.         {NULL}
  87.       };
  88.  
  89.     // Define the command bar
  90.     static vColor btnColor(0,0,0);
  91.  
  92.     static int minMaxStep[3] = {1, 20, 1};      // for line width
  93.  
  94.     static char *penbrush[] = {"Pen Color", "Brush Color", "Background", 0 };
  95.  
  96.     // IMPORTANT - this order must correspond to the order used in the
  97.     // vDrawAllDialog class so SendWindowCommandAll can be used
  98.     static char *drawShape[] =
  99.       {
  100.         "Point", "Line", "Rectangle", "Round Rect",
  101.         "Ellipse", "Triangle", 0
  102.       };
  103.     static int drawVal[] =      // map val to command
  104.       {
  105.         m_DrawPoint, m_DrawLine, m_DrawRect, m_DrawRdRect,
  106.         m_DrawEllipse, m_DrawPoly, 0
  107.       };
  108.  
  109.     static CommandObject CommandBar[] =
  110.       {
  111.         {C_CheckBox, m_QuickPick, 0, "Quick Pick", NoList,
  112.                 CA_None,isSens,NoFrame,0,0},
  113.         {C_ComboBox, m_PenBrushCombo, 0, "",(void*)penbrush,
  114.                 CA_None,isSens,NoFrame,0,0},
  115.         {C_ColorButton, m_ColorBtn, 0, "", (void*)&btnColor,
  116.                 CA_None,isSens,NoFrame,0,0,16},
  117. #define vC_Size 8               // size of color buttons
  118. #include<v/vcb2x8.h>    // define a color selection box
  119.         {C_Label, 999, 0 ,"Pen Width:", NoList,
  120.                 CA_None, isSens, NoFrame,0,0},
  121.  
  122.         {C_Spinner,m_LineWidth,1,"",(void*)&minMaxStep[0],
  123.                 CA_None,isSens,NoFrame,0,0},
  124.         {C_ComboBox, m_DrawCombo, 1, "",(void*)drawShape,
  125.                 CA_None,isSens,NoFrame,0,0},
  126.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  127.       };
  128.  
  129.     vStatus StatBar[] =
  130.       {
  131.         {" Time: ", m_TimeLabel, CA_NoBorder, isSens, 0},
  132.         {" 0:00:00 AM  00/00/00 ",m_Time, CA_None, isSens, 0},
  133.         {"    Mouse X,Y: ", m_MousePosLbl, CA_NoBorder, isSens, 0 },
  134.         {" 000 ", m_MousePosX, CA_None, isSens, 0},
  135.         {" 000 ", m_MousePosY, CA_None, isSens, 0},
  136.         {NULL,0,0,0,0}
  137.       };
  138.  
  139.     static char* filter[] = {"*.drw","*", 0};   // file filter
  140.     static int filterIndex = 0;
  141.  
  142. //================>>> myCmdWindow::myCmdWindow <<<================
  143.   myCmdWindow::myCmdWindow(char* name, int width, int height) :
  144.     vCmdWindow(name, width, height)
  145.   {
  146.     // Create and add the proper panes to the CmdWindow
  147.  
  148.     *_fname = 0;                        // no name
  149.     _brush.SetColor(0,0,0);             // black brush
  150.     _pen.SetColor(0,0,0);               // black pen
  151.     _bg.Set(255,255,255);               // white background
  152.     curWidth = 1;
  153.     _mx = _my = 0;
  154.     changeColor = setPen;
  155.     brushMenuId = m_BrushSolid;
  156.     penMenuId = m_PenSolid;
  157.  
  158.     myMenu = new vMenuPane(MainMenu);   // Add the main menu
  159.     AddPane(myMenu);
  160.  
  161.     myCmdPane = new vCommandPane(CommandBar); // Add command pane
  162.     AddPane(myCmdPane);
  163.  
  164.     myCmdWindow* me  = this;
  165.     myCanvas = new myCanvasPane(me);    // Add the canvas pane
  166.     AddPane(myCanvas);
  167.     myCanvas->SetDrawShape(m_DrawLine); // We will be drawing line
  168.     curShape = m_DrawLine;
  169.  
  170.     // The Status Bar
  171.     myStatus = new vStatusPane(StatBar); // a new status bar
  172.     AddPane(myStatus);
  173.     _timer = new myTimer(this);         // create timer
  174.     _timer->TimerSet(1000);             // 2 second intervals
  175.  
  176.  
  177.     myDrwDlg = 0;                       // no dialog yet
  178.    
  179.     ShowWindow();           // FINALLY, we must show the window!
  180.  
  181.     WindowCommand(m_CurTime, m_CurTime, C_Button);      // update clock
  182.  
  183.     myCanvas->ShowVScroll(1);  // And, now turn on scroll bars
  184.     myCanvas->ShowHScroll(1);
  185.   }
  186.  
  187. //===============>>> myCmdWindow::~myCmdWindow <<<================
  188.   myCmdWindow::~myCmdWindow()
  189.   {
  190.     delete myMenu;      // Delete everything new'ed in
  191.     delete myCanvas;    //   the constructor
  192.     delete myCmdPane;
  193.     delete myStatus;
  194.     _timer->TimerStop();
  195.     delete _timer;
  196.     if (myDrwDlg)       // dialog?
  197.         delete myDrwDlg;
  198.   }
  199.  
  200. //==============>>> myCmdWindow::OpenFile <<<================
  201.   void myCmdWindow::OpenFile(char* fname)
  202.   {
  203.     char fn[256];               // scratch copy
  204.     int ix;
  205.  
  206.     if (*_fname)                // already have one!
  207.         return;
  208.     
  209.     for (ix = 0 ; fname[ix] != 0 && ix < 255 ; ++ix)
  210.       fn[ix] = fname[ix];       // safe copy
  211.     fn[ix] = 0;
  212.  
  213.     if (!*fn)           // no file open yet
  214.       {
  215.         vFileSelect fsel(this);     // V file select dialog
  216.         if (!fsel.FileSelect("Open V Draw File",
  217.             fn,255,filter,filterIndex) || !*fn)
  218.             return;
  219.       }
  220.  
  221.     if (!myCanvas->Read(fn))    // Save in _fname
  222.       {
  223.         vNoticeDialog note(this);       // for user notification
  224.         note.Notice("Unable to open file.");
  225.         return;
  226.       }
  227.     SetTitle(fn);               // show on title bar
  228.     strcpy(_fname,fn);          // keep copy
  229.     myCanvas->Redraw(0,0,0,0);  // paint it
  230.     myCanvas->SetChanged(0);    // not really changed
  231.   }
  232.  
  233. //==============>>> myCmdWindow::CheckClose <<<================
  234.   int myCmdWindow::CheckClose()
  235.   {
  236.     // return 1 if ok to close now, 0 to abort
  237.  
  238.     if (myCanvas->Changed())    // changes!
  239.       {
  240.         vYNReplyDialog ynr(this);
  241.         int ans = ynr.AskYN("Save new or changed drawing?");
  242.         if (ans == 0)
  243.           {
  244.             myCanvas->SetChanged(0);
  245.             return 1;           // don't want to save
  246.           }
  247.         if (ans == -1)          // cancel
  248.             return 0;
  249.  
  250.         // ok, want to save changed file
  251.         if (*_fname)                    // have a name
  252.           {
  253.             if (!myCanvas->Save(_fname))        // Save in _fname
  254.               {
  255.                 vNoticeDialog note(this);       // for user notification
  256.                 note.Notice("Unable to save file");
  257.                 return 0;
  258.               }
  259.           }
  260.         else                            // need to request name
  261.           {
  262.             vFileSelect fsel(this);     // V file select dialog
  263.  
  264.             if (!fsel.FileSelectSave("Save V Draw File As",
  265.                 _fname,99,filter,filterIndex) || !*_fname)
  266.             return 0;
  267.  
  268.             if (!myCanvas->Save(_fname))        // Save in _fname
  269.               {
  270.                 vNoticeDialog note(this);       // for user notification
  271.                 note.Notice("Unable to save file");
  272.                 return 0;
  273.               }
  274.           }
  275.       }
  276.     return 1;
  277.   }
  278.  
  279. //==============>>> myCmdWindow::MouseXYStatus <<<================
  280.   void myCmdWindow::MouseXYStatus(int x, int y)
  281.   {
  282.     char buff[12];
  283.  
  284.     _mx = x; _my = y;
  285.     IntToStr(x,buff);   // convert x
  286.     SetString(m_MousePosX,buff);
  287.     IntToStr(y,buff);
  288.     SetString(m_MousePosY,buff);
  289.   }
  290.  
  291.  
  292. //==============>>> myCmdWindow::WindowCommand <<<================
  293.   void myCmdWindow::WindowCommand(ItemVal id, ItemVal val,
  294.         CmdType cType)
  295.   {
  296.     // route all commands through here - menus and buttons
  297.  
  298.     vNoticeDialog note(this);   // for user notification
  299.  
  300.     switch (id)         // switch on id of commands
  301.       {
  302.         case M_New:     // new file
  303.           {
  304.             (void) theApp->NewAppWin(0,"V Draw - No Name",600,250,0);
  305.             break;
  306.           }
  307.  
  308.         case M_Open:                    // open existing file
  309.           {
  310.             if (*_fname)                // need to create a new window
  311.               {
  312.                 // create new window, then open a file in it.
  313.                 myCmdWindow* cw = (myCmdWindow*)
  314.                     theApp->NewAppWin(0,"V Draw - No Name",600, 250,0);
  315.                 cw->OpenFile("");       // open via dialog
  316.                 cw->RaiseWindow();      // bring to front
  317.               }
  318.             else
  319.                 OpenFile("");           // open a file using dialog
  320.                 
  321.             break;
  322.           }
  323.  
  324.         case m_CloseFile:               // Close current file
  325.           {
  326.             if (!myCanvas->Changed())   // not changed!
  327.               {
  328.                 myCanvas->ClearShapes();
  329.                 *_fname = 0;
  330.                 SetTitle("V Draw - No Name");   // no file
  331.                 break;
  332.               }
  333.             // else fall through
  334.           }
  335.  
  336.         case M_Save:                    // save current drawing
  337.           {
  338.             if (*_fname)                // already have a name
  339.               {
  340.                 if (!myCanvas->Save(_fname))    // Save in _fname
  341.                     note.Notice("Unable to save file");
  342.                 else if (id == m_CloseFile)
  343.                   {
  344.                     *_fname = 0;
  345.                     SetTitle("V Draw - No Name");       // no file
  346.                   }
  347.                 break;
  348.               }
  349.             // else fall through to SaveAs
  350.           }
  351.  
  352.         case M_SaveAs:                  // save file as
  353.           {
  354.             vFileSelect fsel(this);     // V file select dialog
  355.  
  356.             if (!fsel.FileSelectSave("Save V Draw File As",
  357.               _fname,99,filter,filterIndex) || !*_fname)
  358.                 break;                  // ignore if no selection
  359.  
  360.             if (!myCanvas->Save(_fname)) // Save in _fname
  361.               {
  362.                 note.Notice("Unable to save file");
  363.                 break;
  364.               }
  365.             if (id == m_CloseFile)
  366.               {
  367.                 *_fname = 0;
  368.                 SetTitle("V Draw - No Name");   // no file
  369.               }
  370.             else
  371.                 SetTitle(_fname);               // change title
  372.             break;
  373.           }
  374.  
  375.         case M_Exit:                    // quit all
  376.           {
  377.             if (CheckClose())           // ok to close
  378.                 theApp->Exit(); // Standard action for Exit
  379.             break;
  380.           }
  381.  
  382.         case m_LineWidth:               // change line width
  383.           {
  384.             _pen.SetWidth(val);         // set new pen width
  385.             myCanvas->SetPen(_pen);
  386.             break;
  387.           }
  388.  
  389.         case m_Clr:                   // clear the screen
  390.           {
  391.             myCanvas->ClearShapes();
  392.             break;
  393.           }
  394.  
  395.         case M_Print:                   // print
  396.           {
  397.             myCanvas->Print();
  398.             break;
  399.           }
  400.  
  401.         case m_PenSolid:                // change to solid pen
  402.           {
  403.             _pen.SetStyle(vSolid);
  404.             myCanvas->SetPen(_pen);
  405.             SetValue(penMenuId,0,Checked);      // uncheck old style
  406.             penMenuId = id;
  407.             SetValue(penMenuId,1,Checked);      // check new style
  408.             break;
  409.           }
  410.  
  411.         case m_PenTransparent:          // transparent pen
  412.           {
  413.             _pen.SetStyle(vTransparent);
  414.             myCanvas->SetPen(_pen);
  415.             SetValue(penMenuId,0,Checked);
  416.             penMenuId = id;
  417.             SetValue(penMenuId,1,Checked);
  418.             break;
  419.           }
  420.  
  421.         case m_PenDash:                 // dashed pen
  422.           {
  423.             _pen.SetStyle(vDash);
  424.             myCanvas->SetPen(_pen);
  425.             SetValue(penMenuId,0,Checked);
  426.             penMenuId = id;
  427.             SetValue(penMenuId,1,Checked);
  428.             break;
  429.           }
  430.  
  431.         case m_PenDot:                  // dotted pen
  432.           {
  433.             _pen.SetStyle(vDot);
  434.             myCanvas->SetPen(_pen);
  435.             SetValue(penMenuId,0,Checked);
  436.             penMenuId = id;
  437.             SetValue(penMenuId,1,Checked);
  438.             break;
  439.           }
  440.  
  441.         case m_PenDashDot:              // dashed-dotted pen
  442.           {
  443.             _pen.SetStyle(vDashDot);
  444.             myCanvas->SetPen(_pen);
  445.             SetValue(penMenuId,0,Checked);
  446.             penMenuId = id;
  447.             SetValue(penMenuId,1,Checked);
  448.             break;
  449.           }
  450.  
  451.         case m_BrushSolid:              // solid brush
  452.           {
  453.             _brush.SetStyle(vSolid);
  454.             myCanvas->SetBrush(_brush);
  455.             SetValue(brushMenuId,0,Checked);
  456.             brushMenuId = id;
  457.             SetValue(brushMenuId,1,Checked);
  458.             break;
  459.           }
  460.  
  461.         case m_BrushTransparent:        // transparent brush
  462.           {
  463.             _brush.SetStyle(vTransparent);
  464.             myCanvas->SetBrush(_brush);
  465.             SetValue(brushMenuId,0,Checked);
  466.             brushMenuId = id;
  467.             SetValue(brushMenuId,1,Checked);
  468.             break;
  469.           }
  470.  
  471.         case m_BrushHoriz:              // horizontal brush
  472.           {
  473.             _brush.SetStyle(vHorizontalHatch );
  474.             myCanvas->SetBrush(_brush);
  475.             SetValue(brushMenuId,0,Checked);
  476.             brushMenuId = id;
  477.             SetValue(brushMenuId,1,Checked);
  478.             break;
  479.           }
  480.  
  481.         case m_BrushVert:               // vertical brush
  482.           {
  483.             _brush.SetStyle(vVerticalHatch);
  484.             myCanvas->SetBrush(_brush);
  485.             SetValue(brushMenuId,0,Checked);
  486.             brushMenuId = id;
  487.             SetValue(brushMenuId,1,Checked);
  488.             break;
  489.           }
  490.  
  491.         case m_BrushLeft:               // left diagonal hatch
  492.           {
  493.             _brush.SetStyle(vLeftDiagonalHatch );
  494.             myCanvas->SetBrush(_brush);
  495.             SetValue(brushMenuId,0,Checked);
  496.             brushMenuId = id;
  497.             SetValue(brushMenuId,1,Checked);
  498.             break;
  499.           }
  500.  
  501.         case m_BrushRight:              // right diagonal hatch
  502.           {
  503.             _brush.SetStyle(vRightDiagonalHatch );
  504.             myCanvas->SetBrush(_brush);
  505.             SetValue(brushMenuId,0,Checked);
  506.             brushMenuId = id;
  507.             SetValue(brushMenuId,1,Checked);
  508.             break;
  509.           }
  510.  
  511.         case m_BrushCross:              // cross hatch
  512.           {
  513.             _brush.SetStyle(vCrossHatch );
  514.             myCanvas->SetBrush(_brush);
  515.             SetValue(brushMenuId,0,Checked);
  516.             brushMenuId = id;
  517.             SetValue(brushMenuId,1,Checked);
  518.             break;
  519.           }
  520.  
  521.         case m_BrushDiagCross:          // cross diagonal
  522.           {
  523.             _brush.SetStyle(vDiagonalCrossHatch );
  524.             myCanvas->SetBrush(_brush);
  525.             SetValue(brushMenuId,0,Checked);
  526.             brushMenuId = id;
  527.             SetValue(brushMenuId,1,Checked);
  528.             break;
  529.           }
  530.  
  531.         case m_DrawLine:                // set what we are drawing
  532.         case m_DrawPoly:
  533.         case m_DrawRect:
  534.         case m_DrawRdRect:
  535. #ifdef ICON
  536.         case m_DrawIcon:                        // icon
  537. #endif
  538.         case m_DrawPoint:
  539.         case m_DrawEllipse:
  540.           {
  541.             SetValue(curShape,0,Checked);       // fix the menu check
  542.             curShape = id;
  543.             SetValue(curShape,1,Checked);
  544.             myCanvas->SetDrawShape(id);
  545.             for (int xx = 0 ; drawVal[xx] != 0 ; ++xx) // need to make combo
  546.               {                                 // have same as menu
  547.                 if (drawVal[xx] == id)
  548.                   {
  549.                     SetValue(m_DrawCombo, xx, Value);
  550.                     break;
  551.                   }
  552.               }
  553.             break;
  554.           }
  555.  
  556.         case m_PenBrushCombo:           // what color map represents
  557.           {
  558.             if (val == setPen)          // pen
  559.               {
  560.                 changeColor = setPen;
  561.                 SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().r(),Red);
  562.                 SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().g(),Green);
  563.                 SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().b(),Blue);
  564.               }
  565.             else if (val == setBrush)   // brush
  566.               {
  567.                 changeColor = setBrush;
  568.                 SetValue(m_ColorBtn,(ItemVal)_brush.GetColor().r(),Red);
  569.                 SetValue(m_ColorBtn,(ItemVal)_brush.GetColor().g(),Green);
  570.                 SetValue(m_ColorBtn,(ItemVal)_brush.GetColor().b(),Blue);
  571.               }
  572.             else                        // background
  573.               {
  574.                 changeColor = setBG;
  575.                 SetValue(m_ColorBtn,(ItemVal)_bg.r(),Red);
  576.                 SetValue(m_ColorBtn,(ItemVal)_bg.g(),Green);
  577.                 SetValue(m_ColorBtn,(ItemVal)_bg.b(),Blue);
  578.               }
  579.             break;
  580.           }
  581.  
  582.         case m_DrawCombo:               // select which shape to draw
  583.           {
  584.             SetValue(curShape,0,Checked);  // fix the menu check
  585.             curShape = drawVal[val];       // map to shape
  586.             SetValue(curShape,1,Checked);
  587.             myCanvas->SetDrawShape(curShape);
  588.             break;
  589.           }
  590.  
  591.         case m_CurTime:
  592.           {
  593.             char buff[40];
  594.             char date[30];
  595.             vGetLocalTime(buff);
  596.             vGetLocalDate(date);
  597.             strcat(buff,"  ");
  598.             strcat(buff,date);
  599.             SetString(m_Time,buff);
  600.             break;
  601.           }
  602.  
  603.         case m_QuickPick:               // open the quick pick dialog
  604.           {
  605.             if (val)
  606.               {
  607.                 if (!myDrwDlg)          // not created yet
  608.                     myDrwDlg = new vDrawDialog(this, 0);
  609.                 myDrwDlg->ShowDialog("Drawing Attributes");
  610.                 int l,t,w,h;
  611.                 GetPosition(l,t,w,h);   // my position
  612.                 myDrwDlg->SetDialogPosition(l+w+2,t);   // put quick pick here
  613.               }
  614.             else                        // close the dialog
  615.               {
  616.                 myDrwDlg->CloseDialog();
  617.               }
  618.             break;
  619.           }
  620.  
  621.         default:                        // change pen color?
  622.           {
  623.             if (id >= M_Black && id <= M_White)  // color button
  624.               {
  625.                 if (changeColor == setPen)      // what we are changing?
  626.                   {
  627.                     _pen.SetColor( vStdColors[val]);
  628.                     myCanvas->SetPen(_pen);
  629.                     SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().r(),Red);
  630.                     SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().g(),Green);
  631.                     SetValue(m_ColorBtn,(ItemVal)_pen.GetColor().b(),Blue);
  632.                   }
  633.                 else if (changeColor == setBrush)
  634.                   {
  635.                     _brush.SetColor(vStdColors[val]);
  636.                     myCanvas->SetBrush(_brush);
  637.                     SetValue(m_ColorBtn,(ItemVal)_brush.GetColor().r(),Red);
  638.                     SetValue(m_ColorBtn,(ItemVal)_brush.GetColor().g(),Green);
  639.                     SetValue(m_ColorBtn,(ItemVal)_brush.GetColor().b(),Blue);
  640.                   }
  641.                 else                    // set background
  642.                   {
  643.                     _bg.Set(vStdColors[val]);
  644.                     myCanvas->SetBackground(_bg);
  645.                     SetValue(m_ColorBtn,(ItemVal)_bg.r(),Red);
  646.                     SetValue(m_ColorBtn,(ItemVal)_bg.g(),Green);
  647.                     SetValue(m_ColorBtn,(ItemVal)_bg.b(),Blue);
  648.                   }
  649.               }
  650.             else                        // pass up hierarchy
  651.                 vCmdWindow::WindowCommand(id, val, cType);
  652.             break;
  653.           }
  654.       }
  655.   }
  656.