Remove obsolete backend classes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5101 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1999-10-29 18:43:48 +00:00
parent ad16a5786c
commit 97eb87a61c
15 changed files with 421 additions and 52 deletions

View file

@ -1,3 +1,23 @@
1999-10-29 Adam Fedor <fedor@gnu.org>
* Remove backend application, cursor, and screen classes and use
new window ops.
* Headers/gnustep/gui/DPSOperators.h: New window ops.
* Headers/gnustep/gui/GSMethodTable.h: Likewise.
* Headers/gnustep/gui/NSGraphicsContext.h: Likewise.
* NSGraphicsContext.m: Likewise.
* Headers/gnustep/gui/NSCursor.h: Add enum for standard cursors.
* Source/NSCursor.m: Implement methods using new cursor ops.
* Source/NSApplication.m: Move icon window classes
from backend here and use new window ops.
* Source/NSScreen.m: Implement methods using new window ops.
* Source/NSView.m (-registerForDragTypes:): Fix typo? wrong list
being removed.
* Source/NSWindow.m (+_windowList): New method.
Wed Oct 27 1999 Nicola Pero <n.pero@mi.flashnet.it>
Changings suggested by Andrew Lindesay:

View file

@ -888,6 +888,30 @@ static inline void
DPSreleasemouse(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPSsetinputfocus(GSCTXT *ctxt, int win)
__attribute__((unused));
static inline void
DPShidecursor(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPSshowcursor(GSCTXT *ctxt)
__attribute__((unused));
static inline void
DPSstandardcursor(GSCTXT *ctxt, int style, void ** cid)
__attribute__((unused));
static inline void
DPSimagecursor(GSCTXT *ctxt, float hotx, float hoty, float w, float h, int colors, const char * image, void ** cid)
__attribute__((unused));
static inline void
DPSsetcursorcolor(GSCTXT *ctxt, float fr, float fg, float fb, float br, float bg, float bb, void * cid)
__attribute__((unused));
/* ----------------------------------------------------------------------- */
/* Color operations */
/* ----------------------------------------------------------------------- */
@ -2366,6 +2390,48 @@ DPSreleasemouse(GSCTXT *ctxt)
(ctxt, @selector(DPSreleasemouse));
}
static inline void
DPSsetinputfocus(GSCTXT *ctxt, int win)
{
(ctxt->methods->DPSsetinputfocus_)
(ctxt, @selector(DPSsetinputfocus:), win);
}
static inline void
DPShidecursor(GSCTXT *ctxt)
{
(ctxt->methods->DPShidecursor)
(ctxt, @selector(DPShidecursor));
}
static inline void
DPSshowcursor(GSCTXT *ctxt)
{
(ctxt->methods->DPSshowcursor)
(ctxt, @selector(DPSshowcursor));
}
static inline void
DPSstandardcursor(GSCTXT *ctxt, int style, void ** cid)
{
(ctxt->methods->DPSstandardcursor__)
(ctxt, @selector(DPSstandardcursor::), style, cid);
}
static inline void
DPSimagecursor(GSCTXT *ctxt, float hotx, float hoty, float w, float h, int colors, const char * image, void ** cid)
{
(ctxt->methods->DPSimagecursor_______)
(ctxt, @selector(DPSimagecursor:::::::), hotx, hoty, w, h, colors, image, cid);
}
static inline void
DPSsetcursorcolor(GSCTXT *ctxt, float fr, float fg, float fb, float br, float bg, float bb, void * cid)
{
(ctxt->methods->DPSsetcursorcolor_______)
(ctxt, @selector(DPSsetcursorcolor:::::::), fr, fg, fb, br, bg, bb, cid);
}
/* ----------------------------------------------------------------------- */
/* GNUstep Event and other I/O extensions */
/* ----------------------------------------------------------------------- */

View file

@ -483,6 +483,18 @@ typedef struct {
(NSGraphicsContext*, SEL, int);
void (*DPSreleasemouse)
(NSGraphicsContext*, SEL);
void (*DPSsetinputfocus_)
(NSGraphicsContext*, SEL, int);
void (*DPShidecursor)
(NSGraphicsContext*, SEL);
void (*DPSshowcursor)
(NSGraphicsContext*, SEL);
void (*DPSstandardcursor__)
(NSGraphicsContext*, SEL, int, void **);
void (*DPSimagecursor_______)
(NSGraphicsContext*, SEL, float, float, float, float, int, const char *, void **);
void (*DPSsetcursorcolor_______)
(NSGraphicsContext*, SEL, float, float, float, float, float, float, void *);
/* ----------------------------------------------------------------------- */
/* GNUstep Event and other I/O extensions */
/* ----------------------------------------------------------------------- */

View file

@ -33,7 +33,7 @@
#include <AppKit/NSFontManager.h>
@class NSCell;
@class NSPasteBoard;
@class NSPasteboard;
typedef short NSLineDesc;
@ -470,7 +470,7 @@ typedef struct _NSCStringTextInternalState {
- (void)setLocation:(NSPoint)origin
ofCell:(NSCell *)cell;
+ excludeFromServicesMenu:(BOOL)flag;
- (BOOL)readSelectionFromPasteboard:(NSPasteBoard *)pboard;
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard;
- (id)validRequestorForSendType:(NSString *)sendType
returnType:(NSString *)returnType;
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard

View file

@ -42,8 +42,7 @@
BOOL is_set_on_mouse_entered;
BOOL is_set_on_mouse_exited;
// Reserved for back-end use
void *be_cursor_reserved;
void *cid;
}
//
@ -92,13 +91,10 @@
@end
//
// Methods implemented by the backend
//
@interface NSCursor (GNUstepBackend)
+ (void)currentCursorHasChanged;
@end
/* Cursor types */
typedef enum {
GSArrowCursor,
GSIBeamCursor
} GSCursorTypes;
#endif // _GNUstep_H_NSCursor

View file

@ -408,6 +408,12 @@ NSGraphicsContext *GSCurrentContext();
- (void) DPSflushwindowrect: (float) x : (float) y : (float) w : (float) h : (int) win ;
- (void) DPScapturemouse: (int) win ;
- (void) DPSreleasemouse;
- (void) DPSsetinputfocus: (int) win ;
- (void) DPShidecursor;
- (void) DPSshowcursor;
- (void) DPSstandardcursor: (int) style : (void **) cid ;
- (void) DPSimagecursor: (float) hotx : (float) hoty : (float) w : (float) h : (int) colors : (const char *) image : (void **) cid ;
- (void) DPSsetcursorcolor: (float) fr : (float) fg : (float) fb : (float) br : (float) bg : (float) bb : (void *) cid ;
/* ----------------------------------------------------------------------- */
/* GNUstep Event and other I/O extensions */

View file

@ -468,7 +468,8 @@ extern NSSize NSTokenSize;
*/
@interface NSWindow (GNUstepPrivate)
+ (NSWindow*) _windowWithNumber: (int)windowNumber;
+ (NSWindow *) _windowWithNumber: (int)windowNumber;
+ (NSArray *) _windowList;
/*
* Mouse capture/release

View file

@ -75,15 +75,150 @@ struct _NSModalSession {
NSModalSession previous;
};
@interface NSIconWindow : NSWindow
@end
@interface NSAppIconView : NSView
- (void) setImage: (NSImage *)anImage;
@end
/*
* Class variables
*/
static BOOL gnustep_gui_app_is_in_dealloc;
static NSIconWindow *app_icon_window;
static NSEvent *null_event;
static NSString *NSAbortModalException = @"NSAbortModalException";
NSApplication *NSApp = nil;
@implementation NSIconWindow
- (BOOL) canBecomeMainWindow
{
return NO;
}
- (BOOL) canBecomeKeyWindow
{
return NO;
}
- (void) initDefaults
{
[super initDefaults];
menu_exclude = YES; // Don't show in windows menu.
window_level = NSDockWindowLevel;
is_released_when_closed = NO;
}
@end
@implementation NSAppIconView
// Class variables
static NSCell* dragCell = nil;
static NSCell* tileCell = nil;
+ (void) initialize
{
NSImage *defImage = [NSImage imageNamed: @"GNUstep"];
NSImage *tileImage = [NSImage imageNamed: @"common_Tile"];
dragCell = [[NSCell alloc] initImageCell: defImage];
[dragCell setBordered: NO];
tileCell = [[NSCell alloc] initImageCell: tileImage];
[tileCell setBordered: NO];
}
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
{
return YES;
}
- (void) drawRect: (NSRect)rect
{
[tileCell drawWithFrame: rect inView: self];
[dragCell drawWithFrame: rect inView: self];
}
- (void) mouseDown: (NSEvent*)theEvent
{
if ([theEvent clickCount] >= 2)
{
NSWindow *kw = [NSApp keyWindow];
if (!kw)
kw = [self window];
[NSApp unhide: self];
if (kw)
{
NSGraphicsContext *context = GSCurrentContext();
[kw orderFrontRegardless];
[context flush];
DPSsetinputfocus(context, [kw windowNumber]);
}
}
else
{
NSPoint lastLocation;
NSPoint location;
unsigned eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
| NSPeriodicMask | NSRightMouseUpMask;
NSDate *theDistantFuture = [NSDate distantFuture];
NSApplication *theApp = [NSApplication sharedApplication];
BOOL done = NO;
lastLocation = [theEvent locationInWindow];
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.02];
while (!done)
{
theEvent = [theApp nextEventMatchingMask: eventMask
untilDate: theDistantFuture
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
switch ([theEvent type])
{
case NSRightMouseUp:
case NSLeftMouseUp:
/* right mouse up or left mouse up means we're done */
done = YES;
break;
case NSPeriodic:
location = [window mouseLocationOutsideOfEventStream];
if (NSEqualPoints(location, lastLocation) == NO)
{
NSPoint origin = [window frame].origin;
origin.x += (location.x - lastLocation.x);
origin.y += (location.y - lastLocation.y);
[window setFrameOrigin: origin];
}
break;
default:
break;
}
}
[NSEvent stopPeriodicEvents];
}
}
- (void) setImage: (NSImage *)anImage
{
[self lockFocus];
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
[dragCell setImage: anImage];
[dragCell drawWithFrame: NSMakeRect(8,8,48,48) inView: self];
[window flushWindow];
[self unlockFocus];
}
@end
@implementation NSApplication
/*
@ -131,6 +266,30 @@ NSApplication *NSApp = nil;
/*
* Instance methods
*/
- _appIconInit
{
NSAppIconView *iv;
NSGraphicsContext *context = GSCurrentContext();
if (app_icon == nil)
app_icon = [[NSImage imageNamed: @"GNUstep"] retain];
app_icon_window = [[NSIconWindow alloc] initWithContentRect:
NSMakeRect(0,0,64,64)
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreRetained
defer: NO
screen: nil];
iv = [[NSAppIconView alloc] initWithFrame: NSMakeRect(0,0,64,64)];
[app_icon_window setContentView: iv];
[iv setImage: app_icon];
[app_icon_window orderFrontRegardless];
DPSsetinputfocus(context, [app_icon_window windowNumber]);
return self;
}
- (id) init
{
if (NSApp != nil && NSApp != self)
@ -149,6 +308,7 @@ NSApplication *NSApp = nil;
NSDebugLog(@"Begin of NSApplication -init\n");
[self _appIconInit];
unhide_on_activation = YES;
app_is_hidden = YES;
app_is_active = NO;
@ -279,9 +439,11 @@ NSApplication *NSApp = nil;
{
if (app_is_active == NO)
{
NSGraphicsContext *context = GSCurrentContext();
NSWindow *kw = [self keyWindow];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
/*
/*
* Menus should observe this notification in order to make themselves
* visible when the application is active.
*/
@ -293,6 +455,15 @@ NSApplication *NSApp = nil;
if (unhide_on_activation)
[self unhide: nil];
if (kw == nil || [kw isVisible] == NO)
{
kw = app_icon_window;
}
NSDebugLog(@"activateIgnoringOtherApps start.");
[context flush];
DPSsetinputfocus(context, [kw windowNumber]);
NSDebugLog(@"activateIgnoringOtherApps end.");
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
object: self];
}
@ -831,6 +1002,8 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
[app_icon setName: nil];
[anImage setName: @"NSApplicationIcon"];
ASSIGN(app_icon, anImage);
[[app_icon_window contentView] setImage: anImage];
[[app_icon_window contentView] setNeedsDisplay: YES];
}
- (NSImage*) applicationIconImage
@ -1082,25 +1255,12 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
- (NSArray*) windows
{
// Implemented by backend.
return nil;
return [NSWindow _windowList];
}
- (NSWindow *) windowWithWindowNumber: (int)windowNum
{
NSArray *window_list = [self windows];
unsigned i, j;
NSWindow *w;
j = [window_list count];
for (i = 0; i < j; ++i)
{
w = [window_list objectAtIndex: i];
if ([w windowNumber] == windowNum)
return w;
}
return nil;
return [NSWindow _windowWithNumber: windowNum];
}
/*

View file

@ -29,6 +29,8 @@
#include <gnustep/gui/config.h>
#include <Foundation/NSArray.h>
#include <AppKit/NSCursor.h>
#include <AppKit/NSGraphicsContext.h>
#include <AppKit/DPSOperators.h>
// Class variables
static NSMutableArray *gnustep_gui_cursor_stack;
@ -54,11 +56,22 @@ static BOOL gnustep_gui_hidden_until_move;
}
}
- (void *)_cid
{
return cid;
}
- (void) _setCid: (void *)id
{
cid = id;
}
//
// Setting the Cursor
//
+ (void)hide
{
DPShidecursor(GSCurrentContext());
}
+ (void)pop
@ -74,7 +87,9 @@ static BOOL gnustep_gui_hidden_until_move;
if ([gnustep_gui_cursor_stack count])
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
[self currentCursorHasChanged];
if ([gnustep_gui_current_cursor _cid])
DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1,
[gnustep_gui_current_cursor _cid]);
}
+ (void)setHiddenUntilMouseMoves:(BOOL)flag
@ -89,6 +104,7 @@ static BOOL gnustep_gui_hidden_until_move;
+ (void)unhide
{
DPSshowcursor(GSCurrentContext());
}
//
@ -96,7 +112,11 @@ static BOOL gnustep_gui_hidden_until_move;
//
+ (NSCursor *)arrowCursor
{
return nil;
void *c;
NSCursor *cur = AUTORELEASE([[NSCursor alloc] initWithImage: nil]);
DPSstandardcursor(GSCurrentContext(), GSArrowCursor, &c);
[cur _setCid: c];
return cur;
}
+ (NSCursor *)currentCursor
@ -106,7 +126,11 @@ static BOOL gnustep_gui_hidden_until_move;
+ (NSCursor *)IBeamCursor
{
return nil;
void *c;
NSCursor *cur = AUTORELEASE([[NSCursor alloc] initWithImage: nil]);
DPSstandardcursor(GSCurrentContext(), GSIBeamCursor, &c);
[cur _setCid: c];
return cur;
}
//
@ -193,13 +217,15 @@ static BOOL gnustep_gui_hidden_until_move;
{
[gnustep_gui_cursor_stack addObject: self];
gnustep_gui_current_cursor = self;
[NSCursor currentCursorHasChanged];
if (cid)
DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, cid);
}
- (void)set
{
gnustep_gui_current_cursor = self;
[NSCursor currentCursorHasChanged];
if (cid)
DPSsetcursorcolor(GSCurrentContext(), 0, 0, 0, 1, 1, 1, cid);
}
- (void)setOnMouseEntered:(BOOL)flag
@ -225,13 +251,3 @@ static BOOL gnustep_gui_hidden_until_move;
}
@end
//
// Methods implemented by the backend
//
@implementation NSCursor (GNUstepBackend)
+ (void)currentCursorHasChanged
{}
@end

View file

@ -811,6 +811,18 @@ NSGraphicsContext *GSCurrentContext()
GET_IMP(@selector(DPScapturemouse:));
methodTable.DPSreleasemouse =
GET_IMP(@selector(DPSreleasemouse));
methodTable.DPSsetinputfocus_ =
GET_IMP(@selector(DPSsetinputfocus:));
methodTable.DPShidecursor =
GET_IMP(@selector(DPShidecursor));
methodTable.DPSshowcursor =
GET_IMP(@selector(DPSshowcursor));
methodTable.DPSstandardcursor__ =
GET_IMP(@selector(DPSstandardcursor::));
methodTable.DPSimagecursor_______ =
GET_IMP(@selector(DPSimagecursor:::::::));
methodTable.DPSsetcursorcolor_______ =
GET_IMP(@selector(DPSsetcursorcolor:::::::));
/* ----------------------------------------------------------------------- */
/* GNUstep Event and other I/O extensions */
/* ----------------------------------------------------------------------- */
@ -1926,6 +1938,36 @@ NSGraphicsContext *GSCurrentContext()
[self subclassResponsibility: _cmd];
}
- (void) DPSsetinputfocus: (int) win ;
{
[self subclassResponsibility: _cmd];
}
- (void) DPShidecursor;
{
[self subclassResponsibility: _cmd];
}
- (void) DPSshowcursor;
{
[self subclassResponsibility: _cmd];
}
- (void) DPSstandardcursor: (int) style : (void **) cid ;
{
[self subclassResponsibility: _cmd];
}
- (void) DPSimagecursor: (float) hotx : (float) hoty : (float) w : (float) h : (int) colors : (const char *) image : (void **) cid ;
{
[self subclassResponsibility: _cmd];
}
- (void) DPSsetcursorcolor: (float) fr : (float) fg : (float) fb : (float) br : (float) bg : (float) bb : (void *) cid ;
{
[self subclassResponsibility: _cmd];
}
/* ----------------------------------------------------------------------- */
/* GNUstep Event and other I/O extensions */
/* ----------------------------------------------------------------------- */

View file

@ -174,10 +174,10 @@ static NSDictionary* nsmapping = nil;
{
NSString* ext;
NSString* path = nil;
NSBundle* main;
NSBundle* main_bundle;
NSArray *array;
NSString *the_name = aName;
main = [NSBundle mainBundle];
main_bundle = [NSBundle mainBundle];
ext = [aName pathExtension];
/* Check if extension is one of the image types */
@ -198,7 +198,7 @@ static NSDictionary* nsmapping = nil;
/* First search locally */
if (ext)
path = [main pathForResource: the_name ofType: ext];
path = [main_bundle pathForResource: the_name ofType: ext];
else
{
id o, e;
@ -207,7 +207,7 @@ static NSDictionary* nsmapping = nil;
while ((o = [e nextObject]))
{
NSDebugLog(@"extension %s\n", [o cString]);
path = [main pathForResource: the_name
path = [main_bundle pathForResource: the_name
ofType: o];
if (path != nil && [path length] != 0)
break;

View file

@ -265,8 +265,7 @@
if ([window isVisible])
{
[window display];
#warning It does not seem that GNUstep has a NSDPSContext
// [[NSDPSContext currentContext] flush];
[GSCurrentContext() flush];
}
}

View file

@ -32,8 +32,23 @@
#include <AppKit/NSApplication.h>
#include <AppKit/NSScreen.h>
#include <AppKit/NSInterfaceStyle.h>
#include <AppKit/NSGraphicsContext.h>
#include <AppKit/DPSOperators.h>
static int *
_screen_numbers(void)
{
int count, *list;
NSGraphicsContext *ctxt = GSCurrentContext();
DPScountscreenlist(ctxt, 0, &count);
if (count == 0)
return NULL;
list = NSZoneMalloc(NSDefaultMallocZone(), (count+1)*sizeof(int));
DPSscreenlist(ctxt, 0, count, list);
return list;
}
@implementation NSScreen
@ -82,6 +97,10 @@ static NSScreen *mainScreen = nil;
//
- initWithDeviceDescription: (NSDictionary *)dict
{
int screen;
float x, y, w, h;
NSGraphicsContext *ctxt = GSCurrentContext();
[super init];
depth = 0;
frame = NSZeroRect;
@ -89,6 +108,33 @@ static NSScreen *mainScreen = nil;
device_desc = [dict mutableCopy];
else
device_desc = [[NSMutableDictionary dictionary] retain];
if ([ctxt isDrawingToScreen] == NO)
{
NSLog(@"Internal error: trying to find screen with wrong context\n");
[self dealloc];
return nil;
}
if (!dict || [dict objectForKey: @"NSScreenKeyName"] == nil
|| [[dict objectForKey: @"NSScreenKeyName"] isEqual: @"Main"])
{
/* Assume the main screen is the one we started with */
int *windows = _screen_numbers();
screen = 0;
if (windows)
screen = windows[0];
NSZoneFree(NSDefaultMallocZone(), windows);
}
else if ([dict objectForKey: @"NSScreenNumber"])
{
screen = [[dict objectForKey: @"NSScreenNumber"] intValue];
}
/* Special hack to get screen frame since window number of root window
is same as screen number */
DPScurrentwindowbounds(ctxt, screen, &x, &y, &w, &h);
frame = NSMakeRect(x, y, w, h);
DPScurrentwindowdepth(ctxt, screen, &depth);
return self;
}

View file

@ -2192,7 +2192,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[ctxt _addDragTypes: t toWindow: [window windowNumber]];
if (o != nil)
{
[ctxt _removeDragTypes: t fromWindow: [window windowNumber]];
[ctxt _removeDragTypes: o fromWindow: [window windowNumber]];
}
}
TEST_RELEASE(o);

View file

@ -2423,11 +2423,16 @@ static NSMapTable* windowmaps = NULL;
*/
@implementation NSWindow (GNUstepPrivate)
+ (NSWindow*) _windowWithNumber: (int)windowNumber
+ (NSWindow *) _windowWithNumber: (int)windowNumber
{
return NSMapGet(windowmaps, (void *)windowNumber);
}
+ (NSArray *) _windowList
{
return NSAllMapTableValues(windowmaps);
}
/*
* Mouse capture/release
*/