1999-04-01 06:19:37 +00:00
|
|
|
/*
|
1996-05-30 20:03:15 +00:00
|
|
|
NSControl.m
|
|
|
|
|
|
|
|
The abstract control class
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
1998-11-25 17:16:48 +00:00
|
|
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
|
|
|
Date: August 1998
|
1999-04-01 06:19:37 +00:00
|
|
|
|
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.
|
1999-04-01 06:19:37 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
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.
|
1999-04-01 06:19:37 +00:00
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
1998-11-25 17:16:48 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
#include <Foundation/NSException.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSControl.h>
|
1999-04-01 06:19:37 +00:00
|
|
|
#include <AppKit/NSColor.h>
|
1998-11-25 17:16:48 +00:00
|
|
|
#include <AppKit/NSEvent.h>
|
|
|
|
#include <AppKit/NSWindow.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
#include <AppKit/NSCell.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Class variables
|
|
|
|
//
|
* NSWindow.m renmae captureMouse: to _captureMouse: (designate as non OS),
various methods add fieldEditor support.
* GSContext.m/GSContext.h revert to previous code as solution discussed
with Adam Fedor regarding backends had problems I had not forseen.
* NSBrowserCell.h/.m specify text subcell as an NSCell, eliminate image
cell, copyWithZone: optimize and eliminate use of ASSIGN (fixes serious
dealloc bug), highlight: eliminate method (fixes dup display bug).
* NSButtonCell.m copyWithZone: optimize and eliminate use of ASSIGN
* NSStringDrawing.h/.m remove unimplemented draw methods from Category
(these are backend specific, can't be defined twice and are already
implemented in xraw).
* NSApplication.h redefine initialize_gnustep_backend () per Adam's
redefinition in the backend.
* Functions.m/.h remove initialize_gnustep_backend()
* NSCell.m preliminary implementation of fieldEditor mechanism,
copyWithZone: optimize and eliminate use of ASSIGN
* NSControl.m rename cell class global to _NSCONTROL_CELL_CLASS
* NSMatrix.m implement NSControl's updateCell: to prevent unecessary
matrix drawing if possible.
* NSView.m -resizeWithOldSuperviewSize reverted code to my own once more
(fewer lines and no if/else logic), changed code to use view frame instead
of bounds per 3.3/4.2 docs, optimize to avoid floating point math and scale
adjustment unless view has been scaled.
* NSScrollView.m define as externs various PS* functions for use in
drawing, polish drawing, move all backend code to front.
* Tools/dummy.m define dummy PS* functions employed in gui.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3454 72102866-910b-0410-8b05-ffd578937521
1998-12-14 09:54:38 +00:00
|
|
|
static id _NSCONTROL_CELL_CLASS = nil;
|
|
|
|
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSControl
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (self == [NSControl class])
|
|
|
|
{
|
|
|
|
NSDebugLog(@"Initialize NSControl class\n");
|
|
|
|
[self setVersion: 1];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Setting the Control's Cell
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
+ (Class) cellClass
|
|
|
|
{
|
|
|
|
return _NSCONTROL_CELL_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) setCellClass: (Class)factoryId
|
|
|
|
{
|
|
|
|
_NSCONTROL_CELL_CLASS = factoryId;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (id) initWithFrame: (NSRect)frameRect
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[super initWithFrame: frameRect];
|
|
|
|
if (_NSCONTROL_CELL_CLASS)
|
|
|
|
[self setCell: [[_NSCONTROL_CELL_CLASS new] autorelease]];
|
|
|
|
else
|
|
|
|
[self setCell: [[NSCell new] autorelease]];
|
|
|
|
tag = 0;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) dealloc
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[cell release];
|
|
|
|
[super dealloc];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-01-30 15:41:50 +00:00
|
|
|
//
|
|
|
|
// Creating copies
|
|
|
|
//
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
1997-01-30 15:41:50 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
id c = NSCopyObject(self, 0, zone);
|
|
|
|
NSCell *o = [cell copy];
|
* NSWindow.m renmae captureMouse: to _captureMouse: (designate as non OS),
various methods add fieldEditor support.
* GSContext.m/GSContext.h revert to previous code as solution discussed
with Adam Fedor regarding backends had problems I had not forseen.
* NSBrowserCell.h/.m specify text subcell as an NSCell, eliminate image
cell, copyWithZone: optimize and eliminate use of ASSIGN (fixes serious
dealloc bug), highlight: eliminate method (fixes dup display bug).
* NSButtonCell.m copyWithZone: optimize and eliminate use of ASSIGN
* NSStringDrawing.h/.m remove unimplemented draw methods from Category
(these are backend specific, can't be defined twice and are already
implemented in xraw).
* NSApplication.h redefine initialize_gnustep_backend () per Adam's
redefinition in the backend.
* Functions.m/.h remove initialize_gnustep_backend()
* NSCell.m preliminary implementation of fieldEditor mechanism,
copyWithZone: optimize and eliminate use of ASSIGN
* NSControl.m rename cell class global to _NSCONTROL_CELL_CLASS
* NSMatrix.m implement NSControl's updateCell: to prevent unecessary
matrix drawing if possible.
* NSView.m -resizeWithOldSuperviewSize reverted code to my own once more
(fewer lines and no if/else logic), changed code to use view frame instead
of bounds per 3.3/4.2 docs, optimize to avoid floating point math and scale
adjustment unless view has been scaled.
* NSScrollView.m define as externs various PS* functions for use in
drawing, polish drawing, move all backend code to front.
* Tools/dummy.m define dummy PS* functions employed in gui.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3454 72102866-910b-0410-8b05-ffd578937521
1998-12-14 09:54:38 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
[c setCell: o];
|
|
|
|
[o release];
|
|
|
|
return c;
|
1997-01-30 15:41:50 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Setting the Control's Cell
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (id) cell
|
|
|
|
{
|
|
|
|
return cell;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setCell: (NSCell *)aCell
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (![aCell isKindOfClass: [NSCell class]])
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"attempt to set silly value for control cell"];
|
|
|
|
|
|
|
|
[cell setControlView: nil];
|
|
|
|
[aCell setControlView: self];
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
[aCell retain];
|
|
|
|
[cell release];
|
|
|
|
cell = aCell;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Enabling and Disabling the Control
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (BOOL) isEnabled
|
|
|
|
{
|
|
|
|
return [[self selectedCell] isEnabled];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setEnabled: (BOOL)flag
|
|
|
|
{
|
|
|
|
[[self selectedCell] setEnabled: flag];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Identifying the Selected Cell
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (id) selectedCell
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if ([cell state])
|
|
|
|
return cell;
|
|
|
|
else
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (int) selectedTag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return [[self selectedCell] tag];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Setting the Control's Value
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (double) doubleValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return [[self selectedCell] doubleValue];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (float) floatValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return [[self selectedCell] floatValue];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (int) intValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return [[self selectedCell] intValue];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setDoubleValue: (double)aDouble
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] setDoubleValue: aDouble];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setFloatValue: (float)aFloat
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] setFloatValue: aFloat];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setIntValue: (int)anInt
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] setIntValue: anInt];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setNeedsDisplay
|
|
|
|
{
|
|
|
|
[super setNeedsDisplay: YES];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setStringValue: (NSString *)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] setStringValue: aString];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (NSString *) stringValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return [[self selectedCell] stringValue];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Interacting with Other Controls
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) takeDoubleValueFrom: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] takeDoubleValueFrom: sender];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) takeFloatValueFrom: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] takeFloatValueFrom: sender];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) takeIntValueFrom: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] takeIntValueFrom: sender];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) takeStringValueFrom: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
[[self selectedCell] takeStringValueFrom: sender];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Formatting Text
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (NSTextAlignment) alignment
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (cell)
|
|
|
|
return [cell alignment];
|
|
|
|
else
|
|
|
|
return NSLeftTextAlignment;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (NSFont *) font
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (cell)
|
|
|
|
return [cell font];
|
|
|
|
else
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setAlignment: (NSTextAlignment)mode
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (cell)
|
|
|
|
{
|
|
|
|
[cell setAlignment: mode];
|
|
|
|
[self setNeedsDisplay: YES];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setFont: (NSFont *)fontObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (cell)
|
|
|
|
[cell setFont: fontObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setFloatingPointFormat: (BOOL)autoRange
|
|
|
|
left: (unsigned)leftDigits
|
|
|
|
right: (unsigned)rightDigits
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Managing the Field Editor
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (BOOL) abortEditing
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSText *) currentEditor
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) validateEditing
|
|
|
|
{
|
|
|
|
} // FIX ME
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Resizing the Control
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) calcSize
|
|
|
|
{
|
|
|
|
} // FIX ME
|
|
|
|
|
|
|
|
- (void) sizeToFit
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Displaying the Control and Cell
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) drawCell: (NSCell *)aCell
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (cell == aCell)
|
|
|
|
{
|
|
|
|
[cell drawWithFrame: bounds inView: self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) drawCellInside: (NSCell *)aCell
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
if (cell == aCell)
|
|
|
|
{
|
|
|
|
[cell drawInteriorWithFrame: bounds inView: self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) selectCell: (NSCell *)aCell
|
|
|
|
{
|
|
|
|
if (cell == aCell)
|
|
|
|
[cell setState: 1];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) updateCell: (NSCell *)aCell
|
|
|
|
{
|
|
|
|
[self setNeedsDisplay: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) updateCellInside: (NSCell *)aCell
|
|
|
|
{
|
|
|
|
[self setNeedsDisplay: YES];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
// Target and Action
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (SEL) action
|
|
|
|
{
|
|
|
|
return [cell action];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (BOOL) isContinuous
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return [cell isContinuous];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (BOOL) sendAction: (SEL)theAction to: (id)theTarget
|
|
|
|
{
|
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
|
|
|
|
if (theAction && theTarget)
|
|
|
|
return [theApp sendAction: theAction to: theTarget from: self];
|
|
|
|
else
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-01-19 10:55:24 +00:00
|
|
|
- (int) sendActionOn: (int)mask
|
|
|
|
{
|
|
|
|
return [cell sendActionOn: mask];
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) setAction: (SEL)aSelector
|
|
|
|
{
|
|
|
|
[cell setAction: aSelector];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setContinuous: (BOOL)flag
|
|
|
|
{
|
|
|
|
[cell setContinuous: flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setTarget: (id)anObject
|
|
|
|
{
|
|
|
|
[cell setTarget: anObject];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) target
|
|
|
|
{
|
|
|
|
return [cell target];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Assigning a Tag
|
|
|
|
//
|
|
|
|
- (void) setTag: (int)anInt
|
|
|
|
{
|
|
|
|
tag = anInt;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) tag
|
|
|
|
{
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Tracking the Mouse
|
|
|
|
//
|
|
|
|
- (void) mouseDown: (NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
NSApplication *theApp = [NSApplication sharedApplication];
|
|
|
|
BOOL mouseUp = NO, done = NO;
|
|
|
|
NSEvent *e;
|
|
|
|
int oldActionMask;
|
|
|
|
NSPoint location;
|
|
|
|
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
|
|
|
NSMouseMovedMask | NSLeftMouseDraggedMask |
|
|
|
|
NSRightMouseDraggedMask;
|
|
|
|
|
|
|
|
NSDebugLog(@"NSControl mouseDown\n");
|
|
|
|
|
|
|
|
if (![self isEnabled])
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ([cell isContinuous])
|
|
|
|
oldActionMask = [cell sendActionOn: 0];
|
|
|
|
else
|
|
|
|
oldActionMask = [cell sendActionOn: NSPeriodicMask];
|
|
|
|
|
|
|
|
[window _captureMouse: self];
|
|
|
|
|
|
|
|
[self lockFocus];
|
|
|
|
|
|
|
|
e = theEvent;
|
|
|
|
while (!done) // loop until mouse goes up
|
|
|
|
{
|
|
|
|
location = [e locationInWindow];
|
|
|
|
location = [self convertPoint: location fromView: nil];
|
|
|
|
// ask the cell to track the mouse only
|
|
|
|
// if the mouse is within the cell
|
|
|
|
if ((location.x >= 0) && (location.x < bounds.size.width) &&
|
|
|
|
(location.y >= 0 && location.y < bounds.size.height))
|
|
|
|
{
|
|
|
|
[cell highlight: YES withFrame: bounds inView: self];
|
|
|
|
[window flushWindow];
|
|
|
|
if ([cell trackMouse: e
|
|
|
|
inRect: bounds
|
|
|
|
ofView: self
|
|
|
|
untilMouseUp: YES])
|
|
|
|
done = mouseUp = YES;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[cell highlight: NO withFrame: bounds inView: self];
|
|
|
|
[window flushWindow];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
break;
|
|
|
|
|
|
|
|
NSDebugLog(@"NSControl process another event\n");
|
|
|
|
e = [theApp nextEventMatchingMask: event_mask
|
|
|
|
untilDate: nil
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
dequeue: YES];
|
|
|
|
if ([e type] == NSLeftMouseUp)
|
|
|
|
done = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
[window _releaseMouse: self];
|
|
|
|
|
|
|
|
if (mouseUp)
|
|
|
|
{
|
|
|
|
[self lockFocus];
|
|
|
|
// [cell setState: ![cell state]];
|
|
|
|
[cell highlight: NO withFrame: bounds inView: self];
|
|
|
|
[window flushWindow];
|
|
|
|
}
|
|
|
|
[self unlockFocus];
|
|
|
|
[cell sendActionOn: oldActionMask];
|
|
|
|
|
|
|
|
if (mouseUp)
|
|
|
|
[self sendAction: [self action] to: [self target]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) ignoresMultiClick
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setIgnoresMultiClick: (BOOL)flag
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Methods Implemented by the Delegate
|
|
|
|
//
|
1999-04-01 06:19:37 +00:00
|
|
|
- (BOOL) control: (NSControl *)control
|
|
|
|
textShouldBeginEditing: (NSText *)fieldEditor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (BOOL) control: (NSControl *)control
|
|
|
|
textShouldEndEditing: (NSText *)fieldEditor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:19:37 +00:00
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) controlTextDidBeginEditing: (NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) controlTextDidEndEditing: (NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:19:37 +00:00
|
|
|
- (void) controlTextDidChange: (NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
}
|
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];
|
1999-04-01 06:19:37 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &tag];
|
|
|
|
[aCoder encodeObject: cell];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
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];
|
1999-04-01 06:19:37 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &tag];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &cell];
|
|
|
|
|
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|