File: MyImageView.h

package info (click to toggle)
lynkeos.app 3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,740 kB
  • sloc: objc: 40,528; ansic: 811; cpp: 150; sh: 68; makefile: 27
file content (246 lines) | stat: -rw-r--r-- 8,373 bytes parent folder | download
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//
//  Lynkeos
//  $Id$
//
//  Created by Jean-Etienne LAMIAUD on Wed Sep 24 2003.
//  Copyright (c) 2003-2023. Jean-Etienne LAMIAUD
//
// 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 the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//

/*!
 * @header
 * @abstract Definitions for the custom image view
 */
#ifndef __MYIMAGEVIEW_H
#define __MYIMAGEVIEW_H

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

#include "SMDoubleSlider.h"

#include "LynkeosCommon.h"
#include "LynkeosProcessingView.h"

/*!
 * @abstract Position of a selection side or corner.
 * @discussion Preceding side is left or bottom and following is right or top.
 */
typedef enum
{
   PrecedingSide  = -1,
   MiddlePosition =  0,
   FollowingSide  =  1
} SelectionPosition_t;

/*!
 * @abstract Selection management model object
 */
@interface MyImageSelection : NSObject
{
@public
   BOOL                _resizable;   //!< Wether the selection is resizable
   BOOL                _movable;     //!< Wether the selection is movable
   LynkeosIntegerRect  _rect;        //!< Selection rectangle
 	// Cursor rectangles
   NSRect              _left;        //!< Left side cursor rectangle
   NSRect              _right;       //!< Right side cursor rectangle
   NSRect              _top;         //!< Top side cursor rectangle
   NSRect              _bottom;      //!< Bttom side cursor rectangle
   NSRect              _topLeft;     //!< Top left corner cursor rectangle
   NSRect              _topRight;    //!< Top right side corner rectangle
   NSRect              _bottomLeft;  //!< Bottom left side corner rectangle
   NSRect              _bottomRight; //!< Bottom right side corner rectangle
   NSRect              _inside;      //!< Interior cursor rectangle
}

/*!
 * @abstract Dedicated initializer
 * @param rect Selection rectangle
 * @param move Wether the selection is can be resized
 * @param resize Wether the selection is moved
 * @result The new initialized selection
 */
- (id) initWithRect:(LynkeosIntegerRect)rect movable:(BOOL)move resizable:(BOOL)resize;

/*!
 * @abstract Set a specific cursor rectangle
 * @param[out] r The cursor rectangle
 * @param cur The cursor associated to this rectangle
 * @param s width, height or side of the rectangle (or square)
 * @param hPos Horizontal order of this rectangle
 * @param vPos Vertical order of this rectangle
 * @param v Visible rectangle for this view
 * @param view The view in which to place the cursor
 */
- (void) processCursorRect:(NSRect*)r cursor:(NSCursor*)cur size:(float)s
           horizontalOrder:(SelectionPosition_t)hPos
             verticalOrder:(SelectionPosition_t)vPos
                   visible:(NSRect)v view:(NSView*)view;
@end

/*!
 * @abstract Selection dragging mode
 */
typedef enum { SelNone, SelNormal, SelH, SelV, SelMove } SelectionDraggingMode_t;

/*!
 * @abstract Tile status (internal use)
 */
typedef enum {Blank, Drawing, Available} TileState_t;

/*!
 * @abstract The custom image view.
 * @ingroup Views
 */
@interface MyImageView : NSView <LynkeosImageView>
{
@private
   // For IB
   IBOutlet NSSlider*         _zoomSlider;       //!< Slider controlling the zoom
   IBOutlet NSTextField*      _zoomField;        //!< Zoom text value

   IBOutlet SMDoubleSlider*   _blackWhiteSlider; //!< Black and white levels
   IBOutlet NSSlider*         _gammaSlider;      //!< Level exponent
   IBOutlet NSTextField*      _blackText;        //!< Black level text value
   IBOutlet NSTextField*      _whiteText;        //!< White level text value
   IBOutlet NSTextField*      _gammaText;        //!< Gamma level text value

   IBOutlet id                _delegate;         //!< The view delegate
   id <LynkeosImageViewDelegate> _selectionDelegate; //!< The selection delegate

   id <LynkeosProcessableItem> _item;            //!< The item to display
   //!< The displayed item modification sequence number
   u_long                     _itemSequenceNumber;
   LynkeosIntegerSize         _itemSize;         //<! The size of the displayed item

   // Image management
   NSAffineTransform*         _imageTransform;   //!< Additional transform
#if GNUSTEP
   NSImageRep*                _imageRep;         //!< Cached representation
#endif
   NSRect                     _canvasRect;       //!< Rectangle in which the image fits after transformation
#if !GNUSTEP
   NSOperationQueue*          _tilesQueue;       //!< Operation queue used to retrieve the image tiles
   CGContextRef               _layerContext;     //!< Bitmap context for the layer
   CGLayerRef                 _imageLayer;       //!< Layer accumulating the successive tiles
#endif
	uint8_t*                   _drawnTile;        //!< Bookkeeping of tiles update
	u_short                    _tilePerLine;

   // Zoom control
   double                     _zoom;             //!< Current zoom value
   // Selection management
   SelectionMode_t            _selectionMode;    //!< No, Single or Multi
   SelectionMode_t            _savedSelectionMode;  //!< Saved during freezing
   u_int                      _freezeCounter; //!< Take care of recursive freeze
   //! Array of MyImageSelection objects
   NSMutableArray            *_selection;
   //! Selection being modified
   LynkeosIntegerRect         _inProgressSelection;
   SelectionIndex_t           _currentSelectionIndex;
   SelectionIndex_t           _previousSelectionIndex;
   LynkeosIntegerPoint        _selectionOrigin, _lastPoint;
   unsigned int               _modifiers;
   NSCursor                  *_crossCursor,                           // Cursors
                             *_leftCursor, *_rightCursor,
                             *_topCursor, *_bottomCursor,
                             *_topLeftCursor, *_topRightCursor,
                             *_bottomLeftCursor, *_bottomRightCursor,
                             *_insideCursor;
   SelectionDraggingMode_t    _draggingMode;
   NSTimer                   *_autoscrollTimer;
   BOOL                       _isNotifying;
}

//! \name IBActions
//! Methods connected to Interface builder actions
//!@{
/*!
 * @abstract Set the zoom according to the slider value
 * @param sender The slider.
 */
- (IBAction)doZoom:(id)sender;

/*!
 * @abstract Zoom in
 * @param sender The button.
 */
- (IBAction)moreZoom:(id)sender;

/*!
 * @abstract Zoom out
 * @param sender The button.
 */
- (IBAction)lessZoom:(id)sender;

/*!
 * @abstract Set the black and white levels for the image
 * @param sender the control that was changed
 */
- (IBAction) blackWhiteChange :(id)sender ;

/*!
 * @abstract Set the gamma correction exponent for the image
 * @param sender the control that was changed
 */
- (IBAction) gammaChange :(id)sender ;

//!@}

/*!
 * @abstract Retrieve the displayed image size
 * @result The image size
 */
- (NSSize) imageSize ;

/*!
 * @abstract Access to the image rendering parameters
 * @param [out] black The black level
 * @param [out] white The white level
 * @param [out] gamma The contrast setting
 */
- (void) getBlack:(double*)black white:(double*)white gamma:(double*)gamma ;

@end

/*!
 * @abstract Selection handling in MyImageView
 */
@interface MyImageView(Selection)

/*!
 * @abstract Get all the details of a selection
 * @param index The index of the required selection
 * @param rect [out] the selection rectangle
 * @param resize [out] wether the selection is resizable
 * @param move [out] wether the selection is movable
 * @result None 
 */
- (void) getSelectionAtIndex:(SelectionIndex_t)index
                        rect:(LynkeosIntegerRect*)rect
                   resizable:(BOOL*)resize
                     movable:(BOOL*)move;

/*!
 * @abstract Initialize all the selection related cursors
 * @result None 
 */
- (void) initCursors ;

@end

#endif