This is FirstPanelController.m in view mode; [Download] [Up]
//*****************************************************************************
//
// FirstPanelController.h.
//
// Preferences logic.
//
// by Felipe A. Rodriguez
//
// This code is supplied "as is" the author makes no warranty as to its
// suitability for any purpose. This code is free and may be distributed
// in accordance with the terms of the:
//
// GNU GENERAL PUBLIC LICENSE
// Version 2, June 1991
// copyright (C) 1989, 1991 Free Software Foundation, Inc.
// 675 Mass Ave, Cambridge, MA 02139, USA
//
//*****************************************************************************
#import "FirstPanelController.h"
#import "../Coordinator.h"
#import "../GKdefs.h"
#define FMOD (S_IREAD | S_IWRITE) // read, write by owner
typedef unsigned short mode_t;
// preferences controls
char *sList[] = {"autoHide", "autoUnhide", "DispPPP", AITIMER, DOD, NULL};
@implementation FirstPanelController
//*****************************************************************************
//
// sent to us after nib objects are unarchived and init'd
//
//*****************************************************************************
- awakeFromNib
{
int i = 0;
// default switches
do { // if set in ddb turn check switch on
if(strcmp(NXGetDefaultValue([NXApp appName], sList[i]), "YES") == 0)
[[swMatrix findCellWithTag:i] setIntValue:1];
}
while(sList[++i]);
return self;
}
//*****************************************************************************
//
// returns the inspector panel we control
//
//*****************************************************************************
- inspectorPanel
{
return [swMatrix window];
}
//*****************************************************************************
//
// Target method of defaults db entries for our preferences
// check switches based on the tag assigned in IB to each switch.
//
//*****************************************************************************
- switch:sender
{
int tag = [sender selectedTag];
// toggles entries YES/NO
if(strcmp(NXGetDefaultValue([NXApp appName], sList[tag]),"NO") == 0)
{ // sw set ON
if(!NXWriteDefault([NXApp appName], sList[tag], "YES"))
[[NXApp delegate] showAlert:"ddbWriteError"];
else
{
if(tag == 3) // app icon time enabled
[[NXApp delegate] setAppIconTimer:YES];
}
}
else // sw set OFF
{
if(!NXWriteDefault([NXApp appName], sList[tag], "NO"))
[[NXApp delegate] showAlert:"ddbWriteError"];
else
{
if(tag == 3) // app icon time disabled
[[NXApp delegate] setAppIconTimer:NO];
}
}
return self;
}
//*********************** text field matrix delegation ************************
//*****************************************************************************
//
// as text delegate we recieve this when textfield cell is being edited
//
//*****************************************************************************
- (BOOL)textWillChange:textObject
{
[[swMatrix window] setDocEdited:YES]; // indicate change
// is not saved
return NO;
}
//*****************************************************************************
//
// text delegate receives when editing of textfield cell is ended
//
//*****************************************************************************
- textDidEnd:textObject endChar:(unsigned short)whyEnd
{
if ((whyEnd == 16) || (whyEnd == 17)) // indicate change
[[swMatrix window] setDocEdited:NO]; // is saved
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.