Author: zooey Date: 2010-08-17 18:25:45 +0200 (Tue, 17 Aug 2010) New Revision: 38197 Changeset: http://dev.haiku-os.org/changeset/38197 Modified: haiku/trunk/src/preferences/filetypes/IconView.cpp haiku/trunk/src/preferences/filetypes/IconView.h Log: * style adjustments - no functional change Modified: haiku/trunk/src/preferences/filetypes/IconView.cpp =================================================================== --- haiku/trunk/src/preferences/filetypes/IconView.cpp 2010-08-17 16:15:45 UTC (rev 38196) +++ haiku/trunk/src/preferences/filetypes/IconView.cpp 2010-08-17 16:25:45 UTC (rev 38197) @@ -431,17 +431,20 @@ 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 @@ 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 @@ 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 @@ { if (message == NULL) fTarget.SendMessage(kMsgIconInvoked); - else + else fTarget.SendMessage(message); return B_OK; } @@ -1220,7 +1225,8 @@ 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 @@ 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 @@ else if (fHasType) BMimeType::StopWatching(this); } - Modified: haiku/trunk/src/preferences/filetypes/IconView.h =================================================================== --- haiku/trunk/src/preferences/filetypes/IconView.h 2010-08-17 16:15:45 UTC (rev 38196) +++ haiku/trunk/src/preferences/filetypes/IconView.h 2010-08-17 16:25:45 UTC (rev 38197) @@ -22,132 +22,148 @@ 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