mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Improved button inspector.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21618 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0a4eb9ce3a
commit
cde6e64c5e
9 changed files with 204 additions and 467 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2005-08-06 17:52 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormLib/IBInspector.m: Call revert with object instead of anObject.
|
||||
Same object, just a slightly nicer way to do it.
|
||||
* Palettes/2Controls/GNUmakefile: Add in GormButtonAttributesInspector
|
||||
files.
|
||||
* Palettes/2Controls/GormButtonAttributesInspector.h: Changed ivar
|
||||
names.
|
||||
* Palettes/2Controls/GormButtonAttributesInspector.m: Changed names
|
||||
of vars and corrected problem with revert using anObject instead
|
||||
of object as it should. Removed explicit button item adds from
|
||||
init. Added trivial subclass to the file.
|
||||
* Palettes/2Controls/GormNSButtonInspector.gorm: Added NSPopUpButton
|
||||
items for button types.
|
||||
* Palettes/2Controls/GormStepperAttributesInspector.m: Added trivial
|
||||
subclass to the file.
|
||||
* Palettes/2Controls/inspectors.m: Moved all of IBObjectAdditions
|
||||
categories here.
|
||||
|
||||
2005-08-06 15:40 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Palettes/0Menus/GNUmakefile: Add new file
|
||||
|
|
|
@ -103,7 +103,7 @@ static NSNotificationCenter *nc = nil;
|
|||
- (void) setObject: (id)anObject
|
||||
{
|
||||
ASSIGN(object, anObject);
|
||||
[self revert: self];
|
||||
[self revert: object];
|
||||
}
|
||||
|
||||
- (void) textDidBeginEditing: (NSNotification*)aNotification
|
||||
|
|
|
@ -26,21 +26,21 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
|||
PALETTE_NAME = 2Controls
|
||||
2Controls_PALETTE_ICON = ControlsPalette
|
||||
|
||||
2Controls_OBJC_FILES = GormBoxAttributesInspector.m\
|
||||
GormCellAttributesInspector.m\
|
||||
GormColorWellAttributesInspector.m\
|
||||
GormFormAttributesInspector.m\
|
||||
GormPopUpButtonAttributesInspector.m\
|
||||
GormSliderAttributesInspector.m\
|
||||
GormStepperAttributesInspector.m\
|
||||
GormProgressIndicatorAttributesInspector.m\
|
||||
GormTextFieldAttributesInspector.m\
|
||||
GormMatrixAttributesInspector.m\
|
||||
2Controls_OBJC_FILES = GormButtonAttributesInspector.m \
|
||||
GormBoxAttributesInspector.m \
|
||||
GormCellAttributesInspector.m \
|
||||
GormColorWellAttributesInspector.m \
|
||||
GormFormAttributesInspector.m \
|
||||
GormPopUpButtonAttributesInspector.m \
|
||||
GormSliderAttributesInspector.m \
|
||||
GormStepperAttributesInspector.m \
|
||||
GormProgressIndicatorAttributesInspector.m \
|
||||
GormTextFieldAttributesInspector.m \
|
||||
GormMatrixAttributesInspector.m \
|
||||
ControlsPalette.m \
|
||||
GormPopUpButtonEditor.m \
|
||||
GormButtonEditor.m\
|
||||
GormButtonEditor.m \
|
||||
inspectors.m
|
||||
# GormButtonAttributesInspector.m\
|
||||
|
||||
2Controls_PRINCIPAL_CLASS = ControlsPalette
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@
|
|||
{
|
||||
NSMatrix *alignMatrix;
|
||||
NSMatrix *iconMatrix;
|
||||
NSForm *keyField;
|
||||
NSForm *keyForm;
|
||||
NSMatrix *optionMatrix;
|
||||
NSForm *tagForm;
|
||||
NSMatrix *titleForm;
|
||||
NSPopUpButton *typePopUpButton;
|
||||
NSPopUpButton *keyEquivPopUpButton;
|
||||
NSForm *titleForm;
|
||||
NSPopUpButton *typeButton;
|
||||
NSPopUpButton *keyEquiv;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,9 +1,45 @@
|
|||
/* inspectors - Various inspectors for control elements
|
||||
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
Author: Adam Fedor <fedor@gnu.org>
|
||||
Laurent Julliard <laurent@julliard-online.org>
|
||||
Date: Aug 2001
|
||||
Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
Date: 2003, 2005
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(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.
|
||||
*/
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <InterfaceBuilder/InterfaceBuilder.h>
|
||||
|
||||
#include "GormButtonAttributesInspector.h"
|
||||
|
||||
/* This macro makes sure that the string contains a value, even if @"" */
|
||||
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
|
||||
|
||||
// trivial cell subclass.
|
||||
@interface GormButtonCellAttributesInspector : GormButtonAttributesInspector
|
||||
@end
|
||||
|
||||
@implementation GormButtonCellAttributesInspector
|
||||
@end
|
||||
|
||||
@implementation GormButtonAttributesInspector
|
||||
|
||||
|
@ -17,29 +53,58 @@
|
|||
NSLog(@"Could not gorm GormButtonInspector");
|
||||
return nil;
|
||||
}
|
||||
|
||||
#warning Why ?
|
||||
/* Need to set up popup button */
|
||||
[typeButton removeAllItems];
|
||||
[typeButton addItemWithTitle: @"Momentary Push"];
|
||||
[[typeButton lastItem] setTag: 0];
|
||||
[typeButton addItemWithTitle: @"Push On/Off"];
|
||||
[[typeButton lastItem] setTag: 1];
|
||||
[typeButton addItemWithTitle: @"Toggle"];
|
||||
[[typeButton lastItem] setTag: 2];
|
||||
[typeButton addItemWithTitle: @"Momentary Change"];
|
||||
[[typeButton lastItem] setTag: 5];
|
||||
[typeButton addItemWithTitle: @"On/Off"];
|
||||
[[typeButton lastItem] setTag: 6];
|
||||
[typeButton addItemWithTitle: @"Momentary Light"];
|
||||
[[typeButton lastItem] setTag: 7];
|
||||
/* Doesn't work yet? */
|
||||
// [typeButton setAction: @selector(setButtonTypeFrom:)];
|
||||
// [typeButton setTarget: self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/* The button type isn't stored in the button, so reverse-engineer it */
|
||||
- (NSButtonType) buttonTypeForObject: (id)button
|
||||
{
|
||||
NSButtonCell *cell;
|
||||
NSButtonType type;
|
||||
int highlight, stateby;
|
||||
|
||||
/* We could be passed the button or the cell */
|
||||
cell = ([button isKindOfClass: [NSButton class]]) ? [button cell] : button;
|
||||
|
||||
highlight = [cell highlightsBy];
|
||||
stateby = [cell showsStateBy];
|
||||
NSDebugLog(@"highlight = %d, stateby = %d",
|
||||
[cell highlightsBy],[cell showsStateBy]);
|
||||
|
||||
type = NSMomentaryPushButton;
|
||||
if (highlight == NSChangeBackgroundCellMask)
|
||||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryLight;
|
||||
else
|
||||
type = NSOnOffButton;
|
||||
}
|
||||
else if (highlight == (NSPushInCellMask | NSChangeGrayCellMask))
|
||||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryPushButton;
|
||||
else
|
||||
type = NSPushOnPushOffButton;
|
||||
}
|
||||
else if (highlight == (NSPushInCellMask | NSContentsCellMask))
|
||||
{
|
||||
type = NSToggleButton;
|
||||
}
|
||||
else if (highlight == NSContentsCellMask)
|
||||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryChangeButton;
|
||||
else
|
||||
type = NSToggleButton; /* Really switch or radio. What should it be? */
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugLog(@"Ack! no button type");
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
- (void) ok: (id) sender
|
||||
{
|
||||
|
@ -52,7 +117,7 @@
|
|||
[object setImagePosition:
|
||||
(NSCellImagePosition)[[sender selectedCell] tag]];
|
||||
}
|
||||
else if (sender == keyField)
|
||||
else if (sender == keyForm)
|
||||
{
|
||||
[keyEquiv selectItem: nil]; // if the user does his own thing, select the default...
|
||||
[object setKeyEquivalent: [[sender cellAtIndex: 0] stringValue]];
|
||||
|
@ -71,7 +136,7 @@
|
|||
flag = ([[sender cellAtRow: 4 column: 0] state] == NSOnState) ? YES : NO;
|
||||
[object setTransparent: flag];
|
||||
}
|
||||
else if (sender == tagField)
|
||||
else if (sender == tagForm)
|
||||
{
|
||||
[object setTag: [[sender cellAtIndex: 0] intValue]];
|
||||
}
|
||||
|
@ -98,7 +163,7 @@
|
|||
}
|
||||
else if (sender == typeButton)
|
||||
{
|
||||
[self setButtonType: [[sender selectedItem] tag] forObject: object];
|
||||
[object setButtonType: [[sender selectedItem] tag]];
|
||||
}
|
||||
else if ([sender isKindOfClass: [NSMenuItem class]] )
|
||||
{
|
||||
|
@ -108,81 +173,84 @@
|
|||
* FIXME: Ideally we should also test if the menu item belongs
|
||||
* to the 'type button' control. How to do that?
|
||||
*/
|
||||
[self setButtonType: [sender tag] forObject: object];
|
||||
[object setButtonType: [sender tag]];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) revert:(id) anObject
|
||||
-(void) revert: (id)sender
|
||||
{
|
||||
NSImage *image;
|
||||
NSString *key = VSTR([anObject keyEquivalent]);
|
||||
|
||||
if (anObject != object)
|
||||
{
|
||||
return;
|
||||
}
|
||||
[alignMatrix selectCellWithTag: [anObject alignment]];
|
||||
[iconMatrix selectCellWithTag: [anObject imagePosition]];
|
||||
[[keyField cellAtIndex: 0] setStringValue: VSTR([anObject keyEquivalent])];
|
||||
|
||||
if([key isEqualToString: @"\n"])
|
||||
if(sender != nil)
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 1];
|
||||
NSString *key = VSTR([object keyEquivalent]);
|
||||
|
||||
[alignMatrix selectCellWithTag: [object alignment]];
|
||||
[iconMatrix selectCellWithTag: [object imagePosition]];
|
||||
[[keyForm cellAtIndex: 0] setStringValue: VSTR([object keyEquivalent])];
|
||||
|
||||
if([key isEqualToString: @"\n"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 1];
|
||||
}
|
||||
else if([key isEqualToString: @"\b"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 2];
|
||||
}
|
||||
else if([key isEqualToString: @"\E"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 3];
|
||||
}
|
||||
else if([key isEqualToString: @"\t"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
[keyEquiv selectItem: nil];
|
||||
}
|
||||
|
||||
[optionMatrix deselectAllCells];
|
||||
if ([object isBordered])
|
||||
[optionMatrix selectCellAtRow: 0 column: 0];
|
||||
if ([object isContinuous])
|
||||
[optionMatrix selectCellAtRow: 1 column: 0];
|
||||
if ([object isEnabled])
|
||||
[optionMatrix selectCellAtRow: 2 column: 0];
|
||||
if ([object state] == NSOnState)
|
||||
[optionMatrix selectCellAtRow: 3 column: 0];
|
||||
if ([object isTransparent])
|
||||
[optionMatrix selectCellAtRow: 4 column: 0];
|
||||
|
||||
[[tagForm cellAtIndex: 0] setIntValue: [object tag]];
|
||||
|
||||
[[titleForm cellAtIndex: 0] setStringValue: VSTR([object title])];
|
||||
[[titleForm cellAtIndex: 1] setStringValue: VSTR([object alternateTitle])];
|
||||
|
||||
image = [object image];
|
||||
if (image != nil)
|
||||
{
|
||||
[[titleForm cellAtIndex: 2] setStringValue: VSTR([image name])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[titleForm cellAtIndex: 2] setStringValue: @""];
|
||||
}
|
||||
|
||||
image = [object alternateImage];
|
||||
if (image != nil)
|
||||
{
|
||||
[[titleForm cellAtIndex: 3] setStringValue: VSTR([image name])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[titleForm cellAtIndex: 3] setStringValue: @""];
|
||||
}
|
||||
|
||||
[typeButton selectItemAtIndex:
|
||||
[typeButton indexOfItemWithTag:
|
||||
[self buttonTypeForObject: object]]];
|
||||
}
|
||||
else if([key isEqualToString: @"\b"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 2];
|
||||
}
|
||||
else if([key isEqualToString: @"\E"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 3];
|
||||
}
|
||||
else if([key isEqualToString: @"\t"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
[keyEquiv selectItem: nil];
|
||||
}
|
||||
|
||||
[optionMatrix deselectAllCells];
|
||||
if ([anObject isBordered])
|
||||
[optionMatrix selectCellAtRow: 0 column: 0];
|
||||
if ([anObject isContinuous])
|
||||
[optionMatrix selectCellAtRow: 1 column: 0];
|
||||
if ([anObject isEnabled])
|
||||
[optionMatrix selectCellAtRow: 2 column: 0];
|
||||
if ([anObject state] == NSOnState)
|
||||
[optionMatrix selectCellAtRow: 3 column: 0];
|
||||
if ([anObject isTransparent])
|
||||
[optionMatrix selectCellAtRow: 4 column: 0];
|
||||
|
||||
[[tagField cellAtIndex: 0] setIntValue: [anObject tag]];
|
||||
|
||||
[[titleForm cellAtIndex: 0] setStringValue: VSTR([anObject title])];
|
||||
[[titleForm cellAtIndex: 1] setStringValue: VSTR([anObject alternateTitle])];
|
||||
|
||||
image = [anObject image];
|
||||
if (image != nil)
|
||||
{
|
||||
[[titleForm cellAtIndex: 2] setStringValue: VSTR([image name])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[titleForm cellAtIndex: 2] setStringValue: @""];
|
||||
}
|
||||
|
||||
image = [anObject alternateImage];
|
||||
if (image != nil)
|
||||
{
|
||||
[[titleForm cellAtIndex: 3] setStringValue: VSTR([image name])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[titleForm cellAtIndex: 3] setStringValue: @""];
|
||||
}
|
||||
|
||||
[typeButton selectItemAtIndex:
|
||||
[typeButton indexOfItemWithTag: [self buttonTypeForObject: anObject]]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -32,22 +32,17 @@
|
|||
*/
|
||||
|
||||
#include "GormStepperAttributesInspector.h"
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
|
||||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSNibLoading.h>
|
||||
#include <AppKit/NSStepper.h>
|
||||
#include <AppKit/NSTextField.h>
|
||||
|
||||
// Some simple inspectors.
|
||||
@interface GormStepperCellAttributesInspector : GormStepperAttributesInspector
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation NSStepper (IBObjectAdditions)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormStepperAttributesInspector";
|
||||
}
|
||||
@implementation GormStepperCellAttributesInspector
|
||||
@end
|
||||
|
||||
@implementation GormStepperAttributesInspector
|
||||
|
|
|
@ -22,36 +22,14 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <InterfaceBuilder/InterfaceBuilder.h>
|
||||
#include <GormCore/NSColorWell+GormExtensions.h>
|
||||
|
||||
#include "GormButtonAttributesInspector.h"
|
||||
#include "GormStepperAttributesInspector.h"
|
||||
|
||||
/* This macro makes sure that the string contains a value, even if @"" */
|
||||
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
|
||||
|
||||
/* This is so that the NSSecureTextField will show in the custom class inspector */
|
||||
/*
|
||||
@implementation NSSecureTextField (IBObjectAdditions)
|
||||
+ (BOOL) canSubstituteForClass: (Class)origClass
|
||||
{
|
||||
if(origClass == [NSTextField class])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* NSButton
|
||||
*/
|
||||
@implementation NSButton (IBObjectAdditions)
|
||||
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormButtonEditor";
|
||||
|
@ -61,350 +39,27 @@
|
|||
{
|
||||
return @"GormButtonAttributesInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormButtonAttributesInspector : IBInspector
|
||||
{
|
||||
id alignMatrix;
|
||||
id iconMatrix;
|
||||
id keyField;
|
||||
id optionMatrix;
|
||||
id tagField;
|
||||
id titleForm;
|
||||
id typeButton;
|
||||
id keyEquiv;
|
||||
}
|
||||
- (void) setButtonType: (NSButtonType)type forObject: (id)button;
|
||||
- (void) _setValuesFromControl: (id)control;
|
||||
- (void) _getValuesFromObject: (id)anObject;
|
||||
@end
|
||||
|
||||
@implementation GormButtonAttributesInspector
|
||||
|
||||
/* delegate method for changing the NSButton title */
|
||||
- (void)controlTextDidChange:(NSNotification *)aNotification
|
||||
{
|
||||
[self ok:[aNotification object]];
|
||||
}
|
||||
|
||||
|
||||
/* The button type isn't stored in the button, so reverse-engineer it */
|
||||
- (NSButtonType) buttonTypeForObject: button
|
||||
{
|
||||
NSButtonCell *cell;
|
||||
NSButtonType type;
|
||||
int highlight, stateby;
|
||||
|
||||
/* We could be passed the button or the cell */
|
||||
cell = ([button isKindOfClass: [NSButton class]]) ? [button cell] : button;
|
||||
|
||||
highlight = [cell highlightsBy];
|
||||
stateby = [cell showsStateBy];
|
||||
NSDebugLog(@"highlight = %d, stateby = %d",
|
||||
[cell highlightsBy],[cell showsStateBy]);
|
||||
|
||||
type = NSMomentaryPushButton;
|
||||
if (highlight == NSChangeBackgroundCellMask)
|
||||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryLight;
|
||||
else
|
||||
type = NSOnOffButton;
|
||||
}
|
||||
else if (highlight == (NSPushInCellMask | NSChangeGrayCellMask))
|
||||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryPushButton;
|
||||
else
|
||||
type = NSPushOnPushOffButton;
|
||||
}
|
||||
else if (highlight == (NSPushInCellMask | NSContentsCellMask))
|
||||
{
|
||||
type = NSToggleButton;
|
||||
}
|
||||
else if (highlight == NSContentsCellMask)
|
||||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryChangeButton;
|
||||
else
|
||||
type = NSToggleButton; /* Really switch or radio. What should it be? */
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugLog(@"Ack! no button type");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/* We may need to reset some parameters based on the previous type */
|
||||
- (void) setButtonType: (NSButtonType)type forObject: (id)button
|
||||
{
|
||||
[object setButtonType: type];
|
||||
}
|
||||
|
||||
- (void) _setValuesFromControl: (id)control
|
||||
{
|
||||
if (control == alignMatrix)
|
||||
{
|
||||
[object setAlignment: (NSTextAlignment)[[control selectedCell] tag]];
|
||||
}
|
||||
else if (control == iconMatrix)
|
||||
{
|
||||
[object setImagePosition:
|
||||
(NSCellImagePosition)[[control selectedCell] tag]];
|
||||
}
|
||||
else if (control == keyField)
|
||||
{
|
||||
[keyEquiv selectItem: nil]; // if the user does his own thing, select the default...
|
||||
[object setKeyEquivalent: [[control cellAtIndex: 0] stringValue]];
|
||||
}
|
||||
else if (control == optionMatrix)
|
||||
{
|
||||
BOOL flag;
|
||||
|
||||
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO;
|
||||
[object setBordered: flag]; flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO;
|
||||
[object setContinuous: flag];
|
||||
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
|
||||
[object setEnabled: flag];
|
||||
|
||||
[object setState: [[control cellAtRow: 3 column: 0] state]];
|
||||
flag = ([[control cellAtRow: 4 column: 0] state] == NSOnState) ? YES : NO;
|
||||
[object setTransparent: flag];
|
||||
}
|
||||
else if (control == tagField)
|
||||
{
|
||||
[object setTag: [[control cellAtIndex: 0] intValue]];
|
||||
}
|
||||
else if (control == titleForm)
|
||||
{
|
||||
NSString *string;
|
||||
NSImage *image;
|
||||
|
||||
[object setTitle: [[control cellAtIndex: 0] stringValue]];
|
||||
[object setAlternateTitle: [[control cellAtIndex: 1] stringValue]];
|
||||
|
||||
string = [[control cellAtIndex: 2] stringValue];
|
||||
if ([string length] > 0)
|
||||
{
|
||||
image = [NSImage imageNamed: string];
|
||||
[object setImage: image];
|
||||
}
|
||||
string = [[control cellAtIndex: 3] stringValue];
|
||||
if ([string length] > 0)
|
||||
{
|
||||
image = [NSImage imageNamed: string];
|
||||
[object setAlternateImage: image];
|
||||
}
|
||||
}
|
||||
else if (control == typeButton)
|
||||
{
|
||||
[self setButtonType: [[control selectedItem] tag] forObject: object];
|
||||
}
|
||||
else if ([control isKindOfClass: [NSMenuItem class]] )
|
||||
{
|
||||
/*
|
||||
* In old NSPopUpButton implementation we do receive
|
||||
* the selected menu item here. Not the PopUpbutton 'typeButton'
|
||||
* FIXME: Ideally we should also test if the menu item belongs
|
||||
* to the 'type button' control. How to do that?
|
||||
*/
|
||||
[self setButtonType: [control tag] forObject: object];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _getValuesFromObject: anObject
|
||||
{
|
||||
NSImage *image;
|
||||
NSString *key = VSTR([anObject keyEquivalent]);
|
||||
|
||||
if (anObject != object)
|
||||
{
|
||||
return;
|
||||
}
|
||||
[alignMatrix selectCellWithTag: [anObject alignment]];
|
||||
[iconMatrix selectCellWithTag: [anObject imagePosition]];
|
||||
[[keyField cellAtIndex: 0] setStringValue: VSTR([anObject keyEquivalent])];
|
||||
|
||||
if([key isEqualToString: @"\n"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 1];
|
||||
}
|
||||
else if([key isEqualToString: @"\b"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 2];
|
||||
}
|
||||
else if([key isEqualToString: @"\E"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 3];
|
||||
}
|
||||
else if([key isEqualToString: @"\t"])
|
||||
{
|
||||
[keyEquiv selectItemAtIndex: 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
[keyEquiv selectItem: nil];
|
||||
}
|
||||
|
||||
[optionMatrix deselectAllCells];
|
||||
if ([anObject isBordered])
|
||||
[optionMatrix selectCellAtRow: 0 column: 0];
|
||||
if ([anObject isContinuous])
|
||||
[optionMatrix selectCellAtRow: 1 column: 0];
|
||||
if ([anObject isEnabled])
|
||||
[optionMatrix selectCellAtRow: 2 column: 0];
|
||||
if ([anObject state] == NSOnState)
|
||||
[optionMatrix selectCellAtRow: 3 column: 0];
|
||||
if ([anObject isTransparent])
|
||||
[optionMatrix selectCellAtRow: 4 column: 0];
|
||||
|
||||
[[tagField cellAtIndex: 0] setIntValue: [anObject tag]];
|
||||
|
||||
[[titleForm cellAtIndex: 0] setStringValue: VSTR([anObject title])];
|
||||
[[titleForm cellAtIndex: 1] setStringValue: VSTR([anObject alternateTitle])];
|
||||
|
||||
image = [anObject image];
|
||||
if (image != nil)
|
||||
{
|
||||
[[titleForm cellAtIndex: 2] setStringValue: VSTR([image name])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[titleForm cellAtIndex: 2] setStringValue: @""];
|
||||
}
|
||||
|
||||
image = [anObject alternateImage];
|
||||
if (image != nil)
|
||||
{
|
||||
[[titleForm cellAtIndex: 3] setStringValue: VSTR([image name])];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[titleForm cellAtIndex: 3] setStringValue: @""];
|
||||
}
|
||||
|
||||
[typeButton selectItemAtIndex:
|
||||
[typeButton indexOfItemWithTag: [self buttonTypeForObject: anObject]]];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([super init] == nil)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if ([NSBundle loadNibNamed: @"GormNSButtonInspector" owner: self] == NO)
|
||||
{
|
||||
NSLog(@"Could not gorm GormButtonInspector");
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* Need to set up popup button */
|
||||
[typeButton removeAllItems];
|
||||
[typeButton addItemWithTitle: @"Momentary Push"];
|
||||
[[typeButton lastItem] setTag: 0];
|
||||
[typeButton addItemWithTitle: @"Push On/Off"];
|
||||
[[typeButton lastItem] setTag: 1];
|
||||
[typeButton addItemWithTitle: @"Toggle"];
|
||||
[[typeButton lastItem] setTag: 2];
|
||||
[typeButton addItemWithTitle: @"Momentary Change"];
|
||||
[[typeButton lastItem] setTag: 5];
|
||||
[typeButton addItemWithTitle: @"On/Off"];
|
||||
[[typeButton lastItem] setTag: 6];
|
||||
[typeButton addItemWithTitle: @"Momentary Light"];
|
||||
[[typeButton lastItem] setTag: 7];
|
||||
/* Doesn't work yet? */
|
||||
// [typeButton setAction: @selector(setButtonTypeFrom:)];
|
||||
// [typeButton setTarget: self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
[super ok: sender];
|
||||
[self _setValuesFromControl: sender];
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[self _getValuesFromObject: anObject];
|
||||
}
|
||||
|
||||
- (void) selectKeyEquivalent: (id)sender
|
||||
{
|
||||
int code = [[keyEquiv selectedItem] tag];
|
||||
id cell = [keyField cellAtIndex: 0];
|
||||
switch(code)
|
||||
{
|
||||
case 0:
|
||||
[cell setStringValue: @""];
|
||||
[object setKeyEquivalent: @""];
|
||||
break;
|
||||
case 1:
|
||||
[cell setStringValue: @"\n"];
|
||||
[object setKeyEquivalent: @"\n"];
|
||||
break;
|
||||
case 2:
|
||||
[cell setStringValue: @"\b"];
|
||||
[object setKeyEquivalent: @"\b"];
|
||||
break;
|
||||
case 3:
|
||||
[cell setStringValue: @"\E"];
|
||||
[object setKeyEquivalent: @"\E"];
|
||||
break;
|
||||
case 4:
|
||||
[cell setStringValue: @"\t"];
|
||||
[object setKeyEquivalent: @"\t"];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* NSButtonCell
|
||||
*/
|
||||
@implementation NSButtonCell (IBObjectAdditions)
|
||||
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormButtonCellAttributesInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormButtonCellAttributesInspector : GormButtonAttributesInspector
|
||||
@implementation NSStepper (IBObjectAdditions)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormStepperAttributesInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormButtonCellAttributesInspector
|
||||
@end
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* NSStepperCell
|
||||
*/
|
||||
@implementation NSStepperCell (IBObjectAdditions)
|
||||
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormStepperCellAttributesInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormStepperCellAttributesInspector : GormStepperAttributesInspector
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormStepperCellAttributesInspector
|
||||
@end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue