HaikuDepot: notify work status from main window
[haiku.git] / src / apps / icon-o-matic / gui / GradientControl.h
blob77048112df1b9af87cb45fb8448938f43630c85f
1 /*
2 * Copyright 2006-2007, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
8 #ifndef GRADIENT_CONTROL_H
9 #define GRADIENT_CONTROL_H
12 #include <View.h>
14 #if LIB_LAYOUT
15 # include <layout.h>
16 #endif
18 #include "IconBuild.h"
21 _BEGIN_ICON_NAMESPACE
22 class Gradient;
23 _END_ICON_NAMESPACE
26 enum {
27 MSG_GRADIENT_CONTROL_FOCUS_CHANGED = 'gcfc',
30 class GradientControl :
31 #if LIB_LAYOUT
32 public MView,
33 #endif
34 public BView {
36 public:
37 GradientControl(BMessage* message = NULL,
38 BHandler* target = NULL);
39 virtual ~GradientControl();
41 // MView
42 #if LIB_LAYOUT
43 virtual minimax layoutprefs();
44 virtual BRect layout(BRect frame);
45 #endif
47 // BView
48 virtual void WindowActivated(bool active);
49 virtual void MakeFocus(bool focus);
51 virtual void MouseDown(BPoint where);
52 virtual void MouseUp(BPoint where);
53 virtual void MouseMoved(BPoint where, uint32 transit,
54 const BMessage* dragMessage);
56 virtual void MessageReceived(BMessage* message);
57 virtual void KeyDown(const char* bytes, int32 numBytes);
59 virtual void Draw(BRect updateRect);
60 virtual void FrameResized(float width, float height);
62 // GradientControl
63 void SetGradient(const _ICON_NAMESPACE Gradient*
64 gradient);
65 _ICON_NAMESPACE Gradient* Gradient() const
66 { return fGradient; }
68 void SetCurrentStop(const rgb_color& color);
69 bool GetCurrentStop(rgb_color* color) const;
71 void SetEnabled(bool enabled);
72 bool IsEnabled() const
73 { return fEnabled; }
75 private:
76 void _UpdateColors();
77 void _AllocBitmap(int32 width, int32 height);
78 BRect _GradientBitmapRect() const;
79 int32 _StepIndexFor(BPoint where) const;
80 float _OffsetFor(BPoint where) const;
81 void _UpdateCurrentColor() const;
83 _ICON_NAMESPACE Gradient* fGradient;
84 BBitmap* fGradientBitmap;
85 int32 fDraggingStepIndex;
86 int32 fCurrentStepIndex;
88 float fDropOffset;
89 int32 fDropIndex;
91 bool fEnabled;
93 BMessage* fMessage;
94 BHandler* fTarget;
97 #endif // GRADIENT_CONTROL_H