home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / test / vtdialog.cpp < prev    next >
C/C++ Source or Header  |  1998-09-04  |  11KB  |  284 lines

  1.  
  2. //=======================================================================
  3. // vtdialog.cxx - Source file for testDialog class
  4. //  Copyright (C) 1995,1996, 1997, 1998  Bruce E. Wampler
  5. //
  6. //  This program is part of the V C++ GUI Framework example programs.
  7. //
  8. //  This program is free software; you can redistribute it and/or modify
  9. //  it under the terms of the GNU General Public License as published by
  10. //  the Free Software Foundation; either version 2 of the License, or
  11. //  (at your option) any later version.
  12. //
  13. //  This program is distributed in the hope that it will be useful,
  14. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. //  GNU General Public License for more details.
  17. //
  18. //  You should have received a copy of the GNU General Public License
  19. //  (see COPYING) along with this program; if not, write to the Free
  20. //  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. //=======================================================================
  22.  
  23. #include "vtdialog.h"
  24. #include <v/v_defs.h>
  25. #include <v/vnotice.h>
  26. #include <v/vcolor.h>
  27. #include <v/vlabelc.h>
  28. #include <v/vutil.h>
  29.  
  30.     static char change_me[] = "Change Me A (Σσ)";    // a label to change
  31. #define ChangeMeID 444
  32.  
  33.     static vColor btncolor(255, 0 , 0);         // start at red
  34.  
  35.     static int prange[2] = {-20,200};
  36.  
  37.     CommandObject DefaultCmds[] =
  38.       {
  39.  
  40.         {C_Frame, 10, 0, "", NoList, CA_None, isSens, NoFrame, 0, 0},
  41.         {C_Label, 111, 0, "Frame - ⁿΘΓΣ", NoList, CA_None, isSens, 10, 0, 0},
  42.         {C_CheckBox, 112, 0, "Test A", NoList, CA_None, isSens, 10, 0, 111, 0,
  43.         "Test A CheckBox"},
  44.         {C_CheckBox, 113, 0, "Test B", NoList, CA_None, isSens, 10, 112, 111, 0,
  45.         "Test B Checkbox"},
  46.         {C_CheckBox, 114, 1, "Test C", NoList, CA_None, isSens, 10, 0, 112, 0,
  47.         "Test C Checkbox"},
  48.  
  49.         {C_Frame,115, 0, "", NoList,CA_NoBorder,isSens, 10, 113, 0},
  50.         {C_Label, 116, 0 , "Column A",NoList,CA_None,isSens,115,0,0},
  51.         {C_Button, 117, 0, "Uneven",NoList, CA_None, isSens, 115, 0,116, 0,
  52.         "Top Button"},
  53.         {C_Button, 118, 0, "Vertical",NoList, CA_None, isSens, 115, 0,117, 0,
  54.         "Middle Button"},
  55.         {C_Button, 119, 0, "Buttons",NoList, CA_None, isSens, 115, 0,118, 0,
  56.         "Bottom Button"},
  57.  
  58.         {C_Frame,120, 0, "", NoList,CA_NoBorder,isSens, 10, 115, 0},
  59.         {C_Label, 121, 0 , "Column B",NoList,CA_None,isSens,120,0,0},
  60.         {C_Button, 122, 0, "Another",NoList, CA_None, isSens, 120, 0,121,0,
  61.         "Another button"},
  62.         {C_Button, 123, 0, "Vertical",NoList, CA_None, isSens, 120, 0,122,0,
  63.         "To test"},
  64.         {C_Button, 124, 0, "Set",NoList, CA_None, isSens, 120, 0,123, 0,
  65.         "Test code is boring"},
  66.  
  67.         {C_Frame, 11, 0, "", NoList,CA_None,isSens,NoFrame, 10, 0},
  68.         {C_Label, 20, 0, "VFrame", NoList,CA_None, isSens,11, 0, 0},
  69.         {C_RadioButton, 21, 1, "KOB",  NoList,CA_None,isSens, 11, 0, 20, 0,
  70.         "TV station KOB"},
  71.         {C_RadioButton, 22, 0, "KOAT", NoList, CA_None, isSens, 11, 0, 21, 0,
  72.         "TV station KOAT"},
  73.         {C_RadioButton, 23, 0, "KRQE", NoList, CA_None, isSens, 11, 0, 22, 0,
  74.         "TV station KRQE"},
  75.  
  76.         {C_Frame, 12, 0, "", NoList,CA_NoSpace,isSens,NoFrame, 11, 0,0,
  77.         "Does Frame Help Work?"},
  78.         {C_Label, 40, 0 , "NoSpace",NoList,CA_None,isSens,12,0,0},
  79.         {C_Button, 41, 41, "Button 1", NoList, CA_None, isSens, 12, 0, 40, 0,
  80.         "Another Button"},
  81.         {C_Button, 42, 42, "Button 2", NoList, CA_None, isSens, 12, 0, 41},
  82.         {C_Button, 43, 43, "Button 3", NoList, CA_None, isSens, 12, 0, 42},
  83.         {C_Button, 44, 44, "Button 4", NoList, CA_None, isSens, 12, 41, 40},
  84.         {C_Button, 45, 45, "ⁿ÷δ etc.", NoList, CA_None, isSens, 12, 41, 44, 0,
  85.         "Test extended characters"},
  86.  
  87.         {C_Frame, 13, 0, "",   NoList,CA_None,isSens,NoFrame, 0,10},
  88.         {C_Label, 30, 0 , "HFrame",NoList,CA_None,isSens,13,0,0},
  89.         {C_CheckBox, 31, 1, "H Check 1", NoList, CA_None, isSens, 13, 30, 0},
  90.         {C_CheckBox, 32, 0, "H Check 2", NoList, CA_None, isSens, 13, 31, 0},
  91.  
  92.         {C_CheckBox, 3, 1, "Check 1",    NoList,CA_None,isSens,NoFrame, 0, 13},
  93.         {C_CheckBox, 301, 0, "Check 2 ", NoList,CA_None,isSens,NoFrame, 3, 13},
  94.  
  95.         {C_Text, 4, 0, "", "This is an example\nof a two line text. (ⁿΣ)",
  96.                 CA_None,isSens,NoFrame, 301, 13},
  97.  
  98.         {C_ProgressBar, 76, 50, "", (void*)&prange[0],
  99.             CA_Vertical | CA_NoLabel | CA_Small, isSens,0, 4, 10},
  100.  
  101.         {C_Frame, 86, 0, "",   NoList,CA_None,isSens,NoFrame, 76,10},
  102.         {C_Label, 87, 0, "Slider", NoList,CA_None,isSens,86,0,0},
  103.         {C_Slider, 88, 50, "", (void*)&prange[0],CA_Horizontal ,isSens,86, 0, 87},
  104.         {C_Text, 89, 50, "", " 50",CA_NoBorder,isSens,86, 88, 87},
  105.  
  106.         {C_Slider, 85, 50, "", NoList,CA_Vertical ,isSens,0, 86, 10},
  107.    
  108.         {C_Frame, 70, 0, "",   NoList,CA_None,isSens,NoFrame, 76,86},
  109.         {C_Label, 71, 0, "Progress Bar", NoList,CA_None,isSens,70,0,0},
  110.         {C_ProgressBar, 72, 50, "", (void*)&prange[0],
  111.              CA_Horizontal | CA_Percent ,isSens,70, 0, 71},
  112.  
  113.         {C_RadioButton, 60, 1, "ABC", NoList,CA_None,isSens,NoFrame, 0, 3},
  114.         {C_RadioButton, 61, 0, "DEF", NoList,CA_None,isSens,NoFrame, 60, 3},
  115.         {C_RadioButton, 62, 0, "GHI", NoList,CA_None,isSens,NoFrame, 61, 3},
  116.  
  117.         {C_ColorButton, 7, 7, "  ", (void*)&btncolor, CA_None, isSens, NoFrame,
  118.            0, 60, 16},
  119.         {C_ColorLabel, 8, 8, "Color", (void*)&btncolor, CA_None, isSens, NoFrame,
  120.            7, 60},
  121.         {C_Button, ChangeMeID, 0, change_me, NoList, CA_None, isSens, NoFrame, 8, 60},
  122.         {C_Blank, 18,18,"   ",NoList,CA_None,notSens,NoFrame,ChangeMeID,60},
  123.  
  124.         {C_Button, 200, 200,"Hide",NoList,CA_None,isSens,NoFrame,0,8},
  125.         {C_Button, 201, 201,"UnHide",NoList,CA_Hidden,isSens,NoFrame,0,8},
  126.  
  127.         {C_Blank, 400,400,"   ",NoList,CA_None,notSens,NoFrame,201,8},
  128.  
  129.         {C_Button, M_Cancel, M_Cancel," Cancel ",NoList,CA_None,isSens,NoFrame,400,8},
  130.         {C_Button, M_OK, M_OK, " OK ", NoList, CA_DefaultButton,
  131.                 isSens, NoFrame, M_Cancel, 8},
  132.         {C_Button,880, 0, " Fill Chars",NoList,CA_None,isSens,NoFrame,M_OK,8},
  133.         {C_BoxedLabel, 888,0,"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
  134.                 NoList,CA_None,isSens,NoFrame,0,M_OK},
  135.         {C_BoxedLabel, 889,0,"d#########d#########d#########d#########d########d",
  136.                 NoList,CA_None,isSens,NoFrame,0,888},
  137.  
  138.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  139.       };
  140.  
  141.     static vLabelCmd* newLbl;
  142.     static CommandObject DynLabel =
  143.  
  144.         {C_Label, 301, 301, "Dynamic", NoList, CA_None, isSens, NoFrame, 18, 60};
  145.     static char let = ' ';
  146.  
  147. //=========================>>> testDialog::testDialog <<<====================
  148.   testDialog::testDialog(vBaseWindow* bw) :
  149.     vDialog(bw,0,"V Test Dialog (Σσ)")
  150.   {
  151.     UserDebug(Constructor,"testDialog::testDialog()\n")
  152.  
  153.     _myBase = bw;
  154.  
  155.     AddDialogCmds(DefaultCmds);         // add the predefined commands
  156.   }
  157.  
  158. //========================>>> testDialog::~testDialog <<<====================
  159.   testDialog::~testDialog()
  160.   {
  161.     UserDebug(Destructor,"testDialog::~testDialog() destructor\n")
  162.   }
  163.  
  164. //====================>>> testDialog::DialogCommand <<<=======================
  165.   void testDialog::DialogCommand(ItemVal id, ItemVal retval, CmdType ctype)
  166.   {
  167.     // After the user has selected a command from the dialog,
  168.     // this routine is called with the value.  This code would be generated
  169.     // by Vigr.
  170.  
  171.  
  172.     UserDebug2(CmdEvents,"testDialog::DialogCommand(id:%d, val:%d)\n",id, retval)
  173.  
  174.     switch (id)         // We will do some things depending on value
  175.       {
  176.         case 21:    // kob
  177.         case 22:    // koat
  178.         case 23:    // krqe
  179.         case 112:    // test a
  180.         case 113:    // test b
  181.         case 114:    // test c
  182.         case 60:    // abc
  183.         case 61:    // def
  184.         case 62:    // ghi
  185.           {
  186.    //        vNoticeDialog note(_myBase);
  187.    //         if (retval == 1)
  188.     //            note.Notice("radio button ON");
  189.    //         else
  190.    //             note.Notice("Radio Button OFF");
  191.             break;
  192.           }
  193.  
  194.         case 880:
  195.           {
  196.             char str[42];
  197.             for (int ix = 0 ; ix < 20 ; ++ix)
  198.                 str[ix] = let;
  199.             str[20] = 0;
  200.             str[0] = 'c';
  201.             str[19] = 'c';
  202.             let++;
  203.             SetString(888, str);
  204.             break;
  205.           }
  206.  
  207.         case ChangeMeID:                // Change my own label
  208.           {
  209.             // We will change the label on this button
  210.             change_me[10]++;            // change the "A"
  211.             SetString(ChangeMeID, change_me);
  212.             SetDialogTitle(change_me);
  213.         SetValue(62,1,Value);    // force a dyamic change to rb for test
  214.         SetValue(112,1,Value);    // force a dyamic change to rb for test
  215.             break;
  216.           }
  217.  
  218.         case 7:
  219.           {
  220.             // Test remapping of color to see how fast we use up colors
  221.             btncolor.ResetColor(btncolor.r()+127, btncolor.g()+63, btncolor.b()+31);
  222. #define SET1
  223. #ifdef SET1
  224.             SetValue(7,0,ChangeColor);          // change all at once
  225.             SetValue(8,0,ChangeColor);
  226. #else
  227.             SetValue(7,(ItemVal)btncolor.r(),Red);
  228.             SetValue(7,(ItemVal)btncolor.g(),Green);
  229.             SetValue(7,(ItemVal)btncolor.b(),Blue);
  230. #endif
  231.             break;
  232.           }
  233.  
  234.         case 88:                // Slider
  235.           {
  236.             char buff[20];
  237.             IntToStr(retval,buff);
  238.             SetString(89,buff);
  239.             SetValue(72,retval,Value);
  240.             SetValue(76,retval,Value);
  241.             break;
  242.           }
  243.  
  244.         case 200:                       // Hide some things
  245.           {
  246.             SetValue(200,1,Hidden);     // Hide this one
  247.             SetValue(201,0,Hidden);     // Unhide the UnHide
  248.  
  249.             // Hide stuff
  250.             SetValue(10,1,Hidden);      // Hide the frame
  251.             SetValue(3,1,Hidden);       // A checkbox
  252.             SetValue(4,1,Hidden);       // The text box
  253.             SetValue(76,1,Hidden);      // The progress bar
  254.             SetValue(72,1,Hidden);      // The progress bar
  255.             SetValue(8,1,Hidden);       // The color button
  256.             SetValue(60,1,Hidden);      // A radio button
  257.             SetValue(87,1,Hidden);      // Slider Label
  258.             SetValue(88,1,Hidden);      // Slider
  259.             break;
  260.           }
  261.  
  262.         case 201:
  263.           {
  264.             SetValue(201,1,Hidden);     // Hide the UnHide
  265.             SetValue(200,0,Hidden);     // Unhide the Hide
  266.  
  267.             // Unhide stuff
  268.             SetValue(10,0,Hidden);      // Hide the frame
  269.             SetValue(3,0,Hidden);       // A checkbox
  270.             SetValue(4,0,Hidden);       // The text box
  271.             SetValue(76,0,Hidden);      // The progress bar
  272.             SetValue(72,0,Hidden);      // The progress bar
  273.             SetValue(8,0,Hidden);       // The color button
  274.             SetValue(60,0,Hidden);      // A radio button
  275.             SetValue(87,0,Hidden);      // Slider Label
  276.             SetValue(88,0,Hidden);      // Slider
  277.             break;
  278.           }
  279.  
  280.       }
  281.     // All commands should also route through the parent handler
  282.     vDialog::DialogCommand(id,retval,ctype);
  283.   }
  284.