home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / srcos2 / vdebug.cpp < prev    next >
C/C++ Source or Header  |  1998-10-13  |  8KB  |  209 lines

  1. //===============================================================
  2. // vdebug.cxx - vDebugDialog class methods
  3. //
  4. // Copyright (C) 1995,1996,1997,1998  Bruce E. Wampler
  5. //
  6. // This file is part of the V C++ GUI Framework, and is covered
  7. // under the terms of the GNU Library General Public License,
  8. // Version 2. This library has NO WARRANTY. See the source file
  9. // vapp.cxx for more complete information about license terms.
  10. //===============================================================
  11. #include <v/vos2.h>        // for OS/2 stuff
  12. #include <v/vdebug.h>        // our header
  13.  
  14. // Define static data of the class
  15. #define dSystem 10
  16. #define dUser 11
  17. #define dCmdEvents 12
  18. #define dMouseEvents 13
  19. #define dWindowEvents 14
  20. #define dBuild 15
  21. #define dMisc 16
  22. #define dBadVals 17
  23. #define dConstructor 18
  24. #define dDestructor 19
  25. #define dText 30
  26. #define dUserApp1 20
  27. #define dUserApp2 21
  28. #define dUserApp3 22
  29.  
  30.   int SetCommandObject(const int id, const int val, CommandObject* CmdList);
  31.   int GetCommandObject(const int id, CommandObject* CmdList);
  32.  
  33.   static CommandObject DebugDialog[] =
  34.   {
  35.     {C_Label, 91, 0, "Set Debug Options",
  36.       NoList, CA_MainMsg, isSens, 0,0},
  37.  
  38.     {C_Blank, 98, 0, "       ", NoList,CA_None,isSens,NoFrame,91,0},
  39.     {C_Label, 99, 0, V_Version, NoList,CA_None,isSens,NoFrame,98,0},
  40.  
  41.     // A frame around the check boxes
  42.     {C_Frame, 92, 0, "", NoList, CA_None, isSens,NoFrame, 0, 91},
  43.  
  44.     // note: the id corresponds to the #defines above
  45.     {C_CheckBox,10,0,"System Msgs   ",NoList,CA_None,isSens,92,0,0},
  46.     {C_CheckBox,11,0,"User Messages ",NoList,CA_None,isSens,92,10,0},
  47.     {C_CheckBox,12,0,"Command Events",NoList,CA_None,isSens,92,0,10},
  48.     {C_CheckBox,13,0,"Mouse Events  ",NoList,CA_None,isSens,92,12,10},
  49.     {C_CheckBox,14,0,"Window Events ",NoList,CA_None,isSens,92,13,10},
  50.  
  51.     {C_CheckBox,15,0,"Build Windows ",NoList,CA_None,isSens,92,0,12},
  52.     {C_CheckBox,16,0,"Misc Messages ",NoList,CA_None,isSens,92,15,12},
  53.     {C_CheckBox,17,0,"Illegal Values",NoList,CA_None,isSens,92,16,12},
  54.  
  55.     {C_CheckBox,18,0,"Constructors  ",NoList,CA_None,isSens,92,0,15},
  56.     {C_CheckBox,19,0,"Destructors   ",NoList,CA_None,isSens,92,18,15},
  57.     {C_CheckBox,30,0,"Text          ",NoList,CA_None,isSens,92,19,15},
  58.  
  59.     {C_CheckBox,20,0,"User Debug 1  ",NoList,CA_None,isSens,92,0,18},
  60.     {C_CheckBox,21,0,"User Debug 2  ",NoList,CA_None,isSens,92,20,18},
  61.     {C_CheckBox,22,0,"User Debug 3  ",NoList,CA_None,isSens,92,21,18},
  62.  
  63.     {C_Button, M_All,M_All," All On ",NoList,CA_None,isSens,NoFrame,0,92},
  64.     {C_Button, M_None,M_None," All Off ",NoList,CA_None,isSens,NoFrame,M_All,92},
  65.     {C_Blank, 95, 0, "          ", NoList,CA_None,isSens,NoFrame,M_None,92},
  66.     {C_Button, M_Cancel, M_Cancel, " Cancel ", NoList,
  67.       CA_None,isSens,NoFrame, 95,92},
  68.     {C_Button, M_OK, M_OK, " OK ", NoList,
  69.       CA_DefaultButton, isSens, NoFrame, M_Cancel, 92},
  70.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  71.   };
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. //=======================>>> vDebugDialog::SetDebug <<<=======================
  79.   void vDebugDialog::SetDebug()
  80.   {
  81.     //    Show a message, ask user Yes/No/Cancel
  82.     //    returns < 0 for cancel, 0 for No, 1 for Yes
  83.     int id;
  84.     ItemVal val;
  85.     // first, set with current values
  86.     (void) SetCommandObject(dSystem, DebugState.System, DebugDialog);
  87.     (void) SetCommandObject(dUser, DebugState.User, DebugDialog);
  88.     (void) SetCommandObject(dCmdEvents, DebugState.CmdEvents, DebugDialog);
  89.     (void) SetCommandObject(dMouseEvents, DebugState.MouseEvents, DebugDialog);
  90.     (void) SetCommandObject(dWindowEvents, DebugState.WindowEvents, DebugDialog);
  91.     (void) SetCommandObject(dUserApp1, DebugState.UserApp1, DebugDialog);
  92.     (void) SetCommandObject(dUserApp2, DebugState.UserApp2 , DebugDialog);
  93.     (void) SetCommandObject(dUserApp3, DebugState.UserApp3 , DebugDialog);
  94.     (void) SetCommandObject(dBuild, DebugState.Build, DebugDialog);
  95.     (void) SetCommandObject(dMisc, DebugState.Misc, DebugDialog);
  96.     (void) SetCommandObject(dText, DebugState.Text, DebugDialog);
  97.     (void) SetCommandObject(dBadVals, DebugState.BadVals, DebugDialog);
  98.     (void) SetCommandObject(dConstructor, DebugState.Constructor, DebugDialog);
  99.     (void) SetCommandObject(dDestructor, DebugState.Destructor, DebugDialog);
  100.  
  101.  
  102.     AddDialogCmds(DebugDialog);        // Set up standard dialog
  103.     ShowModalDialog("Set Debug Options",val);    // show and wait
  104.     switch (val)            // convert to our system
  105.     {
  106.       case M_OK:
  107.     DebugState.System = GetValue(dSystem);
  108.     DebugState.User = GetValue(dUser);
  109.     DebugState.CmdEvents = GetValue(dCmdEvents);
  110.     DebugState.MouseEvents = GetValue(dMouseEvents);
  111.     DebugState.WindowEvents = GetValue(dWindowEvents);
  112.     DebugState.UserApp1 = GetValue(dUserApp1);
  113.     DebugState.UserApp2  = GetValue(dUserApp2);
  114.     DebugState.UserApp3  = GetValue(dUserApp3);
  115.     DebugState.Build = GetValue(dBuild);
  116.     DebugState.Misc = GetValue(dMisc);
  117.     DebugState.Text = GetValue(dText);
  118.     DebugState.BadVals = GetValue(dBadVals);
  119.     DebugState.Constructor = GetValue(dConstructor);
  120.     DebugState.Destructor = GetValue(dDestructor);
  121.     break;
  122.       case M_Cancel:
  123.     break;
  124.       default:
  125.     SysDebug1(BadVals,"vDebugDialog::SetDebug() - can't handle %d\n",val)
  126.     break;
  127.     };
  128.  
  129.   }
  130. //====================>>> vDebugDialog::DialogCommand <<<=======================
  131.   void vDebugDialog::DialogCommand(ItemVal id, ItemVal val, CmdType ctype)
  132.   {
  133.     vModalDialog::DialogCommand(id,val,ctype);
  134.     switch (id)
  135.     {
  136.       case M_OK:
  137.     CloseDialog();
  138.     break;
  139.       case M_All:                // set all to 1
  140.     SetValue(dSystem, 1, Value);
  141.     SetValue(dUser, 1, Value);
  142.     SetValue(dCmdEvents, 1, Value);
  143.     SetValue(dMouseEvents, 1, Value);
  144.     SetValue(dWindowEvents, 1, Value);
  145.     SetValue(dUserApp1, 1, Value);
  146.     SetValue(dUserApp2, 1, Value);
  147.     SetValue(dUserApp3, 1, Value);
  148.     SetValue(dBuild, 1, Value);
  149.     SetValue(dMisc, 1, Value);
  150.     SetValue(dText, 1, Value);
  151.     SetValue(dBadVals, 1, Value);
  152.     SetValue(dConstructor, 1, Value);
  153.     SetValue(dDestructor, 1, Value);
  154.     break;
  155.  
  156.       case M_None:                // set all to 0
  157.     SetValue(dSystem, 0, Value);
  158.     SetValue(dUser, 0, Value);
  159.     SetValue(dCmdEvents, 0, Value);
  160.     SetValue(dMouseEvents, 0, Value);
  161.     SetValue(dWindowEvents, 0, Value);
  162.     SetValue(dUserApp1, 0, Value);
  163.     SetValue(dUserApp2, 0, Value);
  164.     SetValue(dUserApp3, 0, Value);
  165.     SetValue(dBuild, 0, Value);
  166.     SetValue(dMisc, 0, Value);
  167.     SetValue(dText, 0, Value);
  168.     SetValue(dBadVals, 0, Value);
  169.     SetValue(dConstructor, 0, Value);
  170.     SetValue(dDestructor, 0, Value);
  171.     break;
  172.     }
  173.   }
  174. //###########################################################################
  175. // Utilities - these may be useful for others, too.
  176. //========================>>> SetCommandObject <<<==============================
  177.   int SetCommandObject(const int id, const int val, CommandObject* CmdList)
  178.   {
  179.     for (CommandObject* cur = CmdList ; cur->cmdType != C_EndOfList ; ++cur)
  180.     {
  181.       if (cur->cmdId == id)
  182.       {
  183.     cur->retVal = val;
  184.     return 1;
  185.       }
  186.     }
  187.     SysDebug1(BadVals,"SetCommandObject(id:%d...) - No match in list\n",id)
  188.     return 0;
  189.   }
  190.  
  191. //========================>>> GetCommandObject <<<==============================
  192. // This just gets the static value of the original CommandObject.  It does
  193. // not get the updated state of the checkbox which is how it was orginially
  194. // being used.  All versions of DebugDialog except OS/2 seem to be broken in
  195. // this way before v1.20
  196.   int GetCommandObject(const int id, CommandObject* CmdList)
  197.   {
  198.     for (CommandObject* cur = CmdList ; cur->cmdType != C_EndOfList ; ++cur)
  199.     {
  200.       if (cur->cmdId == id)
  201.       {
  202.     return cur->retVal;
  203.       }
  204.     }
  205.     SysDebug1(BadVals,"GetCommandObject(id:%d...) - No match in list\n",id)
  206.     return 0;
  207.   }
  208.  
  209.