Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
sources/TSetupPane.cp
// TSetupPane.cp - AppleShare IP Dialog Pane Object |
// |
// Apple Macintosh Developer Technical Support |
// Written by: Vinnie Moscaritolo |
// |
// Copyright (work in progress) Apple Computer, Inc All rights reserved. |
// |
// You may incorporate this sample code into your applications without |
// restriction, though the sample code has been provided "AS IS" and the |
// responsibility for its operation is 100% yours. However, what you are |
// not permitted to do is to redistribute the source as "DSC Sample Code" |
// after having made changes. If you're going to re-distribute the source, |
// we require that you make it clear in the source that the code was |
// descended from Apple Sample Code, but that you've made changes. |
// |
#include <Appearance.h> |
#include "TSetupPane.h" |
#include "PassphraseCache.h" |
#include "PGPUAMclientLoginDialog.h" |
static enum{ |
kSetupPaneDITL = 141, |
}; |
enum |
{ |
kCachePassPhase = 1, |
kCacheTimeLimit, |
kTxt1Min, |
kTxt2Min, |
kTxt3Min, |
kTxtAlways, |
kBorder2, |
kAuthServer, |
kOption1, |
kOption2 |
}; |
#define kSetupStringsID 141 |
static enum { |
k1MinStrID =1, |
k30MinStrID , |
k60MinStrID , |
kAlwaysStrID |
}; |
// --------------------------------------------------------------------------- |
TSetupPane::TSetupPane( DialogPtr dialog, SInt16 items, TPGPUAMPrefs* prefs ) |
: TPane (dialog, items) |
// --------------------------------------------------------------------------- |
// |
{ |
ControlFontStyleRec fontInfo; |
Str255 text; |
fPrefs = prefs; |
AppendDialogItemList(dialog, kSetupPaneDITL, overlayDITL ); |
// box |
fontInfo.flags = kControlUseFontMask; |
fontInfo.font = kControlFontSmallBoldSystemFont; |
GetDialogItemAsControl( dialog, items + kCachePassPhase, &fCachePassPhrase ); |
SetControlValue(fCachePassPhrase, fPrefs->GetCachePassPhrase()); |
SetControlData( fCachePassPhrase, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
GetDialogItemAsControl( dialog, items + kAuthServer, &fAuthServer ); |
SetControlValue(fAuthServer, fPrefs->GetAuthenticateServer()); |
SetControlData( fAuthServer, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
GetDialogItemAsControl( dialog, items + kOption1, &fOption1 ); |
SetControlValue(fOption1, fPrefs->GetOption1()); |
SetControlData( fOption1, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
GetDialogItemAsControl( dialog, items + kOption2, &fOption2 ); |
SetControlValue(fOption2, fPrefs->GetOption2()); |
SetControlData( fOption2, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
// tick strings |
fontInfo.flags = kControlUseFontMask | kControlUseJustMask; |
fontInfo.font = kControlFontSmallSystemFont; |
fontInfo.just = teJustRight; |
GetIndString(text, kSetupStringsID,kAlwaysStrID); |
GetDialogItemAsControl( dialog, items + kTxtAlways, &fTickLast ); |
SetControlData( fTickLast, 0, kControlStaticTextTextTag, text[0], (Ptr)(text+1)); |
SetControlData( fTickLast, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
fontInfo.just = teJustCenter; |
GetIndString(text, kSetupStringsID,k60MinStrID); |
GetDialogItemAsControl( dialog, items + kTxt3Min, &fTick3 ); |
SetControlData( fTick3, 0, kControlStaticTextTextTag, text[0], (Ptr)(text+1)); |
SetControlData( fTick3, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
GetIndString(text, kSetupStringsID,k30MinStrID); |
GetDialogItemAsControl( dialog, items + kTxt2Min, &fTick2 ); |
SetControlData( fTick2, 0, kControlStaticTextTextTag, text[0], (Ptr)(text+1)); |
SetControlData( fTick2, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
fontInfo.just = teJustLeft; |
GetIndString(text, kSetupStringsID,k1MinStrID); |
GetDialogItemAsControl( dialog, items + kTxt1Min, &fTick1 ); |
SetControlData( fTick1, 0, kControlStaticTextTextTag, text[0], (Ptr)(text+1)); |
SetControlData( fTick1, 0, kControlStaticTextStyleTag, sizeof fontInfo, (Ptr)&fontInfo); |
// slider |
GetDialogItemAsControl( dialog, items + kCacheTimeLimit, &fCacheTimeLimit ); |
SetControlMinimum(fCacheTimeLimit, 1); |
SetControlMaximum(fCacheTimeLimit, 90); |
SetControlValue(fCacheTimeLimit, fPrefs->GetCachePassPhraseTimeLimit()); |
if (fPrefs->GetCachePassPhrase()) |
{ |
ActivateControl(fCacheTimeLimit); |
ActivateControl(fTick1); |
ActivateControl(fTick2); |
ActivateControl(fTick3); |
ActivateControl(fTickLast); |
} |
else |
{ |
DeactivateControl(fCacheTimeLimit); |
DeactivateControl(fTick1); |
DeactivateControl(fTick2); |
DeactivateControl(fTick3); |
DeactivateControl(fTickLast); |
} |
// deactivate till we know what to do with them |
DeactivateControl(fOption1); |
DeactivateControl(fOption2); |
ShowControl(fCachePassPhrase); |
} |
// --------------------------------------------------------------------------- |
TSetupPane::~TSetupPane() |
// --------------------------------------------------------------------------- |
// |
{ |
ShortenDITL( fDialog, CountDITL(fDialog) - fOrigItems); |
} |
// --------------------------------------------------------------------------- |
void TSetupPane::Refresh(void) |
// --------------------------------------------------------------------------- |
// |
{ |
} |
// --------------------------------------------------------------------------- |
void TSetupPane::Idle(void) |
// --------------------------------------------------------------------------- |
// |
{ |
} |
// --------------------------------------------------------------------------- |
void TSetupPane::ItemHit(SInt16 item) |
// --------------------------------------------------------------------------- |
// |
{ |
SInt16 localItem; |
Boolean enable; |
localItem = item - fOrigItems; |
switch ( localItem ) |
{ |
case kCachePassPhase: |
enable = (GetControlValue(fCachePassPhrase) == 0) ; |
SetControlValue(fCachePassPhrase, enable); |
fPrefs->SetCachePassPhrase(enable); |
EnablePassphraseCaching(enable); |
if (enable) |
{ |
ActivateControl(fCacheTimeLimit); |
ActivateControl(fTick1); |
ActivateControl(fTick2); |
ActivateControl(fTick3); |
ActivateControl(fTickLast); |
SetPassphraseCacheTimeLimit( GetControlValue(fCacheTimeLimit) ); |
} |
else |
{ |
DeactivateControl(fCacheTimeLimit); |
DeactivateControl(fTick1); |
DeactivateControl(fTick2); |
DeactivateControl(fTick3); |
DeactivateControl(fTickLast); |
SetPassphraseCacheTimeLimit( 0 ); |
} |
break; |
case kCacheTimeLimit: |
if( GetControlValue(fCacheTimeLimit) != fPrefs->GetCachePassPhraseTimeLimit() ) |
{ |
fPrefs->SetCachePassPhraseTimeLimit(GetControlValue(fCacheTimeLimit)); |
SetPassphraseCacheTimeLimit( GetControlValue(fCacheTimeLimit) ); |
} |
break; |
case kAuthServer: |
enable = (GetControlValue(fAuthServer) == 0) ; |
SetControlValue(fAuthServer, enable); |
fPrefs->SetAuthenticateServer(enable); |
break; |
case kOption1: |
enable = (GetControlValue(fOption1) == 0) ; |
SetControlValue(fOption1, enable); |
fPrefs->SetOption1(enable); |
break; |
case kOption2: |
enable = (GetControlValue(fOption1) == 0) ; |
SetControlValue(fOption1, enable); |
fPrefs->SetOption2(enable); |
break; |
} |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-07-22