1 /*
2        ImageView.h
3
4	This file is part of Preview
5
6	Copyright (C) 2003;2004 Fabien VALLON
7	2003,2004 Alcove ( http://www.alcove.com )
8	Additional copyrights here
9
10	Authors : Fabien VALLON <fabien@sonappart.net>
11	Date:	10 Jan 2005
12
13	This program is free software; you can redistribute it and/or
14	modify it under the terms of the GNU General Public License as
15	published by the Free Software Foundation; either version 2 of
16	the License, or (at your option) any later version.
17
18	This program is distributed in the hope that it will be useful,
19	but WITHOUT ANY WARRANTY; without even the implied warranty of
20	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
22	See the GNU General Public License for more details.
23
24	You should have received a copy of the GNU General Public
25	License along with this program; if not, write to:
26
27		Free Software Foundation, Inc.
28		59 Temple Place - Suite 330
29		Boston, MA  02111-1307, USA
30*/
31
32#include "ImageView.h"
33#include <Foundation/NSNotification.h>
34#include <Foundation/NSDictionary.h>
35#include <Foundation/NSValue.h>
36
37#include <AppKit/NSCursor.h>
38#include <AppKit/NSEvent.h>
39
40@implementation ImageView
41
42-(BOOL) needsHandCursor
43{
44  NSSize visibleSize = [self visibleRect].size;
45  NSSize boundsSize  = [self bounds].size;
46
47  if ( ( ( visibleSize.width + 1 )  < boundsSize.width )
48       || ( ( visibleSize.height + 1 ) < boundsSize.height ) )
49    return YES;
50  else
51    return NO;
52}
53
54- (void) mouseDown: (NSEvent*)event
55{
56  if ( [self needsHandCursor] )
57    {
58     [[NSCursor closedHandCursor] push];
59    }
60}
61
62- (void) mouseUp: (NSEvent*)event
63{
64  if ( [self needsHandCursor] )
65    {
66     [[NSCursor openHandCursor] push];
67    }
68}
69
70- (void) mouseDragged: (NSEvent*)event
71{
72   NSSize scrollAmount = NSMakeSize(-[event deltaX], -[event deltaY]);
73   NSDictionary *dict = [NSDictionary dictionaryWithObject:
74				       [NSValue valueWithSize: scrollAmount]
75				     forKey: @"UserInfoKeyScrollAmount"];
76
77   [[NSNotificationCenter defaultCenter] postNotificationName: @"TEST"
78					 object: self
79					 userInfo: dict];
80}
81
82
83
84-(void) mouseEntered:(NSEvent *) event
85{
86  if ( [self needsHandCursor] )
87    [[NSCursor openHandCursor] push];
88//   else
89//     [[NSCursor arrowCursor] push];
90}
91
92-(void) mouseExited:(NSEvent *) event
93{
94   if ( [self needsHandCursor] )
95     {
96       [[NSCursor arrowCursor] push];
97     }
98}
99
100
101@end
102