2005-08-06 17:59:08 +00:00
|
|
|
/*
|
|
|
|
GormImageViewAttributesInspector.m
|
|
|
|
|
|
|
|
Copyright (C) 2001-2005 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Laurent Julliard <laurent@julliard-online.org>
|
|
|
|
Date: Nov 2001
|
|
|
|
|
|
|
|
This file is part of GNUstep.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-11-05 23:44:36 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2005-08-06 17:59:08 +00:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
July 2005 : Split inspector classes into separate files.
|
|
|
|
Always use ok: revert: methods
|
|
|
|
Clean up
|
|
|
|
Author : Fabien Vallon <fabien@sonappart.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GormImageViewAttributesInspector.h"
|
|
|
|
#include <Foundation/NSNotification.h>
|
|
|
|
#include <AppKit/NSButton.h>
|
|
|
|
#include <AppKit/NSImage.h>
|
|
|
|
#include <AppKit/NSImageView.h>
|
|
|
|
#include <AppKit/NSMatrix.h>
|
|
|
|
#include <AppKit/NSNibLoading.h>
|
|
|
|
#include <AppKit/NSTextField.h>
|
|
|
|
|
|
|
|
/* This macro makes sure that the string contains a value, even if @"" */
|
2008-04-14 21:40:11 +00:00
|
|
|
#define VSTR(str) ({id _str = (id)str; (_str) ? (id)_str : (id)(@"");})
|
2005-08-06 17:59:08 +00:00
|
|
|
|
|
|
|
@implementation GormImageViewAttributesInspector
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ([super init] == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
if ([NSBundle loadNibNamed: @"GormNSImageViewInspector" owner: self] == NO)
|
|
|
|
{
|
|
|
|
NSLog(@"Could not gorm GormImageViewInspector");
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Commit changes that the user makes in the Attributes Inspector */
|
2005-08-12 02:52:49 +00:00
|
|
|
- (void) ok: (id)sender
|
2005-08-06 17:59:08 +00:00
|
|
|
{
|
|
|
|
/* icon name */
|
|
|
|
if (sender == iconField)
|
|
|
|
{
|
|
|
|
NSString *name = [sender stringValue];
|
|
|
|
NSImage *image;
|
|
|
|
|
|
|
|
if (name == nil || [name isEqual: @""])
|
|
|
|
{
|
|
|
|
[object setImage: nil];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
image = [NSImage imageNamed: name];
|
|
|
|
if (image == nil)
|
|
|
|
{
|
|
|
|
image = [[NSImage alloc] initByReferencingFile: name];
|
|
|
|
if (image)
|
2005-08-12 02:52:49 +00:00
|
|
|
{
|
|
|
|
[image setName: name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[object setImage: image ];
|
2005-08-06 17:59:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* border */
|
|
|
|
else if (sender == borderMatrix)
|
|
|
|
{
|
|
|
|
[object setImageFrameStyle: [[sender selectedCell] tag]];
|
|
|
|
}
|
|
|
|
/* alignment */
|
|
|
|
else if (sender == alignmentMatrix)
|
|
|
|
{
|
|
|
|
[object setImageAlignment: [[sender selectedCell] tag]];
|
|
|
|
}
|
|
|
|
/* scaling */
|
|
|
|
else if (sender == scalingMatrix)
|
|
|
|
{
|
|
|
|
[object setImageScaling: [[sender selectedCell] tag]];
|
|
|
|
}
|
|
|
|
/* editable */
|
|
|
|
else if (sender == editableSwitch)
|
|
|
|
{
|
|
|
|
[object setEditable: ([sender state] == NSOnState)];
|
|
|
|
}
|
|
|
|
|
|
|
|
[super ok:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sync from object ( ImageView ) changes to the inspector */
|
|
|
|
-(void) revert:(id) sender
|
|
|
|
{
|
|
|
|
if ( object == nil)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( [ [[object image] name] isEqualToString: @"Sunday_seurat.tiff"] )
|
|
|
|
[object setImage: nil];
|
|
|
|
|
|
|
|
[iconField setStringValue: VSTR([[object image] name])];
|
|
|
|
[borderMatrix selectCellWithTag: [object imageFrameStyle]];
|
|
|
|
[alignmentMatrix selectCellWithTag: [object imageAlignment]];
|
|
|
|
[scalingMatrix selectCellWithTag: [object imageScaling]];
|
|
|
|
[editableSwitch setState: [object isEditable]];
|
|
|
|
|
|
|
|
[super revert:sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delegate method for changing the ImageView Name */
|
|
|
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
[self ok:[aNotification object]];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|