mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Committing Alex's font changes as well as my font panel changes and some
work I did on NSDataLink a while back (a few months ago). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16898 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1e087664dd
commit
d10d57c53e
14 changed files with 714 additions and 88 deletions
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
2003-06-09 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Headers/gnustep/gui/NSDataLinkPanel.h: Added ivar declarations
|
||||
for the data link panel.
|
||||
* Source/NSDataLinkPanel.m: Added some implementations for panel methods.
|
||||
* Source/NSDataLinkManager.m: Manages the data links for an application.
|
||||
added implementation for some methods.
|
||||
* Headers/gnustep/gui/NSFontPanel.h: Added topView and bottomView and sizes
|
||||
for use by accessory view code.
|
||||
* Source/NSFontPanel.m: Added implementation for _getOriginalSize and also
|
||||
for sertAccessoryView. Previously the setAccessoryView method was causing
|
||||
the accessory view to overlay the content view of the window.
|
||||
* Panels/GNUmakefile: added GSDataLinkPanel.gorm in the makefile.
|
||||
* Source/NSBundleAdditions.m: Skeletal implementation of GSObjectData
|
||||
class.
|
||||
|
||||
2003-06-09 Alexander Malmberg <alexander@malmberg.org>
|
||||
committed by: Gregory Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Headers/gnustep/gui/NSFont.h: Added ivar to hold font role
|
||||
to represent preferred fonts (e.g. system, user, & tooltip fonts)
|
||||
* Source/NSFont.m: Added roles and modified code to properly encode
|
||||
and decode fonts such that an intelligent default is selected if the
|
||||
specified font is unavailable and also unarchives as the correct
|
||||
preferred font if one of the predefined roles is selected.
|
||||
|
||||
|
||||
2003-06-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep.m
|
||||
|
|
|
@ -133,6 +133,16 @@
|
|||
}
|
||||
@end
|
||||
|
||||
@interface GSObjectData : NSObject
|
||||
{
|
||||
NSMutableDictionary *dictionary;
|
||||
}
|
||||
|
||||
- (void) setValuesFromObject: (id)object;
|
||||
- (void) restoreValuesToObject: (id)object;
|
||||
- (NSMutableDictionary *)dictionary;
|
||||
@end
|
||||
|
||||
@interface GSClassSwapper : NSObject
|
||||
{
|
||||
NSString *_className;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
@class NSString;
|
||||
@class NSEnumerator;
|
||||
|
||||
@class NSMutableDictionary;
|
||||
@class NSDataLink;
|
||||
@class NSSelection;
|
||||
@class NSPasteboard;
|
||||
|
@ -42,6 +42,14 @@
|
|||
@interface NSDataLinkManager : NSObject <NSCoding>
|
||||
{
|
||||
// Attributes
|
||||
id delegate;
|
||||
NSString *filename;
|
||||
BOOL delegateVerifiesLinks;
|
||||
BOOL interactsWithUser;
|
||||
BOOL isEdited;
|
||||
BOOL areLinkOutlinesVisible;
|
||||
NSMutableDictionary *sourceLinks;
|
||||
NSMutableDictionary *destinationLinks;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
@interface NSDataLinkPanel : NSPanel <NSCoding>
|
||||
{
|
||||
// Attributes
|
||||
id _sourceField;
|
||||
id _lastUpdateField;
|
||||
id _openSourceButton;
|
||||
id _updateDestinationButton;
|
||||
id _breakLinkButton;
|
||||
id _breakAllLinksButton;
|
||||
id _updateModeButton;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -59,7 +59,7 @@ typedef enum _NSMultibyteGlyphPacking {
|
|||
NSFourByteGlyphPacking
|
||||
} NSMultibyteGlyphPacking;
|
||||
|
||||
APPKIT_EXPORT const float*NSFontIdentityMatrix;
|
||||
APPKIT_EXPORT const float *NSFontIdentityMatrix;
|
||||
|
||||
@interface NSFont : NSObject <NSCoding, NSCopying>
|
||||
{
|
||||
|
@ -70,6 +70,13 @@ APPKIT_EXPORT const float*NSFontIdentityMatrix;
|
|||
|
||||
id fontInfo;
|
||||
void *_fontRef;
|
||||
|
||||
/*
|
||||
If this font was created with a specific "role", like user font, or
|
||||
message font, and not a specific postscript name, the role will be
|
||||
stored here.
|
||||
*/
|
||||
int role;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -72,6 +72,12 @@ enum {
|
|||
|
||||
// field for display
|
||||
NSView *_accessoryView;
|
||||
NSView *_topView;
|
||||
NSView *_bottomView;
|
||||
|
||||
// sizes
|
||||
NSSize _originalMinSize;
|
||||
NSSize _originalSize;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
172
Panels/English.lproj/GSDataLinkPanel.gorm/data.classes
Normal file
172
Panels/English.lproj/GSDataLinkPanel.gorm/data.classes
Normal file
|
@ -0,0 +1,172 @@
|
|||
{
|
||||
FirstResponder = {
|
||||
Actions = (
|
||||
"activateContextHelpMode:",
|
||||
"alignCenter:",
|
||||
"alignJustified:",
|
||||
"alignLeft:",
|
||||
"alignRight:",
|
||||
"arrangeInFront:",
|
||||
"cancel:",
|
||||
"capitalizeWord:",
|
||||
"changeColor:",
|
||||
"changeFont:",
|
||||
"checkSpelling:",
|
||||
"close:",
|
||||
"complete:",
|
||||
"copy:",
|
||||
"copyFont:",
|
||||
"copyRuler:",
|
||||
"cut:",
|
||||
"delete:",
|
||||
"deleteBackward:",
|
||||
"deleteForward:",
|
||||
"deleteToBeginningOfLine:",
|
||||
"deleteToBeginningOfParagraph:",
|
||||
"deleteToEndOfLine:",
|
||||
"deleteToEndOfParagraph:",
|
||||
"deleteToMark:",
|
||||
"deleteWordBackward:",
|
||||
"deleteWordForward:",
|
||||
"deminiaturize:",
|
||||
"deselectAll:",
|
||||
"fax:",
|
||||
"hide:",
|
||||
"hideOtherApplications:",
|
||||
"indent:",
|
||||
"loosenKerning:",
|
||||
"lowerBaseline:",
|
||||
"lowercaseWord:",
|
||||
"makeKeyAndOrderFront:",
|
||||
"miniaturize:",
|
||||
"miniaturizeAll:",
|
||||
"moveBackward:",
|
||||
"moveBackwardAndModifySelection:",
|
||||
"moveDown:",
|
||||
"moveDownAndModifySelection:",
|
||||
"moveForward:",
|
||||
"moveForwardAndModifySelection:",
|
||||
"moveLeft:",
|
||||
"moveRight:",
|
||||
"moveToBeginningOfDocument:",
|
||||
"moveToBeginningOfLine:",
|
||||
"moveToBeginningOfParagraph:",
|
||||
"moveToEndOfDocument:",
|
||||
"moveToEndOfLine:",
|
||||
"moveToEndOfParagraph:",
|
||||
"moveUp:",
|
||||
"moveUpAndModifySelection:",
|
||||
"moveWordBackward:",
|
||||
"moveWordBackwardAndModifySelection:",
|
||||
"moveWordForward:",
|
||||
"moveWordForwardAndModifySelection:",
|
||||
"newDocument:",
|
||||
"ok:",
|
||||
"openDocument:",
|
||||
"orderBack:",
|
||||
"orderFront:",
|
||||
"orderFrontColorPanel:",
|
||||
"orderFrontDataLinkPanel:",
|
||||
"orderFrontFontPanel:",
|
||||
"orderFrontHelpPanel:",
|
||||
"orderFrontStandardAboutPanel:",
|
||||
"orderFrontStandardInfoPanel:",
|
||||
"orderOut:",
|
||||
"pageDown:",
|
||||
"pageUp:",
|
||||
"paste:",
|
||||
"pasteAsPlainText:",
|
||||
"pasteAsRichText:",
|
||||
"pasteFont:",
|
||||
"pasteRuler:",
|
||||
"performClose:",
|
||||
"performMiniaturize:",
|
||||
"performZoom:",
|
||||
"print:",
|
||||
"raiseBaseline:",
|
||||
"revertDocumentToSaved:",
|
||||
"runPageLayout:",
|
||||
"runToolbarCustomizationPalette:",
|
||||
"saveAllDocuments:",
|
||||
"saveDocument:",
|
||||
"saveDocumentAs:",
|
||||
"saveDocumentTo:",
|
||||
"scrollLineDown:",
|
||||
"scrollLineUp:",
|
||||
"scrollPageDown:",
|
||||
"scrollPageUp:",
|
||||
"scrollViaScroller:",
|
||||
"selectAll:",
|
||||
"selectLine:",
|
||||
"selectNextKeyView:",
|
||||
"selectParagraph:",
|
||||
"selectPreviousKeyView:",
|
||||
"selectText:",
|
||||
"selectText:",
|
||||
"selectToMark:",
|
||||
"selectWord:",
|
||||
"showContextHelp:",
|
||||
"showGuessPanel:",
|
||||
"showHelp:",
|
||||
"showWindow:",
|
||||
"stop:",
|
||||
"subscript:",
|
||||
"superscript:",
|
||||
"swapWithMark:",
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:",
|
||||
"terminate:",
|
||||
"tightenKerning:",
|
||||
"toggle:",
|
||||
"toggleContinuousSpellChecking:",
|
||||
"toggleRuler:",
|
||||
"toggleToolbarShown:",
|
||||
"toggleTraditionalCharacterShape:",
|
||||
"transpose:",
|
||||
"transposeWords:",
|
||||
"turnOffKerning:",
|
||||
"turnOffLigatures:",
|
||||
"underline:",
|
||||
"unhide:",
|
||||
"unhideAllApplications:",
|
||||
"unscript:",
|
||||
"uppercaseWord:",
|
||||
"useAllLigatures:",
|
||||
"useStandardKerning:",
|
||||
"useStandardLigatures:",
|
||||
"yank:",
|
||||
"zoom:"
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
GSDataLinkPanelController = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
panel
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSDataLinkPanel = {
|
||||
Actions = (
|
||||
"pickedUpdateMode:",
|
||||
"pickedUpdateDestination:",
|
||||
"pickedOpenSource:",
|
||||
"pickedBreakLink:",
|
||||
"pickedBreakAllLinks:"
|
||||
);
|
||||
Outlets = (
|
||||
_updateModeButton,
|
||||
_breakAllLinksButton,
|
||||
_breakLinkButton,
|
||||
_updateDestinationButton,
|
||||
_openSourceButton,
|
||||
_lastUpdateField,
|
||||
_sourceField
|
||||
);
|
||||
Super = NSPanel;
|
||||
};
|
||||
}
|
BIN
Panels/English.lproj/GSDataLinkPanel.gorm/objects.gorm
Normal file
BIN
Panels/English.lproj/GSDataLinkPanel.gorm/objects.gorm
Normal file
Binary file not shown.
|
@ -36,7 +36,8 @@ include ../Version
|
|||
LANGUAGES = English
|
||||
|
||||
LOCALIZED_RESOURCE_FILES = GSPrintPanel.gorm GSPageLayout.gorm \
|
||||
SpellPanel.gmodel
|
||||
SpellPanel.gmodel \
|
||||
GSDataLinkPanel.gorm
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
-include GNUmakefile.local
|
||||
|
|
|
@ -295,7 +295,9 @@ Class gmodel_class(void)
|
|||
id obj;
|
||||
|
||||
// font fallback and automatic translation...
|
||||
#if 0
|
||||
[unarchiver decodeClassName: @"NSFont" asClassName: @"GSFontProxy"];
|
||||
#endif
|
||||
// [unarchiver decodeClassName: @"NSString" asClassName: @"GSStringProxy"];
|
||||
|
||||
NSDebugLog(@"Invoking unarchiver");
|
||||
|
@ -1486,6 +1488,22 @@ Class gmodel_class(void)
|
|||
}
|
||||
@end
|
||||
|
||||
// this class holds the data from subclasses so that more specific templates
|
||||
// need not be made.
|
||||
@implementation GSObjectData
|
||||
- (void) setValuesFromObject: (id)object
|
||||
{
|
||||
}
|
||||
|
||||
- (void) restoreValuesToObject: (id)object
|
||||
{
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)dictionary
|
||||
{
|
||||
return dictionary;
|
||||
}
|
||||
@end
|
||||
|
||||
// This class uses the templates above to persist the correct type of
|
||||
// custom object into the nib file.
|
||||
|
@ -1547,6 +1565,7 @@ Class gmodel_class(void)
|
|||
}
|
||||
@end
|
||||
|
||||
#if 0
|
||||
// Font proxy...
|
||||
@implementation GSFontProxy
|
||||
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||
|
@ -1562,6 +1581,7 @@ Class gmodel_class(void)
|
|||
return result;
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
||||
// String proxy for dynamic translation...
|
||||
/*
|
||||
|
|
|
@ -48,13 +48,31 @@
|
|||
//
|
||||
- (id)initWithDelegate:(id)anObject
|
||||
{
|
||||
return nil;
|
||||
self = [super init];
|
||||
|
||||
ASSIGN(delegate,anObject);
|
||||
filename = nil;
|
||||
delegateVerifiesLinks = NO;
|
||||
interactsWithUser = NO;
|
||||
isEdited = NO;
|
||||
areLinkOutlinesVisible = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithDelegate:(id)anObject
|
||||
fromFile:(NSString *)path
|
||||
{
|
||||
return nil;
|
||||
self = [super init];
|
||||
|
||||
ASSIGN(delegate,anObject);
|
||||
ASSIGN(filename,path);
|
||||
delegateVerifiesLinks = NO;
|
||||
interactsWithUser = NO;
|
||||
isEdited = NO;
|
||||
areLinkOutlinesVisible = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -74,7 +92,7 @@
|
|||
|
||||
- (NSDataLink *)addLinkPreviouslyAt:(NSSelection *)oldSelection
|
||||
fromPasteboard:(NSPasteboard *)pasteboard
|
||||
at:(NSSelection *)selection
|
||||
at:(NSSelection *)selection
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
@ -111,41 +129,45 @@ at:(NSSelection *)selection
|
|||
//
|
||||
- (id)delegate
|
||||
{
|
||||
return nil;
|
||||
return delegate;
|
||||
}
|
||||
|
||||
- (BOOL)delegateVerifiesLinks
|
||||
{
|
||||
return NO;
|
||||
return delegateVerifiesLinks;
|
||||
}
|
||||
|
||||
- (NSString *)filename
|
||||
{
|
||||
return nil;
|
||||
return filename;
|
||||
}
|
||||
|
||||
- (BOOL)interactsWithUser
|
||||
{
|
||||
return NO;
|
||||
return interactsWithUser;
|
||||
}
|
||||
|
||||
- (BOOL)isEdited
|
||||
{
|
||||
return NO;
|
||||
return isEdited;
|
||||
}
|
||||
|
||||
- (void)setDelegateVerifiesLinks:(BOOL)flag
|
||||
{}
|
||||
{
|
||||
delegateVerifiesLinks = flag;
|
||||
}
|
||||
|
||||
- (void)setInteractsWithUser:(BOOL)flag
|
||||
{}
|
||||
{
|
||||
interactsWithUser = flag;
|
||||
}
|
||||
|
||||
//
|
||||
// Getting and Setting Information about the Manager's Links
|
||||
//
|
||||
- (BOOL)areLinkOutlinesVisible
|
||||
{
|
||||
return NO;
|
||||
return areLinkOutlinesVisible;
|
||||
}
|
||||
|
||||
- (NSEnumerator *)destinationLinkEnumerator
|
||||
|
@ -159,7 +181,9 @@ at:(NSSelection *)selection
|
|||
}
|
||||
|
||||
- (void)setLinkOutlinesVisible:(BOOL)flag
|
||||
{}
|
||||
{
|
||||
areLinkOutlinesVisible = flag;
|
||||
}
|
||||
|
||||
- (NSEnumerator *)sourceLinkEnumerator
|
||||
{
|
||||
|
|
|
@ -25,7 +25,46 @@
|
|||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSDataLinkPanel.h>
|
||||
#include <AppKit/NSNibLoading.h>
|
||||
|
||||
static NSDataLinkPanel *__sharedDataLinkPanel;
|
||||
|
||||
@interface GSDataLinkPanelController : NSObject
|
||||
{
|
||||
id panel;
|
||||
}
|
||||
- (id) panel;
|
||||
@end
|
||||
|
||||
@implementation GSDataLinkPanelController
|
||||
- (id) init
|
||||
{
|
||||
NSString *panelPath;
|
||||
NSDictionary *table;
|
||||
|
||||
self = [super init];
|
||||
panelPath = [NSBundle pathForGNUstepResource: @"GSDataLinkPanel"
|
||||
ofType: @"gorm"
|
||||
inDirectory: nil];
|
||||
NSLog(@"Panel path=%@",panelPath);
|
||||
table = [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"];
|
||||
if ([NSBundle loadNibFile: panelPath
|
||||
externalNameTable: table
|
||||
withZone: [self zone]] == NO)
|
||||
{
|
||||
NSRunAlertPanel(@"Error", @"Could not load data link panel resource",
|
||||
@"OK", NULL, NULL);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) panel
|
||||
{
|
||||
return panel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSApplication (NSDataLinkPanel)
|
||||
|
||||
|
@ -60,9 +99,13 @@
|
|||
//
|
||||
+ (NSDataLinkPanel *)sharedDataLinkPanel
|
||||
{
|
||||
NSRunAlertPanel (NULL, @"Data Link Panel not implemented yet",
|
||||
@"OK", NULL, NULL);
|
||||
return nil;
|
||||
if(__sharedDataLinkPanel == nil)
|
||||
{
|
||||
id controller = [[GSDataLinkPanelController alloc] init];
|
||||
__sharedDataLinkPanel = [controller panel];
|
||||
}
|
||||
NSLog(@"%@",__sharedDataLinkPanel);
|
||||
return __sharedDataLinkPanel;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -110,19 +153,29 @@ isMultiple:(BOOL)flag
|
|||
// Responding to User Input
|
||||
//
|
||||
- (void)pickedBreakAllLinks:(id)sender
|
||||
{}
|
||||
{
|
||||
NSLog(@"Break all links...");
|
||||
}
|
||||
|
||||
- (void)pickedBreakLink:(id)sender
|
||||
{}
|
||||
{
|
||||
NSLog(@"Break link...");
|
||||
}
|
||||
|
||||
- (void)pickedOpenSource:(id)sender
|
||||
{}
|
||||
{
|
||||
NSLog(@"Open Source...");
|
||||
}
|
||||
|
||||
- (void)pickedUpdateDestination:(id)sender
|
||||
{}
|
||||
{
|
||||
NSLog(@"Update destination...");
|
||||
}
|
||||
|
||||
- (void)pickedUpdateMode:(id)sender
|
||||
{}
|
||||
{
|
||||
NSLog(@"Update mode..");
|
||||
}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
|
|
297
Source/NSFont.m
297
Source/NSFont.m
|
@ -40,6 +40,34 @@
|
|||
#include <AppKit/NSView.h>
|
||||
#include <gnustep/gui/GSFusedSilicaContext.h>
|
||||
|
||||
|
||||
/*
|
||||
The valid font roles. Note that these values are used when encoding and
|
||||
decoding, so entries may never be removed. Entries may be added after the
|
||||
last entry, and entries don't have to actually be handled.
|
||||
|
||||
Note that these values are multiplied by two before they are used since the
|
||||
lowest bit is used to indicate an explicit size. If the lowest bit is set,
|
||||
the size is explicitly specified and encoded.
|
||||
*/
|
||||
enum FontRoles
|
||||
{
|
||||
RoleExplicit=0,
|
||||
RoleBoldSystemFont,
|
||||
RoleSystemFont,
|
||||
RoleUserFixedPitchFont,
|
||||
RoleUserFont,
|
||||
RoleTitleBarFont,
|
||||
RoleMenuFont,
|
||||
RoleMessageFont,
|
||||
RolePaletteFont,
|
||||
RoleToolTipsFont,
|
||||
RoleControlContentFont,
|
||||
RoleLabelFont
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* We cache all the 4 default fonts after we first get them.
|
||||
But when a default font is changed, the variable is set to YES
|
||||
so all default fonts are forced to be recomputed. */
|
||||
|
@ -53,25 +81,30 @@ static NSFont *placeHolder = nil;
|
|||
- (id) initWithName: (NSString*)name
|
||||
matrix: (const float*)fontMatrix
|
||||
fix: (BOOL)explicitlySet
|
||||
screenFont: (BOOL)screenFont;
|
||||
screenFont: (BOOL)screenFont
|
||||
role: (int)role;
|
||||
+ (NSFont*) _fontWithName: (NSString*)aFontName
|
||||
size: (float)fontSize
|
||||
role: (int)role;
|
||||
@end
|
||||
|
||||
static int currentVersion = 2;
|
||||
static int currentVersion = 3;
|
||||
|
||||
/*
|
||||
* Just to ensure that we use a standard name in the cache.
|
||||
*/
|
||||
static NSString*
|
||||
newNameWithMatrix(NSString *name, const float *matrix, BOOL fix,
|
||||
BOOL screenFont)
|
||||
BOOL screenFont, int role)
|
||||
{
|
||||
NSString *nameWithMatrix;
|
||||
|
||||
nameWithMatrix = [[NSString alloc] initWithFormat:
|
||||
@"%@ %.3f %.3f %.3f %.3f %.3f %.3f %c %c", name,
|
||||
@"%@ %.3f %.3f %.3f %.3f %.3f %.3f %c %c %i", name,
|
||||
matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5],
|
||||
(fix == NO) ? 'N' : 'Y',
|
||||
screenFont ? 'S' : 'P'];
|
||||
screenFont ? 'S' : 'P',
|
||||
role];
|
||||
return nameWithMatrix;
|
||||
}
|
||||
|
||||
|
@ -133,7 +166,7 @@ newNameWithMatrix(NSString *name, const float *matrix, BOOL fix,
|
|||
/* Class variables*/
|
||||
|
||||
/* Fonts that are preferred by the application */
|
||||
NSArray *_preferredFonts;
|
||||
static NSArray *_preferredFonts;
|
||||
|
||||
/* Class for fonts */
|
||||
static Class NSFontClass = 0;
|
||||
|
@ -143,11 +176,13 @@ static NSMapTable* globalFontMap = 0;
|
|||
|
||||
static NSUserDefaults *defaults = nil;
|
||||
|
||||
NSFont*
|
||||
getNSFont(NSString* key, NSString* defaultFontName, float fontSize)
|
||||
static NSFont *
|
||||
getNSFont(NSString* key, NSString* defaultFontName, float fontSize, int role)
|
||||
{
|
||||
NSString *fontName;
|
||||
NSFont *font;
|
||||
|
||||
role *= 2;
|
||||
|
||||
fontName = [defaults objectForKey: key];
|
||||
if (fontName == nil)
|
||||
|
@ -160,14 +195,20 @@ getNSFont(NSString* key, NSString* defaultFontName, float fontSize)
|
|||
fontSize = [defaults floatForKey:
|
||||
[NSString stringWithFormat: @"%@Size", key]];
|
||||
}
|
||||
else
|
||||
{
|
||||
role |= 1;
|
||||
}
|
||||
|
||||
font = [NSFontClass fontWithName: fontName size: fontSize];
|
||||
font = [NSFontClass _fontWithName: fontName size: fontSize role: role];
|
||||
|
||||
/* That font couldn't be found (?). */
|
||||
if (font == nil)
|
||||
{
|
||||
/* Try the same size, but the defaultFontName. */
|
||||
font = [NSFontClass fontWithName: defaultFontName size: fontSize];
|
||||
font = [NSFontClass _fontWithName: defaultFontName
|
||||
size: fontSize
|
||||
role: role];
|
||||
|
||||
if (font == nil)
|
||||
{
|
||||
|
@ -175,21 +216,29 @@ getNSFont(NSString* key, NSString* defaultFontName, float fontSize)
|
|||
fontSize = [defaults floatForKey:
|
||||
[NSString stringWithFormat: @"%@Size", key]];
|
||||
|
||||
font = [NSFontClass fontWithName: defaultFontName size: fontSize];
|
||||
font = [NSFontClass _fontWithName: defaultFontName
|
||||
size: fontSize
|
||||
role: role];
|
||||
|
||||
/* It seems we can't get any font here! Try some well known
|
||||
* fonts as a last resort. */
|
||||
if (font == nil)
|
||||
{
|
||||
font = [NSFontClass fontWithName: @"Helvetica" size: 12.];
|
||||
font = [NSFontClass _fontWithName: @"Helvetica"
|
||||
size: 12.
|
||||
role: role];
|
||||
}
|
||||
if (font == nil)
|
||||
{
|
||||
font = [NSFontClass fontWithName: @"Courier" size: 12.];
|
||||
font = [NSFontClass _fontWithName: @"Courier"
|
||||
size: 12.
|
||||
role: role];
|
||||
}
|
||||
if (font == nil)
|
||||
{
|
||||
font = [NSFontClass fontWithName: @"Fixed" size: 12.];
|
||||
font = [NSFontClass _fontWithName: @"Fixed"
|
||||
size: 12.
|
||||
role: role];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,13 +304,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSBoldFont", @"Helvetica-Bold", fontSize);
|
||||
return getNSFont (@"NSBoldFont", @"Helvetica-Bold", fontSize, RoleBoldSystemFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (boldSystemCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSBoldFont", @"Helvetica-Bold", 0));
|
||||
ASSIGN (font, getNSFont (@"NSBoldFont", @"Helvetica-Bold", 0, RoleBoldSystemFont));
|
||||
boldSystemCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -279,13 +328,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSFont", @"Helvetica", fontSize, RoleSystemFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (systemCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSFont", @"Helvetica", 0, RoleSystemFont));
|
||||
systemCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -302,13 +351,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSUserFixedPitchFont", @"Courier", fontSize);
|
||||
return getNSFont (@"NSUserFixedPitchFont", @"Courier", fontSize, RoleUserFixedPitchFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userFixedCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSUserFixedPitchFont", @"Courier", 0));
|
||||
ASSIGN (font, getNSFont (@"NSUserFixedPitchFont", @"Courier", 0, RoleUserFixedPitchFont));
|
||||
userFixedCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -325,13 +374,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSUserFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSUserFont", @"Helvetica", fontSize, RoleUserFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSUserFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSUserFont", @"Helvetica", 0, RoleUserFont));
|
||||
userCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -371,13 +420,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSControlContentFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSControlContentFont", @"Helvetica", fontSize, RoleControlContentFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSControlContentFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSControlContentFont", @"Helvetica", 0, RoleControlContentFont));
|
||||
userCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -390,13 +439,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSLabelFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSLabelFont", @"Helvetica", fontSize, RoleLabelFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSLabelFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSLabelFont", @"Helvetica", 0, RoleLabelFont));
|
||||
userCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -409,13 +458,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSMenuFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSMenuFont", @"Helvetica", fontSize, RoleMenuFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSMenuFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSMenuFont", @"Helvetica", 0, RoleMenuFont));
|
||||
userCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -428,13 +477,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSTitleBarFont", @"Helvetica-Bold", fontSize);
|
||||
return getNSFont (@"NSTitleBarFont", @"Helvetica-Bold", fontSize, RoleTitleBarFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (boldSystemCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSTitleBarFont", @"Helvetica-Bold", 0));
|
||||
ASSIGN (font, getNSFont (@"NSTitleBarFont", @"Helvetica-Bold", 0, RoleTitleBarFont));
|
||||
boldSystemCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -447,13 +496,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSMessageFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSMessageFont", @"Helvetica", fontSize, RoleMessageFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSMessageFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSMessageFont", @"Helvetica", 0, RoleMessageFont));
|
||||
userCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -467,13 +516,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSPaletteFont", @"Helvetica-Bold", fontSize);
|
||||
return getNSFont (@"NSPaletteFont", @"Helvetica-Bold", fontSize, RolePaletteFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (boldSystemCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSPaletteFont", @"Helvetica-Bold", 0));
|
||||
ASSIGN (font, getNSFont (@"NSPaletteFont", @"Helvetica-Bold", 0, RolePaletteFont));
|
||||
boldSystemCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -487,13 +536,13 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
if (fontSize != 0)
|
||||
{
|
||||
return getNSFont (@"NSToolTipsFont", @"Helvetica", fontSize);
|
||||
return getNSFont (@"NSToolTipsFont", @"Helvetica", fontSize, RoleToolTipsFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((font == nil) || (userCacheNeedsRecomputing == YES))
|
||||
{
|
||||
ASSIGN (font, getNSFont (@"NSToolTipsFont", @"Helvetica", 0));
|
||||
ASSIGN (font, getNSFont (@"NSToolTipsFont", @"Helvetica", 0, RoleToolTipsFont));
|
||||
userCacheNeedsRecomputing = NO;
|
||||
}
|
||||
return font;
|
||||
|
@ -561,7 +610,8 @@ setNSFont(NSString* key, NSFont* font)
|
|||
font = [placeHolder initWithName: aFontName
|
||||
matrix: fontMatrix
|
||||
fix: fix
|
||||
screenFont: NO];
|
||||
screenFont: NO
|
||||
role: RoleExplicit];
|
||||
|
||||
return AUTORELEASE(font);
|
||||
}
|
||||
|
@ -573,6 +623,15 @@ setNSFont(NSString* key, NSFont* font)
|
|||
*/
|
||||
+ (NSFont*) fontWithName: (NSString*)aFontName
|
||||
size: (float)fontSize
|
||||
{
|
||||
return [self _fontWithName: aFontName
|
||||
size: fontSize
|
||||
role: RoleExplicit];
|
||||
}
|
||||
|
||||
+ (NSFont*) _fontWithName: (NSString*)aFontName
|
||||
size: (float)fontSize
|
||||
role: (int)aRole
|
||||
{
|
||||
NSFont *font;
|
||||
float fontMatrix[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
|
@ -591,7 +650,8 @@ setNSFont(NSString* key, NSFont* font)
|
|||
font = [placeHolder initWithName: aFontName
|
||||
matrix: fontMatrix
|
||||
fix: NO
|
||||
screenFont: NO];
|
||||
screenFont: NO
|
||||
role: aRole];
|
||||
return AUTORELEASE(font);
|
||||
}
|
||||
|
||||
|
@ -621,7 +681,8 @@ setNSFont(NSString* key, NSFont* font)
|
|||
- (id) initWithName: (NSString*)name
|
||||
matrix: (const float*)fontMatrix
|
||||
fix: (BOOL)explicitlySet
|
||||
screenFont: (BOOL)screen;
|
||||
screenFont: (BOOL)screen
|
||||
role: (int)aRole
|
||||
{
|
||||
NSString *nameWithMatrix;
|
||||
NSFont *font;
|
||||
|
@ -631,7 +692,7 @@ setNSFont(NSString* key, NSFont* font)
|
|||
|
||||
/* Check whether the font is cached */
|
||||
nameWithMatrix = newNameWithMatrix(name, fontMatrix, explicitlySet,
|
||||
screen);
|
||||
screen, aRole);
|
||||
font = (id)NSMapGet(globalFontMap, (void*)nameWithMatrix);
|
||||
if (font == nil)
|
||||
{
|
||||
|
@ -648,6 +709,7 @@ setNSFont(NSString* key, NSFont* font)
|
|||
memcpy(matrix, fontMatrix, sizeof(matrix));
|
||||
matrixExplicitlySet = explicitlySet;
|
||||
screenFont = screen;
|
||||
role = aRole;
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: fontName
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
|
@ -682,7 +744,8 @@ setNSFont(NSString* key, NSFont* font)
|
|||
NSString *nameWithMatrix;
|
||||
|
||||
nameWithMatrix = newNameWithMatrix(fontName, matrix,
|
||||
matrixExplicitlySet, screenFont);
|
||||
matrixExplicitlySet, screenFont,
|
||||
role);
|
||||
NSMapRemove(globalFontMap, (void*)nameWithMatrix);
|
||||
RELEASE(nameWithMatrix);
|
||||
RELEASE(fontName);
|
||||
|
@ -697,7 +760,7 @@ setNSFont(NSString* key, NSFont* font)
|
|||
NSString *description;
|
||||
|
||||
nameWithMatrix = newNameWithMatrix(fontName, matrix, matrixExplicitlySet,
|
||||
screenFont);
|
||||
screenFont, role);
|
||||
description = [[super description] stringByAppendingFormat: @" %@",
|
||||
nameWithMatrix];
|
||||
RELEASE(nameWithMatrix);
|
||||
|
@ -748,7 +811,8 @@ setNSFont(NSString* key, NSFont* font)
|
|||
return AUTORELEASE([placeHolder initWithName: fontName
|
||||
matrix: fontMatrix
|
||||
fix: YES
|
||||
screenFont: screenFont]);
|
||||
screenFont: screenFont
|
||||
role: role]);
|
||||
}
|
||||
|
||||
static BOOL flip_hack;
|
||||
|
@ -802,7 +866,8 @@ static BOOL flip_hack;
|
|||
return [placeHolder initWithName: fontName
|
||||
matrix: matrix
|
||||
fix: matrixExplicitlySet
|
||||
screenFont: NO];
|
||||
screenFont: NO
|
||||
role: role];
|
||||
}
|
||||
- (NSFont*) screenFont
|
||||
{
|
||||
|
@ -811,7 +876,8 @@ static BOOL flip_hack;
|
|||
return [placeHolder initWithName: fontName
|
||||
matrix: matrix
|
||||
fix: matrixExplicitlySet
|
||||
screenFont: YES];
|
||||
screenFont: YES
|
||||
role: role];
|
||||
}
|
||||
|
||||
- (float) ascender { return [fontInfo ascender]; }
|
||||
|
@ -948,9 +1014,19 @@ static BOOL flip_hack;
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: fontName];
|
||||
[aCoder encodeArrayOfObjCType: @encode(float) count: 6 at: matrix];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet];
|
||||
printf("encoding role %i\n",role);
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &role];
|
||||
|
||||
if (role == 0)
|
||||
{
|
||||
[aCoder encodeObject: fontName];
|
||||
[aCoder encodeArrayOfObjCType: @encode(float) count: 6 at: matrix];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &matrixExplicitlySet];
|
||||
}
|
||||
else if (role & 1)
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &matrix[0]];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
@ -959,30 +1035,121 @@ static BOOL flip_hack;
|
|||
id name;
|
||||
float fontMatrix[6];
|
||||
BOOL fix;
|
||||
int the_role;
|
||||
|
||||
name = [aDecoder decodeObject];
|
||||
[aDecoder decodeArrayOfObjCType: @encode(float)
|
||||
count: 6
|
||||
at: fontMatrix];
|
||||
if (version == currentVersion)
|
||||
printf("[NSFont -initWithCoder:] version %i\n",version);
|
||||
if (version == 3)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &fix];
|
||||
[aDecoder decodeValueOfObjCType: @encode(int)
|
||||
at: &the_role];
|
||||
printf("got explicit role %i\n",the_role);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fontMatrix[0] == fontMatrix[3]
|
||||
&& fontMatrix[1] == 0.0 && fontMatrix[2] == 0.0)
|
||||
fix = NO;
|
||||
else
|
||||
fix = YES;
|
||||
the_role = RoleExplicit;
|
||||
}
|
||||
|
||||
self = [self initWithName: name
|
||||
matrix: fontMatrix
|
||||
fix: fix
|
||||
screenFont: NO];
|
||||
return self;
|
||||
if (the_role == RoleExplicit)
|
||||
{
|
||||
/* The easy case: an explicit font, or a font encoded with
|
||||
version <= 2. */
|
||||
name = [aDecoder decodeObject];
|
||||
[aDecoder decodeArrayOfObjCType: @encode(float)
|
||||
count: 6
|
||||
at: fontMatrix];
|
||||
|
||||
if (version >= 2)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &fix];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fontMatrix[0] == fontMatrix[3]
|
||||
&& fontMatrix[1] == 0.0 && fontMatrix[2] == 0.0)
|
||||
fix = NO;
|
||||
else
|
||||
fix = YES;
|
||||
}
|
||||
|
||||
self = [self initWithName: name
|
||||
matrix: fontMatrix
|
||||
fix: fix
|
||||
screenFont: NO
|
||||
role: RoleExplicit];
|
||||
if (self)
|
||||
return self;
|
||||
|
||||
self = [isa userFontOfSize: fontMatrix[0]];
|
||||
NSAssert(self != nil, @"Couldn't find a valid font when decoding.");
|
||||
return self;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A non-explicit font. */
|
||||
float size;
|
||||
NSFont *new;
|
||||
|
||||
if (the_role & 1)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(float)
|
||||
at: &size];
|
||||
}
|
||||
else
|
||||
{
|
||||
size = 0.0;
|
||||
}
|
||||
|
||||
switch (the_role >> 1)
|
||||
{
|
||||
case RoleBoldSystemFont:
|
||||
new = [isa boldSystemFontOfSize: size];
|
||||
break;
|
||||
case RoleSystemFont:
|
||||
new = [isa systemFontOfSize: size];
|
||||
break;
|
||||
case RoleUserFixedPitchFont:
|
||||
new = [isa userFixedPitchFontOfSize: size];
|
||||
break;
|
||||
case RoleTitleBarFont:
|
||||
new = [isa titleBarFontOfSize: size];
|
||||
break;
|
||||
case RoleMenuFont:
|
||||
new = [isa menuFontOfSize: size];
|
||||
break;
|
||||
case RoleMessageFont:
|
||||
new = [isa messageFontOfSize: size];
|
||||
break;
|
||||
case RolePaletteFont:
|
||||
new = [isa paletteFontOfSize: size];
|
||||
break;
|
||||
case RoleToolTipsFont:
|
||||
new = [isa toolTipsFontOfSize: size];
|
||||
break;
|
||||
case RoleControlContentFont:
|
||||
new = [isa controlContentFontOfSize: size];
|
||||
break;
|
||||
case RoleLabelFont:
|
||||
new = [isa labelFontOfSize: size];
|
||||
break;
|
||||
|
||||
default:
|
||||
// NSDebugLLog(@"NSFont", @"unknown role %i", the_role);
|
||||
printf("unknown role %i", the_role);
|
||||
/* fall through */
|
||||
case RoleUserFont:
|
||||
new = [isa userFontOfSize: size];
|
||||
break;
|
||||
}
|
||||
|
||||
[self release];
|
||||
if (new)
|
||||
return new;
|
||||
|
||||
new = [isa userFontOfSize: size];
|
||||
NSAssert(new != nil, @"Couldn't find a valid font when decoding.");
|
||||
return new;
|
||||
}
|
||||
}
|
||||
|
||||
@end /* NSFont */
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSBox.h>
|
||||
|
||||
#define _SAVE_PANEL_X_PAD 5
|
||||
#define _SAVE_PANEL_Y_PAD 4
|
||||
|
||||
static inline void _setFloatValue (NSTextField *field, float size)
|
||||
{
|
||||
/* If casting size to int and then back to float we get no change,
|
||||
|
@ -88,6 +91,7 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
- (void) _doPreview;
|
||||
- (void) ok: (id) sender;
|
||||
|
||||
- (void) _getOriginalSize;
|
||||
- (id)_initWithoutGModel;
|
||||
@end
|
||||
|
||||
|
@ -133,6 +137,7 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
_face = -1;
|
||||
_family = -1;
|
||||
[self reloadDefaultFontFamilies];
|
||||
[self _getOriginalSize];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -304,8 +309,10 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
return _accessoryView;
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) setAccessoryView: (NSView*)aView
|
||||
{
|
||||
|
||||
// FIXME: We have to resize
|
||||
// Perhaps we could copy the code from NSSavePanel over to here
|
||||
if (_accessoryView != nil)
|
||||
|
@ -316,6 +323,121 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
ASSIGN(_accessoryView, aView);
|
||||
[[self contentView] addSubview: aView];
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) _getOriginalSize
|
||||
{
|
||||
/* Used in setMinSize: */
|
||||
_originalMinSize = [self minSize];
|
||||
/* Used in setContentSize: */
|
||||
_originalSize = [[self contentView] frame].size;
|
||||
}
|
||||
|
||||
- (void) setAccessoryView: (NSView*)aView
|
||||
{
|
||||
NSRect accessoryViewFrame, bottomFrame;
|
||||
NSRect tmpRect;
|
||||
NSSize contentSize, contentMinSize;
|
||||
float addedHeight, accessoryWidth;
|
||||
|
||||
if (aView == _accessoryView)
|
||||
return;
|
||||
|
||||
/* The following code is very tricky. Please think and test a lot
|
||||
before changing it. */
|
||||
|
||||
/* Remove old accessory view if any */
|
||||
if (_accessoryView != nil)
|
||||
{
|
||||
/* Remove accessory view */
|
||||
accessoryViewFrame = [_accessoryView frame];
|
||||
[_accessoryView removeFromSuperview];
|
||||
|
||||
/* Change the min size before doing the resizing otherwise it
|
||||
could be a problem. */
|
||||
[self setMinSize: _originalMinSize];
|
||||
|
||||
/* Resize the panel to the height without the accessory view.
|
||||
This must be done with the special care of not resizing
|
||||
the heights of the other views. */
|
||||
addedHeight = accessoryViewFrame.size.height + (_SAVE_PANEL_Y_PAD * 2);
|
||||
contentSize = [[self contentView] frame].size;
|
||||
contentSize.height -= addedHeight;
|
||||
// Resize without modifying topView and bottomView height.
|
||||
[_topView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||
[self setContentSize: contentSize];
|
||||
[_topView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
|
||||
}
|
||||
|
||||
/* Resize the panel to its original size. This resizes freely the
|
||||
heights of the views. NB: minSize *must* come first */
|
||||
[self setMinSize: _originalMinSize];
|
||||
[self setContentSize: _originalSize];
|
||||
|
||||
/* Set the new accessory view */
|
||||
_accessoryView = aView;
|
||||
|
||||
/* If there is a new accessory view, plug it in */
|
||||
if (_accessoryView != nil)
|
||||
{
|
||||
/* Make sure the new accessory view behaves - its height must be fixed
|
||||
* and its position relative to the bottom of the superview must not
|
||||
* change - so its position rlative to the top must be changable. */
|
||||
[_accessoryView setAutoresizingMask: NSViewMaxYMargin
|
||||
| ([_accessoryView autoresizingMask]
|
||||
& ~(NSViewHeightSizable | NSViewMinYMargin))];
|
||||
|
||||
/* Compute size taken by the new accessory view */
|
||||
accessoryViewFrame = [_accessoryView frame];
|
||||
addedHeight = accessoryViewFrame.size.height + (_SAVE_PANEL_Y_PAD * 2);
|
||||
accessoryWidth = accessoryViewFrame.size.width + (_SAVE_PANEL_X_PAD * 2);
|
||||
|
||||
/* Resize content size accordingly */
|
||||
contentSize = _originalSize;
|
||||
contentSize.height += addedHeight;
|
||||
if (accessoryWidth > contentSize.width)
|
||||
{
|
||||
contentSize.width = accessoryWidth;
|
||||
}
|
||||
|
||||
/* Set new content size without resizing heights of topView, bottomView */
|
||||
// Our views should resize horizontally if needed, but not vertically
|
||||
[_topView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
|
||||
[self setContentSize: contentSize];
|
||||
// Restore the original autoresizing masks
|
||||
[_topView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
|
||||
|
||||
/* Compute new min size */
|
||||
contentMinSize = _originalMinSize;
|
||||
contentMinSize.height += addedHeight;
|
||||
// width is more delicate
|
||||
tmpRect = NSMakeRect (0, 0, contentMinSize.width, contentMinSize.height);
|
||||
tmpRect = [NSWindow contentRectForFrameRect: tmpRect
|
||||
styleMask: [self styleMask]];
|
||||
if (accessoryWidth > tmpRect.size.width)
|
||||
{
|
||||
contentMinSize.width += accessoryWidth - tmpRect.size.width;
|
||||
}
|
||||
// Set new min size
|
||||
[self setMinSize: contentMinSize];
|
||||
|
||||
/*
|
||||
* Pack the Views
|
||||
*/
|
||||
|
||||
/* BottomView is ready */
|
||||
bottomFrame = [_bottomView frame];
|
||||
|
||||
/* AccessoryView */
|
||||
accessoryViewFrame.origin.x
|
||||
= (contentSize.width - accessoryViewFrame.size.width) / 2;
|
||||
accessoryViewFrame.origin.y = NSMaxY (bottomFrame) + _SAVE_PANEL_Y_PAD;
|
||||
[_accessoryView setFrameOrigin: accessoryViewFrame.origin];
|
||||
|
||||
/* Add the accessory view */
|
||||
[[self contentView] addSubview: _accessoryView];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* NSCoding protocol
|
||||
|
@ -417,6 +539,7 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
// preview and selection
|
||||
topArea = [[NSView alloc] initWithFrame: topAreaRect];
|
||||
[topArea setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
_topView = topArea;
|
||||
|
||||
splitView = [[NSSplitView alloc] initWithFrame: splitViewRect];
|
||||
[splitView setVertical: NO];
|
||||
|
@ -541,6 +664,7 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
|
||||
// action buttons
|
||||
bottomArea = [[NSView alloc] initWithFrame: bottomAreaRect];
|
||||
_bottomView = bottomArea;
|
||||
|
||||
slash = [[NSBox alloc] initWithFrame: slashRect];
|
||||
[slash setBorderType: NSGrooveBorder];
|
||||
|
|
Loading…
Reference in a new issue