mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Many bugfixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ee210229a6
commit
a57f809bd6
8 changed files with 1594 additions and 1231 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
Thu Feb 18 13:12:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Headers/AppKit/NSView.h: Listed all private methods allong with
|
||||
a warning that they shouldn't be overridden. Removed a couple of
|
||||
unused ivars. Added two new ivars - a cache for the visible rectangle
|
||||
and a flag to say whether it (and when we add it, a matrix to map
|
||||
to and from window coordinates) is currently valid.
|
||||
Added ([-_invalidateCoordinates]) method declaration.
|
||||
* Source/NSView.m: Much tidying up. Added ([-__invalidateCoordinates]).
|
||||
Modified ([-visibleRect]) to cache the visible rect and to clip the
|
||||
invalid rect. Speeded up iterations over all subviews etc.
|
||||
Fix error in redisplay causing occasional excess redisplay.
|
||||
* Source/NSSplitView.m: Corrected orientation of dividers.
|
||||
* Source/NSBrowser.m: Tidied - use setNeedsDisplay.
|
||||
* Source/NSBrowserCell.m: Tidied and fixed bugs in decoding.
|
||||
* Source/NSCell.m: Tidied and fixed bugs in decoding and setting
|
||||
editable/selectable status.
|
||||
* Source/NSScroller.m: Tidy a little.
|
||||
|
||||
Thu Feb 18 1999 Felipe A. Rodriguez <farz@mindspring.com>
|
||||
|
||||
* NSView.m display: fix for display bug in buttons example
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
NSView.h
|
||||
|
||||
The wonderful view class; it encapsulates all drawing functionality
|
||||
|
@ -11,14 +11,14 @@
|
|||
Date: 1997
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Date: August 1998
|
||||
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
@ -28,7 +28,7 @@
|
|||
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.
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSView
|
||||
#define _GNUstep_H_NSView
|
||||
|
@ -50,22 +50,23 @@
|
|||
|
||||
typedef int NSTrackingRectTag;
|
||||
|
||||
typedef enum _NSBorderType { // constants representing the
|
||||
NSNoBorder, // four types of borders that
|
||||
NSLineBorder, // can appear around an NSView
|
||||
NSBezelBorder,
|
||||
NSGrooveBorder
|
||||
typedef enum _NSBorderType { // constants representing the
|
||||
NSNoBorder, // four types of borders that
|
||||
NSLineBorder, // can appear around an NSView
|
||||
NSBezelBorder,
|
||||
NSGrooveBorder
|
||||
} NSBorderType;
|
||||
// autoresize constants which NSView uses in
|
||||
// determining the parts of a view which are
|
||||
enum { // resized when the view's superview is resized
|
||||
NSViewNotSizable = 0, // view does not resize with its superview
|
||||
NSViewMinXMargin = 1, // left margin between views can stretch
|
||||
NSViewWidthSizable = 2, // view's width can stretch
|
||||
NSViewMaxXMargin = 4, // right margin between views can stretch
|
||||
NSViewMinYMargin = 8, // top margin between views can stretch
|
||||
NSViewHeightSizable = 16, // view's height can stretch
|
||||
NSViewMaxYMargin = 32 // bottom margin between views can stretch
|
||||
// autoresize constants which NSView uses in
|
||||
// determining the parts of a view which are
|
||||
// resized when the view's superview is resized
|
||||
enum {
|
||||
NSViewNotSizable = 0, // view does not resize with its superview
|
||||
NSViewMinXMargin = 1, // left margin between views can stretch
|
||||
NSViewWidthSizable = 2, // view's width can stretch
|
||||
NSViewMaxXMargin = 4, // right margin between views can stretch
|
||||
NSViewMinYMargin = 8, // top margin between views can stretch
|
||||
NSViewHeightSizable = 16, // view's height can stretch
|
||||
NSViewMaxYMargin = 32 // bottom margin between views can stretch
|
||||
};
|
||||
|
||||
@interface NSView : NSResponder <NSCoding>
|
||||
|
@ -82,6 +83,7 @@ enum { // resized when the view's superview is resized
|
|||
NSMutableArray *tracking_rects;
|
||||
NSMutableArray *cursor_rects;
|
||||
NSRect invalidRect;
|
||||
NSRect visibleRect;
|
||||
unsigned int autoresizingMask;
|
||||
|
||||
BOOL is_rotated_from_base;
|
||||
|
@ -91,22 +93,19 @@ enum { // resized when the view's superview is resized
|
|||
BOOL post_frame_changes;
|
||||
BOOL post_bounds_changes;
|
||||
BOOL autoresize_subviews;
|
||||
|
||||
NSView* _nextSiblingSubviewThatNeedsDisplay;
|
||||
/* NULL if no sibling view needs display */
|
||||
NSView* _subviewsThatNeedDisplay;
|
||||
BOOL coordinates_valid;
|
||||
|
||||
// Reserved for back-end use
|
||||
void *be_view_reserved;
|
||||
}
|
||||
|
||||
//
|
||||
//Initializing NSView Objects
|
||||
//Initializing NSView Objects
|
||||
//
|
||||
- (id)initWithFrame:(NSRect)frameRect;
|
||||
|
||||
//
|
||||
// Managing the NSView Hierarchy
|
||||
// Managing the NSView Hierarchy
|
||||
//
|
||||
- (void)addSubview:(NSView *)aView;
|
||||
- (void)addSubview:(NSView *)aView
|
||||
|
@ -118,7 +117,7 @@ enum { // resized when the view's superview is resized
|
|||
- (void)removeFromSuperview;
|
||||
- (void)replaceSubview:(NSView *)oldView
|
||||
with:(NSView *)newView;
|
||||
- (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare
|
||||
- (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare
|
||||
context:(void *)context;
|
||||
- (NSMutableArray *)subviews;
|
||||
- (NSView *)superview;
|
||||
|
@ -127,7 +126,7 @@ enum { // resized when the view's superview is resized
|
|||
- (void)viewWillMoveToWindow:(NSWindow *)newWindow;
|
||||
|
||||
//
|
||||
// Modifying the Frame Rectangle
|
||||
// Modifying the Frame Rectangle
|
||||
//
|
||||
- (float)frameRotation;
|
||||
- (NSRect)frame;
|
||||
|
@ -138,7 +137,7 @@ enum { // resized when the view's superview is resized
|
|||
- (void)setFrameSize:(NSSize)newSize;
|
||||
|
||||
//
|
||||
// Modifying the Coordinate System
|
||||
// Modifying the Coordinate System
|
||||
//
|
||||
|
||||
- (float)boundsRotation;
|
||||
|
@ -154,7 +153,7 @@ enum { // resized when the view's superview is resized
|
|||
- (void)translateOriginToPoint:(NSPoint)point;
|
||||
|
||||
//
|
||||
// Converting Coordinates
|
||||
// Converting Coordinates
|
||||
//
|
||||
- (NSRect)centerScanRect:(NSRect)aRect;
|
||||
- (NSPoint)convertPoint:(NSPoint)aPoint
|
||||
|
@ -171,7 +170,7 @@ enum { // resized when the view's superview is resized
|
|||
toView:(NSView *)aView;
|
||||
|
||||
//
|
||||
// Notifying Ancestor Views
|
||||
// Notifying Ancestor Views
|
||||
//
|
||||
- (void)setPostsFrameChangedNotifications:(BOOL)flag;
|
||||
- (BOOL)postsFrameChangedNotifications;
|
||||
|
@ -179,7 +178,7 @@ enum { // resized when the view's superview is resized
|
|||
- (BOOL)postsBoundsChangedNotifications;
|
||||
|
||||
//
|
||||
// Resizing Subviews
|
||||
// Resizing Subviews
|
||||
//
|
||||
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize;
|
||||
- (void)setAutoresizesSubviews:(BOOL)flag;
|
||||
|
@ -189,7 +188,7 @@ enum { // resized when the view's superview is resized
|
|||
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize;
|
||||
|
||||
//
|
||||
// Graphics State Objects
|
||||
// Graphics State Objects
|
||||
//
|
||||
- (void)allocateGState;
|
||||
- (void)releaseGState;
|
||||
|
@ -198,14 +197,14 @@ enum { // resized when the view's superview is resized
|
|||
- (void)setUpGState;
|
||||
|
||||
//
|
||||
// Focusing
|
||||
// Focusing
|
||||
//
|
||||
+ (NSView *)focusView;
|
||||
- (void)lockFocus;
|
||||
- (void)unlockFocus;
|
||||
|
||||
//
|
||||
// Displaying
|
||||
// Displaying
|
||||
//
|
||||
- (BOOL) canDraw;
|
||||
- (void) display;
|
||||
|
@ -224,7 +223,7 @@ enum { // resized when the view's superview is resized
|
|||
- (BOOL) shouldDrawColor;
|
||||
|
||||
//
|
||||
// Scrolling
|
||||
// Scrolling
|
||||
//
|
||||
- (NSRect)adjustScroll:(NSRect)newVisible;
|
||||
- (BOOL)autoscroll:(NSEvent *)theEvent;
|
||||
|
@ -237,7 +236,7 @@ enum { // resized when the view's superview is resized
|
|||
- (BOOL)scrollRectToVisible:(NSRect)aRect;
|
||||
|
||||
//
|
||||
// Managing the Cursor
|
||||
// Managing the Cursor
|
||||
//
|
||||
- (void)addCursorRect:(NSRect)aRect
|
||||
cursor:(NSCursor *)anObject;
|
||||
|
@ -248,13 +247,13 @@ enum { // resized when the view's superview is resized
|
|||
- (NSArray *)cursorRectangles;
|
||||
|
||||
//
|
||||
// Assigning a Tag
|
||||
// Assigning a Tag
|
||||
//
|
||||
- (int)tag;
|
||||
- (id)viewWithTag:(int)aTag;
|
||||
|
||||
//
|
||||
// Aiding Event Handling
|
||||
// Aiding Event Handling
|
||||
//
|
||||
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
|
||||
- (NSView *)hitTest:(NSPoint)aPoint;
|
||||
|
@ -270,7 +269,7 @@ enum { // resized when the view's superview is resized
|
|||
- (NSArray *)trackingRectangles;
|
||||
|
||||
//
|
||||
// Dragging
|
||||
// Dragging
|
||||
//
|
||||
- (BOOL)dragFile:(NSString *)filename
|
||||
fromRect:(NSRect)rect
|
||||
|
@ -296,7 +295,7 @@ enum { // resized when the view's superview is resized
|
|||
toPasteboard:(NSPasteboard *)pasteboard;
|
||||
|
||||
//
|
||||
// Pagination
|
||||
// Pagination
|
||||
//
|
||||
- (void)adjustPageHeightNew:(float *)newBottom
|
||||
top:(float)oldTop
|
||||
|
@ -304,7 +303,7 @@ enum { // resized when the view's superview is resized
|
|||
limit:(float)bottomLimit;
|
||||
- (void)adjustPageWidthNew:(float *)newRight
|
||||
left:(float)oldLeft
|
||||
right:(float)oldRight
|
||||
right:(float)oldRight
|
||||
limit:(float)rightLimit;
|
||||
- (float)heightAdjustLimit;
|
||||
- (BOOL)knowsPagesFirst:(int *)firstPageNum
|
||||
|
@ -314,7 +313,7 @@ enum { // resized when the view's superview is resized
|
|||
- (float)widthAdjustLimit;
|
||||
|
||||
//
|
||||
// Writing Conforming PostScript
|
||||
// Writing Conforming PostScript
|
||||
//
|
||||
- (void)addToPageSetup;
|
||||
- (void)beginPage:(int)ordinalNum
|
||||
|
@ -354,15 +353,34 @@ enum { // resized when the view's superview is resized
|
|||
|
||||
//
|
||||
// GNUstep extensions
|
||||
//
|
||||
// Methods whose names begin with an underscore must NOT be overridden.
|
||||
//
|
||||
#ifndef NO_GNUSTEP
|
||||
@interface NSView (PrivateMethods)
|
||||
// If the view is rotated returns
|
||||
- (NSRect)_boundingRectFor:(NSRect)rect; // the bounding box of the rect in
|
||||
// the "normal" coordinates
|
||||
|
||||
/*
|
||||
* If the view is rotated, [-_boundingRectFor:] returns the bounding box
|
||||
* of the rect in the "normal" coordinates
|
||||
*/
|
||||
- (NSRect) _boundingRectFor: (NSRect)rect;
|
||||
|
||||
/*
|
||||
* The [-_invalidateCoordinates] method marks the cached visible rectangles
|
||||
* of the view and it's subview as being invalid. NSViews methods call this
|
||||
* whenever the coordinate system of the view is changed in any way - thus
|
||||
* forcing recalculation of cached values next time they are needed.
|
||||
*/
|
||||
- (void) _invalidateCoordinates;
|
||||
|
||||
|
||||
- (PSMatrix*)_frameMatrix;
|
||||
- (PSMatrix*)_boundsMatrix;
|
||||
|
||||
- (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)p;
|
||||
- (PSMatrix*) _concatenateMatricesInReverseOrderFromPath: (NSArray*)p;
|
||||
- (NSMutableArray*) _pathBetweenSubview: (NSView*)subview
|
||||
toSuperview: (NSView*)superview;
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
||||
/* Notifications */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
NSBrowser.m
|
||||
|
||||
Control to display and select from hierarchal lists
|
||||
|
@ -9,14 +9,14 @@
|
|||
Date: 1996
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Date: August 1998
|
||||
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
@ -26,7 +26,7 @@
|
|||
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.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSBrowser.h>
|
||||
|
@ -72,7 +72,7 @@
|
|||
|
||||
@implementation NSBrowserColumn
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
|
||||
|
@ -82,7 +82,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
[_columnScrollView release];
|
||||
[_columnMatrix release];
|
||||
|
@ -91,21 +91,19 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setIsLoaded:(BOOL)flag
|
||||
- (void) setIsLoaded: (BOOL)flag
|
||||
{
|
||||
_isLoaded = flag;
|
||||
}
|
||||
|
||||
- (BOOL)isLoaded
|
||||
- (BOOL) isLoaded
|
||||
{
|
||||
return _isLoaded;
|
||||
}
|
||||
|
||||
- (void)setColumnScrollView:(id)aView
|
||||
- (void) setColumnScrollView: (id)aView
|
||||
{
|
||||
[aView retain];
|
||||
[_columnScrollView release];
|
||||
_columnScrollView = aView;
|
||||
ASSIGN(_columnScrollView, aView);
|
||||
}
|
||||
|
||||
- columnScrollView
|
||||
|
@ -113,11 +111,9 @@
|
|||
return _columnScrollView;
|
||||
}
|
||||
|
||||
- (void)setColumnMatrix:(id)aMatrix
|
||||
- (void)setColumnMatrix: (id)aMatrix
|
||||
{
|
||||
[aMatrix retain];
|
||||
[_columnMatrix release];
|
||||
_columnMatrix = aMatrix;
|
||||
ASSIGN(_columnMatrix, aMatrix);
|
||||
}
|
||||
|
||||
- columnMatrix
|
||||
|
@ -125,7 +121,7 @@
|
|||
return _columnMatrix;
|
||||
}
|
||||
|
||||
- (void)setNumberOfRows:(int)num
|
||||
- (void) setNumberOfRows: (int)num
|
||||
{
|
||||
_numberOfRows = num;
|
||||
}
|
||||
|
@ -135,7 +131,7 @@
|
|||
return _numberOfRows;
|
||||
}
|
||||
|
||||
- (void)setColumnTitle:(NSString *)aString
|
||||
- (void)setColumnTitle: (NSString *)aString
|
||||
{
|
||||
[aString retain];
|
||||
[_columnTitle release];
|
||||
|
@ -158,11 +154,11 @@
|
|||
// Private NSBrowser methods
|
||||
//
|
||||
@interface NSBrowser (Private)
|
||||
- (void)_adjustMatrixOfColumn:(int)column;
|
||||
- (void)_adjustScrollerFrameOfColumn:(int)column force:(BOOL)flag;
|
||||
- (void)_adjustScrollerFrames:(BOOL)flag;
|
||||
- (void)_performLoadOfColumn:(int)column;
|
||||
- (void)_unloadFromColumn:(int)column;
|
||||
- (void)_adjustMatrixOfColumn: (int)column;
|
||||
- (void)_adjustScrollerFrameOfColumn: (int)column force:(BOOL)flag;
|
||||
- (void)_adjustScrollerFrames: (BOOL)flag;
|
||||
- (void)_performLoadOfColumn: (int)column;
|
||||
- (void)_unloadFromColumn: (int)column;
|
||||
@end
|
||||
|
||||
//
|
||||
|
@ -178,12 +174,12 @@
|
|||
if (self == [NSBrowser class])
|
||||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
[self setVersion: 1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Component Classes
|
||||
// Setting Component Classes
|
||||
//
|
||||
+ (Class)cellClass
|
||||
{
|
||||
|
@ -193,7 +189,7 @@
|
|||
//
|
||||
// Instance methods
|
||||
//
|
||||
- initWithFrame:(NSRect)rect
|
||||
- initWithFrame: (NSRect)rect
|
||||
{
|
||||
NSSize bs;
|
||||
NSRect scroller_rect;
|
||||
|
@ -261,33 +257,33 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Setting the Delegate
|
||||
// Setting the Delegate
|
||||
//
|
||||
- (id)delegate
|
||||
{
|
||||
return _browserDelegate;
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id)anObject
|
||||
- (void)setDelegate: (id)anObject
|
||||
{
|
||||
BOOL flag = NO;
|
||||
BOOL both = NO;
|
||||
|
||||
if (![anObject respondsToSelector:
|
||||
@selector(browser:willDisplayCell:atRow:column:)])
|
||||
@selector(browser: willDisplayCell:atRow:column:)])
|
||||
[NSException raise: NSBrowserIllegalDelegateException
|
||||
format: @"Delegate does not respond to %s\n",
|
||||
"browser:willDisplayCell:atRow:column:"];
|
||||
"browser: willDisplayCell:atRow:column:"];
|
||||
|
||||
if ([anObject respondsToSelector:
|
||||
@selector(browser:numberOfRowsInColumn:)])
|
||||
@selector(browser: numberOfRowsInColumn:)])
|
||||
{
|
||||
_passiveDelegate = YES;
|
||||
flag = YES;
|
||||
}
|
||||
|
||||
if ([anObject respondsToSelector:
|
||||
@selector(browser:createRowsForColumn:inMatrix:)])
|
||||
@selector(browser: createRowsForColumn:inMatrix:)])
|
||||
{
|
||||
_passiveDelegate = NO;
|
||||
|
||||
|
@ -302,14 +298,14 @@
|
|||
if (!flag)
|
||||
[NSException raise: NSBrowserIllegalDelegateException
|
||||
format: @"Delegate does not respond to %s or %s\n",
|
||||
"browser:numberOfRowsInColumn:",
|
||||
"browser:createRowsForColumn:inMatrix:"];
|
||||
"browser: numberOfRowsInColumn:",
|
||||
"browser: createRowsForColumn:inMatrix:"];
|
||||
|
||||
if (both)
|
||||
[NSException raise: NSBrowserIllegalDelegateException
|
||||
format: @"Delegate responds to both %s and %s\n",
|
||||
"browser:numberOfRowsInColumn:",
|
||||
"browser:createRowsForColumn:inMatrix:"];
|
||||
"browser: numberOfRowsInColumn:",
|
||||
"browser: createRowsForColumn:inMatrix:"];
|
||||
|
||||
[anObject retain];
|
||||
[_browserDelegate release];
|
||||
|
@ -317,7 +313,7 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Target and Action
|
||||
// Target and Action
|
||||
//
|
||||
- (SEL)doubleAction
|
||||
{
|
||||
|
@ -329,13 +325,13 @@
|
|||
return [self sendAction: [self action] to: [self target]];
|
||||
}
|
||||
|
||||
- (void)setDoubleAction:(SEL)aSelector
|
||||
- (void)setDoubleAction: (SEL)aSelector
|
||||
{
|
||||
_doubleAction = aSelector;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Component Classes
|
||||
// Setting Component Classes
|
||||
//
|
||||
- (id)cellPrototype
|
||||
{
|
||||
|
@ -347,7 +343,7 @@
|
|||
return _browserMatrixClass;
|
||||
}
|
||||
|
||||
- (void)setCellClass:(Class)classId
|
||||
- (void)setCellClass: (Class)classId
|
||||
{
|
||||
_browserCellClass = classId;
|
||||
|
||||
|
@ -355,32 +351,32 @@
|
|||
[self setCellPrototype: [[[_browserCellClass alloc] init] autorelease]];
|
||||
}
|
||||
|
||||
- (void)setCellPrototype:(NSCell *)aCell
|
||||
- (void)setCellPrototype: (NSCell *)aCell
|
||||
{
|
||||
[aCell retain];
|
||||
[_browserCellPrototype release];
|
||||
_browserCellPrototype = aCell;
|
||||
}
|
||||
|
||||
- (void)setMatrixClass:(Class)classId
|
||||
- (void)setMatrixClass: (Class)classId
|
||||
{
|
||||
_browserMatrixClass = classId;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting NSBrowser Behavior
|
||||
// Setting NSBrowser Behavior
|
||||
//
|
||||
- (BOOL)reusesColumns
|
||||
{
|
||||
return _reusesColumns;
|
||||
}
|
||||
|
||||
- (void)setReusesColumns:(BOOL)flag
|
||||
- (void)setReusesColumns: (BOOL)flag
|
||||
{
|
||||
_reusesColumns = flag;
|
||||
}
|
||||
|
||||
- (void)setTakesTitleFromPreviousColumn:(BOOL)flag
|
||||
- (void)setTakesTitleFromPreviousColumn: (BOOL)flag
|
||||
{
|
||||
_takesTitleFromPreviousColumn = flag;
|
||||
}
|
||||
|
@ -391,7 +387,7 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Allowing Different Types of Selection
|
||||
// Allowing Different Types of Selection
|
||||
//
|
||||
- (BOOL)allowsBranchSelection
|
||||
{
|
||||
|
@ -408,17 +404,17 @@
|
|||
return _allowsMultipleSelection;
|
||||
}
|
||||
|
||||
- (void)setAllowsBranchSelection:(BOOL)flag
|
||||
- (void)setAllowsBranchSelection: (BOOL)flag
|
||||
{
|
||||
_allowsBranchSelection = flag;
|
||||
}
|
||||
|
||||
- (void)setAllowsEmptySelection:(BOOL)flag
|
||||
- (void)setAllowsEmptySelection: (BOOL)flag
|
||||
{
|
||||
_allowsEmptySelection = flag;
|
||||
}
|
||||
|
||||
- (void)setAllowsMultipleSelection:(BOOL)flag
|
||||
- (void)setAllowsMultipleSelection: (BOOL)flag
|
||||
{
|
||||
_allowsMultipleSelection = flag;
|
||||
}
|
||||
|
@ -436,20 +432,20 @@
|
|||
return _sendsActionOnArrowKeys;
|
||||
}
|
||||
|
||||
- (void)setAcceptsArrowKeys:(BOOL)flag
|
||||
- (void)setAcceptsArrowKeys: (BOOL)flag
|
||||
{
|
||||
_acceptsArrowKeys = flag;
|
||||
}
|
||||
|
||||
- (void)setSendsActionOnArrowKeys:(BOOL)flag
|
||||
- (void)setSendsActionOnArrowKeys: (BOOL)flag
|
||||
{
|
||||
_sendsActionOnArrowKeys = flag;
|
||||
}
|
||||
|
||||
//
|
||||
// Showing a Horizontal Scroller
|
||||
// Showing a Horizontal Scroller
|
||||
//
|
||||
- (void)setHasHorizontalScroller:(BOOL)flag
|
||||
- (void)setHasHorizontalScroller: (BOOL)flag
|
||||
{
|
||||
_hasHorizontalScroller = flag;
|
||||
|
||||
|
@ -465,7 +461,7 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Setting the NSBrowser's Appearance
|
||||
// Setting the NSBrowser's Appearance
|
||||
//
|
||||
- (int)maxVisibleColumns
|
||||
{
|
||||
|
@ -482,7 +478,7 @@
|
|||
return _separatesColumns;
|
||||
}
|
||||
|
||||
- (void)setMaxVisibleColumns:(int)columnCount
|
||||
- (void)setMaxVisibleColumns: (int)columnCount
|
||||
{
|
||||
int i, count = [_browserColumns count];
|
||||
|
||||
|
@ -498,7 +494,7 @@
|
|||
[self _adjustScrollerFrames: NO];
|
||||
}
|
||||
|
||||
- (void)setMinColumnWidth:(int)columnWidth
|
||||
- (void)setMinColumnWidth: (int)columnWidth
|
||||
{
|
||||
float sw = [NSScroller scrollerWidth];
|
||||
NSSize bs = [NSCell sizeForBorderType: NSBezelBorder];
|
||||
|
@ -517,7 +513,7 @@
|
|||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setSeparatesColumns:(BOOL)flag
|
||||
- (void)setSeparatesColumns: (BOOL)flag
|
||||
{
|
||||
_separatesColumns = flag;
|
||||
|
||||
|
@ -525,7 +521,7 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Manipulating Columns
|
||||
// Manipulating Columns
|
||||
//
|
||||
- (void)addColumn
|
||||
{
|
||||
|
@ -547,7 +543,7 @@
|
|||
[_browserColumns addObject: bc];
|
||||
}
|
||||
|
||||
- (int)columnOfMatrix:(NSMatrix *)matrix
|
||||
- (int)columnOfMatrix: (NSMatrix *)matrix
|
||||
{
|
||||
NSBrowserColumn *bc;
|
||||
int i, count = [_browserColumns count];
|
||||
|
@ -564,7 +560,7 @@
|
|||
return NSNotFound;
|
||||
}
|
||||
|
||||
- (void)displayAllColumns
|
||||
- (void) displayAllColumns
|
||||
{
|
||||
int i, count = [_browserColumns count];
|
||||
|
||||
|
@ -578,7 +574,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)displayColumn:(int)column
|
||||
- (void) displayColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc;
|
||||
|
||||
|
@ -590,7 +586,7 @@
|
|||
|
||||
// Ask the delegate for the column title
|
||||
if ([_browserDelegate respondsToSelector:
|
||||
@selector(browser:titleOfColumn:)])
|
||||
@selector(browser: titleOfColumn:)])
|
||||
[self setTitle: [_browserDelegate browser: self
|
||||
titleOfColumn: column]
|
||||
ofColumn: column];
|
||||
|
@ -695,7 +691,7 @@
|
|||
return i + 1;
|
||||
}
|
||||
|
||||
- (void)reloadColumn:(int)column
|
||||
- (void)reloadColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc;
|
||||
|
||||
|
@ -719,7 +715,7 @@
|
|||
[self setLastColumn: column];
|
||||
}
|
||||
|
||||
- (void)selectAll:(id)sender
|
||||
- (void)selectAll: (id)sender
|
||||
{
|
||||
id matrix = [self matrixInColumn: _lastVisibleColumn];
|
||||
[matrix selectAll: sender];
|
||||
|
@ -754,7 +750,7 @@
|
|||
return [[self matrixInColumn: column] selectedRow];
|
||||
}
|
||||
|
||||
- (void)setLastColumn:(int)column
|
||||
- (void)setLastColumn: (int)column
|
||||
{
|
||||
_lastColumnLoaded = column;
|
||||
}
|
||||
|
@ -765,7 +761,7 @@
|
|||
|
||||
// xxx Should we trigger an exception?
|
||||
if (![_browserDelegate respondsToSelector:
|
||||
@selector(browser:isColumnValid:)])
|
||||
@selector(browser: isColumnValid:)])
|
||||
return;
|
||||
|
||||
// Loop through the visible columns
|
||||
|
@ -780,11 +776,11 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Manipulating Column Titles
|
||||
// Manipulating Column Titles
|
||||
//
|
||||
- (void)drawTitle:(NSString *)title
|
||||
inRect:(NSRect)aRect
|
||||
ofColumn:(int)column
|
||||
- (void)drawTitle: (NSString *)title
|
||||
inRect: (NSRect)aRect
|
||||
ofColumn: (int)column
|
||||
{
|
||||
// Not titled then nothing to draw
|
||||
if (![self isTitled])
|
||||
|
@ -803,15 +799,15 @@
|
|||
return _isTitled;
|
||||
}
|
||||
|
||||
- (void)setTitled:(BOOL)flag
|
||||
- (void)setTitled: (BOOL)flag
|
||||
{
|
||||
_isTitled = flag;
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString *)aString
|
||||
ofColumn:(int)column
|
||||
- (void)setTitle: (NSString *)aString
|
||||
ofColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc = [_browserColumns objectAtIndex: column];
|
||||
[bc setColumnTitle: aString];
|
||||
|
@ -823,7 +819,7 @@
|
|||
[self setNeedsDisplayInRect: [self titleFrameOfColumn: column]];
|
||||
}
|
||||
|
||||
- (NSRect)titleFrameOfColumn:(int)column
|
||||
- (NSRect)titleFrameOfColumn: (int)column
|
||||
{
|
||||
NSRect r;
|
||||
int n;
|
||||
|
@ -852,16 +848,16 @@
|
|||
return 24;
|
||||
}
|
||||
|
||||
- (NSString *)titleOfColumn:(int)column
|
||||
- (NSString *)titleOfColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc = [_browserColumns objectAtIndex: column];
|
||||
return [bc columnTitle];
|
||||
}
|
||||
|
||||
//
|
||||
// Scrolling an NSBrowser
|
||||
// Scrolling an NSBrowser
|
||||
//
|
||||
- (void)scrollColumnsLeftBy:(int)shiftAmount
|
||||
- (void)scrollColumnsLeftBy: (int)shiftAmount
|
||||
{
|
||||
// Cannot shift past the zero column
|
||||
if ((_firstVisibleColumn - shiftAmount) < 0)
|
||||
|
@ -890,7 +886,7 @@
|
|||
[_browserDelegate browserDidScroll: self];
|
||||
}
|
||||
|
||||
- (void)scrollColumnsRightBy:(int)shiftAmount
|
||||
- (void)scrollColumnsRightBy: (int)shiftAmount
|
||||
{
|
||||
// Cannot shift past the last loaded column
|
||||
if ((shiftAmount + _lastVisibleColumn) > _lastColumnLoaded)
|
||||
|
@ -919,7 +915,7 @@
|
|||
[_browserDelegate browserDidScroll: self];
|
||||
}
|
||||
|
||||
- (void)scrollColumnToVisible:(int)column
|
||||
- (void)scrollColumnToVisible: (int)column
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -939,7 +935,7 @@
|
|||
[self scrollColumnsRightBy: (-i)];
|
||||
}
|
||||
|
||||
- (void)scrollViaScroller:(NSScroller *)sender
|
||||
- (void)scrollViaScroller: (NSScroller *)sender
|
||||
{
|
||||
NSScrollerPart hit = [sender hitPart];
|
||||
|
||||
|
@ -984,7 +980,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)updateScroller
|
||||
- (void) updateScroller
|
||||
{
|
||||
// If there are not enough columns to scroll with
|
||||
// then the column must be visible
|
||||
|
@ -1000,15 +996,13 @@
|
|||
[_horizontalScroller setEnabled: YES];
|
||||
}
|
||||
|
||||
[self display]; // should probably be a setNeedsDisplay FIX ME?
|
||||
|
||||
return;
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
//
|
||||
// Event Handling
|
||||
// Event Handling
|
||||
//
|
||||
- (void)doClick:(id)sender
|
||||
- (void)doClick: (id)sender
|
||||
{
|
||||
int column = [self columnOfMatrix: sender];
|
||||
NSArray *a;
|
||||
|
@ -1020,7 +1014,7 @@
|
|||
|
||||
// Ask delegate if selection is ok
|
||||
if ([_browserDelegate respondsToSelector:
|
||||
@selector(browser:selectRow:inColumn:)])
|
||||
@selector(browser: selectRow:inColumn:)])
|
||||
{
|
||||
int row = [sender selectedRow];
|
||||
shouldSelect = [_browserDelegate browser: self selectRow: row
|
||||
|
@ -1030,7 +1024,7 @@
|
|||
{
|
||||
// Try the other method
|
||||
if ([_browserDelegate respondsToSelector:
|
||||
@selector(browser:selectCellWithString:inColumn:)])
|
||||
@selector(browser: selectCellWithString:inColumn:)])
|
||||
{
|
||||
id c = [sender selectedCell];
|
||||
shouldSelect = [_browserDelegate browser: self
|
||||
|
@ -1092,11 +1086,10 @@
|
|||
|
||||
// Send the action to target
|
||||
[self sendAction];
|
||||
|
||||
[self display]; // should probably be a setNeedsDisplay FIX ME?
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (void)doDoubleClick:(id)sender
|
||||
- (void)doDoubleClick: (id)sender
|
||||
{
|
||||
// We have already handled the single click
|
||||
// so send the double action
|
||||
|
@ -1104,10 +1097,10 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Getting Matrices and Cells
|
||||
// Getting Matrices and Cells
|
||||
//
|
||||
- (id)loadedCellAtRow:(int)row
|
||||
column:(int)column
|
||||
- (id)loadedCellAtRow: (int)row
|
||||
column: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc;
|
||||
NSArray *columnCells;
|
||||
|
@ -1144,7 +1137,7 @@
|
|||
return aCell;
|
||||
}
|
||||
|
||||
- (NSMatrix *)matrixInColumn:(int)column
|
||||
- (NSMatrix *)matrixInColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc = [_browserColumns objectAtIndex: column];
|
||||
return [bc columnMatrix];
|
||||
|
@ -1163,7 +1156,7 @@
|
|||
return [matrix selectedCell];
|
||||
}
|
||||
|
||||
- (id)selectedCellInColumn:(int)column
|
||||
- (id)selectedCellInColumn: (int)column
|
||||
{
|
||||
id matrix = [self matrixInColumn: column];
|
||||
return [matrix selectedCell];
|
||||
|
@ -1183,9 +1176,9 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Getting Column Frames
|
||||
// Getting Column Frames
|
||||
//
|
||||
- (NSRect)frameOfColumn:(int)column
|
||||
- (NSRect)frameOfColumn: (int)column
|
||||
{
|
||||
NSRect r = NSZeroRect;
|
||||
int n;
|
||||
|
@ -1207,14 +1200,14 @@
|
|||
return r;
|
||||
}
|
||||
|
||||
- (NSRect)frameOfInsideOfColumn:(int)column
|
||||
- (NSRect)frameOfInsideOfColumn: (int)column
|
||||
{
|
||||
// xxx what does this one do?
|
||||
return [self frameOfColumn: column];
|
||||
}
|
||||
|
||||
//
|
||||
// Manipulating Paths
|
||||
// Manipulating Paths
|
||||
//
|
||||
- (NSString *)path
|
||||
{
|
||||
|
@ -1226,7 +1219,7 @@
|
|||
return _pathSeparator;
|
||||
}
|
||||
|
||||
- (NSString *)pathToColumn:(int)column
|
||||
- (NSString *)pathToColumn: (int)column
|
||||
{
|
||||
int i;
|
||||
NSMutableString *s = [NSMutableString stringWithCString: ""];
|
||||
|
@ -1247,12 +1240,12 @@
|
|||
return [[[NSString alloc] initWithString: s] autorelease];
|
||||
}
|
||||
|
||||
- (BOOL)setPath:(NSString *)path
|
||||
- (BOOL)setPath: (NSString *)path
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)setPathSeparator:(NSString *)aString
|
||||
- (void)setPathSeparator: (NSString *)aString
|
||||
{
|
||||
[aString retain];
|
||||
[_pathSeparator release];
|
||||
|
@ -1260,7 +1253,7 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Arranging an NSBrowser's Components
|
||||
// Arranging an NSBrowser's Components
|
||||
//
|
||||
- (void)tile
|
||||
{
|
||||
|
@ -1299,7 +1292,7 @@
|
|||
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)rect
|
||||
- (void)drawRect: (NSRect)rect
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1322,39 +1315,39 @@
|
|||
}
|
||||
|
||||
//
|
||||
// Displaying the Control and Cell
|
||||
// Displaying the Control and Cell
|
||||
//
|
||||
- (void)drawCell:(NSCell *)aCell
|
||||
- (void)drawCell: (NSCell *)aCell
|
||||
{
|
||||
}
|
||||
|
||||
- (void)drawCellInside:(NSCell *)aCell
|
||||
- (void)drawCellInside: (NSCell *)aCell
|
||||
{
|
||||
}
|
||||
|
||||
- (void)selectCell:(NSCell *)aCell
|
||||
- (void)selectCell: (NSCell *)aCell
|
||||
{
|
||||
}
|
||||
|
||||
- (void)updateCell:(NSCell *)aCell
|
||||
- (void)updateCell: (NSCell *)aCell
|
||||
{
|
||||
}
|
||||
|
||||
- (void)updateCellInside:(NSCell *)aCell
|
||||
- (void)updateCellInside: (NSCell *)aCell
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder
|
||||
- (void)encodeWithCoder: aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[super encodeWithCoder: aCoder];
|
||||
}
|
||||
|
||||
- initWithCoder:aDecoder
|
||||
- initWithCoder: aDecoder
|
||||
{
|
||||
[super initWithCoder:aDecoder];
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -1366,7 +1359,7 @@
|
|||
//
|
||||
@implementation NSBrowser (Private)
|
||||
|
||||
- (void)_adjustMatrixOfColumn:(int)column
|
||||
- (void)_adjustMatrixOfColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc;
|
||||
NSScrollView *sc;
|
||||
|
@ -1376,30 +1369,30 @@ NSRect mr;
|
|||
|
||||
if (column >= (int)[_browserColumns count])
|
||||
return;
|
||||
|
||||
|
||||
bc = [_browserColumns objectAtIndex: column];
|
||||
sc = [bc columnScrollView];
|
||||
matrix = [bc columnMatrix];
|
||||
// Adjust matrix to fit in scrollview
|
||||
if (sc && matrix && [bc isLoaded]) // do it only if column has been loaded
|
||||
{
|
||||
if (sc && matrix && [bc isLoaded]) // do it only if column has been loaded
|
||||
{
|
||||
cs = [sc contentSize];
|
||||
ms = [matrix cellSize];
|
||||
ms.width = cs.width;
|
||||
[matrix setCellSize: ms];
|
||||
mr = [matrix frame];
|
||||
|
||||
|
||||
if (mr.size.height < cs.height) // matrix smaller than
|
||||
{ // scrollview's content
|
||||
mr.origin.y = cs.height; // view requires origin
|
||||
[matrix setFrame: mr]; // adjustment for it to
|
||||
[matrix setFrame: mr]; // adjustment for it to
|
||||
} // appear at top
|
||||
|
||||
[sc setDocumentView: matrix];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_adjustScrollerFrameOfColumn:(int)column force:(BOOL)flag
|
||||
- (void)_adjustScrollerFrameOfColumn: (int)column force:(BOOL)flag
|
||||
{
|
||||
// Only if we've loaded the first column
|
||||
if ((_isLoaded) || (flag))
|
||||
|
@ -1421,7 +1414,7 @@ NSRect mr;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)_adjustScrollerFrames:(BOOL)force
|
||||
- (void)_adjustScrollerFrames: (BOOL)force
|
||||
{
|
||||
int i, count = [_browserColumns count];
|
||||
|
||||
|
@ -1460,7 +1453,7 @@ NSRect mr;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)_performLoadOfColumn:(int)column
|
||||
- (void)_performLoadOfColumn: (int)column
|
||||
{
|
||||
NSBrowserColumn *bc = [_browserColumns objectAtIndex: column];
|
||||
|
||||
|
@ -1541,7 +1534,7 @@ NSRect mr;
|
|||
[bc setIsLoaded: YES];
|
||||
}
|
||||
|
||||
- (void)_unloadFromColumn:(int)column
|
||||
- (void)_unloadFromColumn: (int)column
|
||||
{
|
||||
int i, count = [_browserColumns count];
|
||||
|
||||
|
@ -1561,12 +1554,12 @@ NSRect mr;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)frameRect
|
||||
- (void)setFrame: (NSRect)frameRect
|
||||
{
|
||||
NSLog (@"NSBrowser setFrame ");
|
||||
[super setFrame:frameRect];
|
||||
[super setFrame: frameRect];
|
||||
[self tile]; // recalc browser's elements
|
||||
[self _adjustScrollerFrames:YES]; // adjust browser's matrix
|
||||
[self _adjustScrollerFrames: YES]; // adjust browser's matrix
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
NSBrowserCell.m
|
||||
|
||||
Cell class for the NSBrowser
|
||||
|
@ -9,14 +9,14 @@
|
|||
Date: 1996
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Date: October 1998
|
||||
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
@ -26,7 +26,7 @@
|
|||
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.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
|
||||
|
@ -45,18 +45,26 @@ static NSImage *highlight_image;
|
|||
// Private methods
|
||||
//
|
||||
@interface NSBrowserCell (Private)
|
||||
- (void)setBranchImageCell:aCell;
|
||||
- (void)setHighlightBranchImageCell:aCell;
|
||||
- (void)setTextFieldCell:aCell;
|
||||
- (void) setBranchImageCell: aCell;
|
||||
- (void) setHighlightBranchImageCell: aCell;
|
||||
- (void) setTextFieldCell: aCell;
|
||||
@end
|
||||
|
||||
@implementation NSBrowserCell (Private)
|
||||
|
||||
- (void)setTextFieldCell:aCell { ASSIGN(_browserText, aCell); }
|
||||
- (void)setBranchImageCell:aCell { ASSIGN(_branchImage, aCell); }
|
||||
- (void)setHighlightBranchImageCell:aCell
|
||||
{
|
||||
ASSIGN(_highlightBranchImage, aCell);
|
||||
- (void) setTextFieldCell: aCell
|
||||
{
|
||||
ASSIGN(_browserText, aCell);
|
||||
}
|
||||
|
||||
- (void) setBranchImageCell: aCell
|
||||
{
|
||||
ASSIGN(_branchImage, aCell);
|
||||
}
|
||||
|
||||
- (void) setHighlightBranchImageCell: aCell
|
||||
{
|
||||
ASSIGN(_highlightBranchImage, aCell);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -64,7 +72,7 @@ static NSImage *highlight_image;
|
|||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NSBrowserCell
|
||||
// NSBrowserCell
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
|
@ -73,231 +81,272 @@ static NSImage *highlight_image;
|
|||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSBrowserCell class])
|
||||
{
|
||||
[self setVersion:1]; // The default images
|
||||
ASSIGN(branch_image, [NSImage imageNamed: @"common_ArrowRight"]);
|
||||
ASSIGN(highlight_image, [NSImage imageNamed: @"common_ArrowRightH"]);
|
||||
}
|
||||
if (self == [NSBrowserCell class])
|
||||
{
|
||||
[self setVersion: 1];
|
||||
ASSIGN(branch_image, [NSImage imageNamed: @"common_ArrowRight"]);
|
||||
ASSIGN(highlight_image, [NSImage imageNamed: @"common_ArrowRightH"]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Accessing Graphic Attributes
|
||||
// Accessing Graphic Attributes
|
||||
//
|
||||
+ (NSImage *)branchImage { return branch_image; }
|
||||
+ (NSImage *)highlightedBranchImage { return highlight_image; }
|
||||
+ (NSImage*) branchImage
|
||||
{
|
||||
return branch_image;
|
||||
}
|
||||
|
||||
+ (NSImage*) highlightedBranchImage
|
||||
{
|
||||
return highlight_image;
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- init
|
||||
{
|
||||
return [self initTextCell: @"aTitle"];
|
||||
}
|
||||
|
||||
- initTextCell:(NSString *)aString
|
||||
- (id) init
|
||||
{
|
||||
[super initTextCell: aString];
|
||||
// create image cells
|
||||
_branchImage = [[NSBrowserCell branchImage] retain];
|
||||
_highlightBranchImage = [[NSBrowserCell highlightedBranchImage] retain];
|
||||
// create the text cell
|
||||
_browserText = [[[NSCell alloc] initTextCell: aString] retain];
|
||||
[_browserText setEditable: NO];
|
||||
[_browserText setBordered: NO];
|
||||
[_browserText setAlignment:NSLeftTextAlignment];
|
||||
|
||||
_alternateImage = nil;
|
||||
_isLeaf = NO;
|
||||
_isLoaded = NO;
|
||||
|
||||
[self setEditable: YES];
|
||||
|
||||
return self;
|
||||
return [self initTextCell: @"aTitle"];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (id) initTextCell: (NSString *)aString
|
||||
{
|
||||
[_branchImage release];
|
||||
[_highlightBranchImage release];
|
||||
if(_alternateImage)
|
||||
[_alternateImage release];
|
||||
[_browserText release];
|
||||
|
||||
[super dealloc];
|
||||
[super initTextCell: aString];
|
||||
// create image cells
|
||||
_branchImage = [[NSBrowserCell branchImage] retain];
|
||||
_highlightBranchImage = [[NSBrowserCell highlightedBranchImage] retain];
|
||||
// create the text cell
|
||||
_browserText = [[[NSCell alloc] initTextCell: aString] retain];
|
||||
[_browserText setEditable: NO];
|
||||
[_browserText setBordered: NO];
|
||||
[_browserText setAlignment: NSLeftTextAlignment];
|
||||
|
||||
_alternateImage = nil;
|
||||
_isLeaf = NO;
|
||||
_isLoaded = NO;
|
||||
|
||||
[self setEditable: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone*)zone
|
||||
- (void) dealloc
|
||||
{
|
||||
NSBrowserCell* c = [super copyWithZone:zone];
|
||||
// Copy the image cells
|
||||
c->_branchImage = [_branchImage retain];
|
||||
if(_alternateImage)
|
||||
c->_alternateImage = [_alternateImage retain];
|
||||
c->_highlightBranchImage = [_highlightBranchImage retain];
|
||||
c->_browserText = [[_browserText copy] retain]; // Copy the text cell
|
||||
c->_isLeaf = _isLeaf;
|
||||
c->_isLoaded = _isLoaded;
|
||||
|
||||
return c;
|
||||
[_branchImage release];
|
||||
[_highlightBranchImage release];
|
||||
if (_alternateImage)
|
||||
[_alternateImage release];
|
||||
[_browserText release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
//
|
||||
// Accessing Graphic Attributes
|
||||
//
|
||||
- (NSImage *)alternateImage { return _alternateImage; }
|
||||
|
||||
- (void)setAlternateImage:(NSImage *)anImage
|
||||
{ // set image to display
|
||||
ASSIGN(_alternateImage, anImage); // when highlighted
|
||||
}
|
||||
|
||||
//
|
||||
// Placing in the Browser Hierarchy
|
||||
//
|
||||
- (BOOL)isLeaf { return _isLeaf; }
|
||||
- (void)setLeaf:(BOOL)flag { _isLeaf = flag; }
|
||||
|
||||
//
|
||||
// Determining Loaded Status
|
||||
//
|
||||
- (BOOL)isLoaded { return _isLoaded; }
|
||||
- (void)setLoaded:(BOOL)flag { _isLoaded = flag; }
|
||||
|
||||
//
|
||||
// Setting State
|
||||
//
|
||||
- (void)reset
|
||||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
cell_highlighted = NO;
|
||||
cell_state = NO;
|
||||
NSBrowserCell* c = [super copyWithZone: zone];
|
||||
// Copy the image cells
|
||||
c->_branchImage = [_branchImage retain];
|
||||
if (_alternateImage)
|
||||
c->_alternateImage = [_alternateImage retain];
|
||||
c->_highlightBranchImage = [_highlightBranchImage retain];
|
||||
c->_browserText = [[_browserText copy] retain]; // Copy the text cell
|
||||
c->_isLeaf = _isLeaf;
|
||||
c->_isLoaded = _isLoaded;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
- (void)set
|
||||
//
|
||||
// Accessing Graphic Attributes
|
||||
//
|
||||
- (NSImage*) alternateImage
|
||||
{
|
||||
cell_highlighted = YES;
|
||||
cell_state = YES;
|
||||
return _alternateImage;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting and accessing the NSCell's Value
|
||||
//
|
||||
- (double)doubleValue { return [_browserText doubleValue]; }
|
||||
- (float)floatValue; { return [_browserText floatValue]; }
|
||||
- (int)intValue { return [_browserText intValue]; }
|
||||
- (NSString *)stringValue { return [_browserText stringValue]; }
|
||||
- (void)setIntValue:(int)anInt { [_browserText setIntValue: anInt]; }
|
||||
|
||||
- (void)setDoubleValue:(double)aDouble
|
||||
{
|
||||
[_browserText setDoubleValue:aDouble];
|
||||
}
|
||||
|
||||
- (void)setFloatValue:(float)aFloat
|
||||
- (void) setAlternateImage: (NSImage *)anImage
|
||||
{
|
||||
[_browserText setFloatValue: aFloat];
|
||||
}
|
||||
|
||||
- (void)setStringValue:(NSString *)aString
|
||||
{
|
||||
[_browserText setStringValue: aString];
|
||||
ASSIGN(_alternateImage, anImage);
|
||||
}
|
||||
|
||||
//
|
||||
// Displaying
|
||||
// Placing in the Browser Hierarchy
|
||||
//
|
||||
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
|
||||
- (BOOL) isLeaf
|
||||
{
|
||||
NSRect title_rect = cellFrame;
|
||||
NSRect image_rect = cellFrame;
|
||||
NSImage *image = nil;
|
||||
return _isLeaf;
|
||||
}
|
||||
|
||||
control_view = controlView; // remember last view
|
||||
// cell was drawn in
|
||||
if (cell_highlighted || cell_state) // temporary hack FAR FIX ME?
|
||||
{
|
||||
NSColor *white = [NSColor whiteColor];
|
||||
- (void) setLeaf: (BOOL)flag
|
||||
{
|
||||
_isLeaf = flag;
|
||||
}
|
||||
|
||||
[white set];
|
||||
//
|
||||
// Determining Loaded Status
|
||||
//
|
||||
- (BOOL) isLoaded
|
||||
{
|
||||
return _isLoaded;
|
||||
}
|
||||
|
||||
- (void) setLoaded: (BOOL)flag
|
||||
{
|
||||
_isLoaded = flag;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting State
|
||||
//
|
||||
- (void) reset
|
||||
{
|
||||
cell_highlighted = NO;
|
||||
cell_state = NO;
|
||||
}
|
||||
|
||||
- (void) set
|
||||
{
|
||||
cell_highlighted = YES;
|
||||
cell_state = YES;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting and accessing the NSCell's Value
|
||||
//
|
||||
- (double) doubleValue
|
||||
{
|
||||
return [_browserText doubleValue];
|
||||
}
|
||||
|
||||
- (float) floatValue
|
||||
{
|
||||
return [_browserText floatValue];
|
||||
}
|
||||
|
||||
- (int) intValue
|
||||
{
|
||||
return [_browserText intValue];
|
||||
}
|
||||
|
||||
- (NSString*) stringValue
|
||||
{
|
||||
return [_browserText stringValue];
|
||||
}
|
||||
|
||||
- (void) setIntValue: (int)anInt
|
||||
{
|
||||
[_browserText setIntValue: anInt];
|
||||
}
|
||||
|
||||
- (void) setDoubleValue: (double)aDouble
|
||||
{
|
||||
[_browserText setDoubleValue: aDouble];
|
||||
}
|
||||
|
||||
- (void) setFloatValue: (float)aFloat
|
||||
{
|
||||
[_browserText setFloatValue: aFloat];
|
||||
}
|
||||
|
||||
- (void) setStringValue: (NSString*)aString
|
||||
{
|
||||
[_browserText setStringValue: aString];
|
||||
}
|
||||
|
||||
//
|
||||
// Displaying
|
||||
//
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
{
|
||||
NSRect title_rect = cellFrame;
|
||||
NSRect image_rect = cellFrame;
|
||||
NSImage *image = nil;
|
||||
|
||||
control_view = controlView; // remember last view cell was drawn in
|
||||
if (cell_highlighted || cell_state) // temporary hack FAR FIX ME?
|
||||
{
|
||||
NSColor *white = [NSColor whiteColor];
|
||||
|
||||
[white set];
|
||||
// [_browserText setBackgroundColor: white];
|
||||
if (!_isLeaf)
|
||||
{
|
||||
image = _highlightBranchImage;
|
||||
image_rect.size.height = cellFrame.size.height;
|
||||
image_rect.size.width = image_rect.size.height;
|
||||
// Right justify
|
||||
image_rect.origin.x += cellFrame.size.width- image_rect.size.width;
|
||||
}
|
||||
else
|
||||
image_rect = NSZeroRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSColor *backColor = [[controlView window] backgroundColor];
|
||||
if (!_isLeaf)
|
||||
{
|
||||
image = _highlightBranchImage;
|
||||
image_rect.size.height = cellFrame.size.height;
|
||||
image_rect.size.width = image_rect.size.height;
|
||||
// Right justify
|
||||
image_rect.origin.x += cellFrame.size.width- image_rect.size.width;
|
||||
}
|
||||
else
|
||||
image_rect = NSZeroRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSColor *backColor = [[controlView window] backgroundColor];
|
||||
|
||||
[backColor set];
|
||||
// [_browserText setBackgroundColor:backColor];
|
||||
if (!_isLeaf)
|
||||
{
|
||||
image = _branchImage;
|
||||
image_rect.size.height = cellFrame.size.height;
|
||||
image_rect.size.width = image_rect.size.height;
|
||||
// Right justify
|
||||
image_rect.origin.x += cellFrame.size.width- image_rect.size.width;
|
||||
}
|
||||
else
|
||||
image_rect = NSZeroRect;
|
||||
}
|
||||
NSRectFill(cellFrame); // Clear the background
|
||||
[backColor set];
|
||||
// [_browserText setBackgroundColor: backColor];
|
||||
if (!_isLeaf)
|
||||
{
|
||||
image = _branchImage;
|
||||
image_rect.size.height = cellFrame.size.height;
|
||||
image_rect.size.width = image_rect.size.height;
|
||||
// Right justify
|
||||
image_rect.origin.x += cellFrame.size.width- image_rect.size.width;
|
||||
}
|
||||
else
|
||||
image_rect = NSZeroRect;
|
||||
}
|
||||
NSRectFill(cellFrame); // Clear the background
|
||||
|
||||
title_rect.size.width -= image_rect.size.width + 4; // draw the title cell
|
||||
[_browserText drawWithFrame:title_rect inView: controlView];
|
||||
title_rect.size.width -= image_rect.size.width + 4; // draw the title cell
|
||||
[_browserText drawWithFrame: title_rect inView: controlView];
|
||||
|
||||
if (image) // Draw the image
|
||||
[self _drawImage:image inFrame:image_rect];
|
||||
if (image)
|
||||
[self _drawImage: image inFrame: image_rect];
|
||||
}
|
||||
|
||||
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
|
||||
{ // no border so just
|
||||
// draw the interior
|
||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
|
||||
//
|
||||
// Editing Text
|
||||
//
|
||||
- (void)editWithFrame:(NSRect)aRect
|
||||
inView:(NSView *)controlView
|
||||
editor:(NSText *)textObject
|
||||
delegate:(id)anObject
|
||||
event:(NSEvent *)theEvent
|
||||
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
{
|
||||
NSPoint location = [controlView convertPoint:[theEvent locationInWindow]
|
||||
fromView:nil];
|
||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
|
||||
//
|
||||
// Editing Text
|
||||
//
|
||||
- (void) editWithFrame: (NSRect)aRect
|
||||
inView: (NSView *)controlView
|
||||
editor: (NSText *)textObject
|
||||
delegate: (id)anObject
|
||||
event: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint location = [controlView convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
fprintf(stderr, " NSBrowserCell: editWithFrame --- ");
|
||||
|
||||
[_browserText _setCursorLocation:location];
|
||||
[_browserText _setCursorVisibility: YES];
|
||||
[_browserText _setCursorLocation: location];
|
||||
[_browserText _setCursorVisibility: YES];
|
||||
|
||||
if ([[controlView window] makeFirstResponder:controlView])
|
||||
fprintf(stderr, " XRBrowserCell: we are now first responder --- ");
|
||||
if ([[controlView window] makeFirstResponder: controlView])
|
||||
fprintf(stderr, " XRBrowserCell: we are now first responder --- ");
|
||||
|
||||
[self drawInteriorWithFrame: aRect inView: controlView];
|
||||
[self drawInteriorWithFrame: aRect inView: controlView];
|
||||
}
|
||||
|
||||
- (void)endEditing:(NSText *)textObject
|
||||
- (void) endEditing: (NSText *)textObject
|
||||
{
|
||||
[_browserText _setCursorVisibility: NO];
|
||||
[_browserText _setCursorVisibility: NO];
|
||||
}
|
||||
|
||||
- (void)_handleKeyEvent:(NSEvent*)keyEvent
|
||||
- (void) _handleKeyEvent: (NSEvent*)keyEvent
|
||||
{
|
||||
fprintf(stderr, " NSBrowserCell: _handleKeyEvent --- ");
|
||||
fprintf(stderr, " NSBrowserCell: _handleKeyEvent --- ");
|
||||
|
||||
[_browserText _handleKeyEvent:keyEvent];
|
||||
[_browserText _handleKeyEvent: keyEvent];
|
||||
|
||||
// [self drawInteriorWithFrame: aRect inView: controlView];
|
||||
}
|
||||
|
@ -305,28 +354,28 @@ fprintf(stderr, " NSBrowserCell: _handleKeyEvent --- ");
|
|||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject: _browserText];
|
||||
[aCoder encodeObject: _branchImage];
|
||||
[aCoder encodeObject: _highlightBranchImage];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeObject: _browserText];
|
||||
[aCoder encodeObject: _branchImage];
|
||||
[aCoder encodeObject: _highlightBranchImage];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||
}
|
||||
|
||||
- initWithCoder:aDecoder
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
[super initWithCoder:aDecoder];
|
||||
|
||||
_browserText = [aDecoder decodeObject];
|
||||
_branchImage = [aDecoder decodeObject];
|
||||
_highlightBranchImage = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||
|
||||
return self;
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_browserText];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_branchImage];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_highlightBranchImage];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
934
Source/NSCell.m
934
Source/NSCell.m
File diff suppressed because it is too large
Load diff
|
@ -526,6 +526,7 @@ static BOOL preCalcValues = NO;
|
|||
|
||||
[self _preCalcParts]; // pre calc scroller parts
|
||||
preCalcValues = YES;
|
||||
|
||||
knobRect = [self rectForPart: NSScrollerKnob];
|
||||
|
||||
if (_hitPart == NSScrollerKnob)
|
||||
|
@ -581,7 +582,11 @@ static BOOL preCalcValues = NO;
|
|||
[self setFloatValue: floatValue];
|
||||
[self sendAction: _action to: _target];
|
||||
|
||||
oldFloatValue = floatValue;
|
||||
/*
|
||||
* Get current float value - which may have been changed
|
||||
* when we sent the action to the target.
|
||||
*/
|
||||
oldFloatValue = _floatValue;
|
||||
[window update];
|
||||
}
|
||||
knobRect.origin = point;
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
/*
|
||||
/*
|
||||
NSSplitView.h
|
||||
|
||||
Allows multiple views to share a region in a window
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Robert Vasvari <vrobi@ddrummer.com>
|
||||
Author: Robert Vasvari < vrobi@ddrummer.com >
|
||||
Date: Jul 1998
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Author: Felipe A. Rodriguez < far@ix.netcom.com >
|
||||
Date: November 1998
|
||||
|
||||
Author: Richard Frith-Macdonald < richard@brainstorm.co.uk >
|
||||
Date: January 1999
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
@ -26,7 +28,7 @@
|
|||
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.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <string.h>
|
||||
|
@ -43,223 +45,220 @@
|
|||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
static NSRect oldRect; //only one can be dragged at a time
|
||||
NSPoint p;
|
||||
NSEvent *e;
|
||||
NSRect r, r1, bigRect, vis;
|
||||
id v, prev=nil;
|
||||
float minCoord,maxCoord;
|
||||
NSArray *subs=[self subviews];
|
||||
int offset=0,i,count=[subs count];
|
||||
float divVertical, divHorizontal, div=[self dividerThickness];
|
||||
NSColor *divColor=[self dividerColor];
|
||||
NSDate *farAway=[NSDate distantFuture];
|
||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
||||
| NSPeriodicMask;
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
static NSRect oldRect; //only one can be dragged at a time
|
||||
NSPoint p;
|
||||
NSEvent *e;
|
||||
NSRect r, r1, bigRect, vis;
|
||||
id v, prev = nil;
|
||||
float minCoord, maxCoord;
|
||||
NSArray *subs = [self subviews];
|
||||
int offset = 0,i,count = [subs count];
|
||||
float divVertical, divHorizontal, div = [self dividerThickness];
|
||||
NSColor *divColor = [self dividerColor];
|
||||
NSDate *farAway = [NSDate distantFuture];
|
||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
||||
| NSPeriodicMask;
|
||||
|
||||
/* if there are less the two subviews, there is nothing
|
||||
to do
|
||||
*/
|
||||
if(count<2) return;
|
||||
/* if there are less the two subviews, there is nothing to do */
|
||||
if (count < 2)
|
||||
return;
|
||||
|
||||
[[self window] setAcceptsMouseMovedEvents:YES];
|
||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||
vis = [self visibleRect];
|
||||
|
||||
/* find out which divider it is */
|
||||
p=[theEvent locationInWindow];
|
||||
p = [self convertPoint:p fromView:nil];
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
v=[subs objectAtIndex:i];
|
||||
r=[v frame];
|
||||
p = [theEvent locationInWindow];
|
||||
p = [self convertPoint: p fromView: nil];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
v = [subs objectAtIndex: i];
|
||||
r = [v frame];
|
||||
/* if the click is inside of a subview, return.
|
||||
this should never happen */
|
||||
if([self isVertical])
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
if((p.y>NSMinY(r)) && (p.y<NSMaxY(r)))
|
||||
if ((p.y > NSMinY(r)) && (p.y < NSMaxY(r)))
|
||||
goto RETURN_LABEL;
|
||||
if(NSMaxY(r)>p.y)
|
||||
{
|
||||
offset=i;
|
||||
if (NSMaxY(r) > p.y)
|
||||
{
|
||||
offset = i;
|
||||
|
||||
/* get the enclosing rect for the two views */
|
||||
if(prev) r=[prev frame];
|
||||
if (prev) r = [prev frame];
|
||||
else r = NSZeroRect;
|
||||
if(v) r1=[v frame];
|
||||
bigRect=r;
|
||||
bigRect=NSUnionRect(r1 , bigRect);
|
||||
if (v) r1= [v frame];
|
||||
bigRect = r;
|
||||
bigRect = NSUnionRect(r1 , bigRect);
|
||||
break;
|
||||
}
|
||||
prev=v;
|
||||
prev = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((p.x>NSMinX(r)) && (p.x<NSMaxX(r)))
|
||||
if ((p.x > NSMinX(r)) && (p.x < NSMaxX(r)))
|
||||
goto RETURN_LABEL;
|
||||
if((NSMinX(r)+NSWidth(r))>p.x)
|
||||
{
|
||||
offset=i;
|
||||
if ((NSMinX(r) + NSWidth(r)) > p.x)
|
||||
{
|
||||
offset = i;
|
||||
|
||||
/* get the enclosing rect for the two views */
|
||||
if(prev) r=[prev frame];
|
||||
if (prev) r = [prev frame];
|
||||
else r = NSZeroRect;
|
||||
if(v) r1=[v frame];
|
||||
bigRect=r;
|
||||
bigRect=NSUnionRect(r1 , bigRect);
|
||||
if (v) r1= [v frame];
|
||||
bigRect = r;
|
||||
bigRect = NSUnionRect(r1 , bigRect);
|
||||
break;
|
||||
}
|
||||
prev=v;
|
||||
prev = v;
|
||||
}
|
||||
}
|
||||
if([self isVertical])
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
divVertical=div;
|
||||
divHorizontal=NSWidth([self frame]);
|
||||
divVertical = div;
|
||||
divHorizontal = NSWidth([self frame]);
|
||||
/* set the default limits on the dragging */
|
||||
minCoord=NSMinY(bigRect)+divVertical;
|
||||
maxCoord=NSHeight(bigRect)+NSMinY(bigRect)-divVertical;
|
||||
minCoord = NSMinY(bigRect) + divVertical;
|
||||
maxCoord = NSHeight(bigRect) + NSMinY(bigRect) - divVertical;
|
||||
}
|
||||
else
|
||||
{
|
||||
divHorizontal=div;
|
||||
divVertical=NSHeight([self frame]);
|
||||
divHorizontal = div;
|
||||
divVertical = NSHeight([self frame]);
|
||||
/* set the default limits on the dragging */
|
||||
minCoord=NSMinX(bigRect)+divHorizontal;
|
||||
maxCoord=NSWidth(bigRect)+NSMinX(bigRect)-divHorizontal;
|
||||
minCoord = NSMinX(bigRect) + divHorizontal;
|
||||
maxCoord = NSWidth(bigRect) + NSMinX(bigRect) - divHorizontal;
|
||||
}
|
||||
|
||||
|
||||
/* find out what the dragging limit is */
|
||||
if(delegate && [delegate respondsToSelector:@selector
|
||||
(splitView:constrainMinCoordinate:maxCoordinate:ofSubviewAt:)])
|
||||
{
|
||||
if([self isVertical])
|
||||
if (delegate && [delegate respondsToSelector:
|
||||
@selector(splitView:constrainMinCoordinate:maxCoordinate:ofSubviewAt:)])
|
||||
{
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
float delMinY=minCoord, delMaxY=maxCoord;
|
||||
[delegate splitView:self
|
||||
constrainMinCoordinate:&delMinY
|
||||
maxCoordinate:&delMaxY
|
||||
ofSubviewAt:offset];
|
||||
float delMinY= minCoord, delMaxY= maxCoord;
|
||||
[delegate splitView: self
|
||||
constrainMinCoordinate: &delMinY
|
||||
maxCoordinate: &delMaxY
|
||||
ofSubviewAt: offset];
|
||||
/* we are still constrained by the original bounds */
|
||||
if(delMinY>minCoord) minCoord=delMinY;
|
||||
if(delMaxY<maxCoord) maxCoord=delMaxY;
|
||||
if (delMinY > minCoord) minCoord = delMinY;
|
||||
if (delMaxY < maxCoord) maxCoord = delMaxY;
|
||||
}
|
||||
else
|
||||
{
|
||||
float delMinX=minCoord, delMaxX=maxCoord;
|
||||
[delegate splitView:self
|
||||
constrainMinCoordinate:&delMinX
|
||||
maxCoordinate:&delMaxX
|
||||
ofSubviewAt:offset];
|
||||
float delMinX= minCoord, delMaxX= maxCoord;
|
||||
[delegate splitView: self
|
||||
constrainMinCoordinate: &delMinX
|
||||
maxCoordinate: &delMaxX
|
||||
ofSubviewAt: offset];
|
||||
/* we are still constrained by the original bounds */
|
||||
if(delMinX>minCoord) minCoord=delMinX;
|
||||
if(delMaxX<maxCoord) maxCoord=delMaxX;
|
||||
if (delMinX > minCoord) minCoord = delMinX;
|
||||
if (delMaxX < maxCoord) maxCoord = delMaxX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
oldRect = NSZeroRect;
|
||||
[self lockFocus];
|
||||
|
||||
/* FIXME: Are these really needed? */
|
||||
[NSEvent startPeriodicEventsAfterDelay:0.1 withPeriod:0.1];
|
||||
[[NSRunLoop currentRunLoop] limitDateForMode:NSEventTrackingRunLoopMode];
|
||||
|
||||
[NSEvent startPeriodicEventsAfterDelay: 0.1 withPeriod: 0.1];
|
||||
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
|
||||
|
||||
[divColor set];
|
||||
r.size.width = divHorizontal;
|
||||
r.size.height = divVertical;
|
||||
e = [app nextEventMatchingMask:eventMask
|
||||
untilDate:farAway
|
||||
inMode:NSEventTrackingRunLoopMode
|
||||
dequeue:YES];
|
||||
e = [app nextEventMatchingMask: eventMask
|
||||
untilDate: farAway
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
while([e type] != NSLeftMouseUp) // user is moving the knob
|
||||
{ // loop until left mouse up
|
||||
// [self displayRect:oldRect];
|
||||
if ([e type] != NSPeriodic)
|
||||
p = [self convertPoint:[e locationInWindow] fromView:nil];
|
||||
if([self isVertical])
|
||||
{
|
||||
if(p.y<minCoord)
|
||||
p.y=minCoord;
|
||||
if(p.y>maxCoord)
|
||||
p.y=maxCoord;
|
||||
r.origin.y = p.y-(divVertical/2.);
|
||||
r.origin.x = NSMinX(vis);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p.x<minCoord)
|
||||
p.x=minCoord;
|
||||
if(p.x>maxCoord)
|
||||
p.x=maxCoord;
|
||||
r.origin.x = p.x-(divHorizontal/2.);
|
||||
r.origin.y = NSMinY(vis);
|
||||
}
|
||||
NSDebugLog(@"drawing divider at x:%d, y:%d, w:%d, h:%d\n",
|
||||
(int)NSMinX(r),(int)NSMinY(r),(int)NSWidth(r),
|
||||
(int)NSHeight(r));
|
||||
[dividerColor set]; // draw the divider
|
||||
NSHighlightRect(r);
|
||||
// user is moving the knob loop until left mouse up
|
||||
while ([e type] != NSLeftMouseUp)
|
||||
{
|
||||
if ([e type] != NSPeriodic)
|
||||
p = [self convertPoint: [e locationInWindow] fromView: nil];
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
if (p.y < minCoord)
|
||||
p.y = minCoord;
|
||||
if (p.y > maxCoord)
|
||||
p.y = maxCoord;
|
||||
r.origin.y = p.y - (divVertical/2.);
|
||||
r.origin.x = NSMinX(vis);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.x < minCoord)
|
||||
p.x = minCoord;
|
||||
if (p.x > maxCoord)
|
||||
p.x = maxCoord;
|
||||
r.origin.x = p.x - (divHorizontal/2.);
|
||||
r.origin.y = NSMinY(vis);
|
||||
}
|
||||
NSDebugLog(@"drawing divider at x: %d, y: %d, w: %d, h: %d\n",
|
||||
(int)NSMinX(r),(int)NSMinY(r),(int)NSWidth(r),
|
||||
(int)NSHeight(r));
|
||||
[dividerColor set];
|
||||
NSHighlightRect(r);
|
||||
// [[NSDrawContext currentContext] flush];
|
||||
oldRect=r;
|
||||
e = [app nextEventMatchingMask:eventMask
|
||||
untilDate:farAway
|
||||
inMode:NSEventTrackingRunLoopMode
|
||||
dequeue:YES];
|
||||
[dividerColor set]; // draw the divider
|
||||
NSHighlightRect(oldRect);
|
||||
}
|
||||
oldRect = r;
|
||||
e = [app nextEventMatchingMask: eventMask
|
||||
untilDate: farAway
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
[dividerColor set];
|
||||
NSHighlightRect(oldRect);
|
||||
}
|
||||
|
||||
[self unlockFocus];
|
||||
[NSEvent stopPeriodicEvents];
|
||||
|
||||
/* resize the subviews accordingly */
|
||||
r = [prev frame];
|
||||
if([self isVertical])
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
r.size.height=p.y-NSMinY(bigRect)-(divVertical/2.);
|
||||
if(NSHeight(r) < 1.) r.size.height=1.;
|
||||
r.size.height = p.y - NSMinY(bigRect) - (divVertical/2.);
|
||||
if (NSHeight(r) < 1.) r.size.height = 1.;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.size.width=p.x-NSMinX(bigRect)-(divHorizontal/2.);
|
||||
if(NSWidth(r) < 1.) r.size.width=1.;
|
||||
r.size.width = p.x - NSMinX(bigRect) - (divHorizontal/2.);
|
||||
if (NSWidth(r) < 1.) r.size.width = 1.;
|
||||
}
|
||||
[prev setFrame:r];
|
||||
NSDebugLog(@"drawing PREV at x:%d, y:%d, w:%d, h:%d\n",
|
||||
[prev setFrame: r];
|
||||
NSDebugLog(@"drawing PREV at x: %d, y: %d, w: %d, h: %d\n",
|
||||
(int)NSMinX(r),(int)NSMinY(r),(int)NSWidth(r),(int)NSHeight(r));
|
||||
|
||||
r1 = [v frame];
|
||||
if([self isVertical])
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
r1.origin.y=p.y+(divVertical/2.);
|
||||
if(NSMinY(r1) < 0.) r1.origin.y=0.;
|
||||
r1.size.height=NSHeight(bigRect)-NSHeight(r)-divVertical;
|
||||
if(NSHeight(r) < 1.) r.size.height=1.;
|
||||
r1.origin.y = p.y + (divVertical/2.);
|
||||
if (NSMinY(r1) < 0.) r1.origin.y = 0.;
|
||||
r1.size.height = NSHeight(bigRect) - NSHeight(r) - divVertical;
|
||||
if (NSHeight(r) < 1.) r.size.height = 1.;
|
||||
}
|
||||
else
|
||||
{
|
||||
r1.origin.x=p.x+(divHorizontal/2.);
|
||||
if(NSMinX(r1) < 0.) r1.origin.x=0.;
|
||||
r1.size.width=NSWidth(bigRect)-NSWidth(r)-divHorizontal;
|
||||
if(NSWidth(r1) < 1.) r1.size.width=1.;
|
||||
r1.origin.x = p.x + (divHorizontal/2.);
|
||||
if (NSMinX(r1) < 0.) r1.origin.x = 0.;
|
||||
r1.size.width = NSWidth(bigRect) - NSWidth(r) - divHorizontal;
|
||||
if (NSWidth(r1) < 1.) r1.size.width = 1.;
|
||||
}
|
||||
[v setFrame:r1];
|
||||
NSDebugLog(@"drawing LAST at x:%d, y:%d, w:%d, h:%d\n",
|
||||
[v setFrame: r1];
|
||||
NSDebugLog(@"drawing LAST at x: %d, y: %d, w: %d, h: %d\n",
|
||||
(int)NSMinX(r1),(int)NSMinY(r1),(int)NSWidth(r1),
|
||||
(int)NSHeight(r1));
|
||||
|
||||
[[self window] invalidateCursorRectsForView:self];
|
||||
[[self window] invalidateCursorRectsForView: self];
|
||||
|
||||
RETURN_LABEL:
|
||||
[[self window] setAcceptsMouseMovedEvents:NO];
|
||||
[self setNeedsDisplay:YES];
|
||||
[[self window] setAcceptsMouseMovedEvents: NO];
|
||||
[self setNeedsDisplay: YES];
|
||||
|
||||
[self display];
|
||||
}
|
||||
|
@ -272,9 +271,10 @@ RETURN_LABEL:
|
|||
[nc postNotificationName: NSSplitViewWillResizeSubviewsNotification
|
||||
object: self];
|
||||
|
||||
if(delegate && [delegate respondsToSelector:@selector(splitView:resizeSubviewsWithOldSize:)])
|
||||
{
|
||||
[delegate splitView:self resizeSubviewsWithOldSize:fr.size];
|
||||
if (delegate && [delegate respondsToSelector:
|
||||
@selector(splitView:resizeSubviewsWithOldSize:)])
|
||||
{
|
||||
[delegate splitView: self resizeSubviewsWithOldSize: fr.size];
|
||||
}
|
||||
else
|
||||
{ /* split the area up evenly */
|
||||
|
@ -294,9 +294,9 @@ RETURN_LABEL:
|
|||
float running;
|
||||
|
||||
[subs getObjects: views];
|
||||
if ([self isVertical])
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
newTotal = NSHeight(bd) - thickness*(count-1);
|
||||
newTotal = NSHeight(bd) - thickness*(count - 1);
|
||||
oldTotal = 0.0;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ RETURN_LABEL:
|
|||
}
|
||||
else
|
||||
{
|
||||
newTotal = NSWidth(bd) - thickness*(count-1);
|
||||
newTotal = NSWidth(bd) - thickness*(count - 1);
|
||||
oldTotal = 0.0;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -354,46 +354,45 @@ RETURN_LABEL:
|
|||
object: self];
|
||||
}
|
||||
|
||||
- (void)addSubview:(NSView *)aView
|
||||
positioned:(NSWindowOrderingMode)place
|
||||
relativeTo:(NSView *)otherView
|
||||
{
|
||||
[super addSubview:aView positioned:place relativeTo:otherView];
|
||||
|
||||
[self adjustSubviews];
|
||||
}
|
||||
|
||||
- (void)addSubview:aView
|
||||
- (void) addSubview: (NSView*)aView
|
||||
positioned: (NSWindowOrderingMode)place
|
||||
relativeTo: (NSView*)otherView
|
||||
{
|
||||
[super addSubview:aView];
|
||||
[super addSubview: aView positioned: place relativeTo: otherView];
|
||||
[self adjustSubviews];
|
||||
}
|
||||
|
||||
- (float)dividerThickness //defaults to 8
|
||||
- (void) addSubview: aView
|
||||
{
|
||||
[super addSubview: aView];
|
||||
[self adjustSubviews];
|
||||
}
|
||||
|
||||
- (float) dividerThickness //defaults to 8
|
||||
{
|
||||
return dividerWidth;
|
||||
}
|
||||
|
||||
- (void)setDividerThickNess:(float)newWidth
|
||||
- (void) setDividerThickNess: (float)newWidth
|
||||
{
|
||||
dividerWidth=ceil(newWidth);
|
||||
dividerWidth = ceil(newWidth);
|
||||
}
|
||||
|
||||
- (float)draggedBarWidth //defaults to 8
|
||||
- (float) draggedBarWidth //defaults to 8
|
||||
{
|
||||
return draggedBarWidth;
|
||||
}
|
||||
|
||||
- (void)setDraggedBarWidth:(float)newWidth
|
||||
- (void) setDraggedBarWidth: (float)newWidth
|
||||
{
|
||||
draggedBarWidth=newWidth;
|
||||
draggedBarWidth = newWidth;
|
||||
}
|
||||
|
||||
NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
||||
{
|
||||
NSPoint p;
|
||||
p.x=MAX(NSMidX(outerRect)-(innerSize.width/2.),0.);
|
||||
p.y=MAX(NSMidY(outerRect)-(innerSize.height/2.),0.);
|
||||
p.x = MAX(NSMidX(outerRect) - (innerSize.width/2.),0.);
|
||||
p.y = MAX(NSMidY(outerRect) - (innerSize.height/2.),0.);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -402,60 +401,57 @@ NSPoint centerRectInRect(NSRect innerRect, NSRect outerRect)
|
|||
return centerSizeInRect(innerRect.size,outerRect);
|
||||
}
|
||||
|
||||
- (void)drawDividerInRect:(NSRect)aRect
|
||||
- (void) drawDividerInRect: (NSRect)aRect
|
||||
{
|
||||
NSPoint dimpleOrigin;
|
||||
NSSize dimpleSize;
|
||||
|
||||
/* focus is already on self */
|
||||
if(!dimpleImage) return;
|
||||
dimpleSize=[dimpleImage size];
|
||||
if (!dimpleImage)
|
||||
return;
|
||||
dimpleSize = [dimpleImage size];
|
||||
|
||||
/* composite into the center of the given rect. Since NSImages
|
||||
are always flipped, we adjust for it here */
|
||||
dimpleOrigin=centerSizeInRect(dimpleSize,aRect);
|
||||
if([self isFlipped]) dimpleOrigin.y+=dimpleSize.height;
|
||||
[dimpleImage compositeToPoint:dimpleOrigin operation:NSCompositeSourceOver];
|
||||
dimpleOrigin = centerSizeInRect(dimpleSize,aRect);
|
||||
if ([self isFlipped])
|
||||
dimpleOrigin.y += dimpleSize.height;
|
||||
[dimpleImage compositeToPoint: dimpleOrigin operation: NSCompositeSourceOver];
|
||||
}
|
||||
|
||||
- (void)setVertical:(BOOL)flag /* Vertical splitview has a vertical split bar */
|
||||
/* Vertical splitview has a vertical split bar */
|
||||
- (void) setVertical: (BOOL)flag
|
||||
{
|
||||
isVertical=flag;
|
||||
isVertical = flag;
|
||||
}
|
||||
|
||||
- (BOOL)isVertical
|
||||
- (BOOL) isVertical
|
||||
{
|
||||
return isVertical;
|
||||
}
|
||||
|
||||
- (void)setDimpleImage:(NSImage *)anImage resetDividerThickness:(BOOL)flag
|
||||
- (void) setDimpleImage: (NSImage *)anImage resetDividerThickness: (BOOL)flag
|
||||
{
|
||||
if(dimpleImage==anImage) return;
|
||||
[dimpleImage release];
|
||||
dimpleImage=[anImage retain];
|
||||
ASSIGN(dimpleImage, anImage);
|
||||
|
||||
if(flag)
|
||||
if (flag)
|
||||
{
|
||||
NSSize s={8.,8.};
|
||||
if(dimpleImage) s=[dimpleImage size];
|
||||
[self setDividerThickNess: isVertical ? s.height : s.width];
|
||||
NSSize s = NSMakeSize(8., 8.);
|
||||
|
||||
if (dimpleImage)
|
||||
s = [dimpleImage size];
|
||||
[self setDividerThickNess: isVertical ? s.width : s.height];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayRect:(NSRect)rect
|
||||
{ // should not be needed FIX ME
|
||||
[super displayRect:rect];
|
||||
[window flushWindow];
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)r
|
||||
- (void) drawRect: (NSRect)r
|
||||
{
|
||||
NSArray *subs=[self subviews];
|
||||
int i, count=[subs count];
|
||||
NSArray *subs = [self subviews];
|
||||
int i, count = [subs count];
|
||||
id v;
|
||||
NSRect divRect;
|
||||
|
||||
if([self isOpaque])
|
||||
if ([self isOpaque])
|
||||
{
|
||||
[[self backgroundColor] set];
|
||||
NSRectFill(r);
|
||||
|
@ -463,70 +459,70 @@ NSPoint centerRectInRect(NSRect innerRect, NSRect outerRect)
|
|||
|
||||
/* draw the dimples */
|
||||
{
|
||||
for(i=0;i<(count-1);i++)
|
||||
{
|
||||
v=[subs objectAtIndex:i];
|
||||
divRect=[v frame];
|
||||
if([self isVertical])
|
||||
for (i = 0; i < (count-1); i++)
|
||||
{
|
||||
v = [subs objectAtIndex: i];
|
||||
divRect = [v frame];
|
||||
if ([self isVertical] == NO)
|
||||
{
|
||||
divRect.origin.y=NSMaxY(divRect);
|
||||
divRect.size.height=[self dividerThickness];
|
||||
divRect.origin.y = NSMaxY(divRect);
|
||||
divRect.size.height = [self dividerThickness];
|
||||
}
|
||||
else
|
||||
{
|
||||
divRect.origin.x=NSMaxX(divRect);
|
||||
divRect.size.width=[self dividerThickness];
|
||||
divRect.origin.x = NSMaxX(divRect);
|
||||
divRect.size.width = [self dividerThickness];
|
||||
}
|
||||
[self drawDividerInRect:divRect];
|
||||
[self drawDividerInRect: divRect];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSImage *)dimpleImage
|
||||
- (NSImage*) dimpleImage
|
||||
{
|
||||
return dimpleImage;
|
||||
}
|
||||
|
||||
/* Overridden Methods */
|
||||
- (BOOL)isFlipped
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isOpaque
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
if((self=[super initWithFrame:frameRect])!=nil)
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
{
|
||||
if ((self = [super initWithFrame: frameRect]) != nil)
|
||||
{
|
||||
dividerWidth=8;
|
||||
draggedBarWidth=8;
|
||||
isVertical=NO;
|
||||
[self seDividerColor:[NSColor darkGrayColor]];
|
||||
[self setBackgroundColor:[NSColor lightGrayColor]];
|
||||
dividerWidth = 8;
|
||||
draggedBarWidth = 8;
|
||||
isVertical = NO;
|
||||
[self setDividerColor: [NSColor darkGrayColor]];
|
||||
[self setBackgroundColor: [NSColor lightGrayColor]];
|
||||
[self setDimpleImage:
|
||||
[NSImage imageNamed:@"common_Dimple.tiff"] resetDividerThickness:YES];
|
||||
[NSImage imageNamed: @"common_Dimple.tiff"] resetDividerThickness: YES];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
|
||||
{
|
||||
[super resizeWithOldSuperviewSize:oldSize];
|
||||
- (void) resizeWithOldSuperviewSize: (NSSize)oldSize
|
||||
{
|
||||
[super resizeWithOldSuperviewSize: oldSize];
|
||||
[self adjustSubviews];
|
||||
[[self window] invalidateCursorRectsForView:self];
|
||||
[[self window] invalidateCursorRectsForView: self];
|
||||
}
|
||||
|
||||
- (id) delegate
|
||||
{
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id)anObject
|
||||
{
|
||||
{
|
||||
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (delegate)
|
||||
|
@ -536,7 +532,7 @@ NSPoint centerRectInRect(NSRect innerRect, NSRect outerRect)
|
|||
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
||||
if ([delegate respondsToSelector: @selector(splitView##notif_name:)]) \
|
||||
[nc addObserver: delegate \
|
||||
selector: @selector(splitView##notif_name:) \
|
||||
selector: @selector(splitView##notif_name: ) \
|
||||
name: NSSplitView##notif_name##Notification \
|
||||
object: self]
|
||||
|
||||
|
@ -544,66 +540,82 @@ NSPoint centerRectInRect(NSRect innerRect, NSRect outerRect)
|
|||
SET_DELEGATE_NOTIFICATION(WillResizeSubviews);
|
||||
}
|
||||
|
||||
- (NSColor *)dividerColor
|
||||
{
|
||||
- (NSColor*) dividerColor
|
||||
{
|
||||
return dividerColor;
|
||||
}
|
||||
|
||||
- (void)seDividerColor:(NSColor *)aColor
|
||||
{
|
||||
if(dividerColor==aColor) return;
|
||||
[dividerColor release];
|
||||
dividerColor=[aColor retain];
|
||||
- (void) setDividerColor: (NSColor*) aColor
|
||||
{
|
||||
ASSIGN(dividerColor, aColor);
|
||||
}
|
||||
|
||||
- (NSColor *)backgroundColor
|
||||
{
|
||||
- (NSColor*) backgroundColor
|
||||
{
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor *)aColor
|
||||
{
|
||||
if(backgroundColor==aColor) return;
|
||||
[backgroundColor release];
|
||||
backgroundColor=[aColor retain];
|
||||
- (void) setBackgroundColor: (NSColor*)aColor
|
||||
{
|
||||
ASSIGN(backgroundColor, aColor);
|
||||
}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
// NSDebugLog(@"NSSplitView: start encoding\n");
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeObject:delegate];
|
||||
[aCoder encodeObject:splitCursor];
|
||||
[aCoder encodeObject:dimpleImage];
|
||||
[aCoder encodeObject:backgroundColor];
|
||||
[aCoder encodeObject:dividerColor];
|
||||
[aCoder encodeValueOfObjCType:@encode(int) at: ÷rWidth];
|
||||
[aCoder encodeValueOfObjCType:@encode(int) at: &draggedBarWidth];
|
||||
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &isVertical];
|
||||
// NSDebugLog(@"NSView: finish encoding\n");
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
/*
|
||||
* Encode objects we don't own.
|
||||
*/
|
||||
[aCoder encodeConditionalObject: delegate];
|
||||
[aCoder encodeConditionalObject: splitCursor];
|
||||
|
||||
/*
|
||||
* Encode the objects we do own.
|
||||
*/
|
||||
[aCoder encodeObject: dimpleImage];
|
||||
[aCoder encodeObject: backgroundColor];
|
||||
[aCoder encodeObject: dividerColor];
|
||||
|
||||
/*
|
||||
* Encode the rest of the ivar data.
|
||||
*/
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: ÷rWidth];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &draggedBarWidth];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &isVertical];
|
||||
}
|
||||
|
||||
- initWithCoder:aDecoder
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
self=[super initWithCoder:aDecoder];
|
||||
self = [super initWithCoder: aDecoder];
|
||||
|
||||
/*
|
||||
* Decode objects that we don't retain.
|
||||
*/
|
||||
delegate = [aDecoder decodeObject];
|
||||
splitCursor = [aDecoder decodeObject];
|
||||
|
||||
/*
|
||||
* Decode objects that we do retain.
|
||||
*/
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &dimpleImage];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &backgroundColor];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: ÷rColor];
|
||||
|
||||
/*
|
||||
* Decode non-object data.
|
||||
*/
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: ÷rWidth];
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &draggedBarWidth];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &isVertical];
|
||||
|
||||
// NSDebugLog(@"NSSplitView: start decoding\n");
|
||||
delegate=[aDecoder decodeObject];
|
||||
splitCursor=[aDecoder decodeObject];
|
||||
dimpleImage=[aDecoder decodeObject];
|
||||
backgroundColor=[aDecoder decodeObject];
|
||||
dividerColor=[aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType:@encode(int) at: ÷rWidth];
|
||||
[aDecoder decodeValueOfObjCType:@encode(int) at: &draggedBarWidth];
|
||||
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &isVertical];
|
||||
// NSDebugLog(@"NSView: finish decoding\n");
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
[backgroundColor release];
|
||||
[dividerColor release];
|
||||
|
|
503
Source/NSView.m
503
Source/NSView.m
|
@ -11,6 +11,8 @@
|
|||
Date: 1997
|
||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Date: August 1998
|
||||
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Date: January 1999
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -48,17 +50,20 @@
|
|||
#include <AppKit/PSMatrix.h>
|
||||
|
||||
|
||||
|
||||
@implementation NSView
|
||||
|
||||
//
|
||||
// Class variables
|
||||
//
|
||||
static NSString *viewThreadKey = @"NSViewThreadKey";
|
||||
static void (*concatImp)(PSMatrix*, SEL, PSMatrix*) = 0;
|
||||
static SEL concatSel = @selector(concatenateWith:);
|
||||
static PSMatrix *flip = nil;
|
||||
|
||||
static void (*concatImp)(PSMatrix*, SEL, PSMatrix*) = 0;
|
||||
static SEL concatSel = @selector(concatenateWith:);
|
||||
|
||||
static void (*invalidateImp)(NSView*, SEL) = 0;
|
||||
static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
@ -71,6 +76,10 @@ static PSMatrix *flip = nil;
|
|||
|
||||
concatImp = (void (*)(PSMatrix*, SEL, PSMatrix*))
|
||||
[matrixClass instanceMethodForSelector: concatSel];
|
||||
|
||||
invalidateImp = (void (*)(NSView*, SEL))
|
||||
[self instanceMethodForSelector: invalidateSel];
|
||||
|
||||
flip = [[matrixClass matrixFrom: vals] retain];
|
||||
|
||||
NSDebugLog(@"Initialize NSView class\n");
|
||||
|
@ -79,9 +88,9 @@ static PSMatrix *flip = nil;
|
|||
}
|
||||
|
||||
/*
|
||||
* return the view at the top of thread's focus stack
|
||||
* or nil if none is focused
|
||||
*/
|
||||
* return the view at the top of thread's focus stack
|
||||
* or nil if none is focused
|
||||
*/
|
||||
+ (NSView*) focusView
|
||||
{
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
|
@ -124,9 +133,9 @@ static PSMatrix *flip = nil;
|
|||
|
||||
|
||||
/*
|
||||
* Remove the top focusView for the current thread from the stack
|
||||
* and return the new focusView (or nil if the stack is now empty).
|
||||
*/
|
||||
* Remove the top focusView for the current thread from the stack
|
||||
* and return the new focusView (or nil if the stack is now empty).
|
||||
*/
|
||||
+ (NSView*) popFocusView
|
||||
{
|
||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||
|
@ -307,6 +316,8 @@ static PSMatrix *flip = nil;
|
|||
if (!super_view) // if no superview then just return
|
||||
return;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
if ([window firstResponder] == self)
|
||||
[window makeFirstResponder: window];
|
||||
views = [super_view subviews];
|
||||
|
@ -323,6 +334,8 @@ static PSMatrix *flip = nil;
|
|||
if (!super_view) // if no superview then just return
|
||||
return;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
if ([window firstResponder] == self)
|
||||
[window makeFirstResponder: window];
|
||||
views = [super_view subviews];
|
||||
|
@ -340,10 +353,10 @@ static PSMatrix *flip = nil;
|
|||
return;
|
||||
|
||||
/*
|
||||
* NB. we implement the replacement in full rather than calling addSubview:
|
||||
* since classes like NSBox override these methods but expect to be able to
|
||||
* call [super replaceSubview: with: ] safely.
|
||||
*/
|
||||
* NB. we implement the replacement in full rather than calling addSubview:
|
||||
* since classes like NSBox override these methods but expect to be able to
|
||||
* call [super replaceSubview: with: ] safely.
|
||||
*/
|
||||
if (!oldView)
|
||||
{
|
||||
[newView retain];
|
||||
|
@ -388,17 +401,26 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void) viewWillMoveToWindow: (NSWindow*)newWindow
|
||||
{
|
||||
unsigned i, count;
|
||||
unsigned count;
|
||||
|
||||
window = newWindow;
|
||||
|
||||
count = [sub_views count];
|
||||
for (i = 0; i < count; ++i)
|
||||
[[sub_views objectAtIndex: i] viewWillMoveToWindow: newWindow];
|
||||
if (count > 0)
|
||||
{
|
||||
unsigned i;
|
||||
NSView* array[count];
|
||||
|
||||
[sub_views getObjects: array];
|
||||
for (i = 0; i < count; ++i)
|
||||
[array[i] viewWillMoveToWindow: newWindow];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) rotateByAngle: (float)angle
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
[boundsMatrix rotateByAngle: angle];
|
||||
is_rotated_from_base = is_rotated_or_scaled_from_base = YES;
|
||||
|
||||
|
@ -412,6 +434,8 @@ static PSMatrix *flip = nil;
|
|||
{
|
||||
NSSize old_size = frame.size;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
frame = frameRect;
|
||||
bounds.size = frame.size;
|
||||
[frameMatrix setFrameOrigin: frame.origin];
|
||||
|
@ -425,6 +449,8 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void) setFrameOrigin: (NSPoint)newOrigin
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
frame.origin = newOrigin;
|
||||
[frameMatrix setFrameOrigin: frame.origin];
|
||||
|
||||
|
@ -438,6 +464,8 @@ static PSMatrix *flip = nil;
|
|||
{
|
||||
NSSize old_size = frame.size;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
frame.size = bounds.size = newSize;
|
||||
|
||||
[self resizeSubviewsWithOldSize: old_size]; // Resize the subviews
|
||||
|
@ -449,6 +477,8 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void) setFrameRotation: (float)angle
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
[frameMatrix setFrameRotation: angle];
|
||||
is_rotated_from_base = is_rotated_or_scaled_from_base = YES;
|
||||
|
||||
|
@ -480,6 +510,8 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void) scaleUnitSquareToSize: (NSSize)newSize
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
if (!newSize.width)
|
||||
newSize.width = 1;
|
||||
if (!newSize.height)
|
||||
|
@ -503,6 +535,8 @@ static PSMatrix *flip = nil;
|
|||
{
|
||||
float sx, sy;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
if (aRect.size.width <= 0 || aRect.size.height <= 0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"illegal bounds size supplied"];
|
||||
|
@ -525,6 +559,8 @@ static PSMatrix *flip = nil;
|
|||
{
|
||||
bounds.origin = newOrigin;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
[boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
|
||||
|
||||
if (post_bounds_changes)
|
||||
|
@ -537,6 +573,8 @@ static PSMatrix *flip = nil;
|
|||
{
|
||||
float sx, sy;
|
||||
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
if (newSize.width <= 0 || newSize.height <= 0)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"illegal bounds size supplied"];
|
||||
|
@ -556,6 +594,8 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void) setBoundsRotation: (float)angle
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
[boundsMatrix setFrameRotation: angle];
|
||||
is_rotated_from_base = is_rotated_or_scaled_from_base = YES;
|
||||
|
||||
|
@ -567,6 +607,8 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void) translateOriginToPoint: (NSPoint)point
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
[boundsMatrix translateToPoint: point];
|
||||
|
||||
if (post_bounds_changes)
|
||||
|
@ -580,54 +622,6 @@ static PSMatrix *flip = nil;
|
|||
return NSZeroRect;
|
||||
}
|
||||
|
||||
- (PSMatrix*) _concatenateMatricesInReverseOrderFromPath: (NSArray*)viewsPath
|
||||
{
|
||||
PSMatrix *matrix = [[PSMatrix new] autorelease];
|
||||
unsigned i = [viewsPath count];
|
||||
NSView *matrices[i];
|
||||
NSView *parent;
|
||||
BOOL wasFlipped;
|
||||
BOOL isFlipped;
|
||||
|
||||
if (i-- < 2)
|
||||
return matrix;
|
||||
[viewsPath getObjects: matrices];
|
||||
parent = matrices[i];
|
||||
wasFlipped = [parent isFlipped];
|
||||
while (i-- > 0)
|
||||
{
|
||||
NSView *view = matrices[i];
|
||||
|
||||
(*concatImp)(matrix, concatSel, view->frameMatrix);
|
||||
isFlipped = [view isFlipped];
|
||||
if (isFlipped != wasFlipped)
|
||||
{
|
||||
flip->matrix[5] = view->bounds.size.height;
|
||||
(*concatImp)(matrix, concatSel, flip);
|
||||
}
|
||||
(*concatImp)(matrix, concatSel, view->boundsMatrix);
|
||||
parent = view;
|
||||
wasFlipped = isFlipped;
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
- (NSMutableArray*) _pathBetweenSubview: (NSView*)subview
|
||||
toSuperview: (NSView*)_superview
|
||||
{
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
NSView *view = subview;
|
||||
|
||||
while (view && view != _superview)
|
||||
{
|
||||
[array addObject: view];
|
||||
view = view->super_view;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
- (NSPoint) convertPoint: (NSPoint)aPoint fromView: (NSView*)aView
|
||||
{
|
||||
NSPoint new;
|
||||
|
@ -706,21 +700,6 @@ static PSMatrix *flip = nil;
|
|||
return r;
|
||||
}
|
||||
|
||||
- (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)viewsPath
|
||||
{
|
||||
unsigned count = [viewsPath count];
|
||||
PSMatrix* matrix = [[PSMatrix new] autorelease];
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
NSView* view = [viewsPath objectAtIndex: --count];
|
||||
|
||||
[matrix concatenateWith: view->boundsMatrix];
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
- (NSSize) convertSize: (NSSize)aSize fromView: (NSView*)aView
|
||||
{
|
||||
NSSize new;
|
||||
|
@ -884,7 +863,11 @@ static PSMatrix *flip = nil;
|
|||
}
|
||||
|
||||
if (changedSize || changedOrigin)
|
||||
[self resizeSubviewsWithOldSize: old_size];
|
||||
{
|
||||
if (coordinates_valid)
|
||||
(*invalidateImp)(self, invalidateSel);
|
||||
[self resizeSubviewsWithOldSize: old_size];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) allocateGState
|
||||
|
@ -930,20 +913,11 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (void)display
|
||||
{
|
||||
if(!window) // do nothing if not in
|
||||
return; // a window's heirarchy
|
||||
|
||||
if ([self isOpaque]) // if self is opaque
|
||||
[self displayRect:bounds]; // display visible rect
|
||||
else // else back up to a
|
||||
{
|
||||
NSView *firstOpaque = [self opaqueAncestor]; // convert rect into
|
||||
NSRect rect = bounds; // coordinates of the
|
||||
// first opaque view
|
||||
rect = [firstOpaque convertRect:rect fromView:self];
|
||||
[firstOpaque displayRect:rect];
|
||||
}
|
||||
}
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
[self displayRect: bounds];
|
||||
}
|
||||
|
||||
- (void) displayIfNeeded
|
||||
{
|
||||
|
@ -1002,6 +976,7 @@ static PSMatrix *flip = nil;
|
|||
BOOL stillNeedsDisplay = NO;
|
||||
NSRect rect;
|
||||
|
||||
count = [sub_views count];
|
||||
rect = NSIntersectionRect(aRect, invalidRect);
|
||||
if (NSIsEmptyRect(rect) == NO)
|
||||
{
|
||||
|
@ -1009,42 +984,52 @@ static PSMatrix *flip = nil;
|
|||
[self drawRect: rect];
|
||||
[self unlockFocus];
|
||||
|
||||
for (i = 0, count = [sub_views count]; i < count; i++)
|
||||
if (count > 0)
|
||||
{
|
||||
NSRect intersection;
|
||||
NSView *subview = [sub_views objectAtIndex: i];
|
||||
NSRect subviewFrame = subview->frame;
|
||||
NSView* array[count];
|
||||
|
||||
if ([subview->frameMatrix isRotated])
|
||||
{
|
||||
[subview->frameMatrix boundingRectFor: subviewFrame
|
||||
result: &subviewFrame];
|
||||
}
|
||||
intersection = NSIntersectionRect(rect, subviewFrame);
|
||||
if (NSIsEmptyRect(intersection) == NO)
|
||||
{
|
||||
intersection = [subview convertRect: intersection
|
||||
fromView: self];
|
||||
[subview displayRectIgnoringOpacity: intersection];
|
||||
}
|
||||
else
|
||||
[sub_views getObjects: array];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSRect isect;
|
||||
NSView *subview = array[i];
|
||||
NSRect subviewFrame = subview->frame;
|
||||
|
||||
if ([subview->frameMatrix isRotated])
|
||||
{
|
||||
[subview->frameMatrix boundingRectFor: subviewFrame
|
||||
result: &subviewFrame];
|
||||
}
|
||||
/*
|
||||
* Having drawn ourself into the rect, we must unconditionally
|
||||
* draw any subviews that are also in that rectangle.
|
||||
*/
|
||||
isect = NSIntersectionRect(rect, subviewFrame);
|
||||
if (NSIsEmptyRect(isect) == NO)
|
||||
{
|
||||
isect = [subview convertRect: isect
|
||||
fromView: self];
|
||||
[subview displayRectIgnoringOpacity: isect];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (subview->needs_display)
|
||||
{
|
||||
[subview displayIfNeededIgnoringOpacity];
|
||||
}
|
||||
}
|
||||
if (subview->needs_display)
|
||||
{
|
||||
[subview displayIfNeededIgnoringOpacity];
|
||||
stillNeedsDisplay = YES;
|
||||
}
|
||||
}
|
||||
if (subview->needs_display)
|
||||
{
|
||||
stillNeedsDisplay = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the rect we displayed contains the invalidRect
|
||||
* for the view then we can clear the invalidRect,
|
||||
* otherwise, we still need to be displayed.
|
||||
*/
|
||||
* If the rect we displayed contains the invalidRect
|
||||
* for the view then we can clear the invalidRect,
|
||||
* otherwise, we still need to be displayed.
|
||||
*/
|
||||
rect = NSUnionRect(invalidRect, aRect);
|
||||
if (NSEqualRects(rect, aRect) == YES)
|
||||
{
|
||||
|
@ -1055,32 +1040,35 @@ static PSMatrix *flip = nil;
|
|||
stillNeedsDisplay = YES;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (count > 0)
|
||||
{
|
||||
NSView* array[count];
|
||||
|
||||
[sub_views getObjects: array];
|
||||
/*
|
||||
* We don't have an invalidRect - so it must be one of our
|
||||
* subviews that actually needs the display.
|
||||
*/
|
||||
for (i = 0, count = [sub_views count]; i < count; i++)
|
||||
* We don't have an invalidRect - so it must be one of our
|
||||
* subviews that actually needs the display.
|
||||
*/
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSView *subview = [sub_views objectAtIndex: i];
|
||||
NSView *subview = array[i];
|
||||
|
||||
if (subview->needs_display)
|
||||
{
|
||||
NSRect subviewFrame = subview->frame;
|
||||
NSRect intersection;
|
||||
NSRect isect;
|
||||
|
||||
if ([subview->frameMatrix isRotated])
|
||||
{
|
||||
[subview->frameMatrix boundingRectFor: subviewFrame
|
||||
result: &subviewFrame];
|
||||
}
|
||||
intersection = NSIntersectionRect(aRect, subviewFrame);
|
||||
if (NSIsEmptyRect(intersection) == NO)
|
||||
isect = NSIntersectionRect(aRect, subviewFrame);
|
||||
if (NSIsEmptyRect(isect) == NO)
|
||||
{
|
||||
intersection = [subview convertRect: intersection
|
||||
fromView: self];
|
||||
[subview displayRectIgnoringOpacity: intersection];
|
||||
isect = [subview convertRect: isect
|
||||
fromView: self];
|
||||
[subview displayIfNeededInRectIgnoringOpacity: isect];
|
||||
}
|
||||
if (subview->needs_display)
|
||||
{
|
||||
|
@ -1089,7 +1077,10 @@ static PSMatrix *flip = nil;
|
|||
}
|
||||
}
|
||||
}
|
||||
needs_display = stillNeedsDisplay;
|
||||
if (NSIsEmptyRect(invalidRect) == NO)
|
||||
needs_display = YES;
|
||||
else
|
||||
needs_display = stillNeedsDisplay;
|
||||
[window flushWindow];
|
||||
}
|
||||
}
|
||||
|
@ -1126,32 +1117,41 @@ static PSMatrix *flip = nil;
|
|||
[self drawRect: aRect];
|
||||
[self unlockFocus];
|
||||
|
||||
for (i = 0, count = [sub_views count]; i < count; ++i)
|
||||
count = [sub_views count];
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
NSView *subview = [sub_views objectAtIndex: i];
|
||||
NSRect subviewFrame = subview->frame;
|
||||
NSRect intersection;
|
||||
NSView* array[count];
|
||||
|
||||
if ([subview->frameMatrix isRotated])
|
||||
[subview->frameMatrix boundingRectFor: subviewFrame
|
||||
result: &subviewFrame];
|
||||
[sub_views getObjects: array];
|
||||
|
||||
intersection = NSIntersectionRect(aRect, subviewFrame);
|
||||
if (NSIsEmptyRect(intersection) == NO)
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
intersection = [subview convertRect: intersection fromView: self];
|
||||
[subview displayRectIgnoringOpacity: intersection];
|
||||
}
|
||||
if (subview->needs_display)
|
||||
{
|
||||
stillNeedsDisplay = YES;
|
||||
NSView *subview = array[i];
|
||||
NSRect subviewFrame = subview->frame;
|
||||
NSRect intersection;
|
||||
|
||||
if ([subview->frameMatrix isRotated])
|
||||
[subview->frameMatrix boundingRectFor: subviewFrame
|
||||
result: &subviewFrame];
|
||||
|
||||
intersection = NSIntersectionRect(aRect, subviewFrame);
|
||||
if (NSIsEmptyRect(intersection) == NO)
|
||||
{
|
||||
intersection = [subview convertRect: intersection fromView: self];
|
||||
[subview displayRectIgnoringOpacity: intersection];
|
||||
}
|
||||
if (subview->needs_display)
|
||||
{
|
||||
stillNeedsDisplay = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the rect we displayed contains the invalidRect
|
||||
* for the view then we can empty invalidRect.
|
||||
*/
|
||||
* If the rect we displayed contains the invalidRect
|
||||
* for the view then we can empty invalidRect.
|
||||
*/
|
||||
rect = NSUnionRect(invalidRect, aRect);
|
||||
if (NSEqualRects(rect, aRect) == YES)
|
||||
{
|
||||
|
@ -1170,19 +1170,25 @@ static PSMatrix *flip = nil;
|
|||
|
||||
- (NSRect) visibleRect
|
||||
{
|
||||
if (coordinates_valid)
|
||||
return visibleRect;
|
||||
if (!window)
|
||||
return NSZeroRect;
|
||||
if (!super_view)
|
||||
return bounds;
|
||||
visibleRect = NSZeroRect;
|
||||
else if (!super_view)
|
||||
visibleRect = bounds;
|
||||
else
|
||||
{
|
||||
NSRect superviewsVisibleRect;
|
||||
NSRect superviewsVisibleRect;
|
||||
|
||||
superviewsVisibleRect = [self convertRect: [super_view visibleRect]
|
||||
fromView: super_view];
|
||||
|
||||
return NSIntersectionRect(superviewsVisibleRect, bounds);
|
||||
visibleRect = NSIntersectionRect(superviewsVisibleRect, bounds);
|
||||
if (needs_display)
|
||||
invalidRect = NSIntersectionRect(invalidRect, visibleRect);
|
||||
}
|
||||
coordinates_valid = YES;
|
||||
return visibleRect;
|
||||
}
|
||||
|
||||
- (void) setNeedsDisplay: (BOOL)flag
|
||||
|
@ -1201,10 +1207,10 @@ static PSMatrix *flip = nil;
|
|||
- (void) setNeedsDisplayInRect: (NSRect)rect
|
||||
{
|
||||
/*
|
||||
* Limit to bounds, combine with old invalidRect, and then check to see
|
||||
* if the result is the same as the old invalidRect - if it isn't then
|
||||
* set the new invalidRect.
|
||||
*/
|
||||
* Limit to bounds, combine with old invalidRect, and then check to see
|
||||
* if the result is the same as the old invalidRect - if it isn't then
|
||||
* set the new invalidRect.
|
||||
*/
|
||||
rect = NSIntersectionRect(rect, bounds);
|
||||
rect = NSUnionRect(invalidRect, rect);
|
||||
if (NSEqualRects(rect, invalidRect) == NO)
|
||||
|
@ -1232,29 +1238,20 @@ static PSMatrix *flip = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSRect) _boundingRectFor: (NSRect)rect
|
||||
{
|
||||
NSRect new;
|
||||
|
||||
[frameMatrix boundingRectFor: rect result: &new];
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
//
|
||||
// Scrolling
|
||||
//
|
||||
- (NSRect)adjustScroll: (NSRect)newVisible
|
||||
{
|
||||
return NSZeroRect;
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
- (BOOL)autoscroll: (NSEvent*)theEvent
|
||||
{
|
||||
if (super_view)
|
||||
return [super_view autoscroll: theEvent];
|
||||
if (super_view)
|
||||
return [super_view autoscroll: theEvent];
|
||||
|
||||
return NO;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) reflectScrolledClipView: (NSClipView*)aClipView
|
||||
|
@ -1325,12 +1322,19 @@ static PSMatrix *flip = nil;
|
|||
unsigned i, count;
|
||||
|
||||
count = [sub_views count];
|
||||
for (i = 0; i < count; ++i)
|
||||
if (count > 0)
|
||||
{
|
||||
id view = [sub_views objectAtIndex: i];
|
||||
NSView* array[count];
|
||||
|
||||
if ([view tag] == aTag)
|
||||
return view;
|
||||
[sub_views getObjects: array];
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
NSView *view = array[i];
|
||||
|
||||
if ([view tag] == aTag)
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
@ -1357,14 +1361,20 @@ static PSMatrix *flip = nil;
|
|||
p = [self convertPoint: aPoint fromView: super_view];
|
||||
|
||||
count = [sub_views count]; // Check our sub_views
|
||||
while (count > 0)
|
||||
if (count > 0)
|
||||
{
|
||||
w = [sub_views objectAtIndex: --count];
|
||||
v = [w hitTest: p];
|
||||
if (v)
|
||||
break;
|
||||
}
|
||||
NSView* array[count];
|
||||
|
||||
[sub_views getObjects: array];
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
w = array[--count];
|
||||
v = [w hitTest: p];
|
||||
if (v)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (v) // mouse is either in the subview or within self
|
||||
return v;
|
||||
else
|
||||
|
@ -1636,9 +1646,9 @@ static PSMatrix *flip = nil;
|
|||
frame = [aDecoder decodeRect];
|
||||
bounds = [aDecoder decodeRect];
|
||||
super_view = [aDecoder decodeObject];
|
||||
sub_views = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &sub_views];
|
||||
window = [aDecoder decodeObject];
|
||||
tracking_rects = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &tracking_rects];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_rotated_from_base];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &is_rotated_or_scaled_from_base];
|
||||
|
@ -1739,16 +1749,6 @@ static PSMatrix *flip = nil;
|
|||
return [frameMatrix rotationAngle];
|
||||
}
|
||||
|
||||
- (PSMatrix*) _boundsMatrix
|
||||
{
|
||||
return boundsMatrix;
|
||||
}
|
||||
|
||||
- (PSMatrix*) _frameMatrix
|
||||
{
|
||||
return frameMatrix;
|
||||
}
|
||||
|
||||
- (BOOL) postsFrameChangedNotifications
|
||||
{
|
||||
return post_frame_changes;
|
||||
|
@ -1759,4 +1759,117 @@ static PSMatrix *flip = nil;
|
|||
return post_bounds_changes;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Private methods.
|
||||
*/
|
||||
|
||||
- (NSRect) _boundingRectFor: (NSRect)rect
|
||||
{
|
||||
NSRect new;
|
||||
|
||||
[frameMatrix boundingRectFor: rect result: &new];
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
- (PSMatrix*) _boundsMatrix
|
||||
{
|
||||
return boundsMatrix;
|
||||
}
|
||||
|
||||
- (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)viewsPath
|
||||
{
|
||||
unsigned count = [viewsPath count];
|
||||
PSMatrix* matrix = [[PSMatrix new] autorelease];
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
NSView* view = [viewsPath objectAtIndex: --count];
|
||||
|
||||
[matrix concatenateWith: view->boundsMatrix];
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
- (PSMatrix*) _concatenateMatricesInReverseOrderFromPath: (NSArray*)viewsPath
|
||||
{
|
||||
PSMatrix *matrix = [[PSMatrix new] autorelease];
|
||||
unsigned i = [viewsPath count];
|
||||
NSView *matrices[i];
|
||||
NSView *parent;
|
||||
BOOL wasFlipped;
|
||||
BOOL isFlipped;
|
||||
|
||||
if (i-- < 2)
|
||||
return matrix;
|
||||
[viewsPath getObjects: matrices];
|
||||
parent = matrices[i];
|
||||
wasFlipped = [parent isFlipped];
|
||||
while (i-- > 0)
|
||||
{
|
||||
NSView *view = matrices[i];
|
||||
|
||||
(*concatImp)(matrix, concatSel, view->frameMatrix);
|
||||
isFlipped = [view isFlipped];
|
||||
if (isFlipped != wasFlipped)
|
||||
{
|
||||
flip->matrix[5] = view->bounds.size.height;
|
||||
(*concatImp)(matrix, concatSel, flip);
|
||||
}
|
||||
(*concatImp)(matrix, concatSel, view->boundsMatrix);
|
||||
parent = view;
|
||||
wasFlipped = isFlipped;
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
- (void) _invalidateCoordinates
|
||||
{
|
||||
if (coordinates_valid == YES)
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
coordinates_valid = NO;
|
||||
count = [sub_views count];
|
||||
if (count > 0)
|
||||
{
|
||||
NSView* array[count];
|
||||
unsigned i;
|
||||
|
||||
[sub_views getObjects: array];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSView *sub = array[i];
|
||||
|
||||
if (sub->coordinates_valid == YES)
|
||||
(*invalidateImp)(sub, invalidateSel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (PSMatrix*) _frameMatrix
|
||||
{
|
||||
return frameMatrix;
|
||||
}
|
||||
|
||||
- (NSMutableArray*) _pathBetweenSubview: (NSView*)subview
|
||||
toSuperview: (NSView*)_superview
|
||||
{
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
NSView *view = subview;
|
||||
|
||||
while (view && view != _superview)
|
||||
{
|
||||
[array addObject: view];
|
||||
view = view->super_view;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue