diff --git a/ChangeLog b/ChangeLog index e1f8c845..27ff7a54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-04-17 11:55 Gregory John Casamento + + * 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 * Palettes/3Containers/inspectors.m: Added code to the diff --git a/Defaults.plist b/Defaults.plist index 9ab2c894..619bddc2 100644 --- a/Defaults.plist +++ b/Defaults.plist @@ -5,4 +5,10 @@ HeaderList = (); CellSizeWidth = 72; ArchiveType = Typed; + GuideColor = { + alpha = 1; + blue = 0; + green = 0; + red = 1; + }; } diff --git a/GNUmakefile b/GNUmakefile index 430130a7..1230063c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 diff --git a/GormColorsPref.h b/GormColorsPref.h new file mode 100644 index 00000000..14d46d5f --- /dev/null +++ b/GormColorsPref.h @@ -0,0 +1,19 @@ +#ifndef INCLUDED_GormColorsPref_h +#define INCLUDED_GormColorsPref_h + +#include +#include + +#include + +@interface GormColorsPref : NSObject +{ + id color; + id window; + id _view; +} +- (NSView *) view; +- (void)ok: (id)sender; +@end + +#endif diff --git a/GormColorsPref.m b/GormColorsPref.m new file mode 100644 index 00000000..07fa1e83 --- /dev/null +++ b/GormColorsPref.m @@ -0,0 +1,57 @@ +#include "GormColorsPref.h" +#include "GormFunctions.h" + +#include +#include +#include +#include +#include + +@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 diff --git a/GormCustomView.m b/GormCustomView.m index d2f3dac7..e5e348aa 100644 --- a/GormCustomView.m +++ b/GormCustomView.m @@ -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]; diff --git a/GormFunctions.h b/GormFunctions.h index b782502b..16ec4e44 100644 --- a/GormFunctions.h +++ b/GormFunctions.h @@ -27,6 +27,8 @@ #include +// @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 diff --git a/GormFunctions.m b/GormFunctions.m index 84d598b9..0e03b816 100644 --- a/GormFunctions.m +++ b/GormFunctions.m @@ -25,6 +25,7 @@ #include "GormFunctions.h" #include "GormViewEditor.h" #include +#include // 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; +} diff --git a/GormPrefController.h b/GormPrefController.h index aefa4a78..12f80f70 100644 --- a/GormPrefController.h +++ b/GormPrefController.h @@ -14,6 +14,7 @@ id _generalView; id _headersView; id _shelfView; + id _colorsView; } - (void) popupAction: (id)sender; diff --git a/GormPrefController.m b/GormPrefController.m index e491f9db..4c783fa6 100644 --- a/GormPrefController.m +++ b/GormPrefController.m @@ -2,6 +2,7 @@ #include "GormGeneralPref.h" #include "GormHeadersPref.h" #include "GormShelfPref.h" +#include "GormColorsPref.h" #include #include @@ -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; diff --git a/GormViewEditor.m b/GormViewEditor.m index e6d8fc61..44d7b0f2 100644 --- a/GormViewEditor.m +++ b/GormViewEditor.m @@ -23,6 +23,7 @@ */ #include +#include #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); diff --git a/Resources/GormPrefColors.gorm/data.classes b/Resources/GormPrefColors.gorm/data.classes new file mode 100644 index 00000000..198b9eb4 --- /dev/null +++ b/Resources/GormPrefColors.gorm/data.classes @@ -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; + }; +} \ No newline at end of file diff --git a/Resources/GormPrefColors.gorm/objects.gorm b/Resources/GormPrefColors.gorm/objects.gorm new file mode 100644 index 00000000..e59ea75e Binary files /dev/null and b/Resources/GormPrefColors.gorm/objects.gorm differ diff --git a/Resources/GormPreferences.gorm/objects.gorm b/Resources/GormPreferences.gorm/objects.gorm index d4b35c38..c6049b2b 100644 Binary files a/Resources/GormPreferences.gorm/objects.gorm and b/Resources/GormPreferences.gorm/objects.gorm differ