File: ImageView.m

package info (click to toggle)
preview.app 0.8.5-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 508 kB
  • sloc: objc: 487; makefile: 57; sh: 17
file content (101 lines) | stat: -rw-r--r-- 2,368 bytes parent folder | download | duplicates (6)
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
 /*
        ImageView.h

	This file is part of Preview 

	Copyright (C) 2003;2004 Fabien VALLON 
	2003,2004 Alcove ( http://www.alcove.com ) 
	Additional copyrights here

	Authors : Fabien VALLON <fabien@sonappart.net>
	Date:	10 Jan 2005

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License as
	published by the Free Software Foundation; either version 2 of
	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

	See the GNU General Public License for more details.

	You should have received a copy of the GNU General Public
	License along with this program; if not, write to:

		Free Software Foundation, Inc.
		59 Temple Place - Suite 330
		Boston, MA  02111-1307, USA
*/

#include "ImageView.h"
#include <Foundation/NSNotification.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSValue.h>

#include <AppKit/NSCursor.h>
#include <AppKit/NSEvent.h>

@implementation ImageView 

-(BOOL) needsHandCursor
{
  NSSize visibleSize = [self visibleRect].size;
  NSSize boundsSize  = [self bounds].size;
  
  if ( ( ( visibleSize.width + 1 )  < boundsSize.width ) 
       || ( ( visibleSize.height + 1 ) < boundsSize.height ) )
    return YES;
  else
    return NO;
} 

- (void) mouseDown: (NSEvent*)event
{
  if ( [self needsHandCursor] ) 
    {
     [[NSCursor closedHandCursor] push];
    }
}

- (void) mouseUp: (NSEvent*)event
{
  if ( [self needsHandCursor] ) 
    {
     [[NSCursor openHandCursor] push];
    }
}

- (void) mouseDragged: (NSEvent*)event
{
   NSSize scrollAmount = NSMakeSize(-[event deltaX], -[event deltaY]);
   NSDictionary *dict = [NSDictionary dictionaryWithObject: 
				       [NSValue valueWithSize: scrollAmount]
				     forKey: @"UserInfoKeyScrollAmount"];

   [[NSNotificationCenter defaultCenter] postNotificationName: @"TEST"
					 object: self
					 userInfo: dict];
}



-(void) mouseEntered:(NSEvent *) event
{
  if ( [self needsHandCursor] ) 
    [[NSCursor openHandCursor] push];
//   else
//     [[NSCursor arrowCursor] push];
}

-(void) mouseExited:(NSEvent *) event
{
   if ( [self needsHandCursor] ) 
     {
       [[NSCursor arrowCursor] push];
     }
}


@end