HaikuDepot: notify work status from main window
[haiku.git] / src / apps / magnify / Magnify.h
blob9b9663b3b3d5b7f6a7bea594b44df2ac9fe16684
1 /*
2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Copyright 1999, Be Incorporated. All Rights Reserved.
6 * This file may be used under the terms of the Be Sample Code License.
7 */
8 #ifndef MAGNIFY_H
9 #define MAGNIFY_H
12 #include <Application.h>
13 #include <Box.h>
14 #include <FilePanel.h>
15 #include <MenuBar.h>
16 #include <View.h>
17 #include <Window.h>
20 class TMagnify;
21 class TWindow;
23 class TOSMagnify : public BView {
24 public:
25 TOSMagnify(BRect, TMagnify* parent, color_space space);
26 virtual ~TOSMagnify();
28 void InitObject();
30 virtual void FrameResized(float width, float height);
31 void SetSpace(color_space space);
33 void Resize(int32 width, int32 height);
35 bool CreateImage(BPoint, bool force=false);
36 bool CopyScreenRect(BRect);
38 void DrawGrid(int32 width, int32 height,
39 BRect dest, int32 pixelSize);
40 void DrawSelection();
42 rgb_color ColorAtSelection();
44 BBitmap* Bitmap() { return fBitmap; }
46 private:
47 color_space fColorSpace;
48 char* fOldBits;
49 long fBytesPerPixel;
51 TMagnify* fParent;
52 BBitmap* fBitmap;
53 BBitmap* fPixel;
54 BView* fPixelView;
57 class TMagnify : public BView {
58 public:
59 TMagnify(BRect, TWindow*);
60 virtual ~TMagnify();
62 void InitBuffers(int32 hPixelCount, int32 vPixelCount,
63 int32 pixelSize, bool showGrid);
65 virtual void AttachedToWindow();
66 virtual void Draw(BRect);
68 virtual void KeyDown(const char *bytes, int32 numBytes);
69 virtual void FrameResized(float, float);
70 virtual void MouseDown(BPoint where);
71 virtual void ScreenChanged(BRect bounds, color_space cs);
72 virtual void WindowActivated(bool);
74 void SetSelection(bool state);
75 void MoveSelection(int32 x, int32 y);
76 void MoveSelectionTo(int32 x, int32 y);
77 void ShowSelection();
79 short Selection();
80 bool SelectionIsShowing();
81 void SelectionLoc(float* x, float* y);
82 void SetSelectionLoc(float, float);
83 rgb_color SelectionColor();
85 void CrossHair1Loc(float* x, float* y);
86 void CrossHair2Loc(float* x, float* y);
87 BPoint CrossHair1Loc();
88 BPoint CrossHair2Loc();
90 void NudgeMouse(float x, float y);
92 void Update(bool force);
93 bool NeedToUpdate();
94 void SetUpdate(bool);
96 void CopyImage();
98 long ThreadID() { return fThread; }
100 void MakeActive(bool);
101 bool Active() { return fActive; }
103 void MakeSticked(bool);
104 bool Sticked() const { return fStickCoordinates; }
106 void AddCrossHair();
107 void RemoveCrossHair();
108 void SetCrossHairsShowing(bool ch1=false, bool ch2=false);
109 void CrossHairsShowing(bool*, bool*);
111 void PixelCount(int32* width, int32* height);
112 int32 PixelSize();
113 bool ShowGrid();
115 void StartSave();
116 void SaveImage(entry_ref* ref, char* name);
117 void EndSave();
119 private:
120 static status_t MagnifyTask(void *);
122 bool fNeedToUpdate;
123 long fThread; // magnify thread id
124 bool fActive; // magnifying toggle
126 BBitmap* fImageBuf; // os buffer
127 TOSMagnify* fImageView; // os view
128 BPoint fLastLoc;
130 short fSelection;
132 bool fShowSelection;
133 BPoint fSelectionLoc;
135 bool fShowCrossHair1;
136 BPoint fCrossHair1;
137 bool fShowCrossHair2;
138 BPoint fCrossHair2;
140 TWindow* fParent;
142 bool fImageFrozenOnSave;
143 bool fStickCoordinates;
146 class TMenu : public BMenu {
147 public:
148 TMenu(TWindow* mainWindow, const char *title = NULL,
149 menu_layout layout = B_ITEMS_IN_COLUMN);
150 virtual ~TMenu();
152 virtual void AttachedToWindow();
154 private:
155 TWindow* fMainWindow;
158 class TInfoView : public BBox {
159 public:
160 TInfoView(BRect frame);
161 virtual ~TInfoView();
163 virtual void AttachedToWindow();
164 virtual void Draw(BRect updateRect);
165 virtual void FrameResized(float width, float height);
166 virtual void GetPreferredSize(float* _width, float* _height);
168 void AddMenu();
169 void SetMagView(TMagnify* magView);
170 void SetInfoTextVisible(bool visible);
171 bool IsInfoTextVisible();
173 private:
174 float fFontHeight;
175 TMagnify* fMagView;
176 BMenuField* fPopUp;
177 TMenu* fMenu;
179 int32 fHPixelCount;
180 int32 fVPixelCount;
181 int32 fPixelSize;
183 rgb_color fSelectionColor;
185 BPoint fCH1Loc;
186 BPoint fCH2Loc;
188 char fInfoStr[64];
189 char fRGBStr[64];
190 char fCH1Str[64];
191 char fCH2Str[64];
193 bool fInfoTextVisible;
196 class TWindow : public BWindow {
197 public:
198 TWindow(int32 pixelCount = -1);
199 virtual ~TWindow();
201 virtual void MessageReceived(BMessage* message);
202 virtual bool QuitRequested();
204 status_t GetSupportedSuites(BMessage* msg);
205 BHandler* ResolveSpecifier(BMessage* msg, int32 index,
206 BMessage* specifier, int32 what,
207 const char* property);
209 void GetPrefs(int32 pixelCount = -1);
210 void SetPrefs();
212 virtual void FrameResized(float width, float height);
213 virtual void ScreenChanged(BRect screenSize, color_space depth);
215 virtual void Minimize(bool);
216 virtual void Zoom(BPoint position, float width, float height);
218 void CalcViewablePixels();
219 void GetPreferredSize(float* width, float* height);
221 void ResizeWindow(int32 rowCount, int32 columnCount);
222 void ResizeWindow(bool direction);
224 void SetGrid(bool);
225 bool ShowGrid();
227 void ShowInfo(bool);
228 bool InfoIsShowing();
229 bool InfoBarIsVisible();
230 void UpdateInfo();
231 void UpdateInfoBarOnResize();
233 void AddCrossHair();
234 void RemoveCrossHair();
235 void CrossHairsShowing(bool* ch1, bool* ch2);
237 void PixelCount(int32* h, int32 *v);
239 void SetPixelSize(int32);
240 void SetPixelSize(bool);
241 int32 PixelSize();
243 bool IsActive();
244 bool IsSticked();
246 private:
247 float fInfoHeight;
248 bool fShowInfo;
249 float fFontHeight;
251 bool fShowGrid;
252 bool fInfoBarState;
254 int32 fHPixelCount;
255 int32 fVPixelCount;
256 int32 fPixelSize;
258 TMagnify* fFatBits;
259 TInfoView* fInfo;
261 BFilePanel* fSavePanel;
264 class TApp : public BApplication {
265 public:
266 TApp(int32 pixelCount = -1);
269 #endif // MAGNIFY_H