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

  1. //========================= brshdlg.cxx =================================
  2. // This is the source file for the brush dialog 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.  
  14. #include "brshdlg.h"
  15. #include "viedcmdw.h"
  16. #include <v/vcolor.h>
  17. #include <v/vapp.h>
  18. #include <v/vwindow.h>
  19. #include <v/vicon.h>
  20.  
  21. //Brush image files
  22. #include "brush1.vbm"
  23. #include "brush2.vbm"
  24. #include "brush3.vbm"
  25. #include "brush4.vbm"
  26. #include "brush5.vbm"
  27. #include "brush6.vbm"
  28. #include "brush7.vbm"
  29. #include "brush8.vbm"
  30. #include "brush9.vbm"
  31. #include "brush10.vbm"
  32.  
  33.  
  34. //Brush declarations
  35. static vIcon brush1(&brush1_bits[0], brush1_height, brush1_width,brush1_depth);
  36. static vIcon brush2(&brush2_bits[0], brush2_height, brush2_width,brush2_depth);
  37. static vIcon brush3(&brush3_bits[0], brush3_height, brush3_width,brush3_depth);
  38. static vIcon brush4(&brush4_bits[0], brush4_height, brush4_width,brush4_depth);
  39. static vIcon brush5(&brush5_bits[0], brush5_height, brush5_width,brush5_depth);
  40. static vIcon brush6(&brush6_bits[0], brush6_height, brush6_width,brush6_depth);
  41. static vIcon brush7(&brush7_bits[0], brush7_height, brush7_width,brush7_depth);
  42. static vIcon brush8(&brush8_bits[0], brush8_height, brush8_width,brush8_depth);
  43. static vIcon brush9(&brush9_bits[0], brush9_height, brush9_width,brush9_depth);
  44. static vIcon brush10(&brush10_bits[0], brush10_height, brush10_width,brush10_depth);
  45.  
  46. // Set Item Values for brushes
  47. const ItemVal lbL1 = 2999;
  48. const ItemVal frBrushBox = 104;
  49. const ItemVal frBrush = 105;
  50. const ItemVal ibBrush1 = 3101;
  51. const ItemVal ibBrush2 = 3102;
  52. const ItemVal ibBrush3 = 3103;
  53. const ItemVal ibBrush4 = 3104;
  54. const ItemVal ibBrush5 = 3105;
  55. const ItemVal ibBrush6 = 3106;
  56. const ItemVal ibBrush7 = 3107;
  57. const ItemVal ibBrush8 = 3108;
  58. const ItemVal ibBrush9 = 3109;
  59. const ItemVal ibBrush10 = 3110;
  60.  
  61. // Define the brush dialog window
  62. static CommandObject DefaultCmds[] =
  63.   {
  64.     {C_Label, lbL1, 0,"           ",NoList,CA_MainMsg,isSens,NoFrame, 0, 0},
  65.     
  66.     //----------- The brush frame ---------------------------------
  67.     {C_Frame, frBrush, 0, "", NoList, CA_NoSpace, isSens, NoFrame, 0, lbL1},
  68.  
  69.     {C_ToggleIconButton, ibBrush1, 1, "", (void*)&brush1, CA_None, isSens,
  70.             frBrush, 0, 0, 0, "Point"},
  71.     {C_ToggleIconButton, ibBrush2, 0, "", (void*)&brush2, CA_None, isSens,
  72.             frBrush, ibBrush1, 0, 0, "Medium Round"},
  73.     {C_ToggleIconButton, ibBrush3, 0, "", (void*)&brush3, CA_None, isSens,
  74.             frBrush, ibBrush2, 0, 0, "Large Round"},
  75.     {C_ToggleIconButton, ibBrush4, 0, "", (void*)&brush4, CA_None, isSens,
  76.             frBrush, ibBrush3, 0, 0, "Small Right Slash"},
  77.     {C_ToggleIconButton, ibBrush5, 0, "", (void*)&brush5, CA_None, isSens,
  78.             frBrush, ibBrush4, 0, 0, "Large Right Slash"},
  79.     {C_ToggleIconButton, ibBrush6, 0, "", (void*)&brush6, CA_None, isSens,
  80.             frBrush, 0, ibBrush1, 0, "Small Square"},
  81.     {C_ToggleIconButton, ibBrush7, 0, "", (void*)&brush7, CA_None, isSens,
  82.             frBrush, ibBrush6, ibBrush1, 0, "Medium Square"},
  83.     {C_ToggleIconButton, ibBrush8, 0, "", (void*)&brush8, CA_None, isSens,
  84.             frBrush, ibBrush7, ibBrush1, 0, "Large Square"},
  85.     {C_ToggleIconButton, ibBrush9, 0, "", (void*)&brush9, CA_None, isSens,
  86.             frBrush, ibBrush8, ibBrush1, 0, "Small Left Slash"},
  87.     {C_ToggleIconButton, ibBrush10, 0, "", (void*)&brush10, CA_None, isSens,
  88.             frBrush, ibBrush9, ibBrush1, 0, "Large Left Slash"},
  89.  
  90.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  91.   };
  92.  
  93.  
  94. //=========================>>> vBrshDialog::vBrshDialog <<<====================
  95.  vBrshDialog::vBrshDialog(vBaseWindow* bw, int All, myCanvasPane* cnv) :
  96.     vDialog(bw, 0, "Brush Box")
  97.   {
  98.     // Creates the brush dialog window.
  99.  
  100.     UserDebug(Constructor,"vBrshDialog::vBrshDialog(basewindow)\n")
  101.     toAll = All;
  102.     pWin = (vWindow*) bw;
  103.     myCanvas = (myCanvasPane*)cnv;
  104.     toggleBrush = ibBrush1;
  105.     init();
  106.   }
  107.  
  108. //=========================>>> vBrshDialog::vBrshDialog <<<====================
  109.  void vBrshDialog::init()
  110.   {
  111.     // Initializes the brush dialog window.
  112.  
  113.     AddDialogCmds(DefaultCmds);         // add the predefined commands
  114.  
  115.     drawWhatBrush = brush_1;
  116.   }
  117.  
  118. //========================>>> vBrshDialog::~vBrshDialog <<<====================
  119.   vBrshDialog::~vBrshDialog()
  120.   {
  121.     // Brush Dialog destructor function
  122.  
  123.     UserDebug(Destructor,"vBrshDialog::~vBrshDialog() destructor\n")
  124.   }
  125.  
  126. //====================>>> vBrshDialog::DialogCommand <<<=======================
  127.   void vBrshDialog::DialogCommand(ItemVal id, ItemVal val, CmdType ctype)
  128.   {
  129.     // After the user has selected a command from the dialog, this routine is 
  130.     // called with the value.  This code would be generated by Vigr.
  131.  
  132.     UserDebug2(CmdEvents,"vBrshDialog::DialogCommand(id:%d, val:%d)\n",id, val)
  133.  
  134.     int i,j;
  135.  
  136.     switch (id)         // We will draw in a different brush depending on value
  137.         // toggleBrush is used to keep track of which item
  138.         // from the Brush box is currently being used.
  139.         // Only one brush can be used at any one time.
  140.  
  141.       {
  142.         case ibBrush1:    // Style 1 brush chosen
  143.      {
  144.            if (toggleBrush == ibBrush1) //toggle with other patterns
  145.            SetValue(ibBrush1,1, Value);
  146.             else
  147.           {
  148.         SetValue(toggleBrush, 0,Value);
  149.         toggleBrush = ibBrush1;
  150.           }
  151.  
  152.         // Draw selected brush
  153.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  154.             myCanvas->_myPicture->SetIndex(0,0,2,-99);
  155.             myCanvas->_BrushWidth = 1;
  156.             myCanvas->_BrushHeight = 1;
  157.             myCanvas->_BrushOffX = 0;
  158.             myCanvas->_BrushOffY = 0;
  159.             drawWhatBrush = brush_1;
  160.             break;
  161.      }
  162.  
  163.         case ibBrush2:    // Style 2 brush chosen
  164.      {
  165.            if (toggleBrush == ibBrush2) //toggle with other patterns 
  166.                     SetValue(ibBrush2,1, Value);
  167.             else    {
  168.                      SetValue(toggleBrush, 0,Value);  
  169.                      toggleBrush = ibBrush2;  
  170.                     }
  171.  
  172.             // Draw selected brush
  173.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  174.             myCanvas->_myPicture->SetIndex(1,0,2,-99);
  175.             myCanvas->_myPicture->SetIndex(2,0,2,-99);
  176.             myCanvas->_myPicture->SetIndex(0,1,2,-99);
  177.             myCanvas->_myPicture->SetIndex(1,1,2,-99);
  178.             myCanvas->_myPicture->SetIndex(2,1,2,-99);
  179.             myCanvas->_myPicture->SetIndex(3,1,2,-99);
  180.             myCanvas->_myPicture->SetIndex(0,2,2,-99);
  181.             myCanvas->_myPicture->SetIndex(1,2,2,-99);
  182.             myCanvas->_myPicture->SetIndex(2,2,2,-99);
  183.             myCanvas->_myPicture->SetIndex(3,2,2,-99);
  184.             myCanvas->_myPicture->SetIndex(1,3,2,-99);
  185.             myCanvas->_myPicture->SetIndex(2,3,2,-99);
  186.  
  187.             myCanvas->_BrushWidth = 4;
  188.             myCanvas->_BrushHeight = 4;
  189.             myCanvas->_BrushOffX = 2;
  190.             myCanvas->_BrushOffY = 2;
  191.             drawWhatBrush = brush_2;
  192.             break;
  193.      }
  194.  
  195.         case ibBrush3:    // Style 3 brush chosen
  196.      {
  197.            if (toggleBrush == ibBrush3) //toggle with other patterns 
  198.                     SetValue(ibBrush3,1, Value);
  199.             else    {
  200.                      SetValue(toggleBrush, 0,Value);  
  201.                      toggleBrush = ibBrush3;  
  202.                     }
  203.  
  204.             // Draw selected brush
  205.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  206.             myCanvas->_myPicture->SetIndex(2,0,2,-99);
  207.             myCanvas->_myPicture->SetIndex(3,0,2,-99);
  208.             myCanvas->_myPicture->SetIndex(4,0,2,-99);
  209.             myCanvas->_myPicture->SetIndex(1,1,2,-99);
  210.             myCanvas->_myPicture->SetIndex(2,1,2,-99);
  211.             myCanvas->_myPicture->SetIndex(3,1,2,-99);
  212.             myCanvas->_myPicture->SetIndex(4,1,2,-99);
  213.             myCanvas->_myPicture->SetIndex(5,1,2,-99);
  214.             myCanvas->_myPicture->SetIndex(0,2,2,-99);
  215.             myCanvas->_myPicture->SetIndex(1,2,2,-99);
  216.             myCanvas->_myPicture->SetIndex(2,2,2,-99);
  217.             myCanvas->_myPicture->SetIndex(3,2,2,-99);
  218.             myCanvas->_myPicture->SetIndex(4,2,2,-99);
  219.             myCanvas->_myPicture->SetIndex(5,2,2,-99);
  220.             myCanvas->_myPicture->SetIndex(6,2,2,-99);
  221.             myCanvas->_myPicture->SetIndex(0,3,2,-99);
  222.             myCanvas->_myPicture->SetIndex(1,3,2,-99);
  223.             myCanvas->_myPicture->SetIndex(2,3,2,-99);
  224.             myCanvas->_myPicture->SetIndex(3,3,2,-99);
  225.             myCanvas->_myPicture->SetIndex(4,3,2,-99);
  226.             myCanvas->_myPicture->SetIndex(5,3,2,-99);
  227.             myCanvas->_myPicture->SetIndex(6,3,2,-99);
  228.             myCanvas->_myPicture->SetIndex(1,4,2,-99);
  229.             myCanvas->_myPicture->SetIndex(2,4,2,-99);
  230.             myCanvas->_myPicture->SetIndex(3,4,2,-99);
  231.             myCanvas->_myPicture->SetIndex(4,4,2,-99);
  232.             myCanvas->_myPicture->SetIndex(5,4,2,-99);
  233.             myCanvas->_myPicture->SetIndex(2,5,2,-99);
  234.             myCanvas->_myPicture->SetIndex(3,5,2,-99);
  235.             myCanvas->_myPicture->SetIndex(4,5,2,-99);
  236.  
  237.             myCanvas->_BrushWidth = 7;
  238.             myCanvas->_BrushHeight = 7;
  239.             myCanvas->_BrushOffX = 4;
  240.             myCanvas->_BrushOffY = 4;
  241.             drawWhatBrush = brush_3;
  242.             break;
  243.      }
  244.  
  245.         case ibBrush4:    // Style 4 brush chosen
  246.      {
  247.            if (toggleBrush == ibBrush4) //toggle with other patterns 
  248.                     SetValue(ibBrush4,1, Value);
  249.             else    {
  250.                      SetValue(toggleBrush, 0,Value);  
  251.                      toggleBrush = ibBrush4;  
  252.                     }
  253.  
  254.             // Draw selected brush
  255.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  256.             myCanvas->_myPicture->SetIndex(1,0,2,-99);
  257.             myCanvas->_myPicture->SetIndex(0,1,2,-99);
  258.  
  259.             myCanvas->_BrushWidth = 2;
  260.             myCanvas->_BrushHeight = 2;
  261.             myCanvas->_BrushOffX = 1;
  262.             myCanvas->_BrushOffY = 1;
  263.             drawWhatBrush = brush_4;
  264.             break;
  265.      }
  266.  
  267.         case ibBrush5:    // Style 5 brush chosen
  268.      {
  269.            if (toggleBrush == ibBrush5) //toggle with other patterns 
  270.                     SetValue(ibBrush5,1, Value);
  271.             else    {
  272.                      SetValue(toggleBrush, 0,Value);  
  273.                      toggleBrush = ibBrush5;  
  274.                     }
  275.  
  276.             // Draw selected brush
  277.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  278.             myCanvas->_myPicture->SetIndex(4,0,2,-99);
  279.             myCanvas->_myPicture->SetIndex(3,1,2,-99);
  280.             myCanvas->_myPicture->SetIndex(2,2,2,-99);
  281.             myCanvas->_myPicture->SetIndex(1,3,2,-99);
  282.             myCanvas->_myPicture->SetIndex(0,4,2,-99);
  283.  
  284.             myCanvas->_BrushWidth = 5;
  285.             myCanvas->_BrushHeight = 5;
  286.             myCanvas->_BrushOffX = 3;
  287.             myCanvas->_BrushOffY = 3;
  288.             drawWhatBrush = brush_5;
  289.             break;
  290.      }
  291.  
  292.         case ibBrush6:    // Style 6 brush chosen
  293.      {
  294.            if (toggleBrush == ibBrush6) //toggle with other patterns 
  295.                     SetValue(ibBrush6,1, Value);
  296.             else    {
  297.                      SetValue(toggleBrush, 0,Value);  
  298.                      toggleBrush = ibBrush6;  
  299.                     }
  300.  
  301.             // Draw selected brush
  302.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  303.             myCanvas->_myPicture->SetIndex(0,0,2,-99);
  304.             myCanvas->_myPicture->SetIndex(1,0,2,-99);
  305.             myCanvas->_myPicture->SetIndex(0,1,2,-99);
  306.             myCanvas->_myPicture->SetIndex(1,1,2,-99);
  307.  
  308.             myCanvas->_BrushWidth = 2;
  309.             myCanvas->_BrushHeight = 2;
  310.             myCanvas->_BrushOffX = 1;
  311.             myCanvas->_BrushOffY = 1;
  312.             drawWhatBrush = brush_6;
  313.             break;
  314.      }
  315.  
  316.         case ibBrush7:    // Style 7 brush chosen
  317.      {
  318.            if (toggleBrush == ibBrush7) //toggle with other patterns 
  319.                     SetValue(ibBrush7,1, Value);
  320.             else    {
  321.                      SetValue(toggleBrush, 0,Value);  
  322.                      toggleBrush = ibBrush7;  
  323.                     }
  324.  
  325.             // Draw selected brush
  326.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  327.             for (i = 0; i < 5; i++)
  328.               for (j = 0; j < 5; j++)
  329.                 myCanvas->_myPicture->SetIndex(i,j,2,-99);            
  330.                                               
  331.             myCanvas->_BrushWidth = 5;
  332.             myCanvas->_BrushHeight = 5;
  333.             myCanvas->_BrushOffX = 3;
  334.             myCanvas->_BrushOffY = 3;
  335.             drawWhatBrush = brush_7;
  336.             break;
  337.      }
  338.  
  339.         case ibBrush8:    // Style 8 brush chosen
  340.      {
  341.            if (toggleBrush == ibBrush8) //toggle with other patterns 
  342.                     SetValue(ibBrush8,1, Value);
  343.             else    {
  344.                      SetValue(toggleBrush, 0,Value);  
  345.                      toggleBrush = ibBrush8;  
  346.                     }
  347.  
  348.             // Draw selected brush
  349.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  350.             for (i = 0; i < 8; i++)
  351.               for (j = 0; j < 8; j++)
  352.                 myCanvas->_myPicture->SetIndex(i,j,2,-99);            
  353.  
  354.             myCanvas->_BrushWidth = 8;
  355.             myCanvas->_BrushHeight = 8;
  356.             myCanvas->_BrushOffX = 3;
  357.             myCanvas->_BrushOffY = 3;
  358.             drawWhatBrush = brush_8;
  359.             break;
  360.      }
  361.  
  362.         case ibBrush9:    // Style 9 brush chosen
  363.      {
  364.            if (toggleBrush == ibBrush9) //toggle with other patterns 
  365.                     SetValue(ibBrush9,1, Value);
  366.             else    {
  367.                      SetValue(toggleBrush, 0,Value);  
  368.                      toggleBrush = ibBrush9;  
  369.                     }
  370.  
  371.             // Draw selected brush
  372.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  373.             myCanvas->_myPicture->SetIndex(0,0,2,-99);
  374.             myCanvas->_myPicture->SetIndex(1,1,2,-99);
  375.  
  376.             myCanvas->_BrushWidth = 2;
  377.             myCanvas->_BrushHeight = 2;
  378.             myCanvas->_BrushOffX = 1;
  379.             myCanvas->_BrushOffY = 1;
  380.             
  381.             drawWhatBrush = brush_9;
  382.             break;
  383.      }
  384.  
  385.         case ibBrush10:    // Style 10 brush chosen
  386.      {
  387.            if (toggleBrush == ibBrush10) //toggle with other patterns 
  388.                     SetValue(ibBrush10,1, Value);
  389.             else    {
  390.                      SetValue(toggleBrush, 0,Value);  
  391.                      toggleBrush = ibBrush10;  
  392.                     }
  393.  
  394.             // Draw selected brush
  395.             myCanvas->_myPicture->Clear(2, myCanvas->_myColorPal->getbg());
  396.             myCanvas->_myPicture->SetIndex(0,0,2,-99);
  397.             myCanvas->_myPicture->SetIndex(1,1,2,-99);
  398.             myCanvas->_myPicture->SetIndex(2,2,2,-99);
  399.             myCanvas->_myPicture->SetIndex(3,3,2,-99);
  400.             myCanvas->_myPicture->SetIndex(4,4,2,-99);
  401.  
  402.             myCanvas->_BrushWidth = 5;
  403.             myCanvas->_BrushHeight = 5;
  404.             myCanvas->_BrushOffX = 3;
  405.             myCanvas->_BrushOffY = 3;
  406.             drawWhatBrush = brush_10;
  407.             break;
  408.      }
  409.  
  410.       }
  411.     myCanvas->Redraw(0,0,0,0);    // Do an automatic redraw clear old brush on the canvas
  412.   }
  413.