2006-10-09 18:56:25 +00:00
|
|
|
/**
|
|
|
|
EntityView.m
|
|
|
|
|
2007-01-05 16:17:04 +00:00
|
|
|
Author: Matt Rice <ratmice@gmail.com>
|
2006-10-09 18:56:25 +00:00
|
|
|
Date: Oct 2006
|
|
|
|
|
|
|
|
This file is part of DBModeler.
|
|
|
|
|
|
|
|
<license>
|
|
|
|
DBModeler is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-12 06:39:22 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2006-10-09 18:56:25 +00:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
DBModeler 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 DBModeler; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
</license>
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "EntityView.h"
|
|
|
|
#include "DiagramView.h"
|
|
|
|
#include "AttributeCell.h"
|
|
|
|
#include "NSView+Additions.h"
|
2008-05-09 20:21:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef NeXT_GUI_LIBRARY
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
#else
|
2006-10-09 18:56:25 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
2008-05-09 20:21:17 +00:00
|
|
|
#include <AppKit/NSColor.h>
|
|
|
|
#include <AppKit/NSFont.h>
|
2006-10-09 18:56:25 +00:00
|
|
|
#include <AppKit/NSGraphics.h>
|
|
|
|
#include <AppKit/NSTextFieldCell.h>
|
|
|
|
#include <AppKit/NSMatrix.h>
|
|
|
|
#include <AppKit/NSEvent.h>
|
|
|
|
#include <AppKit/NSBox.h>
|
|
|
|
#include <AppKit/NSImageCell.h>
|
|
|
|
#include <AppKit/NSImage.h>
|
|
|
|
#include <AppKit/NSScrollView.h>
|
2008-05-09 20:21:17 +00:00
|
|
|
#endif
|
2006-10-09 18:56:25 +00:00
|
|
|
|
2008-05-09 20:21:17 +00:00
|
|
|
#include <GNUstepBase/GNUstep.h>
|
2006-10-09 18:56:25 +00:00
|
|
|
|
|
|
|
@interface AttributeMatrix : NSMatrix
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AttributeMatrix : NSMatrix
|
|
|
|
- (void) mouseDown:(NSEvent *)ev
|
|
|
|
{
|
|
|
|
[self orderViewFront:self];
|
|
|
|
[super mouseDown:ev];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface AttributeBox : NSBox
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AttributeBox : NSBox
|
|
|
|
- (void) drawRect:(NSRect)aRect
|
|
|
|
{
|
|
|
|
[[NSColor blackColor] set];
|
|
|
|
NSFrameRect(aRect);
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation EntityView
|
|
|
|
- (NSString *) description
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat:@"<%@ %p %@>", [self class], self, [_title stringValue]];
|
|
|
|
}
|
|
|
|
- (BOOL) isFlipped
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setTitle:(NSString *)title
|
|
|
|
{
|
|
|
|
[_title setStringValue:title];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (AttributeCell *)cellAtRow:(int)row
|
|
|
|
{
|
|
|
|
return [_attributesView cellAtRow:row column:0];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setNumberOfAttributes:(int)num
|
|
|
|
{
|
|
|
|
[_attributesView renewRows:num columns:1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) sizeToFit
|
|
|
|
{
|
|
|
|
NSSize s;
|
|
|
|
NSRect r;
|
|
|
|
[_attributesView sizeToCells];
|
|
|
|
[_attributesView sizeToFit];
|
|
|
|
[_box sizeToFit];
|
|
|
|
|
|
|
|
_titleRect.size = [_title cellSize];
|
|
|
|
r = [_box bounds];
|
|
|
|
s.height = _titleRect.size.height + r.size.height + 4;
|
|
|
|
s.width = ((_titleRect.size.width > r.size.width) ? _titleRect.size.width : r.size.width) + 4;
|
|
|
|
|
|
|
|
[_box setFrameOrigin:NSMakePoint(2, _titleRect.size.height + 2)];
|
|
|
|
[self setFrameSize:s];
|
|
|
|
[self setNeedsDisplay:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_title);
|
2007-01-10 12:13:37 +00:00
|
|
|
[super dealloc];
|
2006-10-09 18:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithFrame:(NSRect)frameRect
|
|
|
|
{
|
|
|
|
self = [super initWithFrame:frameRect];
|
|
|
|
|
|
|
|
_title = [[TitleCell alloc] init];
|
|
|
|
[_title setFont: [NSFont boldSystemFontOfSize:0]];
|
|
|
|
[_title setEditable:NO];
|
|
|
|
[_title setSelectable:NO];
|
|
|
|
[_title setAlignment:NSLeftTextAlignment];
|
|
|
|
_titleRect = NSMakeRect(2,2, 0, 0);
|
|
|
|
|
|
|
|
_box = [[AttributeBox alloc] initWithFrame:NSMakeRect(2,2,0,0)];
|
|
|
|
[_box setContentViewMargins:NSMakeSize(0,0)];
|
|
|
|
[_box setBorderType:NSBezelBorder];
|
|
|
|
[_box setTitlePosition:NSNoTitle];
|
|
|
|
|
|
|
|
_attributesView = [[AttributeMatrix alloc] initWithFrame:NSMakeRect(1,1,1,1)];
|
|
|
|
[_attributesView setBackgroundColor:[NSColor whiteColor]];
|
|
|
|
[_attributesView setPrototype:[[AttributeCell alloc] init]];
|
|
|
|
[_attributesView setAutosizesCells:YES];
|
|
|
|
|
|
|
|
[[_box contentView] addSubview:_attributesView];
|
|
|
|
RELEASE(_attributesView);
|
|
|
|
[_box sizeToFit];
|
|
|
|
|
|
|
|
[self addSubview:_box];
|
|
|
|
RELEASE(_box);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) drawRect:(NSRect)dRect
|
|
|
|
{
|
|
|
|
[[NSColor lightGrayColor] set];
|
|
|
|
NSRectFill([self bounds]);
|
|
|
|
|
|
|
|
[_title drawWithFrame:_titleRect inView:self];
|
|
|
|
[[NSColor controlShadowColor] set];
|
|
|
|
NSFrameRect(_bounds);
|
|
|
|
|
|
|
|
[_attributesView setNeedsDisplay:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) orderViewFront:(NSView *)v
|
|
|
|
{
|
|
|
|
[(DiagramView *)[self superview] orderViewFront:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) mouseDown:(NSEvent *)ev
|
|
|
|
{
|
|
|
|
NSPoint pt = [self convertPoint:[ev locationInWindow] fromView:nil];
|
|
|
|
// allow clicking on title to move it..
|
|
|
|
if (NSMouseInRect(pt, NSMakeRect(0, 0, _frame.size.width, _titleRect.size.height), YES))
|
|
|
|
{
|
* Makefile.postamble (after-distclean::): Remove generated
GNUmakefile.
* gdl2.make.in (ADDITIONAL_NATIVE_LIBS): Don't force
linking of any GDL2 libraries just to get the version.
[API Change].
* variable-processing.make: Remove file (functionality
is now supplied by -make).
* EOInterface/GNUmakefile, EOAccess/EOModelGroup.m,
EOAccess/GNUmakefile, EOControl/GNUmakefile,
DBModeler/GNUmakefile, Tools/GNUmakefile,
GDL2Palette/GNUmakefile, EOModeler/GNUmakefile,
EOAdaptors/SQLiteAdaptor/LoginPanel/GNUmakefile,
EOAdaptors/PostgreSQLAdaptor/LoginPanel/GNUmakefile:
Remove reference to variable-processing.make.
* EOControl/EOGenericRecord.m
([-_infoForInstanceVariableNamed:stringName:retType:retSize:retOffset:]):
Use marker that matches underlying type signedness.
([-_getValueForKey:selector:type:size:offset:],
[-_setValueForKey:selector:type:size:offset:]):
Match 'offset' with underlying type signedness and update
marker.
([-storedValueForKey:],[-takeStoredValue:forKey:],
[-takeValue:forKey:]): Update signedness of offset to avoid
compiler warnings.
* EOControl/EOClassDescription.m
([NSObject-validateValue:forKey:]): Correct signedness of 'buf'.
* EOControl/EOPrivate.m (GDL2_PrivateInit): Fix assignemnt of
GDL2_EOEditingContext_recordObjectGlobalIDIMP.
* EOAccess/EOModelGroup.m
([EOObjectStoreCoordinator-modelGroup]): Correct method
signature to avoid compiler warnings.
* DBModeler/EntityView.m ([-mouseDown:]): Match class
with return type of initializer method to avoid
compiler warnings and unnecessary cast.
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m (newNumberValue):
Change type of 'data' to match usage.
([-fetchRowWithZone:]): Cast return type of sqlite3_column_text
to match expected usage to avoid compiler warnings.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@25545 72102866-910b-0410-8b05-ffd578937521
2007-10-31 05:32:46 +00:00
|
|
|
NSView *dv = [self superview];
|
2006-10-09 18:56:25 +00:00
|
|
|
float in, up;
|
|
|
|
pt = [dv convertPoint:pt fromView:self];
|
|
|
|
up = pt.y - _frame.origin.y ;
|
|
|
|
in = pt.x - _frame.origin.x;
|
|
|
|
|
|
|
|
[dv orderViewFront:self];
|
|
|
|
|
|
|
|
while ((ev = [NSApp nextEventMatchingMask:NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:nil inMode:NSEventTrackingRunLoopMode dequeue:YES]))
|
Replaced tabs with spaces throughout the DBModeler sub-project.
* DBModeler/AdaptorsPanel.m, DBModeler/AttributeCell.m,
DBModeler/ConsistencyChecker.m, DBModeler/DefaultColumnProvider.m,
DBModeler/DiagramView.m, DBModeler/EOAdditions.m, DBModeler/EntityView.m,
DBModeler/GNUmakefile, DBModeler/KVDataSource.m,
DBModeler/MainModelEditor.h, DBModeler/MainModelEditor.m,
DBModeler/ModelerAttributeEditor.m, DBModeler/ModelerEntityEditor.h,
DBModeler/ModelerEntityEditor.m,
DBModeler/ModelerTableEmbedibleEditor.h,
DBModeler/ModelerTableEmbedibleEditor.m,
DBModeler/NSView+Additions.m, DBModeler/Preferences.m,
DBModeler/SQLGenerator.m, DBModeler/Inspectors/AdvancedEntityInspector.m,
DBModeler/Inspectors/AttributeInspector.h,
DBModeler/Inspectors/AttributeInspector.m,
DBModeler/Inspectors/RelationshipInspector.h,
DBModeler/Inspectors/RelationshipInspector.m
White-space clean-up. Replaced tabs with spaces.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@26556 72102866-910b-0410-8b05-ffd578937521
2008-05-23 12:11:26 +00:00
|
|
|
{
|
|
|
|
float tox, toy;
|
|
|
|
if ([ev type] == NSLeftMouseUp) break;
|
2006-10-09 18:56:25 +00:00
|
|
|
NSPoint pt2 = [dv convertPoint:[ev locationInWindow] fromView:nil];
|
Replaced tabs with spaces throughout the DBModeler sub-project.
* DBModeler/AdaptorsPanel.m, DBModeler/AttributeCell.m,
DBModeler/ConsistencyChecker.m, DBModeler/DefaultColumnProvider.m,
DBModeler/DiagramView.m, DBModeler/EOAdditions.m, DBModeler/EntityView.m,
DBModeler/GNUmakefile, DBModeler/KVDataSource.m,
DBModeler/MainModelEditor.h, DBModeler/MainModelEditor.m,
DBModeler/ModelerAttributeEditor.m, DBModeler/ModelerEntityEditor.h,
DBModeler/ModelerEntityEditor.m,
DBModeler/ModelerTableEmbedibleEditor.h,
DBModeler/ModelerTableEmbedibleEditor.m,
DBModeler/NSView+Additions.m, DBModeler/Preferences.m,
DBModeler/SQLGenerator.m, DBModeler/Inspectors/AdvancedEntityInspector.m,
DBModeler/Inspectors/AttributeInspector.h,
DBModeler/Inspectors/AttributeInspector.m,
DBModeler/Inspectors/RelationshipInspector.h,
DBModeler/Inspectors/RelationshipInspector.m
White-space clean-up. Replaced tabs with spaces.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@26556 72102866-910b-0410-8b05-ffd578937521
2008-05-23 12:11:26 +00:00
|
|
|
tox = pt2.x - in;
|
|
|
|
toy = pt2.y - up;
|
|
|
|
/* contrain to a positive x,y. */
|
|
|
|
// at 1.0 we can get some libart artifacts for some reason..
|
|
|
|
pt2.x = tox > 1.0 ? tox : 1.1;
|
|
|
|
pt2.y = toy > 1.0 ? toy : 1.1;
|
|
|
|
[self setFrameOrigin:pt2];
|
|
|
|
[self autoscroll:ev];
|
|
|
|
[dv setNeedsDisplay:YES];
|
|
|
|
[self setNeedsDisplay:YES];
|
|
|
|
}
|
2006-10-09 18:56:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect) attributeRectAtRow:(int)row
|
|
|
|
{
|
|
|
|
NSRect cellFrame = [_attributesView cellFrameAtRow:row column:0];
|
|
|
|
cellFrame.origin.y += _titleRect.origin.y + _titleRect.size.height;
|
|
|
|
return cellFrame;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|