mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:00:47 +00:00
* NSApplication.h added windows_need_update as autodisplay ivar.
* NSApplication.m in init set default for main_menu, windows_need_update. * NSApplication.m in run added support for OPENSTEP autodisplay mechanism. * NSApplication.m _eventMatchingMask: reformat. * NSApplication.m nextEventMatchingMask:untilDate:inMode:dequeue: move calls to _flushWindows to XDPS backend. * NSApplication.m implemented updateWindows. * NSApplication.m implemented setWindowsNeedUpdate:. * NSApplication.m setMainMenu: test for menu prior to release. * NSActionCell.m removed setState: method. * NSActionCell.m copyWithZone: optimized ivar copying. * NSButtonCell.m added _init and moved common defaults to this method. * NSButtonCell.m initImageCell: and initTextCell: minor optimizations. * NSButtonCell.m setAlternateTitle: optimize and use ASSIGN macro. * NSButtonCell.m setKeyEquivalent: remove [copy release]. * NSButtonCell.m setKeyEquivalentFont:size: optimize. * NSButtonCell.m copyWithZone: optimized ivar copying where possible. * NSCell.m _init removed call to [super init]. * NSCell.m initTextCell: removed duplicate default initializers. * NSCell.m setImage: rewrote to use ASSIGN macro. * NSCell.m setDoubleValue: rewrote to use ASSIGN macro. * NSCell.m setFloatValue: rewrote to use ASSIGN macro. * NSCell.m setIntValue: rewrote to use ASSIGN macro. * NSCell.m setStringValue: rewrote to use ASSIGN macro. * NSCell.m setFont: rewrote to use ASSIGN macro. * NSCell.m setRepresentedObject: rewrote to use ASSIGN macro. * NSCell.m copyWithZone: optimized ivar copying where possible. * NSClipView.m viewBoundsChanged: minor optimization. * NSClipView.m viewFrameChanged: minor optimization. * NSClipView.m scaleUnitSquareToSize: minor optimization. * NSClipView.m setBoundsOrigin: minor optimization. * NSClipView.m setBoundsSize: minor optimization. * NSClipView.m setFrameSize: minor optimization. * NSClipView.m setFrameOrigin: minor optimization. * NSClipView.m setFrame: minor optimization. * NSClipView.m translateOriginToPoint: minor optimization. * NSMatrix.m eliminate retain/release of selected cell via ASSIGN. * NSMatrix.m initWithFrame: remove duplicate setting of selected row and column. * NSMatrix.m removeColumn: rewrite so that col is removed before new selection is attempted (needed because selected cell is not retained). * NSMatrix.m removeRow: rewrite so that row is removed before new selection is attempted (needed because selected cell is not retained). * NSMatrix.m deselectAllCells per OS spec try to select a cell at end if empty selection is not allowed. * NSMatrix.m deselectSelectedCell set default selected row/col to 0. * NSMatrix.m mouseDown: optimize for new drawing behaviour. * NSMenu.m setSelectedCell: eliminate use of retain/release of selected cell via ASSIGN. * NSMenuItem.m copyWithZone: optimized ivar copying where possible. * NSMenuItem.m dealloc minor optimization. * NSMenuItem.m setTarget: minor optimization. * NSScroller.m trackScrollButtons: heavily optimized. * NSScroller.m sendAction: reimplemented to use sendAction: per spec also optimized. * NSText.m implemented init method. * NSText.m initWithFrame: fixed initialization of ivars which are released to retain. * NSText.m dealloc add release of retained ivars. * NSView.m dealloc add release of retained ivars. * NSView.m displayRect: and _addSubviewForNeedingDisplay reformatted code and rewrote comments. * NSWindow.m setFrame:display: rewrote for clarity. * NSWindow.m implemented update method per OPENSTEP spec. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2941 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ada8279bee
commit
48b8e5aa73
14 changed files with 628 additions and 528 deletions
67
ChangeLog
67
ChangeLog
|
@ -1,3 +1,70 @@
|
||||||
|
Sun Aug 30 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
|
|
||||||
|
* NSApplication.h added windows_need_update as autodisplay ivar.
|
||||||
|
* NSApplication.m in init set default for main_menu, windows_need_update.
|
||||||
|
* NSApplication.m in run added support for OPENSTEP autodisplay mechanism.
|
||||||
|
* NSApplication.m _eventMatchingMask: reformat.
|
||||||
|
* NSApplication.m nextEventMatchingMask:untilDate:inMode:dequeue:
|
||||||
|
move calls to _flushWindows to XDPS backend.
|
||||||
|
* NSApplication.m implemented updateWindows.
|
||||||
|
* NSApplication.m implemented setWindowsNeedUpdate:.
|
||||||
|
* NSApplication.m setMainMenu: test for menu prior to release.
|
||||||
|
* NSActionCell.m removed setState: method.
|
||||||
|
* NSActionCell.m copyWithZone: optimized ivar copying.
|
||||||
|
* NSButtonCell.m added _init and moved common defaults to this method.
|
||||||
|
* NSButtonCell.m initImageCell: and initTextCell: minor optimizations.
|
||||||
|
* NSButtonCell.m setAlternateTitle: optimize and use ASSIGN macro.
|
||||||
|
* NSButtonCell.m setKeyEquivalent: remove [copy release].
|
||||||
|
* NSButtonCell.m setKeyEquivalentFont:size: optimize.
|
||||||
|
* NSButtonCell.m copyWithZone: optimized ivar copying where possible.
|
||||||
|
* NSCell.m _init removed call to [super init].
|
||||||
|
* NSCell.m initTextCell: removed duplicate default initializers.
|
||||||
|
* NSCell.m setImage: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m setDoubleValue: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m setFloatValue: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m setIntValue: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m setStringValue: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m setFont: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m setRepresentedObject: rewrote to use ASSIGN macro.
|
||||||
|
* NSCell.m copyWithZone: optimized ivar copying where possible.
|
||||||
|
* NSClipView.m viewBoundsChanged: minor optimization.
|
||||||
|
* NSClipView.m viewFrameChanged: minor optimization.
|
||||||
|
* NSClipView.m scaleUnitSquareToSize: minor optimization.
|
||||||
|
* NSClipView.m setBoundsOrigin: minor optimization.
|
||||||
|
* NSClipView.m setBoundsSize: minor optimization.
|
||||||
|
* NSClipView.m setFrameSize: minor optimization.
|
||||||
|
* NSClipView.m setFrameOrigin: minor optimization.
|
||||||
|
* NSClipView.m setFrame: minor optimization.
|
||||||
|
* NSClipView.m translateOriginToPoint: minor optimization.
|
||||||
|
* NSMatrix.m eliminate retain/release of selected cell via ASSIGN.
|
||||||
|
* NSMatrix.m initWithFrame: remove duplicate setting of selected row and
|
||||||
|
column.
|
||||||
|
* NSMatrix.m removeColumn: rewrite so that col is removed before new
|
||||||
|
selection is attempted (needed because selected cell is not retained).
|
||||||
|
* NSMatrix.m removeRow: rewrite so that row is removed before new
|
||||||
|
selection is attempted (needed because selected cell is not retained).
|
||||||
|
* NSMatrix.m deselectAllCells per OS spec try to select a cell at end
|
||||||
|
if empty selection is not allowed.
|
||||||
|
* NSMatrix.m deselectSelectedCell set default selected row/col to 0.
|
||||||
|
* NSMatrix.m mouseDown: optimize for new drawing behaviour.
|
||||||
|
* NSMenu.m setSelectedCell: eliminate use of retain/release of selected
|
||||||
|
cell via ASSIGN.
|
||||||
|
* NSMenuItem.m copyWithZone: optimized ivar copying where possible.
|
||||||
|
* NSMenuItem.m dealloc minor optimization.
|
||||||
|
* NSMenuItem.m setTarget: minor optimization.
|
||||||
|
* NSScroller.m trackScrollButtons: heavily optimized.
|
||||||
|
* NSScroller.m sendAction: reimplemented to use sendAction: per spec also
|
||||||
|
optimized.
|
||||||
|
* NSText.m implemented init method.
|
||||||
|
* NSText.m initWithFrame: fixed initialization of ivars which are released
|
||||||
|
to retain.
|
||||||
|
* NSText.m dealloc add release of retained ivars.
|
||||||
|
* NSView.m dealloc add release of retained ivars.
|
||||||
|
* NSView.m displayRect: and _addSubviewForNeedingDisplay reformatted code
|
||||||
|
and rewrote comments.
|
||||||
|
* NSWindow.m setFrame:display: rewrote for clarity.
|
||||||
|
* NSWindow.m implemented update method per OPENSTEP spec.
|
||||||
|
|
||||||
Thurs Aug 20 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
Thurs Aug 20 1998 Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
|
|
||||||
* NSTextView.m commented out references to defaultTypingAttributes
|
* NSTextView.m commented out references to defaultTypingAttributes
|
||||||
|
|
|
@ -75,6 +75,7 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
BOOL app_should_quit;
|
BOOL app_should_quit;
|
||||||
BOOL app_is_active;
|
BOOL app_is_active;
|
||||||
BOOL app_is_hidden;
|
BOOL app_is_hidden;
|
||||||
|
BOOL windows_need_update;
|
||||||
NSImage *app_icon;
|
NSImage *app_icon;
|
||||||
|
|
||||||
// Reserved for back-end use
|
// Reserved for back-end use
|
||||||
|
|
|
@ -138,17 +138,6 @@
|
||||||
[(NSControl *)control_view updateCell: self];
|
[(NSControl *)control_view updateCell: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Setting the NSCell's State
|
|
||||||
//
|
|
||||||
- (void)setState:(int)value
|
|
||||||
{
|
|
||||||
[super setState: value];
|
|
||||||
if (control_view)
|
|
||||||
if ([control_view isKindOfClass: [NSControl class]])
|
|
||||||
[(NSControl *)control_view updateCell: self];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Manipulating NSActionCell Values
|
// Manipulating NSActionCell Values
|
||||||
//
|
//
|
||||||
|
@ -225,9 +214,9 @@
|
||||||
{
|
{
|
||||||
NSActionCell* c = [super copyWithZone:zone];
|
NSActionCell* c = [super copyWithZone:zone];
|
||||||
|
|
||||||
[c setTag:tag];
|
c->tag = tag;
|
||||||
[c setTarget:target];
|
c->target = target;
|
||||||
[c setAction:action];
|
c->action = action;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
|
Date: August 1998
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
|
@ -116,6 +118,8 @@ static id NSApp;
|
||||||
window_list = [NSMutableArray new];
|
window_list = [NSMutableArray new];
|
||||||
window_count = 1;
|
window_count = 1;
|
||||||
|
|
||||||
|
main_menu = nil;
|
||||||
|
windows_need_update = YES;
|
||||||
//
|
//
|
||||||
// Event handling setup
|
// Event handling setup
|
||||||
//
|
//
|
||||||
|
@ -222,36 +226,36 @@ static id NSApp;
|
||||||
|
|
||||||
- (void)run
|
- (void)run
|
||||||
{
|
{
|
||||||
NSEvent *e;
|
NSEvent *e;
|
||||||
NSAutoreleasePool* pool;
|
NSAutoreleasePool* pool;
|
||||||
|
|
||||||
NSDebugLog(@"NSApplication -run\n");
|
NSDebugLog(@"NSApplication -run\n");
|
||||||
|
|
||||||
[self finishLaunching];
|
[self finishLaunching];
|
||||||
|
|
||||||
app_should_quit = NO;
|
app_should_quit = NO;
|
||||||
app_is_running = YES;
|
app_is_running = YES;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
pool = [NSAutoreleasePool new];
|
||||||
pool = [NSAutoreleasePool new];
|
|
||||||
|
|
||||||
e = [self nextEventMatchingMask:NSAnyEventMask
|
e = [self nextEventMatchingMask:NSAnyEventMask
|
||||||
untilDate:[NSDate distantFuture]
|
untilDate:[NSDate distantFuture]
|
||||||
inMode:NSDefaultRunLoopMode dequeue:YES];
|
inMode:NSDefaultRunLoopMode
|
||||||
if (e)
|
dequeue:YES];
|
||||||
[self sendEvent: e];
|
if (e)
|
||||||
else
|
[self sendEvent: e];
|
||||||
{
|
else // if Null event call back
|
||||||
// Null event
|
[self handleNullEvent]; // end method to handle it
|
||||||
// Call the back-end method to handle it
|
|
||||||
[self handleNullEvent];
|
|
||||||
}
|
|
||||||
[pool release];
|
|
||||||
} while (!app_should_quit);
|
|
||||||
app_is_running = YES;
|
|
||||||
|
|
||||||
NSDebugLog(@"NSApplication end of run loop\n");
|
if(windows_need_update) // send an update message
|
||||||
|
[self updateWindows]; // to all visible windows
|
||||||
|
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
while (!app_should_quit);
|
||||||
|
|
||||||
|
NSDebugLog(@"NSApplication end of run loop\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)runModalForWindow:(NSWindow *)theWindow
|
- (int)runModalForWindow:(NSWindow *)theWindow
|
||||||
|
@ -410,98 +414,90 @@ static id NSApp;
|
||||||
|
|
||||||
- (NSEvent*)_eventMatchingMask:(unsigned int)mask
|
- (NSEvent*)_eventMatchingMask:(unsigned int)mask
|
||||||
{
|
{
|
||||||
NSEvent* event;
|
NSEvent* event;
|
||||||
int i, count = [event_queue count];
|
int i, count = [event_queue count];
|
||||||
|
|
||||||
[self getNextEvent];
|
[self getNextEvent];
|
||||||
|
|
||||||
/* Get an event from the events queue */
|
if ((count = [event_queue count])) // Get an event from
|
||||||
if ((count = [event_queue count])) {
|
{ // the events queue
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++)
|
||||||
event = [event_queue objectAtIndex:i];
|
{
|
||||||
if ([self event:event matchMask:mask]) {
|
event = [event_queue objectAtIndex:i];
|
||||||
[event retain];
|
if ([self event:event matchMask:mask])
|
||||||
[event_queue removeObjectAtIndex:i];
|
{
|
||||||
[self setCurrentEvent:event];
|
[event retain];
|
||||||
return [event autorelease];
|
[event_queue removeObjectAtIndex:i];
|
||||||
}
|
[self setCurrentEvent:event];
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
return [event autorelease];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
||||||
untilDate:(NSDate *)expiration
|
untilDate:(NSDate *)expiration
|
||||||
inMode:(NSString *)mode
|
inMode:(NSString *)mode
|
||||||
dequeue:(BOOL)flag
|
dequeue:(BOOL)flag
|
||||||
{
|
{
|
||||||
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
||||||
NSEventType type;
|
NSEventType type;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
BOOL done = NO;
|
BOOL done = NO;
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
event = [self _eventMatchingMask:mask];
|
||||||
if (event)
|
if (event)
|
||||||
done = YES;
|
done = YES;
|
||||||
else if (!expiration)
|
else if (!expiration)
|
||||||
expiration = [NSDate distantFuture];
|
expiration = [NSDate distantFuture];
|
||||||
|
|
||||||
|
while (!done) // Not in queue so wait
|
||||||
|
{ // for next event
|
||||||
|
NSDate *limitDate, *originalLimitDate;
|
||||||
|
// Retain the limitDate so it doesn't get
|
||||||
|
// release accidentally by runMode:beforeDate:
|
||||||
|
// if a timer which has this date as fire date
|
||||||
|
// gets released.
|
||||||
|
limitDate = [[currentLoop limitDateForMode:mode] retain];
|
||||||
|
originalLimitDate = limitDate;
|
||||||
|
|
||||||
// Not in queue so wait for next event
|
event = [self _eventMatchingMask:mask];
|
||||||
while (!done) {
|
if (event)
|
||||||
NSDate *limitDate, *originalLimitDate;
|
{
|
||||||
|
[limitDate release];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// flush any windows that need it
|
if (limitDate)
|
||||||
[NSWindow _flushWindows];
|
limitDate = [expiration earlierDate:limitDate];
|
||||||
[self _flushCommunicationChannels];
|
else
|
||||||
|
limitDate = expiration;
|
||||||
|
|
||||||
/* Retain the limitDate so it doesn't get release accidentally by
|
[currentLoop runMode:mode beforeDate:limitDate];
|
||||||
runMode:beforeDate: if a timer which has this date as fire date gets
|
[originalLimitDate release];
|
||||||
released. */
|
|
||||||
limitDate = [[currentLoop limitDateForMode:mode] retain];
|
|
||||||
originalLimitDate = limitDate;
|
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
event = [self _eventMatchingMask:mask];
|
||||||
if (event) {
|
if (event)
|
||||||
[limitDate release];
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (limitDate)
|
type = [event type];
|
||||||
limitDate = [expiration earlierDate:limitDate];
|
// Unhide the cursor if necessary
|
||||||
else
|
if (event != gnustep_gui_null_event) // and event is not a null event
|
||||||
limitDate = expiration;
|
{ // do so only if we should
|
||||||
|
if ([NSCursor isHiddenUntilMouseMoves]) // unhide when mouse moves
|
||||||
|
{ // and event is mouse event
|
||||||
|
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
||||||
|
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
||||||
|
|| (type == NSMouseMoved))
|
||||||
|
[NSCursor unhide];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[currentLoop runMode:mode beforeDate:limitDate];
|
return event;
|
||||||
[originalLimitDate release];
|
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
|
||||||
if (event)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// flush any windows that need it
|
|
||||||
[NSWindow _flushWindows];
|
|
||||||
[self _flushCommunicationChannels];
|
|
||||||
|
|
||||||
type = [event type];
|
|
||||||
|
|
||||||
// Unhide the cursor if necessary
|
|
||||||
// but only if its not a null event
|
|
||||||
if (event != gnustep_gui_null_event)
|
|
||||||
{
|
|
||||||
// Only if we should unhide when mouse moves
|
|
||||||
if ([NSCursor isHiddenUntilMouseMoves])
|
|
||||||
{
|
|
||||||
// Make sure the event is a mouse event before unhiding
|
|
||||||
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
|
||||||
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|
||||||
|| (type == NSMouseMoved))
|
|
||||||
[NSCursor unhide];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return event;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
|
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
|
||||||
|
@ -712,23 +708,25 @@ static id NSApp;
|
||||||
|
|
||||||
- (void)setWindowsNeedUpdate:(BOOL)flag
|
- (void)setWindowsNeedUpdate:(BOOL)flag
|
||||||
{
|
{
|
||||||
|
windows_need_update = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateWindows
|
- (void)updateWindows // send an update message to
|
||||||
{
|
{ // all visible windows
|
||||||
int i, count;
|
int i, count;
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
// notify that we will update
|
// notify that we will update
|
||||||
[nc postNotificationName: NSApplicationWillUpdateNotification
|
[nc postNotificationName:NSApplicationWillUpdateNotification object:self];
|
||||||
object: self];
|
|
||||||
|
|
||||||
for (i = 0, count = [window_list count]; i < count; i++)
|
for (i = 0, count = [window_list count]; i < count; i++)
|
||||||
[[window_list objectAtIndex:i] update];
|
{
|
||||||
|
NSWindow *win = [window_list objectAtIndex:i];
|
||||||
// notify that we did update
|
if([win isVisible]) // send update only if
|
||||||
[nc postNotificationName: NSApplicationDidUpdateNotification
|
[win update]; // window is visible
|
||||||
object: self];
|
}
|
||||||
|
// notify that we did update
|
||||||
|
[nc postNotificationName:NSApplicationDidUpdateNotification object:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)windows
|
- (NSArray *)windows
|
||||||
|
@ -785,7 +783,8 @@ static id NSApp;
|
||||||
|
|
||||||
// Release old and retain new
|
// Release old and retain new
|
||||||
[aMenu retain];
|
[aMenu retain];
|
||||||
[main_menu release];
|
if(main_menu)
|
||||||
|
[main_menu release];
|
||||||
main_menu = aMenu;
|
main_menu = aMenu;
|
||||||
|
|
||||||
// Search for a menucell with the name Windows
|
// Search for a menucell with the name Windows
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Ovidiu Predescu <ovidiu@net-community.com>
|
Ovidiu Predescu <ovidiu@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
|
Date: August 1998
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -40,10 +42,9 @@
|
||||||
#include <AppKit/NSFont.h>
|
#include <AppKit/NSFont.h>
|
||||||
#include <AppKit/NSImage.h>
|
#include <AppKit/NSImage.h>
|
||||||
|
|
||||||
#define ASSIGN(a, b) \
|
#define ASSIGN(a, b) [b retain]; \
|
||||||
[b retain]; \
|
[a release]; \
|
||||||
[a release]; \
|
a = b;
|
||||||
a = b;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// NSButtonCell implementation
|
// NSButtonCell implementation
|
||||||
|
@ -56,45 +57,47 @@
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
if (self == [NSButtonCell class])
|
if (self == [NSButtonCell class])
|
||||||
{
|
[self setVersion:1]; // Initial version
|
||||||
// Initial version
|
|
||||||
[self setVersion:1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Instance methods
|
// Instance methods
|
||||||
//
|
//
|
||||||
|
- _init
|
||||||
|
{
|
||||||
|
cell_enabled = YES;
|
||||||
|
transparent = NO;
|
||||||
|
cell_bordered = YES;
|
||||||
|
showAltStateMask = NSNoCellMask; // configure as a NSMomentaryPushButton
|
||||||
|
highlightsByMask = NSPushInCellMask | NSChangeGrayCellMask;
|
||||||
|
delayInterval = 0.4;
|
||||||
|
repeatInterval = 0.075;
|
||||||
|
altContents = nil;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
- init
|
- init
|
||||||
{
|
{
|
||||||
[self initTextCell:@"Button"];
|
[self initTextCell:@"Button"];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- initImageCell:(NSImage *)anImage
|
- initImageCell:(NSImage *)anImage
|
||||||
{
|
{
|
||||||
[super initImageCell:anImage];
|
[super initImageCell:anImage];
|
||||||
[self setStringValue:@"Button"];
|
|
||||||
[self setButtonType:NSMomentaryPushButton];
|
contents = nil;
|
||||||
[self setEnabled:YES];
|
|
||||||
[self setTransparent:NO];
|
return [self _init];
|
||||||
[self setBordered:YES];
|
|
||||||
delayInterval = 0.4;
|
|
||||||
repeatInterval = 0.075;
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- initTextCell:(NSString *)aString
|
- initTextCell:(NSString *)aString
|
||||||
{
|
{
|
||||||
[super initTextCell:aString];
|
[super initTextCell:aString];
|
||||||
altContents = nil;
|
|
||||||
[self setButtonType:NSMomentaryPushButton];
|
return [self _init];
|
||||||
[self setEnabled:YES];
|
|
||||||
[self setTransparent:NO];
|
|
||||||
[self setBordered:YES];
|
|
||||||
delayInterval = 0.4;
|
|
||||||
repeatInterval = 0.075;
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
|
@ -103,6 +106,7 @@
|
||||||
[altImage release];
|
[altImage release];
|
||||||
[keyEquivalent release];
|
[keyEquivalent release];
|
||||||
[keyEquivalentFont release];
|
[keyEquivalentFont release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,9 +120,10 @@
|
||||||
|
|
||||||
- (void)setAlternateTitle:(NSString *)aString
|
- (void)setAlternateTitle:(NSString *)aString
|
||||||
{
|
{
|
||||||
altContents = [aString copy];
|
NSString* _string = [aString copy];
|
||||||
// update our state
|
|
||||||
[self setState:[self state]];
|
ASSIGN(altContents, _string);
|
||||||
|
[self setState:[self state]]; // update our state
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFont:(NSFont *)fontObject
|
- (void)setFont:(NSFont *)fontObject
|
||||||
|
@ -129,8 +134,7 @@
|
||||||
- (void)setTitle:(NSString *)aString
|
- (void)setTitle:(NSString *)aString
|
||||||
{
|
{
|
||||||
[self setStringValue:aString];
|
[self setStringValue:aString];
|
||||||
// update our state
|
[self setState:[self state]]; // update our state
|
||||||
[self setState:[self state]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)title
|
- (NSString *)title
|
||||||
|
@ -165,14 +169,14 @@
|
||||||
// Setting the Repeat Interval
|
// Setting the Repeat Interval
|
||||||
//
|
//
|
||||||
- (void)getPeriodicDelay:(float *)delay
|
- (void)getPeriodicDelay:(float *)delay
|
||||||
interval:(float *)interval
|
interval:(float *)interval
|
||||||
{
|
{
|
||||||
*delay = delayInterval;
|
*delay = delayInterval;
|
||||||
*interval = repeatInterval;
|
*interval = repeatInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPeriodicDelay:(float)delay
|
- (void)setPeriodicDelay:(float)delay
|
||||||
interval:(float)interval
|
interval:(float)interval
|
||||||
{
|
{
|
||||||
delayInterval = delay;
|
delayInterval = delay;
|
||||||
repeatInterval = interval;
|
repeatInterval = interval;
|
||||||
|
@ -197,11 +201,11 @@
|
||||||
return keyEquivalentModifierMask;
|
return keyEquivalentModifierMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalent:(NSString *)key
|
- (void)setKeyEquivalent:(NSString *)key
|
||||||
{
|
{
|
||||||
id copy = [key copy];
|
NSString* _string = [key copy];
|
||||||
ASSIGN(keyEquivalent, copy);
|
|
||||||
[copy release];
|
ASSIGN(keyEquivalent, _string);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalentModifierMask:(unsigned int)mask
|
- (void)setKeyEquivalentModifierMask:(unsigned int)mask
|
||||||
|
@ -215,9 +219,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalentFont:(NSString *)fontName
|
- (void)setKeyEquivalentFont:(NSString *)fontName
|
||||||
size:(float)fontSize
|
size:(float)fontSize
|
||||||
{
|
{
|
||||||
ASSIGN(keyEquivalentFont, [NSFont fontWithName:fontName size:fontSize]);
|
NSFont* font = [NSFont fontWithName:fontName size:fontSize];
|
||||||
|
|
||||||
|
ASSIGN(keyEquivalentFont, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -327,18 +333,17 @@
|
||||||
[self setState:(aDouble != 0)];
|
[self setState:(aDouble != 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)intValue { return [self state]; }
|
- (int)intValue { return [self state]; }
|
||||||
- (float)floatValue { return [self state]; }
|
- (float)floatValue { return [self state]; }
|
||||||
- (double)doubleValue { return [self state]; }
|
- (double)doubleValue { return [self state]; }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Displaying
|
// Displaying
|
||||||
//
|
//
|
||||||
- (void)drawWithFrame:(NSRect)cellFrame
|
- (void)drawWithFrame:(NSRect)cellFrame
|
||||||
inView:(NSView *)controlView
|
inView:(NSView *)controlView
|
||||||
{
|
{
|
||||||
// Save last view drawn to
|
control_view = controlView; // Save last view cell was drawn to
|
||||||
control_view = controlView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -352,12 +357,12 @@
|
||||||
{
|
{
|
||||||
NSButtonCell* c = [super copyWithZone:zone];
|
NSButtonCell* c = [super copyWithZone:zone];
|
||||||
|
|
||||||
[c setAlternateTitle:altContents];
|
c->altContents = [[altContents copy] retain];
|
||||||
[c setAlternateImage:altImage];
|
ASSIGN(c->altImage, altImage);
|
||||||
[c setKeyEquivalent:keyEquivalent];
|
c->keyEquivalent = [[keyEquivalent copy] retain];
|
||||||
[c setKeyEquivalentFont:keyEquivalentFont];
|
ASSIGN(c->keyEquivalentFont, keyEquivalentFont);
|
||||||
[c setKeyEquivalentModifierMask:keyEquivalentModifierMask];
|
c->keyEquivalentModifierMask = keyEquivalentModifierMask;
|
||||||
[c setTransparent:transparent];
|
c->transparent = transparent;
|
||||||
c->highlightsByMask = highlightsByMask;
|
c->highlightsByMask = highlightsByMask;
|
||||||
c->showAltStateMask = showAltStateMask;
|
c->showAltStateMask = showAltStateMask;
|
||||||
|
|
||||||
|
@ -387,6 +392,7 @@
|
||||||
altImage = [aDecoder decodeObject];
|
altImage = [aDecoder decodeObject];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &transparent];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &transparent];
|
||||||
NSDebugLog(@"NSButtonCell: finish decoding\n");
|
NSDebugLog(@"NSButtonCell: finish decoding\n");
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
107
Source/NSCell.m
107
Source/NSCell.m
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
|
Date: August 1998
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -39,6 +41,10 @@
|
||||||
#include <AppKit/NSCell.h>
|
#include <AppKit/NSCell.h>
|
||||||
#include <AppKit/NSEvent.h>
|
#include <AppKit/NSEvent.h>
|
||||||
|
|
||||||
|
#define ASSIGN(a, b) [b retain]; \
|
||||||
|
[a release]; \
|
||||||
|
a = b;
|
||||||
|
|
||||||
@implementation NSCell
|
@implementation NSCell
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -70,7 +76,6 @@
|
||||||
//
|
//
|
||||||
- _init
|
- _init
|
||||||
{
|
{
|
||||||
self = [super init];
|
|
||||||
cell_type = NSNullCellType;
|
cell_type = NSNullCellType;
|
||||||
cell_image = nil;
|
cell_image = nil;
|
||||||
cell_font = nil;
|
cell_font = nil;
|
||||||
|
@ -88,6 +93,7 @@
|
||||||
cell_float_left = 0;
|
cell_float_left = 0;
|
||||||
cell_float_right = 0;
|
cell_float_right = 0;
|
||||||
action_mask = NSLeftMouseUpMask;
|
action_mask = NSLeftMouseUpMask;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +116,7 @@
|
||||||
cell_image = [anImage retain];
|
cell_image = [anImage retain];
|
||||||
image_position = NSImageOnly;
|
image_position = NSImageOnly;
|
||||||
cell_font = [[NSFont userFontOfSize:0] retain];
|
cell_font = [[NSFont userFontOfSize:0] retain];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,11 +130,9 @@
|
||||||
contents = [aString retain];
|
contents = [aString retain];
|
||||||
cell_type = NSTextCellType;
|
cell_type = NSTextCellType;
|
||||||
text_align = NSCenterTextAlignment;
|
text_align = NSCenterTextAlignment;
|
||||||
cell_image = nil;
|
|
||||||
image_position = NSNoImage;
|
|
||||||
cell_float_autorange = YES;
|
cell_float_autorange = YES;
|
||||||
cell_float_left = 0;
|
|
||||||
cell_float_right = 6;
|
cell_float_right = 6;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,15 +224,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setImage:(NSImage *)anImage
|
- (void)setImage:(NSImage *)anImage
|
||||||
{
|
{
|
||||||
// Not an image class --then forget it
|
if (![anImage isKindOfClass:[NSImage class]]) // set the image only
|
||||||
if (![anImage isKindOfClass:[NSImage class]])
|
return; // if it's an NSImage
|
||||||
return;
|
|
||||||
|
|
||||||
// Only set the image if we are an image cell
|
ASSIGN(cell_image, anImage);
|
||||||
[anImage retain];
|
|
||||||
[cell_image release];
|
|
||||||
cell_image = anImage;
|
|
||||||
[self setType:NSImageCellType];
|
[self setType:NSImageCellType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,36 +257,35 @@
|
||||||
|
|
||||||
- (void)setDoubleValue:(double)aDouble
|
- (void)setDoubleValue:(double)aDouble
|
||||||
{
|
{
|
||||||
NSNumber* number = [NSNumber numberWithDouble:aDouble];
|
NSString* number_string = [[NSNumber numberWithDouble:aDouble] stringValue];
|
||||||
|
|
||||||
[contents release];
|
ASSIGN(contents, number_string);
|
||||||
contents = [[number stringValue] retain];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFloatValue:(float)aFloat
|
- (void)setFloatValue:(float)aFloat
|
||||||
{
|
{
|
||||||
NSNumber* number = [NSNumber numberWithFloat:aFloat];
|
NSString* number_string = [[NSNumber numberWithFloat:aFloat] stringValue];
|
||||||
|
|
||||||
[contents release];
|
ASSIGN(contents, number_string);
|
||||||
contents = [[number stringValue] retain];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setIntValue:(int)anInt
|
- (void)setIntValue:(int)anInt
|
||||||
{
|
{
|
||||||
NSNumber* number = [NSNumber numberWithInt:anInt];
|
NSString* number_string = [[NSNumber numberWithInt:anInt] stringValue];
|
||||||
|
|
||||||
[contents release];
|
ASSIGN(contents, number_string);
|
||||||
contents = [[number stringValue] retain];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStringValue:(NSString *)aString
|
- (void)setStringValue:(NSString *)aString
|
||||||
{
|
{
|
||||||
aString = [aString copy];
|
NSString* _string;
|
||||||
[contents release];
|
|
||||||
if (!aString)
|
if (!aString)
|
||||||
contents = @"";
|
_string = @"";
|
||||||
else
|
else
|
||||||
contents = aString;
|
_string = [aString copy];
|
||||||
|
|
||||||
|
ASSIGN(contents, _string);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -354,13 +354,10 @@
|
||||||
|
|
||||||
- (void)setFont:(NSFont *)fontObject
|
- (void)setFont:(NSFont *)fontObject
|
||||||
{
|
{
|
||||||
// Not a font --then forget it
|
if (![fontObject isKindOfClass:[NSFont class]]) // set the font only
|
||||||
if (![fontObject isKindOfClass:[NSFont class]])
|
return; // if it's an NSFont
|
||||||
return;
|
|
||||||
|
|
||||||
[fontObject retain];
|
ASSIGN(cell_font, fontObject);
|
||||||
[cell_font release];
|
|
||||||
cell_font = fontObject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSelectable:(BOOL)flag
|
- (void)setSelectable:(BOOL)flag
|
||||||
|
@ -505,8 +502,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)highlight:(BOOL)lit
|
- (void)highlight:(BOOL)lit
|
||||||
withFrame:(NSRect)cellFrame
|
withFrame:(NSRect)cellFrame
|
||||||
inView:(NSView *)controlView
|
inView:(NSView *)controlView
|
||||||
{
|
{
|
||||||
cell_highlighted = lit;
|
cell_highlighted = lit;
|
||||||
|
|
||||||
|
@ -769,36 +766,32 @@
|
||||||
|
|
||||||
- (void)setRepresentedObject:(id)anObject
|
- (void)setRepresentedObject:(id)anObject
|
||||||
{
|
{
|
||||||
[anObject retain];
|
ASSIGN(represented_object, anObject);
|
||||||
[represented_object release];
|
|
||||||
represented_object = anObject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)copyWithZone:(NSZone*)zone
|
- (id)copyWithZone:(NSZone*)zone
|
||||||
{
|
{
|
||||||
NSCell* c;
|
NSCell* c = [[isa allocWithZone: zone] init];
|
||||||
|
|
||||||
c = [[isa allocWithZone: zone] init];
|
c->contents = [[contents copy] retain];
|
||||||
|
ASSIGN(c->cell_image, cell_image);
|
||||||
[c setStringValue:contents];
|
ASSIGN(c->cell_font, cell_font);
|
||||||
[c setImage:cell_image];
|
c->cell_state = cell_state;
|
||||||
[c setFont:cell_font];
|
|
||||||
[c setState:cell_state];
|
|
||||||
c->cell_highlighted = cell_highlighted;
|
c->cell_highlighted = cell_highlighted;
|
||||||
[c setEnabled:cell_enabled];
|
c->cell_enabled = cell_enabled;
|
||||||
[c setEditable:cell_editable];
|
c->cell_editable = cell_editable;
|
||||||
[c setBordered:cell_bordered];
|
c->cell_bordered = cell_bordered;
|
||||||
[c setBezeled:cell_bezeled];
|
c->cell_bezeled = cell_bezeled;
|
||||||
[c setScrollable:cell_scrollable];
|
c->cell_scrollable = cell_scrollable;
|
||||||
[c setSelectable:cell_selectable];
|
c->cell_selectable = cell_selectable;
|
||||||
[c setContinuous:cell_continuous];
|
[c setContinuous:cell_continuous];
|
||||||
[c setFloatingPointFormat:cell_float_autorange
|
c->cell_float_autorange = cell_float_autorange;
|
||||||
left:cell_float_left
|
c->cell_float_left = cell_float_left;
|
||||||
right:cell_float_right];
|
c->cell_float_right = cell_float_right;
|
||||||
c->image_position = image_position;
|
c->image_position = image_position;
|
||||||
[c setType:cell_type];
|
c->cell_type = cell_type;
|
||||||
[c setAlignment:text_align];
|
c->text_align = text_align;
|
||||||
[c setEntryType:entry_type];
|
c->entry_type = entry_type;
|
||||||
c->control_view = control_view;
|
c->control_view = control_view;
|
||||||
c->cell_size = cell_size;
|
c->cell_size = cell_size;
|
||||||
[c setRepresentedObject:represented_object];
|
[c setRepresentedObject:represented_object];
|
||||||
|
|
|
@ -167,55 +167,55 @@
|
||||||
|
|
||||||
- (void)viewBoundsChanged:(NSNotification*)aNotification
|
- (void)viewBoundsChanged:(NSNotification*)aNotification
|
||||||
{
|
{
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewFrameChanged:(NSNotification*)aNotification
|
- (void)viewFrameChanged:(NSNotification*)aNotification
|
||||||
{
|
{
|
||||||
[self setBoundsOrigin:[self constrainScrollPoint:bounds.origin]];
|
[self setBoundsOrigin:[self constrainScrollPoint:bounds.origin]];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize
|
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize
|
||||||
{
|
{
|
||||||
[super scaleUnitSquareToSize:newUnitSize];
|
[super scaleUnitSquareToSize:newUnitSize];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBoundsOrigin:(NSPoint)aPoint
|
- (void)setBoundsOrigin:(NSPoint)aPoint
|
||||||
{
|
{
|
||||||
[super setBoundsOrigin:aPoint];
|
[super setBoundsOrigin:aPoint];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBoundsSize:(NSSize)aSize
|
- (void)setBoundsSize:(NSSize)aSize
|
||||||
{
|
{
|
||||||
[super setBoundsSize:aSize];
|
[super setBoundsSize:aSize];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameSize:(NSSize)aSize
|
- (void)setFrameSize:(NSSize)aSize
|
||||||
{
|
{
|
||||||
[super setFrameSize:aSize];
|
[super setFrameSize:aSize];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameOrigin:(NSPoint)aPoint
|
- (void)setFrameOrigin:(NSPoint)aPoint
|
||||||
{
|
{
|
||||||
[super setFrameOrigin:aPoint];
|
[super setFrameOrigin:aPoint];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)rect
|
- (void)setFrame:(NSRect)rect
|
||||||
{
|
{
|
||||||
[super setFrame:rect];
|
[super setFrame:rect];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)translateOriginToPoint:(NSPoint)aPoint
|
- (void)translateOriginToPoint:(NSPoint)aPoint
|
||||||
{
|
{
|
||||||
[super translateOriginToPoint:aPoint];
|
[super translateOriginToPoint:aPoint];
|
||||||
[[self superview] reflectScrolledClipView:self];
|
[super_view reflectScrolledClipView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)documentView { return _documentView; }
|
- (id)documentView { return _documentView; }
|
||||||
|
|
|
@ -381,7 +381,6 @@ static int mouseDownFlags = 0;
|
||||||
[self setSelectionByRect:YES];
|
[self setSelectionByRect:YES];
|
||||||
[self setAutosizesCells:YES];
|
[self setAutosizesCells:YES];
|
||||||
if (mode == NSRadioModeMatrix && numRows && numCols) {
|
if (mode == NSRadioModeMatrix && numRows && numCols) {
|
||||||
selectedRow = selectedColumn = 0;
|
|
||||||
[self selectCellAtRow:0 column:0];
|
[self selectCellAtRow:0 column:0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -557,14 +556,17 @@ static int mouseDownFlags = 0;
|
||||||
if (column >= numCols)
|
if (column >= numCols)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (column == selectedColumn)
|
|
||||||
[self selectCellAtRow:0 column:0];
|
|
||||||
|
|
||||||
for (i = 0; i < numRows; i++)
|
for (i = 0; i < numRows; i++)
|
||||||
[[cells objectAtIndex:i] removeObjectAtIndex:column];
|
[[cells objectAtIndex:i] removeObjectAtIndex:column];
|
||||||
|
|
||||||
removeColumn (selectedCells, column);
|
removeColumn (selectedCells, column);
|
||||||
numCols--;
|
numCols--;
|
||||||
|
|
||||||
|
if (column == selectedColumn)
|
||||||
|
{
|
||||||
|
selectedCell = nil;
|
||||||
|
[self selectCellAtRow:0 column:0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeRow:(int)row
|
- (void)removeRow:(int)row
|
||||||
|
@ -572,12 +574,15 @@ static int mouseDownFlags = 0;
|
||||||
if (row >= numRows)
|
if (row >= numRows)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (row == selectedRow)
|
|
||||||
[self selectCellAtRow:0 column:0];
|
|
||||||
|
|
||||||
[cells removeObjectAtIndex:row];
|
[cells removeObjectAtIndex:row];
|
||||||
removeRow (selectedCells, row);
|
removeRow (selectedCells, row);
|
||||||
numRows--;
|
numRows--;
|
||||||
|
|
||||||
|
if (row == selectedRow)
|
||||||
|
{
|
||||||
|
selectedCell = nil;
|
||||||
|
[self selectCellAtRow:0 column:0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)renewRows:(int)newRows
|
- (void)renewRows:(int)newRows
|
||||||
|
@ -712,7 +717,7 @@ static int mouseDownFlags = 0;
|
||||||
|
|
||||||
if (mode == NSRadioModeMatrix) {
|
if (mode == NSRadioModeMatrix) {
|
||||||
if (value) {
|
if (value) {
|
||||||
ASSIGN(selectedCell, aCell);
|
selectedCell = aCell; // select current cell
|
||||||
selectedRow = row;
|
selectedRow = row;
|
||||||
selectedColumn = column;
|
selectedColumn = column;
|
||||||
[selectedCell setState:1];
|
[selectedCell setState:1];
|
||||||
|
@ -745,14 +750,17 @@ static int mouseDownFlags = 0;
|
||||||
((tMatrix)selectedCells)->matrix[i][j] = NO;
|
((tMatrix)selectedCells)->matrix[i][j] = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!allowsEmptySelection) // if we don't allow an
|
||||||
|
[self selectCellAtRow:0 column:0]; // empty selection
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deselectSelectedCell
|
- (void)deselectSelectedCell
|
||||||
{
|
{
|
||||||
[selectedCell setState:0];
|
[selectedCell setState:0];
|
||||||
selectedCell = nil;
|
selectedCell = nil;
|
||||||
selectedRow = -1;
|
selectedRow = 0;
|
||||||
selectedColumn = -1;
|
selectedColumn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)selectAll:(id)sender
|
- (void)selectAll:(id)sender
|
||||||
|
@ -761,7 +769,7 @@ static int mouseDownFlags = 0;
|
||||||
NSArray* row;
|
NSArray* row;
|
||||||
|
|
||||||
/* Make the selected cell the cell at (0, 0) */
|
/* Make the selected cell the cell at (0, 0) */
|
||||||
ASSIGN(selectedCell, [self cellAtRow:0 column:0]);
|
selectedCell = [self cellAtRow:0 column:0]; // select current cell
|
||||||
selectedRow = 0;
|
selectedRow = 0;
|
||||||
selectedColumn = 0;
|
selectedColumn = 0;
|
||||||
|
|
||||||
|
@ -792,7 +800,7 @@ static int mouseDownFlags = 0;
|
||||||
else if (!aCell)
|
else if (!aCell)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSIGN(selectedCell, aCell);
|
selectedCell = aCell; // select current cell
|
||||||
selectedRow = row;
|
selectedRow = row;
|
||||||
selectedColumn = column;
|
selectedColumn = column;
|
||||||
[selectedCell setState:1];
|
[selectedCell setState:1];
|
||||||
|
@ -1147,6 +1155,7 @@ BOOL done = NO;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
id aCell, previousCell = nil, selectedCellTarget;
|
id aCell, previousCell = nil, selectedCellTarget;
|
||||||
NSRect previousCellRect;
|
NSRect previousCellRect;
|
||||||
|
NSApplication *app = [NSApplication sharedApplication];
|
||||||
static MPoint anchor = {0, 0};
|
static MPoint anchor = {0, 0};
|
||||||
|
|
||||||
mouseDownFlags = [theEvent modifierFlags];
|
mouseDownFlags = [theEvent modifierFlags];
|
||||||
|
@ -1174,58 +1183,60 @@ static MPoint anchor = {0, 0};
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case NSTrackModeMatrix: // in Track mode
|
case NSTrackModeMatrix: // in Track mode the cell
|
||||||
ASSIGN(selectedCell, aCell); // the cell should
|
selectedCell = aCell; // should track the mouse
|
||||||
selectedRow = row; // track the mouse
|
selectedRow = row; // until the cursor either
|
||||||
selectedColumn = column; // until the cursor
|
selectedColumn = column; // leaves the cellframe or
|
||||||
// either leaves
|
// NSLeftMouseUp occurs
|
||||||
if([aCell trackMouse:lastEvent // the cellframe or
|
if([aCell trackMouse:lastEvent
|
||||||
inRect:rect // NSLeftMouseUp
|
inRect:rect
|
||||||
ofView:self
|
ofView:self
|
||||||
untilMouseUp:YES]) // YES if mouse
|
untilMouseUp:YES]) // YES if mouse
|
||||||
done = YES; // went up in cell
|
done = YES; // went up in cell
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSHighlightModeMatrix:
|
case NSHighlightModeMatrix: // Highlight mode is like
|
||||||
[aCell setState:1];
|
[aCell setState:1]; // Track mode except that
|
||||||
|
selectedCell = aCell; // the cell is lit before
|
||||||
|
selectedRow = row; // it begins tracking and
|
||||||
|
selectedColumn = column; // unlit afterwards
|
||||||
[aCell highlight: YES withFrame: rect inView: self];
|
[aCell highlight: YES withFrame: rect inView: self];
|
||||||
[self setNeedsDisplayInRect:rect]; // Highlight mode
|
[window flushWindow];
|
||||||
ASSIGN(selectedCell, aCell); // is like Track
|
|
||||||
selectedRow = row; // mode except that
|
if([aCell trackMouse:lastEvent
|
||||||
selectedColumn = column; // the cell is lit
|
inRect:rect
|
||||||
// before it begins
|
|
||||||
if([aCell trackMouse:lastEvent // tracking and
|
|
||||||
inRect:rect // unlit afterwards
|
|
||||||
ofView:self
|
ofView:self
|
||||||
untilMouseUp:YES]) // YES if mouse
|
untilMouseUp:YES]) // YES if mouse
|
||||||
done = YES; // went up in cell
|
done = YES; // went up in cell
|
||||||
|
|
||||||
[aCell setState:0];
|
[aCell setState:0];
|
||||||
[aCell highlight: NO withFrame: rect inView: self];
|
[aCell highlight: NO withFrame: rect inView: self];
|
||||||
[self setNeedsDisplayInRect:rect];
|
[window flushWindow];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSRadioModeMatrix: // Radio mode allows no
|
case NSRadioModeMatrix: // Radio mode allows no
|
||||||
if (previousCell == aCell) // more than one cell
|
if (previousCell == aCell) // more than one cell
|
||||||
break; // to be selected
|
break; // to be selected
|
||||||
|
|
||||||
[selectedCell setState:0]; // deselect previously
|
if(selectedCell)
|
||||||
if (!previousCell) // selected cell
|
{
|
||||||
previousCellRect = [self cellFrameAtRow:selectedRow
|
[selectedCell setState:0]; // deselect previously
|
||||||
column:selectedColumn];
|
if (!previousCell) // selected cell
|
||||||
[selectedCell highlight:NO
|
previousCellRect = [self cellFrameAtRow:selectedRow
|
||||||
withFrame:previousCellRect
|
column:selectedColumn];
|
||||||
inView:self];
|
[selectedCell highlight:NO
|
||||||
((tMatrix)selectedCells)->matrix[selectedRow]
|
withFrame:previousCellRect
|
||||||
[selectedColumn] = NO;
|
inView:self];
|
||||||
[self setNeedsDisplayInRect:previousCellRect];
|
((tMatrix)selectedCells)->matrix[selectedRow]
|
||||||
|
[selectedColumn] = NO;
|
||||||
ASSIGN(selectedCell, aCell); // select current cell
|
}
|
||||||
|
selectedCell = aCell; // select current cell
|
||||||
selectedRow = row;
|
selectedRow = row;
|
||||||
selectedColumn = column;
|
selectedColumn = column;
|
||||||
[aCell setState:1];
|
[aCell setState:1];
|
||||||
[aCell highlight:YES withFrame:rect inView:self];
|
[aCell highlight:YES withFrame:rect inView:self];
|
||||||
((tMatrix)selectedCells)->matrix[row][column] = YES;
|
((tMatrix)selectedCells)->matrix[row][column] = YES;
|
||||||
[self setNeedsDisplayInRect:rect];
|
[window flushWindow];
|
||||||
break;
|
break;
|
||||||
// List mode allows
|
// List mode allows
|
||||||
case NSListModeMatrix: // multiple cells to be
|
case NSListModeMatrix: // multiple cells to be
|
||||||
|
@ -1247,7 +1258,7 @@ static MPoint anchor = {0, 0};
|
||||||
// selection to the current cell
|
// selection to the current cell
|
||||||
if (!(modifiers & NSAlternateKeyMask))
|
if (!(modifiers & NSAlternateKeyMask))
|
||||||
{
|
{
|
||||||
ASSIGN(selectedCell, aCell);
|
selectedCell = aCell; // select current cell
|
||||||
selectedRow = row;
|
selectedRow = row;
|
||||||
selectedColumn = column;
|
selectedColumn = column;
|
||||||
|
|
||||||
|
@ -1256,7 +1267,7 @@ static MPoint anchor = {0, 0};
|
||||||
withFrame:rect
|
withFrame:rect
|
||||||
inView:self];
|
inView:self];
|
||||||
((tMatrix)selectedCells)->matrix[row][column] =YES;
|
((tMatrix)selectedCells)->matrix[row][column] =YES;
|
||||||
[self setNeedsDisplayInRect:rect];
|
[window flushWindow];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1269,7 +1280,8 @@ static MPoint anchor = {0, 0};
|
||||||
last:MakePoint (selectedColumn, selectedRow)
|
last:MakePoint (selectedColumn, selectedRow)
|
||||||
current:MakePoint (column, row)];
|
current:MakePoint (column, row)];
|
||||||
|
|
||||||
ASSIGN(selectedCell, aCell);
|
[window flushWindow];
|
||||||
|
selectedCell = aCell; // select current cell
|
||||||
selectedRow = row;
|
selectedRow = row;
|
||||||
selectedColumn = column;
|
selectedColumn = column;
|
||||||
break;
|
break;
|
||||||
|
@ -1285,22 +1297,20 @@ static MPoint anchor = {0, 0};
|
||||||
|
|
||||||
while (!shouldProceedEvent)
|
while (!shouldProceedEvent)
|
||||||
{ // Get the next event
|
{ // Get the next event
|
||||||
theEvent = [[NSApplication sharedApplication]
|
theEvent = [app nextEventMatchingMask:eventMask
|
||||||
nextEventMatchingMask:eventMask
|
untilDate:[NSDate distantFuture]
|
||||||
untilDate:[NSDate distantFuture]
|
inMode:NSEventTrackingRunLoopMode
|
||||||
inMode:NSEventTrackingRunLoopMode
|
dequeue:YES];
|
||||||
dequeue:YES];
|
|
||||||
switch ([theEvent type])
|
switch ([theEvent type])
|
||||||
{
|
{
|
||||||
case NSPeriodic:
|
case NSPeriodic:
|
||||||
NSDebugLog(@"NSMatrix: got NSPeriodic event\n");
|
NSDebugLog(@"NSMatrix: got NSPeriodic event\n");
|
||||||
shouldProceedEvent = YES;
|
shouldProceedEvent = YES; // it's time to cycle
|
||||||
break;
|
break; // thru the loop again
|
||||||
case NSLeftMouseUp:
|
case NSLeftMouseUp:
|
||||||
done = YES;
|
done = YES; // Track and Highlight modes do not use
|
||||||
case NSLeftMouseDown:
|
case NSLeftMouseDown: // periodic events so we must break out
|
||||||
default: // if in Track or Highlight modes break
|
default: // and check if the mouse is in a cell
|
||||||
// out and check if mouse is in a cell
|
|
||||||
if ((mode == NSTrackModeMatrix) ||
|
if ((mode == NSTrackModeMatrix) ||
|
||||||
(mode == NSHighlightModeMatrix))
|
(mode == NSHighlightModeMatrix))
|
||||||
shouldProceedEvent = YES;
|
shouldProceedEvent = YES;
|
||||||
|
@ -1318,25 +1328,30 @@ static MPoint anchor = {0, 0};
|
||||||
|
|
||||||
switch (mode) // Finish the selection
|
switch (mode) // Finish the selection
|
||||||
{ // process
|
{ // process
|
||||||
case NSTrackModeMatrix:
|
case NSRadioModeMatrix:
|
||||||
case NSHighlightModeMatrix:
|
if(selectedCell)
|
||||||
[selectedCell setState:![selectedCell state]];
|
[selectedCell highlight:NO withFrame:rect inView:self];
|
||||||
case NSRadioModeMatrix:
|
|
||||||
[selectedCell highlight:NO withFrame:rect inView:self];
|
|
||||||
case NSListModeMatrix:
|
case NSListModeMatrix:
|
||||||
[self setNeedsDisplayInRect:rect];
|
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||||
|
[window flushWindow];
|
||||||
|
case NSHighlightModeMatrix:
|
||||||
|
case NSTrackModeMatrix:
|
||||||
break;
|
break;
|
||||||
} // in Track and Highlight modes the single
|
}
|
||||||
// click action has already been sent by the
|
|
||||||
// cell to it's target (if it has one)
|
if(selectedCell)
|
||||||
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix) &&
|
{ // send single click action
|
||||||
(selectedCellTarget = [selectedCell target]))
|
if(!(selectedCellTarget = [selectedCell target]))
|
||||||
[selectedCellTarget performSelector:[selectedCell action]
|
{ // selected cell has no target so send single
|
||||||
withObject:self];
|
if (target) // click action to matrix's (self's) target
|
||||||
else // selected cell has no target
|
[target performSelector:action withObject:self];
|
||||||
{ // so send single click action
|
} // in Track and Highlight modes the single
|
||||||
if (target) // to matrix's (self's) target
|
else // click action has already been sent by the
|
||||||
[target performSelector:action withObject:self];
|
{ // cell to it's target (if it has one)
|
||||||
|
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix))
|
||||||
|
[selectedCellTarget performSelector:[selectedCell action]
|
||||||
|
withObject:self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// click count > 1 indicates a double click
|
// click count > 1 indicates a double click
|
||||||
if (target && doubleAction && ([lastEvent clickCount] > 1))
|
if (target && doubleAction && ([lastEvent clickCount] > 1))
|
||||||
|
@ -1344,7 +1359,7 @@ static MPoint anchor = {0, 0};
|
||||||
|
|
||||||
[self unlockFocus];
|
[self unlockFocus];
|
||||||
|
|
||||||
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix))
|
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix))
|
||||||
[NSEvent stopPeriodicEvents];
|
[NSEvent stopPeriodicEvents];
|
||||||
|
|
||||||
[lastEvent release];
|
[lastEvent release];
|
||||||
|
@ -1405,48 +1420,48 @@ static MPoint anchor = {0, 0};
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMode:(NSMatrixMode)aMode { mode = aMode; }
|
- (void)setMode:(NSMatrixMode)aMode { mode = aMode; }
|
||||||
- (NSMatrixMode)mode { return mode; }
|
- (NSMatrixMode)mode { return mode; }
|
||||||
- (void)setCellClass:(Class)class { cellClass = class; }
|
- (void)setCellClass:(Class)class { cellClass = class; }
|
||||||
- (Class)cellClass { return cellClass; }
|
- (Class)cellClass { return cellClass; }
|
||||||
- (void)setPrototype:(NSCell*)aCell { ASSIGN(cellPrototype, aCell) }
|
- (void)setPrototype:(NSCell*)aCell { ASSIGN(cellPrototype, aCell) }
|
||||||
- (id)prototype { return cellPrototype; }
|
- (id)prototype { return cellPrototype; }
|
||||||
- (NSSize)cellSize { return cellSize; }
|
- (NSSize)cellSize { return cellSize; }
|
||||||
- (NSSize)intercellSpacing { return intercell; }
|
- (NSSize)intercellSpacing { return intercell; }
|
||||||
- (void)setBackgroundColor:(NSColor*)c { ASSIGN(backgroundColor, c) }
|
- (void)setBackgroundColor:(NSColor*)c { ASSIGN(backgroundColor, c) }
|
||||||
- (NSColor*)backgroundColor { return backgroundColor; }
|
- (NSColor*)backgroundColor { return backgroundColor; }
|
||||||
- (void)setCellBackgroundColor:(NSColor*)c { ASSIGN(cellBackgroundColor, c) }
|
- (void)setCellBackgroundColor:(NSColor*)c { ASSIGN(cellBackgroundColor, c) }
|
||||||
- (NSColor*)cellBackgroundColor { return cellBackgroundColor; }
|
- (NSColor*)cellBackgroundColor { return cellBackgroundColor; }
|
||||||
- (void)setDelegate:(id)object { ASSIGN(delegate, object) }
|
- (void)setDelegate:(id)object { ASSIGN(delegate, object) }
|
||||||
- (id)delegate { return delegate; }
|
- (id)delegate { return delegate; }
|
||||||
- (void)setTarget:anObject { ASSIGN(target, anObject) }
|
- (void)setTarget:anObject { ASSIGN(target, anObject) }
|
||||||
- (id)target { return target; }
|
- (id)target { return target; }
|
||||||
- (void)setAction:(SEL)sel { action = sel; }
|
- (void)setAction:(SEL)sel { action = sel; }
|
||||||
- (SEL)action { return action; }
|
- (SEL)action { return action; }
|
||||||
- (void)setDoubleAction:(SEL)sel { doubleAction = sel; }
|
- (void)setDoubleAction:(SEL)sel { doubleAction = sel; }
|
||||||
- (SEL)doubleAction { return doubleAction; }
|
- (SEL)doubleAction { return doubleAction; }
|
||||||
- (void)setErrorAction:(SEL)sel { errorAction = sel; }
|
- (void)setErrorAction:(SEL)sel { errorAction = sel; }
|
||||||
- (SEL)errorAction { return errorAction; }
|
- (SEL)errorAction { return errorAction; }
|
||||||
- (void)setAllowsEmptySelection:(BOOL)f { allowsEmptySelection = f; }
|
- (void)setAllowsEmptySelection:(BOOL)f { allowsEmptySelection = f; }
|
||||||
- (BOOL)allowsEmptySelection { return allowsEmptySelection; }
|
- (BOOL)allowsEmptySelection { return allowsEmptySelection; }
|
||||||
- (void)setSelectionByRect:(BOOL)flag { selectionByRect = flag; }
|
- (void)setSelectionByRect:(BOOL)flag { selectionByRect = flag; }
|
||||||
- (BOOL)isSelectionByRect { return selectionByRect; }
|
- (BOOL)isSelectionByRect { return selectionByRect; }
|
||||||
- (void)setDrawsBackground:(BOOL)flag { drawsBackground = flag; }
|
- (void)setDrawsBackground:(BOOL)flag { drawsBackground = flag; }
|
||||||
- (BOOL)drawsBackground { return drawsBackground; }
|
- (BOOL)drawsBackground { return drawsBackground; }
|
||||||
- (void)setDrawsCellBackground:(BOOL)f { drawsCellBackground = f; }
|
- (void)setDrawsCellBackground:(BOOL)f { drawsCellBackground = f; }
|
||||||
- (BOOL)drawsCellBackground { return drawsCellBackground; }
|
- (BOOL)drawsCellBackground { return drawsCellBackground; }
|
||||||
- (void)setAutosizesCells:(BOOL)flag { autosizesCells = flag; }
|
- (void)setAutosizesCells:(BOOL)flag { autosizesCells = flag; }
|
||||||
- (BOOL)autosizesCells { return autosizesCells; }
|
- (BOOL)autosizesCells { return autosizesCells; }
|
||||||
- (BOOL)isAutoscroll { return autoscroll; }
|
- (BOOL)isAutoscroll { return autoscroll; }
|
||||||
- (int)numberOfRows { return numRows; }
|
- (int)numberOfRows { return numRows; }
|
||||||
- (int)numberOfColumns { return numCols; }
|
- (int)numberOfColumns { return numCols; }
|
||||||
- (id)selectedCell { return selectedCell; }
|
- (id)selectedCell { return selectedCell; }
|
||||||
- (int)selectedColumn { return selectedColumn; }
|
- (int)selectedColumn { return selectedColumn; }
|
||||||
- (int)selectedRow { return selectedRow; }
|
- (int)selectedRow { return selectedRow; }
|
||||||
- (int)mouseDownFlags { return mouseDownFlags; }
|
- (int)mouseDownFlags { return mouseDownFlags; }
|
||||||
|
|
||||||
#if HAS_FLIPPED_VIEWS
|
#if HAS_FLIPPED_VIEWS
|
||||||
- (BOOL)isFlipped { return YES; }
|
- (BOOL)isFlipped { return YES; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -60,6 +60,11 @@
|
||||||
- (void)_resizeMenuForCellSize;
|
- (void)_resizeMenuForCellSize;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// NSMenuMatrix
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
@implementation NSMenuMatrix
|
@implementation NSMenuMatrix
|
||||||
|
|
||||||
|
@ -227,15 +232,21 @@ static NSFont* menuFont = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize)cellSize { return cellSize; }
|
- (NSSize)cellSize { return cellSize; }
|
||||||
- (void)setMenu:(NSMenu*)anObject { menu = anObject; }
|
- (void)setMenu:(NSMenu*)anObject { menu = anObject; }
|
||||||
- (void)setSelectedCell:(id)aCell { ASSIGN(selectedCell, aCell); }
|
- (void)setSelectedCell:(id)aCell { selectedCell = aCell; }
|
||||||
- (id)selectedCell { return selectedCell; }
|
- (id)selectedCell { return selectedCell; }
|
||||||
- (NSRect)selectedCellRect { return selectedCellRect; }
|
- (NSRect)selectedCellRect { return selectedCellRect; }
|
||||||
|
|
||||||
@end /* NSMenuMatrix */
|
@end /* NSMenuMatrix */
|
||||||
|
|
||||||
|
|
||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// NSMenu
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
@implementation NSMenu
|
@implementation NSMenu
|
||||||
|
|
||||||
// Class variables
|
// Class variables
|
||||||
|
|
|
@ -73,7 +73,7 @@ static BOOL usesUserKeyEquivalents = YES;
|
||||||
|
|
||||||
[representedObject release];
|
[representedObject release];
|
||||||
if (hasSubmenu)
|
if (hasSubmenu)
|
||||||
[[self target] release];
|
[target release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ static BOOL usesUserKeyEquivalents = YES;
|
||||||
copy->hasSubmenu = hasSubmenu;
|
copy->hasSubmenu = hasSubmenu;
|
||||||
if (hasSubmenu) {
|
if (hasSubmenu) {
|
||||||
id submenu = [[target copyWithZone:zone] autorelease];
|
id submenu = [[target copyWithZone:zone] autorelease];
|
||||||
[copy setTarget:submenu];
|
copy->target = [submenu retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ static BOOL usesUserKeyEquivalents = YES;
|
||||||
hasSubmenu = anObject && [anObject isKindOfClass:[NSMenu class]];
|
hasSubmenu = anObject && [anObject isKindOfClass:[NSMenu class]];
|
||||||
if (hasSubmenu) {
|
if (hasSubmenu) {
|
||||||
[anObject retain];
|
[anObject retain];
|
||||||
[[self target] release];
|
[target release];
|
||||||
}
|
}
|
||||||
[super setTarget:anObject];
|
[super setTarget:anObject];
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||||
A completely rewritten version of the original source by Scott Christley.
|
A completely rewritten version of the original source by Scott Christley.
|
||||||
Date: July 1997
|
Date: July 1997
|
||||||
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
|
Date: August 1998
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
|
@ -207,14 +209,15 @@ static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
- (void)setFloatValue:(float)aFloat
|
- (void)setFloatValue:(float)aFloat
|
||||||
{
|
{
|
||||||
if (aFloat < 0)
|
if (aFloat < 0)
|
||||||
_floatValue = 0;
|
_floatValue = 0;
|
||||||
else if (aFloat > 1)
|
else
|
||||||
_floatValue = 1;
|
if (aFloat > 1)
|
||||||
else
|
_floatValue = 1;
|
||||||
_floatValue = aFloat;
|
else
|
||||||
|
_floatValue = aFloat;
|
||||||
[self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]];
|
|
||||||
|
[self setNeedsDisplayInRect:[self rectForPart:NSScrollerKnobSlot]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFloatValue:(float)aFloat
|
- (void)setFloatValue:(float)aFloat
|
||||||
|
@ -435,74 +438,77 @@ static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
- (void)trackScrollButtons:(NSEvent*)theEvent
|
- (void)trackScrollButtons:(NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
| NSLeftMouseDraggedMask | NSMouseMovedMask;
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||||
NSPoint location;
|
NSLeftMouseDraggedMask | NSMouseMovedMask;
|
||||||
NSEventType eventType;
|
NSPoint location;
|
||||||
BOOL shouldReturn = NO;
|
BOOL shouldReturn = NO;
|
||||||
id theCell = nil;
|
id theCell = nil;
|
||||||
|
NSRect rect;
|
||||||
|
|
||||||
NSDebugLog (@"trackScrollButtons");
|
NSDebugLog (@"trackScrollButtons");
|
||||||
do {
|
do {
|
||||||
NSRect rect = [self rectForPart:_hitPart];
|
location = [self convertPoint:[theEvent locationInWindow]fromView:nil];
|
||||||
|
_hitPart = [self testPart:location];
|
||||||
|
rect = [self rectForPart:_hitPart];
|
||||||
|
|
||||||
switch (_hitPart) {
|
switch (_hitPart) // determine which cell
|
||||||
case NSScrollerIncrementLine:
|
{ // was hit
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementLine:
|
||||||
theCell = (_isHorizontal ? rightCell : upCell);
|
case NSScrollerIncrementPage:
|
||||||
break;
|
theCell = (_isHorizontal ? rightCell : upCell);
|
||||||
|
break;
|
||||||
|
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
theCell = (_isHorizontal ? leftCell : downCell);
|
theCell = (_isHorizontal ? leftCell : downCell);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
theCell = nil;
|
theCell = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theCell) {
|
if (theCell)
|
||||||
[theCell highlight:YES withFrame:rect inView:self]; // highlight cell
|
{ // highlight the cell
|
||||||
[self setNeedsDisplayInRect:rect];
|
[theCell highlight:YES withFrame:rect inView:self];
|
||||||
NSDebugLog (@"tracking cell %x", theCell);
|
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||||
/* Track the mouse until mouse goes up */
|
[window flushWindow];
|
||||||
shouldReturn = [theCell trackMouse:theEvent
|
NSDebugLog (@"tracking cell %x", theCell);
|
||||||
inRect:rect
|
// Track the mouse until mouse goes up
|
||||||
ofView:self
|
shouldReturn = [theCell trackMouse:theEvent
|
||||||
untilMouseUp:NO];
|
inRect:rect
|
||||||
|
ofView:self
|
||||||
|
untilMouseUp:YES];
|
||||||
|
// unhighlight the cell
|
||||||
|
[theCell highlight:NO withFrame:rect inView:self];
|
||||||
|
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||||
|
[window flushWindow];
|
||||||
|
}
|
||||||
|
|
||||||
/* Now unhighlight the cell */
|
if (shouldReturn)
|
||||||
[theCell highlight:NO withFrame:rect inView:self];
|
break;
|
||||||
#if 1
|
|
||||||
[self setNeedsDisplayInRect:rect];
|
|
||||||
#else
|
|
||||||
[theCell drawWithFrame:rect inView:self];
|
|
||||||
[self setNeedsDisplayInRect:rect];
|
|
||||||
[[self window] flushWindow];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldReturn)
|
theEvent = [theApp nextEventMatchingMask:eventMask
|
||||||
break;
|
untilDate:[NSDate distantFuture]
|
||||||
|
inMode:NSEventTrackingRunLoopMode
|
||||||
|
dequeue:YES];
|
||||||
|
}
|
||||||
|
while ([theEvent type] != NSLeftMouseUp);
|
||||||
|
|
||||||
theEvent = [[NSApplication sharedApplication]
|
NSDebugLog (@"return from trackScrollButtons");
|
||||||
nextEventMatchingMask:eventMask
|
|
||||||
untilDate:[NSDate distantFuture]
|
|
||||||
inMode:NSEventTrackingRunLoopMode
|
|
||||||
dequeue:YES];
|
|
||||||
eventType = [theEvent type];
|
|
||||||
location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
|
||||||
_hitPart = [self testPart:location];
|
|
||||||
} while (eventType != NSLeftMouseUp);
|
|
||||||
NSDebugLog (@"return from trackScrollButtons");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)sendAction:(SEL)action to:(id)target
|
- (BOOL)sendAction:(SEL)theAction to:(id)theTarget
|
||||||
{
|
{ // send action to
|
||||||
[target performSelector:action withObject:self];
|
BOOL ret = [super sendAction:theAction to:theTarget]; // the target on
|
||||||
return YES;
|
// behalf of cell
|
||||||
}
|
[self drawKnobSlot]; // lockFocus set in mouseDown method is
|
||||||
|
[self drawKnob]; // active so we simply redraw the knob and
|
||||||
|
[window flushWindow]; // slot to reflect the hit scroll button
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)encodeWithCoder:aCoder
|
- (void)encodeWithCoder:aCoder
|
||||||
{}
|
{}
|
||||||
|
@ -514,18 +520,15 @@ static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void)drawRect:(NSRect)rect
|
||||||
{
|
{
|
||||||
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
|
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
|
||||||
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||||
|
|
||||||
/* Draw the scroller buttons */
|
// Draw the scroller buttons
|
||||||
[self drawArrow:NSScrollerDecrementArrow highlight:NO];
|
[self drawArrow:NSScrollerDecrementArrow highlight:NO];
|
||||||
[self drawArrow:NSScrollerIncrementArrow highlight:NO];
|
[self drawArrow:NSScrollerIncrementArrow highlight:NO];
|
||||||
|
|
||||||
/* Draw the knob slot */
|
[self drawKnobSlot]; // Draw knob slot
|
||||||
[self drawKnobSlot];
|
[self drawKnob]; // Draw the knob
|
||||||
|
|
||||||
/* Draw the knob */
|
|
||||||
[self drawKnob];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawArrow:(NSScrollerArrow)whichButton
|
- (void)drawArrow:(NSScrollerArrow)whichButton
|
||||||
|
@ -554,8 +557,7 @@ static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
- (void)drawKnob
|
- (void)drawKnob
|
||||||
{
|
{
|
||||||
NSRect rect = [self rectForPart:NSScrollerKnob];
|
[knobCell drawWithFrame:[self rectForPart:NSScrollerKnob] inView:self];
|
||||||
[knobCell drawWithFrame:rect inView:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following methods should be implemented in the backend */
|
/* The following methods should be implemented in the backend */
|
||||||
|
|
|
@ -70,6 +70,11 @@
|
||||||
//
|
//
|
||||||
// Initialization
|
// Initialization
|
||||||
//
|
//
|
||||||
|
- init
|
||||||
|
{
|
||||||
|
return [self initWithFrame:NSZeroRect];
|
||||||
|
}
|
||||||
|
|
||||||
- initWithFrame:(NSRect)frameRect
|
- initWithFrame:(NSRect)frameRect
|
||||||
{
|
{
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
|
@ -86,15 +91,17 @@
|
||||||
is_ruler_visible = NO;
|
is_ruler_visible = NO;
|
||||||
is_field_editor = NO;
|
is_field_editor = NO;
|
||||||
draws_background = YES;
|
draws_background = YES;
|
||||||
background_color = [NSColor whiteColor];
|
background_color = [[NSColor whiteColor] retain];
|
||||||
text_color = [NSColor blackColor];
|
text_color = [[NSColor blackColor] retain];
|
||||||
default_font = [NSFont userFontOfSize:12];
|
default_font = [[NSFont userFontOfSize:12] retain];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
[default_font release];
|
||||||
|
[text_color release];
|
||||||
[background_color release];
|
[background_color release];
|
||||||
[plainContent release];
|
[plainContent release];
|
||||||
[rtfContent release];
|
[rtfContent release];
|
||||||
|
|
120
Source/NSView.m
120
Source/NSView.m
|
@ -715,6 +715,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
||||||
{ // preliminary implementation FIX ME
|
{ // preliminary implementation FIX ME
|
||||||
if(autoresizingMask == NSViewNotSizable) // view is not resizable
|
if(autoresizingMask == NSViewNotSizable) // view is not resizable
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(autoresizingMask & NSViewWidthSizable) // width resizable?
|
if(autoresizingMask & NSViewWidthSizable) // width resizable?
|
||||||
{
|
{
|
||||||
frame.size.width = [super_view frame].size.width;
|
frame.size.width = [super_view frame].size.width;
|
||||||
|
@ -724,6 +725,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
||||||
if(autoresizingMask & NSViewMinXMargin)
|
if(autoresizingMask & NSViewMinXMargin)
|
||||||
frame.origin.x += [super_view frame].size.width - oldSize.width;
|
frame.origin.x += [super_view frame].size.width - oldSize.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(autoresizingMask & NSViewHeightSizable) // height resizable?
|
if(autoresizingMask & NSViewHeightSizable) // height resizable?
|
||||||
{
|
{
|
||||||
frame.size.height = [super_view frame].size.height;
|
frame.size.height = [super_view frame].size.height;
|
||||||
|
@ -815,41 +817,44 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
||||||
|
|
||||||
- (void)displayRect:(NSRect)rect
|
- (void)displayRect:(NSRect)rect
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
if (!boundsMatrix || !frameMatrix)
|
if (!boundsMatrix || !frameMatrix)
|
||||||
NSLog (@"warning: %@ %p has not have the PS matrices setup!",
|
NSLog (@"warning: %@ %p has not have the PS matrices setup!",
|
||||||
NSStringFromClass(isa), self);
|
NSStringFromClass(isa), self);
|
||||||
|
|
||||||
needs_display = NO;
|
needs_display = NO;
|
||||||
|
|
||||||
[self lockFocus];
|
[self lockFocus];
|
||||||
[self drawRect:rect];
|
[self drawRect:rect];
|
||||||
[window _setNeedsFlush];
|
[window _setNeedsFlush];
|
||||||
// [window _view:self needsFlushInRect:rect];
|
// [window _view:self needsFlushInRect:rect];
|
||||||
[self unlockFocus];
|
[self unlockFocus];
|
||||||
|
// Tell subviews to display
|
||||||
|
for (i = 0, count = [sub_views count]; i < count; ++i)
|
||||||
|
{
|
||||||
|
NSView* subview = [sub_views objectAtIndex:i];
|
||||||
|
NSRect subviewFrame = subview->frame;
|
||||||
|
NSRect intersection;
|
||||||
|
// If the subview is rotated compute its
|
||||||
|
// bounding rectangle and use this one
|
||||||
|
// instead of the subview's frame.
|
||||||
|
if ([subview->frameMatrix isRotated])
|
||||||
|
[subview->frameMatrix boundingRectFor:subviewFrame
|
||||||
|
result:&subviewFrame];
|
||||||
|
|
||||||
// Tell subviews to display
|
// Determine if the subview's frame
|
||||||
for (i = 0, count = [sub_views count]; i < count; ++i) {
|
// intersects "rect" so that we can display
|
||||||
NSView* subview = [sub_views objectAtIndex:i];
|
// the subview.
|
||||||
NSRect subviewFrame = subview->frame;
|
intersection = NSIntersectionRect (rect, subviewFrame);
|
||||||
NSRect intersection;
|
if (intersection.origin.x || intersection.origin.y ||
|
||||||
|
intersection.size.width || intersection.size.height)
|
||||||
/* If the subview is rotated compute its bounding rectangle and use this
|
{ // Convert the intersection rectangle to
|
||||||
one instead of the subview's frame. */
|
// the subview's coordinates
|
||||||
if ([subview->frameMatrix isRotated])
|
intersection = [subview convertRect:intersection fromView:self];
|
||||||
[subview->frameMatrix boundingRectFor:subviewFrame result:&subviewFrame];
|
[subview displayRect:intersection];
|
||||||
|
}
|
||||||
/* Determine if the subview's frame intersects "rect"
|
}
|
||||||
so that we can display the subview. */
|
|
||||||
intersection = NSIntersectionRect (rect, subviewFrame);
|
|
||||||
if (intersection.origin.x || intersection.origin.y
|
|
||||||
|| intersection.size.width || intersection.size.height) {
|
|
||||||
/* Convert the intersection rectangle to the subview's coordinates */
|
|
||||||
intersection = [subview convertRect:intersection fromView:self];
|
|
||||||
[subview displayRect:intersection];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)displayRectIgnoringOpacity:(NSRect)aRect
|
- (void)displayRectIgnoringOpacity:(NSRect)aRect
|
||||||
|
@ -871,35 +876,35 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_addSubviewForNeedingDisplay:(NSView*)view
|
- (void)_addSubviewForNeedingDisplay:(NSView*)view
|
||||||
{
|
{ // Add view to the list of
|
||||||
NSView* currentView;
|
NSView* currentView; // sibling subviews that
|
||||||
|
// need display.
|
||||||
|
currentView = _subviewsThatNeedDisplay;
|
||||||
|
while (currentView) // do nothing if the view
|
||||||
|
{ // is already in self's
|
||||||
|
if (currentView == view) // list.
|
||||||
|
return;
|
||||||
|
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
||||||
|
}
|
||||||
|
// view is not in the list of subviews that need display.
|
||||||
|
// Concatenate self's list of subviews that need display to
|
||||||
|
// the view's list of siblings subviews that need display.
|
||||||
|
|
||||||
/* Add view in the list of sibling subviews that need display. First
|
// find the last element in the view's
|
||||||
check if view is not already there. */
|
currentView = view; // list of siblings that need display
|
||||||
currentView = _subviewsThatNeedDisplay;
|
while (currentView->_nextSiblingSubviewThatNeedsDisplay)
|
||||||
while (currentView) {
|
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
||||||
if (currentView == view)
|
|
||||||
return;
|
|
||||||
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* view is not in the list of subviews that need display; add it.
|
// link the lists by assigning to view's
|
||||||
To do this concatenate the "view"'s list of siblings to the list of
|
// _nextSiblingSubviewThatNeedsDisplay ivar
|
||||||
subviews. Find the last element in the "view"'s list of siblings and
|
// self's _subviewsThatNeedDisplay ivar.
|
||||||
assign to its _nextSiblingSubviewThatNeedsDisplay ivar the first element
|
currentView->_nextSiblingSubviewThatNeedsDisplay =_subviewsThatNeedDisplay;
|
||||||
of the subviews that need display list in self.
|
_subviewsThatNeedDisplay = view;
|
||||||
*/
|
|
||||||
currentView = view;
|
|
||||||
while (currentView->_nextSiblingSubviewThatNeedsDisplay)
|
|
||||||
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
|
||||||
|
|
||||||
currentView->_nextSiblingSubviewThatNeedsDisplay = _subviewsThatNeedDisplay;
|
// Add recursively using the same algorithm with
|
||||||
_subviewsThatNeedDisplay = view;
|
needs_display = YES; // self. This way we'll create a subtree of views
|
||||||
|
if (super_view) // that need display inside the views hierarchy.
|
||||||
/* Now add recursively do the same algorithm with self. This way we'll create
|
[super_view _addSubviewForNeedingDisplay:self];
|
||||||
a subtree of views that need display inside the views hierarchy. */
|
|
||||||
if (super_view)
|
|
||||||
[super_view _addSubviewForNeedingDisplay:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_removeSubviewFromViewsThatNeedDisplay:(NSView*)view
|
- (void)_removeSubviewFromViewsThatNeedDisplay:(NSView*)view
|
||||||
|
@ -935,7 +940,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
||||||
{
|
{
|
||||||
needs_display = flag;
|
needs_display = flag;
|
||||||
if (needs_display) {
|
if (needs_display) {
|
||||||
// NSLog (@"NSView setNeedsDisplay:");
|
|
||||||
invalidatedRectangle = bounds;
|
invalidatedRectangle = bounds;
|
||||||
[window _setNeedsDisplay];
|
[window _setNeedsDisplay];
|
||||||
|
|
||||||
|
@ -946,7 +951,6 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
||||||
|
|
||||||
- (void)setNeedsDisplayInRect:(NSRect)rect
|
- (void)setNeedsDisplayInRect:(NSRect)rect
|
||||||
{
|
{
|
||||||
// NSLog (@"NSView setNeedsDisplayInRect:");
|
|
||||||
needs_display = YES;
|
needs_display = YES;
|
||||||
invalidatedRectangle = NSUnionRect (invalidatedRectangle, rect);
|
invalidatedRectangle = NSUnionRect (invalidatedRectangle, rect);
|
||||||
[window _setNeedsDisplay];
|
[window _setNeedsDisplay];
|
||||||
|
|
|
@ -583,19 +583,16 @@ static BOOL _needsFlushWindows = YES;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)frameRect
|
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
|
||||||
display:(BOOL)flag
|
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
frame = frameRect;
|
frame = frameRect;
|
||||||
|
// post notification
|
||||||
// post notification
|
|
||||||
[nc postNotificationName: NSWindowDidResizeNotification object: self];
|
[nc postNotificationName: NSWindowDidResizeNotification object: self];
|
||||||
|
|
||||||
// display if requested
|
if (flag) // display if requested
|
||||||
if (!flag) return;
|
[self display];
|
||||||
[self display];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameOrigin:(NSPoint)aPoint
|
- (void)setFrameOrigin:(NSPoint)aPoint
|
||||||
|
@ -730,9 +727,16 @@ static BOOL _needsFlushWindows = YES;
|
||||||
|
|
||||||
- (void)update
|
- (void)update
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
|
if(is_autodisplay && needs_display) // if autodisplay is
|
||||||
|
{ // enabled
|
||||||
|
[self _collectFlushRectangles];
|
||||||
|
[self displayIfNeeded];
|
||||||
|
[self flushWindowIfNeeded];
|
||||||
|
}
|
||||||
|
|
||||||
|
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)useOptimizedDrawing:(BOOL)flag
|
- (void)useOptimizedDrawing:(BOOL)flag
|
||||||
|
@ -1587,15 +1591,17 @@ static BOOL _needsFlushWindows = YES;
|
||||||
// NSLog (@"_flushWindows");
|
// NSLog (@"_flushWindows");
|
||||||
|
|
||||||
windowList = [[NSApplication sharedApplication] windows];
|
windowList = [[NSApplication sharedApplication] windows];
|
||||||
|
|
||||||
for (i = 0, count = [windowList count]; i < count; i++) {
|
for (i = 0, count = [windowList count]; i < count; i++)
|
||||||
|
{
|
||||||
NSWindow* window = [windowList objectAtIndex:i];
|
NSWindow* window = [windowList objectAtIndex:i];
|
||||||
|
|
||||||
if (window->needs_display || window->needs_flush) {
|
if (window->needs_display || window->needs_flush)
|
||||||
[window _collectFlushRectangles];
|
{
|
||||||
[window displayIfNeeded];
|
[window _collectFlushRectangles];
|
||||||
[window flushWindowIfNeeded];
|
[window displayIfNeeded];
|
||||||
}
|
[window flushWindowIfNeeded];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_needsFlushWindows = NO;
|
_needsFlushWindows = NO;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue