File: MQResultSetCell.m

package info (click to toggle)
mysql-admin 1.2.5rc-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 80,944 kB
  • ctags: 43,103
  • sloc: sql: 295,916; pascal: 256,535; cpp: 74,487; ansic: 68,881; objc: 26,417; sh: 16,867; yacc: 10,755; java: 9,917; xml: 8,453; php: 2,806; python: 2,068; makefile: 1,252; perl: 3
file content (102 lines) | stat: -rw-r--r-- 2,384 bytes parent folder | download | duplicates (4)
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