ftp.nice.ch/pub/next/developer/resources/palettesfor2.xx/RDRGridViewPalette.0.1.s.tar.gz#/RDRGridViewPalette/RDRGridViewInspector.m

This is RDRGridViewInspector.m in view mode; [Download] [Up]

/* -------------------------------------------------------------------
	Objective-C source file for the class RDRGridViewInspector

        Author: Chris Walters, RDR, Inc.

        You may freely copy, distribute and reuse
	the code in this example.  I disclaim any warranty
	of any kind, expressed or implied, as to 
	its fitness for any particular use.


                         RDRGridViewInspector                         

	1. Introduction

	The inspector for the RDRGridView class.  The inspector contains
	a "sample" so that changes can be "reviewed" before they take
	effect on the real selected object.  This is of dubious
	value, but I was just playing around to see what I could
	do.

------------------------------------------------------------------- */

/* ------------------------- Import files ------------------------- */


/* ------------------------  Classes used  ------------------------ */
#import <appkit/Cell.h>
#import <appkit/NXColorWell.h>
#import "RDRGridView.h"
/* -------------------------  Externals  -------------------------- */


/* --------------------------  Defines  --------------------------- */


/* ----------------------  Class variables  ----------------------- */


/*====================================================================
             Implementation of class RDRGridViewInspector             
====================================================================*/
#import "RDRGridViewInspector.h"
/*
#import <nib/InterfaceBuilder.h>
#import <appkit/Application.h>
*/
@implementation RDRGridViewInspector : Inspector
{
    id gridEnabledToggle;
    id fgColorWell;
    id bgColorWell;
    id horizSpacingSlider;
    id horizSpacingField;
    id vertSpacingSlider;
    id vertSpacingField;
    id horizLineWidthField;
    id horizLineWidthSlider;
    id vertLineWidthField;
    id vertLineWidthSlider;
    id practiceGrid;
}

/*====================================================================
                 Palette Protocol (required methods)                  
====================================================================*/
/*--------------------------------------------------------------------
|+finishLoading:(struct mach_header *)hdr| 

--------------------------------------------------------------------*/
+finishLoading:(struct mach_header *)hdr
{
    NIBDidLoadClass(self, hdr);
    return nil;
}

/*--------------------------------------------------------------------
|+startUnloading| 

--------------------------------------------------------------------*/
+startUnloading
{
    NIBWillUnloadClass(self);
    return nil;
}


/*--------------------------------------------------------------------
|-init| 
Return self.
--------------------------------------------------------------------*/
-init
{
    [super init];
    [NXApp loadNibSection:"RDRGridViewInspector.nib" owner:self];
    return self;
}

/*--------------------------------------------------------------------
|-ok:sender| 
Return self.
--------------------------------------------------------------------*/
-ok:sender
{
    [object setEnabled:[gridEnabledToggle intValue]];
    [object setGridForegroundColor:[fgColorWell color]];
    [object setGridBackgroundColor:[bgColorWell color]];
    [object setHorizontalWidth:[horizLineWidthSlider floatValue]];
    [object setVerticalWidth:[vertLineWidthSlider floatValue]];
    [object setHorizontalSpacing:[horizSpacingSlider intValue]];
    [object setVerticalSpacing:[vertSpacingSlider intValue]];
    [object display];
    return[super ok:sender];
}

/*--------------------------------------------------------------------
|-revert:sender| 
Return self.
--------------------------------------------------------------------*/
-revert:sender
{
    [practiceGrid setEnabled:[object isEnabled]];
    [practiceGrid setGridForegroundColor:[object foregroundColor]];
    [practiceGrid setGridBackgroundColor:[object backgroundColor]];
    [practiceGrid setHorizontalWidth:[object horizontalWidth]];
    [practiceGrid setVerticalWidth:[object verticalWidth]];
    [practiceGrid setHorizontalSpacing:[object horizontalSpacing]];
    [practiceGrid setVerticalSpacing:[object verticalSpacing]];
    [practiceGrid display];

    [gridEnabledToggle setIntValue:[object isEnabled]];
    [fgColorWell setColor:[object foregroundColor]];
    [bgColorWell setColor:[object backgroundColor]];
    [horizLineWidthSlider setFloatValue:[object horizontalWidth]];
    [vertLineWidthSlider setFloatValue:[object verticalWidth]];
    [horizSpacingSlider setIntValue:[object horizontalSpacing]];
    [vertSpacingSlider setIntValue:[object verticalSpacing]];
    [horizLineWidthField setFloatValue:[object horizontalWidth]];
    [vertLineWidthField setFloatValue:[object verticalWidth]];
    [horizSpacingField setIntValue:[object horizontalSpacing]];
    [vertSpacingField setIntValue:[object verticalSpacing]];

    return[super revert:sender];
}

/*====================================================================
             setting/accessing attributes of RDRGridView              
====================================================================*/
/*--------------------------------------------------------------------
|-toggleEnabled:sender| 
Return self.
--------------------------------------------------------------------*/
-toggleEnabled:sender
{
    [[practiceGrid setEnabled:[sender intValue]] display];
    return self;
}

/*--------------------------------------------------------------------
|-setBackgroundColor:sender| 
Return self.
--------------------------------------------------------------------*/
-setBackgroundColor:sender
{
    [[practiceGrid setGridBackgroundColor:[sender color]] display];
    return self;
}

/*--------------------------------------------------------------------
|-setForegroundColor:sender| 
Return self.
--------------------------------------------------------------------*/
-setForegroundColor:sender
{
    [[practiceGrid setGridForegroundColor:[sender color]] display];
    return self;
}

/*--------------------------------------------------------------------
|-setHorizontalLineSpacing:sender| 
Return self.
--------------------------------------------------------------------*/
-setHorizontalLineSpacing:sender
{
    [[practiceGrid setHorizontalSpacing:[sender intValue]] display];
    switch ([sender tag]) {
    case 0:			/* textfield */
	[horizSpacingSlider setIntValue:[sender intValue]];
	break;
    case 1:			/* slider */
	[horizSpacingField setIntValue:[sender intValue]];
	break;
    default:
	break;
    }
    return self;
}

/*--------------------------------------------------------------------
|-setVerticalLineSpacing:sender| 
Return self.
--------------------------------------------------------------------*/
-setVerticalLineSpacing:sender
{
    [[practiceGrid setVerticalSpacing:[sender intValue]] display];
    switch ([sender tag]) {
    case 0:			/* text field */
	[vertSpacingSlider setIntValue:[sender intValue]];
	break;
    case 1:			/* slider */
	[vertSpacingField setIntValue:[sender intValue]];
	break;
    default:
	break;
    }
    return self;

}

/*--------------------------------------------------------------------
|-setHorizontalLineWidth:sender| 
Return self.
--------------------------------------------------------------------*/
-setHorizontalLineWidth:sender
{
    [[practiceGrid setHorizontalWidth:[sender floatValue]] display];
    switch ([sender tag]) {
    case 0:			/* text field */
	[horizLineWidthSlider setIntValue:[sender intValue]];
	break;
    case 1:			/* slider */
	[horizLineWidthField setIntValue:[sender intValue]];
	break;
    default:
	break;
    }
    return self;
}

/*--------------------------------------------------------------------
|-setVerticalLineWidth:sender| 
Return self.
--------------------------------------------------------------------*/
-setVerticalLineWidth:sender
{
    [[practiceGrid setVerticalWidth:[sender floatValue]] display];
    switch ([sender tag]) {
    case 0:			/* text field */
	[vertLineWidthSlider setIntValue:[sender intValue]];
	break;
    case 1:			/* slider */
	[vertLineWidthField setIntValue:[sender intValue]];
	break;
    default:
	break;
    }
    return self;
}


@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.