1/* 2 Project: Graphos 3 Graphos.m 4 5 Copyright (C) 2000-2018 GNUstep Application Project 6 7 Author: Enrico Sersale (original implementation) 8 Author: Ing. Riccardo Mottola 9 10 This application is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public 12 License as published by the Free Software Foundation; either 13 version 2 of the License, or (at your option) any later version. 14 15 This application is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 Library General Public License for more details. 19 20 You should have received a copy of the GNU General Public 21 License along with this library; if not, write to the Free 22 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 */ 24 25#import "Graphos.h" 26#import "GRFunctions.h" 27#import "GRDocument.h" 28 29@implementation Graphos 30 31- (id) init 32{ 33 if ((self = [super init])) 34 { 35 [[NSNotificationCenter defaultCenter] addObserver:self 36 selector:@selector(mainWindowChanged:) 37 name:NSWindowDidBecomeMainNotification object:nil]; 38 [[NSNotificationCenter defaultCenter] addObserver:self 39 selector:@selector(mainWindowResigned:) 40 name:NSWindowDidResignMainNotification object:nil]; 41 objectInspector = nil; 42 } 43 return self; 44} 45 46- (void)dealloc 47{ 48 [tools release]; 49 [objectInspector release]; 50 [super dealloc]; 51} 52 53- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 54{ 55 tools = [[GRToolsWindow alloc] init]; 56 [tools display]; 57 [tools orderFront:nil]; 58} 59 60- (IBAction)showObjectInspector: (id)sender 61{ 62 if (objectInspector == nil) 63 objectInspector = [[GRPropsEditor alloc] init]; 64 [objectInspector setDocView: [[[NSDocumentController sharedDocumentController] currentDocument] docView]]; 65 [objectInspector readProperties]; 66 [objectInspector makeKeyAndOrderFront: sender]; 67} 68 69- (GRPropsEditor *)objectInspector 70{ 71 return objectInspector; 72} 73 74- (void)setToolType:(ToolType)type 75{ 76 tooltype = type; 77 [tools setButtonsPositions: tooltype]; 78} 79 80- (ToolType)currentToolType 81{ 82 return tooltype; 83} 84 85// FIXME This is pretty ugly. GRText is the only thing that uses 86// it. maybe its possible to get rid of it. 87- (void)updateCurrentWindow 88{ 89 NSWindow *curWin = [[[[[NSDocumentController sharedDocumentController] currentDocument] windowControllers] objectAtIndex: 0] window]; 90 [curWin display]; 91} 92 93/* notification */ 94- (void)mainWindowChanged :(NSNotification *)notif 95{ 96 [objectInspector setDocView: [[[NSDocumentController sharedDocumentController] currentDocument] docView]]; 97 [[NSNotificationCenter defaultCenter] postNotificationName:@"ObjectSelectionChanged" object:self]; 98} 99 100/* notification */ 101- (void)mainWindowResigned :(NSNotification *)notif 102{ 103 [objectInspector setDocView: nil]; 104 [[NSNotificationCenter defaultCenter] postNotificationName:@"ObjectSelectionChanged" object:self]; 105} 106 107 108@end 109 110#if !defined (GNUSTEP) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) 111 112@implementation NSString (TigerExtensions) 113- (BOOL) boolValue 114{ 115 if (self != nil && [self length] > 0) 116 { 117 if([self characterAtIndex:0] == 'Y' || [self characterAtIndex:0] == 'y') 118 return YES; 119 if([self characterAtIndex:0] == 'T' || [self characterAtIndex:0] == 't') 120 return YES; 121 } 122 123 return NO; 124} 125@end 126 127#endif 128