2 * Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
11 #include <Messenger.h>
27 Icon(const Icon
& source
);
30 void SetTo(const BAppFileInfo
& info
,
31 const char* type
= NULL
);
32 void SetTo(const entry_ref
& ref
,
33 const char* type
= NULL
);
34 void SetTo(const BMimeType
& type
,
35 icon_source
* _source
= NULL
);
36 status_t
CopyTo(BAppFileInfo
& info
,
37 const char* type
= NULL
,
38 bool force
= false) const;
39 status_t
CopyTo(const entry_ref
& ref
,
40 const char* type
= NULL
,
41 bool force
= false) const;
42 status_t
CopyTo(BMimeType
& type
,
43 bool force
= false) const;
44 status_t
CopyTo(BMessage
& message
) const;
46 void SetData(const uint8
* data
, size_t size
);
47 void SetLarge(const BBitmap
* large
);
48 void SetMini(const BBitmap
* large
);
52 status_t
GetData(icon_size which
,
53 BBitmap
** _bitmap
) const;
54 status_t
GetData(uint8
** _data
, size_t* _size
) const;
56 status_t
GetIcon(BBitmap
* bitmap
) const;
58 Icon
& operator=(const Icon
& source
);
60 void AdoptLarge(BBitmap
* large
);
61 void AdoptMini(BBitmap
* mini
);
62 void AdoptData(uint8
* data
, size_t size
);
64 static BBitmap
* AllocateBitmap(int32 size
, int32 space
= -1);
77 class IconView
: public BControl
{
79 IconView(const char* name
,
80 uint32 flags
= B_NAVIGABLE
);
83 virtual void AttachedToWindow();
84 virtual void DetachedFromWindow();
85 virtual void MessageReceived(BMessage
* message
);
86 virtual void Draw(BRect updateRect
);
87 virtual void GetPreferredSize(float* _width
, float* _height
);
89 virtual BSize
MaxSize();
90 virtual BSize
MinSize();
91 virtual BSize
PreferredSize();
93 virtual void MouseDown(BPoint where
);
94 virtual void MouseUp(BPoint where
);
95 virtual void MouseMoved(BPoint where
, uint32 transit
,
96 const BMessage
* dragMessage
);
97 virtual void KeyDown(const char* bytes
, int32 numBytes
);
99 virtual void MakeFocus(bool focus
= true);
101 void SetTo(const entry_ref
& file
,
102 const char* fileType
= NULL
);
103 void SetTo(const BMimeType
& type
);
104 void SetTo(::Icon
* icon
);
108 void SetIconSize(int32 size
);
109 void ShowIconHeap(bool show
);
110 void ShowEmptyFrame(bool show
);
111 status_t
SetTarget(const BMessenger
& target
);
112 void SetModificationMessage(BMessage
* message
);
113 status_t
Invoke(BMessage
* message
= NULL
);
116 int32
IconSize() const { return fIconSize
; }
117 icon_source
IconSource() const { return fSource
; }
118 status_t
GetRef(entry_ref
& ref
) const;
119 status_t
GetMimeType(BMimeType
& type
) const;
122 virtual status_t
SetTarget(BMessenger target
);
123 virtual status_t
SetTarget(const BHandler
* handler
,
124 const BLooper
* looper
= NULL
);
126 using BControl::SetTarget
;
131 virtual bool AcceptsDrag(const BMessage
* message
);
132 virtual BRect
BitmapRect() const;
135 void _AddOrEditIcon();
136 void _SetIcon(BBitmap
* large
, BBitmap
* mini
,
137 const uint8
* data
, size_t size
,
139 void _SetIcon(entry_ref
* ref
);
142 void _StartWatching();
143 void _StopWatching();
146 BMessage
* fModificationMessage
;
162 bool fShowEmptyFrame
;
166 static const uint32 kMsgIconInvoked
= 'iciv';
167 static const uint32 kMsgRemoveIcon
= 'icrm';
168 static const uint32 kMsgAddIcon
= 'icad';
169 static const uint32 kMsgEditIcon
= 'iced';
172 extern status_t
icon_for_type(const BMimeType
& type
, uint8
** _data
,
173 size_t* _size
, icon_source
* _source
= NULL
);
174 extern status_t
icon_for_type(const BMimeType
& type
, BBitmap
& bitmap
,
175 icon_size size
, icon_source
* _source
= NULL
);
178 #endif // ICON_VIEW_H