1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSPopUpButton.m
|
|
|
|
|
|
|
|
Popup list class
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
1999-06-17 21:07:38 +00:00
|
|
|
Author: Michael Hanni <mhanni@sprintmail.com>
|
|
|
|
Date: June 1999
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
1999-06-30 03:10:38 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSPopUpButton.h>
|
1999-06-19 00:31:39 +00:00
|
|
|
#include <AppKit/NSPopUpButtonCell.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
1998-01-30 00:34:25 +00:00
|
|
|
#include <AppKit/NSMenu.h>
|
1999-07-18 03:53:42 +00:00
|
|
|
#include <AppKit/NSMenuView.h>
|
1999-06-20 10:13:34 +00:00
|
|
|
#include <AppKit/NSFont.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// NSPopUpButton implementation
|
|
|
|
//
|
1999-07-18 03:53:42 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@implementation NSPopUpButton
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSPopUpButton class])
|
|
|
|
{
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initializing an NSPopUpButton
|
|
|
|
//
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
return [self initWithFrame:NSZeroRect pullsDown:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithFrame:(NSRect)frameRect
|
|
|
|
{
|
|
|
|
return [self initWithFrame:frameRect pullsDown:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithFrame:(NSRect)frameRect
|
|
|
|
pullsDown:(BOOL)flag
|
|
|
|
{
|
|
|
|
[super initWithFrame:frameRect];
|
1999-07-18 03:53:42 +00:00
|
|
|
list_items = [NSMutableArray new];
|
|
|
|
|
|
|
|
popb_view = [[NSMenuView alloc] initWithFrame:frameRect
|
|
|
|
cellSize: NSMakeSize (frameRect.size.width,
|
|
|
|
frameRect.size.height)];
|
|
|
|
[popb_view setPopUpButton: self];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
is_up = NO;
|
|
|
|
pulls_down = flag;
|
1999-06-19 11:44:32 +00:00
|
|
|
selected_item = 0;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-07-28 10:50:30 +00:00
|
|
|
[super setTarget: self];
|
|
|
|
|
|
|
|
popb_win = [[NSMenuWindow alloc] initWithContentRect: frameRect
|
|
|
|
styleMask: NSBorderlessWindowMask
|
|
|
|
backing: NSBackingStoreRetained
|
|
|
|
defer: NO];
|
|
|
|
|
|
|
|
[popb_win setContentView: popb_view];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1999-07-28 10:50:30 +00:00
|
|
|
- (void) close
|
|
|
|
{
|
|
|
|
[popb_win orderOut: self];
|
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) dealloc
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
[list_items release];
|
1996-05-30 20:03:15 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Target and Action
|
|
|
|
//
|
|
|
|
- (SEL)action
|
|
|
|
{
|
|
|
|
return pub_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAction:(SEL)aSelector
|
|
|
|
{
|
|
|
|
pub_action = aSelector;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)target
|
|
|
|
{
|
|
|
|
return pub_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setTarget:(id)anObject
|
|
|
|
{
|
|
|
|
pub_target = anObject;
|
|
|
|
}
|
|
|
|
|
1999-06-20 10:13:34 +00:00
|
|
|
- (void)buttonSelected:(id)sender
|
|
|
|
{
|
1999-06-21 04:38:35 +00:00
|
|
|
if (!pulls_down)
|
|
|
|
selected_item = [self indexOfItemWithTitle:[sender title]];
|
|
|
|
else
|
|
|
|
selected_item = 0;
|
1999-06-20 10:13:34 +00:00
|
|
|
|
|
|
|
[self synchronizeTitleAndSelectedItem];
|
|
|
|
|
1999-07-18 03:53:42 +00:00
|
|
|
[self close];
|
|
|
|
|
|
|
|
[self lockFocus];
|
1999-06-20 10:13:34 +00:00
|
|
|
[self drawRect:[self frame]];
|
1999-07-18 03:53:42 +00:00
|
|
|
[self unlockFocus];
|
1999-06-20 10:13:34 +00:00
|
|
|
[self setNeedsDisplay:YES];
|
|
|
|
|
|
|
|
if (pub_target && pub_action)
|
|
|
|
[pub_target performSelector:pub_action withObject:self];
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Adding Items
|
|
|
|
//
|
|
|
|
- (void)addItemWithTitle:(NSString *)title
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
[self insertItemWithTitle:title atIndex:[list_items count]];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)addItemsWithTitles:(NSArray *)itemTitles
|
1998-01-30 00:34:25 +00:00
|
|
|
{
|
|
|
|
int i, count = [itemTitles count];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[self addItemWithTitle:[itemTitles objectAtIndex:i]];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)insertItemWithTitle:(NSString *)title
|
|
|
|
atIndex:(unsigned int)index
|
1998-01-30 00:34:25 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
id menuCell = [[NSPopUpButtonCell new] autorelease];
|
|
|
|
|
|
|
|
[menuCell setFont: [NSFont systemFontOfSize:12]];
|
|
|
|
[menuCell setTitle: title];
|
|
|
|
[menuCell setTarget: self];
|
|
|
|
[menuCell setAction: @selector(buttonSelected:)];
|
1999-07-26 07:02:26 +00:00
|
|
|
[menuCell setEnabled:YES];
|
|
|
|
|
1999-07-18 03:53:42 +00:00
|
|
|
[list_items insertObject: menuCell atIndex: index];
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
[self synchronizeTitleAndSelectedItem];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Removing Items
|
|
|
|
//
|
|
|
|
- (void)removeAllItems
|
1998-01-30 00:34:25 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
[list_items removeAllObjects];
|
1998-01-30 00:34:25 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)removeItemWithTitle:(NSString *)title
|
1998-01-30 00:34:25 +00:00
|
|
|
{
|
|
|
|
int index = [self indexOfItemWithTitle:title];
|
|
|
|
|
|
|
|
if (index != NSNotFound)
|
1999-07-18 03:53:42 +00:00
|
|
|
[list_items removeObjectAtIndex:index];
|
1998-01-30 00:34:25 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)removeItemAtIndex:(int)index
|
1998-01-30 00:34:25 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
[list_items removeObjectAtIndex:index];
|
1998-01-30 00:34:25 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Querying the NSPopUpButton about Its Items
|
|
|
|
//
|
|
|
|
- (int)indexOfItemWithTitle:(NSString *)title
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
int i, count = [list_items count];
|
1998-01-30 00:34:25 +00:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
1999-07-18 03:53:42 +00:00
|
|
|
if ([[[list_items objectAtIndex:i] title] isEqual:title])
|
1998-01-30 00:34:25 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return NSNotFound;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int)indexOfSelectedItem
|
|
|
|
{
|
|
|
|
return selected_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)numberOfItems
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
return [list_items count];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
- (id <NSMenuItem>)itemAtIndex:(int)index
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
return [list_items objectAtIndex:index];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
- (NSArray *)itemArray
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
return list_items;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)itemTitleAtIndex:(int)index
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
return [[list_items objectAtIndex:index] title];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)itemTitles
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
int i, count = [list_items count];
|
1998-01-30 00:34:25 +00:00
|
|
|
NSMutableArray* titles = [NSMutableArray arrayWithCapacity:count];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
1999-07-18 03:53:42 +00:00
|
|
|
[titles addObject:[[list_items objectAtIndex:i] title]];
|
1998-01-30 00:34:25 +00:00
|
|
|
|
|
|
|
return titles;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
- (id <NSMenuItem>)itemWithTitle:(NSString *)title
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-01-30 00:34:25 +00:00
|
|
|
int index = [self indexOfItemWithTitle:title];
|
|
|
|
|
|
|
|
if (index != NSNotFound)
|
1999-07-18 03:53:42 +00:00
|
|
|
return [list_items objectAtIndex:index];
|
1996-05-30 20:03:15 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
- (id <NSMenuItem>)lastItem
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
if ([list_items count])
|
|
|
|
return [list_items lastObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
- (id <NSMenuItem>)selectedItem
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
return [list_items objectAtIndex:selected_item];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)titleOfSelectedItem
|
|
|
|
{
|
1998-01-30 00:34:25 +00:00
|
|
|
return [[self selectedItem] title];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Manipulating the NSPopUpButton
|
|
|
|
//
|
|
|
|
- (NSFont *)font
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)pullsDown
|
|
|
|
{
|
|
|
|
return pulls_down;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)selectItemAtIndex:(int)index
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
if ((index >= 0) && (index < [list_items count]))
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
selected_item = index;
|
|
|
|
[self synchronizeTitleAndSelectedItem];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)selectItemWithTitle:(NSString *)title
|
1998-01-30 00:34:25 +00:00
|
|
|
{
|
|
|
|
int index = [self indexOfItemWithTitle:title];
|
|
|
|
|
|
|
|
if (index != NSNotFound)
|
|
|
|
[self selectItemAtIndex:index];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setFont:(NSFont *)fontObject
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)setPullsDown:(BOOL)flag
|
|
|
|
{
|
|
|
|
pulls_down = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setTitle:(NSString *)aString
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (NSString *)stringValue
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)synchronizeTitleAndSelectedItem
|
|
|
|
{
|
1999-07-18 03:53:42 +00:00
|
|
|
// if (!pulls_down)
|
|
|
|
// [list_items setIndexOfSelectedItem:selected_item];
|
|
|
|
// else
|
|
|
|
// [list_items setIndexOfSelectedItem:0];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Displaying the NSPopUpButton's Items
|
|
|
|
//
|
|
|
|
- (BOOL)autoenablesItems
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAutoenablesItems:(BOOL)flag
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Handle events
|
|
|
|
//
|
|
|
|
- (void)mouseDown:(NSEvent *)theEvent
|
|
|
|
{
|
1999-07-26 07:02:26 +00:00
|
|
|
NSNotificationCenter *nc;
|
1999-07-28 10:50:30 +00:00
|
|
|
NSPoint cP;
|
|
|
|
NSRect butf;
|
|
|
|
NSRect winf;
|
1999-07-26 07:02:26 +00:00
|
|
|
|
|
|
|
nc = [NSNotificationCenter defaultCenter];
|
|
|
|
[nc postNotificationName: NSPopUpButtonWillPopUpNotification
|
|
|
|
object: self
|
|
|
|
userInfo: nil];
|
1999-07-28 10:50:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get frame of this button in window coordinates,
|
|
|
|
* and origin in screen coordinates.
|
|
|
|
*/
|
|
|
|
butf = [self frame];
|
|
|
|
butf = [[self superview] convertRect: butf toView: nil];
|
|
|
|
butf.origin = [[self window] convertBaseToScreen: butf.origin];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine frame size for a popup window capable of containing the
|
|
|
|
* menu view.
|
|
|
|
*/
|
|
|
|
[popb_view sizeToFitForPopUpButton];
|
|
|
|
[popb_view setFrameOrigin: NSMakePoint(0,0)];
|
|
|
|
winf = [NSMenuWindow frameRectForContentRect: [popb_view frame]
|
|
|
|
styleMask: [popb_win styleMask]];
|
|
|
|
/*
|
|
|
|
* Set popup window frame origin so that the top-left corner of the
|
|
|
|
* window lines up with the top-left corner of this button.
|
|
|
|
*/
|
|
|
|
winf.origin = butf.origin;
|
|
|
|
winf.origin.y += butf.size.height - winf.size.height;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Small hack to fix line up.
|
|
|
|
*/
|
|
|
|
|
|
|
|
winf.origin.x += 1;
|
|
|
|
winf.origin.y -= 1;
|
|
|
|
|
|
|
|
//NSLog(@"butf %@", NSStringFromRect(butf));
|
|
|
|
//NSLog(@"winf %@", NSStringFromRect(winf));
|
|
|
|
|
|
|
|
if (pulls_down == NO)
|
|
|
|
{
|
|
|
|
winf.origin.y += (selected_item * butf.size.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
[popb_win setFrame: winf display: YES];
|
|
|
|
[popb_win orderFrontRegardless];
|
|
|
|
[popb_win display];
|
|
|
|
|
|
|
|
cP = [theEvent locationInWindow];
|
|
|
|
cP = [[self window] convertBaseToScreen: cP];
|
|
|
|
cP = [popb_win convertScreenToBase: cP];
|
|
|
|
|
|
|
|
[popb_view mouseDown:
|
|
|
|
[NSEvent mouseEventWithType: NSLeftMouseDragged
|
|
|
|
location: cP
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
timestamp: [theEvent timestamp]
|
|
|
|
windowNumber: [popb_win windowNumber]
|
|
|
|
context: [theEvent context]
|
|
|
|
eventNumber: [theEvent eventNumber]
|
|
|
|
clickCount: [theEvent clickCount]
|
|
|
|
pressure: [theEvent pressure]]];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseUp:(NSEvent *)theEvent
|
|
|
|
{
|
1999-07-28 10:50:30 +00:00
|
|
|
NSPoint cP;
|
|
|
|
|
|
|
|
cP = [[self window] convertBaseToScreen: [theEvent locationInWindow]];
|
|
|
|
cP = [popb_win convertScreenToBase: cP];
|
|
|
|
|
|
|
|
//NSLog(@"location x = %d, y = %d\n", (int)cP.x, (int)cP.y);
|
|
|
|
|
|
|
|
[popb_view mouseUp:
|
|
|
|
[NSEvent mouseEventWithType: NSLeftMouseUp
|
|
|
|
location: cP
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
timestamp: [theEvent timestamp]
|
|
|
|
windowNumber: [popb_win windowNumber]
|
|
|
|
context: [theEvent context]
|
|
|
|
eventNumber: [theEvent eventNumber]
|
|
|
|
clickCount: [theEvent clickCount]
|
|
|
|
pressure: [theEvent pressure]]];
|
|
|
|
|
|
|
|
[popb_win orderOut: nil];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseMoved:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)hitTest:(NSPoint)aPoint
|
|
|
|
{
|
|
|
|
// First check ourselves
|
1999-06-17 21:07:38 +00:00
|
|
|
// if ([self mouse:aPoint inRect:bounds]) return self;
|
|
|
|
if ([self mouse:aPoint inRect:[self frame]]) return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Displaying
|
|
|
|
//
|
|
|
|
- (void)drawRect:(NSRect)rect
|
|
|
|
{
|
1999-06-19 00:31:39 +00:00
|
|
|
id aCell;
|
1999-06-17 21:07:38 +00:00
|
|
|
|
1999-07-18 03:53:42 +00:00
|
|
|
if ([list_items count] == 0)
|
1999-07-15 17:32:38 +00:00
|
|
|
return;
|
|
|
|
|
1999-06-19 00:31:39 +00:00
|
|
|
if (!pulls_down)
|
1999-07-18 03:53:42 +00:00
|
|
|
aCell = [list_items objectAtIndex:selected_item];
|
1999-06-19 00:31:39 +00:00
|
|
|
else
|
1999-07-18 03:53:42 +00:00
|
|
|
aCell = [list_items objectAtIndex:0];
|
1999-06-17 21:07:38 +00:00
|
|
|
|
1999-06-19 00:31:39 +00:00
|
|
|
[aCell drawWithFrame:rect inView:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// NSCoding protocol
|
|
|
|
//
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
[super encodeWithCoder: aCoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
[aCoder encodeObject: list_items];
|
|
|
|
[aCoder encodeRect: list_rect];
|
1999-03-02 08:58:30 +00:00
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &selected_item];
|
|
|
|
[aCoder encodeConditionalObject: pub_target];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeValueOfObjCType: @encode(SEL) at: &pub_action];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_up];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &pulls_down];
|
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
[super initWithCoder: aDecoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &list_items];
|
1996-05-30 20:03:15 +00:00
|
|
|
list_rect = [aDecoder decodeRect];
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &selected_item];
|
1997-02-18 00:29:25 +00:00
|
|
|
pub_target = [aDecoder decodeObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &pub_action];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_up];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &pulls_down];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|