home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Appearance SDK 1.0.4 / Appearance Sample Code / Source / LayoutPane.cp < prev    next >
Encoding:
Text File  |  1999-07-16  |  2.3 KB  |  99 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        LayoutPane.cp
  3.  
  4.     Contains:    Class to drive our layout pane, demonstrating group boxes.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (edv)    Ed Voas
  21.  
  22.     Change History (most recent first):
  23.  
  24.          <2>    10/28/97    edv        Use RadioGroup control!
  25.          <1>     9/11/97    edv        First checked in.
  26. */
  27.  
  28. #include "LayoutPane.h"
  29. #include "Appearance.h"
  30. #include "AppearanceHelpers.h"
  31. #include "UDialogUtils.h"
  32.  
  33. enum
  34. {
  35.     kPrimaryGroup        = 1,
  36.     kUserPane            = 2,
  37.     kSecondaryGroup        = 3,
  38.     kSeparator            = 4,
  39.     kRadioGroup            = 5,
  40.     kLevel1Radio        = 6,
  41.     kLevel2Radio        = 7,
  42.     kLevel3Radio        = 8,
  43.     kUseMilliCheck        = 9,
  44.     kFullCheck            = 10
  45. };
  46.  
  47. LayoutPane::LayoutPane( DialogPtr dialog, SInt16 items ) : MegaPane( dialog, items )
  48. {
  49.     ControlHandle    control;
  50.     
  51.     AppendDialogItemList( dialog, 6005, overlayDITL );
  52.     
  53.     UDialogUtils::SetDialogItemValue( dialog, fOrigItems + kPrimaryGroup, 1 );
  54.     
  55.     GetDialogItemAsControl( dialog, fOrigItems + kLevel1Radio, &control );
  56.     SetControlMaximum( control, 2 );
  57.     GetDialogItemAsControl( dialog, fOrigItems + kLevel2Radio, &control );
  58.     SetControlMaximum( control, 2 );
  59.     GetDialogItemAsControl( dialog, fOrigItems + kLevel3Radio, &control );
  60.     SetControlMaximum( control, 2 );
  61.     UDialogUtils::SetDialogItemValue( dialog, fOrigItems + kRadioGroup, 2 );
  62.     UDialogUtils::SetDialogItemValue( dialog, fOrigItems + kLevel3Radio, 1 );
  63.     UDialogUtils::SetDialogItemValue( dialog, fOrigItems + kLevel1Radio, 2 );
  64.     UDialogUtils::SetDialogItemValue( dialog, fOrigItems + kLevel1Radio, 0 );
  65.     UDialogUtils::SetDialogItemValue( dialog, fOrigItems + kLevel2Radio, 1 );
  66. }
  67.  
  68. LayoutPane::~LayoutPane()
  69. {
  70.     ShortenDITL( fDialog, CountDITL( fDialog ) - fOrigItems );
  71. }
  72.  
  73. void
  74. LayoutPane::ItemHit( SInt16 item )
  75. {
  76.     SInt16            localItem;
  77.     ControlHandle    control;
  78.     
  79.     localItem = item - fOrigItems;
  80.     
  81.     switch( localItem )
  82.     {
  83.         case kPrimaryGroup:
  84.             UDialogUtils::ToggleCheckBox( fDialog, item );
  85.             GetDialogItemAsControl( fDialog, fOrigItems + kUserPane, &control );
  86.             if ( UDialogUtils::GetDialogItemValue( fDialog, item ) == 1 )
  87.                 ActivateControl( control );
  88.             else
  89.                 DeactivateControl( control );
  90.             break;
  91.         
  92.         case kUseMilliCheck:
  93.         case kFullCheck:
  94.             UDialogUtils::ToggleCheckBox( fDialog, item );
  95.             break;
  96.             
  97.     }
  98. }
  99.