2 * Copyright 2006-2011, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
12 //! GUI class that loads an image from disk and shows it as clickable button.
26 class BIconButton
: public BControl
{
28 BIconButton(const char* name
,
29 const char* label
= NULL
,
30 BMessage
* message
= NULL
,
31 BHandler
* target
= NULL
);
32 virtual ~BIconButton();
35 virtual void MessageReceived(BMessage
* message
);
36 virtual void AttachedToWindow();
38 virtual void Draw(BRect updateRect
);
39 virtual bool ShouldDrawBorder() const;
40 virtual void DrawBorder(BRect
& frame
,
41 const BRect
& updateRect
,
42 const rgb_color
& backgroundColor
,
43 uint32 controlLookFlags
);
44 virtual void DrawBackground(BRect
& frame
,
45 const BRect
& updateRect
,
46 const rgb_color
& backgroundColor
,
47 uint32 controlLookFlags
);
49 virtual void MouseDown(BPoint where
);
50 virtual void MouseUp(BPoint where
);
51 virtual void MouseMoved(BPoint where
, uint32 transit
,
52 const BMessage
* message
);
53 virtual void GetPreferredSize(float* width
,
55 virtual BSize
MinSize();
56 virtual BSize
MaxSize();
60 virtual status_t
Invoke(BMessage
* message
= NULL
);
63 virtual void SetValue(int32 value
);
64 virtual void SetEnabled(bool enable
);
69 void SetPressed(bool pressed
);
70 bool IsPressed() const;
72 status_t
SetIcon(int32 resourceID
);
73 status_t
SetIcon(const char* pathToBitmap
);
74 virtual status_t
SetIcon(const BBitmap
* bitmap
,
76 status_t
SetIcon(const BMimeType
* fileType
,
78 status_t
SetIcon(const unsigned char* bitsFromQuickRes
,
79 uint32 width
, uint32 height
,
81 bool convertToBW
= false);
83 void TrimIcon(bool keepAspect
= true);
85 BBitmap
* Bitmap() const;
86 // caller has to delete the returned bitmap
89 bool IsInside() const;
90 void SetInside(bool inside
);
93 BBitmap
* _ConvertToRGB32(const BBitmap
* bitmap
) const;
94 status_t
_MakeBitmaps(const BBitmap
* bitmap
);
95 void _DeleteBitmaps();
96 void _SendMessage() const;
98 void _SetTracking(bool state
);
99 void _SetFlags(uint32 flags
, bool set
);
100 bool _HasFlags(uint32 flags
) const;
104 BBitmap
* fNormalBitmap
;
105 BBitmap
* fDisabledBitmap
;
106 BBitmap
* fClickedBitmap
;
107 BBitmap
* fDisabledClickedBitmap
;
109 BHandler
* fTargetCache
;
113 } // namespac BPrivate
116 using BPrivate::BIconButton
;
119 #endif // ICON_BUTTON_H