home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / iconed / viedcmdw.cpp < prev    next >
C/C++ Source or Header  |  1998-11-17  |  39KB  |  1,341 lines

  1. //========================= viedcmdw.cxx ================================
  2. // This is the source file for the command window class.
  3. //
  4. // Copyright (C) 1996 Philip Eckenroth, Mike Tipping, Marilee Padilla,
  5. //                    John Fredric Jr. Masciantoni, and Bruce E. Wampler.
  6. //
  7. // This file is part of the V Icon Editor, and is covered
  8. // under the terms of the GNU General Public License,
  9. // Version 2. This program has NO WARRANTY. See the source file
  10. // viedapp.cpp for more complete information about license terms.
  11. //=======================================================================
  12.  
  13. #include <v/vnotice.h>          // use notice box
  14. #include <v/vfilesel.h>         // for file selection
  15. #include <v/vutil.h>            // use utilities
  16. #include <v/vynreply.h>         // use yes/no reply box
  17. #include <v/vreply.h>           // use reply box
  18. #include <v/vpen.h>             // use a pen
  19. #include <v/vicon.h>            // use v defined icons
  20. #include <v/vmodald.h>
  21.  
  22. #include <iostream.h>
  23. #include <ctype.h>
  24.  
  25. #include "viedapp.h"
  26. #include "viedcmdw.h"           // our header
  27. #include "viedcnv.h"            // myCanvasPane class
  28. #include "coldlg.h"             // color palette dialog
  29. #include "brshdlg.h"            // brush dialog
  30.  
  31. //-------------------------------------------------------------
  32. // MENUS and COMMAND BARS
  33. //-------------------------------------------------------------
  34. // Define the File and Edit pulldown menus
  35.  
  36. // Note - The space padding is necessary for X Athena to come out
  37. // looking right, and it is harmless for Windows
  38. static vMenu FileMenu[] =
  39.   {
  40.     {"&New       ", M_New, isSens, notChk, "Ctrl-N", 'N'-'@', noSub},
  41.     {"&Open...   ", M_Open, isSens, notChk, "Ctrl-O", 'O'-'@', noSub},
  42.     {"&Save      ", M_Save, isSens, notChk, "Ctrl-S", 'S'-'@', noSub},
  43.     {"Save &as...", M_SaveAs, isSens,notChk,noKeyLbl,noKey,noSub},
  44.     {"C&lose     ", m_CloseFile, isSens,notChk,"Ctrl-L",'L'-'@',noSub},
  45.     {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  46.     {"About V Icon Ed",M_About, isSens,notChk,noKeyLbl,noKey,noSub},
  47.     {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  48.     {"E&xit      ", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
  49.     {NULL}
  50.   };
  51.  
  52. static vMenu ZoomMenu[] =
  53.   {
  54.     {"&2", m_Zoom2, isSens, notChk, noKeyLbl, noKey,noSub},
  55.     {"&4", m_Zoom4, isSens, notChk, noKeyLbl, noKey,noSub},
  56.     {"&8", m_Zoom8, isSens, isChk, noKeyLbl, noKey,noSub},
  57.     {"&16", m_Zoom16, isSens, notChk, noKeyLbl, noKey,noSub},
  58.     {"&32", m_Zoom32, isSens, notChk, noKeyLbl, noKey,noSub},
  59.     {NULL}
  60.   };
  61.  
  62. static vMenu EditMenu[] =
  63.   {
  64.     {"&Undo         ", m_Undo, isSens, notChk, "Ctrl-Z", 'Z'-'@',noSub},
  65.     {"&Clear", m_Clear, isSens, notChk, noKeyLbl, noKey,noSub},
  66.     {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  67.     {"&Resize",m_Resize, isSens,notChk,noKeyLbl, noKey, noSub},
  68.     {NULL}
  69.   };
  70.  
  71. static vMenu DrawMenu[] =
  72.   {
  73.     {"&Point", m_DrawPoint, isSens, isChk, noKeyLbl, noKey,noSub},
  74.     {"&Line", m_DrawLine, isSens, notChk, noKeyLbl, noKey, noSub},
  75.     {"&Rectangle", m_DrawRect, isSens, notChk, noKeyLbl, noKey,noSub},
  76.     {"R&ounded Rectangle", m_DrawRdRect, isSens, notChk, noKeyLbl, noKey,noSub},
  77.     {"&Ellipse", m_DrawEllipse, isSens, notChk, noKeyLbl, noKey,noSub},
  78.     {"Pick &Color", m_DrawDropper, isSens, notChk, noKeyLbl, noKey,noSub},
  79.     {"&Fill", m_DrawFill, isSens, notChk, noKeyLbl, noKey,noSub},
  80.     {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  81.     {"Refresh Image",m_DrawRefresh, isSens, notChk, noKeyLbl, noKey, noSub},
  82.     {"Show &Grid        ",m_DrawGrid, isSens, isChk, "Ctrl-G", 'G'-'@', noSub},
  83.     {NULL}
  84.   };
  85.  
  86. static vMenu BrushMenu[] =
  87.   {
  88.     {"&Regular Brush", m_DrawPixel, isSens, isChk, noKeyLbl, noKey,noSub},
  89.     {"&Text Brush", m_DrawText, isSens, notChk, noKeyLbl, noKey,noSub},
  90.     {"&Cut/Paste Brush", m_DrawSelect, isSens, notChk, noKeyLbl, noKey,noSub},
  91.     {NULL}
  92.   };
  93.  
  94. // Define the main menu
  95. vMenu MainMenu[] =
  96.   {
  97.     {"&File",M_File,isSens,notUsed,notUsed,noKey,&FileMenu[0]},
  98.     {"&Edit",M_Edit,isSens,notUsed,notUsed,noKey,&EditMenu[0]},
  99.     {"&Draw",92,isSens,notUsed,notUsed,noKey,&DrawMenu[0]},
  100.     {"&Brush",93,isSens,notUsed,notUsed,noKey,&BrushMenu[0]},
  101.     {"&Zoom",94,isSens,notUsed,notUsed,noKey,&ZoomMenu[0]},
  102.     {NULL}
  103.   };
  104.  
  105.  
  106. // icon image files for command window toolbar
  107. #include "palett.vbm"
  108. #include "brushes.vbm"
  109. #include "snap.vbm"
  110. #include "clear.vbm"
  111. #include "undo.vbm"
  112.  
  113. // define command window toolbar
  114. static vIcon palett(&palett_bits[0], palett_height, palett_width, palett_depth,Transparent);
  115. static vIcon brushes(&brushes_bits[0], brushes_height, brushes_width, brushes_depth,Transparent);
  116. static vIcon snap(&snap_bits[0], snap_height, snap_width, snap_depth,Transparent);
  117. static vIcon undo(&undo_bits[0], undo_height, undo_width, undo_depth);
  118. static vIcon clear(&clear_bits[0], clear_height, clear_width, clear_depth);
  119.     
  120. #include "drwbnorm.vbm"
  121. #include "drwbsel.vbm"
  122. #include "drwbabc.vbm"
  123.  
  124. static vIcon drwbnorm(&drwbnorm_bits[0], drwbnorm_height, drwbnorm_width, drwbnorm_depth,Transparent);
  125. static vIcon drwbsel(&drwbsel_bits[0], drwbsel_height, drwbsel_width, drwbsel_depth,Transparent);
  126. static vIcon drwbabc(&drwbabc_bits[0], drwbabc_height, drwbabc_width, drwbabc_depth,Transparent);
  127.  
  128. static vColor fgBtnColor(0,0,0);
  129. static vColor bgBtnColor(255,255,255);
  130.  
  131. // Define the tool command bar
  132. static CommandObject CommandBar[] =
  133.   {
  134.     {C_Frame, m_fgbgFrame,0,"",NoList, CA_NoBorder | CA_NoSpace,isSens,NoFrame,0,0},
  135.     {C_ColorButton,m_fgColor,0," ",(void*)&fgBtnColor,CA_None,isSens,m_fgbgFrame,0,0,
  136.     20,"Current Foreground Color"},
  137.     {C_ColorButton,m_bgColor,0," ",(void*)&bgBtnColor,CA_None,isSens,m_fgbgFrame,m_fgColor,
  138.     0,20,"Current Background Color"},
  139.  
  140.     {C_Blank,999,0," ",NoList, CA_None,isSens,NoFrame,0,0},
  141.  
  142.     {C_ToggleIconButton, m_Snap, 0, "Snap", (void*)&snap,
  143.         CA_None,isSens,NoFrame,0,0, 0, "Snap to square or circle"},
  144.  
  145.     {C_ToggleIconButton, m_BrshBox, 0, "BrushBox", (void*)&brushes,
  146.         CA_None,isSens,NoFrame,0,0, 0, "Toggle Brush Selection Dialog"},
  147.  
  148.     {C_ToggleIconButton, m_ColorPalette, 0, "Palette", (void*)&palett,
  149.         CA_None,isSens,NoFrame,0,0,0, "Toggle Color Palette Dialog"},
  150.  
  151.     {C_Blank,999,0," ",NoList, CA_None,isSens,NoFrame,0,0},
  152.     {C_Frame, m_brushFrame,0,"",NoList, CA_NoSpace,isSens,NoFrame,0,0},
  153.     {C_ToggleIconButton, m_DrawPixel, 1, "Norm Brush", (void*)&drwbnorm,
  154.         CA_None,isSens,m_brushFrame,0,0, 0, "Use Shaped Brush"},
  155.     {C_ToggleIconButton, m_DrawText, 0, "Text Brush", (void*)&drwbabc,
  156.         CA_None,isSens,m_brushFrame,m_DrawPixel,0,0,"Use Text Brush"},
  157.     {C_ToggleIconButton, m_DrawSelect, 0, "Select Brush", (void*)&drwbsel,
  158.         CA_None,isSens,m_brushFrame,m_DrawText,0, 0, "Cut/Paste Brush"},
  159.  
  160.  
  161.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  162.   };
  163.  
  164.  
  165. // Shapes and tools icon images
  166. #include "rect.vbm"
  167. #include "rdrect.vbm"
  168. #include "ellipse.vbm"
  169. #include "line.vbm"
  170. #include "point.vbm"
  171. #include "fill.vbm"
  172.  
  173. #include "dropper.vbm"
  174.  
  175. // Shapes and tools icon declarations
  176. static vIcon rect(&rect_bits[0], rect_height, rect_width, rect_depth);
  177. static vIcon rdrect(&rdrect_bits[0], rdrect_height, rdrect_width, rdrect_depth);
  178. static vIcon ellipse(&ellipse_bits[0], ellipse_height, ellipse_width, ellipse_depth);
  179. static vIcon line(&line_bits[0], line_height, line_width, line_depth);
  180. static vIcon point(&point_bits[0], point_height, point_width, point_depth);
  181. static vIcon fill(&fill_bits[0], fill_height, fill_width, fill_depth);
  182. static vIcon dropper(&dropper_bits[0], dropper_height, dropper_width, dropper_depth);
  183.  
  184. // Define shapes and tools icon item values
  185. const ItemVal frShapeBox = 104;
  186. const ItemVal frShape = 105;
  187.  
  188.   static CommandObject ToolBar[] =
  189.     {
  190.     //----------- The shape frame ---------------------------------
  191.     {C_IconButton, m_Clear, 0, "Clear", (void*)&clear,
  192.         CA_None,isSens,NoFrame,0,0,0,"Clear to Background color"},
  193.     {C_IconButton, m_Undo, 0, "Undo", (void*)&undo,
  194.         CA_None,isSens,NoFrame,0,0,0,"Undo last action"},
  195.  
  196.     {C_Frame, frShape, 0, "", NoList, CA_NoSpace, isSens, NoFrame, 0, lbL1},
  197.  
  198.     {C_ToggleIconButton, m_DrawPoint, 1, "", (void*)&point, CA_None, isSens, 
  199.         frShape, 0, 0,0,"Draw Points"},
  200.     {C_ToggleIconButton, m_DrawLine, 0, "", (void*)&line, CA_None, isSens, 
  201.         frShape, m_DrawPoint, 0,0,"Draw Line"},
  202.     {C_ToggleIconButton, m_DrawRect, 0, "", (void*)&rect, CA_None, isSens,   
  203.         frShape, m_DrawLine, 0,0,"Draw Rectangle"},
  204.     {C_ToggleIconButton, m_DrawRdRect, 0, "", (void*)&rdrect, CA_None, isSens,
  205.         frShape, m_DrawRect, 0,0,"Draw Rounded Rectangle"},
  206.     {C_ToggleIconButton, m_DrawEllipse, 0, "", (void*)&ellipse, CA_None, isSens,
  207.         frShape, m_DrawRdRect,0,0,"Draw Ellipse"},
  208.     {C_ToggleIconButton, m_DrawDropper, 0, "", (void*)&dropper, CA_None, isSens,
  209.         frShape, m_DrawEllipse, 0,0,"Select color from current icon"},
  210.     {C_ToggleIconButton, m_DrawFill, 0, "", (void*)&fill, CA_None, isSens,
  211.         frShape, m_DrawDropper, 0, 0,"Area Fill"},
  212.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  213.     };
  214.  
  215. // Define the Status bar
  216. vStatus StatBar[] =
  217.   {
  218.     {"X,Y: ", m_MousePosLbl, CA_NoBorder, isSens, 0 },
  219.     {" 000 ", m_MousePosX, CA_None, isSens, 0},
  220.     {" 000 ", m_MousePosY, CA_None, isSens, 0},
  221.     {NULL,0,0,0,0}
  222.   };
  223.  
  224. #include "about.vbm"
  225. static vIcon about(&about_bits[0], about_height, about_width, about_depth);
  226. static CommandObject About[] =
  227.   {
  228.     {C_Icon,800,0,"",&about,CA_None,isSens,0,0,0},
  229.     {C_Label,802,0,"   V Icon Editor Version" ,NoList,CA_None,isSens,0,800,0},
  230.     {C_Label,803,0,viedVers ,NoList,CA_None,isSens,0,802,0},
  231.     {C_Label,810,0,"Developed by Philip Eckenroth, Mike Tipping,",
  232.     NoList,CA_None,isSens,0,0,800},
  233.     {C_Label,820,0,"Marilee Padilla, and John Fredric Jr. Masciantoni,",
  234.     NoList,CA_None,isSens,0,0,810},
  235.     {C_Label,830,0,"for UNM CS-460 Software Engineering, Spring 1996.",
  236.     NoList,CA_None,isSens,0,0,820},
  237.     {C_Label,840,0,"Enhancements by Bruce E. Wampler. " ,
  238.     NoList,CA_None,isSens,0,0,830},
  239.  
  240.     {C_Button,M_OK,0," OK ", NoList,CA_DefaultButton,isSens,0,840,840},
  241.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  242.   };
  243.  
  244. static char* filter[] = {"*.vbm;*.bmp;*.xbm;*.xpm",
  245. "*.vbm","*.bmp","*.xbm", "*.xpm","*", 0};   // file filter
  246. static int filterIndex = 0;
  247.  
  248. //================>>> myCmdWindow::myCmdWindow <<<================
  249.   myCmdWindow::myCmdWindow(char* name, int width, int height) :
  250.     vCmdWindow(name, width, height)
  251.   {
  252.     // Create and add the proper panes to the CmdWindow
  253.  
  254.     *_fname = 0;                        // no name
  255.     _fgbrush.SetColor(0,0,0);           // black brush
  256.     _pen.SetColor(0,0,0);               // black pen
  257.     _bg.Set(255,255,255);               // white background
  258.     curWidth = 1;                       // brush width
  259.     _mx = _my = 0;
  260.     brushMenuId = m_BrushSolid;
  261.     penMenuId = m_PenSolid;
  262.  
  263.     myMenu = new vMenuPane(MainMenu);           // Add the main menu
  264.     AddPane(myMenu);
  265.  
  266.     myCmdPane = new vCommandPane(CommandBar);   // Add command pane
  267.     AddPane(myCmdPane);
  268.  
  269.     myToolPane = new vCommandPane(ToolBar);     // Add command pane
  270.     AddPane(myToolPane);
  271.  
  272.     myCmdWindow* me  = this;
  273.     myCanvas = new myCanvasPane(me);            // Add the canvas pane
  274.  
  275.     AddPane(myCanvas);
  276.  
  277.     myCanvas->SetDrawShape(m_DrawPoint);        // We will be drawing line
  278.     curShape = m_DrawPoint;
  279.     
  280.     // Add the Status bar pane
  281.     myStatus = new vStatusPane(StatBar); // a new status bar
  282.     AddPane(myStatus);
  283.  
  284.     myColDlg = 0;                       // all dialog windows are closed
  285.     myBrshDlg = 0;
  286.  
  287.     ShowWindow();           // FINALLY, we must show the window!
  288.  
  289.     myCanvas->ShowVScroll(1);  // And, now turn on scroll bars
  290.     myCanvas->ShowHScroll(1);
  291.     myCanvas->SetDrawShape(m_DrawPoint);
  292.   }
  293.  
  294. //===============>>> myCmdWindow::~myCmdWindow <<<================
  295.   myCmdWindow::~myCmdWindow()
  296.   {
  297.     // Destory the command window and everything in it
  298.  
  299.     delete myMenu;      // Delete main menu
  300.     delete myCanvas;    // Delete the canvas
  301.     delete myCmdPane;   // Delete the command pane
  302.     delete myToolPane;  // Delete the Tool pane
  303.     delete myStatus;    // Delete the status bar
  304.     if (myColDlg)       // if color palette is open, delete it
  305.         delete myColDlg;         
  306.     if (myBrshDlg)       // if brushes box is open, delete it
  307.         delete myBrshDlg;         
  308.     
  309.   }
  310.  
  311. //===================>>> myCmdWindow::SetFGBtn <<<====================
  312.   void myCmdWindow::SetFGBtn(vColor& color)
  313.   {
  314.     fgBtnColor = color;
  315.     SetValue(m_fgColor,0,ChangeColor);
  316.   }
  317.  
  318. //===================>>> myCmdWindow::SetBGBtn <<<====================
  319.   void myCmdWindow::SetBGBtn(vColor& color)
  320.   {
  321.     bgBtnColor = color;
  322.     SetValue(m_bgColor,0,ChangeColor);
  323.   }
  324.  
  325. //===================>>> myCmdWindow::GetText <<<====================
  326.   int myCmdWindow::GetText(void)
  327.   {
  328.     // Opens a reply dialog box, which allows the user to enter text.
  329.     // The text is then read from the input box, and the text is placed
  330.     // in the current brush.
  331.  
  332.     vReplyDialog rp(this);
  333.     char r[25];            // a buffer for the reply
  334.     char temp_str[256];
  335.     char letter;
  336.     int location = 0;    // this gives x location only - top left of letters
  337.  
  338.     if ( rp.Reply("Enter Text for brush:",r,25) == M_Cancel)
  339.         return 0;
  340.  
  341.     myCanvas->_myPicture->Clear(BrushLayer, myCanvas->_myColorPal->getbg());
  342.  
  343.     while (strlen(r) > 0)
  344.       {
  345.         letter = r[0];
  346.         strcpy(temp_str, r+1);
  347.         strcpy(r, temp_str);
  348.         location = write_text(letter, location);
  349.  
  350.         // add the call to add the letter to the brush layer here
  351.       }
  352.     myCanvas->_BrushOffX = 0;
  353.     myCanvas->_BrushOffY = 0;
  354.     myCanvas->_BrushWidth = location;
  355.     myCanvas->_BrushHeight = 7;
  356.     return 1;
  357.   }
  358.  
  359. //===================>>> myCmdWindow::write_text <<<=====================
  360.   int myCmdWindow::write_text(char letter, int location)
  361.   {
  362.     // Converts text input into a bit sequence, and draws it on the canvas
  363.  
  364.     char bit_seq[46];   // text bit sequence
  365.     int pos;
  366.     int width = 5;      // width of our custom font
  367.     int height = 7;     // height of our custom font
  368.     char cur_bit;
  369.  
  370.     if ( (location + width) > myCanvas->_myPicture->GetPicWidth())  
  371.       return location;
  372.  
  373.     switch(letter)
  374.     {
  375.       case 'A' : 
  376.       {
  377.         strcpy(bit_seq, "01110100011000111111100011000110001"); 
  378.         break; 
  379.       }
  380.       case 'B' : 
  381.       {
  382.         strcpy(bit_seq, "11110100011000111110100011000111110"); 
  383.         break;
  384.       }
  385.       case 'C' : 
  386.       {
  387.         strcpy(bit_seq, "01110100011000010000100001000101110"); 
  388.         break;
  389.       }
  390.       case 'D' : 
  391.       {
  392.         strcpy(bit_seq, "11110100011000110001100011000111110"); 
  393.         break;
  394.       }
  395.       case 'E' : 
  396.       {
  397.         strcpy(bit_seq, "11111100001000011110100001000011111"); 
  398.         break;
  399.       }
  400.       case 'F' : 
  401.       {
  402.         strcpy(bit_seq, "11111100001000011110100001000010000"); 
  403.         break;
  404.       }
  405.       case 'G' : 
  406.       {
  407.         strcpy(bit_seq, "01110100011000010000100111000101110"); 
  408.         break;
  409.       }
  410.       case 'H' : 
  411.       {
  412.         strcpy(bit_seq, "10001100011000111111100011000110001"); 
  413.         break;
  414.       }
  415.       case 'I' : 
  416.       {
  417.         strcpy(bit_seq, "11111001000010000100001000010011111"); 
  418.         break;
  419.       }
  420.       case 'J' : 
  421.       {
  422.         strcpy(bit_seq, "11111001000010000100001001010011000"); 
  423.         break;
  424.       }
  425.       case 'K' : 
  426.       {
  427.         strcpy(bit_seq, "10001100101010011000101001001010001"); 
  428.         break;
  429.       }
  430.       case 'L' : 
  431.       {
  432.         strcpy(bit_seq, "10000100001000010000100001000011111"); 
  433.         break;
  434.       }
  435.       case 'M' : 
  436.       {
  437.         strcpy(bit_seq, "10001110111010110101100011000110001"); 
  438.         break;
  439.       }
  440.       case 'N' : 
  441.       {
  442.         strcpy(bit_seq, "10001110011010110101101011001110001"); 
  443.         break;
  444.       }
  445.       case 'O' : 
  446.       {
  447.         strcpy(bit_seq, "01110100011000110001100011000101110"); 
  448.         break;
  449.       }
  450.       case 'P' : 
  451.       {
  452.         strcpy(bit_seq, "11110100011000111110100001000010000"); 
  453.         break;
  454.       }
  455.       case 'Q' : 
  456.       {
  457.         strcpy(bit_seq, "01110100011000110001101011001001101"); 
  458.         break;
  459.       }
  460.       case 'R' : 
  461.       {
  462.         strcpy(bit_seq, "11110100011000111110101001001010001"); 
  463.         break;
  464.       }
  465.       case 'S' : 
  466.       {
  467.         strcpy(bit_seq, "01110100011000001110000011000101110"); 
  468.         break;
  469.       }
  470.       case 'T' : 
  471.       {
  472.         strcpy(bit_seq, "11111001000010000100001000010000100"); 
  473.         break;
  474.       }
  475.       case 'U' : 
  476.       {
  477.         strcpy(bit_seq, "10001100011000110001100011000101110"); 
  478.         break;
  479.       }
  480.       case 'V' : 
  481.       {
  482.         strcpy(bit_seq, "10001100010101001010010100010000100"); 
  483.         break;
  484.       }
  485.       case 'W' : 
  486.       {
  487.         strcpy(bit_seq, "10001100011000110101101011010101110"); 
  488.         break;
  489.       }
  490.       case 'X' : 
  491.       {
  492.         strcpy(bit_seq, "10001010100101000100010100101010001"); 
  493.         break;
  494.       }
  495.       case 'Y' : 
  496.       {
  497.         strcpy(bit_seq, "10001010100101000100001000010000100"); 
  498.         break;
  499.       }
  500.       case 'Z' : 
  501.       {
  502.         strcpy(bit_seq, "11111100010001000100010001000111111"); 
  503.         break;
  504.       }
  505.       case '0' : 
  506.       {
  507.         strcpy(bit_seq, "01110100011000110001100011000101110"); 
  508.         break;
  509.       }
  510.       case '1' : 
  511.       {
  512.         strcpy(bit_seq, "00100011001010000100001000010011111"); 
  513.         break;
  514.       }
  515.       case '2' : 
  516.       {
  517.         strcpy(bit_seq, "01110100010000100010001000100011111"); 
  518.         break;
  519.       }
  520.       case '3' : 
  521.       {
  522.         strcpy(bit_seq, "01110100010000100110000011000101110"); 
  523.         break;
  524.       }
  525.       case '4' : 
  526.       {
  527.         strcpy(bit_seq, "10001100011000111111000010000100001"); 
  528.         break;
  529.       }
  530.       case '5' : 
  531.       {
  532.         strcpy(bit_seq, "11111100001000011110000010000111110"); 
  533.         break;
  534.       }
  535.       case '6' : 
  536.       {
  537.         strcpy(bit_seq, "00001000100010001110100011000101110"); 
  538.         break;
  539.       }
  540.       case '7' : 
  541.       {
  542.         strcpy(bit_seq, "11111000010000100010001000100010000"); 
  543.         break;
  544.       }
  545.       case '8' : 
  546.       {
  547.         strcpy(bit_seq, "01110100011000101110100011000101110"); 
  548.         break;
  549.       }
  550.       case '9' : 
  551.       {
  552.         strcpy(bit_seq, "01110100011000101110000100010001000"); 
  553.         break;
  554.       }
  555.       case '-' : 
  556.       {
  557.         strcpy(bit_seq, "00000000000000011111000000000000000"); 
  558.         break;
  559.       }
  560.       case '_' : 
  561.       {
  562.         strcpy(bit_seq, "00000000000000000000000000000011111"); 
  563.         break;
  564.       }
  565.       case '=' : 
  566.       {
  567.         strcpy(bit_seq, "00000000001111100000111110000000000"); 
  568.         break;
  569.       }
  570.       case '+' : 
  571.       {
  572.         strcpy(bit_seq, "00000001000010011111001000010000000"); 
  573.         break;
  574.       }
  575.       case '!' : 
  576.       {
  577.         strcpy(bit_seq, "00100001000010000100001000000000100"); 
  578.         break;
  579.       }
  580.       case '@' : 
  581.       {
  582.         strcpy(bit_seq, "01110100011001110101101101000001110"); 
  583.         break;
  584.       }
  585.       case '#' : 
  586.       {
  587.         strcpy(bit_seq, "00000010101111101010111110101000000"); 
  588.         break;
  589.       }
  590.       case '$' : 
  591.       {
  592.         strcpy(bit_seq, "00100011101010001110001010111000100"); 
  593.         break;
  594.       }
  595.       case '%' : 
  596.       {
  597.         strcpy(bit_seq, "01001101010101000100010101010110010"); 
  598.         break;
  599.       }
  600.       case '^' : 
  601.       {
  602.         strcpy(bit_seq, "00100010101000100000000000000000000"); 
  603.         break;
  604.       }
  605.       case '&' : 
  606.       {
  607.         strcpy(bit_seq, "01000101001010001000101011001001101"); 
  608.         break;
  609.       }
  610.       case '*' : 
  611.       {
  612.         strcpy(bit_seq, "00000101010111011111011101010100000"); 
  613.         break;
  614.       }
  615.       case '(' : 
  616.       {
  617.         strcpy(bit_seq, "00100010001000010000100000100000100"); 
  618.         break;
  619.       }
  620.       case ')' : 
  621.       {
  622.         strcpy(bit_seq, "00100000100000100001000010001000100"); 
  623.         break;
  624.       }
  625.       case '~' : 
  626.       {
  627.         strcpy(bit_seq, "01001101011001000000000000000000000"); 
  628.         break;
  629.       }
  630.       case '`' : 
  631.       {
  632.         strcpy(bit_seq, "01100001000001000000000000000000000"); 
  633.         break;
  634.       }
  635.       case '[' : 
  636.       {
  637.         strcpy(bit_seq, "01110010000100001000010000100001110"); 
  638.         break;
  639.       }
  640.       case ']' : 
  641.       {
  642.         strcpy(bit_seq, "01110000100001000010000100001001110"); 
  643.         break;
  644.       }
  645.       case '{' : 
  646.       {
  647.         strcpy(bit_seq, "00110010000010011000001000100000110"); 
  648.         break;
  649.       }
  650.       case '}' : 
  651.       {
  652.         strcpy(bit_seq, "01100000100010000011001000001001100"); 
  653.         break;
  654.       }
  655.       case ':' : 
  656.       {
  657.         strcpy(bit_seq, "00100011100010000000001000111000100"); 
  658.         break;
  659.       }
  660.       case ';' : 
  661.       {
  662.         strcpy(bit_seq, "00100011100010000000001100010001000"); 
  663.         break;
  664.       }
  665.       case '"' : 
  666.       {
  667.         strcpy(bit_seq, "01010010100101000000000000000000000"); 
  668.         break;
  669.       }
  670.       case '\'' : 
  671.       {
  672.         strcpy(bit_seq, "00110001000100000000000000000000000"); 
  673.         break;
  674.       }
  675.       case '<' : 
  676.       {
  677.         strcpy(bit_seq, "00000000110110010000011000001100000"); 
  678.         break;
  679.       }
  680.       case '>' : 
  681.       {
  682.         strcpy(bit_seq, "00000110000011000001001101100000000"); 
  683.         break;
  684.       }
  685.       case ',' : 
  686.       {
  687.         strcpy(bit_seq, "00000000000000000000001100010001000"); 
  688.         break;
  689.       }
  690.       case '.' : 
  691.       {
  692.         strcpy(bit_seq, "00000000000000000000001000111000100"); 
  693.         break;
  694.       }
  695.       case '/' : 
  696.       {
  697.         strcpy(bit_seq, "00001000010001000100010001000010000"); 
  698.         break;
  699.       }
  700.       case '\\' : 
  701.       {
  702.         strcpy(bit_seq, "10000100000100000100000100000100001"); 
  703.         break;
  704.       }
  705.       case '|' : 
  706.       {
  707.         strcpy(bit_seq, "00100001000010000000001000010000100"); 
  708.         break;
  709.       }
  710.       case '?' : 
  711.       {
  712.         strcpy(bit_seq, "01110100010001000100001000000000100"); 
  713.         break;
  714.       }
  715.       case 'a' : 
  716.       {
  717.         strcpy(bit_seq, "00000000000111000001011111000101111"); 
  718.         break;
  719.       }
  720.       case 'b' : 
  721.       {
  722.         strcpy(bit_seq, "10000100001011011001100011100110110"); 
  723.         break;
  724.       }
  725.       case 'c' : 
  726.       {
  727.         strcpy(bit_seq, "00000000000111010001100001000101110"); 
  728.         break;
  729.       }
  730.       case 'd' : 
  731.       {
  732.         strcpy(bit_seq, "00001000010110110011100011001101101"); 
  733.         break;
  734.       }
  735.       case 'e' : 
  736.       {
  737.         strcpy(bit_seq, "00000000000111010001111111000001110"); 
  738.         break;
  739.       }
  740.       case 'f' : 
  741.       {
  742.         strcpy(bit_seq, "00110010010100011110010000100001000"); 
  743.         break;
  744.       }
  745.       case 'g' : 
  746.       {
  747.         strcpy(bit_seq, "01101100100110010000011101000101110"); 
  748.         break;
  749.       }
  750.       case 'h' : 
  751.       {
  752.         strcpy(bit_seq, "10000100001011011001100011000110001"); 
  753.         break;
  754.       }
  755.       case 'i' : 
  756.       {
  757.         strcpy(bit_seq, "00100000000110000100001000010001110"); 
  758.         break;
  759.       }
  760.       case 'j' : 
  761.       {
  762.         strcpy(bit_seq, "00010000000001000010100101001001100"); 
  763.         break;
  764.       }
  765.       case 'k' : 
  766.       {
  767.         strcpy(bit_seq, "10000100001000110010111001001010001"); 
  768.         break;
  769.       }
  770.       case 'l' : 
  771.       {
  772.         strcpy(bit_seq, "01100001000010000100001000010001110"); 
  773.         break;
  774.       }
  775.       case 'm' : 
  776.       {
  777.         strcpy(bit_seq, "00000000001101010101101011010110001"); 
  778.         break;
  779.       }
  780.       case 'n' : 
  781.       {
  782.         strcpy(bit_seq, "00000000001011011001100011000110001"); 
  783.         break;
  784.       }
  785.       case 'o' : 
  786.       {
  787.         strcpy(bit_seq, "00000000000111010001100011000101110"); 
  788.         break;
  789.       }
  790.       case 'p' : 
  791.       {
  792.         strcpy(bit_seq, "10110110011100110110100001000010000"); 
  793.         break;
  794.       }
  795.       case 'q' : 
  796.       {
  797.         strcpy(bit_seq, "01101100111001101101000010000100001"); 
  798.         break;
  799.       }
  800.       case 'r' : 
  801.       {
  802.         strcpy(bit_seq, "00000000001011011001100001000010000"); 
  803.         break;
  804.       }
  805.       case 's' : 
  806.       {
  807.         strcpy(bit_seq, "00000000000111010000011100000111110"); 
  808.         break;
  809.       }
  810.       case 't' : 
  811.       {
  812.         strcpy(bit_seq, "01000010001111001000010000100100110"); 
  813.         break;
  814.       }
  815.       case 'u' : 
  816.       {
  817.         strcpy(bit_seq, "00000000001000110001100011001101101"); 
  818.         break;
  819.       }
  820.       case 'v' : 
  821.       {
  822.         strcpy(bit_seq, "00000000001000110001010100101000100"); 
  823.         break;
  824.       }
  825.       case 'w' : 
  826.       {
  827.         strcpy(bit_seq, "00000000001000110001101011010101010"); 
  828.         break;
  829.       }
  830.       case 'x' : 
  831.       {
  832.         strcpy(bit_seq, "00000000001000101010001000101010001"); 
  833.         break;
  834.       }
  835.       case 'y' : 
  836.       {
  837.         strcpy(bit_seq, "10001100011001101101000011000101110"); 
  838.         break;
  839.       }
  840.       case 'z' : 
  841.       {
  842.         strcpy(bit_seq, "00000000001111100010001000100011111"); 
  843.         break;
  844.       }
  845.       case ' ' : 
  846.       {
  847.         strcpy(bit_seq, "00000000000000000000000000000000000"); 
  848.         break;
  849.       }
  850.    }
  851.  
  852.    for (int y=0; y < height; y++)
  853.    {
  854.       for (int x=0; x < width; x++)
  855.       {
  856.          pos = y * width + x;
  857.          cur_bit = bit_seq[pos];
  858.          if (cur_bit == '1')
  859.             myCanvas->_myPicture->SetIndex(location+x, y, 2, -99);
  860.       }
  861.    }
  862.  
  863.    return location + width + 1;
  864. }
  865.  
  866. //==============>>> myCmdWindow::OpenFile <<<================
  867.   void myCmdWindow::OpenFile(char* fname)
  868.   {
  869.     // Opens a given file
  870.  
  871.     char fn[256];               // scratch copy
  872.     int ix;
  873.  
  874.     if (*_fname)                // already have one!
  875.         return;
  876.     
  877.     for (ix = 0 ; fname[ix] != 0 && ix < 255 ; ++ix)
  878.       fn[ix] = fname[ix];       // safe copy
  879.     fn[ix] = 0;
  880.  
  881.     if (!*fn)                   // no file open yet
  882.       {
  883.         vFileSelect fsel(this); // V file select dialog
  884.         if (!fsel.FileSelect("Open V Icon File",
  885.             fn,255,filter,filterIndex) || !*fn)
  886.             return;
  887.       }
  888.  
  889.     if (!myCanvas->Read(fn))    // Save in _fname
  890.       {
  891.         vNoticeDialog note(this);       // for user notification
  892.         note.Notice("Unable to open file.");
  893.         return;
  894.       }
  895.  
  896.     if (myColDlg)
  897.     myColDlg->UpdatePalette(myCanvas->_myColorPal->_Palette, 
  898.           myCanvas->_myColorPal->ColorsUsed());
  899.     
  900.     myCanvas->setfg(0);
  901.     myCanvas->setbg(1);
  902.     
  903.     WindowCommand(m_DrawPixel,1,C_Button);
  904.     WindowCommand(m_DrawPoint,1,C_Button);
  905.  
  906.     SetTitle(fn);               // show on title bar
  907.     strcpy(_fname,fn);          // keep copy
  908.     myCanvas->Redraw(0,0,0,0);  // paint it
  909.     myCanvas->SetChanged(0);    // not really changed
  910.   }
  911.  
  912. //==============>>> myCmdWindow::CheckClose <<<================
  913.   int myCmdWindow::CheckClose()
  914.   {
  915.     // Checks to see if the user wants to save changes, if changes have been
  916.     // done, before it closes the application.
  917.     // Return 1 if ok to close now, 0 to abort
  918.  
  919.     if (myCanvas->Changed())    // changes have been made
  920.       {
  921.         vYNReplyDialog ynr(this);
  922.         int ans = ynr.AskYN("Save new or changed drawing?");
  923.         if (ans == 0)
  924.           {
  925.             myCanvas->SetChanged(0);
  926.             return 1;           // don't want to save
  927.           }
  928.         if (ans == -1)          // cancel
  929.             return 0;
  930.  
  931.         // ok, want to save changed file
  932.         if (*_fname)                    // have a name
  933.           {
  934.             if (!myCanvas->Save(_fname))        // Save in _fname
  935.               {
  936.                 vNoticeDialog note(this);       // for user notification
  937.                 note.Notice("Unable to save file");
  938.                 return 0;
  939.               }
  940.           }
  941.         else                            // need to request name
  942.           {
  943.             vFileSelect fsel(this);     // V file select dialog
  944.  
  945.             if (!fsel.FileSelectSave("Save icon file as",
  946.                 _fname,99,filter,filterIndex) || !*_fname)
  947.             return 0;
  948.  
  949.             if (!myCanvas->Save(_fname))        // Save in _fname
  950.               {
  951.                 vNoticeDialog note(this);       // for user notification
  952.                 note.Notice("Unable to save file");
  953.                 return 0;
  954.               }
  955.           }
  956.       }
  957.     return 1;
  958.   }
  959.  
  960. //==============>>> myCmdWindow::MouseXYStatus <<<================
  961.   void myCmdWindow::MouseXYStatus(int x, int y)
  962.   {
  963.     // Get the current X, Y status of the mouse
  964.  
  965.     char buff[12];
  966.  
  967.     _mx = x; _my = y;
  968.     IntToStr(x,buff);   // convert x coordinate to a string
  969.     SetString(m_MousePosX,buff);
  970.     IntToStr(y,buff);   // convert y coordinate to a string
  971.     SetString(m_MousePosY,buff);
  972.   }
  973.  
  974. //==============>>> myCmdWindow::GetDigit  <<<====================
  975.   int myCmdWindow::GetDigit(char * digitstring)
  976.   {
  977.     // Get a digit from the string and make sure it is writable
  978.  
  979.     int add = 0;
  980.     int x = 0;
  981.  
  982.     while (isdigit(digitstring[x]))
  983.     {
  984.       add = (add * 10) + (digitstring[x] - '0');
  985.       x++;
  986.     }
  987.     return add;
  988.   }
  989.  
  990. //====================>>> myCmdWindow::GetWH <<<==========================
  991.   int myCmdWindow::GetWH(int& width, int& height)
  992.   {
  993.     // instantiate a dialog to ask for size of new icon.
  994.  
  995.     vReplyDialog rp(this);
  996.     char r[32], tempr[32];        // a buffer for the reply
  997.  
  998.     r[0] = 0;
  999.     if (rp.Reply("Please enter WIDTH and HEIGHT",r,30) == M_Cancel)
  1000.     return 0;
  1001.  
  1002.     if (r[0] == 0)
  1003.     return 0;
  1004.  
  1005.     // parse the returned size string - clean out crap and get
  1006.     // just the numbers.  If both nums are not there, punt and go
  1007.     // with the standard defaults settings.
  1008.  
  1009.     while (!(isdigit(r[0])) && (strlen(r) > 0))
  1010.       {
  1011.     strcpy(tempr, r+1);
  1012.     strcpy(r, tempr);
  1013.       }
  1014.     width = GetDigit(r);
  1015.     while (isdigit(r[0]) && (strlen(r) > 0))
  1016.       {
  1017.     strcpy(tempr, r+1);
  1018.     strcpy(r, tempr);
  1019.       }
  1020.  
  1021.     while (!(isdigit(r[0])) && (strlen(r) > 0))
  1022.       {
  1023.     strcpy(tempr, r+1);
  1024.     strcpy(r, tempr);
  1025.       }
  1026.     height = GetDigit(r);
  1027.  
  1028.     // Check to see that nums are within ranges 
  1029.     if (height > 150 || width > 150)
  1030.       {
  1031.         vNoticeDialog note(this);       // for user notification
  1032.         note.Notice("Maximum icon size is 150x150.");
  1033.     return 0;
  1034.       }
  1035.     return 1;
  1036.   }
  1037.  
  1038.  
  1039. //====================>>> myCmdWindow::WindowCommand <<<==========================
  1040.   void myCmdWindow::WindowCommand(ItemVal id, ItemVal val, CmdType cType)
  1041.   {
  1042.     // Implements the commands given from buttons and menu from the command window
  1043.  
  1044.     int width, height;
  1045.  
  1046.     // route all commands through here - menus and buttons
  1047.  
  1048.     vNoticeDialog note(this);   // for user notification
  1049.  
  1050.     switch (id)         // switch on id of commands
  1051.       {
  1052.         case M_New:     // start new icon 
  1053.           {
  1054.             if (!CheckClose())           // ok to close
  1055.                 break;
  1056.  
  1057.         if (!GetWH(width,height))
  1058.         break;
  1059.  
  1060.             // make call for a new canvas of size - default is height = 0
  1061.             if (height == 0)
  1062.                 myCanvas->NewCanvas();
  1063.             else
  1064.                 myCanvas->NewCanvas(width, height);
  1065.  
  1066.         myCanvas->setfg(0);
  1067.         myCanvas->setbg(1);
  1068.  
  1069.         WindowCommand(m_DrawPixel,1,C_Button);
  1070.         WindowCommand(m_DrawPoint,1,C_Button);
  1071.  
  1072.             myCanvas->ClearShapes();
  1073.         if (myColDlg)
  1074.         myColDlg->UpdatePalette(myCanvas->_myColorPal->_Palette, 
  1075.                 myCanvas->_myColorPal->ColorsUsed());
  1076.  
  1077.             break;
  1078.           }
  1079.  
  1080.         case M_Open:                    // open existing file
  1081.           {
  1082.             if (*_fname || myCanvas->Changed()) // need to create a new window
  1083.               {
  1084.                 // create new window, then open a file in it.
  1085.                 myCmdWindow* cw = (myCmdWindow*)
  1086.                 theApp->NewAppWin(0,"V Icon Edit",400,200);
  1087.                 cw->OpenFile("");       // open via dialog
  1088.                 cw->RaiseWindow();      // bring to front
  1089.               }
  1090.             else
  1091.                 OpenFile("");           // open a file using dialog
  1092.  
  1093.         myCanvas->setfg(0);
  1094.         myCanvas->setbg(1);
  1095.  
  1096.         WindowCommand(m_DrawPixel,1,C_Button);
  1097.         WindowCommand(m_DrawPoint,1,C_Button);
  1098.             break;
  1099.           }
  1100.  
  1101.         case m_CloseFile:               // Close current file
  1102.           {
  1103.             if (!CheckClose())           // ok to close
  1104.                 break;
  1105.         myCanvas->ClearShapes();
  1106.         myCanvas->Redraw(0,0,0,0);
  1107.         *_fname = 0;
  1108.         SetTitle("Icon Edit - No Name");   // no file
  1109.         break;
  1110.           }
  1111.  
  1112.         case M_Save:                    // save current drawing
  1113.           {
  1114.             if (*_fname)                // already have a name
  1115.               {
  1116.                 if (!myCanvas->Save(_fname))    // Save in _fname
  1117.           {
  1118.                     note.Notice("Unable to save file");
  1119.           }
  1120.                 else if (id == m_CloseFile)
  1121.                   {
  1122.                     *_fname = 0;
  1123.                     SetTitle("Icon Edit - No Name");       // no file
  1124.                   }
  1125.                 break;
  1126.               }
  1127.             // else fall through to SaveAs
  1128.           }
  1129.  
  1130.         case M_SaveAs:                  // save file as
  1131.           {
  1132.             vFileSelect fsel(this);     // V file select dialog
  1133.  
  1134.             if (!fsel.FileSelectSave("Save icon file as",
  1135.               _fname,99,filter,filterIndex) || !*_fname)
  1136.                 break;                  // ignore if no selection
  1137.  
  1138.             if (!myCanvas->Save(_fname)) // Save in _fname
  1139.               {
  1140.                 note.Notice("Unable to save file");
  1141.                 break;
  1142.               }
  1143.             if (id == m_CloseFile)
  1144.               {
  1145.                 *_fname = 0;
  1146.                 SetTitle("Icon Edit - No Name");   // no file
  1147.               }
  1148.             else
  1149.                 SetTitle(_fname);               // change title
  1150.             break;
  1151.           }
  1152.  
  1153.     case M_About:
  1154.       {
  1155.         vModalDialog about(this,"About V Icon Editor");
  1156.         ItemVal dummy;
  1157.         about.AddDialogCmds(About);
  1158.         about.ShowModalDialog("",dummy);
  1159.         break;
  1160.       }
  1161.  
  1162.         case M_Exit:                    // quit all
  1163.           {
  1164.             if (CheckClose())           // ok to close
  1165.                 theApp->Exit(); // Standard action for Exit
  1166.             break;
  1167.           }
  1168.  
  1169.         case m_Undo:
  1170.           {
  1171.             myCanvas->Undo();
  1172.             break;
  1173.           }
  1174.  
  1175.         case m_Clear:                   // clear the screen
  1176.           {
  1177.             myCanvas->ClearShapes();
  1178.         myCanvas->Redraw(0,0,0,0);
  1179.         myCanvas->SetChanged(1);
  1180.             break;
  1181.           }
  1182.  
  1183.     case m_Resize:
  1184.           {
  1185.           int h, w;
  1186.         if (!GetWH(w,h))
  1187.         break;
  1188.         myCanvas->ResizeCanvas(w,h);
  1189.  
  1190.         WindowCommand(m_DrawPixel,1,C_Button);
  1191.         WindowCommand(m_DrawPoint,1,C_Button);
  1192.  
  1193.             break;
  1194.           }
  1195.  
  1196.     case m_Zoom2:            // note: these values MUST be 700-732
  1197.     case m_Zoom4:
  1198.     case m_Zoom8:
  1199.     case m_Zoom16:
  1200.     case m_Zoom32:
  1201.       {
  1202.         SetValue(m_Zoom2,0,Checked);
  1203.         SetValue(m_Zoom4,0,Checked);
  1204.         SetValue(m_Zoom8,0,Checked);
  1205.         SetValue(m_Zoom16,0,Checked);
  1206.         SetValue(m_Zoom32,0,Checked);
  1207.         SetValue(id,1,Checked);        // turn on ours
  1208.         myCanvas->_PixSize = id - m_Zoom0;
  1209.         myCanvas->ResetScroll();        // reset any scrolling
  1210.         myCanvas->Clear();
  1211.         myCanvas->Redraw(0,0,0,0);
  1212.         break;
  1213.       }
  1214.  
  1215.         case m_DrawDropper:
  1216.         case m_DrawLine:                // set what we are drawing
  1217.     case m_DrawPoint:
  1218.         case m_DrawRect:
  1219.         case m_DrawRdRect:
  1220.         case m_DrawEllipse:
  1221.         case m_DrawFill:
  1222.           {
  1223.             SetValue(curShape,0,Checked);       // fix the menu check
  1224.             curShape = id;
  1225.             SetValue(curShape,1,Checked);
  1226.             myCanvas->SetDrawShape(id);
  1227.             break;
  1228.           }
  1229.  
  1230.         case m_DrawText:                        // Text Brush
  1231.           {
  1232.             if (myCanvas->_cwin->GetText())     // Read text
  1233.               {
  1234.                 SetValue(m_DrawText,1,Checked);
  1235.                 SetValue(m_DrawSelect,0,Checked);
  1236.                 SetValue(m_DrawPixel,0,Checked);
  1237.                 myCanvas->SetDrawShape(id);
  1238.               }
  1239.             else
  1240.               {
  1241.                 SetValue(m_DrawText,0,Checked);
  1242.                 SetValue(m_DrawSelect,0,Checked);
  1243.                 SetValue(m_DrawPixel,1,Checked);
  1244.                 myCanvas->SetDrawShape(m_DrawPixel);
  1245.               }
  1246.  
  1247. //            myCanvas->Redraw(0,0,0,0);  // paint it
  1248.             break;
  1249.           }
  1250.  
  1251.         case m_DrawSelect:
  1252.           {
  1253.             SetValue(m_DrawText,0,Checked);
  1254.             SetValue(m_DrawSelect,1,Checked);
  1255.             SetValue(m_DrawPixel,0,Checked);
  1256.         myCanvas->SetDrawShape(id);
  1257. //            myCanvas->Redraw(0,0,0,0);  // paint it
  1258.             break;
  1259.           }
  1260.  
  1261.         case m_DrawPixel:
  1262.           {
  1263.             SetValue(m_DrawText,0,Checked);
  1264.             SetValue(m_DrawSelect,0,Checked);
  1265.             SetValue(m_DrawPixel,1,Checked);
  1266.  
  1267.             myCanvas->SetDrawShape(id);
  1268. //            myCanvas->Redraw(0,0,0,0);  // paint it
  1269.             break;
  1270.           }
  1271.  
  1272.         case m_ColorPalette:            // open the color palette dialog
  1273.           {
  1274.             if (val)
  1275.               {
  1276.                 if (!myColDlg)          // not created yet
  1277.                     myColDlg = new vColorDialog(this, 0, myCanvas);
  1278.         myColDlg->UpdatePalette(myCanvas->_myColorPal->_Palette,
  1279.             myCanvas->_myColorPal->ColorsUsed());
  1280.                 myColDlg->ShowDialog("Color Selection");
  1281.                 int l,t,w,h;
  1282.                 GetPosition(l,t,w,h);   // my position
  1283.                 myColDlg->SetDialogPosition(l+w+2,t);   // put quick pick here
  1284.               }
  1285.             else                        // close the dialog
  1286.               {
  1287.                 myColDlg->CloseDialog();
  1288.               }
  1289.             break;
  1290.           }
  1291.  
  1292.     case m_DrawGrid:
  1293.       {
  1294.         myCanvas->_drawGrid = !myCanvas->_drawGrid;  // toggle
  1295.         SetValue(m_DrawGrid,myCanvas->_drawGrid,Checked); // fix menu
  1296.         myCanvas->Clear();
  1297.         myCanvas->Redraw(0,0,0,0);  // paint it
  1298.         break;
  1299.       }
  1300.  
  1301.     case m_DrawRefresh:
  1302.       {
  1303.         myCanvas->Clear();
  1304.         myCanvas->Redraw(0,0,0,0);  // paint it
  1305.         break;
  1306.       }
  1307.  
  1308.         case m_BrshBox:                 // open the brush box dialog
  1309.           {
  1310.             if (val)
  1311.               {
  1312.                 if (!myBrshDlg)          // not created yet
  1313.                     myBrshDlg = new vBrshDialog(this, 0, myCanvas);
  1314.                 myBrshDlg->ShowDialog("*Brushes*");
  1315.                 int l,t,w,h;
  1316.                 GetPosition(l,t,w,h);   // my position
  1317.                 myBrshDlg->SetDialogPosition(l+w+2,t+280);
  1318.               }
  1319.             else                        // close the dialog
  1320.               {
  1321.                 myBrshDlg->CloseDialog();
  1322.               }
  1323.             break;
  1324.           }
  1325.  
  1326.          case m_Snap:                   // enable the Snap utility
  1327.          {
  1328.            if (myCanvas->_snap == 0)    
  1329.                myCanvas->_snap = 1;
  1330.            else
  1331.                myCanvas->_snap = 0;
  1332.          }
  1333.  
  1334.         default:                        // change pen color?
  1335.           {
  1336.             vCmdWindow::WindowCommand(id, val, cType);
  1337.             break;
  1338.           }
  1339.       }
  1340.   }
  1341.