mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 11:41:05 +00:00
* English.lproj/GormPalettePanel.gorm: Moved palette window to
gorm file. * GNUmakefile: Added new gorm here. * GormCore/GormDocument.m: Made toolbar items smaller * GormCore/GormPalettesManager.[hm]: Added toolbar implementation to this class to allow the user to switch palettes using the toolbar. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@26477 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0a0af253db
commit
c51b7b4e4b
8 changed files with 170 additions and 87 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2008-04-27 19:32-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* English.lproj/GormPalettePanel.gorm: Moved palette window to
|
||||||
|
gorm file.
|
||||||
|
* GNUmakefile: Added new gorm here.
|
||||||
|
* GormCore/GormDocument.m: Made toolbar items smaller
|
||||||
|
* GormCore/GormPalettesManager.[hm]: Added toolbar implementation
|
||||||
|
to this class to allow the user to switch palettes using the toolbar.
|
||||||
|
|
||||||
2008-04-25 17:41-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
2008-04-25 17:41-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* English.lproj/GormDocument.gorm: Corrected possition.
|
* English.lproj/GormDocument.gorm: Corrected possition.
|
||||||
|
|
27
English.lproj/GormPalettePanel.gorm/data.classes
Normal file
27
English.lproj/GormPalettePanel.gorm/data.classes
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||||
|
GormPalettePanel = {
|
||||||
|
Actions = (
|
||||||
|
);
|
||||||
|
Outlets = (
|
||||||
|
);
|
||||||
|
Super = NSPanel;
|
||||||
|
};
|
||||||
|
GormPaletteView = {
|
||||||
|
Actions = (
|
||||||
|
);
|
||||||
|
Outlets = (
|
||||||
|
);
|
||||||
|
Super = NSView;
|
||||||
|
};
|
||||||
|
GormPalettesManager = {
|
||||||
|
Actions = (
|
||||||
|
);
|
||||||
|
Outlets = (
|
||||||
|
panel,
|
||||||
|
dragView,
|
||||||
|
selectionView
|
||||||
|
);
|
||||||
|
Super = NSObject;
|
||||||
|
};
|
||||||
|
}
|
BIN
English.lproj/GormPalettePanel.gorm/data.info
Normal file
BIN
English.lproj/GormPalettePanel.gorm/data.info
Normal file
Binary file not shown.
BIN
English.lproj/GormPalettePanel.gorm/objects.gorm
Normal file
BIN
English.lproj/GormPalettePanel.gorm/objects.gorm
Normal file
Binary file not shown.
|
@ -149,6 +149,7 @@ Gorm_LOCALIZED_RESOURCE_FILES = \
|
||||||
GormInspectorPanel.gorm \
|
GormInspectorPanel.gorm \
|
||||||
GormObjectInspector.gorm \
|
GormObjectInspector.gorm \
|
||||||
GormNSSplitViewInspector.gorm \
|
GormNSSplitViewInspector.gorm \
|
||||||
|
GormPalettePanel.gorm \
|
||||||
GormPrefColors.gorm \
|
GormPrefColors.gorm \
|
||||||
GormPreferences.gorm \
|
GormPreferences.gorm \
|
||||||
GormPrefGeneral.gorm \
|
GormPrefGeneral.gorm \
|
||||||
|
|
|
@ -341,6 +341,7 @@ static NSImage *fileImage = nil;
|
||||||
// set up the toolbar...
|
// set up the toolbar...
|
||||||
toolbar = [(NSToolbar *)[NSToolbar alloc] initWithIdentifier: @"GormToolbar"];
|
toolbar = [(NSToolbar *)[NSToolbar alloc] initWithIdentifier: @"GormToolbar"];
|
||||||
[toolbar setAllowsUserCustomization: NO];
|
[toolbar setAllowsUserCustomization: NO];
|
||||||
|
[toolbar setSizeMode: NSToolbarSizeModeSmall];
|
||||||
[toolbar setDelegate: self];
|
[toolbar setDelegate: self];
|
||||||
[window setToolbar: toolbar];
|
[window setToolbar: toolbar];
|
||||||
RELEASE(toolbar);
|
RELEASE(toolbar);
|
||||||
|
|
|
@ -37,13 +37,16 @@
|
||||||
NSMatrix *selectionView;
|
NSMatrix *selectionView;
|
||||||
NSView *dragView;
|
NSView *dragView;
|
||||||
NSMutableArray *bundles;
|
NSMutableArray *bundles;
|
||||||
NSMutableArray *palettes;
|
NSMutableDictionary *palettesDict;
|
||||||
|
NSMutableArray *palettes;
|
||||||
|
NSMutableArray *paletteNames;
|
||||||
int current;
|
int current;
|
||||||
BOOL hiddenDuringTest;
|
BOOL hiddenDuringTest;
|
||||||
NSMutableDictionary *importedClasses;
|
NSMutableDictionary *importedClasses;
|
||||||
NSMutableArray *importedImages;
|
NSMutableArray *importedImages;
|
||||||
NSMutableArray *importedSounds;
|
NSMutableArray *importedSounds;
|
||||||
NSMutableDictionary *substituteClasses;
|
NSMutableDictionary *substituteClasses;
|
||||||
|
NSToolbar *toolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods for loading and display the palette panels
|
// methods for loading and display the palette panels
|
||||||
|
@ -51,6 +54,7 @@
|
||||||
- (id) openPalette: (id) sender;
|
- (id) openPalette: (id) sender;
|
||||||
- (NSPanel*) panel;
|
- (NSPanel*) panel;
|
||||||
- (void) setCurrentPalette: (id)anObject;
|
- (void) setCurrentPalette: (id)anObject;
|
||||||
|
- (void) setCurrentPaletteWithTag: (int)tag;
|
||||||
|
|
||||||
// methods for importing stuff from palettes
|
// methods for importing stuff from palettes
|
||||||
- (void) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict;
|
- (void) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict;
|
||||||
|
|
|
@ -150,7 +150,6 @@ static NSImage *dragImage = nil;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Intercepting events in the view and handling them
|
* Intercepting events in the view and handling them
|
||||||
*/
|
*/
|
||||||
|
@ -255,6 +254,7 @@ static NSImage *dragImage = nil;
|
||||||
RELEASE(panel);
|
RELEASE(panel);
|
||||||
RELEASE(bundles);
|
RELEASE(bundles);
|
||||||
RELEASE(palettes);
|
RELEASE(palettes);
|
||||||
|
RELEASE(palettesDict);
|
||||||
RELEASE(importedClasses);
|
RELEASE(importedClasses);
|
||||||
RELEASE(importedImages);
|
RELEASE(importedImages);
|
||||||
RELEASE(importedSounds);
|
RELEASE(importedSounds);
|
||||||
|
@ -287,100 +287,88 @@ static NSImage *dragImage = nil;
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
NSScrollView *scrollView;
|
|
||||||
NSArray *array;
|
NSArray *array;
|
||||||
NSRect contentRect = {{0, 0}, {272, 266}};
|
|
||||||
NSRect selectionRect = {{0, 0}, {52, 52}};
|
|
||||||
NSRect scrollRect = {{0, 192}, {272, 74}};
|
|
||||||
NSRect dragRect = {{0, 0}, {272, 192}};
|
|
||||||
unsigned int style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
|
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||||
NSArray *userPalettes = [defaults arrayForKey: USER_PALETTES];
|
NSArray *userPalettes = [defaults arrayForKey: USER_PALETTES];
|
||||||
|
|
||||||
panel = [[GormPalettePanel alloc] initWithContentRect: contentRect
|
self = [super init];
|
||||||
styleMask: style
|
if(self != nil)
|
||||||
backing: NSBackingStoreRetained
|
{
|
||||||
defer: NO];
|
if([NSBundle loadNibNamed: @"GormPalettePanel" owner: self] == NO)
|
||||||
[panel setTitle: _(@"Palettes")];
|
{
|
||||||
[panel setMinSize: [panel frame].size];
|
return nil;
|
||||||
|
}
|
||||||
// allocate arrays and dictionaries.
|
}
|
||||||
bundles = [[NSMutableArray alloc] init];
|
else
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize dictionary
|
||||||
|
//
|
||||||
|
palettesDict = [[NSMutableDictionary alloc] init];
|
||||||
palettes = [[NSMutableArray alloc] init];
|
palettes = [[NSMutableArray alloc] init];
|
||||||
importedClasses = [[NSMutableDictionary alloc] init];
|
paletteNames = [[NSMutableArray alloc] init];
|
||||||
importedImages = [[NSMutableArray alloc] init];
|
|
||||||
importedSounds = [[NSMutableArray alloc] init];
|
|
||||||
substituteClasses = [[NSMutableDictionary alloc] init];
|
substituteClasses = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
|
//
|
||||||
[scrollView setHasHorizontalScroller: YES];
|
// Set frame name
|
||||||
[scrollView setHasVerticalScroller: NO];
|
//
|
||||||
[scrollView setAutoresizingMask: NSViewMinYMargin | NSViewWidthSizable];
|
|
||||||
[scrollView setBorderType: NSBezelBorder];
|
|
||||||
|
|
||||||
selectionView = [[NSMatrix alloc] initWithFrame: selectionRect
|
|
||||||
mode: NSRadioModeMatrix
|
|
||||||
cellClass: [NSImageCell class]
|
|
||||||
numberOfRows: 1
|
|
||||||
numberOfColumns: 0];
|
|
||||||
[selectionView setTarget: self];
|
|
||||||
[selectionView setAction: @selector(setCurrentPalette:)];
|
|
||||||
[selectionView setCellSize: NSMakeSize(52,52)];
|
|
||||||
[selectionView setIntercellSpacing: NSMakeSize(0,0)];
|
|
||||||
[scrollView setDocumentView: selectionView];
|
|
||||||
RELEASE(selectionView);
|
|
||||||
[[panel contentView] addSubview: scrollView];
|
|
||||||
RELEASE(scrollView);
|
|
||||||
|
|
||||||
dragView = [[GormPaletteView alloc] initWithFrame: dragRect];
|
|
||||||
[dragView setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
|
|
||||||
[[panel contentView] addSubview: dragView];
|
|
||||||
RELEASE(dragView);
|
|
||||||
|
|
||||||
[panel setFrameUsingName: @"Palettes"];
|
[panel setFrameUsingName: @"Palettes"];
|
||||||
[panel setFrameAutosaveName: @"Palettes"];
|
[panel setFrameAutosaveName: @"Palettes"];
|
||||||
current = -1;
|
current = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set up the toolbar.
|
||||||
|
//
|
||||||
|
toolbar = [(NSToolbar *)[NSToolbar alloc] initWithIdentifier: @"GormPalettesToolbar"];
|
||||||
|
[toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
|
||||||
|
[toolbar setSizeMode: NSToolbarSizeModeSmall];
|
||||||
|
[toolbar setAllowsUserCustomization: NO];
|
||||||
|
[toolbar setDelegate: self];
|
||||||
|
[panel setToolbar: toolbar];
|
||||||
|
RELEASE(toolbar);
|
||||||
|
|
||||||
array = [[NSBundle mainBundle] pathsForResourcesOfType: @"palette"
|
array = [[NSBundle mainBundle] pathsForResourcesOfType: @"palette"
|
||||||
inDirectory: nil];
|
inDirectory: nil];
|
||||||
if ([array count] > 0)
|
if ([array count] > 0)
|
||||||
{
|
{
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
array = [array sortedArrayUsingSelector: @selector(compare:)];
|
array = [array sortedArrayUsingSelector: @selector(compare:)];
|
||||||
|
|
||||||
for (index = 0; index < [array count]; index++)
|
for (index = 0; index < [array count]; index++)
|
||||||
{
|
{
|
||||||
[self loadPalette: [array objectAtIndex: index]];
|
[self loadPalette: [array objectAtIndex: index]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have any user palettes load them as well.
|
// if we have any user palettes load them as well.
|
||||||
if(userPalettes != nil)
|
if(userPalettes != nil)
|
||||||
{
|
{
|
||||||
NSEnumerator *en = [userPalettes objectEnumerator];
|
NSEnumerator *en = [userPalettes objectEnumerator];
|
||||||
id paletteName = nil;
|
id paletteName = nil;
|
||||||
while((paletteName = [en nextObject]) != nil)
|
while((paletteName = [en nextObject]) != nil)
|
||||||
{
|
{
|
||||||
[self loadPalette: paletteName];
|
[self loadPalette: paletteName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select initial palette - this should be the standard controls palette.
|
* Select initial palette - this should be the standard controls palette.
|
||||||
*/
|
*/
|
||||||
[selectionView selectCellAtRow: 0 column: 2];
|
[self setCurrentPaletteWithTag: 2];
|
||||||
[self setCurrentPalette: selectionView];
|
|
||||||
|
|
||||||
[nc addObserver: self
|
[nc addObserver: self
|
||||||
selector: @selector(handleNotification:)
|
selector: @selector(handleNotification:)
|
||||||
name: IBWillBeginTestingInterfaceNotification
|
name: IBWillBeginTestingInterfaceNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
[nc addObserver: self
|
[nc addObserver: self
|
||||||
selector: @selector(handleNotification:)
|
selector: @selector(handleNotification:)
|
||||||
name: IBWillEndTestingInterfaceNotification
|
name: IBWillEndTestingInterfaceNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,8 +399,6 @@ static NSImage *dragImage = nil;
|
||||||
NSArray *exportImages;
|
NSArray *exportImages;
|
||||||
NSDictionary *subClasses;
|
NSDictionary *subClasses;
|
||||||
IBPalette *palette;
|
IBPalette *palette;
|
||||||
NSImageCell *cell;
|
|
||||||
int col;
|
|
||||||
|
|
||||||
if([self bundlePathIsLoaded: path])
|
if([self bundlePathIsLoaded: path])
|
||||||
{
|
{
|
||||||
|
@ -535,16 +521,14 @@ static NSImage *dragImage = nil;
|
||||||
[window setFrame: NSMakeRect(0,0,272,192) display: NO];
|
[window setFrame: NSMakeRect(0,0,272,192) display: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manage palette data.
|
||||||
|
[palettesDict setObject: palette forKey: className];
|
||||||
[palettes addObject: palette];
|
[palettes addObject: palette];
|
||||||
|
[paletteNames addObject: className];
|
||||||
|
|
||||||
[selectionView addColumn];
|
[selectionView addColumn];
|
||||||
[[palette paletteIcon] setBackgroundColor: [selectionView backgroundColor]];
|
[toolbar insertItemWithItemIdentifier: className atIndex: ([palettes count] - 1)];
|
||||||
col = [selectionView numberOfColumns] - 1;
|
[self setCurrentPalette: 0];
|
||||||
cell = [selectionView cellAtRow: 0 column: col];
|
|
||||||
[cell setImageFrameStyle: NSImageFrameButton];
|
|
||||||
[cell setImage: [palette paletteIcon]];
|
|
||||||
[selectionView sizeToCells];
|
|
||||||
[selectionView selectCellAtRow: 0 column: col];
|
|
||||||
[self setCurrentPalette: selectionView];
|
|
||||||
RELEASE(palette);
|
RELEASE(palette);
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -610,7 +594,12 @@ static NSImage *dragImage = nil;
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setCurrentPalette: (id)anObj
|
- (void) setCurrentPalette: (id)anObject
|
||||||
|
{
|
||||||
|
[self setCurrentPaletteWithTag: [anObject tag]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setCurrentPaletteWithTag: (int)tag
|
||||||
{
|
{
|
||||||
NSView *wv;
|
NSView *wv;
|
||||||
NSView *sv;
|
NSView *sv;
|
||||||
|
@ -633,7 +622,7 @@ static NSImage *dragImage = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = [anObj selectedColumn];
|
current = tag;
|
||||||
if (current >= 0 && current < [palettes count])
|
if (current >= 0 && current < [palettes count])
|
||||||
{
|
{
|
||||||
id palette = [palettes objectAtIndex: current];
|
id palette = [palettes objectAtIndex: current];
|
||||||
|
@ -649,8 +638,12 @@ static NSImage *dragImage = nil;
|
||||||
* Resize our drag view to the right size fitrst.
|
* Resize our drag view to the right size fitrst.
|
||||||
*/
|
*/
|
||||||
wv = [[palette originalWindow] contentView];
|
wv = [[palette originalWindow] contentView];
|
||||||
if (wv)
|
if(wv)
|
||||||
[dragView setFrameSize: [wv frame].size];
|
{
|
||||||
|
[dragView setFrameSize: [wv frame].size];
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over the subviews and add them to the dragview.
|
||||||
enumerator = [[wv subviews] objectEnumerator];
|
enumerator = [[wv subviews] objectEnumerator];
|
||||||
while ((sv = [enumerator nextObject]) != nil)
|
while ((sv = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
|
@ -662,7 +655,7 @@ static NSImage *dragImage = nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"Bad palette selection - %d", [anObj selectedColumn]);
|
NSLog(@"Bad palette selection - %d", tag);
|
||||||
current = -1;
|
current = -1;
|
||||||
}
|
}
|
||||||
[dragView setNeedsDisplay: YES];
|
[dragView setNeedsDisplay: YES];
|
||||||
|
@ -821,3 +814,51 @@ static NSImage *dragImage = nil;
|
||||||
return substituteClasses;
|
return substituteClasses;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation GormPalettesManager (NSToolbarDelegate)
|
||||||
|
|
||||||
|
- (NSToolbarItem*)toolbar: (NSToolbar*)toolbar
|
||||||
|
itemForItemIdentifier: (NSString*)itemIdentifier
|
||||||
|
willBeInsertedIntoToolbar: (BOOL)flag
|
||||||
|
{
|
||||||
|
NSToolbarItem *toolbarItem = AUTORELEASE([[NSToolbarItem alloc]
|
||||||
|
initWithItemIdentifier: itemIdentifier]);
|
||||||
|
id palette = [palettesDict objectForKey: itemIdentifier];
|
||||||
|
NSImage *image = [palette paletteIcon];
|
||||||
|
int tag = [palettes indexOfObject: palette];
|
||||||
|
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle: itemIdentifier
|
||||||
|
action: @selector(setCurrentPalette:)
|
||||||
|
keyEquivalent: @""];
|
||||||
|
|
||||||
|
// set up the toolbar...
|
||||||
|
[toolbarItem setLabel: itemIdentifier];
|
||||||
|
[toolbarItem setToolTip: itemIdentifier];
|
||||||
|
[toolbarItem setImage: image];
|
||||||
|
[toolbarItem setTarget: self];
|
||||||
|
[toolbarItem setAction: @selector(setCurrentPalette:)];
|
||||||
|
[toolbarItem setTag: tag];
|
||||||
|
[toolbarItem setMenuFormRepresentation: menuItem];
|
||||||
|
|
||||||
|
// complete setup of menu item.
|
||||||
|
[menuItem setTarget: self];
|
||||||
|
[menuItem setTag: tag];
|
||||||
|
RELEASE(menuItem);
|
||||||
|
|
||||||
|
return toolbarItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray*) toolbarAllowedItemIdentifiers: (NSToolbar*)toolbar
|
||||||
|
{
|
||||||
|
return paletteNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray*) toolbarDefaultItemIdentifiers: (NSToolbar*)toolbar
|
||||||
|
{
|
||||||
|
return [NSArray array];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray*) toolbarSelectableItemIdentifiers: (NSToolbar*)toolbar
|
||||||
|
{
|
||||||
|
return paletteNames;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
Loading…
Reference in a new issue