mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 12:01:16 +00:00
Added new alignment and layout menus.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21405 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
793695920e
commit
58f3adfdec
9 changed files with 183 additions and 4 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2005-07-04 17:53 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* English.lproj/Gorm.gorm: Added Layout and Alignment menus.
|
||||||
|
* GormCore/GormDocument.[hm]: Added alignSelectedObjects: and
|
||||||
|
arrangeSelectedObjects: methods.
|
||||||
|
* GormCore/GormProtocol.h: Added alignSelectedObjects: and
|
||||||
|
arrangeSelectedObjects: methods declarations
|
||||||
|
* GormCore/NSView+GormExtensions.[hm]: Added moveViewToFront: and
|
||||||
|
moveViewToBack: methods.
|
||||||
|
* Gorm.m: Added alignSelectedObjects: and
|
||||||
|
arrangeSelectedObjects: methods.
|
||||||
|
|
||||||
2005-07-03 12:52 Gregory John Casamento <greg_casamento@yahoo.com>
|
2005-07-03 12:52 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Palettes/4Data/main.m: Minor fix in
|
* Palettes/4Data/main.m: Minor fix in
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||||
FirstResponder = {
|
FirstResponder = {
|
||||||
Actions = (
|
Actions = (
|
||||||
|
"arrangeSelectedObjects:",
|
||||||
"exportStrings:",
|
"exportStrings:",
|
||||||
|
"alignSelectedObjects:",
|
||||||
"orderFrontFontPanel:",
|
"orderFrontFontPanel:",
|
||||||
"translate:"
|
"translate:"
|
||||||
);
|
);
|
||||||
|
@ -52,7 +54,9 @@
|
||||||
"preferencesPanel:",
|
"preferencesPanel:",
|
||||||
"guideline:",
|
"guideline:",
|
||||||
"translate:",
|
"translate:",
|
||||||
"exportStrings:"
|
"exportStrings:",
|
||||||
|
"arrangeSelectedObjects:",
|
||||||
|
"alignSelectedObjects:"
|
||||||
);
|
);
|
||||||
Outlets = (
|
Outlets = (
|
||||||
gormMenu,
|
gormMenu,
|
||||||
|
|
Binary file not shown.
22
Gorm.m
22
Gorm.m
|
@ -1179,6 +1179,18 @@
|
||||||
connectDestination = nil;
|
connectDestination = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) arrangeSelectedObjects: (id)sender
|
||||||
|
{
|
||||||
|
[[self activeDocument] performSelector: @selector(arrangeSelectedObjects:)
|
||||||
|
withObject: sender];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) alignSelectedObjects: (id)sender
|
||||||
|
{
|
||||||
|
[[self activeDocument] performSelector: @selector(alignSelectedObjects:)
|
||||||
|
withObject: sender];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) translate: (id)sender
|
- (void) translate: (id)sender
|
||||||
{
|
{
|
||||||
[[self activeDocument] performSelector: @selector(translate)];
|
[[self activeDocument] performSelector: @selector(translate)];
|
||||||
|
@ -1228,6 +1240,16 @@
|
||||||
if (active == nil)
|
if (active == nil)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
else if (sel_eq(action, @selector(arrangeSelectedObjects:)))
|
||||||
|
{
|
||||||
|
if (active == nil)
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
else if (sel_eq(action, @selector(alignSelectedObjects:)))
|
||||||
|
{
|
||||||
|
if (active == nil)
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
else if (sel_eq(action, @selector(exportStrings:)))
|
else if (sel_eq(action, @selector(exportStrings:)))
|
||||||
{
|
{
|
||||||
if (active == nil)
|
if (active == nil)
|
||||||
|
|
|
@ -154,6 +154,10 @@
|
||||||
- (id) fontManager;
|
- (id) fontManager;
|
||||||
- (id) firstResponder;
|
- (id) firstResponder;
|
||||||
|
|
||||||
|
/* Layout */
|
||||||
|
- (void) arrangeSelectedObjects: (id)sender;
|
||||||
|
- (void) alignSelectedObjects: (id)sender;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* windowAndRect:forObject: is called by Gorm to determine where it should
|
* windowAndRect:forObject: is called by Gorm to determine where it should
|
||||||
* draw selection markup
|
* draw selection markup
|
||||||
|
|
|
@ -4006,6 +4006,90 @@ static NSImage *fileImage = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) arrangeSelectedObjects: (id)sender
|
||||||
|
{
|
||||||
|
NSArray *selection = [[(id<IB>)NSApp selectionOwner] selection];
|
||||||
|
int tag = [sender tag];
|
||||||
|
NSEnumerator *en = [selection objectEnumerator];
|
||||||
|
id v = nil;
|
||||||
|
|
||||||
|
while((v = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if([v isKindOfClass: [NSView class]])
|
||||||
|
{
|
||||||
|
id editor = [self editorForObject: v create: NO];
|
||||||
|
if([editor respondsToSelector: @selector(superview)])
|
||||||
|
{
|
||||||
|
id superview = [editor superview];
|
||||||
|
if(tag == 0) // bring to front...
|
||||||
|
{
|
||||||
|
[superview moveViewToFront: editor];
|
||||||
|
}
|
||||||
|
else if(tag == 1) // send to back
|
||||||
|
{
|
||||||
|
[superview moveViewToBack: editor];
|
||||||
|
}
|
||||||
|
[superview setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) alignSelectedObjects: (id)sender
|
||||||
|
{
|
||||||
|
NSArray *selection = [[(id<IB>)NSApp selectionOwner] selection];
|
||||||
|
int tag = [sender tag];
|
||||||
|
NSEnumerator *en = [selection objectEnumerator];
|
||||||
|
id v = nil;
|
||||||
|
|
||||||
|
id prev = nil;
|
||||||
|
while((v = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if([v isKindOfClass: [NSView class]])
|
||||||
|
{
|
||||||
|
id editor = [self editorForObject: v create: NO];
|
||||||
|
if(prev != nil)
|
||||||
|
{
|
||||||
|
NSRect r = [prev frame];
|
||||||
|
NSRect e = [editor frame];
|
||||||
|
if(tag == 0) // center vertically
|
||||||
|
{
|
||||||
|
float center = (r.origin.x + (r.size.width / 2));
|
||||||
|
e.origin.x = (center - (e.size.width / 2));
|
||||||
|
}
|
||||||
|
else if(tag == 1) // center horizontally
|
||||||
|
{
|
||||||
|
float center = (r.origin.y + (r.size.height / 2));
|
||||||
|
e.origin.y = (center - (e.size.height / 2));
|
||||||
|
}
|
||||||
|
else if(tag == 2) // align left
|
||||||
|
{
|
||||||
|
e.origin.x = r.origin.x;
|
||||||
|
}
|
||||||
|
else if(tag == 3) // align right
|
||||||
|
{
|
||||||
|
float right = (r.origin.x + r.size.width);
|
||||||
|
e.origin.x = (right - e.size.width);
|
||||||
|
}
|
||||||
|
else if(tag == 4) // align top
|
||||||
|
{
|
||||||
|
float top = (r.origin.y + r.size.height);
|
||||||
|
e.origin.y = (top - e.size.height);
|
||||||
|
}
|
||||||
|
else if(tag == 5) // align bottom
|
||||||
|
{
|
||||||
|
e.origin.y = r.origin.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
[editor setFrame: e];
|
||||||
|
[[editor superview] setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
prev = editor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GormDocument (MenuValidation)
|
@implementation GormDocument (MenuValidation)
|
||||||
|
|
|
@ -72,7 +72,9 @@
|
||||||
- (void) loadSound: (id) sender;
|
- (void) loadSound: (id) sender;
|
||||||
- (void) loadImage: (id) sender;
|
- (void) loadImage: (id) sender;
|
||||||
|
|
||||||
// grouping
|
// grouping/layout
|
||||||
|
- (void) arrangeSelectedObjects: (id)sender;
|
||||||
|
- (void) alignSelectedObjects: (id)sender;
|
||||||
- (void) groupSelectionInSplitView: (id)sender;
|
- (void) groupSelectionInSplitView: (id)sender;
|
||||||
- (void) groupSelectionInBox: (id)sender;
|
- (void) groupSelectionInBox: (id)sender;
|
||||||
- (void) groupSelectionInScrollView: (id)sender;
|
- (void) groupSelectionInScrollView: (id)sender;
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
@interface NSView (GormExtensions)
|
@interface NSView (GormExtensions)
|
||||||
- (NSArray *) superviews;
|
- (NSArray *) superviews;
|
||||||
- (BOOL) hasSuperviewKindOfClass: (Class)cls;
|
- (BOOL) hasSuperviewKindOfClass: (Class)cls;
|
||||||
|
- (void) moveViewToFront: (NSView *)sv;
|
||||||
|
- (void) moveViewToBack: (NSView *)sv;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSEnumerator.h>
|
#include <Foundation/NSEnumerator.h>
|
||||||
|
#include <Foundation/NSDebug.h>
|
||||||
|
|
||||||
#include "NSView+GormExtensions.h"
|
#include "NSView+GormExtensions.h"
|
||||||
#include <InterfaceBuilder/IBViewResourceDragging.h>
|
#include <InterfaceBuilder/IBViewResourceDragging.h>
|
||||||
#include <Foundation/NSArray.h>
|
|
||||||
#include <Foundation/NSEnumerator.h>
|
|
||||||
|
|
||||||
@implementation NSView (GormExtensions)
|
@implementation NSView (GormExtensions)
|
||||||
/**
|
/**
|
||||||
|
@ -64,10 +64,59 @@
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the specified subview to the end of the list, so it's displayed
|
||||||
|
* in front of the other views.
|
||||||
|
*/
|
||||||
|
- (void) moveViewToFront: (NSView *)sv
|
||||||
|
{
|
||||||
|
NSDebugLog(@"move to front %@", sv);
|
||||||
|
if([_sub_views containsObject: sv])
|
||||||
|
{
|
||||||
|
RETAIN(sv); // make sure it doesn't deallocate the view.
|
||||||
|
[_sub_views removeObject: sv];
|
||||||
|
[_sub_views addObject: sv]; // add it to the end.
|
||||||
|
RELEASE(sv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the specified subview to the beginning of the list, so it's
|
||||||
|
* displayed behind all of the other views.
|
||||||
|
*/
|
||||||
|
- (void) moveViewToBack: (NSView *)sv
|
||||||
|
{
|
||||||
|
NSDebugLog(@"move to back %@", sv);
|
||||||
|
if([_sub_views containsObject: sv])
|
||||||
|
{
|
||||||
|
RETAIN(sv); // make sure it doesn't deallocate the view.
|
||||||
|
[_sub_views removeObject: sv];
|
||||||
|
if([_sub_views count] > 0)
|
||||||
|
{
|
||||||
|
[_sub_views insertObject: sv
|
||||||
|
atIndex: 0]; // add it to the end.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[_sub_views addObject: sv];
|
||||||
|
}
|
||||||
|
RELEASE(sv);
|
||||||
|
}
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registry of delegates. This allows the implementation of the protocol
|
||||||
|
* to select from the list of delegates to determine which one should be called.
|
||||||
|
*/
|
||||||
static NSMutableArray *_registeredViewResourceDraggingDelegates = nil;
|
static NSMutableArray *_registeredViewResourceDraggingDelegates = nil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IBViewResourceDraggingDelegates implementation. These methods
|
||||||
|
* make it possible to declare types in palettes and dynamically select the
|
||||||
|
* appropriate delegate to handle the addition of an object to the document.
|
||||||
|
*/
|
||||||
@implementation NSView (IBViewResourceDraggingDelegates)
|
@implementation NSView (IBViewResourceDraggingDelegates)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue