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

  1. //=======================================================================
  2. //  mymodal.cxx - Source file for myModalDialog class
  3. //  Copyright (C) 1995  Bruce E. Wampler
  4. //
  5. //  This program is part of the V C++ GUI Framework example programs.
  6. //
  7. //  This program is free software; you can redistribute it and/or modify
  8. //  it under the terms of the GNU General Public License as published by
  9. //  the Free Software Foundation; either version 2 of the License, or
  10. //  (at your option) any later version.
  11. //
  12. //  This program is distributed in the hope that it will be useful,
  13. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. //  GNU General Public License for more details.
  16. //
  17. //  You should have received a copy of the GNU General Public License
  18. //  (see COPYING) along with this program; if not, write to the Free
  19. //  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. //=======================================================================
  21.  
  22. #include "mymodal.h"
  23. #include <v/vnotice.h>
  24.  
  25. //    The following would be automatically generated by Vigr.  There
  26. //    should be some regular algroithm for generating the #defines -
  27. //    e.g., 2 letters from class name (md), something from the Cmd type (CB),
  28. //    and a value to distinguish each label from aother.  The user should
  29. //    also be able to override the default generated name.  There can be
  30. //    some standard names such as xxBtnOK, etc.  The idea is to get some
  31. //    good compromise for uniqueness, ease of generation, and readability.
  32. //    Each module should have labels starting at the next 100, with the
  33. //    top level window starting with 100.
  34.  
  35. const ItemVal mmLbl1 = 300;
  36. const ItemVal mmBtn1 = 301;
  37. const ItemVal mmBtn2 = 302;
  38. const ItemVal mmBtnCncl = 303;
  39. const ItemVal mmBtnOK = 304;
  40.  
  41. // This would also be automatically generated by Vigr. One of the functions
  42. // of Vigr is to allow the user to specify types and positions of Cmds in the
  43. // dialogs.
  44. //
  45.     static DialogCmd DefaultCmds[] =
  46.       {
  47.  
  48.     {C_Label, mmLbl1, 0,"X",NoList,CA_MainMsg,isSens,NoFrame, 0, 0},
  49.     
  50.     {C_Button, mmBtn1, mmBtn1," Test 1 ",NoList,CA_None,isSens,NoFrame, 0, mmLbl1},
  51.     {C_Button, mmBtn2, mmBtn2," Test 2 ", NoList,CA_None,isSens,NoFrame,
  52.         mmBtn1,mmLbl1},
  53.  
  54.     {C_Button, M_Cancel, M_Cancel," Cancel ",NoList,CA_None,isSens,NoFrame,
  55.         0, mmBtn1},
  56.     {C_Button, M_OK, M_OK, "   OK   ", NoList, CA_DefaultButton, 
  57.         isSens, NoFrame, M_Cancel, mmBtn1},
  58.  
  59.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  60.       };
  61.  
  62.  
  63. //======================>>> myModalDialog::myModalDialog <<<==================
  64.   myModalDialog::myModalDialog(vBaseWindow* bw) :
  65.     vModalDialog(bw)
  66.   {
  67.     UserDebug(Constructor,"myModalDialog::myModalDialog()\n")
  68.     AddDialogCmds(DefaultCmds);        // add the predefined commands
  69.   }
  70.  
  71. //===================>>> myModalDialog::~myModalDialog <<<====================
  72.   myModalDialog::~myModalDialog()
  73.   {
  74.     UserDebug(Destructor,"myModalDialog::~myModalDialog() destructor\n")
  75.   }
  76.  
  77. //====================>>> myModalDialog::DialogCommand <<<====================
  78.   void myModalDialog::DialogCommand(ItemVal id, ItemVal retval, CmdType ctype)
  79.   {
  80.     // After the user has selected a command from the dialog,
  81.     // this routine is called with the value.  This code would be generated
  82.     // by Vigr.
  83.  
  84.     vNoticeDialog note(this);
  85.  
  86.     UserDebug2(CmdEvents,"myModalDialog::DialogCommand(id:%d, val:%d)\n",id, retval)
  87.  
  88.     switch (id)        // We will do some things depending on value
  89.       {
  90.     case mmBtn1:        // Button
  91.       {
  92.         note.Notice(" Test 1 ");
  93.         break;
  94.       }
  95.  
  96.     case mmBtn2:        // Button
  97.       {
  98.         note.Notice(" Test 2 ");
  99.         break;
  100.       }
  101.       }
  102.  
  103.     vModalDialog::DialogCommand(id,retval,ctype);
  104.   }
  105.