From 60f219bec7cda2f5dd54b50a4d368e6737bdfc43 Mon Sep 17 00:00:00 2001 From: Adam Fedor Date: Mon, 17 Sep 2001 17:22:10 +0000 Subject: [PATCH] Implement button type popup git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@10929 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++ GormWindowEditor.m | 9 +- .../2Controls/GormButtonInspector.classes | 3 +- Palettes/2Controls/GormButtonInspector.gorm | Bin 9828 -> 10266 bytes Palettes/2Controls/inspectors.m | 88 ++++++++++++++++++ 5 files changed, 106 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0af01abe..933ba435 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-09-17 Adam Fedor + + * 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 * Fixes to handle matrixes better. Editable matrix cells. Improved diff --git a/GormWindowEditor.m b/GormWindowEditor.m index 4d55ae84..165db24f 100644 --- a/GormWindowEditor.m +++ b/GormWindowEditor.m @@ -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) diff --git a/Palettes/2Controls/GormButtonInspector.classes b/Palettes/2Controls/GormButtonInspector.classes index 7c7629e2..34fc1dec 100644 --- a/Palettes/2Controls/GormButtonInspector.classes +++ b/Palettes/2Controls/GormButtonInspector.classes @@ -1,6 +1,7 @@ { GormButtonInspector = { Actions = ( + "setButtonTypeFrom:" ); Outlets = ( alignMatrix, @@ -75,4 +76,4 @@ ); Super = NSResponder; }; -} \ No newline at end of file +} diff --git a/Palettes/2Controls/GormButtonInspector.gorm b/Palettes/2Controls/GormButtonInspector.gorm index e13098d31c2548dca22aa5e641bc650a90e64aa2..25157cb0f97d950811949dc5c10808d80ea52a4d 100644 GIT binary patch delta 2442 zcmb7`X>e0j6vyv<%}d&(SxB06Nz>3JSVZ7f{UF;=8jOG}(aNGyBtmElX^J70R*NlK zP(kF8;|8J@MZp=-_oyP)g#xbNf-4nuT*mP;D&q%d7(Dkr42=QNWaiDe_x{iC{_pzU z&oj4$l}n`PIBg`OxdeY6OWhzusD}>rwbPL_$2xaz-%d#}7B zwU3f#XhrN=IBhG0AM74ONKvQ3etR`kI6PgvfN7}!?@LkGY?RK?{_~VSgAW!`#_d4WWugk4zu2t&Fz^dW@K&nU5 z4LZrpNoMZQY#_5pD`_E75+_L#Aqmn!!WZXt;gIJdaGnm#O9S)H1H3p6Y4ee`K&RQ# z1GP!%aSrG6$8OXWq&RcHR3hvqv2ZuT)poxurV%DO#?tu^bBxY0v4ybRQEY3_jGRpr z+^JI*z+uNY*CNf#Swz&cTeN((80^D(XarbEwJ9QT^sP{q;}0y+9BirHzo3XEHcIuY zo0ChLSX6Ys3{1{WQ=^ERV1sj#t6Ap@vCNhuV+EXWdUK6&TS6L{ZSUf)D~!V`Dhfj7(Kwe*0XtI%G3)b#WATB{&baOCyl>g(n?Ia zO&@4(dMR?H`e-b=BpF?*{*V3>h*|}O?y~IuD=yT(qNGwOi7G4!d)(gQHf>mX&1&)7 zTWWDSJeHsdessI5gC?vAItiX({Vx_1_tWkAyi>l*DO(L?oJ9BSD>LU^bX zc&smH>tLX$zG}VBIlIg6t??4`?D|k^q9quOp?yLLyARaz2Ad*L%Ykk}*!`N7ZGd^D z9pEh~pc}<$*eFiJ18~q^4&5at*QTNF*n^svZAM5C#uy5ncsHu+5XLWHrXXw!7`-k2 z)W4XmVE`#_$n{W$*@qGPNT#<(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(&ftdnh)?#gg}|u4#TcIM`C=ETE!YP8*7BE?t~my%UBaE z&00X4@!gTnTE zjkJxoP;X%OAmhD)u>~31IitTrKP;K|$-;Lm8%cyTkyg?`u4bK3nIA2_Pxl#}^UY-* zVyTEmnpzveu>@XfLJ8Xf!J^gKibSoax(Q+TYgz08IOpqxW1c+PCGJC)xDVY>Ragj9 zy=ME?@pSA#&BL~#Nf_oDT{gU&YA2fUtIxKh*+a0;+u+~vAFyR?CrtN6><_2GK7zKp z(%BwGyT_2NhxQ1r9>Mka7}xGJE(Hztq;c)!T>Z$^i$(xT{0;8CI+t;5;*An-59@;= zf5g5ojc7j_K9NrJBpMw+q7KL`bkKu>>Y$){3aMt;pVkeG{CJG)88kSA25YkWkR&u4 zNuEW6=is-(TKRblzK|X~jKLRSXnMW;5(bZ?2m3MjG8`}3ARooxF$`WlfHC{ynDh#4 zD{iGp__f$iUj=7izGX8GPFh+oqo%^cFK_NhD7PPIjitJkWtaM(`3V8BgN z@Liw?pMM5e&TD$Uo#)%x>rh@Ytt-g}^iG<`I%$?FqD$KwW338%L-VP7)uh7SM6rX5 zw@`F&aS}x{7jL7eO{!-7JPsG~}_Nh)e{ui#Tx;7GzC2H7dkyFV&gW6L6lr!Q@ sW}n0EQXe}j-hAu}z1}*uORH3!h}SmWTHV$f?_ghwv?TiqzAv5jH@fEn=>Px# diff --git a/Palettes/2Controls/inspectors.m b/Palettes/2Controls/inspectors.m index a18f25f1..39bac4c6 100644 --- a/Palettes/2Controls/inspectors.m +++ b/Palettes/2Controls/inspectors.m @@ -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; }