Numerous WIN32 and bug fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2380 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1997-08-16 23:47:24 +00:00
parent 433204b18a
commit 287c850658
17 changed files with 213 additions and 132 deletions

View file

@ -1,3 +1,47 @@
Sat Aug 16 16:28:31 1997 Scott Christley <scottc@net-community.com>
* Headers/gnustep/gui/NSApplication.h (+setNullEvent:): New method.
(+getNullEvent): New method.
(NSApp): Eliminate global variable.
* Headers/gnustep/gui/NSWindow.h (-performDeminiaturize:): New method.
(-performHide:): New method.
(-performUnhide:): New method.
* Source/Makefile.in: Rename variables.
* Source/NSApplication.m (+setNullEvent:): New method.
(+getNullEvent): New method.
(-peekEventMatchingMask:untilDate:inMode:dequeue:): Modify to be
more like the nextEvent.. method.
(-hide:): Call performHide: method.
(-unhide:): Call performUnhide: method.
* Source/NSButton.m (mouseDown:): Add method calls to capture and
release the mouse. Set the action mask.
* Source/NSCell.m (-setDoubleValue:): Don't set the cell type.
(-setFloatValue:, -setIntValue:, -setStringValue:): Likewise.
* Source/NSEvent.m: Don't access application object through
the global variable, use method instead.
* Source/NSFont.m (getFont, setFont): Rename to getNSFont and
setNSFont and make non-static so that they can be called
from the backend implementation.
* Source/NSMatrix.m (-initWithFrame:mode:prototype:numberOfRows:
numberOfColumns:): Call super's initWithFrame:
(mouseDown:): Capture and release the mouse when tracking. Don't
access application object through the global variable, use
method instead.
* Source/NSMenu.m: Don't access application object through the
global variable, use method instead.
* Source/NSScroller.m: Likewise.
* Source/NSTextFieldCell.m (-dealloc, -copyWithZone:): New method.
Fix retain/release on colors.
* Source/NSWindow.m (-deminiaturize:): Call performDeminiaturize.
(-makeFirstResponder:): Check that first responder exists before
telling it to resign.
(-performDeminiaturize:): New method.
(-performHide:): New method.
(-performUnhide:): New method.
* Source/externs.m: Add global variables.
* Source/libgnustep-gui.def: Add functions.
* Source/libgnustep-gui.m: Eliminate unneeded code.
Wed Aug 6 13:27:53 1997 Ovidiu Predescu <ovidiu@net-community.com>
* Source/NSApplication (-nextEventMatchingMask:untilDate:inMode:

View file

@ -46,8 +46,6 @@
@class NSWindow;
@class NSDPSContext;
extern id NSApp;
typedef struct _NSModalSession *NSModalSession;
enum {
@ -270,6 +268,10 @@ extern NSString *NSEventTrackingRunLoopMode;
//
@interface NSApplication (GNUstepBackend)
// the null event
+ (void)setNullEvent:(NSEvent *)e;
+ (NSEvent *)getNullEvent;
// Get next event
- (NSEvent *)getNextEvent;
- (NSEvent *)peekNextEvent;

View file

@ -419,6 +419,10 @@ extern NSSize NSTokenSize;
- (void)initDefaults;
- cleanInit;
- (void)performDeminiaturize:sender;
- (void)performHide:sender;
- (void)performUnhide:sender;
@end
/* Notifications */

View file

@ -68,9 +68,9 @@ LDFLAGS = @LDFLAGS@ -o
LD = ld
LDOUT =
LIB = ar
LIBOUT =
LIBFLAGS = rc
AR = ar
AROUT =
ARFLAGS = rc
RANLIB = @RANLIB@
RC =
DLLTOOL = @DLLTOOL@
@ -264,12 +264,12 @@ src: @STATIC_LIBRARY@ @SHARED_LIBRARY@
# library
$(MAIN_FILE)$(libext): $(OBJS)
$(LIB) $(LIBFLAGS) $(LIBOUT)$(MAIN_FILE)$(libext) $(OBJS)
$(AR) $(ARFLAGS) $(AROUT)$(MAIN_FILE)$(libext) $(OBJS)
$(RANLIB) $(MAIN_FILE)$(libext)
# static library when building DLL
$(MAIN_FILE)_s$(libext): $(OBJS)
$(LIB) $(LIBFLAGS) $(LIBOUT)$(MAIN_FILE)_s$(libext) $(OBJS)
$(AR) $(ARFLAGS) $(AROUT)$(MAIN_FILE)_s$(libext) $(OBJS)
$(RANLIB) $(MAIN_FILE)_s$(libext)
$(MAIN_FILE).def: FORCE
@ -366,7 +366,9 @@ uninstall:
rm -rf $(includedir)/gnustep/gui
rm -rf $(includedir)/AppKit
rm -rf $(includedir)/DPSClient
rm -rf $(libdir)/$(MAIN_FILE)$(libext)
rm -f $(libdir)/$(MAIN_FILE)$(libext)
rm -f $(libdir)/$(MAIN_FILE)_s$(libext)
rm -f $(bindir)/$(MAIN_FILE).dll
Makefile: $(srcdir)/Makefile.in ../config.status
cd ..; $(SHELL) config.status
@ -379,6 +381,8 @@ clean:
rm -f *~
rm -f *$(oext)
rm -f $(MAIN_FILE)$(libext)
rm -f $(MAIN_FILE)_s$(libext)
rm -f $(MAIN_FILE).dll $(MAIN_FILE).exp $(MAIN_FILE).base
rm -f $(INIT_FILE).c
distclean: clean
rm -f Makefile

View file

@ -43,13 +43,13 @@
#include <AppKit/NSMenuItem.h>
#include <AppKit/NSCursor.h>
extern id NSApp;
extern NSEvent *gnustep_gui_null_event;
//
// Class variables
//
static BOOL gnustep_gui_app_is_in_dealloc;
static NSEvent *gnustep_gui_null_event;
static id NSApp;
@implementation NSApplication
//
@ -465,41 +465,21 @@ static BOOL gnustep_gui_app_is_in_dealloc;
inMode:(NSString *)mode
dequeue:(BOOL)flag
{
NSEvent *e;
NSEvent *event = nil;
int i, j;
// If the queue isn't empty then check those messages
if ([event_queue count])
{
j = [event_queue count];
for (i = j-1;i >= 0; --i)
{
e = [event_queue objectAtIndex: i];
if ([self event: e matchMask: mask])
{
[event_queue removeObjectAtIndex: i];
[self setCurrentEvent: e];
return e;
}
}
}
event = [self _eventMatchingMask:mask];
// Not in queue so peek for event
e = [self peekNextEvent];
// Check mask
if ([self event: e matchMask: mask])
if (!event)
{
if (e)
{
[event_queue removeObject: e];
}
// Not in queue so peek for event
event = [self peekNextEvent];
event = [self _eventMatchingMask:mask];
}
else
return nil;
// Unhide the cursor if necessary
if (e != gnustep_gui_null_event)
if (event && (event != gnustep_gui_null_event))
{
NSEventType type;
@ -507,7 +487,7 @@ static BOOL gnustep_gui_app_is_in_dealloc;
if ([NSCursor isHiddenUntilMouseMoves])
{
// Make sure the event is a mouse event before unhiding
type = [e type];
type = [event type];
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|| (type == NSMouseMoved))
@ -515,8 +495,7 @@ static BOOL gnustep_gui_app_is_in_dealloc;
}
}
[self setCurrentEvent: e];
return e;
return event;
}
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag
@ -583,15 +562,16 @@ static BOOL gnustep_gui_app_is_in_dealloc;
//
- (void)hide:sender
{
int i, j;
id e;
NSWindow *w;
j = [window_list count];
for (i = 0;i < j; ++i)
{
w = [window_list objectAtIndex:i];
// Do something to hide the window
}
// TODO: hide the menu
// Tell the windows to hide
e = [window_list objectEnumerator];
while ((w = [e nextObject]))
[w performHide: sender];
app_is_hidden = YES;
}
@ -602,17 +582,19 @@ static BOOL gnustep_gui_app_is_in_dealloc;
- (void)unhide:sender
{
int i, j;
id e;
NSWindow *w;
app_is_hidden = NO;
j = [window_list count];
for (i = 0;i < j; ++i)
{
w = [window_list objectAtIndex:i];
// Do something to unhide the window
}
// Tell the windows to unhide
e = [window_list objectEnumerator];
while ((w = [e nextObject]))
[w performUnhide: sender];
// TODO: unhide the menu
app_is_hidden = NO;
// Bring the key window to the front
[[self keyWindow] makeKeyAndOrderFront:self];
}
@ -1076,6 +1058,16 @@ static BOOL gnustep_gui_app_is_in_dealloc;
//
@implementation NSApplication (GNUstepBackend)
+ (void)setNullEvent:(NSEvent *)e
{
gnustep_gui_null_event = e;
}
+ (NSEvent *)getNullEvent;
{
return gnustep_gui_null_event;
}
// Get next event
- (NSEvent *)getNextEvent
{

View file

@ -289,7 +289,7 @@ id gnustep_gui_nsbutton_class = nil;
NSEvent *e;
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask;
// int oldActionMask = [cell sendActionOn:0];
int oldActionMask;
NSDebugLog(@"NSButton mouseDown\n");
@ -297,8 +297,15 @@ id gnustep_gui_nsbutton_class = nil;
if (![self isEnabled])
return;
// Have NSCell send action only if we are continuous
if ([cell isContinuous])
oldActionMask = [cell sendActionOn:0];
else
oldActionMask = [cell sendActionOn: NSPeriodicMask];
// capture mouse
// [[self window] captureMouse: self];
[[self window] captureMouse: self];
[self lockFocus];
done = NO;
@ -321,7 +328,7 @@ id gnustep_gui_nsbutton_class = nil;
}
// Release mouse
// [[self window] releaseMouse: self];
[[self window] releaseMouse: self];
// If the mouse went up in the button
if (mouseUp)
@ -337,11 +344,11 @@ id gnustep_gui_nsbutton_class = nil;
[self unlockFocus];
/* Restore the old action mask */
// [cell sendActionOn:oldActionMask];
[cell sendActionOn:oldActionMask];
// Have the target perform the action
// if (mouseUp)
// [self sendAction:[self action] to:[self target]];
if (mouseUp)
[self sendAction:[self action] to:[self target]];
}
- (void)performClick:(id)sender

View file

@ -259,7 +259,6 @@
[contents release];
contents = [[number stringValue] retain];
[self setType:NSTextCellType];
}
- (void)setFloatValue:(float)aFloat
@ -268,7 +267,6 @@
[contents release];
contents = [[number stringValue] retain];
[self setType:NSTextCellType];
}
- (void)setIntValue:(int)anInt
@ -277,12 +275,10 @@
[contents release];
contents = [[number stringValue] retain];
[self setType:NSTextCellType];
}
- (void)setStringValue:(NSString *)aString
{
[self setType:NSTextCellType];
aString = [aString copy];
[contents release];
if (!aString)

View file

@ -346,13 +346,13 @@ static NSRecursiveLock* timersLock = nil;
modifierFlags:0
timestamp:[[NSDate date] timeIntervalSinceReferenceDate]
windowNumber:0
context:[NSApp context]
context:[[NSApplication sharedApplication] context]
subtype:0
data1:0
data2:0];
NSDebugLog (@"_timerFired:");
[NSApp postEvent:periodicEvent atStart:NO];
[[NSApplication sharedApplication] postEvent:periodicEvent atStart:NO];
}
+ (void)_registerRealTimer:(NSTimer*)timer

View file

@ -42,7 +42,8 @@
Convention (see the red book). */
static NSMutableSet* fontsUsed = nil;
static NSFont* getFont(NSString* key, NSString* defaultFontName, float fontSize)
NSFont* getNSFont(NSString* key, NSString* defaultFontName,
float fontSize)
{
NSString* fontName;
@ -60,7 +61,7 @@ static NSFont* getFont(NSString* key, NSString* defaultFontName, float fontSize)
return [NSFont fontWithName:fontName size:fontSize];
}
static void setFont(NSString* key, NSFont* font)
void setNSFont(NSString* key, NSFont* font)
{
NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
@ -87,34 +88,34 @@ static void setFont(NSString* key, NSFont* font)
+ (NSFont*)boldSystemFontOfSize:(float)fontSize
{
return getFont (@"NSBoldFont", @"Helvetica-Bold", fontSize);
return getNSFont (@"NSBoldFont", @"Helvetica-Bold", fontSize);
}
+ (NSFont*)systemFontOfSize:(float)fontSize
{
return getFont (@"NSFont", @"Helvetica", fontSize);
return getNSFont (@"NSFont", @"Helvetica", fontSize);
}
+ (NSFont*)userFixedPitchFontOfSize:(float)fontSize
{
return getFont (@"NSUserFixedPitchFont", @"Courier", fontSize);
return getNSFont (@"NSUserFixedPitchFont", @"Courier", fontSize);
}
+ (NSFont*)userFontOfSize:(float)fontSize
{
return getFont (@"NSUserFont", @"Helvetica", fontSize);
return getNSFont (@"NSUserFont", @"Helvetica", fontSize);
}
/* Setting the preferred user fonts */
+ (void)setUserFixedPitchFont:(NSFont*)font
{
setFont (@"NSUserFixedPitchFont", font);
setNSFont (@"NSUserFixedPitchFont", font);
}
+ (void)setUserFont:(NSFont*)font
{
setFont (@"NSUserFont", font);
setNSFont (@"NSUserFont", font);
}
/* The following method should be rewritten in the backend and it has to be

View file

@ -349,6 +349,8 @@ static int mouseDownFlags = 0;
{
int i, j;
[super initWithFrame: frameRect];
ASSIGN(cellPrototype, prototype);
cells = [[NSMutableArray alloc] initWithCapacity:rows];
@ -1164,6 +1166,10 @@ static int mouseDownFlags = 0;
if (mode != NSTrackModeMatrix)
[NSEvent startPeriodicEventsAfterDelay:0.05 withPeriod:0.05];
ASSIGN(lastEvent, theEvent);
// capture mouse
[[self window] captureMouse: self];
[self lockFocus];
while (!done) {
@ -1286,12 +1292,14 @@ static int mouseDownFlags = 0;
/* Get the next event */
while (!shouldProceedEvent) {
theEvent = [NSApp nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
theEvent = [[NSApplication sharedApplication]
nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
switch ([theEvent type]) {
case NSPeriodic:
NSDebugLog(@"NSMatrix: got NSPeriodic event\n");
shouldProceedEvent = YES;
break;
case NSLeftMouseUp:
@ -1300,6 +1308,7 @@ static int mouseDownFlags = 0;
ASSIGN(lastEvent, theEvent);
break;
default:
NSDebugLog(@"NSMatrix: got event type: %d\n", [theEvent type]);
ASSIGN(lastEvent, theEvent);
continue;
}
@ -1308,6 +1317,9 @@ static int mouseDownFlags = 0;
lastLocation = [self convertPoint:lastLocation fromView:nil];
}
// Release mouse
[[self window] releaseMouse: self];
/* Finalize the selection */
switch (mode) {
case NSTrackModeMatrix:

View file

@ -428,8 +428,9 @@ static Class menuCellClass = nil;
id cells;
int i, count;
id theApp = [NSApplication sharedApplication];
if (![[NSApp mainMenu] autoenablesItems])
if (![[theApp mainMenu] autoenablesItems])
return;
cells = [menuCells itemArray];
@ -471,7 +472,7 @@ static Class menuCellClass = nil;
}
/* Search the key window's responder chain */
keyWindow = [NSApp keyWindow];
keyWindow = [theApp keyWindow];
responder = [keyWindow firstResponder];
while (responder && !found) {
if ([responder respondsToSelector:action]) {
@ -505,7 +506,7 @@ static Class menuCellClass = nil;
continue;
}
mainWindow = [NSApp mainWindow];
mainWindow = [theApp mainWindow];
if (mainWindow != keyWindow) {
/* Search the main window's responder chain */
responder = [mainWindow firstResponder];
@ -544,16 +545,16 @@ static Class menuCellClass = nil;
}
/* Search the NSApplication object */
if ([NSApp respondsToSelector:action]) {
if ([NSApp respondsToSelector:@selector(validateMenuItem:)])
[cell setEnabled:[NSApp validateMenuItem:cell]];
if ([theApp respondsToSelector:action]) {
if ([theApp respondsToSelector:@selector(validateMenuItem:)])
[cell setEnabled:[theApp validateMenuItem:cell]];
else
[cell setEnabled:YES];
continue;
}
/* Search the NSApplication object's delegate */
delegate = [NSApp delegate];
delegate = [theApp delegate];
if ([delegate respondsToSelector:action]) {
if ([delegate respondsToSelector:@selector(validateMenuItem:)])
[cell setEnabled:[delegate validateMenuItem:cell]];
@ -579,6 +580,7 @@ static Class menuCellClass = nil;
NSWindow* mainWindow;
id responder;
id delegate;
id theApp = [NSApplication sharedApplication];
if (![cell isEnabled])
return;
@ -592,7 +594,7 @@ static Class menuCellClass = nil;
}
/* Search the key window's responder chain */
keyWindow = [NSApp keyWindow];
keyWindow = [theApp keyWindow];
responder = [keyWindow firstResponder];
while (responder) {
if ([responder respondsToSelector:action]) {
@ -615,7 +617,7 @@ static Class menuCellClass = nil;
return;
}
mainWindow = [NSApp mainWindow];
mainWindow = [theApp mainWindow];
if (mainWindow != keyWindow) {
/* Search the main window's responder chain */
responder = [mainWindow firstResponder];
@ -642,13 +644,13 @@ static Class menuCellClass = nil;
}
/* Search the NSApplication object */
if ([NSApp respondsToSelector:action]) {
[NSApp perform:action withObject:cell];
if ([theApp respondsToSelector:action]) {
[theApp perform:action withObject:cell];
return;
}
/* Search the NSApplication object's delegate */
delegate = [NSApp delegate];
delegate = [theApp delegate];
if ([delegate respondsToSelector:action]) {
[delegate perform:action withObject:cell];
return;

View file

@ -395,10 +395,11 @@ static NSButtonCell* knobCell = nil;
[[NSRunLoop currentRunLoop] limitDateForMode:NSEventTrackingRunLoopMode];
while (eventType != NSLeftMouseUp) {
theEvent = [NSApp nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
theEvent = [[NSApplication sharedApplication]
nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
eventType = [theEvent type];
if (eventType != NSPeriodic)
@ -467,10 +468,11 @@ static NSButtonCell* knobCell = nil;
if (shouldReturn)
break;
theEvent = [NSApp nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode // NSDefaultRunLoopMode
dequeue:YES];
theEvent = [[NSApplication sharedApplication]
nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode // NSDefaultRunLoopMode
dequeue:YES];
eventType = [theEvent type];
location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
_hitPart = [self testPart:location];

View file

@ -76,14 +76,31 @@
[self setScrollable:YES];
[self setEditable:YES];
[self setAlignment:NSLeftTextAlignment];
background_color = [NSColor whiteColor];
text_color = [NSColor blackColor];
cell_font = [NSFont systemFontOfSize:16];
[self setBackgroundColor: [NSColor whiteColor]];
[self setTextColor: [NSColor blackColor]];
[self setFont: [NSFont systemFontOfSize: 16]];
draw_background = YES;
return self;
}
- (void)dealloc
{
[background_color release];
[text_color release];
[super dealloc];
}
- (id)copyWithZone:(NSZone*)zone
{
NSTextFieldCell* c = [super copyWithZone:zone];
[c setBackgroundColor: background_color];
[c setTextColor: text_color];
return c;
}
//
// Modifying Graphic Attributes
//
@ -99,6 +116,8 @@
- (void)setBackgroundColor:(NSColor *)aColor
{
[aColor retain];
[background_color release];
background_color = aColor;
}
@ -109,6 +128,8 @@
- (void)setTextColor:(NSColor *)aColor
{
[aColor retain];
[text_color release];
text_color = aColor;
}

View file

@ -791,6 +791,8 @@
is_miniaturized = NO;
visible = YES;
[self performDeminiaturize:self];
// Notify our delegate
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
}
@ -899,7 +901,7 @@
// Notify current first responder that it should resign
// If it says NO then no change
// But make sure that there even is a first responder
if ((![first_responder resignFirstResponder]) && first_responder)
if ((first_responder) && (![first_responder resignFirstResponder]))
return NO;
// Make it the first responder
@ -1626,4 +1628,19 @@
return self;
}
- (void)performDeminiaturize:sender
{
// Do nothing, should be overridden by back-end
}
- (void)performHide:sender
{
// Do nothing, should be overridden by back-end
}
- (void)performUnhide:sender
{
// Do nothing, should be overridden by back-end
}
@end

View file

@ -29,12 +29,6 @@
#include <Foundation/NSString.h>
#include <AppKit/NSEvent.h>
/* The global application object */
/* This should really be accessed through [NSApplication sharedApplication] */
id NSApp = nil;
NSEvent *gnustep_gui_null_event = nil;
// Global strings
NSString *NSModalPanelRunLoopMode = @"ModalPanelMode";
NSString *NSEventTrackingRunLoopMode = @"EventTrackingMode";

View file

@ -70,6 +70,8 @@ __objc_class_name_NSDataLinkPanel
__objc_class_name_NSDPSContext
__objc_class_name_NSEPSImageRep
__objc_class_name_NSEvent
getNSFont
setNSFont
__objc_class_name_NSFont
__objc_category_name_NSFontManager_GNUstepBackend
__objc_class_name_NSFontManager
@ -100,7 +102,6 @@ __objc_class_name_NSPopUpButton
__objc_class_name_NSResponder
__objc_class_name_NSSavePanel
__objc_class_name_NSScreen
__objc_category_name_NSScroller_GNUstepBackend
__objc_class_name_NSScroller
__objc_class_name_NSScrollView
__objc_class_name_NSSelection

View file

@ -38,23 +38,5 @@ char **NSArgv = NULL;
int
GNUstepMain(int argc, char **argv)
{
NSFontManager *fm;
// Create the global application object
NSApp = [[NSApplication alloc] init];
// Set the application default fonts
fm = [NSFontManager sharedFontManager];
[NSFont setUserFixedPitchFont: [fm fontWithFamily:@"Arial"
traits:0 weight:0 size:16]];
[NSFont setUserFont: [fm fontWithFamily:@"Times New Roman"
traits:0 weight:0 size:16]];
// Call the user's main
//user_main(0, NULL);
// Release the application
[NSApp release];
return 0;
return 0;
}