1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
//
// MQResultSetCell.m
// MySQL QueryBrowser
//
// Created by Alfredo Kojima on 5/13/05.
// Copyright 2005 MySQL AB. All rights reserved.
//
#import "MQResultSetCell.h"
#import <MySQLToolsCommon/mxUtils.h>
@implementation MQResultSetCell
- (id)init
{
self= [super init];
if (self)
{
_blobIcon= [MXGetImageFromBundle([NSBundle bundleForClass:[self class]],@"blob_icon.png") retain];
_nullIcon= [MXGetImageFromBundle([NSBundle bundleForClass:[self class]],@"field_overlay_null.png") retain];
}
return self;
}
- (id)copyWithZone:(NSZone*)zone
{
MQResultSetCell *copy = (MQResultSetCell*)[super copyWithZone:zone];
copy->_blobIcon = [_blobIcon retain];
copy->_nullIcon = [_nullIcon retain];
return copy;
}
- (void)dealloc
{
[_blobIcon release];
[_nullIcon release];
[super dealloc];
}
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent
{
if (!_blob)
{
aRect.size.height-= 3.0;
aRect.size.width-= 3.0;
[super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent];
}
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength
{
[self setBackgroundColor:[NSColor whiteColor]];
[self setTextColor:[NSColor blackColor]];
aRect.size.height-= 3.0;
aRect.size.width-= 3.0;
[super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
}
- (void)setPlaceholder:(BOOL)flag
{
_placeholder= flag;
}
- (void)setIsBlob:(BOOL)flag
{
_blob= flag;
}
- (void)setIsNull:(BOOL)flag
{
_null= flag;
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSPoint point= cellFrame.origin;
point.x+= 4;
[super drawWithFrame:cellFrame inView:controlView];
if (!_placeholder)
{
if (_blob)
{
if ([self objectValue])
{
point.y+= [_blobIcon size].height + (NSHeight(cellFrame)-[_blobIcon size].height)/2;
[_blobIcon compositeToPoint:point operation:NSCompositeSourceOver];
}
}
if (_null)
{
point.y+= [_nullIcon size].height + (NSHeight(cellFrame)-[_nullIcon size].height)/2;
[_nullIcon compositeToPoint:point operation:NSCompositeSourceOver];
}
}
}
@end
|