Fill out implementation of NSMenu, NSMatrix and NSWindow.

Many bug fixes for NSMatrix.
Assign values for global exception and notification strings.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1842 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
netcrep 1996-10-03 18:45:41 +00:00
parent 0cc4b39bb1
commit c0b92c18ee
6 changed files with 725 additions and 412 deletions

View file

@ -1,4 +1,21 @@
Sat Sep 21 12:25:23 1996 GNUstep Development <gnustep@duncan.ocbi.com> Wed Oct 2 10:40:23 1996 GNUstep Development <gnustep@duncan.ocbi.com>
* Headers/gnustep/gui/NSWindow.h: Add additional instance variables
to fill out implementation.
(-initDefaults): New method.
* Source/NSApplication.m: Assign values to the global exception and
notification strings. Post notifications to the default notification
center. Fixed bug where the first event was being removed from the
queue versus removing the event actually being processed.
* Source/NSMatrix.m: Fill out implementation, reimplement many
methods, and fix lots of bugs.
* Source/NSMenu.m: Don't create NSView as content view, just make
the menu matrix the content view.
* Source/NSWindow.m: Assign values to the notification strings.
Implement many unimplemented methods. Post notifications to the
default notification center.
Sat Sep 21 12:25:23 1996 GNUstep Development <gnustep@ocbi.com>
* Source/NSButtonCell.m (-initTextCell:): Make default font * Source/NSButtonCell.m (-initTextCell:): Make default font
be the user font instead of the user fixed pitch font. be the user font instead of the user fixed pitch font.

View file

@ -49,7 +49,8 @@
{ {
// Attributes // Attributes
NSRect frame; NSRect frame;
id frame_view; NSSize minimum_size;
NSSize maximum_size;
id content_view; id content_view;
id first_responder; id first_responder;
id original_responder; id original_responder;
@ -58,18 +59,33 @@
NSColor *background_color; NSColor *background_color;
NSString *represented_filename; NSString *represented_filename;
NSString *miniaturized_title; NSString *miniaturized_title;
NSImage *miniaturized_image;
NSString *window_title; NSString *window_title;
NSPoint last_point; NSPoint last_point;
NSBackingStoreType backing_type; NSBackingStoreType backing_type;
unsigned int style_mask;
int window_level;
BOOL is_one_shot;
BOOL needs_display;
BOOL is_autodisplay;
BOOL optimize_drawing;
BOOL views_need_display;
NSWindowDepth depth_limit;
BOOL dynamic_depth_limit;
BOOL cursor_rects_enabled;
BOOL visible; BOOL visible;
BOOL is_key; BOOL is_key;
BOOL is_main; BOOL is_main;
BOOL is_edited; BOOL is_edited;
BOOL is_released_when_closed;
BOOL is_miniaturized; BOOL is_miniaturized;
BOOL disable_flush_window; BOOL disable_flush_window;
unsigned int style_mask;
BOOL menu_exclude; BOOL menu_exclude;
BOOL hides_on_deactivate;
BOOL accepts_mouse_moved;
// Reserved for back-end use // Reserved for back-end use
void *be_wind_reserved; void *be_wind_reserved;
@ -315,7 +331,7 @@
// //
// Printing and postscript // Printing and postscript
// //
- (NSDate *)dataWithEPSInsideRect:(NSRect)rect; - (NSData *)dataWithEPSInsideRect:(NSRect)rect;
- (void)fax:sender; - (void)fax:sender;
- (void)print:sender; - (void)print:sender;
@ -354,9 +370,13 @@
- (void)encodeWithCoder:aCoder; - (void)encodeWithCoder:aCoder;
- initWithCoder:aDecoder; - initWithCoder:aDecoder;
@end
// //
// GNUstep additional methods // GNUstep backend methods
// //
@interface NSWindow (GNUstepBackend)
// //
// Mouse capture/release // Mouse capture/release
// //
@ -365,6 +385,7 @@
// Allow subclasses to init without the backend class // Allow subclasses to init without the backend class
// attempting to create an actual window // attempting to create an actual window
- (void)initDefaults;
- cleanInit; - cleanInit;
@end @end

View file

@ -48,56 +48,62 @@ NSString *NSEventTrackingRunLoopMode = @"EventTrackingMode";
// //
// Global Exception Strings // Global Exception Strings
// //
NSString *NSAbortModalException = @"AbortModalException"; NSString *NSAbortModalException = @"AbortModal";
NSString *NSAbortPrintingException = @"AbortPrintingException"; NSString *NSAbortPrintingException = @"AbortPrinting";
NSString *NSAppKitIgnoredException; NSString *NSAppKitIgnoredException = @"AppKitIgnored";
NSString *NSAppKitVirtualMemoryException; NSString *NSAppKitVirtualMemoryException = @"AppKitVirtualMemory";
NSString *NSBadBitmapParametersException; NSString *NSBadBitmapParametersException = @"BadBitmapParameters";
NSString *NSBadComparisonException; NSString *NSBadComparisonException = @"BadComparison";
NSString *NSBadRTFColorTableException; NSString *NSBadRTFColorTableException = @"BadRTFColorTable";
NSString *NSBadRTFDirectiveException; NSString *NSBadRTFDirectiveException = @"BadRTFDirective";
NSString *NSBadRTFFontTableException; NSString *NSBadRTFFontTableException = @"BadRTFFontTable";
NSString *NSBadRTFStyleSheetException; NSString *NSBadRTFStyleSheetException = @"BadRTFStyleSheet";
NSString *NSBrowserIllegalDelegateException; NSString *NSBrowserIllegalDelegateException = @"BrowserIllegalDelegate";
NSString *NSColorListIOException; NSString *NSColorListIOException = @"ColorListIO";
NSString *NSColorListNotEditableException; NSString *NSColorListNotEditableException = @"ColorListNotEditable";
NSString *NSDraggingException; NSString *NSDraggingException = @"Draggin";
NSString *NSFontUnavailableException; NSString *NSFontUnavailableException = @"FontUnavailable";
NSString *NSIllegalSelectorException; NSString *NSIllegalSelectorException = @"IllegalSelector";
NSString *NSImageCacheException; NSString *NSImageCacheException = @"ImageCache";
NSString *NSNibLoadingException; NSString *NSNibLoadingException = @"NibLoading";
NSString *NSPPDIncludeNotFoundException; NSString *NSPPDIncludeNotFoundException = @"PPDIncludeNotFound";
NSString *NSPPDIncludeStackOverflowException; NSString *NSPPDIncludeStackOverflowException = @"PPDIncludeStackOverflow";
NSString *NSPPDIncludeStackUnderflowException; NSString *NSPPDIncludeStackUnderflowException = @"PPDIncludeStackUnderflow";
NSString *NSPPDParseException; NSString *NSPPDParseException = @"PPDParse";
NSString *NSPasteboardCommunicationException; NSString *NSPasteboardCommunicationException = @"PasteboardCommunication";
NSString *NSPrintOperationExistsException; NSString *NSPrintOperationExistsException = @"PrintOperationExists";
NSString *NSPrintPackageException; NSString *NSPrintPackageException = @"PrintPackage";
NSString *NSPrintingCommunicationException; NSString *NSPrintingCommunicationException = @"PrintingCommunication";
NSString *NSRTFPropertyStackOverflowException; NSString *NSRTFPropertyStackOverflowException = @"RTFPropertyStackOverflow";
NSString *NSTIFFException; NSString *NSTIFFException = @"TIFF";
NSString *NSTextLineTooLongException; NSString *NSTextLineTooLongException = @"TextLineTooLong";
NSString *NSTextNoSelectionException; NSString *NSTextNoSelectionException = @"TextNoSelection";
NSString *NSTextReadException; NSString *NSTextReadException = @"TextRead";
NSString *NSTextWriteException; NSString *NSTextWriteException = @"TextWrite";
NSString *NSTypedStreamVersionException; NSString *NSTypedStreamVersionException = @"TypedStreamVersion";
NSString *NSWindowServerCommunicationException; NSString *NSWindowServerCommunicationException = @"WindowServerCommunication";
NSString *NSWordTablesReadException; NSString *NSWordTablesReadException = @"WordTablesRead";
NSString *NSWordTablesWriteException; NSString *NSWordTablesWriteException = @"WordTablesWrite";
// Application notifications // Application notifications
NSString *NSApplicationDidBecomeActiveNotification; NSString *NSApplicationDidBecomeActiveNotification
NSString *NSApplicationDidFinishLaunchingNotification; = @"ApplicationDidBecomeActive";
NSString *NSApplicationDidHideNotification; NSString *NSApplicationDidFinishLaunchingNotification
NSString *NSApplicationDidResignActiveNotification; = @"ApplicationDidFinishLaunching";
NSString *NSApplicationDidUnhideNotification; NSString *NSApplicationDidHideNotification = @"ApplicationDidHide";
NSString *NSApplicationDidUpdateNotification; NSString *NSApplicationDidResignActiveNotification
NSString *NSApplicationWillBecomeActiveNotification; = @"ApplicationDidResignActive";
NSString *NSApplicationWillFinishLaunchingNotification; NSString *NSApplicationDidUnhideNotification = @"ApplicationDidUnhide";
NSString *NSApplicationWillHideNotification; NSString *NSApplicationDidUpdateNotification = @"ApplicationDidUpdate";
NSString *NSApplicationWillResignActiveNotification; NSString *NSApplicationWillBecomeActiveNotification
NSString *NSApplicationWillUnhideNotification; = @"ApplicationWillBecomeActive";
NSString *NSApplicationWillUpdateNotification; NSString *NSApplicationWillFinishLaunchingNotification
= @"ApplicationWillFinishLaunching";
NSString *NSApplicationWillHideNotification = @"ApplicationWillHide";
NSString *NSApplicationWillResignActiveNotification
= @"ApplicationWillResignActive";
NSString *NSApplicationWillUnhideNotification = @"ApplicationWillUnhide";
NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
@implementation NSApplication @implementation NSApplication
@ -164,13 +170,17 @@ NSString *NSApplicationWillUpdateNotification;
- (void)finishLaunching - (void)finishLaunching
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// notify that we will finish the launching // notify that we will finish the launching
[self applicationWillFinishLaunching:self]; [nc postNotificationName: NSApplicationWillFinishLaunchingNotification
object: self];
// finish the launching // finish the launching
// notify that the launching has finished // notify that the launching has finished
[self applicationDidFinishLaunching:self]; [nc postNotificationName: NSApplicationDidFinishLaunchingNotification
object: self];
} }
- (void)dealloc - (void)dealloc
@ -352,6 +362,9 @@ NSString *NSApplicationWillUpdateNotification;
if (!theEvent) return NO; if (!theEvent) return NO;
// Don't check the null event
if (theEvent == NullEvent) return NO;
t = [theEvent type]; t = [theEvent type];
if ((t == NSLeftMouseDown) && (mask & NSLeftMouseDownMask)) if ((t == NSLeftMouseDown) && (mask & NSLeftMouseDownMask))
@ -451,7 +464,9 @@ NSString *NSApplicationWillUpdateNotification;
if ([self event: e matchMask: mask]) if ([self event: e matchMask: mask])
{ {
if (e) if (e)
e = [event_queue dequeueObject]; {
[event_queue removeObject: e];
}
done = YES; done = YES;
} }
} }

View file

@ -47,13 +47,16 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
+ (void)initialize + (void)initialize
{ {
if (self == [NSMatrix class]) if (self == [NSMatrix class])
{ {
NSDebugLog(@"Initialize NSMatrix class\n"); NSDebugLog(@"Initialize NSMatrix class\n");
// Set initial version // Set initial version
[self setVersion: 1]; [self setVersion: 1];
}
// Set the default cell class
NSMATRIX_DEFAULT_CELL_CLASS = [NSCell class];
}
} }
// //
@ -74,51 +77,51 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
// //
- (void)createInitialMatrix - (void)createInitialMatrix
{ {
NSSize cs; NSSize cs;
int i, j; int i, j;
id aRow, aFloat; id aRow, aFloat;
// Determine cell width and height for uniform cell size // Determine cell width and height for uniform cell size
cs.width = (frame.size.width - (inter_cell.width * (num_cols - 1))) cs.width = (frame.size.width - (inter_cell.width * (num_cols - 1)))
/ num_cols; / num_cols;
cs.height = (frame.size.height - (inter_cell.height * (num_rows - 1))) cs.height = (frame.size.height - (inter_cell.height * (num_rows - 1)))
/ num_rows; / num_rows;
// Save cell widths and heights in arrays // Save cell widths and heights in arrays
aFloat = [NSNumber numberWithFloat: cs.height]; aFloat = [NSNumber numberWithFloat: cs.height];
for (i = 0;i < num_rows; ++i) for (i = 0;i < num_rows; ++i)
[row_heights addObject:aFloat]; [row_heights addObject:aFloat];
aFloat = [NSNumber numberWithFloat: cs.width]; aFloat = [NSNumber numberWithFloat: cs.width];
for (i = 0;i < num_cols; ++i) for (i = 0;i < num_cols; ++i)
[col_widths addObject:aFloat]; [col_widths addObject:aFloat];
for (i = 0;i < num_rows; ++i) for (i = 0;i < num_rows; ++i)
{
aRow = [NSMutableArray arrayWithCapacity: num_cols];
[rows addObject: aRow];
for (j = 0;j < num_cols; ++j)
{ {
aRow = [NSMutableArray arrayWithCapacity: num_cols]; if (cell_prototype != nil)
[rows addObject: aRow]; {
for (j = 0;j < num_cols; ++j) [(NSMutableArray *)aRow addObject:
{ [cell_prototype copy]];
if (cell_prototype != nil) }
{ else
[(NSMutableArray *)aRow addObject: {
[cell_prototype copy]]; [(NSMutableArray *)aRow addObject:
} [[cell_class alloc] init]];
else }
{
[(NSMutableArray *)aRow addObject:
[[cell_class alloc] init]];
}
}
} }
}
} }
- (id)initWithFrame:(NSRect)frameRect - (id)initWithFrame:(NSRect)frameRect
{ {
return [self initWithFrame:frameRect return [self initWithFrame: frameRect
mode:NSTrackModeMatrix mode: NSTrackModeMatrix
cellClass:[NSCell class] cellClass: NSMATRIX_DEFAULT_CELL_CLASS
numberOfRows:0 numberOfRows: 0
numberOfColumns:0]; numberOfColumns: 0];
} }
- (id)initWithFrame:(NSRect)frameRect - (id)initWithFrame:(NSRect)frameRect
@ -127,48 +130,49 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
numberOfRows:(int)rowsHigh numberOfRows:(int)rowsHigh
numberOfColumns:(int)colsWide numberOfColumns:(int)colsWide
{ {
NSDebugLog(@"NSMatrix start -initWithFrame: ..cellClass:\n"); NSDebugLog(@"NSMatrix start -initWithFrame: ..cellClass:\n");
[super initWithFrame:frameRect]; [super initWithFrame:frameRect];
if (rowsHigh < 0) if (rowsHigh < 0)
{ {
NSLog(@"NSMatrix initWithFrame:mode: rows has to be >= 0.\n"); NSLog(@"NSMatrix initWithFrame:mode: rows has to be >= 0.\n");
NSLog(@"Will create matrix with 0 rows.\n"); NSLog(@"Will create matrix with 0 rows.\n");
num_rows = 0; num_rows = 0;
} }
else else
{ {
num_rows = rowsHigh; num_rows = rowsHigh;
}
if (colsWide < 0)
{
NSLog(@"NSMatrix initWithFrame:mode: columns has to be >= 0.\n");
NSLog(@"Will create matrix with 0 columns.\n");
num_cols = 0;
}
else
{
num_cols = colsWide;
} }
if (colsWide < 0) rows = [[NSMutableArray alloc] init];
{ row_heights = [[NSMutableArray alloc] init];
NSLog(@"NSMatrix initWithFrame:mode: columns has to be >= 0.\n"); col_widths = [[NSMutableArray alloc] init];
NSLog(@"Will create matrix with 0 columns.\n"); selected_cells = [[NSMutableArray alloc] init];
inter_cell.width = inter_cell.height = 2;
num_cols = 0; allows_empty_selection = YES;
}
else
{
num_cols = colsWide;
}
rows = [[NSMutableArray alloc] init];
row_heights = [[NSMutableArray alloc] init];
col_widths = [[NSMutableArray alloc] init];
selected_cells = [[NSMutableArray alloc] init];
inter_cell.width = inter_cell.height = 2;
cell_prototype = nil; cell_prototype = nil;
cell_class = classId; cell_class = classId;
mode = aMode; mode = aMode;
[self createInitialMatrix]; [self createInitialMatrix];
NSDebugLog(@"NSMatrix end -initWithFrame: ..cellClass:\n"); NSDebugLog(@"NSMatrix end -initWithFrame: ..cellClass:\n");
return self; return self;
} }
- (id)initWithFrame:(NSRect)frameRect - (id)initWithFrame:(NSRect)frameRect
@ -177,25 +181,25 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
numberOfRows:(int)rowsHigh numberOfRows:(int)rowsHigh
numberOfColumns:(int)colsWide numberOfColumns:(int)colsWide
{ {
[super initWithFrame:frameRect]; [super initWithFrame:frameRect];
if (aCell == nil) if (aCell == nil)
{ {
NSLog(@"NSMatrix "); NSLog(@"NSMatrix ");
NSLog(@"initWithFrame:mode:prototype:numberOfRows:numberOfColumns: "); NSLog(@"initWithFrame:mode:prototype:numberOfRows:numberOfColumns: ");
NSLog(@"prototype can't be nil. "); NSLog(@"prototype can't be nil. ");
NSLog(@"Using NSCell as the default class.\n"); NSLog(@"Using NSCell as the default class.\n");
cell_prototype = nil; cell_prototype = nil;
cell_class = [NSCell class]; cell_class = [NSCell class];
} }
else else
{ {
cell_prototype = [aCell retain]; cell_prototype = [aCell retain];
} }
return self; return self;
} }
// //
@ -208,7 +212,7 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)setMode:(NSMatrixMode)aMode - (void)setMode:(NSMatrixMode)aMode
{ {
mode = aMode; mode = aMode;
} }
// //
@ -226,12 +230,12 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)setAllowsEmptySelection:(BOOL)flag - (void)setAllowsEmptySelection:(BOOL)flag
{ {
allows_empty_selection = flag; allows_empty_selection = flag;
} }
- (void)setSelectionByRect:(BOOL)flag - (void)setSelectionByRect:(BOOL)flag
{ {
selection_by_rect = flag; selection_by_rect = flag;
} }
// //
@ -249,12 +253,12 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)setCellClass:(Class)classId - (void)setCellClass:(Class)classId
{ {
cell_class = classId; cell_class = classId;
} }
- (void)setPrototype:(NSCell *)aCell - (void)setPrototype:(NSCell *)aCell
{ {
cell_prototype = [aCell retain]; cell_prototype = [aCell retain];
} }
// //
@ -262,9 +266,9 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
// //
- (void)addColumn - (void)addColumn
{ {
int i; int i;
NSNumber *anInt; NSNumber *anInt;
NSMutableArray *aRow; NSMutableArray *aRow;
if (num_rows <= 0) if (num_rows <= 0)
{ {
@ -299,7 +303,61 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)addColumnWithCells:(NSArray *)cellArray - (void)addColumnWithCells:(NSArray *)cellArray
{ {
[self insertColumn:num_cols withCells:cellArray]; NSMutableArray *a;
id e, o;
id re, aRow;
int nrows, new_rows;
NSNumber *aFloat;
NSSize cs;
int i;
NSDebugLog(@"NSMatrix addColumnWithCells:\n");
// No array then forget the add
if (!cellArray)
return;
// Add more rows if need be
nrows = [cellArray count];
if (nrows > num_rows)
{
NSDebugLog(@"NSMatrix add more rows %d %d\n", nrows, num_rows);
new_rows = nrows - num_rows;
for (i = 0; i < new_rows; ++i)
{
a = [[NSMutableArray alloc] init];
[rows addObject: a];
++num_rows;
}
}
++num_cols;
NSDebugLog(@"NSMatrix rows %d cols %d\n", num_rows, num_cols);
// Determine cell width and height for uniform cell size
cs.width = (frame.size.width - (inter_cell.width * (num_cols - 1)))
/ num_cols;
cs.height = (frame.size.height - (inter_cell.height * (num_rows - 1)))
/ num_rows;
// Save cell widths and heights in arrays
aFloat = [NSNumber numberWithFloat: cs.height];
for (i = 0;i < nrows; ++i)
[row_heights addObject:aFloat];
aFloat = [NSNumber numberWithFloat: cs.width];
[col_widths addObject:aFloat];
NSDebugLog(@"NSMatrix cell size %f %f\n", cs.width, cs.height);
e = [cellArray objectEnumerator];
o = [e nextObject];
re = [rows objectEnumerator];
aRow = [re nextObject];
while (o)
{
[aRow addObject: o];
[o retain];
o = [e nextObject];
aRow = [re nextObject];
}
} }
- (void)addRow - (void)addRow
@ -346,7 +404,90 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)addRowWithCells:(NSArray *)cellArray - (void)addRowWithCells:(NSArray *)cellArray
{ {
[self insertRow:num_rows withCells:cellArray]; NSMutableArray *a;
id e, o;
float ncols;
NSNumber *aFloat;
NSSize cs;
int i;
NSDebugLog(@"NSMatrix addRowWithCells:\n");
// No array then forget the add
if (!cellArray)
return;
a = [[NSMutableArray alloc] init];
[rows addObject: a];
++num_rows;
ncols = [cellArray count];
// Determine cell width and height for uniform cell size
cs.width = (frame.size.width - (inter_cell.width * (ncols - 1)))
/ ncols;
cs.height = (frame.size.height - (inter_cell.height * (num_rows - 1)))
/ num_rows;
// Save cell widths and heights in arrays
aFloat = [NSNumber numberWithFloat: cs.height];
[row_heights addObject:aFloat];
aFloat = [NSNumber numberWithFloat: cs.width];
for (i = 0;i < ncols; ++i)
[col_widths addObject:aFloat];
e = [cellArray objectEnumerator];
o = [e nextObject];
while (o)
{
[a addObject: o];
[o retain];
o = [e nextObject];
}
}
- (void)addRowWithCells:(NSArray *)cellArray
rowSizes:(NSArray *)rowSizes
columnSizes:(NSArray *)columnSizes
{
NSMutableArray *a;
id e, o;
float ncols;
NSNumber *aFloat;
NSSize cs;
int i;
NSDebugLog(@"NSMatrix addRowWithCells:\n");
// No array then forget the insert
if (!cellArray)
return;
a = [[NSMutableArray alloc] init];
[rows addObject: a];
++num_rows;
ncols = [cellArray count];
// Determine cell width and height for uniform cell size
cs.width = (frame.size.width - (inter_cell.width * (ncols - 1)))
/ ncols;
cs.height = (frame.size.height - (inter_cell.height * (num_rows - 1)))
/ num_rows;
// Save cell widths and heights in arrays
aFloat = [NSNumber numberWithFloat: cs.height];
[row_heights addObject:aFloat];
aFloat = [NSNumber numberWithFloat: cs.width];
for (i = 0;i < ncols; ++i)
[col_widths addObject:aFloat];
e = [cellArray objectEnumerator];
o = [e nextObject];
while (o)
{
[a addObject: o];
[o retain];
o = [e nextObject];
}
} }
- (NSRect)cellFrameAtRow:(int)row - (NSRect)cellFrameAtRow:(int)row
@ -361,6 +502,7 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
r.size.width = 0; r.size.width = 0;
r.size.height = 0; r.size.height = 0;
#if 0
/* Validate arguments */ /* Validate arguments */
if ((row >= num_rows) || (row < 0)) if ((row >= num_rows) || (row < 0))
{ {
@ -371,6 +513,7 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
{ {
return r; return r;
} }
#endif
/* Compute the x origin */ /* Compute the x origin */
for (i=0; i<column; i++) for (i=0; i<column; i++)
@ -383,14 +526,16 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
r.size.width = [(NSNumber *)[col_widths objectAtIndex:i] floatValue]; r.size.width = [(NSNumber *)[col_widths objectAtIndex:i] floatValue];
/* Compute the y origin */ /* Compute the y origin */
for (i=0; i<row; i++) r.origin.y = frame.size.height;
r.origin.y -= [(NSNumber *)[row_heights objectAtIndex:0] floatValue];
for (i = 1;i < (row+1); i++)
{ {
r.origin.y += [(NSNumber *)[row_heights objectAtIndex:i] floatValue]; r.origin.y -= inter_cell.height;
r.origin.y += inter_cell.height; r.origin.y -= [(NSNumber *)[row_heights objectAtIndex:i] floatValue];
} }
/* Get the height */ /* Get the height */
r.size.height = [(NSNumber *)[row_heights objectAtIndex:i] floatValue]; r.size.height = [(NSNumber *)[row_heights objectAtIndex:row] floatValue];
NSDebugLog(@"NSMatrix cellFrameAtRow: %d column:%d is: %f %f %f %f\n", NSDebugLog(@"NSMatrix cellFrameAtRow: %d column:%d is: %f %f %f %f\n",
row, column, row, column,
@ -513,32 +658,24 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)insertRow:(int)row withCells:(NSArray *)cellArray - (void)insertRow:(int)row withCells:(NSArray *)cellArray
{ {
NSCell *newCell; NSCell *newCell;
int i, count; int i, count;
id e, o;
[self insertRow:row]; // No array then forget the insert
if (!cellArray)
return;
if (cellArray != nil) [self insertRow:row];
e = [cellArray objectEnumerator];
o = [e nextObject];
i = 0;
while (o)
{ {
count = [cellArray count]; [self putCell: o atRow: row column: i];
} o = [e nextObject];
else ++i;
{
count = 0;
}
for (i=0; i<num_cols; i++)
{
if (i < count)
{
newCell = (NSCell *)[cellArray objectAtIndex:i];
[self putCell:newCell atRow:row column:i];
}
else
{
break;
}
} }
} }
@ -697,66 +834,82 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
column:(int *)column column:(int *)column
forPoint:(NSPoint)aPoint forPoint:(NSPoint)aPoint
{ {
NSRect myFrame = [self bounds]; NSRect myFrame = [self bounds];
NSRect cFrame; NSRect cFrame;
int i, j; id re, ce;
id aRow, aCol;
int i, j;
/* Trivial rejection if the point is not in the Matrix's frame rect */ /* Trivial rejection if the point is not in the Matrix's frame rect */
if ((aPoint.x < myFrame.origin.x) if (![self mouse: aPoint inRect: myFrame])
|| (aPoint.x > (myFrame.origin.x + myFrame.size.width))
|| (aPoint.y < myFrame.origin.y)
|| (aPoint.y > (myFrame.origin.y + myFrame.size.height)))
{ {
NSDebugLog(@"NSMatrix point %f %f not in rect %f %f %f %f\n", NSDebugLog(@"NSMatrix point %f %f not in rect %f %f %f %f\n",
aPoint.x, aPoint.y, myFrame.origin.x, myFrame.origin.y, aPoint.x, aPoint.y, myFrame.origin.x, myFrame.origin.y,
myFrame.size.width, myFrame.size.height); myFrame.size.width, myFrame.size.height);
return NO; return NO;
} }
else
{
/* Here an optimized algo could be used at the expense of clarity */
for (i=0; i<num_rows; i++) /* Here an optimized algo could be used at the expense of clarity */
re = [rows objectEnumerator];
aRow = [re nextObject];
i = 0;
while (aRow)
{
ce = [aRow objectEnumerator];
aCol = [ce nextObject];
j = 0;
while (aCol)
{ {
for (j=0; j<num_cols; j++) cFrame = [self cellFrameAtRow:i column:j];
{
cFrame = [self cellFrameAtRow:i column:j];
if ((aPoint.x >= cFrame.origin.x) if ([self mouse: aPoint inRect: cFrame])
&& (aPoint.x <= (cFrame.origin.x + cFrame.size.width)) {
&& (aPoint.y >= cFrame.origin.y) *row = i;
&& (aPoint.y <= (cFrame.origin.y + cFrame.size.height))) *column = j;
{ return YES;
*row = i;
*column = j;
return YES;
}
} }
aCol = [ce nextObject];
++j;
} }
return NO; aRow = [re nextObject];
++i;
} }
return NO;
} }
- (BOOL)getRow:(int *)row - (BOOL)getRow:(int *)row
column:(int *)column column:(int *)column
ofCell:(NSCell *)aCell ofCell:(NSCell *)aCell
{ {
int i, j; id re, ce;
id aRow, aCol;
int i, j;
for (i=0; i<num_rows; i++) re = [rows objectEnumerator];
aRow = [re nextObject];
i = 0;
while (aRow)
{ {
for (j=0; j<num_cols; j++) ce = [aRow objectEnumerator];
aCol = [ce nextObject];
j = 0;
while (aCol)
{ {
if ((NSCell *)[self cellAtRow:i column:j] == aCell) if ((NSCell *)[self cellAtRow:i column:j] == aCell)
{ {
*row = i; *row = i;
*column = j; *column = j;
return YES; return YES;
} }
aCol = [ce nextObject];
++j;
} }
aRow = [re nextObject];
++i;
} }
return NO; return NO;
} }
// //
@ -785,12 +938,19 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
// //
- (void)deselectAllCells - (void)deselectAllCells
{ {
if (allows_empty_selection)
[selected_cells removeAllObjects]; [selected_cells removeAllObjects];
} }
- (void)deselectSelectedCell - (void)deselectSelectedCell
{ {
[selected_cells removeLastObject]; int cnt = [selected_cells count];
// Is anything even selected?
if (cnt > 0)
// Only empty array if empty selection is allowed
if ((cnt != 1) || (allows_empty_selection))
[selected_cells removeLastObject];
} }
- (void)selectAll:(id)sender - (void)selectAll:(id)sender
@ -802,17 +962,17 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (void)selectCellAtRow:(int)row - (void)selectCellAtRow:(int)row
column:(int)column column:(int)column
{ {
int index; int index;
id aCell = [self cellAtRow:row column:column]; id aCell = [self cellAtRow:row column:column];
NSDebugLog(@"NSMatrix select cell at %d %d\n", row, column); NSDebugLog(@"NSMatrix select cell at %d %d\n", row, column);
if (aCell != nil) if (aCell != nil)
{ {
index = [selected_cells indexOfObject:aCell]; // Add to selected cell list if not already
index = [selected_cells indexOfObject:aCell];
if ((index < 0) || (index > [selected_cells count])) if ((index < 0) || (index > [selected_cells count]))
{ {
[selected_cells addObject:aCell]; [selected_cells addObject:aCell];
} }
} }
} }
@ -838,7 +998,7 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (id)selectedCell - (id)selectedCell
{ {
return [selected_cells lastObject]; return [selected_cells lastObject];
} }
/* /*
@ -851,66 +1011,42 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (int)selectedColumn - (int)selectedColumn
{ {
int row, col; int row, col;
NSMutableArray *aRow, *aCol; id aCell;
id aCell;
if ([selected_cells count]) {
aCell = [selected_cells lastObject]; if ([selected_cells count])
{
for (row=0; row<num_rows; row++) aCell = [selected_cells lastObject];
{
aRow = [rows objectAtIndex:row];
for (col=0; col<num_cols; col++) if ([self getRow: &row column: &col ofCell: aCell])
{ return col;
aCol = [aRow objectAtIndex:col];
if ([aCol indexOfObject:aCell] < num_cols)
{
return col;
}
}
}
} }
return -1; /* not found */ // Not found
return -1;
} }
- (int)selectedRow - (int)selectedRow
{ {
int row, col; int row, col;
NSMutableArray *aRow, *aCol; id aCell;
id aCell;
if ([selected_cells count] > 0)
{
aCell = [selected_cells lastObject];
for (row=0; row<num_rows; row++)
{
aRow = [rows objectAtIndex:row];
for (col=0; col<num_cols; col++) if ([selected_cells count])
{ {
aCol = [aRow objectAtIndex:col]; aCell = [selected_cells lastObject];
if ([aCol indexOfObject:aCell] < num_cols) if ([self getRow: &row column: &col ofCell: aCell])
{ return row;
return row;
}
}
}
} }
return -1; /* not found */ // Not found
return -1;
} }
- (void)setSelectionFrom:(int)startPos - (void)setSelectionFrom:(int)startPos
to:(int)endPos to:(int)endPos
anchor:(int)anchorPos anchor:(int)anchorPos
highlight:(BOOL)flag highlight:(BOOL)flag
{} {}
// //
@ -919,42 +1055,46 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
- (id)cellAtRow:(int)row - (id)cellAtRow:(int)row
column:(int)column column:(int)column
{ {
if ((row >= num_rows) || (row < 0)) id aRow;
if ((row >= num_rows) || (row < 0))
{ {
NSLog(@"NSMatrix cellAt:: invalid row (%d)\n", row); NSLog(@"NSMatrix cellAt:: invalid row (%d)\n", row);
return nil; return nil;
}
aRow = [rows objectAtIndex: row];
if ((column >= [aRow count]) || (column < 0))
{
NSLog(@"NSMatrix cellAt:: invalid column (%d)\n", column);
return nil;
} }
if ((column >= num_cols) || (column < 0)) return [(NSArray *)aRow objectAtIndex:column];
{
NSLog(@"NSMatrix cellAt:: invalid column (%d)\n", column);
return nil;
}
return [(NSArray *)[rows objectAtIndex:row] objectAtIndex:column];
} }
- (id)cellWithTag:(int)anInt - (id)cellWithTag:(int)anInt
{ {
int i, j; id re, ce;
NSMutableArray *aRow; int i, j;
NSCell *aCell; NSMutableArray *aRow;
NSCell *aCell;
for (i=0; i<num_rows; i++)
{
aRow = (NSMutableArray *)[rows objectAtIndex:i];
for (j=0; j<num_cols; j++) // Loop through the rows and columns and find the cell
re = [rows objectEnumerator];
aRow = [re nextObject];
while (aRow)
{
ce = [aRow objectEnumerator];
aCell = (NSCell *)[ce nextObject];
while (aCell)
{ {
aCell = [aRow objectAtIndex:j]; if ([aCell tag] == anInt)
return aCell;
if ([aCell tag] == anInt) aCell = (NSCell *)[ce nextObject];
{
return (id)aCell;
}
} }
} }
return nil; return nil;
} }
- (NSArray *)cells - (NSArray *)cells
@ -1171,54 +1311,60 @@ Class NSMATRIX_DEFAULT_CELL_CLASS;
// //
- (void)display; - (void)display;
{ {
int row,col; id re, ce;
int rcnt, ccnt; int row, col;
NSMutableArray *aRow; NSMutableArray *aRow;
id aCol;
NSDebugLog(@"NSMatrix display\n"); NSDebugLog(@"NSMatrix display %f %f %f %f\n", bounds.origin.x,
bounds.origin.y, bounds.size.width, bounds.size.height);
rcnt = [rows count];
if (rcnt != num_rows)
NSLog(@"NSMatrix internal error: num_rows != actual rows\n");
for (row=0; row<rcnt; row++) re = [rows objectEnumerator];
aRow = (NSMutableArray *)[re nextObject];
row = 0;
while (aRow)
{ {
aRow = [rows objectAtIndex:row]; ce = [aRow objectEnumerator];
ccnt = [aRow count]; aCol = [ce nextObject];
if (ccnt != num_cols) col = 0;
NSLog(@"NSMatrix internal error: num_cols != actual columns\n"); while (aCol)
for (col=0; col<ccnt; col++)
{ {
[self drawCellAtRow: row column: col]; [self drawCellAtRow: row column: col];
++col;
aCol = [ce nextObject];
} }
++row;
aRow = [re nextObject];
} }
NSDebugLog(@"End NSMatrix display\n"); NSDebugLog(@"End NSMatrix display\n");
} }
- (void)drawCellAtRow:(int)row - (void)drawCellAtRow:(int)row
column:(int)column column:(int)column
{ {
NSMutableArray *aRow = [rows objectAtIndex: row]; NSMutableArray *aRow = [rows objectAtIndex: row];
NSCell *aCell = [aRow objectAtIndex: column];
[[aRow objectAtIndex:column] drawWithFrame: NSDebugLog(@"NSMatrix draw cell %d %d %d %d\n", row, column, [rows count],
[self cellFrameAtRow:row column:column] [aRow count]);
inView:self]; [aCell drawWithFrame:
[self cellFrameAtRow:row column:column]
inView:self];
} }
- (void)highlightCell:(BOOL)flag - (void)highlightCell:(BOOL)flag
atRow:(int)row atRow:(int)row
column:(int)column column:(int)column
{ {
NSCell *aCell = [self cellAtRow:row column:column]; NSCell *aCell = [self cellAtRow:row column:column];
NSRect cellFrame; NSRect cellFrame;
BOOL did_lock = NO;
if (aCell != nil) if (aCell != nil)
{ {
cellFrame = [self cellFrameAtRow:row column:column]; cellFrame = [self cellFrameAtRow:row column:column];
[aCell highlight:flag withFrame:cellFrame inView:self]; [aCell highlight:flag withFrame:cellFrame inView:self];
} }
} }
// //

View file

@ -32,6 +32,7 @@
#include <gnustep/gui/NSMenuPrivate.h> #include <gnustep/gui/NSMenuPrivate.h>
#include <Foundation/NSLock.h> #include <Foundation/NSLock.h>
#include <gnustep/base/NSCoder.h> #include <gnustep/base/NSCoder.h>
#include <gnustep/gui/NSApplication.h>
NSZone *gnustep_gui_nsmenu_zone = NULL; NSZone *gnustep_gui_nsmenu_zone = NULL;
@ -76,6 +77,8 @@ NSZone *gnustep_gui_nsmenu_zone = NULL;
// Default initializer // Default initializer
- (id)initWithTitle:(NSString *)aTitle - (id)initWithTitle:(NSString *)aTitle
{ {
NSApplication *theApp = [NSApplication sharedApplication];
// Init our superclass but skip any of its backend implementation // Init our superclass but skip any of its backend implementation
[super cleanInit]; [super cleanInit];
@ -83,9 +86,16 @@ NSZone *gnustep_gui_nsmenu_zone = NULL;
menu_items = [NSMutableArray array]; menu_items = [NSMutableArray array];
super_menu = nil; super_menu = nil;
autoenables_items = NO; autoenables_items = NO;
menu_matrix = nil; // [self setContentView:[[NSView alloc] initWithFrame:frame]];
menu_matrix = [[NSMatrix alloc] initWithFrame: NSZeroRect];
[menu_matrix setCellClass: [NSMenuCell class]];
[menu_matrix setIntercellSpacing: NSZeroSize];
[self setContentView: menu_matrix];
is_torn_off = NO; is_torn_off = NO;
// Register ourselves with the Application object
[theApp addWindowsItem:self title:window_title filename:NO];
return self; return self;
} }

View file

@ -39,20 +39,20 @@
#include <gnustep/base/NSCoder.h> #include <gnustep/base/NSCoder.h>
// NSWindow notifications // NSWindow notifications
NSString *NSWindowDidBecomeKeyNotification; NSString *NSWindowDidBecomeKeyNotification = @"WindowDidBecomeKey";
NSString *NSWindowDidBecomeMainNotification; NSString *NSWindowDidBecomeMainNotification = @"WindowDidBecomeMain";
NSString *NSWindowDidChangeScreenNotification; NSString *NSWindowDidChangeScreenNotification = @"WindowDidChangeScreen";
NSString *NSWindowDidDeminiaturizeNotification; NSString *NSWindowDidDeminiaturizeNotification = @"WindowDidDeminiaturize";
NSString *NSWindowDidExposeNotification; NSString *NSWindowDidExposeNotification = @"WindowDidExpose";
NSString *NSWindowDidMiniaturizeNotification; NSString *NSWindowDidMiniaturizeNotification = @"WindowDidMiniaturize";
NSString *NSWindowDidMoveNotification; NSString *NSWindowDidMoveNotification = @"WindowDidMove";
NSString *NSWindowDidResignKeyNotification; NSString *NSWindowDidResignKeyNotification = @"WindowDidResignKey";
NSString *NSWindowDidResignMainNotification; NSString *NSWindowDidResignMainNotification = @"WindowDidResignMain";
NSString *NSWindowDidResizeNotification; NSString *NSWindowDidResizeNotification = @"WindowDidResize";
NSString *NSWindowDidUpdateNotification; NSString *NSWindowDidUpdateNotification = @"WindowDidUpdate";
NSString *NSWindowWillCloseNotification; NSString *NSWindowWillCloseNotification = @"WindowWillClose";
NSString *NSWindowWillMiniaturizeNotification; NSString *NSWindowWillMiniaturizeNotification = @"WindowWillMiniaturize";
NSString *NSWindowWillMoveNotification; NSString *NSWindowWillMoveNotification = @"WindowWillMove";
// //
// NSWindow implementation // NSWindow implementation
@ -82,15 +82,13 @@ NSString *NSWindowWillMoveNotification;
+ (NSRect)contentRectForFrameRect:(NSRect)aRect + (NSRect)contentRectForFrameRect:(NSRect)aRect
styleMask:(unsigned int)aStyle styleMask:(unsigned int)aStyle
{ {
NSRect t; return aRect;
return t;
} }
+ (NSRect)frameRectForContentRect:(NSRect)aRect + (NSRect)frameRectForContentRect:(NSRect)aRect
styleMask:(unsigned int)aStyle styleMask:(unsigned int)aStyle
{ {
NSRect t; return aRect;
return t;
} }
+ (NSRect)minFrameWidthWithTitle:(NSString *)aTitle + (NSRect)minFrameWidthWithTitle:(NSString *)aTitle
@ -103,7 +101,7 @@ NSString *NSWindowWillMoveNotification;
// Screens and window depths // Screens and window depths
+ (NSWindowDepth)defaultDepthLimit + (NSWindowDepth)defaultDepthLimit
{ {
return 0; return 8;
} }
// //
@ -159,39 +157,30 @@ NSString *NSWindowWillMoveNotification;
screen:aScreen screen:aScreen
{ {
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
NSRect r = [[NSScreen mainScreen] frame];
NSDebugLog(@"NSWindow default initializer\n"); NSDebugLog(@"NSWindow default initializer\n");
if (!theApp) if (!theApp)
NSLog(@"No application!\n"); NSLog(@"No application!\n");
[super init];
NSDebugLog(@"NSWindow start of init\n"); NSDebugLog(@"NSWindow start of init\n");
frame = contentRect; // Initialize attributes and flags
[self cleanInit];
backing_type = bufferingType;
style_mask = aStyle; style_mask = aStyle;
// Size attributes
frame = [NSWindow frameRectForContentRect: contentRect styleMask: aStyle];
minimum_size = NSZeroSize;
maximum_size = r.size;
// Next responder is the application // Next responder is the application
[self setNextResponder:theApp]; [self setNextResponder:theApp];
// Initialize attributes and flags // Create our content view
frame_view = nil;
[self setContentView:[[NSView alloc] initWithFrame:frame]]; [self setContentView:[[NSView alloc] initWithFrame:frame]];
first_responder = nil;
delegate = nil;
window_num = 0;
background_color = [NSColor lightGrayColor];
represented_filename = @"Window";
miniaturized_title = @"Window";
window_title = @"Window";
visible = NO;
is_key = NO;
is_main = NO;
is_edited = NO;
is_miniaturized = NO;
menu_exclude = NO;
backing_type = bufferingType;
disable_flush_window = NO;
// Register ourselves with the Application object // Register ourselves with the Application object
[theApp addWindowsItem:self title:window_title filename:NO]; [theApp addWindowsItem:self title:window_title filename:NO];
@ -294,7 +283,7 @@ NSString *NSWindowWillMoveNotification;
- (BOOL)isOneShot - (BOOL)isOneShot
{ {
return NO; return is_one_shot;
} }
- (void)setBackingType:(NSBackingStoreType)type - (void)setBackingType:(NSBackingStoreType)type
@ -303,7 +292,9 @@ NSString *NSWindowWillMoveNotification;
} }
- (void)setOneShot:(BOOL)flag - (void)setOneShot:(BOOL)flag
{} {
is_one_shot = flag;
}
- (int)windowNumber - (int)windowNumber
{ {
@ -320,7 +311,7 @@ NSString *NSWindowWillMoveNotification;
// //
- (NSImage *)miniwindowImage - (NSImage *)miniwindowImage
{ {
return nil; return miniaturized_image;
} }
- (NSString *)miniwindowTitle - (NSString *)miniwindowTitle
@ -329,7 +320,9 @@ NSString *NSWindowWillMoveNotification;
} }
- (void)setMiniwindowImage:(NSImage *)image - (void)setMiniwindowImage:(NSImage *)image
{} {
miniaturized_image = image;
}
- (void)setMiniwindowTitle:(NSString *)title; - (void)setMiniwindowTitle:(NSString *)title;
{ {
@ -353,20 +346,24 @@ NSString *NSWindowWillMoveNotification;
// //
- (void)becomeKeyWindow - (void)becomeKeyWindow
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// We are the key window // We are the key window
is_key = YES; is_key = YES;
// Post notification // Post notification
[self windowDidBecomeKey:self]; [nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
} }
- (void)becomeMainWindow - (void)becomeMainWindow
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// We are the main window // We are the main window
is_main = YES; is_main = YES;
// Post notification // Post notification
[self windowDidBecomeMain:self]; [nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
} }
- (BOOL)canBecomeKeyWindow - (BOOL)canBecomeKeyWindow
@ -381,7 +378,7 @@ NSString *NSWindowWillMoveNotification;
- (BOOL)hidesOnDeactivate - (BOOL)hidesOnDeactivate
{ {
return NO; return hides_on_deactivate;
} }
- (BOOL)isKeyWindow - (BOOL)isKeyWindow
@ -406,7 +403,7 @@ NSString *NSWindowWillMoveNotification;
- (int)level - (int)level
{ {
return 0; return window_level;
} }
- (void)makeKeyAndOrderFront:sender - (void)makeKeyAndOrderFront:sender
@ -472,25 +469,33 @@ NSString *NSWindowWillMoveNotification;
- (void)resignKeyWindow - (void)resignKeyWindow
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
is_key = NO; is_key = NO;
// Post notification // Post notification
[self windowDidResignKey: self]; [nc postNotificationName: NSWindowDidResignKeyNotification object: self];
} }
- (void)resignMainWindow - (void)resignMainWindow
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
is_main = NO; is_main = NO;
// Post notification // Post notification
[self windowDidResignMain: self]; [nc postNotificationName: NSWindowDidResignMainNotification object: self];
} }
- (void)setHidesOnDeactivate:(BOOL)flag - (void)setHidesOnDeactivate:(BOOL)flag
{} {
hides_on_deactivate = flag;
}
- (void)setLevel:(int)newLevel - (void)setLevel:(int)newLevel
{} {
window_level = newLevel;
}
// //
// Moving and resizing the window // Moving and resizing the window
@ -527,12 +532,12 @@ NSString *NSWindowWillMoveNotification;
- (NSSize)minSize - (NSSize)minSize
{ {
return NSZeroSize; return minimum_size;
} }
- (NSSize)maxSize - (NSSize)maxSize
{ {
return NSZeroSize; return maximum_size;
} }
- (void)setContentSize:(NSSize)aSize - (void)setContentSize:(NSSize)aSize
@ -542,23 +547,35 @@ NSString *NSWindowWillMoveNotification;
- (void)setFrame:(NSRect)frameRect - (void)setFrame:(NSRect)frameRect
display:(BOOL)flag display:(BOOL)flag
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
frame = frameRect; frame = frameRect;
// post notification
[nc postNotificationName: NSWindowDidResizeNotification object: self];
// display if requested
if (!flag) return; if (!flag) return;
[self display]; [self display];
} }
- (void)setFrameOrigin:(NSPoint)aPoint - (void)setFrameOrigin:(NSPoint)aPoint
{} {
frame.origin = aPoint;
}
- (void)setFrameTopLeftPoint:(NSPoint)aPoint - (void)setFrameTopLeftPoint:(NSPoint)aPoint
{} {}
- (void)setMinSize:(NSSize)aSize - (void)setMinSize:(NSSize)aSize
{} {
minimum_size = aSize;
}
- (void)setMaxSize:(NSSize)aSize - (void)setMaxSize:(NSSize)aSize
{} {
maximum_size = aSize;
}
// //
// Converting coordinates // Converting coordinates
@ -592,7 +609,10 @@ NSString *NSWindowWillMoveNotification;
} }
- (void)displayIfNeeded - (void)displayIfNeeded
{} {
if (needs_display)
[self display];
}
- (void)enableFlushWindow - (void)enableFlushWindow
{ {
@ -603,39 +623,56 @@ NSString *NSWindowWillMoveNotification;
{} {}
- (void)flushWindowIfNeeded - (void)flushWindowIfNeeded
{} {
if (!disable_flush_window)
[self flushWindow];
}
- (BOOL)isAutodisplay - (BOOL)isAutodisplay
{ {
return YES; return is_autodisplay;
} }
- (BOOL)isFlushWindowDisabled - (BOOL)isFlushWindowDisabled
{ {
return NO; return disable_flush_window;
} }
- (void)setAutoDisplay:(BOOL)flag - (void)setAutoDisplay:(BOOL)flag
{} {
is_autodisplay = flag;
}
- (void)setViewsNeedDisplay:(BOOL)flag - (void)setViewsNeedDisplay:(BOOL)flag
{} {
views_need_display = flag;
}
- (void)update - (void)update
{} {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
}
- (void)useOptimizedDrawing:(BOOL)flag - (void)useOptimizedDrawing:(BOOL)flag
{} {
optimize_drawing = flag;
}
- (BOOL)viewsNeedDisplay - (BOOL)viewsNeedDisplay
{ {
return NO; return views_need_display;
} }
// Screens and window depths // Screens and window depths
- (BOOL)canStoreColor - (BOOL)canStoreColor
{ {
return YES; // If the depth is greater than a single bit
if (depth_limit > 1)
return YES;
else
return NO;
} }
- (NSScreen *)deepestScreen - (NSScreen *)deepestScreen
@ -645,12 +682,12 @@ NSString *NSWindowWillMoveNotification;
- (NSWindowDepth)depthLimit - (NSWindowDepth)depthLimit
{ {
return 0; return depth_limit;
} }
- (BOOL)hasDynamicDepthLimit - (BOOL)hasDynamicDepthLimit
{ {
return YES; return dynamic_depth_limit;
} }
- (NSScreen *)screen - (NSScreen *)screen
@ -659,27 +696,35 @@ NSString *NSWindowWillMoveNotification;
} }
- (void)setDepthLimit:(NSWindowDepth)limit - (void)setDepthLimit:(NSWindowDepth)limit
{} {
depth_limit = limit;
}
- (void)setDynamicDepthLimit:(BOOL)flag - (void)setDynamicDepthLimit:(BOOL)flag
{} {
dynamic_depth_limit = flag;
}
// //
// Cursor management // Cursor management
// //
- (BOOL)areCursorRectsEnabled - (BOOL)areCursorRectsEnabled
{ {
return NO; return cursor_rects_enabled;
} }
- (void)disableCursorRects - (void)disableCursorRects
{} {
cursor_rects_enabled = NO;
}
- (void)discardCursorRects - (void)discardCursorRects
{} {}
- (void)enableCursorRects - (void)enableCursorRects
{} {
cursor_rects_enabled = YES;
}
- (void)invalidateCursorRectsForView:(NSView *)aView - (void)invalidateCursorRectsForView:(NSView *)aView
{} {}
@ -692,20 +737,24 @@ NSString *NSWindowWillMoveNotification;
// //
- (void)close - (void)close
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Notify our delegate // Notify our delegate
[self windowWillClose:self]; [nc postNotificationName: NSWindowWillCloseNotification object: self];
[self performClose:self]; [self performClose:self];
} }
- (void)deminiaturize:sender - (void)deminiaturize:sender
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Set our flag to say we are not miniaturized // Set our flag to say we are not miniaturized
is_miniaturized = NO; is_miniaturized = NO;
visible = YES; visible = YES;
// Notify our delegate // Notify our delegate
[self windowDidDeminiaturize:self]; [nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
} }
- (BOOL)isDocumentEdited - (BOOL)isDocumentEdited
@ -715,18 +764,20 @@ NSString *NSWindowWillMoveNotification;
- (BOOL)isReleasedWhenClosed - (BOOL)isReleasedWhenClosed
{ {
return YES; return is_released_when_closed;
} }
- (void)miniaturize:sender - (void)miniaturize:sender
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Notify our delegate // Notify our delegate
[self windowWillMiniaturize:self]; [nc postNotificationName: NSWindowWillMiniaturizeNotification object: self];
[self performMiniaturize:self]; [self performMiniaturize:self];
// Notify our delegate // Notify our delegate
[self windowDidMiniaturize:self]; [nc postNotificationName: NSWindowDidMiniaturizeNotification object: self];
} }
- (void)performClose:sender - (void)performClose:sender
@ -746,17 +797,21 @@ NSString *NSWindowWillMoveNotification;
} }
- (void)setDocumentEdited:(BOOL)flag - (void)setDocumentEdited:(BOOL)flag
{} {
is_edited = flag;
}
- (void)setReleasedWhenClosed:(BOOL)flag - (void)setReleasedWhenClosed:(BOOL)flag
{} {
is_released_when_closed = flag;
}
// //
// Aiding event handling // Aiding event handling
// //
- (BOOL)acceptsMouseMovedEvents - (BOOL)acceptsMouseMovedEvents
{ {
return YES; return accepts_mouse_moved;
} }
- (NSEvent *)currentEvent - (NSEvent *)currentEvent
@ -768,7 +823,11 @@ NSString *NSWindowWillMoveNotification;
- (void)discardEventsMatchingMask:(unsigned int)mask - (void)discardEventsMatchingMask:(unsigned int)mask
beforeEvent:(NSEvent *)lastEvent beforeEvent:(NSEvent *)lastEvent
{} {
NSApplication *theApp = [NSApplication sharedApplication];
[theApp discardEventsMatchingMask: mask beforeEvent: lastEvent];
}
- (NSResponder *)firstResponder - (NSResponder *)firstResponder
{ {
@ -821,7 +880,9 @@ NSString *NSWindowWillMoveNotification;
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask - (NSEvent *)nextEventMatchingMask:(unsigned int)mask
{ {
return nil; NSApplication *theApp = [NSApplication sharedApplication];
return [theApp nextEventMatchingMask: mask untilDate: nil
inMode: @"" dequeue: YES];
} }
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask - (NSEvent *)nextEventMatchingMask:(unsigned int)mask
@ -829,7 +890,9 @@ NSString *NSWindowWillMoveNotification;
inMode:(NSString *)mode inMode:(NSString *)mode
dequeue:(BOOL)deqFlag dequeue:(BOOL)deqFlag
{ {
return nil; NSApplication *theApp = [NSApplication sharedApplication];
return [theApp nextEventMatchingMask: mask untilDate: expiration
inMode: mode dequeue: deqFlag];
} }
- (void)postEvent:(NSEvent *)event - (void)postEvent:(NSEvent *)event
@ -841,7 +904,9 @@ NSString *NSWindowWillMoveNotification;
} }
- (void)setAcceptsMouseMovedEvents:(BOOL)flag - (void)setAcceptsMouseMovedEvents:(BOOL)flag
{} {
accepts_mouse_moved = flag;
}
- (void)checkTrackingRectangles:(NSView *)theView forEvent:(NSEvent *)theEvent - (void)checkTrackingRectangles:(NSView *)theView forEvent:(NSEvent *)theEvent
{ {
@ -1044,7 +1109,7 @@ NSString *NSWindowWillMoveNotification;
- (BOOL)worksWhenModal - (BOOL)worksWhenModal
{ {
return YES; return NO;
} }
// //
@ -1116,7 +1181,7 @@ NSString *NSWindowWillMoveNotification;
// //
// Printing and postscript // Printing and postscript
// //
- (NSDate *)dataWithEPSInsideRect:(NSRect)rect - (NSData *)dataWithEPSInsideRect:(NSRect)rect
{ {
return nil; return nil;
} }
@ -1319,9 +1384,12 @@ NSString *NSWindowWillMoveNotification;
return self; return self;
} }
@end
// //
// GNUstep additional methods // GNUstep backend methods
// //
@implementation NSWindow (GNUstepBackend)
// //
// Mouse capture/release // Mouse capture/release
@ -1338,9 +1406,45 @@ NSString *NSWindowWillMoveNotification;
// Allow subclasses to init without the backend class // Allow subclasses to init without the backend class
// attempting to create an actual window // attempting to create an actual window
- (void)initDefaults
{
first_responder = nil;
original_responder = nil;
delegate = nil;
window_num = 0;
background_color = [NSColor lightGrayColor];
represented_filename = @"Window";
miniaturized_title = @"Window";
miniaturized_image = nil;
window_title = @"Window";
last_point = NSZeroPoint;
window_level = NSNormalWindowLevel;
is_one_shot = NO;
needs_display = NO;
is_autodisplay = YES;
optimize_drawing = YES;
views_need_display = NO;
depth_limit = 8;
dynamic_depth_limit = YES;
cursor_rects_enabled = NO;
visible = NO;
is_key = NO;
is_main = NO;
is_edited = NO;
is_released_when_closed = NO;
is_miniaturized = NO;
disable_flush_window = NO;
menu_exclude = NO;
hides_on_deactivate = NO;
accepts_mouse_moved = YES;
}
- cleanInit - cleanInit
{ {
[super init]; [super init];
[self initDefaults];
return self; return self;
} }