mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
The first implementation of scroll views.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2370 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e21d6456f3
commit
6f7b6620d0
17 changed files with 1513 additions and 1038 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
Tue Aug 5 14:39:29 1997 Ovidiu Predescu <ovidiu@net-community.com>
|
||||
|
||||
* Images/common_ArrowLeftH.tiff: New file.
|
||||
* Images/common_ArrowRightH.tiff: Likewise.
|
||||
* Images/common_ArrowUpH.tiff: Likewise.
|
||||
* Images/common_ArrowDownH.tiff: Likewise.
|
||||
* Source/NSApplication.m (-nextEventMatchingMask:untilDate:inMode:
|
||||
dequeue:): Do not pop-up the time events from the queue immediately
|
||||
after -limitDateForMode: to avoid loosing the normal events.
|
||||
* Source/NSCell.m: Handle sending action continuously while the user
|
||||
tracks the mouse.
|
||||
* Source/NSButtonCell.m: Likewise.
|
||||
* Source/NSButton.m: Likewise.
|
||||
|
||||
Implementation of scroll views.
|
||||
* Source/NSClipView.m: The initial implementation.
|
||||
* Source/NSScrollView.m: Likewise.
|
||||
* Source/NSScroller.m: Optimized to work with time events to gain speed
|
||||
in user interaction.
|
||||
|
||||
* Source/NSView.m: Post notifications if needed when a frame or bound
|
||||
change.
|
||||
|
||||
Mon Aug 04 13:16:54 1997 Scott Christley <scottc@ruth.net-community.com>
|
||||
|
||||
* Source/externs.m: New file.
|
||||
|
|
|
@ -55,6 +55,8 @@ typedef enum _NSButtonType {
|
|||
BOOL transparent;
|
||||
unsigned int highlightsByMask;
|
||||
unsigned int showAltStateMask;
|
||||
float delayInterval;
|
||||
float repeatInterval;
|
||||
|
||||
// Reserved for back-end use
|
||||
void *be_bc_reserved;
|
||||
|
|
|
@ -119,6 +119,7 @@ enum {
|
|||
NSView *control_view;
|
||||
NSSize cell_size;
|
||||
id represented_object;
|
||||
unsigned int action_mask;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
/*
|
||||
NSClipView.h
|
||||
|
||||
A clipped view
|
||||
The class that contains the document view displayed by a NSScrollView.
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Date: July 1997
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -21,10 +21,9 @@
|
|||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
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.
|
||||
*/
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSClipView
|
||||
#define _GNUstep_H_NSClipView
|
||||
|
@ -32,56 +31,68 @@
|
|||
#include <AppKit/NSView.h>
|
||||
|
||||
@class NSNotification;
|
||||
|
||||
@class NSCursor;
|
||||
@class NSEvent;
|
||||
@class NSColor;
|
||||
|
||||
@interface NSClipView : NSView <NSCoding>
|
||||
@interface NSClipView : NSView
|
||||
{
|
||||
// Attributes
|
||||
NSView* _documentView;
|
||||
NSCursor* _cursor;
|
||||
NSColor* _backgroundColor;
|
||||
BOOL _copiesOnScroll;
|
||||
}
|
||||
|
||||
//
|
||||
// Managing the Document View
|
||||
//
|
||||
- (NSRect)documentRect;
|
||||
/* Setting the document view */
|
||||
- (void)setDocumentView:(NSView*)aView;
|
||||
- (id)documentView;
|
||||
- (NSRect)documentVisibleRect;
|
||||
- (void)setDocumentView:(NSView *)aView;
|
||||
|
||||
//
|
||||
// Setting the Cursor
|
||||
//
|
||||
- (NSCursor *)documentCursor;
|
||||
- (void)setDocumentCursor:(NSCursor *)anObject;
|
||||
|
||||
//
|
||||
// Setting the Background Color
|
||||
//
|
||||
- (NSColor *)backgroundColor;
|
||||
- (void)setBackgroundColor:(NSColor *)color;
|
||||
|
||||
//
|
||||
// Scrolling
|
||||
//
|
||||
- (BOOL)autoscroll:(NSEvent *)theEvent;
|
||||
- (NSPoint)constrainScrollPoint:(NSPoint)newOrigin;
|
||||
- (BOOL)copiesOnScroll;
|
||||
/* Scrolling */
|
||||
- (void)scrollToPoint:(NSPoint)newOrigin;
|
||||
- (BOOL)autoscroll:(NSEvent*)theEvent;
|
||||
- (NSPoint)constrainScrollPoint:(NSPoint)proposedNewOrigin;
|
||||
|
||||
/* Determining scrolling efficiency */
|
||||
- (void)setCopiesOnScroll:(BOOL)flag;
|
||||
- (BOOL)copiesOnScroll;
|
||||
|
||||
//
|
||||
// Responding to a Changed Frame
|
||||
//
|
||||
- (void)viewFrameChanged:(NSNotification *)notification;
|
||||
/* Getting the visible portion */
|
||||
- (NSRect)documentRect;
|
||||
- (NSRect)documentVisibleRect;
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder;
|
||||
- initWithCoder:aDecoder;
|
||||
/* Setting the document cursor */
|
||||
- (void)setDocumentCursor:(NSCursor*)aCursor;
|
||||
- (NSCursor*)documentCursor;
|
||||
|
||||
/* Setting the background color */
|
||||
- (void)setBackgroundColor:(NSColor*)aColor;
|
||||
- (NSColor*)backgroundColor;
|
||||
|
||||
/* Overridden NSView methods */
|
||||
- (BOOL)acceptsFirstResponder;
|
||||
- (BOOL)isFlipped;
|
||||
- (void)rotateByAngle:(float)angle;
|
||||
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize;
|
||||
- (void)setBoundsOrigin:(NSPoint)aPoint;
|
||||
- (void)setBoundsRotation:(float)angle;
|
||||
- (void)setBoundsSize:(NSSize)aSize;
|
||||
- (void)setFrameSize:(NSSize)aSize;
|
||||
- (void)setFrameOrigin:(NSPoint)aPoint;
|
||||
- (void)setFrameRotation:(float)angle;
|
||||
- (void)translateOriginToPoint:(NSPoint)aPoint;
|
||||
- (void)viewBoundsChanged:(NSNotification*)aNotification;
|
||||
- (void)viewFrameChanged:(NSNotification*)aNotification;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _GNUstep_H_NSClipView
|
||||
|
||||
@interface NSClipView (SuperviewMethods)
|
||||
- (void)reflectScrolledClipView:(NSClipView*)aClipView;
|
||||
- (void)scrollClipView:(NSClipView*)aClipView toPoint:(NSPoint)newOrigin;
|
||||
@end
|
||||
|
||||
|
||||
@interface NSClipView (BackendMethods)
|
||||
- (void)_translateToPoint:(NSPoint)point oldPoint:(NSPoint)oldPoint;
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_NSClipView */
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*
|
||||
/*
|
||||
NSScrollView.h
|
||||
|
||||
A scrolling view to allow documents larger than screen to be shown
|
||||
A view that allows you to scroll a document view that's too big to display
|
||||
entirely on a window.
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Date: July 1997
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -21,91 +22,105 @@
|
|||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
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.
|
||||
*/
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSScrollView
|
||||
#define _GNUstep_H_NSScrollView
|
||||
|
||||
#include <AppKit/NSView.h>
|
||||
|
||||
@class NSScroller;
|
||||
@class NSClipView;
|
||||
@class NSRulerView;
|
||||
@class NSColor;
|
||||
@class NSCursor;
|
||||
@class NSScroller;
|
||||
|
||||
@interface NSScrollView : NSView <NSCoding>
|
||||
@interface NSScrollView : NSView
|
||||
{
|
||||
// Attributes
|
||||
NSClipView* _contentView;
|
||||
NSScroller* _horizScroller;
|
||||
NSScroller* _vertScroller;
|
||||
NSRulerView* _horizRuler;
|
||||
NSRulerView* _vertRuler;
|
||||
float _lineScroll;
|
||||
float _pageScroll;
|
||||
NSBorderType _borderType;
|
||||
BOOL _hasHorizScroller;
|
||||
BOOL _hasVertScroller;
|
||||
BOOL _hasHorizRuler;
|
||||
BOOL _hasVertRuler;
|
||||
BOOL _scrollsDynamically;
|
||||
BOOL _rulersVisible;
|
||||
}
|
||||
|
||||
//
|
||||
// Determining Component Sizes
|
||||
//
|
||||
/* Calculating layout */
|
||||
+ (NSSize)contentSizeForFrameSize:(NSSize)frameSize
|
||||
hasHorizontalScroller:(BOOL)hFlag
|
||||
hasVerticalScroller:(BOOL)vFlag
|
||||
borderType:(NSBorderType)borderType;
|
||||
+ (NSSize)frameSizeForContentSize:(NSSize)contentSize
|
||||
hasHorizontalScroller:(BOOL)hFlag
|
||||
hasVerticalScroller:(BOOL)vFlag
|
||||
borderType:(NSBorderType)borderType;
|
||||
|
||||
/* Determining component sizes */
|
||||
- (NSSize)contentSize;
|
||||
- (NSRect)documentVisibleRect;
|
||||
|
||||
//
|
||||
// Laying Out the NSScrollView
|
||||
//
|
||||
+ (NSSize)contentSizeForFrameSize:(NSSize)size
|
||||
hasHorizontalScroller:(BOOL)horizFlag
|
||||
hasVerticalScroller:(BOOL)vertFlag
|
||||
borderType:(NSBorderType)aType;
|
||||
+ (NSSize)frameSizeForContentSize:(NSSize)size
|
||||
hasHorizontalScroller:(BOOL)horizFlag
|
||||
hasVerticalScroller:(BOOL)vertFlag
|
||||
borderType:(NSBorderType)aType;
|
||||
/* Managing graphic attributes */
|
||||
- (void)setBackgroundColor:(NSColor*)aColor;
|
||||
- (NSColor*)backgroundColor;
|
||||
- (void)setBorderType:(NSBorderType)borderType;
|
||||
- (NSBorderType)borderType;
|
||||
|
||||
/* Managing the scrolled views */
|
||||
- (void)setContentView:(NSClipView*)aView;
|
||||
- (NSClipView*)contentView;
|
||||
- (void)setDocumentView:(NSView*)aView;
|
||||
- (id)documentView;
|
||||
- (void)setDocumentCursor:(NSCursor*)aCursor;
|
||||
- (NSCursor*)documentCursor;
|
||||
|
||||
/* Managing scrollers */
|
||||
- (void)setHorizontalScroller:(NSScroller*)aScroller;
|
||||
- (NSScroller*)horizontalScroller;
|
||||
- (void)setHasHorizontalScroller:(BOOL)flag;
|
||||
- (BOOL)hasHorizontalScroller;
|
||||
- (void)setVerticalScroller:(NSScroller*)aScroller;
|
||||
- (NSScroller*)verticalScroller;
|
||||
- (void)setHasVerticalScroller:(BOOL)flag;
|
||||
- (BOOL)hasVerticalScroller;
|
||||
- (void)tile;
|
||||
- (void)toggleRuler:(id)sender;
|
||||
- (BOOL)isRulerVisible;
|
||||
|
||||
//
|
||||
// Managing Component Views
|
||||
//
|
||||
- (void)setDocumentView:(NSView *)aView;
|
||||
- (id)documentView;
|
||||
- (void)setHorizontalScroller:(NSScroller *)anObject;
|
||||
- (NSScroller *)horizontalScroller;
|
||||
- (void)setVerticalScroller:(NSScroller *)anObject;
|
||||
- (NSScroller *)verticalScroller;
|
||||
- (void)reflectScrolledClipView:(NSClipView *)cView;
|
||||
/* Managing rulers */
|
||||
+ (void)setRulerViewClass:(Class)aClass;
|
||||
+ (Class)rulerViewClass;
|
||||
- (void)setHasHorizontalRuler:(BOOL)flag;
|
||||
- (BOOL)hasHorizontalRuler;
|
||||
- (void)setHorizontalRulerView:(NSRulerView*)aRulerView;
|
||||
- (NSRulerView*)horizontalRulerView;
|
||||
- (void)setHasVerticalRuler:(BOOL)flag;
|
||||
- (BOOL)hasVerticalRuler;
|
||||
- (void)setVerticalRulerView:(NSRulerView*)aRulerView;
|
||||
- (NSRulerView*)verticalRulerView;
|
||||
- (void)setRulersVisible:(BOOL)flag;
|
||||
- (BOOL)rulersVisible;
|
||||
|
||||
//
|
||||
// Modifying Graphic Attributes
|
||||
//
|
||||
- (void)setBorderType:(NSBorderType)aType;
|
||||
- (NSBorderType)borderType;
|
||||
- (void)setBackgroundColor:(NSColor *)color;
|
||||
- (NSColor *)backgroundColor;
|
||||
|
||||
//
|
||||
// Setting Scrolling Behavior
|
||||
//
|
||||
/* Setting scrolling behavior */
|
||||
- (void)setLineScroll:(float)aFloat;
|
||||
- (float)lineScroll;
|
||||
- (void)setPageScroll:(float)aFloat;
|
||||
- (float)pageScroll;
|
||||
- (void)setScrollsDynamically:(BOOL)flag;
|
||||
- (BOOL)scrollsDynamically;
|
||||
- (void)setLineScroll:(float)value;
|
||||
- (void)setPageScroll:(float)value;
|
||||
|
||||
//
|
||||
// Managing the Cursor
|
||||
//
|
||||
- (void)setDocumentCursor:(NSCursor *)anObject;
|
||||
/* Updating display after scrolling */
|
||||
- (void)reflectScrolledClipView:(NSClipView*)aClipView;
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder;
|
||||
- initWithCoder:aDecoder;
|
||||
/* Arranging components */
|
||||
- (void)tile;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _GNUstep_H_NSScrollView
|
||||
#endif /* _GNUstep_H_NSScrollView */
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
A completely rewritten version of the original source by Scott Christley.
|
||||
Date: July 1997
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -40,17 +41,17 @@ typedef enum _NSScrollArrowPosition {
|
|||
} NSScrollArrowPosition;
|
||||
|
||||
typedef enum _NSScrollerPart {
|
||||
NSScrollerNoPart,
|
||||
NSScrollerNoPart = 0,
|
||||
NSScrollerDecrementPage,
|
||||
NSScrollerKnob,
|
||||
NSScrollerIncrementPage,
|
||||
NSScrollerDecrementLine,
|
||||
NSScrollerIncrementLine,
|
||||
NSScrollerKnobSlot
|
||||
NSScrollerKnobSlot
|
||||
} NSScrollerPart;
|
||||
|
||||
typedef enum _NSScrollerUsablePart {
|
||||
NSNoScrollerParts,
|
||||
NSNoScrollerParts = 0,
|
||||
NSOnlyScrollerArrows,
|
||||
NSAllScrollerParts
|
||||
} NSUsableScrollerParts;
|
||||
|
@ -60,18 +61,17 @@ typedef enum _NSScrollerArrow {
|
|||
NSScrollerDecrementArrow
|
||||
} NSScrollerArrow;
|
||||
|
||||
extern const float NSScrollerWidth;
|
||||
|
||||
@interface NSScroller : NSControl <NSCoding>
|
||||
{
|
||||
// Attributes
|
||||
BOOL is_horizontal;
|
||||
float knob_proportion;
|
||||
NSScrollerPart hit_part;
|
||||
NSScrollArrowPosition arrows_position;
|
||||
NSImage *increment_arrow;
|
||||
NSImage *decrement_arrow;
|
||||
NSImage *knob_dimple;
|
||||
float _floatValue;
|
||||
float _knobProportion;
|
||||
id _target;
|
||||
SEL _action;
|
||||
BOOL _isHorizontal;
|
||||
BOOL _isEnabled;
|
||||
NSScrollerPart _hitPart;
|
||||
NSScrollArrowPosition _arrowsPosition;
|
||||
NSUsableScrollerParts _usableParts;
|
||||
|
||||
// Reserved for back-end use
|
||||
void *be_scroll_reserved;
|
||||
|
@ -101,9 +101,9 @@ extern const float NSScrollerWidth;
|
|||
//
|
||||
- (void)drawArrow:(NSScrollerArrow)whichButton
|
||||
highlight:(BOOL)flag;
|
||||
- (void)drawKnobSlot;
|
||||
- (void)drawKnob;
|
||||
- (void)drawParts;
|
||||
- (void)highlight:(BOOL)flag;
|
||||
|
||||
//
|
||||
// Handling Events
|
||||
|
@ -113,25 +113,9 @@ extern const float NSScrollerWidth;
|
|||
- (void)trackKnob:(NSEvent *)theEvent;
|
||||
- (void)trackScrollButtons:(NSEvent *)theEvent;
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder;
|
||||
- initWithCoder:aDecoder;
|
||||
|
||||
@end
|
||||
|
||||
//
|
||||
// Methods implemented by the backend
|
||||
//
|
||||
@interface NSScroller (GNUstepBackend)
|
||||
|
||||
- (void)drawBar;
|
||||
- (NSRect)boundsOfScrollerPart:(NSScrollerPart)part;
|
||||
- (BOOL)isPointInIncrementArrow:(NSPoint)aPoint;
|
||||
- (BOOL)isPointInDecrementArrow:(NSPoint)aPoint;
|
||||
- (BOOL)isPointInKnob:(NSPoint)aPoint;
|
||||
- (BOOL)isPointInBar:(NSPoint)aPoint;
|
||||
/* Other methods */
|
||||
- (void)setFrameSize:(NSSize)size;
|
||||
- (void)setEnabled:(BOOL)flag;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -76,13 +76,13 @@ enum {
|
|||
NSMutableArray *tracking_rects;
|
||||
NSMutableArray *cursor_rects;
|
||||
|
||||
BOOL is_flipped;
|
||||
BOOL is_rotated_from_base;
|
||||
BOOL is_rotated_or_scaled_from_base;
|
||||
BOOL opaque;
|
||||
BOOL needs_display;
|
||||
BOOL disable_autodisplay;
|
||||
BOOL post_frame_changes;
|
||||
BOOL post_bounds_changes;
|
||||
BOOL autoresize_subviews;
|
||||
|
||||
// Reserved for back-end use
|
||||
|
@ -162,8 +162,10 @@ enum {
|
|||
//
|
||||
// Notifying Ancestor Views
|
||||
//
|
||||
- (BOOL)postsFrameChangedNotifications;
|
||||
- (void)setPostsFrameChangedNotifications:(BOOL)flag;
|
||||
- (BOOL)postsFrameChangedNotifications;
|
||||
- (void)setPostsBoundsChangedNotifications:(BOOL)flag;
|
||||
- (BOOL)postsBoundsChangedNotifications;
|
||||
|
||||
//
|
||||
// Resizing Subviews
|
||||
|
@ -335,7 +337,8 @@ enum {
|
|||
@end
|
||||
|
||||
/* Notifications */
|
||||
extern NSString *NSViewFrameChangedNotification;
|
||||
extern NSString *NSViewFocusChangedNotification;
|
||||
extern NSString *NSViewFrameDidChangeNotification;
|
||||
extern NSString *NSViewBoundsDidChangeNotification;
|
||||
extern NSString *NSViewFocusDidChangeNotification;
|
||||
|
||||
#endif // _GNUstep_H_NSView
|
||||
|
|
|
@ -50,7 +50,6 @@ extern NSEvent *gnustep_gui_null_event;
|
|||
// Class variables
|
||||
//
|
||||
static BOOL gnustep_gui_app_is_in_dealloc;
|
||||
|
||||
@implementation NSApplication
|
||||
|
||||
//
|
||||
|
@ -422,12 +421,6 @@ static BOOL gnustep_gui_app_is_in_dealloc;
|
|||
while (!done) {
|
||||
NSDate* limitDate = [currentLoop limitDateForMode:mode];
|
||||
|
||||
/* -limitDateForMode: can fire timers and timer events can be quueued in
|
||||
events queue so check for them. */
|
||||
event = [self _eventMatchingMask:mask];
|
||||
if (event)
|
||||
break;
|
||||
|
||||
if (!expiration)
|
||||
expiration = [NSDate distantFuture];
|
||||
|
||||
|
|
|
@ -141,11 +141,15 @@ id gnustep_gui_nsbutton_class = nil;
|
|||
//
|
||||
- (void)getPeriodicDelay:(float *)delay
|
||||
interval:(float *)interval
|
||||
{}
|
||||
{
|
||||
[cell getPeriodicDelay:delay interval:interval];
|
||||
}
|
||||
|
||||
- (void)setPeriodicDelay:(float)delay
|
||||
interval:(float)interval
|
||||
{}
|
||||
{
|
||||
[cell setPeriodicDelay:delay interval:interval];
|
||||
}
|
||||
|
||||
//
|
||||
// Setting the Titles
|
||||
|
|
|
@ -70,6 +70,8 @@
|
|||
[self setEnabled:YES];
|
||||
[self setTransparent:NO];
|
||||
[self setBordered:YES];
|
||||
delayInterval = 0.4;
|
||||
repeatInterval = 0.075;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -81,6 +83,8 @@
|
|||
[self setEnabled:YES];
|
||||
[self setTransparent:NO];
|
||||
[self setBordered:YES];
|
||||
delayInterval = 0.4;
|
||||
repeatInterval = 0.075;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -153,11 +157,18 @@
|
|||
//
|
||||
- (void)getPeriodicDelay:(float *)delay
|
||||
interval:(float *)interval
|
||||
{}
|
||||
{
|
||||
*delay = delayInterval;
|
||||
*interval = repeatInterval;
|
||||
}
|
||||
|
||||
- (void)setPeriodicDelay:(float)delay
|
||||
interval:(float)interval
|
||||
{}
|
||||
{
|
||||
delayInterval = delay;
|
||||
repeatInterval = interval;
|
||||
[self setContinuous:YES];
|
||||
}
|
||||
|
||||
//
|
||||
// Setting the Key Equivalent
|
||||
|
|
237
Source/NSCell.m
237
Source/NSCell.m
|
@ -27,11 +27,13 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSValue.h>
|
||||
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSControl.h>
|
||||
#include <AppKit/NSCell.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
|
||||
|
@ -82,6 +84,7 @@
|
|||
cell_float_autorange = NO;
|
||||
cell_float_left = 0;
|
||||
cell_float_right = 0;
|
||||
action_mask = NSLeftMouseUpMask;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -523,7 +526,11 @@
|
|||
|
||||
- (int)sendActionOn:(int)mask
|
||||
{
|
||||
return 0;
|
||||
unsigned int previousMask = action_mask;
|
||||
|
||||
action_mask = mask;
|
||||
|
||||
return previousMask;
|
||||
}
|
||||
|
||||
- (void)setAction:(SEL)aSelector
|
||||
|
@ -532,6 +539,7 @@
|
|||
- (void)setContinuous:(BOOL)flag
|
||||
{
|
||||
cell_continuous = flag;
|
||||
[self sendActionOn:(NSLeftMouseUpMask|NSPeriodicMask)];
|
||||
}
|
||||
|
||||
- (void)setTarget:(id)anObject
|
||||
|
@ -582,7 +590,10 @@
|
|||
|
||||
- (void)getPeriodicDelay:(float *)delay
|
||||
interval:(float *)interval
|
||||
{}
|
||||
{
|
||||
*delay = 0.0;
|
||||
*interval = 0.05;
|
||||
}
|
||||
|
||||
- (BOOL)startTrackingAt:(NSPoint)startPoint
|
||||
inView:(NSView *)controlView
|
||||
|
@ -606,117 +617,141 @@
|
|||
ofView:(NSView *)controlView
|
||||
untilMouseUp:(BOOL)flag
|
||||
{
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
NSEvent *e;
|
||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||
NSMouseMovedMask | NSLeftMouseDraggedMask |
|
||||
NSRightMouseDraggedMask;
|
||||
NSPoint location = [theEvent locationInWindow];
|
||||
NSPoint point = [controlView convertPoint: location fromView: nil];
|
||||
NSPoint last_point;
|
||||
BOOL done;
|
||||
BOOL mouseWentUp;
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||
NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask;
|
||||
NSPoint location = [theEvent locationInWindow];
|
||||
NSPoint point = [controlView convertPoint: location fromView: nil];
|
||||
float delay, interval;
|
||||
id target = [self target];
|
||||
SEL action = [self action];
|
||||
NSPoint last_point;
|
||||
BOOL done;
|
||||
BOOL mouseWentUp;
|
||||
|
||||
NSDebugLog(@"NSCell start tracking\n");
|
||||
NSDebugLog(@"NSCell tracking in rect %f %f %f %f\n",
|
||||
cellFrame.origin.x, cellFrame.origin.y,
|
||||
cellFrame.size.width, cellFrame.size.height);
|
||||
NSDebugLog(@"NSCell initial point %f %f\n", point.x, point.y);
|
||||
NSDebugLog(@"NSCell start tracking\n");
|
||||
NSDebugLog(@"NSCell tracking in rect %f %f %f %f\n",
|
||||
cellFrame.origin.x, cellFrame.origin.y,
|
||||
cellFrame.size.width, cellFrame.size.height);
|
||||
NSDebugLog(@"NSCell initial point %f %f\n", point.x, point.y);
|
||||
|
||||
if (![self startTrackingAt: point inView: controlView])
|
||||
return NO;
|
||||
if (![self startTrackingAt: point inView: controlView])
|
||||
return NO;
|
||||
|
||||
// If point is in cellFrame then highlight the cell
|
||||
if ([controlView mouse: point inRect: cellFrame])
|
||||
{
|
||||
[self highlight:YES withFrame:cellFrame inView:controlView];
|
||||
// If point is in cellFrame then highlight the cell
|
||||
if ([controlView mouse: point inRect: cellFrame]) {
|
||||
[self highlight:YES withFrame:cellFrame inView:controlView];
|
||||
[[controlView window] flushWindow];
|
||||
}
|
||||
else
|
||||
return NO;
|
||||
|
||||
if ([theEvent type] == NSLeftMouseDown
|
||||
&& (action_mask & NSLeftMouseDownMask))
|
||||
[(NSControl*)controlView sendAction:action to:target];
|
||||
|
||||
if (cell_continuous) {
|
||||
[self getPeriodicDelay:&delay interval:&interval];
|
||||
[NSEvent startPeriodicEventsAfterDelay:delay withPeriod:interval];
|
||||
event_mask |= NSPeriodicMask;
|
||||
}
|
||||
|
||||
// Get next mouse events until a mouse up is obtained
|
||||
NSDebugLog(@"NSCell get mouse events\n");
|
||||
mouseWentUp = NO;
|
||||
done = NO;
|
||||
while (!done) {
|
||||
NSEventType eventType;
|
||||
BOOL pointIsInCell;
|
||||
|
||||
last_point = point;
|
||||
theEvent = [theApp nextEventMatchingMask:event_mask untilDate:nil
|
||||
inMode:NSEventTrackingRunLoopMode dequeue:YES];
|
||||
eventType = [theEvent type];
|
||||
|
||||
if (eventType != NSPeriodic) {
|
||||
location = [theEvent locationInWindow];
|
||||
point = [controlView convertPoint: location fromView: nil];
|
||||
NSDebugLog(@"NSCell location %f %f\n", location.x, location.y);
|
||||
NSDebugLog(@"NSCell point %f %f\n", point.x, point.y);
|
||||
}
|
||||
else
|
||||
NSDebugLog (@"got a periodic event");
|
||||
|
||||
// Point is not in cell
|
||||
if (![controlView mouse: point inRect: cellFrame]) {
|
||||
NSDebugLog(@"NSCell point not in cell frame\n");
|
||||
|
||||
pointIsInCell = NO;
|
||||
|
||||
// unhighlight cell is highlighted
|
||||
if (cell_highlighted) {
|
||||
[self highlight: NO withFrame: cellFrame
|
||||
inView: controlView];
|
||||
[self drawWithFrame: cellFrame inView: controlView];
|
||||
[[controlView window] flushWindow];
|
||||
}
|
||||
else
|
||||
return NO;
|
||||
|
||||
// Do we now return or keep tracking
|
||||
if (!([[self class] prefersTrackingUntilMouseUp] && flag)) {
|
||||
NSDebugLog(@"NSCell return immediately\n");
|
||||
done = YES;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Point is in cell
|
||||
pointIsInCell = YES;
|
||||
|
||||
// Get next mouse events until a mouse up is obtained
|
||||
NSDebugLog(@"NSCell get mouse events\n");
|
||||
mouseWentUp = NO;
|
||||
done = NO;
|
||||
while (!done)
|
||||
{
|
||||
last_point = point;
|
||||
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
|
||||
inMode:NSEventTrackingRunLoopMode dequeue:YES];
|
||||
location = [e locationInWindow];
|
||||
point = [controlView convertPoint: location fromView: nil];
|
||||
NSDebugLog(@"NSCell location %f %f\n", location.x, location.y);
|
||||
NSDebugLog(@"NSCell point %f %f\n", point.x, point.y);
|
||||
// highlight cell if not highlighted
|
||||
if (!cell_highlighted) {
|
||||
[self highlight: YES withFrame: cellFrame
|
||||
inView: controlView];
|
||||
//[self drawWithFrame: cellFrame inView: controlView];
|
||||
[[controlView window] flushWindow];
|
||||
}
|
||||
}
|
||||
|
||||
// Point is not in cell
|
||||
if (![controlView mouse: point inRect: cellFrame])
|
||||
{
|
||||
NSDebugLog(@"NSCell point not in cell frame\n");
|
||||
// unhighlight cell is highlighted
|
||||
if (cell_highlighted)
|
||||
{
|
||||
[self highlight: NO withFrame: cellFrame
|
||||
inView: controlView];
|
||||
[self drawWithFrame: cellFrame inView: controlView];
|
||||
[[controlView window] flushWindow];
|
||||
}
|
||||
|
||||
// Do we now return or keep tracking
|
||||
if ((![[self class] prefersTrackingUntilMouseUp])
|
||||
&& (!flag))
|
||||
{
|
||||
NSDebugLog(@"NSCell return immediately\n");
|
||||
done = YES;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Point is in cell
|
||||
// highlight cell if not highlighted
|
||||
if (!cell_highlighted)
|
||||
{
|
||||
[self highlight: YES withFrame: cellFrame
|
||||
inView: controlView];
|
||||
//[self drawWithFrame: cellFrame inView: controlView];
|
||||
[[controlView window] flushWindow];
|
||||
}
|
||||
}
|
||||
// should we continue tracking?
|
||||
if (![self continueTracking:last_point at:point inView:controlView]) {
|
||||
NSDebugLog(@"NSCell stop tracking\n");
|
||||
done = YES;
|
||||
}
|
||||
|
||||
// should we continue tracking?
|
||||
if (![self continueTracking: last_point at: point
|
||||
inView: controlView])
|
||||
{
|
||||
NSDebugLog(@"NSCell stop tracking\n");
|
||||
done = YES;
|
||||
continue;
|
||||
}
|
||||
// Did the mouse go up?
|
||||
if (eventType == NSLeftMouseUp) {
|
||||
NSLog(@"NSCell mouse went up\n");
|
||||
mouseWentUp = YES;
|
||||
done = YES;
|
||||
if ((action_mask & NSLeftMouseUpMask))
|
||||
[(NSControl*)controlView sendAction:action to:target];
|
||||
}
|
||||
else {
|
||||
if (pointIsInCell
|
||||
&& ((eventType == NSLeftMouseDragged
|
||||
&& (action_mask & NSLeftMouseDraggedMask))
|
||||
|| ((eventType == NSPeriodic)
|
||||
&& (action_mask & NSPeriodicMask))))
|
||||
[(NSControl*)controlView sendAction:action to:target];
|
||||
}
|
||||
|
||||
// Did the mouse go up?
|
||||
if ([e type] == NSLeftMouseUp)
|
||||
{
|
||||
NSDebugLog(@"NSCell mouse went up\n");
|
||||
mouseWentUp = YES;
|
||||
done = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tell ourselves to stop tracking
|
||||
[self stopTracking: last_point at: point
|
||||
inView: controlView mouseIsUp: mouseWentUp];
|
||||
// Tell ourselves to stop tracking
|
||||
[self stopTracking:last_point at:point
|
||||
inView:controlView mouseIsUp:mouseWentUp];
|
||||
|
||||
// Return YES only if the mouse went up within the cell
|
||||
if ((mouseWentUp) &&
|
||||
([controlView mouse: point inRect: cellFrame]))
|
||||
{
|
||||
NSDebugLog(@"NSCell mouse went up in cell\n");
|
||||
return YES;
|
||||
}
|
||||
if (cell_continuous)
|
||||
[NSEvent stopPeriodicEvents];
|
||||
|
||||
// Otherwise return NO
|
||||
NSDebugLog(@"NSCell mouse did not go up in cell\n");
|
||||
return NO;
|
||||
// Return YES only if the mouse went up within the cell
|
||||
if (mouseWentUp && [controlView mouse: point inRect: cellFrame]) {
|
||||
NSDebugLog(@"NSCell mouse went up in cell\n");
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Otherwise return NO
|
||||
NSDebugLog(@"NSCell mouse did not go up in cell\n");
|
||||
return NO;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/*
|
||||
/*
|
||||
NSClipView.m
|
||||
|
||||
Description...
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Date: July 1997
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -21,113 +19,236 @@
|
|||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
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.
|
||||
*/
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
||||
#include <AppKit/NSClipView.h>
|
||||
#include <AppKit/NSCursor.h>
|
||||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
|
||||
#define ASSIGN(a, b) \
|
||||
[b retain]; \
|
||||
[a release]; \
|
||||
a = b;
|
||||
|
||||
#ifdef MIN
|
||||
# undef MIN
|
||||
#endif
|
||||
#define MIN(a, b) \
|
||||
({typedef _ta = (a), _tb = (b); \
|
||||
_ta _a = (a); _tb _b = (b); \
|
||||
_a < _b ? _a : _b; })
|
||||
|
||||
#ifdef MAX
|
||||
# undef MAX
|
||||
#endif
|
||||
#define MAX(a, b) \
|
||||
({typedef _ta = (a), _tb = (b); \
|
||||
_ta _a = (a); _tb _b = (b); \
|
||||
_a > _b ? _a : _b; })
|
||||
|
||||
@implementation NSClipView
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
- init
|
||||
{
|
||||
if (self == [NSClipView class])
|
||||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
}
|
||||
[super init];
|
||||
[self setAutoresizesSubviews:YES];
|
||||
[self setBackgroundColor:[[self window] backgroundColor]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setDocumentView:(NSView*)aView
|
||||
{
|
||||
if (_documentView)
|
||||
[_documentView removeFromSuperview];
|
||||
|
||||
ASSIGN(_documentView, aView);
|
||||
[self addSubview:_documentView];
|
||||
|
||||
/* Register to notifications sent by the document view */
|
||||
[_documentView setPostsFrameChangedNotifications:YES];
|
||||
[_documentView setPostsBoundsChangedNotifications:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(viewFrameChanged:)
|
||||
name:NSViewFrameDidChangeNotification object:_documentView];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(viewBoundsChanged:)
|
||||
name:NSViewBoundsDidChangeNotification object:_documentView];
|
||||
|
||||
/* TODO: invoke superview's reflectScrolledClipView:? */
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)resetCursorRects
|
||||
{
|
||||
[self addCursorRect:[self bounds] cursor:_cursor];
|
||||
}
|
||||
|
||||
- (void)scrollToPoint:(NSPoint)point
|
||||
{
|
||||
NSPoint currentPoint = [self bounds].origin;
|
||||
|
||||
NSLog (@"scrollToPoint: current point (%f, %f), point (%f, %f)",
|
||||
currentPoint.x, currentPoint.y,
|
||||
point.x, point.y);
|
||||
|
||||
point = [self constrainScrollPoint:point];
|
||||
[super setBoundsOrigin:point];
|
||||
if (_copiesOnScroll)
|
||||
/* TODO: move the visible portion of the document */;
|
||||
else {
|
||||
NSPoint frameOrigin = [_documentView frame].origin;
|
||||
NSPoint newFrameOrigin;
|
||||
|
||||
newFrameOrigin.x = frameOrigin.x - (point.x - currentPoint.x);
|
||||
newFrameOrigin.y = frameOrigin.y - (point.y - currentPoint.y);
|
||||
[_documentView setPostsFrameChangedNotifications:NO];
|
||||
[_documentView setFrameOrigin:newFrameOrigin];
|
||||
[_documentView setPostsFrameChangedNotifications:YES];
|
||||
[self display];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSPoint)constrainScrollPoint:(NSPoint)proposedNewOrigin
|
||||
{
|
||||
NSRect documentFrame = [self documentRect];
|
||||
NSPoint new = proposedNewOrigin;
|
||||
|
||||
if (proposedNewOrigin.x < documentFrame.origin.x)
|
||||
new.x = documentFrame.origin.x;
|
||||
else if (proposedNewOrigin.x
|
||||
> documentFrame.size.width - bounds.size.width)
|
||||
new.x = documentFrame.size.width - bounds.size.width;
|
||||
|
||||
if (proposedNewOrigin.y < documentFrame.origin.y)
|
||||
new.y = documentFrame.origin.y;
|
||||
else if (proposedNewOrigin.y
|
||||
> documentFrame.size.height - bounds.size.height)
|
||||
new.y = documentFrame.size.height - bounds.size.height;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
//
|
||||
// Managing the Document View
|
||||
//
|
||||
- (NSRect)documentRect
|
||||
{
|
||||
return NSZeroRect;
|
||||
}
|
||||
NSRect documentFrame = [_documentView frame];
|
||||
NSRect clipViewBounds = [self bounds];
|
||||
NSRect rect;
|
||||
|
||||
- (id)documentView
|
||||
{
|
||||
return nil;
|
||||
rect.origin = documentFrame.origin;
|
||||
rect.size.width = MAX(documentFrame.size.width, clipViewBounds.size.width);
|
||||
rect.size.height = MAX(documentFrame.size.height,
|
||||
clipViewBounds.size.height);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSRect)documentVisibleRect
|
||||
{
|
||||
return NSZeroRect;
|
||||
NSRect documentBounds = [_documentView bounds];
|
||||
NSRect clipViewBounds = [self bounds];
|
||||
NSRect rect;
|
||||
|
||||
rect.origin = clipViewBounds.origin;
|
||||
rect.size.width = MIN(documentBounds.size.width, clipViewBounds.size.width);
|
||||
rect.size.height = MIN(documentBounds.size.height,
|
||||
clipViewBounds.size.height);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)setDocumentView:(NSView *)aView
|
||||
- (BOOL)autoscroll:(NSEvent*)theEvent
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void)viewBoundsChanged:(NSNotification*)aNotification
|
||||
{
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)viewFrameChanged:(NSNotification*)aNotification
|
||||
{
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize
|
||||
{
|
||||
[super scaleUnitSquareToSize:newUnitSize];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)setBoundsOrigin:(NSPoint)aPoint
|
||||
{
|
||||
[super setBoundsOrigin:aPoint];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)setBoundsSize:(NSSize)aSize
|
||||
{
|
||||
[super setBoundsSize:aSize];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)setFrameSize:(NSSize)aSize
|
||||
{
|
||||
[super setFrameSize:aSize];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)setFrameOrigin:(NSPoint)aPoint
|
||||
{
|
||||
[super setFrameOrigin:aPoint];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)rect
|
||||
{
|
||||
[super setFrame:rect];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (void)translateOriginToPoint:(NSPoint)aPoint
|
||||
{
|
||||
[super translateOriginToPoint:aPoint];
|
||||
[[self superview] reflectScrolledClipView:self];
|
||||
}
|
||||
|
||||
- (id)documentView { return _documentView; }
|
||||
- (void)setCopiesOnScroll:(BOOL)flag { _copiesOnScroll = flag; }
|
||||
- (BOOL)copiesOnScroll { return _copiesOnScroll; }
|
||||
- (void)setDocumentCursor:(NSCursor*)aCursor { ASSIGN(_cursor, aCursor); }
|
||||
- (NSCursor*)documentCursor { return _cursor; }
|
||||
- (NSColor*)backgroundColor { return _backgroundColor; }
|
||||
- (BOOL)isFlipped { return [_documentView isFlipped]; }
|
||||
- (BOOL)acceptsFirstResponder { return _documentView != nil; }
|
||||
|
||||
- (void)setBackgroundColor:(NSColor*)aColor
|
||||
{
|
||||
ASSIGN(_backgroundColor, aColor);
|
||||
}
|
||||
|
||||
/* Disable rotation of clip view */
|
||||
- (void)rotateByAngle:(float)angle
|
||||
{}
|
||||
|
||||
//
|
||||
// Setting the Cursor
|
||||
//
|
||||
- (NSCursor *)documentCursor
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setDocumentCursor:(NSCursor *)anObject
|
||||
- (void)setBoundsRotation:(float)angle
|
||||
{}
|
||||
|
||||
//
|
||||
// Setting the Background Color
|
||||
//
|
||||
- (NSColor *)backgroundColor
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor *)color
|
||||
- (void)setFrameRotation:(float)angle
|
||||
{}
|
||||
|
||||
//
|
||||
// Scrolling
|
||||
//
|
||||
- (BOOL)autoscroll:(NSEvent *)theEvent
|
||||
/* Managing responder chain */
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSPoint)constrainScrollPoint:(NSPoint)newOrigin
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (BOOL)copiesOnScroll
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)scrollToPoint:(NSPoint)newOrigin
|
||||
{}
|
||||
|
||||
- (void)setCopiesOnScroll:(BOOL)flag
|
||||
{}
|
||||
|
||||
//
|
||||
// Responding to a Changed Frame
|
||||
//
|
||||
- (void)viewFrameChanged:(NSNotification *)notification
|
||||
{}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
}
|
||||
|
||||
- initWithCoder:aDecoder
|
||||
{
|
||||
[super initWithCoder:aDecoder];
|
||||
|
||||
return self;
|
||||
return [_documentView becomeFirstResponder];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -353,7 +353,10 @@ static id MB_NSCONTROL_CELL_CLASS = nil;
|
|||
{
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
|
||||
return [theApp sendAction:theAction to:theTarget from:self];
|
||||
if (theAction && theTarget)
|
||||
return [theApp sendAction:theAction to:theTarget from:self];
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (int)sendActionOn:(int)mask
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#ifdef MIN
|
||||
# undef MIN
|
||||
#endif
|
||||
# define MIN(a, b) \
|
||||
#define MIN(a, b) \
|
||||
({typedef _ta = (a), _tb = (b); \
|
||||
_ta _a = (a); _tb _b = (b); \
|
||||
_a < _b ? _a : _b; })
|
||||
|
@ -59,7 +59,7 @@
|
|||
#ifdef MAX
|
||||
# undef MAX
|
||||
#endif
|
||||
# define MAX(a, b) \
|
||||
#define MAX(a, b) \
|
||||
({typedef _ta = (a), _tb = (b); \
|
||||
_ta _a = (a); _tb _b = (b); \
|
||||
_a > _b ? _a : _b; })
|
||||
|
@ -67,7 +67,7 @@
|
|||
#ifdef ABS
|
||||
# undef ABS
|
||||
#endif
|
||||
# define ABS(x) \
|
||||
#define ABS(x) \
|
||||
({typedef _tx = (x); \
|
||||
_tx _x = (x); \
|
||||
_x >= 0 ? _x : -_x; })
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/*
|
||||
/*
|
||||
NSScrollView.m
|
||||
|
||||
Description...
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
||||
Date: July 1997
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -21,187 +19,418 @@
|
|||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
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.
|
||||
*/
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <AppKit/NSScroller.h>
|
||||
#include <AppKit/NSClipView.h>
|
||||
#include <AppKit/NSScrollView.h>
|
||||
|
||||
#define ASSIGN(a, b) \
|
||||
[b retain]; \
|
||||
[a release]; \
|
||||
a = b;
|
||||
|
||||
@implementation NSScrollView
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
static Class rulerViewClass = nil;
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [NSScrollView class])
|
||||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Laying Out the NSScrollView
|
||||
//
|
||||
+ (NSSize)contentSizeForFrameSize:(NSSize)size
|
||||
hasHorizontalScroller:(BOOL)horizFlag
|
||||
hasVerticalScroller:(BOOL)vertFlag
|
||||
borderType:(NSBorderType)aType
|
||||
+ (void)setRulerViewClass:(Class)aClass
|
||||
{
|
||||
return NSZeroSize;
|
||||
rulerViewClass = aClass;
|
||||
}
|
||||
|
||||
+ (NSSize)frameSizeForContentSize:(NSSize)size
|
||||
hasHorizontalScroller:(BOOL)horizFlag
|
||||
hasVerticalScroller:(BOOL)vertFlag
|
||||
borderType:(NSBorderType)aType
|
||||
+ (Class)rulerViewClass
|
||||
{
|
||||
return NSZeroSize;
|
||||
return rulerViewClass;
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
//
|
||||
// Determining Component Sizes
|
||||
//
|
||||
- (NSSize)contentSize
|
||||
/* Backends should rewrite the following 2 methods and adjust the frames
|
||||
depending on the border type. */
|
||||
|
||||
+ (NSSize)contentSizeForFrameSize:(NSSize)frameSize
|
||||
hasHorizontalScroller:(BOOL)hFlag
|
||||
hasVerticalScroller:(BOOL)vFlag
|
||||
borderType:(NSBorderType)borderType
|
||||
{
|
||||
return NSZeroSize;
|
||||
NSSize size = frameSize;
|
||||
|
||||
if (hFlag)
|
||||
size.height -= [NSScroller scrollerWidth];
|
||||
if (vFlag)
|
||||
size.width -= [NSScroller scrollerWidth];
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
- (NSRect)documentVisibleRect
|
||||
+ (NSSize)frameSizeForContentSize:(NSSize)contentSize
|
||||
hasHorizontalScroller:(BOOL)hFlag
|
||||
hasVerticalScroller:(BOOL)vFlag
|
||||
borderType:(NSBorderType)borderType
|
||||
{
|
||||
return NSZeroRect;
|
||||
NSSize size = contentSize;
|
||||
|
||||
if (hFlag)
|
||||
size.height += [NSScroller scrollerWidth];
|
||||
if (vFlag)
|
||||
size.width += [NSScroller scrollerWidth];
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
//
|
||||
// Laying Out the NSScrollView
|
||||
//
|
||||
- (void)setHasHorizontalScroller:(BOOL)flag
|
||||
{}
|
||||
|
||||
- (BOOL)hasHorizontalScroller
|
||||
- initWithFrame:(NSRect)rect
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)setHasVerticalScroller:(BOOL)flag
|
||||
{}
|
||||
|
||||
- (BOOL)hasVerticalScroller
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)tile
|
||||
{}
|
||||
|
||||
- (void)toggleRuler:(id)sender
|
||||
{}
|
||||
|
||||
- (BOOL)isRulerVisible
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
//
|
||||
// Managing Component Views
|
||||
//
|
||||
- (void)setDocumentView:(NSView *)aView
|
||||
{}
|
||||
|
||||
- (id)documentView
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setHorizontalScroller:(NSScroller *)anObject
|
||||
{}
|
||||
|
||||
- (NSScroller *)horizontalScroller
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setVerticalScroller:(NSScroller *)anObject
|
||||
{}
|
||||
|
||||
- (NSScroller *)verticalScroller
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)reflectScrolledClipView:(NSClipView *)cView
|
||||
{}
|
||||
|
||||
//
|
||||
// Modifying Graphic Attributes
|
||||
//
|
||||
- (void)setBorderType:(NSBorderType)aType
|
||||
{}
|
||||
|
||||
- (NSBorderType)borderType
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor *)color
|
||||
{}
|
||||
|
||||
- (NSColor *)backgroundColor
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting Scrolling Behavior
|
||||
//
|
||||
- (float)lineScroll
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
- (float)pageScroll
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
- (void)setScrollsDynamically:(BOOL)flag
|
||||
{}
|
||||
|
||||
- (BOOL)scrollsDynamically
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)setLineScroll:(float)value
|
||||
{}
|
||||
|
||||
- (void)setPageScroll:(float)value
|
||||
{}
|
||||
|
||||
//
|
||||
// Managing the Cursor
|
||||
//
|
||||
- (void)setDocumentCursor:(NSCursor *)anObject
|
||||
{}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void)encodeWithCoder:aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
}
|
||||
|
||||
- initWithCoder:aDecoder
|
||||
{
|
||||
[super initWithCoder:aDecoder];
|
||||
[super initWithFrame:rect];
|
||||
[self setContentView:[[NSClipView new] autorelease]];
|
||||
_lineScroll = 10;
|
||||
_pageScroll = 10;
|
||||
_borderType = NSBezelBorder;
|
||||
_scrollsDynamically = YES;
|
||||
[self tile];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
return [self initWithFrame:NSZeroRect];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_contentView release];
|
||||
|
||||
[_horizScroller release];
|
||||
[_vertScroller release];
|
||||
[_horizRuler release];
|
||||
[_vertRuler release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setContentView:(NSClipView*)aView
|
||||
{
|
||||
ASSIGN(_contentView, aView);
|
||||
[self addSubview:_contentView];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setHorizontalScroller:(NSScroller*)aScroller
|
||||
{
|
||||
[_horizScroller removeFromSuperview];
|
||||
|
||||
/* Do not add the scroller view to the subviews array yet; the user has to
|
||||
explicitly invoke -setHasHorizontalScroller:. */
|
||||
|
||||
ASSIGN(_horizScroller, aScroller);
|
||||
if (_horizScroller) {
|
||||
[_horizScroller setTarget:self];
|
||||
[_horizScroller setAction:@selector(_doScroll:)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHasHorizontalScroller:(BOOL)flag
|
||||
{
|
||||
if (_hasHorizScroller == flag)
|
||||
return;
|
||||
|
||||
_hasHorizScroller = flag;
|
||||
|
||||
if (_hasHorizScroller) {
|
||||
if (!_horizScroller)
|
||||
[self setHorizontalScroller:[[NSScroller new] autorelease]];
|
||||
[self addSubview:_horizScroller];
|
||||
}
|
||||
else
|
||||
[_horizScroller removeFromSuperview];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setVerticalScroller:(NSScroller*)aScroller
|
||||
{
|
||||
[_vertScroller removeFromSuperview];
|
||||
|
||||
/* Do not add the scroller view to the subviews array yet; the user has to
|
||||
explicitly invoke -setHasVerticalScroller:. */
|
||||
|
||||
ASSIGN(_vertScroller, aScroller);
|
||||
if (_vertScroller) {
|
||||
[_vertScroller setTarget:self];
|
||||
[_vertScroller setAction:@selector(_doScroll:)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHasVerticalScroller:(BOOL)flag
|
||||
{
|
||||
if (_hasVertScroller == flag)
|
||||
return;
|
||||
|
||||
_hasVertScroller = flag;
|
||||
|
||||
if (_hasVertScroller) {
|
||||
if (!_vertScroller) {
|
||||
[self setVerticalScroller:[[NSScroller new] autorelease]];
|
||||
if (_contentView && ![_contentView isFlipped])
|
||||
[_vertScroller setFloatValue:1];
|
||||
}
|
||||
[self addSubview:_vertScroller];
|
||||
}
|
||||
else
|
||||
[_vertScroller removeFromSuperview];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)_doScroll:(NSScroller*)scroller
|
||||
{
|
||||
float floatValue = [scroller floatValue];
|
||||
NSRect clipViewBounds = [_contentView bounds];
|
||||
NSScrollerPart hitPart = [scroller hitPart];
|
||||
NSRect documentRect = [_contentView documentRect];
|
||||
float amount = 0;
|
||||
NSPoint point;
|
||||
BOOL wasAScrollerButton = YES;
|
||||
|
||||
NSLog (@"_doScroll: float value = %f", floatValue);
|
||||
|
||||
if (hitPart == NSScrollerIncrementLine)
|
||||
amount = _lineScroll;
|
||||
else if (hitPart == NSScrollerIncrementPage)
|
||||
amount = _pageScroll;
|
||||
else if (hitPart == NSScrollerDecrementLine)
|
||||
amount = -_lineScroll;
|
||||
else if (hitPart == NSScrollerDecrementPage)
|
||||
amount = -_pageScroll;
|
||||
else
|
||||
wasAScrollerButton = NO;
|
||||
|
||||
if (wasAScrollerButton) {
|
||||
if (scroller == _horizScroller) {
|
||||
point.x = clipViewBounds.origin.x + amount;
|
||||
point.y = clipViewBounds.origin.y;
|
||||
}
|
||||
else if (scroller == _vertScroller) {
|
||||
point.x = clipViewBounds.origin.x;
|
||||
/* For the vertical scroller the amount should actually be reversed */
|
||||
amount = -amount;
|
||||
|
||||
/* If the view is flipped we also have to reverse the meanings of
|
||||
increasing or decreasing of the y coordinate */
|
||||
if (![_contentView isFlipped])
|
||||
amount = -amount;
|
||||
|
||||
NSLog (@"increment/decrement: amount = %f, flipped = %d",
|
||||
amount, [_contentView isFlipped]);
|
||||
point.y = clipViewBounds.origin.y + amount;
|
||||
}
|
||||
else {
|
||||
/* do nothing */
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (scroller == _horizScroller) {
|
||||
point.x = floatValue * (documentRect.size.width
|
||||
- clipViewBounds.size.width);
|
||||
point.y = clipViewBounds.origin.y;
|
||||
}
|
||||
else if (scroller == _vertScroller) {
|
||||
point.x = clipViewBounds.origin.x;
|
||||
if (![_contentView isFlipped])
|
||||
floatValue = 1 - floatValue;
|
||||
point.y = floatValue * (documentRect.size.height
|
||||
- clipViewBounds.size.height);
|
||||
}
|
||||
else {
|
||||
/* do nothing */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[_contentView scrollToPoint:point];
|
||||
|
||||
/* Update the scroller knob if the scroll occurred due to a
|
||||
scroller button. */
|
||||
if (wasAScrollerButton) {
|
||||
NSRect newClipViewBounds = [_contentView bounds];
|
||||
|
||||
if (newClipViewBounds.origin.x != clipViewBounds.origin.x) {
|
||||
/* Update the horizontal scroller */
|
||||
floatValue = newClipViewBounds.origin.x
|
||||
/ (documentRect.size.width - newClipViewBounds.size.width);
|
||||
[_horizScroller setFloatValue:floatValue];
|
||||
[_horizScroller display];
|
||||
NSLog (@"new horiz float value %f", floatValue);
|
||||
}
|
||||
|
||||
if (newClipViewBounds.origin.x != clipViewBounds.origin.y) {
|
||||
/* Update the vertical scroller */
|
||||
floatValue = newClipViewBounds.origin.y
|
||||
/ (documentRect.size.height - newClipViewBounds.size.height);
|
||||
/* Take care if the document view is not flipped by reversing the meaning
|
||||
of the float value. */
|
||||
if (![_contentView isFlipped])
|
||||
floatValue = 1 - floatValue;
|
||||
[_vertScroller setFloatValue:floatValue];
|
||||
[_vertScroller display];
|
||||
NSLog (@"new vert float value %f", floatValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reflectScrolledClipView:(NSClipView*)aClipView
|
||||
{
|
||||
NSRect documentRect = [_contentView documentRect];
|
||||
NSRect clipViewBounds = [_contentView bounds];
|
||||
float floatValue;
|
||||
float knobProportion;
|
||||
|
||||
NSLog (@"reflectScrolledClipView:");
|
||||
|
||||
if (_hasVertScroller) {
|
||||
if (documentRect.size.height < clipViewBounds.size.height)
|
||||
[_vertScroller setEnabled:NO];
|
||||
else {
|
||||
[_vertScroller setEnabled:YES];
|
||||
knobProportion = clipViewBounds.size.height / documentRect.size.height;
|
||||
floatValue = clipViewBounds.origin.y / clipViewBounds.size.height;
|
||||
if (![_contentView isFlipped])
|
||||
floatValue = 1 - floatValue;
|
||||
[_vertScroller setFloatValue:floatValue knobProportion:knobProportion];
|
||||
}
|
||||
}
|
||||
|
||||
if (_hasHorizScroller) {
|
||||
if (documentRect.size.width < clipViewBounds.size.width)
|
||||
[_horizScroller setEnabled:NO];
|
||||
else {
|
||||
[_horizScroller setEnabled:YES];
|
||||
knobProportion = clipViewBounds.size.width / documentRect.size.width;
|
||||
floatValue = clipViewBounds.origin.x / clipViewBounds.size.width;
|
||||
[_horizScroller setFloatValue:floatValue knobProportion:knobProportion];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHorizontalRulerView:(NSRulerView*)aRulerView
|
||||
{
|
||||
/* TODO */
|
||||
ASSIGN(_horizRuler, aRulerView);
|
||||
}
|
||||
|
||||
- (void)setHasHorizontalRuler:(BOOL)flag
|
||||
{
|
||||
/* TODO */
|
||||
if (_hasHorizRuler == flag)
|
||||
return;
|
||||
|
||||
_hasHorizRuler = flag;
|
||||
}
|
||||
|
||||
- (void)setVerticalRulerView:(NSRulerView*)ruler
|
||||
{
|
||||
/* TODO */
|
||||
ASSIGN(_vertRuler, ruler);
|
||||
}
|
||||
|
||||
- (void)setHasVerticalRuler:(BOOL)flag
|
||||
{
|
||||
/* TODO */
|
||||
if (_hasVertRuler == flag)
|
||||
return;
|
||||
|
||||
_hasVertRuler = flag;
|
||||
}
|
||||
|
||||
- (void)setRulersVisible:(BOOL)flag
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)rect
|
||||
{
|
||||
[super setFrame:rect];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)setFrameSize:(NSSize)size
|
||||
{
|
||||
[super setFrameSize:size];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
/* This method should be implemented in the backend to position the scroll
|
||||
view's interface elements */
|
||||
- (void)tile
|
||||
{
|
||||
}
|
||||
|
||||
- (NSRect)documentVisibleRect
|
||||
{
|
||||
return [_contentView documentVisibleRect];
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor*)aColor
|
||||
{
|
||||
[_contentView setBackgroundColor:aColor];
|
||||
}
|
||||
|
||||
- (NSColor*)backgroundColor
|
||||
{
|
||||
return [_contentView backgroundColor];
|
||||
}
|
||||
|
||||
- (void)setBorderType:(NSBorderType)borderType
|
||||
{
|
||||
_borderType = borderType;
|
||||
}
|
||||
|
||||
- (void)setDocumentView:(NSView*)aView
|
||||
{
|
||||
[_contentView setDocumentView:aView];
|
||||
if (_contentView && ![_contentView isFlipped])
|
||||
[_vertScroller setFloatValue:1];
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (id)documentView
|
||||
{
|
||||
return [_contentView documentView];
|
||||
}
|
||||
|
||||
- (void)setDocumentCursor:(NSCursor*)aCursor
|
||||
{
|
||||
[_contentView setDocumentCursor:aCursor];
|
||||
}
|
||||
|
||||
- (NSCursor*)documentCursor
|
||||
{
|
||||
return [_contentView documentCursor];
|
||||
}
|
||||
|
||||
- (NSBorderType)borderType { return _borderType; }
|
||||
- (NSScroller*)verticalScroller { return _vertScroller; }
|
||||
- (BOOL)hasVerticalScroller { return _hasVertScroller; }
|
||||
- (BOOL)hasHorizontalRuler { return _hasHorizRuler; }
|
||||
- (NSSize)contentSize { return [_contentView bounds].size; }
|
||||
- (NSClipView*)contentView { return _contentView; }
|
||||
- (NSRulerView*)horizontalRulerView { return _horizRuler; }
|
||||
- (BOOL)hasVerticalRuler { return _hasVertRuler; }
|
||||
- (NSRulerView*)verticalRulerView { return _vertRuler; }
|
||||
- (BOOL)rulersVisible { return _rulersVisible; }
|
||||
- (void)setLineScroll:(float)aFloat { _lineScroll = aFloat; }
|
||||
- (float)lineScroll { return _lineScroll; }
|
||||
- (void)setPageScroll:(float)aFloat { _pageScroll = aFloat; }
|
||||
- (float)pageScroll { return _pageScroll; }
|
||||
- (void)setScrollsDynamically:(BOOL)flag { _scrollsDynamically = flag; }
|
||||
- (BOOL)scrollsDynamically { return _scrollsDynamically; }
|
||||
- (NSScroller*)horizontalScroller { return _horizScroller; }
|
||||
- (BOOL)hasHorizontalScroller { return _hasHorizScroller; }
|
||||
|
||||
@end
|
||||
|
|
File diff suppressed because it is too large
Load diff
110
Source/NSView.m
110
Source/NSView.m
|
@ -31,6 +31,8 @@
|
|||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <gnustep/gui/TrackingRectangle.h>
|
||||
|
@ -159,7 +161,6 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
|
||||
super_view = nil;
|
||||
window = nil;
|
||||
is_flipped = NO;
|
||||
is_rotated_from_base = NO;
|
||||
is_rotated_or_scaled_from_base = NO;
|
||||
opaque = YES;
|
||||
|
@ -351,7 +352,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
//
|
||||
- (float)frameRotation
|
||||
{
|
||||
return 0;
|
||||
return frame_rotation;
|
||||
}
|
||||
|
||||
- (NSRect)frame
|
||||
|
@ -360,7 +361,11 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
}
|
||||
|
||||
- (void)rotateByAngle:(float)angle
|
||||
{}
|
||||
{
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)frameRect
|
||||
{
|
||||
|
@ -371,15 +376,26 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
|
||||
// Resize subviews
|
||||
[self resizeSubviewsWithOldSize: old_size];
|
||||
if (post_frame_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setFrameOrigin:(NSPoint)newOrigin
|
||||
{
|
||||
frame.origin = newOrigin;
|
||||
if (post_frame_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
||||
|
||||
}
|
||||
|
||||
- (void)setFrameRotation:(float)angle
|
||||
{}
|
||||
{
|
||||
if (post_frame_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setFrameSize:(NSSize)newSize
|
||||
{
|
||||
|
@ -390,6 +406,9 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
|
||||
// Resize subviews
|
||||
[self resizeSubviewsWithOldSize: old_size];
|
||||
if (post_frame_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -408,7 +427,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
|
||||
- (BOOL)isFlipped
|
||||
{
|
||||
return is_flipped;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isRotatedFromBase
|
||||
|
@ -422,55 +441,53 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
}
|
||||
|
||||
- (void)scaleUnitSquareToSize:(NSSize)newSize
|
||||
{}
|
||||
{
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setBounds:(NSRect)aRect
|
||||
{
|
||||
bounds = aRect;
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setBoundsOrigin:(NSPoint)newOrigin
|
||||
{
|
||||
bounds.origin = newOrigin;
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setBoundsRotation:(float)angle
|
||||
{}
|
||||
{
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)setBoundsSize:(NSSize)newSize
|
||||
{
|
||||
bounds.size = newSize;
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
- (void)translateOriginToPoint:(NSPoint)point
|
||||
{}
|
||||
{
|
||||
if (post_bounds_changes)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
||||
}
|
||||
|
||||
//
|
||||
// Converting Coordinates
|
||||
//
|
||||
- (NSRect)convertRectToWindow:(NSRect)r
|
||||
{
|
||||
NSRect f, t, a;
|
||||
id s;
|
||||
|
||||
a = r;
|
||||
f = [self frame];
|
||||
s = [self superview];
|
||||
// climb up the superview chain
|
||||
while (s)
|
||||
{
|
||||
t = [s frame];
|
||||
// translate frame
|
||||
f.origin.x += t.origin.x;
|
||||
f.origin.y += t.origin.y;
|
||||
s = [s superview];
|
||||
}
|
||||
a.origin.x += f.origin.x;
|
||||
a.origin.y += f.origin.y;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
- (NSPoint)convertPointToWindow:(NSPoint)p
|
||||
{
|
||||
NSRect f, t;
|
||||
|
@ -479,6 +496,9 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
|
||||
a = p;
|
||||
f = [self frame];
|
||||
if ([self isFlipped])
|
||||
a.y = f.size.height - p.y;
|
||||
|
||||
s = [self superview];
|
||||
// climb up the superview chain
|
||||
while (s)
|
||||
|
@ -486,7 +506,10 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
t = [s frame];
|
||||
// translate frame
|
||||
f.origin.x += t.origin.x;
|
||||
f.origin.y += t.origin.y;
|
||||
if ([s isFlipped])
|
||||
f.origin.y += t.size.height + t.origin.y;
|
||||
else
|
||||
f.origin.y += t.origin.y;
|
||||
s = [s superview];
|
||||
}
|
||||
a.x += f.origin.x;
|
||||
|
@ -495,6 +518,16 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
return a;
|
||||
}
|
||||
|
||||
- (NSRect)convertRectToWindow:(NSRect)r
|
||||
{
|
||||
NSRect a;
|
||||
|
||||
a.origin = [self convertPointToWindow:r.origin];
|
||||
a.size = r.size;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
- (NSRect)centerScanRect:(NSRect)aRect
|
||||
{
|
||||
return NSZeroRect;
|
||||
|
@ -615,6 +648,15 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
post_frame_changes = flag;
|
||||
}
|
||||
|
||||
- (void)setPostsBoundsChangedNotifications:(BOOL)flag
|
||||
{
|
||||
post_bounds_changes = flag;
|
||||
}
|
||||
|
||||
- (BOOL)postsBoundsChangedNotifications
|
||||
{
|
||||
return post_bounds_changes;
|
||||
}
|
||||
|
||||
//
|
||||
// Resizing Subviews
|
||||
|
@ -799,6 +841,8 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
|
||||
- (BOOL)autoscroll:(NSEvent *)theEvent
|
||||
{
|
||||
if (super_view)
|
||||
return [super_view autoscroll:theEvent];
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -1171,7 +1215,6 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
[aCoder encodeConditionalObject:window];
|
||||
#endif
|
||||
[aCoder encodeObject: tracking_rects];
|
||||
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_flipped];
|
||||
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_rotated_from_base];
|
||||
[aCoder encodeValueOfObjCType:@encode(BOOL)
|
||||
at: &is_rotated_or_scaled_from_base];
|
||||
|
@ -1205,7 +1248,6 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
|||
#endif
|
||||
|
||||
tracking_rects = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_flipped];
|
||||
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_rotated_from_base];
|
||||
[aDecoder decodeValueOfObjCType:@encode(BOOL)
|
||||
at: &is_rotated_or_scaled_from_base];
|
||||
|
|
Loading…
Reference in a new issue