home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / Buttons / LAGAStateIconButton.cp < prev    next >
Encoding:
Text File  |  1996-06-30  |  4.6 KB  |  152 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LAGAStateIconButton.cp
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant (almost) state icon button
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGAStateIconButton.h            <- double-click + Command-D to see class declaration
  27. //
  28. //    LAGAStateIconButton is a subclass of LAGAIconButton, and enables the button to use
  29. //        up to three different icons (states), and to use them in a standard way (pushed,
  30. //        disabled, radio behavior)
  31. //
  32. //        see the comments in LAGAIconButton.h
  33. //
  34. //        Version : 1.2
  35. //
  36. //        Change History (most recent first, date in US form : mm/dd/yy):
  37. //
  38. //                        06/30/96    ca        Public release of version 1.2
  39. //                        06/04/96    ca        Added static RegisterClass for easier class registration
  40. //                                                        Increased version to 1.2
  41. //                        06/01/96    ms        Changes brought by Marco Sandri <msandri@mbox.vol.it>
  42. //                                                        Changes made to avoid icon "flicker" during pressing
  43. //                        05/15/96    ca        Increased version to 1.1
  44. //                                                        Added change history
  45. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  46. //                                                        (version 1.0)
  47. //
  48. //        To Do:
  49. //
  50.  
  51. #include "LAGAStateIconButton.h"
  52.  
  53. //    begin    <06/04/96    ca>
  54. void LAGAStateIconButton::RegisterClass ()
  55.  
  56. {
  57.     URegistrar::RegisterClass(LAGAStateIconButton::class_ID, (ClassCreatorFunc)LAGAStateIconButton::CreateAGAStateIconButtonStream);
  58. }
  59. //    end    <06/04/96    ca>
  60.  
  61. LAGAStateIconButton* LAGAStateIconButton::CreateAGAStateIconButtonStream (LStream *inStream)
  62.  
  63. {
  64.     return(new LAGAStateIconButton(inStream));
  65. }
  66.  
  67. //-------Constructors-------------------------------------------------------------------------------------------------
  68.  
  69. LAGAStateIconButton::LAGAStateIconButton ()
  70.  
  71. {
  72.     mState = 0;
  73.     mIconID2 = mIconID3 = resID_Undefined;
  74. }
  75.  
  76. LAGAStateIconButton::LAGAStateIconButton (LStream    *inStream) : LAGAIconButton(inStream)
  77.  
  78. {
  79.     mState = 0;
  80.     inStream->ReadData(&mIconID2, sizeof(ResIDT));
  81.     inStream->ReadData(&mIconID3, sizeof(ResIDT));
  82. }
  83.  
  84. //    begin <0515/96    ca>
  85. LAGAStateIconButton::LAGAStateIconButton (const LAGAStateIconButton &inOriginal) : LAGAIconButton(inOriginal)
  86.  
  87. {
  88.     mState = 0;
  89.     mIconID2 = inOriginal.mIconID2;
  90.     mIconID3 = inOriginal.mIconID3;
  91. }
  92.  
  93. LAGAStateIconButton::LAGAStateIconButton (const SPaneInfo &inPaneInfo, MessageT inClickedMessage, OSType inIconType,
  94.                                                                                     ResIDT inIconState1, ResIDT inIconState2, ResIDT inIconState3,
  95.                                                                                     Boolean inRadioButtonBehavior)
  96.                                                                                 : LAGAIconButton(inPaneInfo, inClickedMessage, inIconType, inIconState1,
  97.                                                                                                                     inRadioButtonBehavior)
  98. {
  99.     mState = 0;
  100.     mIconID2 = inIconState2;
  101.     mIconID3 = inIconState3;
  102. }
  103. //    end <0515/96    ca>
  104.  
  105. LAGAStateIconButton::~LAGAStateIconButton ()
  106.  
  107. {
  108. }
  109.  
  110. //-------Drawers----------------------------------------------------------------------------------------------------
  111.  
  112. short LAGAStateIconButton::GetIconID ()
  113.  
  114. {
  115.     short outIconID;
  116.     
  117.     switch(mState)
  118.         {
  119.             case 0    :
  120.                         outIconID = mIconID;
  121.                         break;
  122.             case 1    :
  123.                         outIconID = mIconID2;
  124.                         break;
  125.             case 2    :
  126.                         outIconID = mIconID3;
  127.                         break;
  128.             dafault    :
  129.                         outIconID = resID_Undefined;
  130.                         break;
  131.         }
  132.         
  133.     return(outIconID);
  134. }
  135.  
  136. void LAGAStateIconButton::SetState (Int32 inValue)
  137.  
  138. {
  139.     if ((inValue != mState) && (inValue < 3))
  140.         {
  141.             mState = inValue;
  142.             if (mIcon != nil)
  143.                 {
  144.                     DisposeCIcon(mIcon);
  145.                     mIcon = nil;
  146.                 }
  147.             Draw(nil);                                                                                                                                                                            //    <06/01/96    ms>
  148.         }
  149. }
  150.  
  151.  
  152.