* Moved class BStringItem into its own source file.

* Changed BStringItem::Update() to set a better baseline offset and height;
  this should improve vertical text placement.
* Fixed a bug in BStringItem::Update(): it used the owner to determine the
  width, but must use the font passed in instead.
* Coding style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-06-17 16:26:17 +00:00
parent 8e5744fe72
commit f3b1ada54f
5 changed files with 265 additions and 271 deletions
+48 -43
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _LIST_ITEM_H
@@ -17,76 +17,81 @@ class BView;
class BListItem : public BArchivable {
public:
public:
BListItem(uint32 outlineLevel = 0,
bool expanded = true);
BListItem(BMessage* archive);
virtual ~BListItem();
virtual ~BListItem();
virtual status_t Archive(BMessage* archive, bool deep = true) const;
virtual status_t Archive(BMessage* archive, bool deep = true) const;
float Height() const;
float Width() const;
bool IsSelected() const;
void Select();
void Deselect();
float Height() const;
float Width() const;
bool IsSelected() const;
void Select();
void Deselect();
virtual void SetEnabled(bool enabled);
bool IsEnabled() const;
virtual void SetEnabled(bool enabled);
bool IsEnabled() const;
void SetHeight(float height);
void SetWidth(float width);
virtual void DrawItem(BView* owner, BRect frame,
void SetHeight(float height);
void SetWidth(float width);
virtual void DrawItem(BView* owner, BRect frame,
bool complete = false) = 0;
virtual void Update(BView* owner, const BFont* font);
virtual void Update(BView* owner, const BFont* font);
virtual status_t Perform(perform_code code, void* arg);
virtual status_t Perform(perform_code code, void* arg);
bool IsExpanded() const;
void SetExpanded(bool expanded);
uint32 OutlineLevel() const;
bool IsExpanded() const;
void SetExpanded(bool expanded);
uint32 OutlineLevel() const;
private:
friend class BOutlineListView;
friend class BListView;
bool HasSubitems() const;
private:
friend class BOutlineListView;
friend class BListView;
virtual void _ReservedListItem1();
virtual void _ReservedListItem2();
bool HasSubitems() const;
virtual void _ReservedListItem1();
virtual void _ReservedListItem2();
BListItem(const BListItem& item);
BListItem& operator=(const BListItem& item);
BListItem& operator=(const BListItem& item);
bool IsItemVisible() const;
void SetItemVisible(bool visible);
inline float Top() const;
inline float Bottom() const;
void SetTop(float top);
private:
float fTop;
BList* fTemporaryList;
float fWidth;
float fHeight;
uint32 fLevel;
bool fSelected;
bool fEnabled;
bool fExpanded;
bool fHasSubitems : 1;
bool fVisible : 1;
bool IsItemVisible() const;
void SetItemVisible(bool visible);
inline float Top() const;
inline float Bottom() const;
void SetTop(float top);
private:
float fTop;
BList* fTemporaryList;
float fWidth;
float fHeight;
uint32 fLevel;
bool fSelected;
bool fEnabled;
bool fExpanded;
bool fHasSubitems : 1;
bool fVisible : 1;
};
inline float
BListItem::Top(void) const
{
return fTop;
}
inline float
BListItem::Bottom(void) const
{
return (fTop + ceilf(fHeight) - 1.0);
return fTop + ceilf(fHeight) - 1.0;
}
#include <StringItem.h>
// to maintain source compatibility
+20 -19
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STRING_ITEM_H
@@ -10,33 +10,34 @@
class BStringItem : public BListItem {
public:
BStringItem(const char* text, uint32 outlineLevel = 0,
bool expanded = true);
public:
BStringItem(const char* text,
uint32 outlineLevel = 0, bool expanded = true);
BStringItem(BMessage* archive);
virtual ~BStringItem();
virtual ~BStringItem();
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive, bool deep = true) const;
virtual void DrawItem(BView* owner, BRect frame, bool complete = false);
virtual void SetText(const char* text);
const char* Text() const;
virtual void DrawItem(BView* owner, BRect frame,
bool complete = false);
virtual void SetText(const char* text);
const char* Text() const;
virtual void Update(BView* owner, const BFont* font);
virtual void Update(BView* owner, const BFont* font);
virtual status_t Perform(perform_code code, void* arg);
virtual status_t Perform(perform_code code, void* arg);
private:
virtual void _ReservedStringItem1();
virtual void _ReservedStringItem2();
private:
virtual void _ReservedStringItem1();
virtual void _ReservedStringItem2();
BStringItem(const BStringItem& item);
BStringItem& operator=(const BStringItem& item);
BStringItem& operator=(const BStringItem& item);
char* fText;
float fBaselineOffset;
uint32 _reserved[2];
char* fText;
float fBaselineOffset;
uint32 _reserved[2];
};
#endif // _STRING_ITEM_H