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

  1. //========================================================================
  2. //  tmodal.cpp - Source file for tutorial tModalDialog class
  3. //
  4. //  Copyright 1995,1996 Bruce E. Wampler, All Rights Reserved
  5. //========================================================================
  6. //
  7.  
  8. #include "tmodal.h"             // our header file
  9. #include <v/vnotice.h>
  10.  
  11. const ItemVal mmLbl1 = 300;
  12. const ItemVal mmBtn1 = 301;
  13. const ItemVal mmBtn2 = 302;
  14.  
  15.     static CommandObject DefaultCmds[] =
  16.       {
  17.         {C_Label, mmLbl1, 0,"X",NoList,CA_MainMsg,isSens,NoFrame, 0, 0},
  18.         
  19.         {C_Button,mmBtn1,mmBtn1," Test 1 ",NoList,CA_None,
  20.                 isSens,NoFrame,0,mmLbl1},
  21.         {C_Button,mmBtn2,mmBtn2," Test 2 ",NoList,CA_None,
  22.                 isSens,NoFrame, mmBtn1,mmLbl1},
  23.  
  24.         {C_Button,M_Cancel,M_Cancel," Cancel ",NoList,CA_None,
  25.                 isSens,NoFrame, 0,mmBtn1},
  26.         {C_Button,M_OK,M_OK,"   OK   ",NoList,CA_DefaultButton,
  27.                 isSens,NoFrame,M_Cancel,mmBtn1},
  28.  
  29.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  30.       };
  31.  
  32.  
  33. //======================>>> tModalDialog::tModalDialog <<<================
  34.   tModalDialog::tModalDialog(vBaseWindow* bw) :
  35.     vModalDialog(bw)
  36.   {
  37.     UserDebug(Constructor,"tModalDialog::tModalDialog()\n")
  38.     AddDialogCmds(DefaultCmds);         // add the predefined commands
  39.   }
  40.  
  41. //=================>>> tModalDialog::~tModalDialog <<<====================
  42.   tModalDialog::~tModalDialog()
  43.   {
  44.     UserDebug(Destructor,"tModalDialog::~tModalDialog() destructor\n")
  45.   }
  46.  
  47. //===================>>> tModalDialog::DialogCommand <<<==================
  48.   void tModalDialog::DialogCommand(ItemVal id,ItemVal retval,CmdType ctype)
  49.   {
  50.     // After the user has selected a command from the dialog,
  51.     // this routine is called with the id and retval.
  52.  
  53.     vNoticeDialog note(this);
  54.  
  55.     UserDebug1(CmdEvents,"tModalDialog::DialogCommand(id:%d)\n",id)
  56.  
  57.     switch (id)         // We will do some things depending on value
  58.       {
  59.         case mmBtn1:            // Button 1
  60.             note.Notice(" Test 1 ");
  61.             break;
  62.  
  63.         case mmBtn2:            // Button 2
  64.             note.Notice(" Test 2 ");
  65.             break;
  66.       }
  67.  
  68.     // let default behavior handle Cancel and OK
  69.     vModalDialog::DialogCommand(id,retval,ctype);
  70.   }
  71.