* 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)
|
if (bitmap == NULL)
|
||||||
return B_BAD_VALUE;
|
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;
|
return B_OK;
|
||||||
|
|
||||||
int32 width = bitmap->Bounds().IntegerWidth() + 1;
|
int32 width = bitmap->Bounds().IntegerWidth() + 1;
|
||||||
|
|
||||||
if (width == B_LARGE_ICON && fLarge != NULL) {
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
if (width == B_MINI_ICON && fMini != NULL) {
|
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;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -798,7 +801,8 @@ IconView::MouseDown(BPoint where)
|
|||||||
clicks = 1;
|
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) {
|
if (clicks == 2) {
|
||||||
// double click - open Icon-O-Matic
|
// double click - open Icon-O-Matic
|
||||||
Invoke();
|
Invoke();
|
||||||
@@ -879,7 +883,8 @@ IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
|||||||
|
|
||||||
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
|
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
|
||||||
dragBitmap->Lock();
|
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);
|
dragBitmap->AddChild(view);
|
||||||
|
|
||||||
view->SetHighColor(B_TRANSPARENT_COLOR);
|
view->SetHighColor(B_TRANSPARENT_COLOR);
|
||||||
@@ -1220,7 +1225,8 @@ IconView::_AddOrEditIcon()
|
|||||||
|
|
||||||
|
|
||||||
void
|
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) {
|
if (fHasRef) {
|
||||||
BFile file(&fRef, B_READ_WRITE);
|
BFile file(&fRef, B_READ_WRITE);
|
||||||
@@ -1317,9 +1323,11 @@ IconView::_SetIcon(entry_ref* ref)
|
|||||||
BMimeType mimeType(type);
|
BMimeType mimeType(type);
|
||||||
if (icon_for_type(mimeType, &data, &size) != B_OK) {
|
if (icon_for_type(mimeType, &data, &size) != B_OK) {
|
||||||
// only try large/mini icons when there is no vector icon
|
// 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;
|
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;
|
hasMini = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1369,4 +1377,3 @@ IconView::_StopWatching()
|
|||||||
else if (fHasType)
|
else if (fHasType)
|
||||||
BMimeType::StopWatching(this);
|
BMimeType::StopWatching(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,132 +22,148 @@ enum icon_source {
|
|||||||
|
|
||||||
|
|
||||||
class Icon {
|
class Icon {
|
||||||
public:
|
public:
|
||||||
Icon();
|
Icon();
|
||||||
Icon(const Icon& source);
|
Icon(const Icon& source);
|
||||||
~Icon();
|
~Icon();
|
||||||
|
|
||||||
void SetTo(const BAppFileInfo& info, const char* type = NULL);
|
void SetTo(const BAppFileInfo& info,
|
||||||
void SetTo(const entry_ref& ref, const char* type = NULL);
|
const char* type = NULL);
|
||||||
void SetTo(const BMimeType& type, icon_source* _source = NULL);
|
void SetTo(const entry_ref& ref,
|
||||||
status_t CopyTo(BAppFileInfo& info, const char* type = NULL,
|
const char* type = NULL);
|
||||||
bool force = false) const;
|
void SetTo(const BMimeType& type,
|
||||||
status_t CopyTo(const entry_ref& ref, const char* type = NULL,
|
icon_source* _source = NULL);
|
||||||
bool force = false) const;
|
status_t CopyTo(BAppFileInfo& info,
|
||||||
status_t CopyTo(BMimeType& type, bool force = false) const;
|
const char* type = NULL,
|
||||||
status_t CopyTo(BMessage& message) const;
|
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 SetData(const uint8* data, size_t size);
|
||||||
void SetLarge(const BBitmap* large);
|
void SetLarge(const BBitmap* large);
|
||||||
void SetMini(const BBitmap* large);
|
void SetMini(const BBitmap* large);
|
||||||
void Unset();
|
void Unset();
|
||||||
|
|
||||||
bool HasData() const;
|
bool HasData() const;
|
||||||
status_t GetData(icon_size which, BBitmap** _bitmap) const;
|
status_t GetData(icon_size which,
|
||||||
status_t GetData(uint8** _data, size_t* _size) const;
|
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 AdoptLarge(BBitmap* large);
|
||||||
void AdoptMini(BBitmap* mini);
|
void AdoptMini(BBitmap* mini);
|
||||||
void AdoptData(uint8* data, size_t size);
|
void AdoptData(uint8* data, size_t size);
|
||||||
|
|
||||||
static BBitmap* AllocateBitmap(int32 size, int32 space = -1);
|
static BBitmap* AllocateBitmap(int32 size, int32 space = -1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBitmap* fLarge;
|
BBitmap* fLarge;
|
||||||
BBitmap* fMini;
|
BBitmap* fMini;
|
||||||
uint8* fData;
|
uint8* fData;
|
||||||
size_t fSize;
|
size_t fSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BSize;
|
class BSize;
|
||||||
|
|
||||||
|
|
||||||
class IconView : public BControl {
|
class IconView : public BControl {
|
||||||
public:
|
public:
|
||||||
IconView(const char* name, uint32 flags = B_NAVIGABLE);
|
IconView(const char* name,
|
||||||
virtual ~IconView();
|
uint32 flags = B_NAVIGABLE);
|
||||||
|
virtual ~IconView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void GetPreferredSize(float* _width, float* _height);
|
virtual void GetPreferredSize(float* _width, float* _height);
|
||||||
|
|
||||||
virtual BSize MaxSize();
|
virtual BSize MaxSize();
|
||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
virtual BSize PreferredSize();
|
virtual BSize PreferredSize();
|
||||||
|
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage);
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
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 entry_ref& file,
|
||||||
void SetTo(const BMimeType& type);
|
const char* fileType = NULL);
|
||||||
void SetTo(::Icon* icon);
|
void SetTo(const BMimeType& type);
|
||||||
void Unset();
|
void SetTo(::Icon* icon);
|
||||||
void Update();
|
void Unset();
|
||||||
|
void Update();
|
||||||
|
|
||||||
void SetIconSize(int32 size);
|
void SetIconSize(int32 size);
|
||||||
void ShowIconHeap(bool show);
|
void ShowIconHeap(bool show);
|
||||||
void ShowEmptyFrame(bool show);
|
void ShowEmptyFrame(bool show);
|
||||||
status_t SetTarget(const BMessenger& target);
|
status_t SetTarget(const BMessenger& target);
|
||||||
void SetModificationMessage(BMessage* message);
|
void SetModificationMessage(BMessage* message);
|
||||||
status_t Invoke(BMessage* message = NULL);
|
status_t Invoke(BMessage* message = NULL);
|
||||||
|
|
||||||
::Icon* Icon();
|
::Icon* Icon();
|
||||||
int32 IconSize() const { return fIconSize; }
|
int32 IconSize() const { return fIconSize; }
|
||||||
icon_source IconSource() const { return fSource; }
|
icon_source IconSource() const { return fSource; }
|
||||||
status_t GetRef(entry_ref& ref) const;
|
status_t GetRef(entry_ref& ref) const;
|
||||||
status_t GetMimeType(BMimeType& type) const;
|
status_t GetMimeType(BMimeType& type) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool AcceptsDrag(const BMessage* message);
|
virtual bool AcceptsDrag(const BMessage* message);
|
||||||
virtual BRect BitmapRect() const;
|
virtual BRect BitmapRect() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _AddOrEditIcon();
|
void _AddOrEditIcon();
|
||||||
void _SetIcon(BBitmap* large, BBitmap* mini, const uint8* data, size_t size,
|
void _SetIcon(BBitmap* large, BBitmap* mini,
|
||||||
bool force = false);
|
const uint8* data, size_t size,
|
||||||
void _SetIcon(entry_ref* ref);
|
bool force = false);
|
||||||
void _RemoveIcon();
|
void _SetIcon(entry_ref* ref);
|
||||||
void _DeleteIcons();
|
void _RemoveIcon();
|
||||||
void _StartWatching();
|
void _DeleteIcons();
|
||||||
void _StopWatching();
|
void _StartWatching();
|
||||||
|
void _StopWatching();
|
||||||
|
|
||||||
BMessenger fTarget;
|
BMessenger fTarget;
|
||||||
BMessage* fModificationMessage;
|
BMessage* fModificationMessage;
|
||||||
int32 fIconSize;
|
int32 fIconSize;
|
||||||
BBitmap* fIcon;
|
BBitmap* fIcon;
|
||||||
BBitmap* fHeapIcon;
|
BBitmap* fHeapIcon;
|
||||||
|
|
||||||
bool fHasRef;
|
bool fHasRef;
|
||||||
bool fHasType;
|
bool fHasType;
|
||||||
entry_ref fRef;
|
entry_ref fRef;
|
||||||
BMimeType fType;
|
BMimeType fType;
|
||||||
icon_source fSource;
|
icon_source fSource;
|
||||||
::Icon* fIconData;
|
::Icon* fIconData;
|
||||||
|
|
||||||
BPoint fDragPoint;
|
BPoint fDragPoint;
|
||||||
bool fTracking;
|
bool fTracking;
|
||||||
bool fDragging;
|
bool fDragging;
|
||||||
bool fDropTarget;
|
bool fDropTarget;
|
||||||
bool fShowEmptyFrame;
|
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,
|
static const uint32 kMsgIconInvoked = 'iciv';
|
||||||
icon_source* _source = NULL);
|
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,
|
extern status_t icon_for_type(const BMimeType& type, BBitmap& bitmap,
|
||||||
icon_size size, icon_source* _source = NULL);
|
icon_size size, icon_source* _source = NULL);
|
||||||
|
|
||||||
|
|
||||||
#endif // ICON_VIEW_H
|
#endif // ICON_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user