4 // Created by Takashi T. Hamada on Thu Nov 01 2000.
5 // Copyright (c) 2000,2001 Takashi T. Hamada. All rights reserved.
8 // bb 25.06.2002 - added acceptsFirstMouse method for click-through
9 // bb 26.06.2002 - removed the isOpaque method
12 #import "TranslucentView.h"
15 @implementation TranslucentView
17 //-------------------------------------------------------------
19 //-------------------------------------------------------------
20 - (id)initWithFrame:(NSRect)frameRect
22 self = [super initWithFrame:frameRect];
23 calBGViewRectTag = [self addTrackingRect:[self frame] owner:self userData:&ImageOpacity assumeInside:YES];
24 theContentDrawer = nil;
30 //-------------------------------------------------------------
31 // draw translucent rectangle
32 //-------------------------------------------------------------
33 - (void)drawRect:(NSRect)rect
35 [[NSColor clearColor] set];
39 if (theContentDrawer != nil)
40 [theContentDrawer performSelector:theDrawingMethod];
44 //-------------------------------------------------------------
46 //-------------------------------------------------------------
47 //- (BOOL)isOpaque { return NO; }
50 //-------------------------------------------------------------
52 //-------------------------------------------------------------
53 - (void)mouseDown:(NSEvent *)theEvent
57 NSPoint globalMouseLoc;
58 NSPoint offsetMouseLoc;
59 NSPoint tempWindowLoc;
62 offsetMouseLoc.x = offsetMouseLoc.y = 0; // avoid uninitialized warning
63 origFrame = [[self window] frame];
64 while( 1 ) { // gee! entering into the infinity loop...
65 mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
67 switch ([theEvent type]) {
69 // save the initial mouse location
70 offsetMouseLoc = mouseLoc;
72 case NSLeftMouseDragged:
73 // get the mouse location in the global coordinates
74 globalMouseLoc = [[self window] convertBaseToScreen:mouseLoc];
75 // calculate the new origin of the window
76 tempWindowLoc.x = (globalMouseLoc.x - offsetMouseLoc.x);
77 tempWindowLoc.y = (globalMouseLoc.y - offsetMouseLoc.y);
78 // get the window's location and size in the global coodinate system
79 [[self window] setFrameOrigin:tempWindowLoc]; // move and resize the window
90 theEvent = [[self window] nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask) ];
97 //-------------------------------------------------------------
98 // set the transparency of this view
99 //-------------------------------------------------------------
100 - (void)setContentDrawer:(id)theDrawer method:(SEL)theMethod
102 theContentDrawer = theDrawer;
103 theDrawingMethod = theMethod;
107 //-------------------------------------------------------------
108 // allow click-through
109 //-------------------------------------------------------------
110 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent