From d4848b7da296482b06bdcc1b5a517f216aa8717a Mon Sep 17 00:00:00 2001 From: gnustep Date: Fri, 21 Jun 1996 15:08:08 +0000 Subject: [PATCH] Implement methods for resizing subviews. Some minor bug fixes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1637 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 12 ++++++++++++ Source/Makefile.sed.nt | 2 +- Source/NSButton.m | 12 ++++++++++++ Source/NSFont.m | 12 ++++++------ Source/NSView.m | 34 ++++++++++++++++++++++++++++++++-- Source/NSWindow.m | 2 ++ 6 files changed, 65 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa2588cdc..0d58585ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Jun 19 14:25:46 1996 Scott Christley + + * Source/NSView.m (resizeSubviewsWithOldSize:): Implement method. + (setFrame:): Notify subviews that size has changed. + (initWithFrame:): Automatically resize subviews. + * Source/Makefile.sed.nt: Have the library automatically contain + COFF debugging information. + * Source/NSButton.m (mouseDown:): Ignore the mouse if the button + is not enabled. + * Source/NSFont.m (MB_USER_FIXED_FONT, MB_USER_FONT): Rename + global variables to correspond with coding standards. + Thu Jun 6 09:20:51 1996 GNUstep Development * Headers/gnustep/gui/NSApplication.h (-context): New method. diff --git a/Source/Makefile.sed.nt b/Source/Makefile.sed.nt index 805145221..fa72dfc20 100644 --- a/Source/Makefile.sed.nt +++ b/Source/Makefile.sed.nt @@ -20,7 +20,7 @@ s/INIT_FILE =/INIT_FILE = gnustep_gui_init_runtime/ s/@LDFLAGS@/-align:0x1000 -entry:WinMainCRTStartup -stack:1000000,1000000/ s/LD = ld/LD = ld -subsystem:windows/ s/LDOUT =/LDOUT = -out:/ -s/LIB = ar/LIB = lib/ +s/LIB = ar/LIB = lib -debugtype:coff/ s/LIBFLAGS = rc/LIBFLAGS =/ s/LIBOUT =/LIBOUT = -out:/ s/@RANLIB@/touch/ diff --git a/Source/NSButton.m b/Source/NSButton.m index 071b58f07..4356b390e 100644 --- a/Source/NSButton.m +++ b/Source/NSButton.m @@ -102,6 +102,14 @@ id MB_NSBUTTON_CLASS; [self display]; } +// +// Identifying the Selected Cell +// +- (id)selectedCell +{ + return cell; +} + // // Setting the State // @@ -257,6 +265,10 @@ id MB_NSBUTTON_CLASS; NSDebugLog(@"NSButton mouseDown\n"); + // If we are not enabled then ignore the mouse + if (![self isEnabled]) + return; + // capture mouse [[self window] captureMouse: self]; diff --git a/Source/NSFont.m b/Source/NSFont.m index e4fe0a169..2087b3803 100644 --- a/Source/NSFont.m +++ b/Source/NSFont.m @@ -31,8 +31,8 @@ #include #include -NSFont *MB_USER_FIXED_FONT; -NSFont *MB_USER_FONT; +NSFont *gnustep_gui_user_fixed_font; +NSFont *gnustep_gui_user_font; // Global Strings NSString *NSAFMAscender; @@ -110,13 +110,13 @@ NSString *NSAFMXHeight; + (NSFont *)userFixedPitchFontOfSize:(float)fontSize { NSFontManager *fm = [NSFontManager sharedFontManager]; - return [fm convertFont:MB_USER_FIXED_FONT toSize:fontSize]; + return [fm convertFont:gnustep_gui_user_fixed_font toSize:fontSize]; } + (NSFont *)userFontOfSize:(float)fontSize { NSFontManager *fm = [NSFontManager sharedFontManager]; - return [fm convertFont:MB_USER_FONT toSize:fontSize]; + return [fm convertFont:gnustep_gui_user_font toSize:fontSize]; } // @@ -124,12 +124,12 @@ NSString *NSAFMXHeight; // + (void)setUserFixedPitchFont:(NSFont *)aFont { - MB_USER_FIXED_FONT = aFont; + gnustep_gui_user_fixed_font = aFont; } + (void)setUserFont:(NSFont *)aFont { - MB_USER_FONT = aFont; + gnustep_gui_user_font = aFont; } + (void)useFont:(NSString *)fontName diff --git a/Source/NSView.m b/Source/NSView.m index 4889420b3..e81ce13b5 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -154,7 +154,7 @@ NSString *NSViewFocusChangedNotification; disable_autodisplay = NO; needs_display = YES; post_frame_changes = NO; - autoresize_subviews = NO; + autoresize_subviews = YES; return self; } @@ -365,8 +365,13 @@ NSString *NSViewFocusChangedNotification; - (void)setFrame:(NSRect)frameRect { + NSSize old_size = bounds.size; + frame = frameRect; bounds.size = frame.size; + + // Resize subviews + [self resizeSubviewsWithOldSize: old_size]; } - (void)setFrameOrigin:(NSPoint)newOrigin @@ -379,8 +384,13 @@ NSString *NSViewFocusChangedNotification; - (void)setFrameSize:(NSSize)newSize { + NSSize old_size = bounds.size; + frame.size = newSize; bounds.size = newSize; + + // Resize subviews + [self resizeSubviewsWithOldSize: old_size]; } // @@ -524,7 +534,27 @@ NSString *NSViewFocusChangedNotification; // Resizing Subviews // - (void)resizeSubviewsWithOldSize:(NSSize)oldSize -{} +{ + id e, o; + + // Are we suppose to resize our subviews? + if (![self autoresizesSubviews]) + return; + + e = [sub_views objectEnumerator]; + o = [e nextObject]; + while (o) + { + NSRect b = [o bounds]; + NSSize old_size = b.size; + + // Resize the subview + // Then tell it to resize its subviews + [o resizeWithOldSuperviewSize: oldSize]; + [o resizeSubviewsWithOldSize: old_size]; + o = [e nextObject]; + } +} - (void)setAutoresizesSubviews:(BOOL)flag { diff --git a/Source/NSWindow.m b/Source/NSWindow.m index b40a1049f..d4d8d1acf 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1270,6 +1270,8 @@ pasteboard:(NSPasteboard *)pboard [aDecoder decodeValueOfObjCType:@encode(BOOL) at: &menu_exclude]; // Register ourselves with the Application object + // +++ we shouldn't do this because coding may not be done? + // better to do it in the awakeFromCoder method theApp = [NSApplication sharedApplication]; [theApp addWindowsItem:self title:nil filename:NO]; NSLog(@"NSWindow: finish decoding\n");