Added NSFontPanel init:.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3960 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Michael Silva 1999-03-23 21:03:52 +00:00
parent baf38fda6e
commit fc2c643d2a
4 changed files with 164 additions and 0 deletions

View file

@ -1,3 +1,11 @@
Tue Mar 23 1999 Michael Hanni <mhanni@sprintmail.com>
* 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 <richard@brainstorm.co.uk>
* Source/NSView.m: implement lockFocus and unlockFocus

View file

@ -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;

View file

@ -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;

View file

@ -30,6 +30,12 @@
#include <AppKit/NSFontPanel.h>
#include <AppKit/NSFontManager.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSSplitView.h>
#include <AppKit/NSScrollView.h>
#include <AppKit/NSTextField.h>
#include <AppKit/NSColor.h>
#include <AppKit/NSPanel.h>
#include <AppKit/NSButton.h>
@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;