* style adjustments - no functional change
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38197 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -431,17 +431,20 @@ Icon::GetIcon(BBitmap* bitmap) const
|
||||
if (bitmap == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (fData != NULL && BIconUtils::GetVectorIcon(fData, fSize, bitmap) == B_OK)
|
||||
if (fData != NULL
|
||||
&& BIconUtils::GetVectorIcon(fData, fSize, bitmap) == B_OK)
|
||||
return B_OK;
|
||||
|
||||
int32 width = bitmap->Bounds().IntegerWidth() + 1;
|
||||
|
||||
if (width == B_LARGE_ICON && fLarge != NULL) {
|
||||
bitmap->SetBits(fLarge->Bits(), fLarge->BitsLength(), 0, fLarge->ColorSpace());
|
||||
bitmap->SetBits(fLarge->Bits(), fLarge->BitsLength(), 0,
|
||||
fLarge->ColorSpace());
|
||||
return B_OK;
|
||||
}
|
||||
if (width == B_MINI_ICON && fMini != NULL) {
|
||||
bitmap->SetBits(fMini->Bits(), fMini->BitsLength(), 0, fMini->ColorSpace());
|
||||
bitmap->SetBits(fMini->Bits(), fMini->BitsLength(), 0,
|
||||
fMini->ColorSpace());
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -798,7 +801,8 @@ IconView::MouseDown(BPoint where)
|
||||
clicks = 1;
|
||||
}
|
||||
|
||||
if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && BitmapRect().Contains(where)) {
|
||||
if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0
|
||||
&& BitmapRect().Contains(where)) {
|
||||
if (clicks == 2) {
|
||||
// double click - open Icon-O-Matic
|
||||
Invoke();
|
||||
@@ -879,7 +883,8 @@ IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
||||
|
||||
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
|
||||
dragBitmap->Lock();
|
||||
BView *view = new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
|
||||
BView *view
|
||||
= new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
|
||||
dragBitmap->AddChild(view);
|
||||
|
||||
view->SetHighColor(B_TRANSPARENT_COLOR);
|
||||
@@ -1139,7 +1144,7 @@ IconView::Invoke(BMessage* message)
|
||||
{
|
||||
if (message == NULL)
|
||||
fTarget.SendMessage(kMsgIconInvoked);
|
||||
else
|
||||
else
|
||||
fTarget.SendMessage(message);
|
||||
return B_OK;
|
||||
}
|
||||
@@ -1220,7 +1225,8 @@ IconView::_AddOrEditIcon()
|
||||
|
||||
|
||||
void
|
||||
IconView::_SetIcon(BBitmap* large, BBitmap* mini, const uint8* data, size_t size, bool force)
|
||||
IconView::_SetIcon(BBitmap* large, BBitmap* mini, const uint8* data,
|
||||
size_t size, bool force)
|
||||
{
|
||||
if (fHasRef) {
|
||||
BFile file(&fRef, B_READ_WRITE);
|
||||
@@ -1317,9 +1323,11 @@ IconView::_SetIcon(entry_ref* ref)
|
||||
BMimeType mimeType(type);
|
||||
if (icon_for_type(mimeType, &data, &size) != B_OK) {
|
||||
// only try large/mini icons when there is no vector icon
|
||||
if (large != NULL && icon_for_type(mimeType, *large, B_LARGE_ICON) == B_OK)
|
||||
if (large != NULL
|
||||
&& icon_for_type(mimeType, *large, B_LARGE_ICON) == B_OK)
|
||||
hasLarge = true;
|
||||
if (mini != NULL && icon_for_type(mimeType, *mini, B_MINI_ICON) == B_OK)
|
||||
if (mini != NULL
|
||||
&& icon_for_type(mimeType, *mini, B_MINI_ICON) == B_OK)
|
||||
hasMini = true;
|
||||
}
|
||||
}
|
||||
@@ -1369,4 +1377,3 @@ IconView::_StopWatching()
|
||||
else if (fHasType)
|
||||
BMimeType::StopWatching(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,132 +22,148 @@ enum icon_source {
|
||||
|
||||
|
||||
class Icon {
|
||||
public:
|
||||
Icon();
|
||||
Icon(const Icon& source);
|
||||
~Icon();
|
||||
public:
|
||||
Icon();
|
||||
Icon(const Icon& source);
|
||||
~Icon();
|
||||
|
||||
void SetTo(const BAppFileInfo& info, const char* type = NULL);
|
||||
void SetTo(const entry_ref& ref, const char* type = NULL);
|
||||
void SetTo(const BMimeType& type, icon_source* _source = NULL);
|
||||
status_t CopyTo(BAppFileInfo& info, const char* type = NULL,
|
||||
bool force = false) const;
|
||||
status_t CopyTo(const entry_ref& ref, const char* type = NULL,
|
||||
bool force = false) const;
|
||||
status_t CopyTo(BMimeType& type, bool force = false) const;
|
||||
status_t CopyTo(BMessage& message) const;
|
||||
void SetTo(const BAppFileInfo& info,
|
||||
const char* type = NULL);
|
||||
void SetTo(const entry_ref& ref,
|
||||
const char* type = NULL);
|
||||
void SetTo(const BMimeType& type,
|
||||
icon_source* _source = NULL);
|
||||
status_t CopyTo(BAppFileInfo& info,
|
||||
const char* type = NULL,
|
||||
bool force = false) const;
|
||||
status_t CopyTo(const entry_ref& ref,
|
||||
const char* type = NULL,
|
||||
bool force = false) const;
|
||||
status_t CopyTo(BMimeType& type,
|
||||
bool force = false) const;
|
||||
status_t CopyTo(BMessage& message) const;
|
||||
|
||||
void SetData(const uint8* data, size_t size);
|
||||
void SetLarge(const BBitmap* large);
|
||||
void SetMini(const BBitmap* large);
|
||||
void Unset();
|
||||
void SetData(const uint8* data, size_t size);
|
||||
void SetLarge(const BBitmap* large);
|
||||
void SetMini(const BBitmap* large);
|
||||
void Unset();
|
||||
|
||||
bool HasData() const;
|
||||
status_t GetData(icon_size which, BBitmap** _bitmap) const;
|
||||
status_t GetData(uint8** _data, size_t* _size) const;
|
||||
bool HasData() const;
|
||||
status_t GetData(icon_size which,
|
||||
BBitmap** _bitmap) const;
|
||||
status_t GetData(uint8** _data, size_t* _size) const;
|
||||
|
||||
status_t GetIcon(BBitmap* bitmap) const;
|
||||
status_t GetIcon(BBitmap* bitmap) const;
|
||||
|
||||
Icon& operator=(const Icon& source);
|
||||
Icon& operator=(const Icon& source);
|
||||
|
||||
void AdoptLarge(BBitmap* large);
|
||||
void AdoptMini(BBitmap* mini);
|
||||
void AdoptData(uint8* data, size_t size);
|
||||
void AdoptLarge(BBitmap* large);
|
||||
void AdoptMini(BBitmap* mini);
|
||||
void AdoptData(uint8* data, size_t size);
|
||||
|
||||
static BBitmap* AllocateBitmap(int32 size, int32 space = -1);
|
||||
static BBitmap* AllocateBitmap(int32 size, int32 space = -1);
|
||||
|
||||
private:
|
||||
BBitmap* fLarge;
|
||||
BBitmap* fMini;
|
||||
uint8* fData;
|
||||
size_t fSize;
|
||||
private:
|
||||
BBitmap* fLarge;
|
||||
BBitmap* fMini;
|
||||
uint8* fData;
|
||||
size_t fSize;
|
||||
};
|
||||
|
||||
|
||||
class BSize;
|
||||
|
||||
|
||||
class IconView : public BControl {
|
||||
public:
|
||||
IconView(const char* name, uint32 flags = B_NAVIGABLE);
|
||||
virtual ~IconView();
|
||||
public:
|
||||
IconView(const char* name,
|
||||
uint32 flags = B_NAVIGABLE);
|
||||
virtual ~IconView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BSize MaxSize();
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseUp(BPoint where);
|
||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||
const BMessage* dragMessage);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
|
||||
virtual void MakeFocus(bool focus = true);
|
||||
virtual void MakeFocus(bool focus = true);
|
||||
|
||||
void SetTo(const entry_ref& file, const char* fileType = NULL);
|
||||
void SetTo(const BMimeType& type);
|
||||
void SetTo(::Icon* icon);
|
||||
void Unset();
|
||||
void Update();
|
||||
void SetTo(const entry_ref& file,
|
||||
const char* fileType = NULL);
|
||||
void SetTo(const BMimeType& type);
|
||||
void SetTo(::Icon* icon);
|
||||
void Unset();
|
||||
void Update();
|
||||
|
||||
void SetIconSize(int32 size);
|
||||
void ShowIconHeap(bool show);
|
||||
void ShowEmptyFrame(bool show);
|
||||
status_t SetTarget(const BMessenger& target);
|
||||
void SetModificationMessage(BMessage* message);
|
||||
status_t Invoke(BMessage* message = NULL);
|
||||
void SetIconSize(int32 size);
|
||||
void ShowIconHeap(bool show);
|
||||
void ShowEmptyFrame(bool show);
|
||||
status_t SetTarget(const BMessenger& target);
|
||||
void SetModificationMessage(BMessage* message);
|
||||
status_t Invoke(BMessage* message = NULL);
|
||||
|
||||
::Icon* Icon();
|
||||
int32 IconSize() const { return fIconSize; }
|
||||
icon_source IconSource() const { return fSource; }
|
||||
status_t GetRef(entry_ref& ref) const;
|
||||
status_t GetMimeType(BMimeType& type) const;
|
||||
::Icon* Icon();
|
||||
int32 IconSize() const { return fIconSize; }
|
||||
icon_source IconSource() const { return fSource; }
|
||||
status_t GetRef(entry_ref& ref) const;
|
||||
status_t GetMimeType(BMimeType& type) const;
|
||||
|
||||
protected:
|
||||
virtual bool AcceptsDrag(const BMessage* message);
|
||||
virtual BRect BitmapRect() const;
|
||||
protected:
|
||||
virtual bool AcceptsDrag(const BMessage* message);
|
||||
virtual BRect BitmapRect() const;
|
||||
|
||||
private:
|
||||
void _AddOrEditIcon();
|
||||
void _SetIcon(BBitmap* large, BBitmap* mini, const uint8* data, size_t size,
|
||||
bool force = false);
|
||||
void _SetIcon(entry_ref* ref);
|
||||
void _RemoveIcon();
|
||||
void _DeleteIcons();
|
||||
void _StartWatching();
|
||||
void _StopWatching();
|
||||
private:
|
||||
void _AddOrEditIcon();
|
||||
void _SetIcon(BBitmap* large, BBitmap* mini,
|
||||
const uint8* data, size_t size,
|
||||
bool force = false);
|
||||
void _SetIcon(entry_ref* ref);
|
||||
void _RemoveIcon();
|
||||
void _DeleteIcons();
|
||||
void _StartWatching();
|
||||
void _StopWatching();
|
||||
|
||||
BMessenger fTarget;
|
||||
BMessage* fModificationMessage;
|
||||
int32 fIconSize;
|
||||
BBitmap* fIcon;
|
||||
BBitmap* fHeapIcon;
|
||||
BMessenger fTarget;
|
||||
BMessage* fModificationMessage;
|
||||
int32 fIconSize;
|
||||
BBitmap* fIcon;
|
||||
BBitmap* fHeapIcon;
|
||||
|
||||
bool fHasRef;
|
||||
bool fHasType;
|
||||
entry_ref fRef;
|
||||
BMimeType fType;
|
||||
icon_source fSource;
|
||||
::Icon* fIconData;
|
||||
bool fHasRef;
|
||||
bool fHasType;
|
||||
entry_ref fRef;
|
||||
BMimeType fType;
|
||||
icon_source fSource;
|
||||
::Icon* fIconData;
|
||||
|
||||
BPoint fDragPoint;
|
||||
bool fTracking;
|
||||
bool fDragging;
|
||||
bool fDropTarget;
|
||||
bool fShowEmptyFrame;
|
||||
BPoint fDragPoint;
|
||||
bool fTracking;
|
||||
bool fDragging;
|
||||
bool fDropTarget;
|
||||
bool fShowEmptyFrame;
|
||||
};
|
||||
|
||||
static const uint32 kMsgIconInvoked = 'iciv';
|
||||
static const uint32 kMsgRemoveIcon = 'icrm';
|
||||
static const uint32 kMsgAddIcon = 'icad';
|
||||
static const uint32 kMsgEditIcon = 'iced';
|
||||
|
||||
extern status_t icon_for_type(const BMimeType& type, uint8** _data, size_t* _size,
|
||||
icon_source* _source = NULL);
|
||||
static const uint32 kMsgIconInvoked = 'iciv';
|
||||
static const uint32 kMsgRemoveIcon = 'icrm';
|
||||
static const uint32 kMsgAddIcon = 'icad';
|
||||
static const uint32 kMsgEditIcon = 'iced';
|
||||
|
||||
|
||||
extern status_t icon_for_type(const BMimeType& type, uint8** _data,
|
||||
size_t* _size, icon_source* _source = NULL);
|
||||
extern status_t icon_for_type(const BMimeType& type, BBitmap& bitmap,
|
||||
icon_size size, icon_source* _source = NULL);
|
||||
|
||||
|
||||
#endif // ICON_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user