From 8408fed8718c5aafc89a7e22c3791904d505a425 Mon Sep 17 00:00:00 2001 From: Johan Paulsson Date: Tue, 26 Feb 2013 21:13:20 +0000 Subject: osx gui initial preferences panel with defaults support --- tikzit/English.lproj/MainMenu.xib | 378 +++++++++--------- tikzit/English.lproj/Preamble.xib | 334 ++++++---------- tikzit/English.lproj/UserDefaults.plist | 8 + tikzit/TikZiT.xcodeproj/project.pbxproj | 22 + tikzit/src/osx/AppDelegate.h | 4 + tikzit/src/osx/AppDelegate.m | 40 ++ tikzit/src/osx/PreferenceController.h | 21 + tikzit/src/osx/PreferenceController.m | 103 +++++ tikzit/src/osx/Preferences.xib | 684 ++++++++++++++++++++++++++++++++ 9 files changed, 1193 insertions(+), 401 deletions(-) create mode 100644 tikzit/English.lproj/UserDefaults.plist create mode 100644 tikzit/src/osx/PreferenceController.h create mode 100644 tikzit/src/osx/PreferenceController.m create mode 100644 tikzit/src/osx/Preferences.xib diff --git a/tikzit/English.lproj/MainMenu.xib b/tikzit/English.lproj/MainMenu.xib index 423079b..4ce33f0 100644 --- a/tikzit/English.lproj/MainMenu.xib +++ b/tikzit/English.lproj/MainMenu.xib @@ -1,35 +1,32 @@ - 1050 - 11C74 - 1617 - 1138.23 - 567.00 + 1080 + 12C60 + 2843 + 1187.34 + 625.00 com.apple.InterfaceBuilder.CocoaPlugin - 1617 + 2843 YES - NSView + NSButtonCell + NSCustomObject NSMatrix - NSWindowTemplate NSMenu NSMenuItem - NSButtonCell - NSCustomObject + NSView + NSWindowTemplate YES com.apple.InterfaceBuilder.CocoaPlugin - YES - - YES - - + PluginDependencyRecalculationVersion + YES @@ -837,7 +834,7 @@ - + 256 YES @@ -846,13 +843,15 @@ 268 {{2, 2}, {32, 134}} + YES + NO 4 1 YES - -2080244224 + -2080374784 0 @@ -861,7 +860,7 @@ 1044 - -1229176577 + -1229176832 6 NSImage @@ -873,12 +872,12 @@ 25 - 67239424 + 67108864 0 - -1229176577 + -1229176832 6 NSImage @@ -888,12 +887,12 @@ 75 - 67239424 + 67108864 0 - -1229176577 + -1229176832 6 NSImage @@ -903,12 +902,12 @@ 75 - 67239424 + 67108864 0 - -1229176577 + -1229176832 6 NSImage @@ -923,11 +922,11 @@ 1151868928 NSActionCell - 67239424 + 67108864 0 - -2034482945 + -2034483200 6 400 75 @@ -950,6 +949,8 @@ {36, 138} + + {{0, 0}, {1440, 878}} @@ -966,6 +967,30 @@ YES + + + terminate: + + + + 448 + + + + delegate + + + + 533 + + + + orderFrontStandardAboutPanel: + + + + 534 + performMiniaturize: @@ -1158,14 +1183,6 @@ 373 - - - terminate: - - - - 448 - performFindPanelAction: @@ -1198,46 +1215,6 @@ 494 - - - delegate - - - - 533 - - - - orderFrontStandardAboutPanel: - - - - 534 - - - - toolPalette - - - - 544 - - - - toolPaletteController - - - - 545 - - - - toolMatrix - - - - 546 - parseTikz: @@ -1304,19 +1281,59 @@ - checkForUpdates: - - + previewTikz: + + - 575 + 583 - previewTikz: + reverseEdgeDirection: - + - 583 + 596 + + + + bringForward: + + + + 608 + + + + bringToFront: + + + + 609 + + + + sendBackward: + + + + 612 + + + + sendToBack: + + + + 613 + + + + toolPaletteController + + + + 545 @@ -1352,43 +1369,35 @@ - reverseEdgeDirection: - - - - 596 - - - - bringForward: - - + togglePreferences: + + - 608 + 614 - - bringToFront: - - + + toolPalette + + - 609 + 544 - - sendBackward: - - + + toolMatrix + + - 612 + 546 - sendToBack: - - + checkForUpdates: + + - 613 + 575 @@ -1396,7 +1405,9 @@ YES 0 - + + YES + @@ -2214,7 +2225,7 @@ 83.IBPluginDependency 92.IBPluginDependency - + YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2368,7 +2379,7 @@ - 613 + 614 @@ -2382,15 +2393,17 @@ YES refreshShapes: togglePreamble: + togglePreferences: togglePropertyInspector: toggleStyleInspector: - + YES id id id id + id @@ -2399,10 +2412,11 @@ YES refreshShapes: togglePreamble: + togglePreferences: togglePropertyInspector: toggleStyleInspector: - + YES refreshShapes: @@ -2412,6 +2426,10 @@ togglePreamble: id + + togglePreferences: + id + togglePropertyInspector: id @@ -2430,7 +2448,7 @@ stylePaletteController toolPaletteController - + YES GraphicsView StylePaletteController @@ -2445,7 +2463,7 @@ stylePaletteController toolPaletteController - + YES graphicsView @@ -2478,7 +2496,7 @@ sendBackward: sendToBack: - + YES id id @@ -2497,7 +2515,7 @@ sendBackward: sendToBack: - + YES bringForward: @@ -2536,7 +2554,7 @@ application tikzSourceController - + YES NSApplication TikzSourceController @@ -2549,7 +2567,7 @@ application tikzSourceController - + YES application @@ -2567,70 +2585,29 @@ - NSDocument + IKImageView - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - id - id - id - id - id - id - + crop: + id - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - + crop: + + crop: + id IBProjectSource - ./Classes/NSDocument.h + ./Classes/IKImageView.h + + + + ParseErrorView + NSView + + IBProjectSource + ./Classes/ParseErrorView.h @@ -2688,7 +2665,7 @@ setFillToClosestHashed: setStrokeToClosestHashed: - + YES id id @@ -2715,7 +2692,7 @@ setFillToClosestHashed: setStrokeToClosestHashed: - + YES addEdgeStyle: @@ -2769,7 +2746,7 @@ nodeStyleView shapeDropdown - + YES NSCollectionView NSArrayController @@ -2796,7 +2773,7 @@ nodeStyleView shapeDropdown - + YES collectionView @@ -2844,16 +2821,31 @@ TikzSourceController NSObject + + closeParseError: + id + + + closeParseError: + + closeParseError: + id + + YES YES + errorMessage + errorNotification graphicsView sourceView status - + YES + NSTextField + ParseErrorView GraphicsView NSTextView NSTextField @@ -2863,12 +2855,22 @@ YES YES + errorMessage + errorNotification graphicsView sourceView status - + YES + + errorMessage + NSTextField + + + errorNotification + ParseErrorView + graphicsView GraphicsView @@ -2898,7 +2900,7 @@ toolMatrix toolPalette - + YES NSMatrix NSPanel @@ -2911,7 +2913,7 @@ toolMatrix toolPalette - + YES toolMatrix @@ -2932,10 +2934,6 @@ 0 IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 @@ -2953,10 +2951,10 @@ select-rectangular transform-crop-and-resize - + YES - {9, 8} - {7, 2} + {11, 11} + {10, 3} {22, 22} {22, 22} {22, 22} diff --git a/tikzit/English.lproj/Preamble.xib b/tikzit/English.lproj/Preamble.xib index c35ead1..f94131a 100644 --- a/tikzit/English.lproj/Preamble.xib +++ b/tikzit/English.lproj/Preamble.xib @@ -1,39 +1,42 @@ - 1050 - 11C74 - 1617 - 1138.23 - 567.00 + 1080 + 12C60 + 2843 + 1187.34 + 625.00 com.apple.InterfaceBuilder.CocoaPlugin - 1617 + 2843 - NSTableColumn - NSToolbar - NSScroller - NSSplitView - NSTextView NSButton - NSScrollView - NSTextFieldCell NSButtonCell + NSCustomObject + NSCustomView NSDictionaryController - NSToolbarSeparatorItem + NSScrollView + NSScroller + NSSplitView + NSTableColumn NSTableView - NSCustomView - NSCustomObject + NSTextFieldCell + NSTextView + NSToolbar + NSToolbarItem + NSToolbarSeparatorItem + NSUserDefaultsController NSView NSWindowTemplate - NSUserDefaultsController - NSToolbarItem com.apple.InterfaceBuilder.CocoaPlugin - + + PluginDependencyRecalculationVersion + + PreambleController @@ -169,7 +172,7 @@ - + @@ -194,11 +197,10 @@ 292 {{28, 3}, {26, 26}} - YES - -2080244224 + -2080374784 134217728 @@ -207,7 +209,7 @@ 1044 - -2033434369 + -2033434624 162 NSImage @@ -218,17 +220,17 @@ 400 75 + NO 292 {{3, 3}, {26, 26}} - YES - -2080244224 + -2080374784 134217728 @@ -237,7 +239,7 @@ 16 - -2032385793 + -2032386048 162 NSImage @@ -248,6 +250,7 @@ 400 75 + NO @@ -262,9 +265,10 @@ 256 {170, 388} - YES + NO + YES -2147483392 @@ -276,7 +280,7 @@ 40 1000 - 75628096 + 75497536 2048 Preambles @@ -299,7 +303,7 @@ - 337772096 + 337641536 2048 Text Cell @@ -355,7 +359,6 @@ {{1, 1}, {170, 388}} - @@ -366,8 +369,8 @@ -2147483392 {{224, 17}, {15, 102}} - + NO _doScroller: 0.99742930591259638 @@ -377,8 +380,8 @@ -2147483392 {{1, 119}, {223, 15}} - + NO 1 _doScroller: @@ -387,18 +390,19 @@ {{0, 31}, {172, 390}} - 133682 QSAAAEEgAABBmAAAQZgAAA + 0.25 + 4 + 1 {172, 421} - NSView @@ -417,28 +421,8 @@ 2322 - - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - NeXT font pasteboard type - NeXT ruler pasteboard type - WebURLsWithTitlesPboardType - public.url - - {469, 14} + {484, 419} - @@ -451,15 +435,15 @@ - 134 + 166 - 469 + 484 1 - 12135 + 67120999 0 @@ -495,13 +479,11 @@ 6 {495, 10000000} - {223, 5} - {{1, 1}, {469, 419}} + {{1, 1}, {484, 419}} - @@ -534,10 +516,9 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 256 - {{470, 1}, {15, 419}} + {{469, 1}, {16, 419}} - - + NO _doScroller: 1 @@ -548,8 +529,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA -2147483392 {{-100, -100}, {87, 18}} - + NO 1 _doScroller: @@ -559,34 +540,33 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {486, 421} - 133138 + 0.25 + 4 + 1 {{181, 0}, {486, 421}} - NSView {667, 421} - YES {667, 421} - - {{0, 0}, {1440, 878}} + {{0, 0}, {1600, 1200}} {10000000000000, 10000000000000} YES @@ -675,6 +655,50 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 33 + + + insertDefaultStyles: + + + + 38 + + + + preambleDictionaryController + + + + 93 + + + + addPreamble: + + + + 96 + + + + enabled: useDefaultPreamble + + + + + + enabled: useDefaultPreamble + enabled + useDefaultPreamble + + NSValueTransformerName + NSNegateBoolean + + 2 + + + 41 + attributedString: preambleText @@ -715,21 +739,13 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 37 - - - insertDefaultStyles: - - - - 38 - enabled: useDefaultPreamble - + - + enabled: useDefaultPreamble enabled @@ -741,35 +757,39 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 2 - 41 + 72 - - enabled: useDefaultPreamble - + + delegate + + + 97 + + + + value: arrangedObjects.key + + - - - enabled: useDefaultPreamble - enabled - useDefaultPreamble - - NSValueTransformerName - NSNegateBoolean - + + + value: arrangedObjects.key + value + arrangedObjects.key 2 - 65 + 77 enabled: useDefaultPreamble - + - + enabled: useDefaultPreamble enabled @@ -781,15 +801,15 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 2 - 68 + 65 enabled: useDefaultPreamble - + - + enabled: useDefaultPreamble enabled @@ -801,23 +821,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 2 - 72 - - - - value: arrangedObjects.key - - - - - - value: arrangedObjects.key - value - arrangedObjects.key - 2 - - - 77 + 68 @@ -859,30 +863,6 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 92 - - - preambleDictionaryController - - - - 93 - - - - addPreamble: - - - - 96 - - - - delegate - - - - 97 - @@ -1130,77 +1110,9 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 97 - - - - PreambleController - NSWindowController - - id - id - id - id - - - - addPreamble: - id - - - duplicatePreamble: - id - - - insertDefaultStyles: - id - - - setPreamble: - id - - - - NSToolbarItem - NSToolbarItem - NSDictionaryController - NSTextView - NSToolbar - - - - customToolbarItem - NSToolbarItem - - - defaultToolbarItem - NSToolbarItem - - - preambleDictionaryController - NSDictionaryController - - - textView - NSTextView - - - toolbar - NSToolbar - - - - IBProjectSource - ./Classes/PreambleController.h - - - - + 0 IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 @@ -1209,8 +1121,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 3 {8, 8} - {9, 8} - {7, 2} + {11, 11} + {10, 3} {8, 8} {32, 32} {32, 32} diff --git a/tikzit/English.lproj/UserDefaults.plist b/tikzit/English.lproj/UserDefaults.plist new file mode 100644 index 0000000..374f6ef --- /dev/null +++ b/tikzit/English.lproj/UserDefaults.plist @@ -0,0 +1,8 @@ + + + + + testDefaultsHandler + foo + + diff --git a/tikzit/TikZiT.xcodeproj/project.pbxproj b/tikzit/TikZiT.xcodeproj/project.pbxproj index bf8e930..33d7495 100644 --- a/tikzit/TikZiT.xcodeproj/project.pbxproj +++ b/tikzit/TikZiT.xcodeproj/project.pbxproj @@ -131,6 +131,9 @@ 7F6E2C8C16B00ABA00BFE20D /* SFBInspectors.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 55CA98D412EF8FCE008F0368 /* SFBInspectors.framework */; }; 7F781C1A16B5DE1400239826 /* ParseErrorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F781C1916B5DE1400239826 /* ParseErrorView.m */; }; 7F90E88616DD29600069EBCD /* NSString+Tikz.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F90E88516DD29600069EBCD /* NSString+Tikz.m */; }; + 7F90E88D16DD47540069EBCD /* PreferenceController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F90E88B16DD47540069EBCD /* PreferenceController.m */; }; + 7F90E88E16DD47540069EBCD /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7F90E88C16DD47540069EBCD /* Preferences.xib */; }; + 7F90E89116DD54440069EBCD /* UserDefaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7F90E88F16DD54440069EBCD /* UserDefaults.plist */; }; 7FB9BFEE16B57C2E00773146 /* TikzFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FB9BFED16B57C2E00773146 /* TikzFormatter.m */; }; 7FEED45716B1A7C500B056CB /* StyleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FEED45616B1A7C500B056CB /* StyleManager.m */; }; 8D15AC2C0486D014006FF6A4 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 2A37F4B9FDCFA73011CA2CEA /* Credits.rtf */; }; @@ -346,6 +349,10 @@ 7F781C1916B5DE1400239826 /* ParseErrorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ParseErrorView.m; path = src/osx/ParseErrorView.m; sourceTree = ""; }; 7F90E88416DD29600069EBCD /* NSString+Tikz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+Tikz.h"; path = "src/common/NSString+Tikz.h"; sourceTree = ""; }; 7F90E88516DD29600069EBCD /* NSString+Tikz.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+Tikz.m"; path = "src/common/NSString+Tikz.m"; sourceTree = ""; }; + 7F90E88A16DD47540069EBCD /* PreferenceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PreferenceController.h; path = src/osx/PreferenceController.h; sourceTree = ""; }; + 7F90E88B16DD47540069EBCD /* PreferenceController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PreferenceController.m; path = src/osx/PreferenceController.m; sourceTree = ""; }; + 7F90E88C16DD47540069EBCD /* Preferences.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = Preferences.xib; path = src/osx/Preferences.xib; sourceTree = ""; }; + 7F90E89016DD54440069EBCD /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = English; path = English.lproj/UserDefaults.plist; sourceTree = ""; }; 7FB9BFEC16B57C2E00773146 /* TikzFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TikzFormatter.h; path = src/osx/TikzFormatter.h; sourceTree = ""; }; 7FB9BFED16B57C2E00773146 /* TikzFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TikzFormatter.m; path = src/osx/TikzFormatter.m; sourceTree = ""; }; 7FEED45516B1A7C400B056CB /* StyleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleManager.h; path = src/common/StyleManager.h; sourceTree = ""; }; @@ -466,6 +473,7 @@ 55E5E99D1215C8E300256F69 /* transform-crop-and-resize.png */, 5573B98711DA377C00B5DC5D /* text-x-script.png */, 8D15AC360486D014006FF6A4 /* TikZiT-Info.plist */, + 7F90E88F16DD54440069EBCD /* UserDefaults.plist */, 089C165FFE840EACC02AAC07 /* InfoPlist.strings */, 2A37F4B9FDCFA73011CA2CEA /* Credits.rtf */, 55D949111165D8870044178C /* draw-ellipse.png */, @@ -477,6 +485,7 @@ 559EFA5611C7D95F00D020F4 /* tikzit_dsa_pub.pem */, 55D945701165904F0044178C /* tikzitdoc.icns */, 55D945711165904F0044178C /* tikzit.icns */, + 7F90E88C16DD47540069EBCD /* Preferences.xib */, 55391AF713D3250F007DBE71 /* Preamble.xib */, 55391AF513D324FE007DBE71 /* Preview.xib */, 55391B0013D32608007DBE71 /* PropertyInspector.xib */, @@ -647,6 +656,8 @@ 55CA997112F08281008F0368 /* TikzWindowController.m */, 553A4C58144ED3D500AA6FAC /* NilToEmptyStringTransformer.h */, 553A4C59144ED3D500AA6FAC /* NilToEmptyStringTransformer.m */, + 7F90E88A16DD47540069EBCD /* PreferenceController.h */, + 7F90E88B16DD47540069EBCD /* PreferenceController.m */, ); name = Gui; sourceTree = ""; @@ -802,6 +813,8 @@ 55397C8D1449ABFC006942FB /* AH_latex_tail.png in Resources */, 55397C901449AC7C006942FB /* AH_latex_head.png in Resources */, 55397C911449AC7C006942FB /* AH_plain_head.png in Resources */, + 7F90E88E16DD47540069EBCD /* Preferences.xib in Resources */, + 7F90E89116DD54440069EBCD /* UserDefaults.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -907,6 +920,7 @@ 7FB9BFEE16B57C2E00773146 /* TikzFormatter.m in Sources */, 7F781C1A16B5DE1400239826 /* ParseErrorView.m in Sources */, 7F90E88616DD29600069EBCD /* NSString+Tikz.m in Sources */, + 7F90E88D16DD47540069EBCD /* PreferenceController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -985,6 +999,14 @@ name = StylePalette.xib; sourceTree = ""; }; + 7F90E88F16DD54440069EBCD /* UserDefaults.plist */ = { + isa = PBXVariantGroup; + children = ( + 7F90E89016DD54440069EBCD /* English */, + ); + name = UserDefaults.plist; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/tikzit/src/osx/AppDelegate.h b/tikzit/src/osx/AppDelegate.h index 349b47b..64acc38 100644 --- a/tikzit/src/osx/AppDelegate.h +++ b/tikzit/src/osx/AppDelegate.h @@ -28,6 +28,7 @@ #import "PreambleController.h" #import "PreviewController.h" #import "GraphicsView.h" +#import "PreferenceController.h"; @interface AppDelegate : NSObject { NSMapTable *table; @@ -35,6 +36,7 @@ PropertyInspectorController *propertyInspectorController; PreambleController *preambleController; PreviewController *previewController; + PreferenceController *preferenceController; ToolPaletteController *toolPaletteController; IBOutlet GraphicsView *graphicsView; NSString *tempDir; @@ -44,10 +46,12 @@ @property IBOutlet ToolPaletteController *toolPaletteController; - (void)awakeFromNib; ++ (void)setDefaults; - (void)applicationWillTerminate:(NSNotification *)notification; - (IBAction)toggleStyleInspector:(id)sender; - (IBAction)togglePropertyInspector:(id)sender; - (IBAction)togglePreamble:(id)sender; +- (IBAction)togglePreferences:(id)sender; - (IBAction)refreshShapes:(id)sender; @end diff --git a/tikzit/src/osx/AppDelegate.m b/tikzit/src/osx/AppDelegate.m index bb1b5d6..ad1d407 100644 --- a/tikzit/src/osx/AppDelegate.m +++ b/tikzit/src/osx/AppDelegate.m @@ -31,6 +31,9 @@ @synthesize stylePaletteController, toolPaletteController; ++(void)initialize{ + [self setDefaults]; +} - (void)awakeFromNib { [TikzGraphAssembler setup]; // initialise lex/yacc parser globals @@ -66,11 +69,44 @@ [[PreviewController alloc] initWithWindowNibName:@"Preview" preambleController:preambleController tempDir:tempDir]; + + preferenceController = [[PreferenceController alloc] initWithWindowNibName:@"Preferences"]; // each application has one global preview controller [PreviewController setDefaultPreviewController:previewController]; } ++ (void)setDefaults{ + NSLog(@"Setting defaults..."); + + NSString *userDefaultsValuesPath; + NSDictionary *userDefaultsValuesDict; + NSDictionary *initialValuesDict; + NSArray *resettableUserDefaultsKeys; + + // load the default values for the user defaults + userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"UserDefaults" + ofType:@"plist"]; + userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath]; + + NSLog(@"Defaults dict: %@",userDefaultsValuesDict); + + // set them in the standard user defaults + [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict]; + + // if your application supports resetting a subset of the defaults to + // factory values, you should set those values + // in the shared user defaults controller + //resettableUserDefaultsKeys=[NSArray arrayWithObjects:@"Value1",@"Value2",@"Value3",nil]; + //initialValuesDict=[userDefaultsValuesDict dictionaryWithValuesForKeys:resettableUserDefaultsKeys]; + + // Set the initial values in the shared user defaults controller + //[[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initialValuesDict]; + + + NSLog(@"Done with defaults..."); +} + - (void)applicationWillTerminate:(NSNotification *)notification { NSString *supportDir = [SupportDir userSupportDir]; [stylePaletteController saveStyles:supportDir]; @@ -100,6 +136,10 @@ [self toggleController:preambleController]; } +- (IBAction)togglePreferences:(id)sender { + [self toggleController:preferenceController]; +} + - (IBAction)refreshShapes:(id)sender { [Shape refreshShapeDictionary]; } diff --git a/tikzit/src/osx/PreferenceController.h b/tikzit/src/osx/PreferenceController.h new file mode 100644 index 0000000..9143851 --- /dev/null +++ b/tikzit/src/osx/PreferenceController.h @@ -0,0 +1,21 @@ +// +// PreferenceController.h +// TikZiT +// +// Created by Karl Johan Paulsson on 26/02/2013. +// Copyright (c) 2013 Aleks Kissinger. All rights reserved. +// + +#import + +@interface PreferenceController : NSWindowController{ + + IBOutlet NSView *engineView; + IBOutlet NSView *generalView; + + int currentViewTag; +} + +- (IBAction)switchView:(id)sender; + +@end diff --git a/tikzit/src/osx/PreferenceController.m b/tikzit/src/osx/PreferenceController.m new file mode 100644 index 0000000..e2c9984 --- /dev/null +++ b/tikzit/src/osx/PreferenceController.m @@ -0,0 +1,103 @@ +// +// PreferenceController.m +// TikZiT +// +// Created by Karl Johan Paulsson on 26/02/2013. +// Copyright (c) 2013 Aleks Kissinger. All rights reserved. +// + +#import "PreferenceController.h" + +@interface PreferenceController () + +@end + +@implementation PreferenceController + +- (id)initWithWindow:(NSWindow *)window +{ + self = [super initWithWindow:window]; + if (self) { + // Initialization code here. + NSLog(@"preference controller is running..."); + NSLog(@"Test defaults: %@",[[NSUserDefaults standardUserDefaults] valueForKey:@"testDefaultsHandler"]); + } + + return self; +} + +- (void)windowDidLoad +{ + [super windowDidLoad]; + + // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. +} + +- (NSRect)newFrameForNewContentView:(NSView*)view { + + NSWindow *window = [self window]; + NSRect newFrameRect = [window frameRectForContentRect:[view frame]]; + NSRect oldFrameRect = [window frame]; + NSSize newSize = newFrameRect.size; + NSSize oldSize = oldFrameRect.size; + + NSRect frame = [window frame]; + frame.size = newSize; + frame.origin.y -= (newSize.height - oldSize.height); + + return frame; +} + +- (NSView *)viewForTag:(int)tag { + + NSView *view = nil; + switch (tag) { + default: + case 0: + view = generalView; + break; + case 1: + view = engineView; + break; + } + + return view; +} + +- (BOOL)validateToolbarItem:(NSToolbarItem *)item { + + if ([item tag] == currentViewTag) return NO; + else return YES; + +} + +- (void)awakeFromNib { + + [[self window] setContentSize:[generalView frame].size]; + [[[self window] contentView] addSubview:generalView]; + [[[self window] contentView] setWantsLayer:YES]; +} + +- (IBAction)switchView:(id)sender { + + int tag = [sender tag]; + NSView *view = [self viewForTag:tag]; + NSView *previousView = [self viewForTag:currentViewTag]; + currentViewTag = tag; + + NSRect newFrame = [self newFrameForNewContentView:view]; + + + [NSAnimationContext beginGrouping]; + + if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) + [[NSAnimationContext currentContext] setDuration:1.0]; + + [[[[self window] contentView] animator] replaceSubview:previousView with:view]; + [[[self window] animator] setFrame:newFrame display:YES]; + + [NSAnimationContext endGrouping]; + +} + +@end diff --git a/tikzit/src/osx/Preferences.xib b/tikzit/src/osx/Preferences.xib new file mode 100644 index 0000000..7184328 --- /dev/null +++ b/tikzit/src/osx/Preferences.xib @@ -0,0 +1,684 @@ + + + + 1080 + 12C60 + 2843 + 1187.34 + 625.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 2843 + + + IBNSLayoutConstraint + NSCustomObject + NSCustomView + NSTextField + NSTextFieldCell + NSToolbar + NSToolbarItem + NSUserDefaultsController + NSView + NSWindowTemplate + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + PreferenceController + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{196, 240}, {480, 270}} + 544735232 + Window + NSWindow + + + C1747407-DC9A-4297-9C1C-0A5010984E6C + + + YES + YES + NO + NO + 1 + 1 + + + + A3DDD070-5637-444B-92C6-905084CAC389 + + General + General + + + + NSImage + NSPreferencesGeneral + + + + {0, 0} + {0, 0} + YES + YES + 0 + YES + 0 + + + + F85FE7C2-9847-4E58-8BF6-BE334E918CA7 + + Engine + Engine + + + + + + {0, 0} + {0, 0} + YES + YES + 1 + YES + 0 + + + + + + + + + + + + + + + + 256 + {480, 270} + + + + + {{0, 0}, {1600, 1200}} + {10000000000000, 10000000000000} + YES + + + + 268 + + + + 268 + {{20, 32}, {96, 22}} + + + + _NS:9 + YES + + -1804599231 + 272630784 + + + LucidaGrande + 13 + 1044 + + _NS:9 + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + NO + + + + 268 + {{17, 69}, {47, 17}} + + + + _NS:1535 + YES + + 68157504 + 272630784 + Engine + + _NS:1535 + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + + + NO + + + {480, 96} + + + + _NS:9 + NSView + + + + 268 + + + + 268 + {{214, 40}, {53, 17}} + + + + _NS:1535 + YES + + 68157504 + 272630784 + General + + _NS:1535 + + + + + NO + + + {480, 96} + + + + _NS:9 + NSView + + + YES + + + + + + + window + + + + 3 + + + + engineView + + + + 23 + + + + generalView + + + + 25 + + + + switchView: + + + + 26 + + + + switchView: + + + + 27 + + + + delegate + + + + 4 + + + + value: values.testDefaultsHandlerOther + + + + + + value: values.testDefaultsHandlerOther + value + values.testDefaultsHandlerOther + 2 + + + 52 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + + + + + + + 2 + + + + + 5 + + + + + + + + + 11 + + + + + 12 + + + + + 13 + + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 42 + + 1000 + + 3 + 9 + 3 + + + + 3 + 0 + + 3 + 1 + + 10 + + 1000 + + 3 + 9 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + + + + + 14 + + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + + + + 15 + + + + + + + + 16 + + + + + 19 + + + + + + + + 20 + + + + + 28 + + + + + 29 + + + + + 30 + + + + + 31 + + + + + 32 + + + + + + 7 + 0 + + 0 + 1 + + 96 + + 1000 + + 3 + 9 + 1 + + + + + + 33 + + + + + 34 + + + + + 35 + + + + + 36 + + + + + 39 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{357, 418}, {480, 270}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 52 + + + + + PreferenceController + NSWindowController + + switchView: + id + + + switchView: + + switchView: + id + + + + NSView + NSView + + + + engineView + NSView + + + generalView + NSView + + + + IBProjectSource + ./Classes/PreferenceController.h + + + + + 0 + IBCocoaFramework + YES + 3 + + NSPreferencesGeneral + {32, 32} + + YES + + -- cgit v1.2.3