File: GSImageTabViewItem.m

package info (click to toggle)
gnustep-examples 1%3A1.4.0%2Bgit20210703-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,164 kB
  • sloc: objc: 17,202; makefile: 56
file content (65 lines) | stat: -rw-r--r-- 1,366 bytes parent folder | download | duplicates (10)
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
#include "GSImageTabViewItem.h"

@implementation GSImageTabViewItem
- (void)setImage:(NSImage *)image
{
  ASSIGN(item_image, image);
}

- (NSImage *)image;
{
  return item_image;
}

- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel;
{
  NSSize rSize = [super sizeOfLabel: shouldTruncateLabel];
  NSSize iSize = [[self image] size];

  return NSMakeSize(rSize.width + iSize.width + 2, 
		    MAX(rSize.height, iSize.height));
}

- (void)drawLabel:(BOOL)shouldTruncateLabel
           inRect:(NSRect)tabRect
{
  NSGraphicsContext     *ctxt = GSCurrentContext();
  NSRect lRect;
  NSRect fRect;

  _rect = tabRect;
 
  DPSgsave(ctxt); 

  fRect = tabRect;
  
  if (_state == NSSelectedTab) {
    fRect.origin.y -= 1;
    fRect.size.height += 1;
    [[NSColor lightGrayColor] set];
    NSRectFill(fRect);
  } else if (_state == NSBackgroundTab) {
    [[NSColor lightGrayColor] set];
    NSRectFill(fRect);
  } else {
    [[NSColor lightGrayColor] set];
    NSRectFill(fRect);
  }
 
  lRect = tabRect;
  lRect.origin.y += 3;
  [[_tabview font] set];

  [[self image] compositeToPoint: NSMakePoint(lRect.origin.x,
					      lRect.origin.y) 
		operation: NSCompositeSourceOver];

  lRect.origin.x += [[self image] size].width + 2;
  
  DPSsetgray(ctxt, 0);
  DPSmoveto(ctxt, lRect.origin.x, lRect.origin.y);
  DPSshow(ctxt, [_label cString]);

  DPSgrestore(ctxt);  
}
@end