Modifications to allow changes of color to guidelines (for now). More configurability to come. :)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19142 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-04-18 04:07:06 +00:00
parent 633963751f
commit 0116f965e4
14 changed files with 337 additions and 5 deletions

View file

@ -1,3 +1,13 @@
2004-04-17 11:55 Gregory John Casamento <greg_casamento@yahoo.com>
* Resources/GormPrefColors.gorm: New gorm file for color
preferences.
* GormColorsPref.[hm]: new class to implement color
preferences.
* GormViewEditor.m: Added code to allow the color of guidelines
to be changed in preferences.
* Defaults.plist: Added entry for GuideColor. The default is red.
2004-04-17 13:11 Gregory John Casamento <greg_casamento@yahoo.com>
* Palettes/3Containers/inspectors.m: Added code to the

View file

@ -5,4 +5,10 @@
HeaderList = ();
CellSizeWidth = 72;
ArchiveType = Typed;
GuideColor = {
alpha = 1;
blue = 0;
green = 0;
red = 1;
};
}

View file

@ -117,6 +117,7 @@ Gorm_RESOURCE_FILES = \
Images/GormView.tiff \
Images/LeftArr.tiff \
Images/RightArr.tiff \
Resources/GormPrefColors.gorm \
Resources/GormViewSizeInspector.gorm \
Resources/GormCustomClassInspector.gorm \
Resources/GormSoundInspector.gorm \
@ -167,7 +168,8 @@ Gorm_HEADERS = \
GormSetNameController.h \
GormGeneralPref.h \
GormFunctions.h \
GormShelfPref.h
GormShelfPref.h \
GormColorsPref.h
Gorm_OBJC_FILES = \
Gorm.m \
@ -212,7 +214,8 @@ Gorm_OBJC_FILES = \
GormSetNameController.m \
GormGeneralPref.m \
GormFunctions.m \
GormShelfPref.m
GormShelfPref.m \
GormColorsPref.m
-include GNUmakefile.preamble

19
GormColorsPref.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef INCLUDED_GormColorsPref_h
#define INCLUDED_GormColorsPref_h
#include <Foundation/NSObject.h>
#include <Foundation/NSArray.h>
#include <AppKit/NSView.h>
@interface GormColorsPref : NSObject
{
id color;
id window;
id _view;
}
- (NSView *) view;
- (void)ok: (id)sender;
@end
#endif

57
GormColorsPref.m Normal file
View file

@ -0,0 +1,57 @@
#include "GormColorsPref.h"
#include "GormFunctions.h"
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSNibLoading.h>
#include <AppKit/NSColorWell.h>
#include <AppKit/NSColor.h>
@implementation GormColorsPref
- (id) init
{
_view = nil;
self = [super init];
if(self != nil)
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSColor *aColor = colorFromDict([defaults objectForKey: @"GuideColor"]);
// default the color to something, if nothing is returned.
if(aColor == nil)
{
aColor = [NSColor redColor];
}
if ( ! [NSBundle loadNibNamed:@"GormPrefColors" owner:self] )
{
NSLog(@"Can not load bundle GormPrefColors");
return nil;
}
[color setColor: aColor];
_view = [[window contentView] retain];
}
return self;
}
- (void) dealloc
{
TEST_RELEASE(_view);
[super dealloc];
}
-(NSView *) view
{
return _view;
}
- (void) ok: (id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject: colorToDict([color color]) forKey: @"GuideColor"];
}
@end

View file

@ -44,7 +44,9 @@
[self setAlignment: NSCenterTextAlignment];
[self setFont: [NSFont boldSystemFontOfSize: 0]];
[self setEditable: NO];
[self setSelectable: NO];
[self setClassName: @"CustomView"];
return self;
}
@ -53,6 +55,11 @@
return @"GormFilesOwnerInspector";
}
- (NSString*) classInspectorClassName
{
return @"GormFilesOwnerInspector";
}
- (void) setClassName: (NSString *)aName
{
[self setStringValue: aName];

View file

@ -27,6 +27,8 @@
#include <AppKit/AppKit.h>
// @class NSDictionary;
// find all subitems for the given items...
void findAllWithArray(id item, NSMutableArray *array);
@ -48,4 +50,10 @@ NSString *cutFileLabelText(NSString *filename, id label, int length);
// get the cell size for all editors
NSSize defaultCellSize();
// color from string
NSColor *colorFromDict(NSDictionary *colorString);
// color to string
NSDictionary *colorToDict(NSColor *color);
#endif

View file

@ -25,6 +25,7 @@
#include "GormFunctions.h"
#include "GormViewEditor.h"
#include <AppKit/AppKit.h>
#include <Foundation/NSDictionary.h>
// find all subitems for the given items...
void findAllWithArray(id item, NSMutableArray *array)
@ -173,3 +174,46 @@ NSSize defaultCellSize()
NSSize size = NSMakeSize(width, 72);
return size;
}
NSColor *colorFromDict(NSDictionary *dict)
{
if(dict != nil)
{
return [NSColor colorWithCalibratedRed: [[dict objectForKey: @"red"] floatValue]
green: [[dict objectForKey: @"green"] floatValue]
blue: [[dict objectForKey: @"blue"] floatValue]
alpha: [[dict objectForKey: @"alpha"] floatValue]];
}
return nil;
}
NSDictionary *colorToDict(NSColor *color)
{
if(color != nil)
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
float red, green, blue, alpha;
NSNumber *fred = nil;
NSNumber *fgreen = nil;
NSNumber *fblue = nil;
NSNumber *falpha = nil;
[color getRed: &red
green: &green
blue: &blue
alpha: &alpha];
fred = [NSNumber numberWithFloat: red];
fgreen = [NSNumber numberWithFloat: green];
fblue = [NSNumber numberWithFloat: blue];
falpha = [NSNumber numberWithFloat: alpha];
[dict setObject: fred forKey: @"red"];
[dict setObject: fgreen forKey: @"green"];
[dict setObject: fblue forKey: @"blue"];
[dict setObject: falpha forKey: @"alpha"];
return dict;
}
return nil;
}

View file

@ -14,6 +14,7 @@
id _generalView;
id _headersView;
id _shelfView;
id _colorsView;
}
- (void) popupAction: (id)sender;

View file

@ -2,6 +2,7 @@
#include "GormGeneralPref.h"
#include "GormHeadersPref.h"
#include "GormShelfPref.h"
#include "GormColorsPref.h"
#include <AppKit/NSBox.h>
#include <AppKit/NSPopUpButton.h>
@ -15,7 +16,7 @@
_generalView = [[GormGeneralPref alloc] init];
_headersView = [[GormHeadersPref alloc] init];
_shelfView = [[GormShelfPref alloc] init];
_colorsView = [[GormColorsPref alloc] init];
[prefBox setContentView:[_generalView view]];
[[self window] setFrameUsingName: @"Preferences"];
@ -41,6 +42,9 @@
case 2:
[prefBox setContentView: [_shelfView view]];
break;
case 3:
[prefBox setContentView: [_colorsView view]];
break;
default:
NSLog(@"Ouch Default : - (void) popupAction: (id)sender");
break;

View file

@ -23,6 +23,7 @@
*/
#include <AppKit/AppKit.h>
#include <Foundation/NSUserDefaults.h>
#include "GormPrivate.h"
#include "GormViewEditor.h"
@ -737,7 +738,16 @@ static BOOL currently_displaying = NO;
rightOfFrame - leftOfFrame,
topOfFrame - bottomOfFrame);
{
[[NSColor redColor] set];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSColor *aColor = colorFromDict([defaults objectForKey: @"GuideColor"]);
// default to the right color...
if(aColor == nil)
{
aColor = [NSColor redColor];
}
[aColor set];
if (!leftEmpty)
{
leftStart = MIN(NSMinY(gpi->hintFrame), leftStart);
@ -1046,7 +1056,16 @@ static BOOL currently_displaying = NO;
topOfFrame - bottomOfFrame);
{
[[NSColor redColor] set];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSColor *aColor = colorFromDict([defaults objectForKey: @"GuideColor"]);
// default to the right color...
if(aColor == nil)
{
aColor = [NSColor redColor];
}
[aColor set];
if (!leftEmpty)
{
leftStart = MIN(NSMinY(gpi->hintFrame), leftStart);

View file

@ -0,0 +1,154 @@
{
FirstResponder = {
Actions = (
"activateContextHelpMode:",
"alignCenter:",
"alignJustified:",
"alignLeft:",
"alignRight:",
"arrangeInFront:",
"cancel:",
"capitalizeWord:",
"changeColor:",
"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:",
"open:",
"openDocument:",
"orderBack:",
"orderFront:",
"orderFrontColorPanel:",
"orderFrontDataLinkPanel:",
"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:",
"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;
};
GormColorsPref = {
Actions = (
"ok:"
);
Outlets = (
color,
window,
_view
);
Super = NSObject;
};
}

Binary file not shown.