diff --git a/ChangeLog b/ChangeLog index 7801d4022..f46f0762e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Mar 23 1999 Michael Hanni + + * Source/NSFontManager.m: implemented orderFrontFontPanel:. + * Source/NSFontPanel.m: implemented init:. Will now display the + font panel. Not necessarily useful yet though. I need to plugin a + few matrixes and bogus arrays with font info to make it look + useful. Try fontpanel.app in xraw/Testing. + Mon Mar 22 13:12:00 1999 Richard Frith-Macdonald * Source/NSView.m: implement lockFocus and unlockFocus diff --git a/Headers/gnustep/gui/NSFontManager.h b/Headers/gnustep/gui/NSFontManager.h index 9b2c443f2..ab0acfbde 100644 --- a/Headers/gnustep/gui/NSFontManager.h +++ b/Headers/gnustep/gui/NSFontManager.h @@ -99,6 +99,7 @@ enum { - (NSArray *)availableFonts; - (NSMenu *)fontMenu:(BOOL)create; - (NSFontPanel *)fontPanel:(BOOL)create; +- (void)orderFrontFontPanel:(id)sender; - (BOOL)isEnabled; - (BOOL)isMultiple; - (NSFont *)selectedFont; diff --git a/Source/NSFontManager.m b/Source/NSFontManager.m index aed006f75..c6d86818c 100644 --- a/Source/NSFontManager.m +++ b/Source/NSFontManager.m @@ -273,6 +273,8 @@ static Class fontPanelClass = Nil; return font_menu; } +// Get the font panel... + - (NSFontPanel *)fontPanel:(BOOL)create { if ((!fontPanel) && (create)) @@ -280,6 +282,15 @@ static Class fontPanelClass = Nil; return fontPanel; } +// Bring the font panel to the front... MacOSX only? + +- (void)orderFrontFontPanel:(id)sender +{ + if (!fontPanel) + fontPanel = [[fontPanelClass alloc] init]; + [fontPanel orderFront:nil]; +} + - (BOOL)isEnabled { return NO; diff --git a/Source/NSFontPanel.m b/Source/NSFontPanel.m index 9e4b59371..feec1fc2e 100644 --- a/Source/NSFontPanel.m +++ b/Source/NSFontPanel.m @@ -30,6 +30,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include @implementation NSFontPanel @@ -60,9 +66,147 @@ // // Instance methods // + // // Creating an NSFontPanel // +- (id)init +{ + NSRect pf = {{100,100}, {300,300}}; + NSRect ts = {{0,250}, {300,50}}; + NSRect bs = {{0,0}, {300,300}}; + NSRect pa = {{5,5}, {290,40}}; + NSRect l = {{5,215}, {110, 20}}; + NSRect ss = {{5,50}, {110, 160}}; + NSRect b = {{60,5}, {75,25}}; + NSView *v; + NSView *topSplit; + NSView *bottomSplit; + NSSplitView *splitView; + NSTextField *previewArea; + NSTextField *label; + NSScrollView *familyScroll; + NSScrollView *typeScroll; + NSScrollView *sizeScroll; + NSButton *setButton; + NSButton *revertButton; + NSButton *previewButton; + + unsigned int style = NSTitledWindowMask; + + self = [super initWithContentRect:pf + styleMask:style + backing:NSBackingStoreRetained + defer:NO + screen:nil]; + [self setTitle:@"Font Panel"]; + +// v = [self contentView]; + + splitView = [NSSplitView new]; + [splitView setVertical:NO]; + [self setContentView:splitView]; + + topSplit = [[NSView alloc] initWithFrame:ts]; + + previewArea = [[NSTextField alloc] initWithFrame:pa]; + [previewArea setBackgroundColor:[NSColor whiteColor]]; + [previewArea setDrawsBackground:YES]; + [topSplit addSubview:previewArea]; + + bottomSplit = [[NSView alloc] initWithFrame:bs]; + + label = [[NSTextField alloc] initWithFrame:l]; + [label setAlignment: NSCenterTextAlignment]; + [label setStringValue:@"Family"]; + [label setDrawsBackground:YES]; + [label setTextColor:[NSColor whiteColor]]; + [label setBackgroundColor:[NSColor darkGrayColor]]; + [bottomSplit addSubview:label]; + [label release]; + + familyScroll = [[NSScrollView alloc] initWithFrame:ss]; + [familyScroll setHasVerticalScroller:YES]; + [bottomSplit addSubview:familyScroll]; + + l.origin.x = 120; + + label = [[NSTextField alloc] initWithFrame:l]; + [label setAlignment: NSCenterTextAlignment]; + [label setDrawsBackground:YES]; + [label setTextColor:[NSColor whiteColor]]; + [label setBackgroundColor:[NSColor darkGrayColor]]; + [label setStringValue:@"Typeface"]; + [bottomSplit addSubview:label]; + [label release]; + + ss.origin.x = 120; + + typeScroll = [[NSScrollView alloc] initWithFrame:ss]; + [typeScroll setHasVerticalScroller:YES]; + [bottomSplit addSubview:typeScroll]; + + l.origin.x = 235; + l.size.width = 60; + + label = [[NSTextField alloc] initWithFrame:l]; + [label setAlignment: NSCenterTextAlignment]; + [label setDrawsBackground:YES]; + [label setTextColor:[NSColor whiteColor]]; + [label setBackgroundColor:[NSColor darkGrayColor]]; + [label setStringValue:@"Size"]; + [bottomSplit addSubview:label]; + [label release]; + + // last label, this is the size input. We don't release this one. + + l.origin.x = 235; + l.origin.y = 190; + l.size.height = 20; + l.size.width = 60; + + label = [[NSTextField alloc] initWithFrame:l]; + [label setDrawsBackground:YES]; + [label setBackgroundColor:[NSColor whiteColor]]; + [bottomSplit addSubview:label]; + + ss.origin.x = 235; + ss.origin.y = 50; + ss.size.height = 135; + ss.size.width = 60; + + sizeScroll = [[NSScrollView alloc] initWithFrame:ss]; + [sizeScroll setHasVerticalScroller:YES]; + [bottomSplit addSubview:sizeScroll]; + + revertButton = [[NSButton alloc] initWithFrame:b]; + [revertButton setStringValue:@"Revert"]; + [bottomSplit addSubview:revertButton]; + + b.origin.x = 140; + + previewButton = [[NSButton alloc] initWithFrame:b]; + [previewButton setStringValue:@"Preview"]; + [bottomSplit addSubview:previewButton]; + + b.origin.x = 220; + + setButton = [[NSButton alloc] initWithFrame:b]; + [setButton setStringValue:@"Set"]; + [bottomSplit addSubview:setButton]; + + [splitView addSubview:bottomSplit]; + [splitView addSubview:topSplit]; + + return self; +} + +/* +- initWithFrame:(NSRect)aFrame +{ + [super initWithFrame:aFrame]; +} +*/ - (NSFont *)panelConvertFont:(NSFont *)fontObject { return panel_font;