mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
New inspectors
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@11031 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
60f219bec7
commit
7b342746be
17 changed files with 877 additions and 29 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2001-09-27 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* GormInspectorsManager.m (-setCurrentInspector:): Gracefully handle
|
||||
an inspector creation error.
|
||||
* GormWindowEditor.m (-editTextField:withEvent:): TextField value
|
||||
editor method.
|
||||
|
||||
* Palettes/2Controls/inspectors.m: New NSBox, NSButtonCell,
|
||||
NSMatrix, and NSTextField inspectors.
|
||||
|
||||
2001-09-17 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* GormWindowEditor.m
|
||||
|
|
|
@ -404,6 +404,14 @@
|
|||
Class c = NSClassFromString(newInspector);
|
||||
|
||||
inspector = [c new];
|
||||
/* Try to gracefully handle an inspector creation error */
|
||||
while (inspector == nil && (obj = [obj superclass])
|
||||
&& current == 0)
|
||||
{
|
||||
NSLog(@"Error loading %@ inspector", newInspector);
|
||||
newInspector = [obj inspectorClassName];
|
||||
inspector = [NSClassFromString(newInspector) new];
|
||||
}
|
||||
[cache setObject: inspector forKey: newInspector];
|
||||
RELEASE(inspector);
|
||||
}
|
||||
|
|
|
@ -293,7 +293,6 @@ static BOOL done_editing;
|
|||
if ([matrix getRow: &row column: &col forPoint: loc] == NO)
|
||||
return;
|
||||
|
||||
NSLog(@"Got hit in cell %d %d", row, col);
|
||||
obj = [matrix cellAtRow: row column: col];
|
||||
if (obj != nil && obj != selected)
|
||||
{
|
||||
|
@ -367,8 +366,6 @@ static BOOL done_editing;
|
|||
|
||||
- (BOOL) activate
|
||||
{
|
||||
NSLog(@"Ack - GormMatrix - activate");
|
||||
//[[self window] makeKeyAndOrderFront: self];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -398,8 +395,7 @@ static BOOL done_editing;
|
|||
|
||||
- (void) orderFront
|
||||
{
|
||||
NSLog(@"Ack - GormMatrix - orderFront");
|
||||
//[[self window] orderFront: self];
|
||||
NSLog(@"Ack - GormMatrixEditor - orderFront");
|
||||
}
|
||||
|
||||
- (void) pasteInSelection
|
||||
|
|
|
@ -200,6 +200,96 @@ _constrainPointToBounds(NSPoint point, NSRect bounds)
|
|||
return nil;
|
||||
}
|
||||
|
||||
static BOOL done_editing;
|
||||
|
||||
- (void) handleNotification: (NSNotification*)aNotification
|
||||
{
|
||||
NSString *name = [aNotification name];
|
||||
if ([name isEqual: NSControlTextDidEndEditingNotification] == YES)
|
||||
{
|
||||
done_editing = YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* Edit a textfield. If it's not already editable, make it so, then
|
||||
edit it */
|
||||
- (void) editTextField: view withEvent: (NSEvent *)theEvent
|
||||
{
|
||||
int wasEditable;
|
||||
unsigned eventMask;
|
||||
NSTextField *editField;
|
||||
NSRect frame;
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSDate *future = [NSDate distantFuture];
|
||||
|
||||
editField = view;
|
||||
frame = [editField frame];
|
||||
wasEditable = [editField isEditable];
|
||||
[editField setEditable: YES];
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(handleNotification:)
|
||||
name: NSControlTextDidEndEditingNotification
|
||||
object: nil];
|
||||
|
||||
/* Do some modal editing */
|
||||
[editField selectText: self];
|
||||
eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||
NSKeyDownMask | NSKeyUpMask | NSFlagsChangedMask;
|
||||
|
||||
done_editing = NO;
|
||||
while (!done_editing)
|
||||
{
|
||||
NSEvent *e;
|
||||
NSEventType eType;
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
switch (eType)
|
||||
{
|
||||
case NSLeftMouseDown:
|
||||
{
|
||||
NSPoint dp = [edit_view convertPoint: [e locationInWindow]
|
||||
fromView: nil];
|
||||
if (NSMouseInRect(dp, frame, NO) == NO)
|
||||
{
|
||||
done_editing = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[[editField currentEditor] mouseDown: e];
|
||||
break;
|
||||
case NSLeftMouseUp:
|
||||
[[editField currentEditor] mouseUp: e];
|
||||
break;
|
||||
case NSLeftMouseDragged:
|
||||
[[editField currentEditor] mouseDragged: e];
|
||||
break;
|
||||
case NSKeyDown:
|
||||
[[editField currentEditor] keyDown: e];
|
||||
break;
|
||||
case NSKeyUp:
|
||||
[[editField currentEditor] keyUp: e];
|
||||
break;
|
||||
case NSFlagsChanged:
|
||||
[[editField currentEditor] flagsChanged: e];
|
||||
break;
|
||||
default:
|
||||
NSLog(@"Internal Error: Unhandled event during editing: %@", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wasEditable == NO)
|
||||
[editField setEditable: NO];
|
||||
[nc removeObserver: self
|
||||
name: NSControlTextDidEndEditingNotification
|
||||
object: nil];
|
||||
}
|
||||
|
||||
|
||||
/* Called when the frame of a view object is changed. Takes care of
|
||||
validating the frame and updating the object */
|
||||
- (BOOL) _validateFrame: (NSRect)frame
|
||||
|
@ -609,6 +699,11 @@ _constrainPointToBounds(NSPoint point, NSRect bounds)
|
|||
if ([subeditor editedObject] != view)
|
||||
[subeditor changeObject: view];
|
||||
}
|
||||
else if ([view isKindOfClass: [NSTextField class]])
|
||||
{
|
||||
[self editTextField: view withEvent: (NSEvent *)theEvent];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* If a subeditor exists, it should handle the mouse events */
|
||||
|
|
|
@ -29,9 +29,12 @@ PALETTE_NAME = 2Controls
|
|||
2Controls_PRINCIPAL_CLASS = ControlsPalette
|
||||
|
||||
2Controls_RESOURCE_FILES = ControlsPalette.tiff \
|
||||
GormBoxInspector.gorm \
|
||||
GormButtonInspector.gorm \
|
||||
GormMatrixInspector.gorm \
|
||||
GormSliderInspector.gorm \
|
||||
GormStepperInspector.gorm
|
||||
GormStepperInspector.gorm \
|
||||
GormTextFieldInspector.gorm
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
|
|
75
Palettes/2Controls/GormBoxInspector.classes
Normal file
75
Palettes/2Controls/GormBoxInspector.classes
Normal file
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
GormBoxInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
borderMatrix,
|
||||
positionMatrix,
|
||||
tagField,
|
||||
titleField
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
IBInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
okButton,
|
||||
revertButton,
|
||||
window
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSApplication = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSButton = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSControl = {
|
||||
Actions = (
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:"
|
||||
);
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
NSMenu = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSMenuItem = {
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSResponder = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSSlider = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSTextField = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSControl;
|
||||
};
|
||||
NSView = {
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
BIN
Palettes/2Controls/GormBoxInspector.gorm
Normal file
BIN
Palettes/2Controls/GormBoxInspector.gorm
Normal file
Binary file not shown.
|
@ -76,4 +76,4 @@
|
|||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
||||
}
|
Binary file not shown.
73
Palettes/2Controls/GormColorWellInspector.classes
Normal file
73
Palettes/2Controls/GormColorWellInspector.classes
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
GormColorWellInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
initialColor,
|
||||
optionMatrix
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
IBInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
okButton,
|
||||
revertButton,
|
||||
window
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSApplication = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSButton = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSControl = {
|
||||
Actions = (
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:"
|
||||
);
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
NSMenu = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSMenuItem = {
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSResponder = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSSlider = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSTextField = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSControl;
|
||||
};
|
||||
NSView = {
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
BIN
Palettes/2Controls/GormColorWellInspector.gorm
Normal file
BIN
Palettes/2Controls/GormColorWellInspector.gorm
Normal file
Binary file not shown.
75
Palettes/2Controls/GormMatrixInspector.classes
Normal file
75
Palettes/2Controls/GormMatrixInspector.classes
Normal file
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
GormMatrixInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
backgroundColor,
|
||||
drawsBackground,
|
||||
modeMatrix,
|
||||
tagField
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
IBInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
okButton,
|
||||
revertButton,
|
||||
window
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSApplication = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSButton = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSControl = {
|
||||
Actions = (
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:"
|
||||
);
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
NSMenu = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSMenuItem = {
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSResponder = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSSlider = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSTextField = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSControl;
|
||||
};
|
||||
NSView = {
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
BIN
Palettes/2Controls/GormMatrixInspector.gorm
Normal file
BIN
Palettes/2Controls/GormMatrixInspector.gorm
Normal file
Binary file not shown.
77
Palettes/2Controls/GormTextFieldInspector.classes
Normal file
77
Palettes/2Controls/GormTextFieldInspector.classes
Normal file
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
GormTextFieldInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
alignMatrix,
|
||||
backgroundColor,
|
||||
drawsBackground,
|
||||
optionMatrix,
|
||||
tagField,
|
||||
textColor
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
IBInspector = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
okButton,
|
||||
revertButton,
|
||||
window
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSApplication = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSButton = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSControl = {
|
||||
Actions = (
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:"
|
||||
);
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
NSMenu = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSMenuItem = {
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSResponder = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSSlider = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSTextField = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSControl;
|
||||
};
|
||||
NSView = {
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
BIN
Palettes/2Controls/GormTextFieldInspector.gorm
Normal file
BIN
Palettes/2Controls/GormTextFieldInspector.gorm
Normal file
Binary file not shown.
|
@ -25,6 +25,121 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
#include "../../GormPrivate.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSBox
|
||||
*/
|
||||
@implementation NSBox (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormBoxAttributesInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormBoxAttributesInspector : IBInspector
|
||||
{
|
||||
id positionMatrix;
|
||||
id borderMatrix;
|
||||
id tagField;
|
||||
id titleField;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormBoxAttributesInspector
|
||||
|
||||
- (void) _setValuesFromControl: control
|
||||
{
|
||||
if (control == positionMatrix)
|
||||
{
|
||||
[object setTitlePosition: [[control selectedCell] tag] ];
|
||||
}
|
||||
else if (control == borderMatrix)
|
||||
{
|
||||
[object setBorderType: [[control selectedCell] tag] ];
|
||||
}
|
||||
else if (control == titleField)
|
||||
{
|
||||
[object setTitle: [[control cellAtIndex: 0] stringValue] ];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _getValuesFromObject: anObject
|
||||
{
|
||||
if (anObject != object)
|
||||
return;
|
||||
|
||||
[positionMatrix selectCellWithTag: [anObject titlePosition] ];
|
||||
[borderMatrix selectCellWithTag: [anObject borderType] ];
|
||||
[[titleField cellAtIndex: 0] setStringValue: [anObject title] ];
|
||||
}
|
||||
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
id notifier = [aNotification object];
|
||||
[self _setValuesFromControl: notifier];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(window);
|
||||
RELEASE(okButton);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([super init] == nil)
|
||||
return nil;
|
||||
|
||||
if ([NSBundle loadNibNamed: @"GormBoxInspector" owner: self] == NO)
|
||||
{
|
||||
NSLog(@"Could not gorm GormBoxInspector");
|
||||
return nil;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(controlTextDidEndEditing:)
|
||||
name: NSControlTextDidEndEditingNotification
|
||||
object: nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) wantsButtons
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSButton*) okButton
|
||||
{
|
||||
if (okButton == nil)
|
||||
{
|
||||
okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,90,20)];
|
||||
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
|
||||
[okButton setAction: @selector(ok:)];
|
||||
[okButton setTarget: self];
|
||||
[okButton setTitle: @"OK"];
|
||||
[okButton setEnabled: YES];
|
||||
}
|
||||
return okButton;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
[self _setValuesFromControl: titleField];
|
||||
[self _setValuesFromControl: positionMatrix];
|
||||
[self _setValuesFromControl: borderMatrix];
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[self _getValuesFromObject: anObject];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSButton
|
||||
*/
|
||||
|
@ -55,10 +170,15 @@
|
|||
/* The button type isn't stored in the button, so reverse-engineer it */
|
||||
- (NSButtonType) buttonTypeForObject: button
|
||||
{
|
||||
NSButtonCell *cell;
|
||||
NSButtonType type;
|
||||
int highlight, stateby;
|
||||
highlight = [[button cell] highlightsBy];
|
||||
stateby = [[button cell] showsStateBy];
|
||||
|
||||
/* We could be passed the button or the cell */
|
||||
cell = ([button isKindOfClass: [NSButton class]]) ? [button cell] : button;
|
||||
|
||||
highlight = [cell highlightsBy];
|
||||
stateby = [cell showsStateBy];
|
||||
type = NSMomentaryPushButton;
|
||||
if (highlight == NSChangeBackgroundCellMask)
|
||||
{
|
||||
|
@ -80,10 +200,8 @@
|
|||
{
|
||||
if (stateby == NSNoCellMask)
|
||||
type = NSMomentaryChangeButton;
|
||||
else if ([ [[button image] name] isEqual: @"common_SwitchOff" ])
|
||||
type = NSSwitchButton;
|
||||
else
|
||||
type = NSRadioButton;
|
||||
type = NSToggleButton;
|
||||
}
|
||||
else
|
||||
NSDebugLog(@"Ack! no button type");
|
||||
|
@ -99,24 +217,13 @@
|
|||
if (type == oldType)
|
||||
return;
|
||||
|
||||
if (oldType == NSSwitchButton || oldType == NSRadioButton)
|
||||
{
|
||||
[object setImage: nil];
|
||||
[object setAlternateImage: nil];
|
||||
[object setImagePosition: NSNoImage];
|
||||
[object setBordered: YES];
|
||||
[[object cell] setBezeled: YES];
|
||||
[object setAlignment: NSCenterTextAlignment];
|
||||
}
|
||||
|
||||
[object setButtonType: type ];
|
||||
[self _getValuesFromObject: object];
|
||||
}
|
||||
|
||||
- (void) setButtonTypeFrom: sender
|
||||
{
|
||||
[self setButtonType: NSMomentaryPushButton + [sender indexOfSelectedItem]
|
||||
forObject: object];
|
||||
[self setButtonType: [[sender selectedItem] tag] forObject: object];
|
||||
}
|
||||
|
||||
- (void) _setValuesFromControl: control
|
||||
|
@ -173,8 +280,7 @@
|
|||
}
|
||||
else if (control == typeButton)
|
||||
{
|
||||
[self setButtonType: NSMomentaryPushButton + [control indexOfSelectedItem]
|
||||
forObject: object];
|
||||
[self setButtonType: [[control selectedItem] tag] forObject: object];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +321,9 @@
|
|||
else
|
||||
[[titleForm cellAtIndex: 3] setStringValue: @"" ];
|
||||
|
||||
[typeButton selectItemAtIndex: [self buttonTypeForObject: anObject ] ];
|
||||
[typeButton selectItemAtIndex:
|
||||
[typeButton indexOfItemWithTag:
|
||||
[self buttonTypeForObject: anObject ] ] ];
|
||||
|
||||
}
|
||||
|
||||
|
@ -252,13 +360,17 @@
|
|||
/* 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 addItemWithTitle: @"Switch"];
|
||||
[typeButton addItemWithTitle: @"Radio"];
|
||||
[[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];
|
||||
|
@ -304,6 +416,170 @@
|
|||
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSButtonCell
|
||||
*/
|
||||
@implementation NSButtonCell (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormButtonCellAttributesInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormButtonCellAttributesInspector : GormButtonAttributesInspector
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormButtonCellAttributesInspector
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSForm
|
||||
*/
|
||||
@implementation NSForm (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
// Not Implemented Yet
|
||||
return @"GormObjectInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSMatrix
|
||||
*/
|
||||
@implementation NSMatrix (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormMatrixAttributesInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormMatrixAttributesInspector : IBInspector
|
||||
{
|
||||
id backgroundColor;
|
||||
id drawsBackground;
|
||||
id modeMatrix;
|
||||
id tagField;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormMatrixAttributesInspector
|
||||
|
||||
- (void) _setValuesFromControl: control
|
||||
{
|
||||
if (control == backgroundColor)
|
||||
{
|
||||
[object setBackgroundColor: [control color]];
|
||||
}
|
||||
else if (control == drawsBackground)
|
||||
{
|
||||
[object setDrawsBackground: ([control state] == NSOnState)];
|
||||
}
|
||||
if (control == modeMatrix)
|
||||
{
|
||||
[(NSMatrix *)object setMode: [[control selectedCell] tag] ];
|
||||
}
|
||||
else if (control == tagField)
|
||||
{
|
||||
[object setTag: [[control cellAtIndex: 0] intValue] ];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _getValuesFromObject: anObject
|
||||
{
|
||||
if (anObject != object)
|
||||
return;
|
||||
|
||||
[backgroundColor setColor: [anObject backgroundColor] ];
|
||||
[drawsBackground setState:
|
||||
([anObject drawsBackground]) ? NSOnState : NSOffState];
|
||||
|
||||
[modeMatrix selectCellWithTag: [(NSMatrix *)anObject mode] ];
|
||||
[[tagField cellAtIndex: 0] setIntValue: [anObject tag] ];
|
||||
}
|
||||
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
id notifier = [aNotification object];
|
||||
[self _setValuesFromControl: notifier];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(window);
|
||||
RELEASE(okButton);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([super init] == nil)
|
||||
return nil;
|
||||
|
||||
if ([NSBundle loadNibNamed: @"GormMatrixInspector" owner: self] == NO)
|
||||
{
|
||||
NSLog(@"Could not gorm GormMatrixInspector");
|
||||
return nil;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(controlTextDidEndEditing:)
|
||||
name: NSControlTextDidEndEditingNotification
|
||||
object: nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) wantsButtons
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSButton*) okButton
|
||||
{
|
||||
if (okButton == nil)
|
||||
{
|
||||
okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,80,30)];
|
||||
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
|
||||
[okButton setAction: @selector(ok:)];
|
||||
[okButton setTarget: self];
|
||||
[okButton setTitle: @"OK"];
|
||||
[okButton setEnabled: YES];
|
||||
}
|
||||
return okButton;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
[self _setValuesFromControl: modeMatrix];
|
||||
[self _setValuesFromControl: backgroundColor];
|
||||
[self _setValuesFromControl: drawsBackground];
|
||||
[self _setValuesFromControl: tagField];
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[self _getValuesFromObject: anObject];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSPopUpButton
|
||||
*/
|
||||
@implementation NSPopUpButton (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
// Not Implemented Yet
|
||||
return @"GormObjectInspector";
|
||||
}
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSSlider
|
||||
*/
|
||||
|
@ -544,3 +820,162 @@
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
NSTextField
|
||||
*/
|
||||
@implementation NSTextField (IBInspectorClassNames)
|
||||
- (NSString*) inspectorClassName
|
||||
{
|
||||
return @"GormTextFieldAttributesInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormTextFieldAttributesInspector : IBInspector
|
||||
{
|
||||
id alignMatrix;
|
||||
id backgroundColor;
|
||||
id drawsBackground;
|
||||
id textColor;
|
||||
id optionMatrix;
|
||||
id tagField;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormTextFieldAttributesInspector
|
||||
|
||||
- (void) _setValuesFromControl: control
|
||||
{
|
||||
if (control == alignMatrix)
|
||||
{
|
||||
[object setAlignment: (NSTextAlignment)[[control selectedCell] tag] ];
|
||||
}
|
||||
else if (control == backgroundColor)
|
||||
{
|
||||
[object setBackgroundColor: [control color]];
|
||||
}
|
||||
else if (control == drawsBackground)
|
||||
{
|
||||
[object setDrawsBackground: ([control state] == NSOnState)];
|
||||
}
|
||||
else if (control == textColor)
|
||||
{
|
||||
[object setTextColor: [control color]];
|
||||
}
|
||||
else if (control == optionMatrix)
|
||||
{
|
||||
BOOL flag;
|
||||
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES :NO;
|
||||
[object setEditable: flag];
|
||||
flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES :NO;
|
||||
[object setSelectable: flag];
|
||||
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES :NO;
|
||||
[[object cell] setScrollable: flag];
|
||||
flag = ([[control cellAtRow: 3 column: 0] state] == NSOnState) ? YES :NO;
|
||||
[object setBezeled: flag];
|
||||
flag = ([[control cellAtRow: 4 column: 0] state] == NSOnState) ? YES :NO;
|
||||
[object setBordered: flag];
|
||||
}
|
||||
else if (control == tagField)
|
||||
{
|
||||
[object setTag: [[control cellAtIndex: 0] intValue] ];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _getValuesFromObject: anObject
|
||||
{
|
||||
if (anObject != object)
|
||||
return;
|
||||
|
||||
[alignMatrix selectCellWithTag: [anObject alignment] ];
|
||||
[backgroundColor setColor: [anObject backgroundColor] ];
|
||||
[textColor setColor: [anObject textColor] ];
|
||||
[drawsBackground setState:
|
||||
([anObject drawsBackground]) ? NSOnState : NSOffState];
|
||||
|
||||
[optionMatrix deselectAllCells];
|
||||
if ([anObject isEditable])
|
||||
[optionMatrix selectCellAtRow: 0 column: 0];
|
||||
if ([anObject isSelectable])
|
||||
[optionMatrix selectCellAtRow: 1 column: 0];
|
||||
if ([[anObject cell] isScrollable])
|
||||
[optionMatrix selectCellAtRow: 2 column: 0];
|
||||
if ([anObject isBezeled])
|
||||
[optionMatrix selectCellAtRow: 3 column: 0];
|
||||
if ([anObject isBordered])
|
||||
[optionMatrix selectCellAtRow: 4 column: 0];
|
||||
|
||||
[[tagField cellAtIndex: 0] setIntValue: [anObject tag] ];
|
||||
}
|
||||
|
||||
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
|
||||
{
|
||||
id notifier = [aNotification object];
|
||||
[self _setValuesFromControl: notifier];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
RELEASE(window);
|
||||
RELEASE(okButton);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([super init] == nil)
|
||||
return nil;
|
||||
|
||||
if ([NSBundle loadNibNamed: @"GormTextFieldInspector" owner: self] == NO)
|
||||
{
|
||||
NSLog(@"Could not gorm GormTextFieldInspector");
|
||||
return nil;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(controlTextDidEndEditing:)
|
||||
name: NSControlTextDidEndEditingNotification
|
||||
object: nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) wantsButtons
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSButton*) okButton
|
||||
{
|
||||
if (okButton == nil)
|
||||
{
|
||||
okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,80,30)];
|
||||
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
|
||||
[okButton setAction: @selector(ok:)];
|
||||
[okButton setTarget: self];
|
||||
[okButton setTitle: @"OK"];
|
||||
[okButton setEnabled: YES];
|
||||
}
|
||||
return okButton;
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
{
|
||||
[self _setValuesFromControl: alignMatrix];
|
||||
[self _setValuesFromControl: backgroundColor];
|
||||
[self _setValuesFromControl: textColor];
|
||||
[self _setValuesFromControl: drawsBackground];
|
||||
[self _setValuesFromControl: optionMatrix];
|
||||
[self _setValuesFromControl: tagField];
|
||||
}
|
||||
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
[super setObject: anObject];
|
||||
[self _getValuesFromObject: anObject];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
// Editable text field
|
||||
v = [[NSTextField alloc] initWithFrame: NSMakeRect(10, 127, 56, 21)];
|
||||
[v setEditable: YES];
|
||||
[v setStringValue: @"Text"];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
|
Loading…
Reference in a new issue