2 * Copyright 2003-2011, Haiku, Inc. All Rights Reserved.
3 * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
4 * Copyright 2006 Bernd Korz. All Rights Reserved
5 * Distributed under the terms of the MIT License.
8 * Fernando Francisco de Oliveira
14 #ifndef SHOW_IMAGE_VIEW_H
15 #define SHOW_IMAGE_VIEW_H
22 #include <TranslatorRoster.h>
26 #include "SelectionBox.h"
32 class ShowImageView
: public BView
{
34 ShowImageView(BRect rect
, const char* name
,
35 uint32 resizingMode
, uint32 flags
);
36 virtual ~ShowImageView();
38 virtual void AttachedToWindow();
39 virtual void FrameResized(float width
, float height
);
40 virtual void Draw(BRect updateRect
);
41 virtual void MouseDown(BPoint point
);
42 virtual void MouseMoved(BPoint point
, uint32 state
,
43 const BMessage
* dragMessage
);
44 virtual void MouseUp(BPoint point
);
45 virtual void KeyDown(const char* bytes
, int32 numBytes
);
48 virtual void MessageReceived(BMessage
* message
);
49 virtual void WindowActivated(bool active
);
51 void SetTrackerMessenger(
52 const BMessenger
& trackerMessenger
);
53 status_t
SetImage(const BMessage
* message
);
54 status_t
SetImage(const entry_ref
* ref
, BBitmap
* bitmap
,
55 BitmapOwner
* bitmapOwner
);
56 const entry_ref
* Image() const { return &fCurrentRef
; }
59 BPoint
ImageToView(BPoint p
) const;
60 BPoint
ViewToImage(BPoint p
) const;
61 BRect
ImageToView(BRect r
) const;
62 void ConstrainToImage(BPoint
& point
) const;
63 void ConstrainToImage(BRect
& rect
) const;
65 void SaveToFile(BDirectory
* dir
, const char* name
,
67 const translation_format
* format
);
69 void SetScaleBilinear(bool b
);
70 bool ScaleBilinear() { return fScaleBilinear
; }
71 void SetShowCaption(bool show
);
72 void SetStretchToBounds(bool enable
);
73 bool StretchesToBounds() const
74 { return fStretchToBounds
; }
75 void SetHideIdlingCursor(bool hide
);
77 void FixupScrollBar(enum orientation orientation
,
78 float bitmapLength
, float viewLength
);
79 void FixupScrollBars();
81 void SetSelectionMode(bool selectionMode
);
82 bool IsSelectionModeEnabled() const
83 { return fSelectionMode
; }
85 void ClearSelection();
87 void CopySelectionToClipboard();
90 void ForceOriginalSize(bool force
)
91 { fForceOriginalSize
= force
; }
92 void SetZoom(float zoom
,
93 BPoint where
= BPoint(-1, -1));
96 void ZoomIn(BPoint where
= BPoint(-1, -1));
97 void ZoomOut(BPoint where
= BPoint(-1, -1));
100 void Rotate(int degree
); // 90 and 270 only
101 void Flip(bool vertical
);
102 void ResizeImage(int width
, int height
);
104 void SetIcon(bool clear
);
107 enum image_orientation
{
116 kNumberOfOrientations
,
119 void _SetHasSelection(bool bHasSelection
);
120 void _AnimateSelection(bool a
);
121 void _SendMessageToWindow(BMessage
* message
);
122 void _SendMessageToWindow(uint32 code
);
124 void _UpdateStatusText();
125 void _GetMergeRects(BBitmap
* merge
,
126 BRect selection
, BRect
& srcRect
,
128 void _GetSelectionMergeRects(BRect
& srcRect
,
130 status_t
_SetSelection(const entry_ref
* ref
,
132 void _MergeWithBitmap(BBitmap
* merge
,
134 void _MergeSelection();
135 void _DeleteScaler();
136 void _DeleteBitmap();
137 void _DeleteSelectionBitmap();
139 void _DoImageOperation(
140 enum ImageProcessor::operation op
,
142 void _UserDoImageOperation(
143 enum ImageProcessor::operation op
,
145 bool _ShouldStretch() const;
146 float _FitToBoundsZoom() const;
147 BRect
_AlignBitmap();
148 BBitmap
* _CopySelection(uchar alpha
= 255,
149 bool imageSize
= true);
150 bool _AddSupportedTypes(BMessage
* message
,
152 void _BeginDrag(BPoint sourcePoint
);
153 void _SendInMessage(BMessage
* message
,
155 translation_format
* format
);
156 bool _OutputFormatForType(BBitmap
* bitmap
,
158 translation_format
* format
);
159 void _HandleDrop(BMessage
* message
);
160 void _ScrollBitmap(BPoint point
);
161 void _UpdateSelectionRect(BPoint point
, bool final
);
162 void _DrawBackground(BRect aroundFrame
);
163 void _LayoutCaption(BFont
& font
, BPoint
& textPos
,
166 void _UpdateCaption();
168 void _DrawImage(BRect rect
);
169 float _LimitToRange(float v
, orientation o
,
171 void _ScrollRestricted(float x
, float y
,
173 void _ScrollRestrictedTo(float x
, float y
);
174 void _ScrollRestrictedBy(float x
, float y
);
175 void _MouseWheelChanged(BMessage
* message
);
176 void _ShowPopUpMenu(BPoint screen
);
177 void _SettingsSetBool(const char* name
, bool value
);
178 void _SetIcon(bool clear
, icon_size which
);
179 void _ToggleSlideShow();
180 void _StopSlideShow();
181 void _ExitFullScreen();
182 void _ShowToolBarIfEnabled(bool show
);
185 entry_ref fCurrentRef
;
187 BitmapOwner
* fBitmapOwner
;
189 BBitmap
* fDisplayBitmap
;
190 BBitmap
* fSelectionBitmap
;
196 BPoint fBitmapLocationInView
;
198 bool fStretchToBounds
;
199 bool fForceOriginalSize
;
201 bool fScrollingBitmap
;
202 bool fCreatingSelection
;
204 // first point in image space of selection
206 bool fAnimateSelection
;
208 SelectionBox fSelectionBox
;
210 // the portion of the background bitmap the selection is made
216 BString fFormatDescription
;
219 bool fShowingPopUpMenu
;
221 int fHideCursorCountDown
;
222 // Hides the cursor when it reaches zero
223 int fStickyZoomCountDown
;
224 // Make the zoom sticky at 1.0 when zoomed with the mousewheel
227 // Is the parent window the active window?
229 BCursor
* fDefaultCursor
;
230 BCursor
* fGrabCursor
;
232 image_orientation fImageOrientation
;
233 static image_orientation fTransformation
[
235 ::kNumberOfAffineTransformations
]
236 [kNumberOfOrientations
];
239 #endif // SHOW_IMAGE_VIEW_H