mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 11:41:05 +00:00
Accepted patch for 34877 by Sergei.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@37909 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1fb82b12ec
commit
4c6a4d7baf
5 changed files with 81 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
2014-05-26 18:32-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Palettes/2Controls/GormFormAttributesInspector.h
|
||||
* Palettes/2Controls/GormFormAttributesInspector.m
|
||||
* Palettes/2Controls/GormNSFormInspector.gorm: Accept patch on
|
||||
bug#38477 by Sergei Golovin. Allows user to modify the
|
||||
number of items in an NSForm using the inspector.
|
||||
|
||||
2014-01-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Palettes/2Controls/GormButtonAttributesInspector.h: Use NSButton
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
@class NSColorWell;
|
||||
@class NSForm;
|
||||
@class NSMatrix;
|
||||
@class NSStepper;
|
||||
|
||||
@interface GormFormAttributesInspector: IBInspector
|
||||
{
|
||||
|
@ -55,6 +56,8 @@
|
|||
id tagForm;
|
||||
id textMatrix;
|
||||
id titleMatrix;
|
||||
NSForm *dimensionsForm;
|
||||
NSStepper *numberStepper;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
|
||||
@implementation GormFormAttributesInspector
|
||||
|
||||
NSUInteger numberStepperValue;
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ([super init] == nil)
|
||||
|
@ -69,6 +71,14 @@
|
|||
NSLog(@"Could not gorm GormFormInspector");
|
||||
return nil;
|
||||
}
|
||||
/* It shouldn't break functionality of field number changing
|
||||
if someone will decide in the future to change the value
|
||||
of the stepper in the gorm file. So we stores those value
|
||||
from the gorm file in the auxillary variable to use it
|
||||
later in -[ok:].
|
||||
(It allows us to avoid the value being hardcoded).
|
||||
*/
|
||||
numberStepperValue = [numberStepper intValue];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -152,6 +162,60 @@
|
|||
BOOL flag = ([autosizeSwitch state] == NSOnState) ? YES : NO;
|
||||
[object setAutosizesCells: flag];
|
||||
}
|
||||
/* number of fields */
|
||||
else if(sender == dimensionsForm)
|
||||
{
|
||||
int fields = [[sender cellAtIndex: 0] intValue];
|
||||
|
||||
if(fields) // make changes only if the user actions do something meaningful
|
||||
{
|
||||
NSRect rect = [object frame];
|
||||
NSSize cell = [object cellSize];
|
||||
NSSize inter = [object intercellSpacing];
|
||||
|
||||
while(((rows = [object numberOfRows]) != fields))
|
||||
{
|
||||
if(rows > fields)
|
||||
{
|
||||
[object removeEntryAtIndex: rows - 1]; // remove last field
|
||||
}
|
||||
else
|
||||
{
|
||||
[object addEntry: [NSString stringWithFormat: @"Field (%i)", rows]];
|
||||
}
|
||||
}
|
||||
cell.height = (rect.size.height + inter.height) / fields - inter.height;
|
||||
[object setCellSize: cell];
|
||||
}
|
||||
[object setNeedsDisplay: YES];
|
||||
[[object superview] setNeedsDisplay: YES];
|
||||
}
|
||||
else if(sender == numberStepper)
|
||||
{
|
||||
int delta = [sender intValue] - numberStepperValue;
|
||||
NSRect rect = [object frame];
|
||||
NSSize cell = [object cellSize];
|
||||
NSSize inter = [object intercellSpacing];
|
||||
|
||||
while(delta > 0)
|
||||
{
|
||||
[object addEntry: [NSString stringWithFormat: @"Field (%i)", rows]];
|
||||
delta--;
|
||||
rows++;
|
||||
}
|
||||
while((delta < 0) && (rows > 1))
|
||||
{
|
||||
[object removeEntryAtIndex: rows - 1];
|
||||
rows--;
|
||||
delta++;
|
||||
}
|
||||
cell.height = (rect.size.height + inter.height) / rows - inter.height;
|
||||
[object setCellSize: cell];
|
||||
[[dimensionsForm cellAtIndex: 0] setIntValue: rows];
|
||||
[sender setIntValue: numberStepperValue];
|
||||
[dimensionsForm setNeedsDisplay: YES];
|
||||
[object setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
[super ok:sender];
|
||||
}
|
||||
|
@ -200,6 +264,9 @@
|
|||
[cellPositionSwitch setState:NSOnState];
|
||||
}
|
||||
}
|
||||
|
||||
/* number of fields */
|
||||
[[dimensionsForm cellAtIndex: 0] setIntValue: [object numberOfRows]];
|
||||
|
||||
/* tag */
|
||||
[[tagForm cellAtRow: 0 column: 0] setIntValue: [object tag]];
|
||||
|
@ -269,5 +336,4 @@
|
|||
[object setButtonType: type];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
editableSwitch,
|
||||
scrollableSwitch,
|
||||
selectableSwitch,
|
||||
autosizeSwitch
|
||||
autosizeSwitch,
|
||||
dimensionsForm,
|
||||
numberStepper
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue