2005-08-06 17:59:08 +00:00
|
|
|
/*
|
|
|
|
GormTextFieldAttributesInspector.m
|
|
|
|
|
|
|
|
Copyright (C) 2001-2005 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Adam Fedor <fedor@gnu.org>
|
|
|
|
Laurent Julliard <laurent@julliard-online.org>
|
|
|
|
Date: Aug 2001
|
|
|
|
|
|
|
|
This file is part of GNUstep.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-11-05 23:44:36 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2005-08-06 17:59:08 +00:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
July 2005 : Split inspector classes into separate files.
|
|
|
|
Always use ok: revert: methods
|
|
|
|
Clean up
|
|
|
|
Author : Fabien Vallon <fabien@sonappart.net>
|
|
|
|
*/
|
|
|
|
|
2019-11-03 01:57:39 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#include <AppKit/AppKit.h>
|
2005-08-06 17:59:08 +00:00
|
|
|
|
2019-11-03 01:57:39 +00:00
|
|
|
#include <GormCore/GormCore.h>
|
2005-08-06 17:59:08 +00:00
|
|
|
|
2019-11-03 01:57:39 +00:00
|
|
|
#include "GormTextFieldAttributesInspector.h"
|
2005-08-06 17:59:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
IBObjectAdditions category
|
|
|
|
*/
|
|
|
|
|
|
|
|
@implementation NSTextField (IBObjectAdditions)
|
|
|
|
|
|
|
|
- (NSString*) inspectorClassName
|
|
|
|
{
|
|
|
|
return @"GormTextFieldAttributesInspector";
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation GormTextFieldAttributesInspector
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ([super init] == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
|
|
|
|
if ([NSBundle loadNibNamed: @"GormNSTextFieldInspector" owner: self] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"Could not gorm GormTextFieldInspector");
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Commit changes that the user makes in the Attributes Inspector */
|
|
|
|
- (void) ok: (id) sender
|
|
|
|
{
|
|
|
|
if (sender == alignMatrix)
|
|
|
|
{
|
|
|
|
[object setAlignment: (NSTextAlignment)[[sender selectedCell] tag]];
|
|
|
|
}
|
|
|
|
else if (sender == backgroundColor)
|
|
|
|
{
|
|
|
|
[object setBackgroundColor: [sender color]];
|
|
|
|
}
|
|
|
|
else if (sender == drawsBackground)
|
|
|
|
{
|
|
|
|
[object setDrawsBackground: [drawsBackground state]];
|
|
|
|
}
|
|
|
|
else if (sender == textColor)
|
|
|
|
{
|
|
|
|
[object setTextColor: [sender color]];
|
|
|
|
}
|
|
|
|
else if ( sender == editableSwitch )
|
|
|
|
{
|
2006-02-19 17:08:18 +00:00
|
|
|
[object setEditable: [editableSwitch state]];
|
2005-08-06 17:59:08 +00:00
|
|
|
}
|
|
|
|
else if ( sender == selectableSwitch )
|
|
|
|
{
|
2006-02-19 17:08:18 +00:00
|
|
|
[object setSelectable: [selectableSwitch state]];
|
2005-08-06 17:59:08 +00:00
|
|
|
}
|
|
|
|
else if ( sender == scrollableSwitch )
|
|
|
|
{
|
2006-02-19 17:08:18 +00:00
|
|
|
[[object cell] setScrollable: [scrollableSwitch state]];
|
2005-08-06 17:59:08 +00:00
|
|
|
}
|
|
|
|
else if (sender == borderMatrix)
|
|
|
|
{
|
2013-01-30 12:43:27 +00:00
|
|
|
BOOL bordered=NO, bezeled=NO;
|
2005-08-06 17:59:08 +00:00
|
|
|
|
|
|
|
if ([[sender cellAtRow: 0 column: 0] state] == NSOnState)
|
|
|
|
{
|
|
|
|
bordered = bezeled = NO;
|
|
|
|
}
|
|
|
|
else if ([[sender cellAtRow: 0 column: 1] state] == NSOnState)
|
|
|
|
{
|
|
|
|
bordered = YES;
|
|
|
|
bezeled = NO;
|
|
|
|
}
|
|
|
|
else if ([[sender cellAtRow: 0 column: 2] state] == NSOnState)
|
|
|
|
{
|
|
|
|
bordered = NO; bezeled = YES;
|
|
|
|
}
|
|
|
|
[object setBordered: bordered];
|
|
|
|
[object setBezeled: bezeled];
|
|
|
|
}
|
|
|
|
else if (sender == tagForm)
|
|
|
|
{
|
|
|
|
[object setTag: [[sender cellAtIndex: 0] intValue]];
|
|
|
|
}
|
2011-04-01 06:55:48 +00:00
|
|
|
else if (sender == sendActionMatrix)
|
|
|
|
{
|
|
|
|
BOOL sendActionOnEndEditing = ([[sender cellAtRow: 1 column: 0] state] == NSOnState);
|
|
|
|
[[object cell] setSendsActionOnEndEditing: sendActionOnEndEditing];
|
|
|
|
}
|
2019-04-14 04:26:47 +00:00
|
|
|
else if (sender == singleLineMode)
|
|
|
|
{
|
2019-04-15 07:42:44 +00:00
|
|
|
[[object cell] setUsesSingleLineMode: [singleLineMode state]];
|
2019-04-14 04:26:47 +00:00
|
|
|
}
|
2005-08-06 17:59:08 +00:00
|
|
|
|
|
|
|
[super ok:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sync from object ( NSTextField ) changes to the inspector */
|
|
|
|
- (void) revert:(id) sender
|
|
|
|
{
|
|
|
|
if (object == nil)
|
|
|
|
return;
|
|
|
|
|
|
|
|
[alignMatrix selectCellWithTag: [object alignment]];
|
|
|
|
[backgroundColor setColorWithoutAction: [object backgroundColor]];
|
|
|
|
[textColor setColorWithoutAction: [object textColor]];
|
|
|
|
[drawsBackground setState:
|
|
|
|
([object drawsBackground]) ? NSOnState : NSOffState];
|
|
|
|
|
|
|
|
[editableSwitch setState:[object isEditable]];
|
|
|
|
[selectableSwitch setState:[object isSelectable]];
|
|
|
|
[scrollableSwitch setState:[[object cell] isScrollable]];
|
2019-04-14 04:27:28 +00:00
|
|
|
[singleLineMode setState:[[object cell] usesSingleLineMode]];
|
2019-04-14 04:26:47 +00:00
|
|
|
|
2005-08-06 17:59:08 +00:00
|
|
|
if ([object isBordered] == YES)
|
|
|
|
{
|
|
|
|
[borderMatrix selectCellAtRow: 0 column: 1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([object isBezeled] == YES)
|
|
|
|
[borderMatrix selectCellAtRow: 0 column: 2];
|
|
|
|
else
|
|
|
|
[borderMatrix selectCellAtRow: 0 column: 0];
|
|
|
|
}
|
|
|
|
|
|
|
|
[[tagForm cellAtIndex: 0] setIntValue: [object tag]];
|
|
|
|
|
2011-04-01 06:55:48 +00:00
|
|
|
if([[object cell] sendsActionOnEndEditing])
|
|
|
|
{
|
|
|
|
[sendActionMatrix selectCellAtRow: 1 column: 0];
|
|
|
|
}
|
2011-04-27 00:13:02 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[sendActionMatrix selectCellAtRow: 0 column: 0];
|
|
|
|
}
|
2011-04-01 06:55:48 +00:00
|
|
|
|
2005-08-06 17:59:08 +00:00
|
|
|
[super revert:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* delegate method for tagForm */
|
|
|
|
-(void) controlTextDidChange:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
[self ok:[aNotification object]];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|