Implement button type popup

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@10929 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2001-09-17 17:22:10 +00:00
parent 6f5ebc106f
commit 60f219bec7
5 changed files with 106 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2001-09-17 Adam Fedor <fedor@gnu.org>
* GormWindowEditor.m
(-_validateFrame:forViewPtr:withEvent:update:update): Allow resize
if frame is already too small.
* Palettes/2Controls/inspectors.m: Implement button type popup
for button inspector.
2001-09-16 Adam Fedor <fedor@gnu.org>
* Fixes to handle matrixes better. Editable matrix cells. Improved

View file

@ -236,10 +236,17 @@ _constrainPointToBounds(NSPoint point, NSRect bounds)
if (!isMatrix)
{
NSRect oldFrame = [view frame];
/* Check if it is too small*/
if (NSWidth(frame) < minSize.width
|| NSHeight(frame) < minSize.height)
return NO;
{
/* Check if it is already too small and we're just
making it bigger */
if (NSWidth(frame) < NSWidth(oldFrame)
&& NSHeight(frame) < NSHeight(oldFrame))
return NO;
}
if (([theEvent modifierFlags] & NSAlternateKeyMask)
!= NSAlternateKeyMask || isControl == NO)

View file

@ -1,6 +1,7 @@
{
GormButtonInspector = {
Actions = (
"setButtonTypeFrom:"
);
Outlets = (
alignMatrix,
@ -75,4 +76,4 @@
);
Super = NSResponder;
};
}
}

View file

@ -46,10 +46,79 @@
id titleForm;
id typeButton;
}
- (void) _getValuesFromObject: anObject;
@end
@implementation GormButtonAttributesInspector
/* The button type isn't stored in the button, so reverse-engineer it */
- (NSButtonType) buttonTypeForObject: button
{
NSButtonType type;
int highlight, stateby;
highlight = [[button cell] highlightsBy];
stateby = [[button cell] showsStateBy];
type = NSMomentaryPushButton;
if (highlight == NSChangeBackgroundCellMask)
{
if (stateby == NSNoCellMask)
type = NSMomentaryLight;
else if (stateby == NSChangeBackgroundCellMask)
type = NSOnOffButton;
else
type = NSToggleButton;
}
else if (highlight == (NSPushInCellMask | NSChangeGrayCellMask) )
{
if (stateby == NSNoCellMask)
type = NSMomentaryPushButton;
else
type = NSPushOnPushOffButton;
}
else if (highlight == NSContentsCellMask)
{
if (stateby == NSNoCellMask)
type = NSMomentaryChangeButton;
else if ([ [[button image] name] isEqual: @"common_SwitchOff" ])
type = NSSwitchButton;
else
type = NSRadioButton;
}
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: button
{
NSButtonType oldType = [self buttonTypeForObject: object];
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];
}
- (void) _setValuesFromControl: control
{
if (control == alignMatrix)
@ -104,6 +173,8 @@
}
else if (control == typeButton)
{
[self setButtonType: NSMomentaryPushButton + [control indexOfSelectedItem]
forObject: object];
}
}
@ -144,6 +215,8 @@
else
[[titleForm cellAtIndex: 3] setStringValue: @"" ];
[typeButton selectItemAtIndex: [self buttonTypeForObject: anObject ] ];
}
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
@ -175,6 +248,21 @@
selector: @selector(controlTextDidEndEditing:)
name: NSControlTextDidEndEditingNotification
object: nil];
/* Need to set up popup button */
[typeButton removeAllItems];
[typeButton addItemWithTitle: @"Momentary Push"];
[typeButton addItemWithTitle: @"Push On/Off"];
[typeButton addItemWithTitle: @"Toggle"];
[typeButton addItemWithTitle: @"Switch"];
[typeButton addItemWithTitle: @"Radio"];
[typeButton addItemWithTitle: @"Momentary Change"];
[typeButton addItemWithTitle: @"On/Off"];
[typeButton addItemWithTitle: @"Momentary Light"];
/* Doesn't work yet? */
[typeButton setAction: @selector(setButtonTypeFrom:)];
[typeButton setTarget: self];
return self;
}