ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Frameworks/MiscAppKit/MiscArrowButton.subproj/MiscArrowButton.m

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

/*
   MiscArrowButton.m

   This object is included in the MiscKit by permission from the author
   and its use is governed by the MiscKit license, found in the file
   "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
   for a list of all applicable permissions and restrictions.
*/

#import <AppKit/AppKit.h>

#import "MiscArrowButtonCell.h"
#import "MiscArrowButton.h"

static Class _myStoredCellClass = nil;

 
@implementation MiscArrowButton

/*"
   MiscArrowButton is a recreation of a button from Websters.app 
   (in Preferences). We are basically just a control that displays a 
   MiscArrowButtonCell instance. 
   
   To get a feel for the arrow button and see what the arrow alignment
   settings do, just load up it's palette in IB and try it out. For more
   information also check out the documentation for MiscArrowButtonCell
   where most of the work is done.
"*/


+ (void) initialize
/*"
   Class initializer. Sets our cell class to be MiscArrowButtonCell.
   We don't set our class version because we don't have any instance
   variables.
"*/
{
	if (self == [MiscArrowButton class]) {
		[self setCellClass:[MiscArrowButtonCell class]];
	}
}


+ (Class) cellClass
/*"
	Returns the class of the cell we'll use. It is probably a good idea
	to use a subclass of MiscArrowButtonCell (or the class itself which
	is the default).
"*/
{
	return _myStoredCellClass;
}


+ (void) setCellClass:(Class)classId
/*"
   Sets the cell class that we use. For best results it should be a subclass
   of MiscArrowButtonCell (the default).
"*/
{
	_myStoredCellClass = classId;
}


- (id) initWithFrame:(NSRect)frameRect
/*"
   Our designated initializer. Sets our left title to "Left" and our right
   title to (yes you guessed it) "Right". Returns self if successful and
   nil if not.
"*/
{
    BOOL error = ([super initWithFrame:frameRect] == nil);

    if (!error) {
        Class cellClass = [[self class] cellClass];
        [self setTitle:@"Left"];
        [self setAlternateTitle:@"Right"];
        [self setButtonType:NSToggleButton];
        [self setCell:[[[cellClass alloc] init] autorelease]];
    }

    return error ? nil : self;
}


- (MiscArrowAlignment) arrowAlignment
/*"
   Returns either MiscArrowAlignmentRelative or MiscArrowAlignmentAbsolute.
   See #setArrowAlignment: for more information.
"*/
{
    return [[self cell] arrowAlignment];
}


- (void) setArrowAlignment:(MiscArrowAlignment)alignment
/*"
   Sets our arrow's alignment to be centered either relative to the
   title and alternate title (MiscArrowAlignmentRelative) or absolute
   (MiscArrowAligmentAbsolute). The absolute setting sets the arrow
   to be in the center of the cell regardless of the title and
   alternate title.
"*/
{
	[[self cell] setArrowAlignment:alignment];
}

@end

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