home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / MDBS.ZIP / BUTTON.CLS < prev    next >
Text File  |  1990-01-15  |  2KB  |  97 lines

  1. /*
  2. **  (C) Copyright 1989, 1990
  3. **  Micro Data Base Systems Inc.
  4. **  Lafayette, Indiana
  5. */
  6. /* Class Button is the class of all button
  7.    type control windows. */
  8. subclass(Control,
  9.          #Button,
  10.          nil,
  11.          true, true, false);$
  12.  
  13. /* Answer the window class name string. */
  14. method Button::windowClassNameOf(self)
  15. {
  16.         return WC_BUTTON;
  17. }
  18.  
  19. /* Simulate a button press. */
  20. method Button::press(self)
  21. {
  22.         sendMessage(self, BM_CLICK, false, 0);
  23.         return nil;
  24. }
  25.  
  26. /* Simulate a button release. */
  27. method Button::release(self)
  28. {
  29.         sendMessage(self, BM_CLICK, true, 0);
  30.         return nil;
  31. }
  32.  
  33. /* Answer whether or not a button is selected. */
  34. method Button::isChecked(self)
  35. {
  36.         return sendMessage(self, BM_QUERYCHECK, 0, 0) == 1;
  37. }
  38.  
  39. /* Answer the 0 based index into a group of radio buttons to the button
  40.    with the check. */
  41. method Button::checkIndexOf(self)
  42. {
  43.     return asInteger(sendMessage(self, BM_QUERYCHECKINDEX, 0, 0));
  44. }
  45.  
  46. /* Answer 'true' if the button is highlited. */
  47. method Button::isHilited(self)
  48. {
  49.     return sendMessage(self, BM_QUERYHILITE, 0, 0) != 0;
  50. }
  51.  
  52. /* Place the checkmark next to a button. Answer with the previous
  53.    check state of the button. */
  54. method Button::check(self)
  55. {
  56.         return sendMessage(self, BM_SETCHECK, 1, 0) == 1;
  57. }
  58.  
  59. /* Remove the checkmark from a button. Answer with the previous
  60.    check state of the button. */
  61. method Button::unCheck(self)
  62. {
  63.         return sendMessage(self, BM_SETCHECK, false, 0) == 1;
  64. }
  65.  
  66. /* Make the push button a default push putton. */
  67. method Button::setDefault(self)
  68. {
  69.         return sendMessage(self, BM_SETDEFAULT, true, 0) != 0;
  70. }
  71.  
  72. /* Make the push button a normal push putton. */
  73. method Button::resetDefault(self)
  74. {
  75.         return sendMessage(self, BM_SETDEFAULT, false, 0) != 0;
  76. }
  77.  
  78. /* Turn on the button hilite. Answer the previous button hilite state. */
  79. method Button::hilite(self)
  80. {
  81.     return sendMessage(self, BM_SETHILITE, true, 0) != 0;
  82. }
  83.  
  84. /* Turn off the button hilite. */
  85. method Button::unHilite(self)
  86. {
  87.     return sendMessage(self, BM_SETHILITE, false, 0) != 0;
  88. }
  89.  
  90. /* Toggle the checked status of the button.  Answer the prior state. */
  91. method Button::toggle(self)
  92. {
  93.         if(isChecked(self)) 
  94.                 return(unCheck(self));
  95.         else
  96.                 return(check(self));
  97. }