mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Initial implementation of NSScreen.
Add mouse dragged events for mouse tracking. Implement methods for converting points to/from views. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9ce655f2c1
commit
e2228d0274
10 changed files with 139 additions and 25 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Fri Jun 21 11:09:50 1996 GNUstep Development <gnustep@duncan.ocbi.com>
|
||||
|
||||
* Headers/gnustep/gui/NSScreen.h: Add instance variables for
|
||||
a screen's device dictionary and for the backend.
|
||||
* Source/NSButton.m (highlight:): Implement method.
|
||||
(mouseDown:): Add mouse dragged events to tracking event mask.
|
||||
* Source/NSCell.m (trackMouse:inRect:ofView:untilMouseUp:): Likewise.
|
||||
* Source/NSMatrix.m (createInitialMatrix): Wrong initial capacity.
|
||||
* Source/NSScreen.m: Initial implementation.
|
||||
* Source/NSView.m (convertRectToWindow:): New method.
|
||||
(convertPointToWindow:): New method.
|
||||
(convertPoint:fromView:, convertPoint:toView:): Implement method.
|
||||
|
||||
Wed Jun 19 14:25:46 1996 Scott Christley <scottc@net-community.com>
|
||||
|
||||
* Source/NSView.m (resizeSubviewsWithOldSize:): Implement method.
|
||||
|
|
|
@ -33,11 +33,16 @@
|
|||
|
||||
#include <AppKit/stdappkit.h>
|
||||
#include <AppKit/TypesandConstants.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
||||
@interface NSScreen : NSObject
|
||||
|
||||
{
|
||||
// Attributes
|
||||
NSMutableDictionary *device_desc;
|
||||
|
||||
// Reserved for backend use
|
||||
void *be_screen_reserved;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -42,7 +42,7 @@ includedir = $(prefix)/include
|
|||
|
||||
MAKEDEFINES =
|
||||
|
||||
CC = @CC@
|
||||
CC = @CC@ -g
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CFLAGS = -c $(GCCFLAGS) -I../Headers $(CPPFLAGS)
|
||||
|
||||
|
@ -277,6 +277,7 @@ installdirs:
|
|||
|
||||
install-lib: $(MAIN_FILE)$(libext)
|
||||
$(INSTALL_PROGRAM) $(MAIN_FILE)$(libext) $(libdir)
|
||||
$(RANLIB) $(libdir)/$(MAIN_FILE)$(libext)
|
||||
|
||||
install-headers:
|
||||
for file in $(GNUSTEP1_HEADERS); do \
|
||||
|
|
|
@ -231,6 +231,7 @@ id MB_NSBUTTON_CLASS;
|
|||
|
||||
- (void)highlight:(BOOL)flag
|
||||
{
|
||||
[cell highlight: flag withFrame: bounds inView: self];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -260,8 +261,8 @@ id MB_NSBUTTON_CLASS;
|
|||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
BOOL mouseUp, done;
|
||||
NSEvent *e;
|
||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||
| NSMouseMovedMask;
|
||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||
NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask;
|
||||
|
||||
NSDebugLog(@"NSButton mouseDown\n");
|
||||
|
||||
|
|
|
@ -405,9 +405,9 @@
|
|||
//
|
||||
- (void)editWithFrame:(NSRect)aRect
|
||||
inView:(NSView *)controlView
|
||||
editor:(NSText *)textObject
|
||||
delegate:(id)anObject
|
||||
event:(NSEvent *)theEvent
|
||||
editor:(NSText *)textObject
|
||||
delegate:(id)anObject
|
||||
event:(NSEvent *)theEvent
|
||||
{}
|
||||
|
||||
- (void)endEditing:(NSText *)textObject
|
||||
|
@ -415,9 +415,9 @@ event:(NSEvent *)theEvent
|
|||
|
||||
- (void)selectWithFrame:(NSRect)aRect
|
||||
inView:(NSView *)controlView
|
||||
editor:(NSText *)textObject
|
||||
delegate:(id)anObject
|
||||
start:(int)selStart
|
||||
editor:(NSText *)textObject
|
||||
delegate:(id)anObject
|
||||
start:(int)selStart
|
||||
length:(int)selLength
|
||||
{}
|
||||
|
||||
|
@ -615,8 +615,9 @@ start:(int)selStart
|
|||
{
|
||||
NSApplication *theApp = [NSApplication sharedApplication];
|
||||
NSEvent *e;
|
||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||
| NSMouseMovedMask;
|
||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||
NSMouseMovedMask | NSLeftMouseDraggedMask |
|
||||
NSRightMouseDraggedMask;
|
||||
NSPoint location = [theEvent locationInWindow];
|
||||
NSPoint point = [controlView convertPoint: location fromView: nil];
|
||||
NSPoint last_point;
|
||||
|
|
|
@ -137,25 +137,19 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
|
|||
NSThread *current_thread = [NSThread currentThread];
|
||||
NSDPSContext *current_context = nil;
|
||||
|
||||
NSLog(@"NSDPSContext: +currentContext\n");
|
||||
// Get current context for current thread
|
||||
[GNU_CONTEXT_LOCK lock];
|
||||
|
||||
current_context = [GNU_CONTEXT_THREAD_DICT objectForKey: current_thread];
|
||||
NSLog(@"NSDPSContext: Looked in context dictionary\n");
|
||||
|
||||
// If not in dictionary then create one
|
||||
if (!current_context)
|
||||
{
|
||||
NSLog(@"NSDPSContext: Did not find context so create it\n");
|
||||
current_context = [[NSDPSContext alloc] init];
|
||||
NSLog(@"NSDPSContext: set the context\n");
|
||||
[self setCurrentContext: current_context];
|
||||
}
|
||||
[GNU_CONTEXT_LOCK unlock];
|
||||
NSLog(@"NSDPSContext: exit critical section\n");
|
||||
|
||||
NSLog(@"NSDPSContext: return from +currentContext\n");
|
||||
return current_context;
|
||||
}
|
||||
|
||||
|
@ -163,9 +157,7 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
|
|||
{
|
||||
NSThread *current_thread = [NSThread currentThread];
|
||||
|
||||
NSLog(@"NSDPSContext: +setCurrentContext\n");
|
||||
[GNU_CONTEXT_LOCK lock];
|
||||
NSLog(@"NSDPSContext: enter critical section\n");
|
||||
|
||||
// If no context then remove from dictionary
|
||||
if (!context)
|
||||
|
@ -179,8 +171,6 @@ BOOL GNU_CONTEXT_SYNCHRONIZED;
|
|||
}
|
||||
|
||||
[GNU_CONTEXT_LOCK unlock];
|
||||
NSLog(@"NSDPSContext: exit critical section\n");
|
||||
NSLog(@"NSDPSContext: return from +setCurrentContext\n");
|
||||
}
|
||||
|
||||
- (NSDPSContext *)DPSContext
|
||||
|
|
|
@ -94,7 +94,7 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
|
|||
|
||||
for (i = 0;i < num_rows; ++i)
|
||||
{
|
||||
aRow = [NSMutableArray arrayWithCapacity: j];
|
||||
aRow = [NSMutableArray arrayWithCapacity: num_cols];
|
||||
[rows addObject: aRow];
|
||||
for (j = 0;j < num_cols; ++j)
|
||||
{
|
||||
|
|
|
@ -73,6 +73,17 @@ NSString *NSDeviceSize = @"Size";
|
|||
//
|
||||
// Instance methods
|
||||
//
|
||||
- init
|
||||
{
|
||||
[super init];
|
||||
|
||||
// Create our device description dictionary
|
||||
// The backend will have to fill the dictionary
|
||||
device_desc = [NSMutableDictionary dictionary];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Screen Information
|
||||
//
|
||||
|
@ -86,9 +97,11 @@ NSString *NSDeviceSize = @"Size";
|
|||
return NSZeroRect;
|
||||
}
|
||||
|
||||
// Make a copy of our dictionary and return it
|
||||
- (NSDictionary *)deviceDescription
|
||||
{
|
||||
return nil;
|
||||
NSDictionary *d = [[NSDictionary alloc] initWithDictionary: device_desc];
|
||||
return d;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -449,6 +449,53 @@ NSString *NSViewFocusChangedNotification;
|
|||
//
|
||||
// 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;
|
||||
NSPoint a;
|
||||
id s;
|
||||
|
||||
a = p;
|
||||
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.x += f.origin.x;
|
||||
a.y += f.origin.y;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
- (NSRect)centerScanRect:(NSRect)aRect
|
||||
{
|
||||
return NSZeroRect;
|
||||
|
@ -457,18 +504,59 @@ NSString *NSViewFocusChangedNotification;
|
|||
- (NSPoint)convertPoint:(NSPoint)aPoint
|
||||
fromView:(NSView *)aView
|
||||
{
|
||||
return NSZeroPoint;
|
||||
NSPoint p, q;
|
||||
NSRect r;
|
||||
|
||||
// Must belong to the same window
|
||||
if (([self window] != [aView window]) && (aView))
|
||||
return NSZeroPoint;
|
||||
|
||||
// if aView is nil
|
||||
// then converting from window
|
||||
// so convert from the content from the content view of the window
|
||||
if (aView == nil)
|
||||
return [self convertPoint: aPoint fromView:[[self window] contentView]];
|
||||
|
||||
// Convert the point to window coordinates
|
||||
p = [aView convertPointToWindow: aPoint];
|
||||
|
||||
// Convert out origin to window coordinates
|
||||
q = [self convertPointToWindow: bounds.origin];
|
||||
|
||||
NSLog(@"point convert: %f %f %f %f\n", p.x, p.y, q.x, q.y);
|
||||
|
||||
// now translate
|
||||
p.x -= q.x;
|
||||
p.y -= q.y;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
- (NSPoint)convertPoint:(NSPoint)aPoint
|
||||
toView:(NSView *)aView
|
||||
{
|
||||
NSPoint p;
|
||||
NSPoint p, q;
|
||||
NSRect r;
|
||||
|
||||
// Must belong to the same window
|
||||
if (([self window] != [aView window]) && (aView))
|
||||
return NSZeroPoint;
|
||||
|
||||
// if aView is nil
|
||||
// then converting to window
|
||||
if (aView == nil)
|
||||
return [self convertPointToWindow: aPoint];
|
||||
|
||||
// convert everything to window coordinates
|
||||
p = [self convertPointToWindow: aPoint];
|
||||
r = [aView bounds];
|
||||
q = [aView convertPointToWindow: r.origin];
|
||||
NSLog(@"point convert: %f %f %f %f\n", p.x, p.y, q.x, q.y);
|
||||
|
||||
// now translate
|
||||
p.x -= q.x;
|
||||
p.y -= q.y;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -872,6 +872,8 @@ inMode:(NSString *)mode
|
|||
case NSLeftMouseDown:
|
||||
{
|
||||
NSView *v = [content_view hitTest:[theEvent locationInWindow]];
|
||||
NSLog([content_view description]);
|
||||
NSLog(@"\n");
|
||||
[v mouseDown:theEvent];
|
||||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue