A bunch of style fixes

No functional changes intended
This commit is contained in:
John Scipione
2014-12-02 19:23:51 -05:00
parent dc4f88b8fb
commit 539dc1bc53
11 changed files with 386 additions and 368 deletions
+105 -136
View File
@@ -13,7 +13,9 @@
#ifndef _COLUMN_TYPES_H #ifndef _COLUMN_TYPES_H
#define _COLUMN_TYPES_H #define _COLUMN_TYPES_H
#include "ColumnListView.h" #include "ColumnListView.h"
#include <String.h> #include <String.h>
#include <Font.h> #include <Font.h>
#include <Bitmap.h> #include <Bitmap.h>
@@ -24,28 +26,23 @@
class BTitledColumn : public BColumn class BTitledColumn : public BColumn
{ {
public: public:
BTitledColumn (const char *title, BTitledColumn(const char* title, float width, float minWidth,
float width, float maxWidth, alignment align = B_ALIGN_LEFT);
float minWidth, virtual void DrawTitle(BRect rect, BView* parent);
float maxWidth, virtual void GetColumnName(BString* into) const;
alignment align = B_ALIGN_LEFT);
virtual void DrawTitle (BRect rect,
BView* parent);
virtual void GetColumnName (BString* into) const;
void DrawString (const char*, void DrawString(const char*, BView*, BRect);
BView*, void SetTitle(const char* title);
BRect); void Title(BString* forTitle) const;
void SetTitle (const char* title); // sets the BString arg to be the title
void Title (BString* forTitle) const; // sets the BString arg to be the title float FontHeight() const;
float FontHeight () const;
virtual float GetPreferredWidth(BField* field, BView* parent) const; virtual float GetPreferredWidth(BField* field, BView* parent) const;
private: private:
float fFontHeight; float fFontHeight;
BString fTitle; BString fTitle;
}; };
@@ -54,21 +51,21 @@ class BTitledColumn : public BColumn
class BStringField : public BField class BStringField : public BField
{ {
public: public:
BStringField (const char* string); BStringField(const char* string);
void SetString (const char* string); void SetString(const char* string);
const char* String () const; const char* String() const;
void SetClippedString (const char* string); void SetClippedString(const char* string);
bool HasClippedString () const; bool HasClippedString() const;
const char* ClippedString (); const char* ClippedString();
void SetWidth (float); void SetWidth(float);
float Width (); float Width();
private: private:
float fWidth; float fWidth;
BString fString; BString fString;
BString fClippedString; BString fClippedString;
}; };
@@ -76,23 +73,17 @@ class BStringField : public BField
class BStringColumn : public BTitledColumn class BStringColumn : public BTitledColumn
{ {
public: public:
BStringColumn (const char *title, BStringColumn(const char* title, float width,
float width, float minWidth, float maxWidth, uint32 truncate,
float minWidth, alignment align = B_ALIGN_LEFT);
float maxWidth, virtual void DrawField(BField* field, BRect rect, BView* parent);
uint32 truncate, virtual int CompareFields(BField* field1, BField* field2);
alignment align = B_ALIGN_LEFT); virtual float GetPreferredWidth(BField* field, BView* parent) const;
virtual void DrawField (BField* field, virtual bool AcceptsField(const BField* field) const;
BRect rect,
BView* parent);
virtual int CompareFields (BField* field1,
BField* field2);
virtual float GetPreferredWidth(BField* field, BView* parent) const;
virtual bool AcceptsField (const BField* field) const;
private: private:
uint32 fTruncate; uint32 fTruncate;
}; };
@@ -101,21 +92,21 @@ class BStringColumn : public BTitledColumn
class BDateField : public BField class BDateField : public BField
{ {
public: public:
BDateField (time_t* t); BDateField(time_t* t);
void SetWidth (float); void SetWidth(float);
float Width (); float Width();
void SetClippedString (const char*); void SetClippedString(const char*);
const char* ClippedString (); const char* ClippedString();
time_t Seconds (); time_t Seconds();
time_t UnixTime (); time_t UnixTime();
private: private:
struct tm fTime; struct tm fTime;
time_t fUnixTime; time_t fUnixTime;
time_t fSeconds; time_t fSeconds;
BString fClippedString; BString fClippedString;
float fWidth; float fWidth;
}; };
@@ -123,19 +114,15 @@ class BDateField : public BField
class BDateColumn : public BTitledColumn class BDateColumn : public BTitledColumn
{ {
public: public:
BDateColumn (const char* title, BDateColumn(const char* title, float width,
float width, float minWidth, float maxWidth,
float minWidth, alignment align = B_ALIGN_LEFT);
float maxWidth, virtual void DrawField(BField* field, BRect rect, BView* parent);
alignment align = B_ALIGN_LEFT); virtual int CompareFields(BField* field1, BField* field2);
virtual void DrawField (BField* field,
BRect rect, private:
BView* parent); BString fTitle;
virtual int CompareFields (BField* field1,
BField* field2);
private:
BString fTitle;
}; };
@@ -144,13 +131,13 @@ class BDateColumn : public BTitledColumn
class BSizeField : public BField class BSizeField : public BField
{ {
public: public:
BSizeField (off_t size); BSizeField(off_t size);
void SetSize (off_t); void SetSize(off_t);
off_t Size (); off_t Size();
private: private:
off_t fSize; off_t fSize;
}; };
@@ -158,17 +145,12 @@ class BSizeField : public BField
class BSizeColumn : public BTitledColumn class BSizeColumn : public BTitledColumn
{ {
public: public:
BSizeColumn (const char* title, BSizeColumn(const char* title, float width,
float width, float minWidth, float maxWidth,
float minWidth, alignment align = B_ALIGN_LEFT);
float maxWidth, virtual void DrawField(BField* field, BRect rect, BView* parent);
alignment align = B_ALIGN_LEFT); virtual int CompareFields(BField* field1, BField* field2);
virtual void DrawField (BField* field,
BRect rect,
BView* parent);
virtual int CompareFields (BField* field1,
BField* field2);
}; };
@@ -177,13 +159,13 @@ class BSizeColumn : public BTitledColumn
class BIntegerField : public BField class BIntegerField : public BField
{ {
public: public:
BIntegerField (int32 number); BIntegerField(int32 number);
void SetValue (int32); void SetValue(int32);
int32 Value (); int32 Value();
private: private:
int32 fInteger; int32 fInteger;
}; };
@@ -191,17 +173,12 @@ class BIntegerField : public BField
class BIntegerColumn : public BTitledColumn class BIntegerColumn : public BTitledColumn
{ {
public: public:
BIntegerColumn (const char* title, BIntegerColumn(const char* title, float width,
float width, float minWidth, float maxWidth,
float minWidth, alignment align = B_ALIGN_LEFT);
float maxWidth, virtual void DrawField(BField* field, BRect rect, BView* parent);
alignment align = B_ALIGN_LEFT); virtual int CompareFields(BField* field1, BField* field2);
virtual void DrawField (BField* field,
BRect rect,
BView* parent);
virtual int CompareFields (BField* field1,
BField* field2);
}; };
@@ -210,13 +187,13 @@ class BIntegerColumn : public BTitledColumn
class BBitmapField : public BField class BBitmapField : public BField
{ {
public: public:
BBitmapField (BBitmap* bitmap); BBitmapField(BBitmap* bitmap);
const BBitmap* Bitmap (); const BBitmap* Bitmap();
void SetBitmap (BBitmap* bitmap); void SetBitmap(BBitmap* bitmap);
private: private:
BBitmap* fBitmap; BBitmap* fBitmap;
}; };
@@ -224,17 +201,13 @@ class BBitmapField : public BField
class BBitmapColumn : public BTitledColumn class BBitmapColumn : public BTitledColumn
{ {
public: public:
BBitmapColumn (const char* title, BBitmapColumn(const char* title, float width,
float width, float minWidth, float maxWidth,
float minWidth, alignment align = B_ALIGN_LEFT);
float maxWidth, virtual void DrawField(BField* field, BRect rect, BView* parent);
alignment align = B_ALIGN_LEFT); virtual int CompareFields(BField* field1, BField* field2);
virtual void DrawField (BField*field, virtual bool AcceptsField(const BField* field) const;
BRect rect,
BView* parent);
virtual int CompareFields (BField* field1, BField* field2);
virtual bool AcceptsField (const BField* field) const;
}; };
@@ -243,16 +216,12 @@ class BBitmapColumn : public BTitledColumn
class GraphColumn : public BIntegerColumn class GraphColumn : public BIntegerColumn
{ {
public: public:
GraphColumn (const char* name, GraphColumn(const char* name, float width,
float width, float minWidth, float maxWidth,
float minWidth, alignment align = B_ALIGN_LEFT);
float maxWidth, virtual void DrawField(BField* field, BRect rect, BView* parent);
alignment align = B_ALIGN_LEFT);
virtual void DrawField (BField*field,
BRect rect,
BView* parent);
}; };
#endif
#endif // _COLUMN_TYPES_H
+93 -77
View File
@@ -70,12 +70,14 @@ All rights reserved.
#include "ColorTools.h" #include "ColorTools.h"
#include "ObjectList.h" #include "ObjectList.h"
#define DOUBLE_BUFFERED_COLUMN_RESIZE 1 #define DOUBLE_BUFFERED_COLUMN_RESIZE 1
#define SMART_REDRAW 1 #define SMART_REDRAW 1
#define DRAG_TITLE_OUTLINE 1 #define DRAG_TITLE_OUTLINE 1
#define CONSTRAIN_CLIPPING_REGION 1 #define CONSTRAIN_CLIPPING_REGION 1
#define LOWER_SCROLLBAR 0 #define LOWER_SCROLLBAR 0
namespace BPrivate { namespace BPrivate {
static const unsigned char kDownSortArrow8x8[] = { static const unsigned char kDownSortArrow8x8[] = {
@@ -247,6 +249,7 @@ private:
BCursor* fColumnMoveCursor; BCursor* fColumnMoveCursor;
}; };
class OutlineView : public BView { class OutlineView : public BView {
typedef BView _inherited; typedef BView _inherited;
public: public:
@@ -371,6 +374,7 @@ private:
friend class RecursiveOutlineIterator; friend class RecursiveOutlineIterator;
}; };
class RecursiveOutlineIterator { class RecursiveOutlineIterator {
public: public:
RecursiveOutlineIterator( RecursiveOutlineIterator(
@@ -550,26 +554,25 @@ BRow::ValidateField(const BField* field, int32 logicalFieldIndex) const
// The Fields may be moved by the user, but the logicalFieldIndexes // The Fields may be moved by the user, but the logicalFieldIndexes
// do not change, so we need to map them over when checking the // do not change, so we need to map them over when checking the
// Field types. // Field types.
BColumn* col = NULL; BColumn* column = NULL;
int32 items = fList->CountColumns(); int32 items = fList->CountColumns();
for (int32 i = 0 ; i < items; ++i) { for (int32 i = 0 ; i < items; ++i) {
col = fList->ColumnAt(i); column = fList->ColumnAt(i);
if( col->LogicalFieldNum() == logicalFieldIndex ) if(column->LogicalFieldNum() == logicalFieldIndex )
break; break;
} }
if (NULL == col) { if (column == NULL) {
BString dbmessage("\n\n\tThe parent BColumnListView does not have " BString dbmessage("\n\n\tThe parent BColumnListView does not have "
"\n\ta BColumn at the logical field index "); "\n\ta BColumn at the logical field index ");
dbmessage << logicalFieldIndex << ".\n\n"; dbmessage << logicalFieldIndex << ".\n\n";
printf(dbmessage.String()); printf(dbmessage.String());
} else { } else {
if (!col->AcceptsField(field)) { if (!column->AcceptsField(field)) {
BString dbmessage("\n\n\tThe BColumn of type "); BString dbmessage("\n\n\tThe BColumn of type ");
dbmessage << typeid(*col).name() << "\n\tat logical field index " dbmessage << typeid(*column).name() << "\n\tat logical field index "
<< logicalFieldIndex << "\n\tdoes not support the " << logicalFieldIndex << "\n\tdoes not support the field type "
"field type " << typeid(*field).name() << ".\n\n";
<< typeid(*field).name() << ".\n\n";
debugger(dbmessage.String()); debugger(dbmessage.String());
} }
} }
@@ -940,7 +943,8 @@ BColumnListView::SetSortingEnabled(bool enabled)
{ {
fSortingEnabled = enabled; fSortingEnabled = enabled;
fSortColumns.MakeEmpty(); fSortColumns.MakeEmpty();
fTitleView->Invalidate(); // Erase sort indicators fTitleView->Invalidate();
// erase sort indicators
} }
@@ -973,7 +977,8 @@ void
BColumnListView::ClearSortColumns() BColumnListView::ClearSortColumns()
{ {
fSortColumns.MakeEmpty(); fSortColumns.MakeEmpty();
fTitleView->Invalidate(); // Erase sort indicators fTitleView->Invalidate();
// erase sort indicators
} }
@@ -1033,7 +1038,7 @@ BColumnListView::AddColumn(BColumn* column, int32 logicalFieldIndex)
column->fList = this; column->fList = this;
column->fFieldID = logicalFieldIndex; column->fFieldID = logicalFieldIndex;
// sanity check. If there is already a field with this ID, remove it. // sanity check -- if there is already a field with this ID, remove it.
for (int32 index = 0; index < fColumns.CountItems(); index++) { for (int32 index = 0; index < fColumns.CountItems(); index++) {
BColumn* existingColumn = (BColumn*) fColumns.ItemAt(index); BColumn* existingColumn = (BColumn*) fColumns.ItemAt(index);
if (existingColumn && existingColumn->fFieldID == logicalFieldIndex) { if (existingColumn && existingColumn->fFieldID == logicalFieldIndex) {
@@ -1117,7 +1122,7 @@ void
BColumnListView::SetColumnVisible(int32 index, bool isVisible) BColumnListView::SetColumnVisible(int32 index, bool isVisible)
{ {
BColumn* column = ColumnAt(index); BColumn* column = ColumnAt(index);
if (column) if (column != NULL)
column->SetVisible(isVisible); column->SetVisible(isVisible);
} }
@@ -1126,7 +1131,7 @@ bool
BColumnListView::IsColumnVisible(int32 index) const BColumnListView::IsColumnVisible(int32 index) const
{ {
BColumn* column = ColumnAt(index); BColumn* column = ColumnAt(index);
if (column) if (column != NULL)
return column->IsVisible(); return column->IsVisible();
return false; return false;
@@ -1355,10 +1360,10 @@ BColumnListView::InvalidateRow(BRow* row)
} }
// This method is deprecated.
void void
BColumnListView::SetFont(const BFont* font, uint32 mask) BColumnListView::SetFont(const BFont* font, uint32 mask)
{ {
// This method is deprecated.
fOutlineView->SetFont(font, mask); fOutlineView->SetFont(font, mask);
fTitleView->SetFont(font, mask); fTitleView->SetFont(font, mask);
} }
@@ -1404,36 +1409,36 @@ BColumnListView::GetFont(ColumnListViewFont font_num, BFont* font) const
void void
BColumnListView::SetColor(ColumnListViewColor color_num, const rgb_color color) BColumnListView::SetColor(ColumnListViewColor colorIndex, const rgb_color color)
{ {
if ((int)color_num < 0) { if ((int)colorIndex < 0) {
ASSERT(false); ASSERT(false);
color_num = (ColumnListViewColor) 0; colorIndex = (ColumnListViewColor)0;
} }
if ((int)color_num >= (int)B_COLOR_TOTAL) { if ((int)colorIndex >= (int)B_COLOR_TOTAL) {
ASSERT(false); ASSERT(false);
color_num = (ColumnListViewColor) (B_COLOR_TOTAL - 1); colorIndex = (ColumnListViewColor)(B_COLOR_TOTAL - 1);
} }
fColorList[color_num] = color; fColorList[colorIndex] = color;
} }
rgb_color rgb_color
BColumnListView::Color(ColumnListViewColor color_num) const BColumnListView::Color(ColumnListViewColor colorIndex) const
{ {
if ((int)color_num < 0) { if ((int)colorIndex < 0) {
ASSERT(false); ASSERT(false);
color_num = (ColumnListViewColor) 0; colorIndex = (ColumnListViewColor)0;
} }
if ((int)color_num >= (int)B_COLOR_TOTAL) { if ((int)colorIndex >= (int)B_COLOR_TOTAL) {
ASSERT(false); ASSERT(false);
color_num = (ColumnListViewColor) (B_COLOR_TOTAL - 1); colorIndex = (ColumnListViewColor)(B_COLOR_TOTAL - 1);
} }
return fColorList[color_num]; return fColorList[colorIndex];
} }
@@ -1441,10 +1446,10 @@ void
BColumnListView::SetHighColor(rgb_color color) BColumnListView::SetHighColor(rgb_color color)
{ {
BView::SetHighColor(color); BView::SetHighColor(color);
// fOutlineView->Invalidate(); // Redraw things with the new color // fOutlineView->Invalidate();
// Note that this will currently cause // Redraw with the new color.
// an infinite loop, refreshing over and over. // Note that this will currently cause an infinite loop, refreshing
// A better solution is needed. // over and over. A better solution is needed.
} }
@@ -1459,7 +1464,8 @@ void
BColumnListView::SetBackgroundColor(rgb_color color) BColumnListView::SetBackgroundColor(rgb_color color)
{ {
fColorList[B_COLOR_BACKGROUND] = color; fColorList[B_COLOR_BACKGROUND] = color;
fOutlineView->Invalidate(); // Repaint with new color fOutlineView->Invalidate();
// repaint with new color
} }
@@ -1517,7 +1523,7 @@ BColumnListView::SuggestTextPosition(const BRow* row,
font_height fh; font_height fh;
fOutlineView->GetFontHeight(&fh); fOutlineView->GetFontHeight(&fh);
float baseline = floor(rect.top + fh.ascent float baseline = floor(rect.top + fh.ascent
+ (rect.Height()+1-(fh.ascent+fh.descent))/2); + (rect.Height() + 1 - (fh.ascent + fh.descent)) / 2);
return BPoint(rect.left + 8, baseline); return BPoint(rect.left + 8, baseline);
} }
@@ -1543,12 +1549,12 @@ BColumnListView::DrawLatch(BView* view, BRect rect, LatchType position, BRow*)
view->SetHighColor(0, 0, 0); view->SetHighColor(0, 0, 0);
// Make Square // make square
int32 sideLen = rect.IntegerWidth(); int32 sideLen = rect.IntegerWidth();
if (sideLen > rect.IntegerHeight()) if (sideLen > rect.IntegerHeight())
sideLen = rect.IntegerHeight(); sideLen = rect.IntegerHeight();
// Make Center // make center
int32 halfWidth = rect.IntegerWidth() / 2; int32 halfWidth = rect.IntegerWidth() / 2;
int32 halfHeight = rect.IntegerHeight() / 2; int32 halfHeight = rect.IntegerHeight() / 2;
int32 halfSide = sideLen / 2; int32 halfSide = sideLen / 2;
@@ -1563,7 +1569,7 @@ BColumnListView::DrawLatch(BView* view, BRect rect, LatchType position, BRow*)
itemRect.InsetBy(rectInset, rectInset); itemRect.InsetBy(rectInset, rectInset);
// Make it an odd number of pixels wide, the latch looks better this way // make it an odd number of pixels wide, the latch looks better this way
if ((itemRect.IntegerWidth() % 2) == 1) { if ((itemRect.IntegerWidth() % 2) == 1) {
itemRect.right += 1; itemRect.right += 1;
itemRect.bottom += 1; itemRect.bottom += 1;
@@ -1763,9 +1769,10 @@ void
BColumnListView::WindowActivated(bool active) BColumnListView::WindowActivated(bool active)
{ {
fOutlineView->Invalidate(); fOutlineView->Invalidate();
// Focus and selection appearance changes with focus // focus and selection appearance changes with focus
Invalidate(); // Redraw focus marks around view Invalidate();
// redraw focus marks around view
BView::WindowActivated(active); BView::WindowActivated(active);
} }
@@ -1851,56 +1858,56 @@ BColumnListView::Draw(BRect updateRect)
void void
BColumnListView::SaveState(BMessage* msg) BColumnListView::SaveState(BMessage* message)
{ {
msg->MakeEmpty(); message->MakeEmpty();
for (int32 i = 0; BColumn* col = (BColumn*)fColumns.ItemAt(i); i++) { for (int32 i = 0; BColumn* column = (BColumn*)fColumns.ItemAt(i); i++) {
msg->AddInt32("ID",col->fFieldID); message->AddInt32("ID", column->fFieldID);
msg->AddFloat("width", col->fWidth); message->AddFloat("width", column->fWidth);
msg->AddBool("visible", col->fVisible); message->AddBool("visible", column->fVisible);
} }
msg->AddBool("sortingenabled", fSortingEnabled); message->AddBool("sortingenabled", fSortingEnabled);
if (fSortingEnabled) { if (fSortingEnabled) {
for (int32 i = 0; BColumn* col = (BColumn*)fSortColumns.ItemAt(i); for (int32 i = 0; BColumn* column = (BColumn*)fSortColumns.ItemAt(i);
i++) { i++) {
msg->AddInt32("sortID", col->fFieldID); message->AddInt32("sortID", column->fFieldID);
msg->AddBool("sortascending", col->fSortAscending); message->AddBool("sortascending", column->fSortAscending);
} }
} }
} }
void void
BColumnListView::LoadState(BMessage* msg) BColumnListView::LoadState(BMessage* message)
{ {
int32 id; int32 id;
for (int i = 0; msg->FindInt32("ID", i, &id) == B_OK; i++) { for (int i = 0; message->FindInt32("ID", i, &id) == B_OK; i++) {
for (int j = 0; BColumn* column = (BColumn*)fColumns.ItemAt(j); j++) { for (int j = 0; BColumn* column = (BColumn*)fColumns.ItemAt(j); j++) {
if (column->fFieldID == id) { if (column->fFieldID == id) {
// move this column to position 'i' and set its attributes // move this column to position 'i' and set its attributes
MoveColumn(column, i); MoveColumn(column, i);
float width; float width;
if (msg->FindFloat("width", i, &width) == B_OK) if (message->FindFloat("width", i, &width) == B_OK)
column->SetWidth(width); column->SetWidth(width);
bool visible; bool visible;
if (msg->FindBool("visible", i, &visible) == B_OK) if (message->FindBool("visible", i, &visible) == B_OK)
column->SetVisible(visible); column->SetVisible(visible);
} }
} }
} }
bool b; bool b;
if (msg->FindBool("sortingenabled", &b) == B_OK) { if (message->FindBool("sortingenabled", &b) == B_OK) {
SetSortingEnabled(b); SetSortingEnabled(b);
for (int k = 0; msg->FindInt32("sortID", k, &id) == B_OK; k++) { for (int k = 0; message->FindInt32("sortID", k, &id) == B_OK; k++) {
for (int j = 0; BColumn* column = (BColumn*)fColumns.ItemAt(j); for (int j = 0; BColumn* column = (BColumn*)fColumns.ItemAt(j);
j++) { j++) {
if (column->fFieldID == id) { if (column->fFieldID == id) {
// add this column to the sort list // add this column to the sort list
bool value; bool value;
if (msg->FindBool("sortascending", k, &value) == B_OK) if (message->FindBool("sortascending", k, &value) == B_OK)
SetSortColumn(column, true, value); SetSortColumn(column, true, value);
} }
} }
@@ -2051,6 +2058,7 @@ BColumnListView::_Init()
BRect bounds(Bounds()); BRect bounds(Bounds());
if (bounds.Width() <= 0) if (bounds.Width() <= 0)
bounds.right = 100; bounds.right = 100;
if (bounds.Height() <= 0) if (bounds.Height() <= 0)
bounds.bottom = 100; bounds.bottom = 100;
@@ -2682,14 +2690,14 @@ TitleView::Draw(BRect invalidRect)
} }
// Bevels for right title margin // bevels for right title margin
if (columnLeftEdge <= invalidRect.right) { if (columnLeftEdge <= invalidRect.right) {
BRect titleRect(columnLeftEdge, 0, Bounds().right + 2, BRect titleRect(columnLeftEdge, 0, Bounds().right + 2,
fVisibleRect.Height()); fVisibleRect.Height());
DrawTitle(this, titleRect, NULL, false); DrawTitle(this, titleRect, NULL, false);
} }
// Bevels for left title margin // bevels for left title margin
if (invalidRect.left < MAX(kLeftMargin, fMasterView->LatchWidth())) { if (invalidRect.left < MAX(kLeftMargin, fMasterView->LatchWidth())) {
BRect titleRect(0, 0, MAX(kLeftMargin, fMasterView->LatchWidth()) - 1, BRect titleRect(0, 0, MAX(kLeftMargin, fMasterView->LatchWidth()) - 1,
fVisibleRect.Height()); fVisibleRect.Height());
@@ -2697,7 +2705,7 @@ TitleView::Draw(BRect invalidRect)
} }
#if DRAG_TITLE_OUTLINE #if DRAG_TITLE_OUTLINE
// (Internal) Column Drag Indicator // (internal) column drag indicator
if (fCurrentState == DRAG_COLUMN_INSIDE_TITLE) { if (fCurrentState == DRAG_COLUMN_INSIDE_TITLE) {
BRect dragRect(fSelectedColumnRect); BRect dragRect(fSelectedColumnRect);
dragRect.OffsetTo(fCurrentDragPosition.x - fClickPoint.x, 0); dragRect.OffsetTo(fCurrentDragPosition.x - fClickPoint.x, 0);
@@ -2737,23 +2745,24 @@ TitleView::MessageReceived(BMessage* message)
if (message->FindInt32("be:field_num", &num) == B_OK) { if (message->FindInt32("be:field_num", &num) == B_OK) {
for (int index = 0; index < fColumns->CountItems(); index++) { for (int index = 0; index < fColumns->CountItems(); index++) {
BColumn* column = (BColumn*) fColumns->ItemAt(index); BColumn* column = (BColumn*) fColumns->ItemAt(index);
if (!column) if (column == NULL)
continue; continue;
if (column->LogicalFieldNum() == num) if (column->LogicalFieldNum() == num)
column->SetVisible(!column->IsVisible()); column->SetVisible(!column->IsVisible());
} }
} }
return; return;
} else {
BView::MessageReceived(message);
} }
BView::MessageReceived(message);
} }
void void
TitleView::MouseDown(BPoint position) TitleView::MouseDown(BPoint position)
{ {
if(fEditMode) if (fEditMode)
return; return;
int32 buttons = 1; int32 buttons = 1;
@@ -2761,46 +2770,52 @@ TitleView::MouseDown(BPoint position)
if (buttons == B_SECONDARY_MOUSE_BUTTON if (buttons == B_SECONDARY_MOUSE_BUTTON
&& (fColumnFlags & B_ALLOW_COLUMN_POPUP)) { && (fColumnFlags & B_ALLOW_COLUMN_POPUP)) {
// Right mouse button -- bring up menu to show/hide columns. // Right mouse button -- bring up menu to show/hide columns.
if (!fColumnPop) fColumnPop = new BPopUpMenu("Columns", false, false); if (fColumnPop == NULL)
fColumnPop = new BPopUpMenu("Columns", false, false);
fColumnPop->RemoveItems(0, fColumnPop->CountItems(), true); fColumnPop->RemoveItems(0, fColumnPop->CountItems(), true);
BMessenger me(this); BMessenger me(this);
for (int index = 0; index < fColumns->CountItems(); index++) { for (int index = 0; index < fColumns->CountItems(); index++) {
BColumn* column = (BColumn*) fColumns->ItemAt(index); BColumn* column = (BColumn*) fColumns->ItemAt(index);
if (!column) continue; if (column == NULL)
continue;
BString name; BString name;
column->GetColumnName(&name); column->GetColumnName(&name);
BMessage* msg = new BMessage(kToggleColumn); BMessage* message = new BMessage(kToggleColumn);
msg->AddInt32("be:field_num", column->LogicalFieldNum()); message->AddInt32("be:field_num", column->LogicalFieldNum());
BMenuItem* it = new BMenuItem(name.String(), msg); BMenuItem* item = new BMenuItem(name.String(), message);
it->SetMarked(column->IsVisible()); item->SetMarked(column->IsVisible());
it->SetTarget(me); item->SetTarget(me);
fColumnPop->AddItem(it); fColumnPop->AddItem(item);
} }
BPoint screenPosition = ConvertToScreen(position); BPoint screenPosition = ConvertToScreen(position);
BRect sticky(screenPosition, screenPosition); BRect sticky(screenPosition, screenPosition);
sticky.InsetBy(-5, -5); sticky.InsetBy(-5, -5);
fColumnPop->Go(ConvertToScreen(position), true, false, sticky, true); fColumnPop->Go(ConvertToScreen(position), true, false, sticky, true);
return; return;
} }
fResizingFirstColumn = true; fResizingFirstColumn = true;
float leftEdge = MAX(kLeftMargin, fMasterView->LatchWidth()); float leftEdge = MAX(kLeftMargin, fMasterView->LatchWidth());
for (int index = 0; index < fColumns->CountItems(); index++) { for (int index = 0; index < fColumns->CountItems(); index++) {
BColumn* column = (BColumn*) fColumns->ItemAt(index); BColumn* column = (BColumn*)fColumns->ItemAt(index);
if (!column->IsVisible()) if (column == NULL || !column->IsVisible())
continue; continue;
if (leftEdge > position.x + kColumnResizeAreaWidth / 2) if (leftEdge > position.x + kColumnResizeAreaWidth / 2)
break; break;
// Check for resizing a column // check for resizing a column
float rightEdge = leftEdge + column->Width(); float rightEdge = leftEdge + column->Width();
if (column->ShowHeading()) { if (column->ShowHeading()) {
if (position.x > rightEdge - kColumnResizeAreaWidth / 2 if (position.x > rightEdge - kColumnResizeAreaWidth / 2
&& position.x < rightEdge + kColumnResizeAreaWidth / 2 && position.x < rightEdge + kColumnResizeAreaWidth / 2
&& column->MaxWidth() > column->MinWidth() && column->MaxWidth() > column->MinWidth()
&& (fColumnFlags & B_ALLOW_COLUMN_RESIZE)) { && (fColumnFlags & B_ALLOW_COLUMN_RESIZE) != 0) {
int32 clicks = 0; int32 clicks = 0;
Window()->CurrentMessage()->FindInt32("clicks", &clicks); Window()->CurrentMessage()->FindInt32("clicks", &clicks);
@@ -2822,7 +2837,7 @@ TitleView::MouseDown(BPoint position)
fResizingFirstColumn = false; fResizingFirstColumn = false;
// Check for clicking on a column. // check for clicking on a column
if (position.x > leftEdge && position.x < rightEdge) { if (position.x > leftEdge && position.x < rightEdge) {
fCurrentState = PRESSING_COLUMN; fCurrentState = PRESSING_COLUMN;
fSelectedColumn = column; fSelectedColumn = column;
@@ -3060,7 +3075,7 @@ TitleView::FrameResized(float width, float height)
} }
// #pragma mark - // #pragma mark - OutlineView
OutlineView::OutlineView(BRect rect, BList* visibleColumns, BList* sortColumns, OutlineView::OutlineView(BRect rect, BList* visibleColumns, BList* sortColumns,
@@ -3556,6 +3571,7 @@ OutlineView::FindRow(float ypos, int32* _rowIndent, float* _top)
line += rowHeight + 1; line += rowHeight + 1;
} }
} }
return NULL; return NULL;
} }
+77 -65
View File
@@ -20,12 +20,27 @@
#define kTEXT_MARGIN 8 #define kTEXT_MARGIN 8
const int64 kKB_SIZE = 1024;
const int64 kMB_SIZE = 1048576;
const int64 kGB_SIZE = 1073741824;
const int64 kTB_SIZE = kGB_SIZE * kKB_SIZE;
const char* kSIZE_FORMATS[] = {
"%.2f %s",
"%.1f %s",
"%.f %s",
"%.f%s",
0
};
BTitledColumn::BTitledColumn(const char* title, float width, float minWidth, BTitledColumn::BTitledColumn(const char* title, float width, float minWidth,
float maxWidth, alignment align) float maxWidth, alignment align)
: BColumn(width, minWidth, maxWidth, align), :
BColumn(width, minWidth, maxWidth, align),
fTitle(title) fTitle(title)
{ {
font_height fh; font_height fh;
be_plain_font->GetHeight(&fh); be_plain_font->GetHeight(&fh);
fFontHeight = fh.descent + fh.leading; fFontHeight = fh.descent + fh.leading;
@@ -60,7 +75,8 @@ BTitledColumn::DrawString(const char* string, BView* parent, BRect rect)
parent->GetFont(&font); parent->GetFont(&font);
font.GetHeight(&finfo); font.GetHeight(&finfo);
y = rect.top + ((rect.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2) y = rect.top + ((rect.Height()
- (finfo.ascent + finfo.descent + finfo.leading)) / 2)
+ (finfo.ascent + finfo.descent) - 2; + (finfo.ascent + finfo.descent) - 2;
switch (Alignment()) { switch (Alignment()) {
@@ -70,13 +86,16 @@ BTitledColumn::DrawString(const char* string, BView* parent, BRect rect)
break; break;
case B_ALIGN_CENTER: case B_ALIGN_CENTER:
parent->MovePenTo(rect.left + kTEXT_MARGIN + ((width - font.StringWidth(string)) / 2), y); parent->MovePenTo(rect.left + kTEXT_MARGIN
+ ((width - font.StringWidth(string)) / 2), y);
break; break;
case B_ALIGN_RIGHT: case B_ALIGN_RIGHT:
parent->MovePenTo(rect.right - kTEXT_MARGIN - font.StringWidth(string), y); parent->MovePenTo(rect.right - kTEXT_MARGIN
- font.StringWidth(string), y);
break; break;
} }
parent->DrawString(string); parent->DrawString(string);
} }
@@ -110,7 +129,7 @@ BTitledColumn::GetPreferredWidth(BField *_field, BView* parent) const
} }
// #pragma mark - // #pragma mark - BStringField
BStringField::BStringField(const char* string) BStringField::BStringField(const char* string)
@@ -173,12 +192,13 @@ BStringField::ClippedString()
} }
// #pragma mark - // #pragma mark - BStringColumn
BStringColumn::BStringColumn(const char* title, float width, float minWidth, BStringColumn::BStringColumn(const char* title, float width, float minWidth,
float maxWidth, uint32 truncate, alignment align) float maxWidth, uint32 truncate, alignment align)
: BTitledColumn(title, width, minWidth, maxWidth, align), :
BTitledColumn(title, width, minWidth, maxWidth, align),
fTruncate(truncate) fTruncate(truncate)
{ {
} }
@@ -203,8 +223,9 @@ BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
field->SetWidth(width); field->SetWidth(width);
} }
DrawString(field->HasClippedString() ? field->ClippedString() DrawString(field->HasClippedString()
: field->String(), parent, rect); ? field->ClippedString()
: field->String(), parent, rect);
} }
@@ -231,13 +252,13 @@ BStringColumn::AcceptsField(const BField *field) const
} }
// #pragma mark - // #pragma mark - BDateField
BDateField::BDateField(time_t *t) BDateField::BDateField(time_t* time)
: :
fTime(*localtime(t)), fTime(*localtime(time)),
fUnixTime(*t), fUnixTime(*time),
fSeconds(0), fSeconds(0),
fClippedString(""), fClippedString(""),
fWidth(0) fWidth(0)
@@ -261,9 +282,9 @@ BDateField::Width()
void void
BDateField::SetClippedString(const char* val) BDateField::SetClippedString(const char* string)
{ {
fClippedString = val; fClippedString = string;
} }
@@ -288,12 +309,13 @@ BDateField::UnixTime()
} }
// #pragma mark - // #pragma mark - BDateColumn
BDateColumn::BDateColumn(const char* title, float width, float minWidth, BDateColumn::BDateColumn(const char* title, float width, float minWidth,
float maxWidth, alignment align) float maxWidth, alignment align)
: BTitledColumn(title, width, minWidth, maxWidth, align), :
BTitledColumn(title, width, minWidth, maxWidth, align),
fTitle(title) fTitle(title)
{ {
} }
@@ -314,20 +336,21 @@ void
BDateColumn::DrawField(BField* _field, BRect rect, BView* parent) BDateColumn::DrawField(BField* _field, BRect rect, BView* parent)
{ {
float width = rect.Width() - (2 * kTEXT_MARGIN); float width = rect.Width() - (2 * kTEXT_MARGIN);
BDateField* field = (BDateField*)_field; BDateField* field = (BDateField*)_field;
if (field->Width() != rect.Width()) { if (field->Width() != rect.Width()) {
char dateString[256]; char dateString[256];
time_t curtime = field->UnixTime(); time_t currentTime = field->UnixTime();
tm time_data; tm time_data;
BFont font; BFont font;
parent->GetFont(&font); parent->GetFont(&font);
localtime_r(&curtime, &time_data); localtime_r(&currentTime, &time_data);
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
if (!kTIME_FORMATS[index]) if (!kTIME_FORMATS[index])
break; break;
strftime(dateString, 256, kTIME_FORMATS[index], &time_data); strftime(dateString, 256, kTIME_FORMATS[index], &time_data);
if (font.StringWidth(dateString) <= width) if (font.StringWidth(dateString) <= width)
break; break;
@@ -354,7 +377,7 @@ BDateColumn::CompareFields(BField* field1, BField* field2)
} }
// #pragma mark - // #pragma mark - BSizeField
BSizeField::BSizeField(off_t size) BSizeField::BSizeField(off_t size)
@@ -378,29 +401,17 @@ BSizeField::Size()
} }
// #pragma mark - // #pragma mark - BSizeColumn
BSizeColumn::BSizeColumn(const char* title, float width, float minWidth, BSizeColumn::BSizeColumn(const char* title, float width, float minWidth,
float maxWidth, alignment align) float maxWidth, alignment align)
: BTitledColumn(title, width, minWidth, maxWidth, align) :
BTitledColumn(title, width, minWidth, maxWidth, align)
{ {
} }
const int64 kKB_SIZE = 1024;
const int64 kMB_SIZE = 1048576;
const int64 kGB_SIZE = 1073741824;
const int64 kTB_SIZE = kGB_SIZE * kKB_SIZE;
const char *kSIZE_FORMATS[] = {
"%.2f %s",
"%.1f %s",
"%.f %s",
"%.f%s",
0
};
void void
BSizeColumn::DrawField(BField* _field, BRect rect, BView* parent) BSizeColumn::DrawField(BField* _field, BRect rect, BView* parent)
{ {
@@ -468,7 +479,7 @@ BSizeColumn::CompareFields(BField* field1, BField* field2)
} }
// #pragma mark - // #pragma mark - BIntegerField
BIntegerField::BIntegerField(int32 number) BIntegerField::BIntegerField(int32 number)
@@ -492,12 +503,13 @@ BIntegerField::Value()
} }
// #pragma mark - // #pragma mark - BIntegerColumn
BIntegerColumn::BIntegerColumn(const char* title, float width, float minWidth, BIntegerColumn::BIntegerColumn(const char* title, float width, float minWidth,
float maxWidth, alignment align) float maxWidth, alignment align)
: BTitledColumn(title, width, minWidth, maxWidth, align) :
BTitledColumn(title, width, minWidth, maxWidth, align)
{ {
} }
@@ -507,7 +519,7 @@ BIntegerColumn::DrawField(BField *field, BRect rect, BView* parent)
{ {
char formatted[256]; char formatted[256];
float width = rect.Width() - (2 * kTEXT_MARGIN); float width = rect.Width() - (2 * kTEXT_MARGIN);
BString string; BString string;
sprintf(formatted, "%d", (int)((BIntegerField*)field)->Value()); sprintf(formatted, "%d", (int)((BIntegerField*)field)->Value());
@@ -524,12 +536,13 @@ BIntegerColumn::CompareFields(BField *field1, BField *field2)
} }
// #pragma mark - // #pragma mark - GraphColumn
GraphColumn::GraphColumn(const char* name, float width, float minWidth, GraphColumn::GraphColumn(const char* name, float width, float minWidth,
float maxWidth, alignment align) float maxWidth, alignment align)
: BIntegerColumn(name, width, minWidth, maxWidth, align) :
BIntegerColumn(name, width, minWidth, maxWidth, align)
{ {
} }
@@ -537,7 +550,7 @@ GraphColumn::GraphColumn(const char* name, float width, float minWidth,
void void
GraphColumn::DrawField(BField* field, BRect rect, BView* parent) GraphColumn::DrawField(BField* field, BRect rect, BView* parent)
{ {
int number = ((BIntegerField*)field)->Value(); int number = ((BIntegerField*)field)->Value();
if (number > 100) if (number > 100)
number = 100; number = 100;
@@ -549,27 +562,27 @@ GraphColumn::DrawField(BField* field, BRect rect, BView* parent)
parent->StrokeRect(graphRect); parent->StrokeRect(graphRect);
if (number > 0) { if (number > 0) {
graphRect.InsetBy(1, 1); graphRect.InsetBy(1, 1);
float val = graphRect.Width() * (float) number / 100; float value = graphRect.Width() * (float)number / 100;
graphRect.right = graphRect.left + val; graphRect.right = graphRect.left + value;
parent->SetHighColor(0, 0, 190); parent->SetHighColor(0, 0, 190);
parent->FillRect(graphRect); parent->FillRect(graphRect);
} }
parent->SetDrawingMode(B_OP_INVERT); parent->SetDrawingMode(B_OP_INVERT);
parent->SetHighColor(128, 128, 128); parent->SetHighColor(128, 128, 128);
char numstr[256]; char numberString[256];
sprintf(numstr, "%d%%", number); sprintf(numberString, "%d%%", number);
float width = be_plain_font->StringWidth(numstr); float width = be_plain_font->StringWidth(numberString);
parent->MovePenTo(rect.left + rect.Width() / 2 - width / 2, rect.bottom - FontHeight()); parent->MovePenTo(rect.left + rect.Width() / 2 - width / 2, rect.bottom - FontHeight());
parent->DrawString(numstr); parent->DrawString(numberString);
} }
// #pragma mark - // #pragma mark - BBitmapField
BBitmapField::BBitmapField(BBitmap *bitmap) BBitmapField::BBitmapField(BBitmap* bitmap)
: :
fBitmap(bitmap) fBitmap(bitmap)
{ {
@@ -590,12 +603,13 @@ BBitmapField::SetBitmap(BBitmap* bitmap)
} }
// #pragma mark - // #pragma mark - BBitmapColumn
BBitmapColumn::BBitmapColumn(const char* title, float width, float minWidth, BBitmapColumn::BBitmapColumn(const char* title, float width, float minWidth,
float maxWidth, alignment align) float maxWidth, alignment align)
: BTitledColumn(title, width, minWidth, maxWidth, align) :
BTitledColumn(title, width, minWidth, maxWidth, align)
{ {
} }
@@ -603,8 +617,8 @@ BBitmapColumn::BBitmapColumn(const char* title, float width, float minWidth,
void void
BBitmapColumn::DrawField(BField* field, BRect rect, BView* parent) BBitmapColumn::DrawField(BField* field, BRect rect, BView* parent)
{ {
BBitmapField *bitmapField = static_cast<BBitmapField *>(field); BBitmapField* bitmapField = static_cast<BBitmapField*>(field);
const BBitmap *bitmap = bitmapField->Bitmap(); const BBitmap* bitmap = bitmapField->Bitmap();
if (bitmap != NULL) { if (bitmap != NULL) {
float x = 0.0; float x = 0.0;
@@ -656,5 +670,3 @@ BBitmapColumn::AcceptsField(const BField *field) const
{ {
return static_cast<bool>(dynamic_cast<const BBitmapField*>(field)); return static_cast<bool>(dynamic_cast<const BBitmapField*>(field));
} }
+2 -1
View File
@@ -668,8 +668,10 @@ BControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
// calculate scroll corner rect before messing with the "rect" // calculate scroll corner rect before messing with the "rect"
BRect scrollCornerFillRect(rect.right, rect.bottom, BRect scrollCornerFillRect(rect.right, rect.bottom,
rect.right, rect.bottom); rect.right, rect.bottom);
if (horizontalScrollBarFrame.IsValid()) if (horizontalScrollBarFrame.IsValid())
scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1; scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1;
if (verticalScrollBarFrame.IsValid()) if (verticalScrollBarFrame.IsValid())
scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1; scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1;
@@ -718,7 +720,6 @@ BControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor,
borders); borders);
verticalScrollBarFrame.InsetBy(-1, -1); verticalScrollBarFrame.InsetBy(-1, -1);
// do not overdraw the left edge // do not overdraw the left edge
verticalScrollBarFrame.left += 2; verticalScrollBarFrame.left += 2;
+46 -38
View File
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010-2011, Haiku Inc. * Copyright 2010-2011 Haiku, Inc. All rights reserved.
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License. *
* Distributed under the terms of the MIT License.
*/ */
@@ -474,25 +475,25 @@ status_t
BGridLayout::Archive(BMessage* into, bool deep) const BGridLayout::Archive(BMessage* into, bool deep) const
{ {
BArchiver archiver(into); BArchiver archiver(into);
status_t err = BTwoDimensionalLayout::Archive(into, deep); status_t result = BTwoDimensionalLayout::Archive(into, deep);
for (int32 i = 0; i < fRowCount && err == B_OK; i++) { for (int32 i = 0; i < fRowCount && result == B_OK; i++) {
err = into->AddFloat(kRowWeightField, fRowInfos->Weight(i)); result = into->AddFloat(kRowWeightField, fRowInfos->Weight(i));
if (err == B_OK) if (result == B_OK)
err = into->AddFloat(kRowSizesField, fRowInfos->MinSize(i)); result = into->AddFloat(kRowSizesField, fRowInfos->MinSize(i));
if (err == B_OK) if (result == B_OK)
err = into->AddFloat(kRowSizesField, fRowInfos->MaxSize(i)); result = into->AddFloat(kRowSizesField, fRowInfos->MaxSize(i));
} }
for (int32 i = 0; i < fColumnCount && err == B_OK; i++) { for (int32 i = 0; i < fColumnCount && result == B_OK; i++) {
err = into->AddFloat(kColumnWeightField, fColumnInfos->Weight(i)); result = into->AddFloat(kColumnWeightField, fColumnInfos->Weight(i));
if (err == B_OK) if (result == B_OK)
err = into->AddFloat(kColumnSizesField, fColumnInfos->MinSize(i)); result = into->AddFloat(kColumnSizesField, fColumnInfos->MinSize(i));
if (err == B_OK) if (result == B_OK)
err = into->AddFloat(kColumnSizesField, fColumnInfos->MaxSize(i)); result = into->AddFloat(kColumnSizesField, fColumnInfos->MaxSize(i));
} }
return archiver.Finish(err); return archiver.Finish(result);
} }
@@ -524,15 +525,17 @@ BGridLayout::ItemArchived(BMessage* into, BLayoutItem* item, int32 index) const
{ {
ItemLayoutData* data = _LayoutDataForItem(item); ItemLayoutData* data = _LayoutDataForItem(item);
status_t err = into->AddInt32(kItemDimensionsField, data->dimensions.x); status_t result = into->AddInt32(kItemDimensionsField, data->dimensions.x);
if (err == B_OK) if (result == B_OK)
err = into->AddInt32(kItemDimensionsField, data->dimensions.y); result = into->AddInt32(kItemDimensionsField, data->dimensions.y);
if (err == B_OK)
err = into->AddInt32(kItemDimensionsField, data->dimensions.width);
if (err == B_OK)
err = into->AddInt32(kItemDimensionsField, data->dimensions.height);
return err; if (result == B_OK)
result = into->AddInt32(kItemDimensionsField, data->dimensions.width);
if (result == B_OK)
result = into->AddInt32(kItemDimensionsField, data->dimensions.height);
return result;
} }
@@ -545,20 +548,20 @@ BGridLayout::ItemUnarchived(const BMessage* from,
index *= 4; index *= 4;
// each item stores 4 int32s into kItemDimensionsField // each item stores 4 int32s into kItemDimensionsField
status_t err = from->FindInt32(kItemDimensionsField, index, &dimensions.x); status_t result = from->FindInt32(kItemDimensionsField, index, &dimensions.x);
if (err == B_OK) if (result == B_OK)
err = from->FindInt32(kItemDimensionsField, ++index, &dimensions.y); result = from->FindInt32(kItemDimensionsField, ++index, &dimensions.y);
if (err == B_OK) if (result == B_OK)
err = from->FindInt32(kItemDimensionsField, ++index, &dimensions.width); result = from->FindInt32(kItemDimensionsField, ++index, &dimensions.width);
if (err == B_OK) { if (result == B_OK) {
err = from->FindInt32(kItemDimensionsField, result = from->FindInt32(kItemDimensionsField,
++index, &dimensions.height); ++index, &dimensions.height);
} }
if (err != B_OK) if (result != B_OK)
return err; return result;
if (!_AreGridCellsEmpty(dimensions.x, dimensions.y, if (!_AreGridCellsEmpty(dimensions.x, dimensions.y,
dimensions.width, dimensions.height)) dimensions.width, dimensions.height))
@@ -569,10 +572,11 @@ BGridLayout::ItemUnarchived(const BMessage* from,
if (dimensions.width > 1) if (dimensions.width > 1)
fMultiColumnItems++; fMultiColumnItems++;
if (dimensions.height > 1) if (dimensions.height > 1)
fMultiRowItems++; fMultiRowItems++;
return err; return result;
} }
@@ -594,6 +598,7 @@ BGridLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
if (itemDimensions.width > 1) if (itemDimensions.width > 1)
fMultiColumnItems--; fMultiColumnItems--;
if (itemDimensions.height > 1) if (itemDimensions.height > 1)
fMultiRowItems--; fMultiRowItems--;
@@ -639,14 +644,14 @@ BGridLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
bool bool
BGridLayout::HasMultiColumnItems() BGridLayout::HasMultiColumnItems()
{ {
return (fMultiColumnItems > 0); return fMultiColumnItems > 0;
} }
bool bool
BGridLayout::HasMultiRowItems() BGridLayout::HasMultiRowItems()
{ {
return (fMultiRowItems > 0); return fMultiRowItems > 0;
} }
@@ -693,6 +698,7 @@ BGridLayout::_IsGridCellEmpty(int32 column, int32 row)
{ {
if (column < 0 || row < 0) if (column < 0 || row < 0)
return false; return false;
if (column >= fColumnCount || row >= fRowCount) if (column >= fColumnCount || row >= fRowCount)
return true; return true;
@@ -746,6 +752,7 @@ BGridLayout::_InsertItemIntoGrid(BLayoutItem* item)
fGrid[column + x][row + y] = OCCUPIED_GRID_CELL; fGrid[column + x][row + y] = OCCUPIED_GRID_CELL;
} }
} }
return true; return true;
} }
@@ -760,8 +767,9 @@ BGridLayout::_ResizeGrid(int32 columnCount, int32 rowCount)
// allocate new grid // allocate new grid
BLayoutItem*** grid = new(nothrow) BLayoutItem**[columnCount]; BLayoutItem*** grid = new(nothrow) BLayoutItem**[columnCount];
if (!grid) if (grid == NULL)
return false; return false;
memset(grid, 0, sizeof(BLayoutItem**) * columnCount); memset(grid, 0, sizeof(BLayoutItem**) * columnCount);
bool success = true; bool success = true;
@@ -788,6 +796,7 @@ BGridLayout::_ResizeGrid(int32 columnCount, int32 rowCount)
// delete the old, respectively on error the partially created grid // delete the old, respectively on error the partially created grid
for (int32 i = 0; i < columnCount; i++) for (int32 i = 0; i < columnCount; i++)
delete[] grid[i]; delete[] grid[i];
delete[] grid; delete[] grid;
return success; return success;
@@ -820,4 +829,3 @@ void BGridLayout::_ReservedGridLayout7() {}
void BGridLayout::_ReservedGridLayout8() {} void BGridLayout::_ReservedGridLayout8() {}
void BGridLayout::_ReservedGridLayout9() {} void BGridLayout::_ReservedGridLayout9() {}
void BGridLayout::_ReservedGridLayout10() {} void BGridLayout::_ReservedGridLayout10() {}
+3 -3
View File
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010, Haiku, Inc. * Copyright 2010 Haiku, Inc. All rights reserved.
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License. *
* Distributed under the terms of the MIT License.
*/ */
@@ -81,4 +82,3 @@ void BGridView::_ReservedGridView7() {}
void BGridView::_ReservedGridView8() {} void BGridView::_ReservedGridView8() {}
void BGridView::_ReservedGridView9() {} void BGridView::_ReservedGridView9() {}
void BGridView::_ReservedGridView10() {} void BGridView::_ReservedGridView10() {}
+11 -13
View File
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010, Haiku, Inc. * Copyright 2010 Haiku, Inc. All rights reserved.
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License. *
* Distributed under the terms of the MIT License.
*/ */
@@ -189,12 +190,12 @@ status_t
BGroupLayout::Archive(BMessage* into, bool deep) const BGroupLayout::Archive(BMessage* into, bool deep) const
{ {
BArchiver archiver(into); BArchiver archiver(into);
status_t err = BTwoDimensionalLayout::Archive(into, deep); status_t result = BTwoDimensionalLayout::Archive(into, deep);
if (err == B_OK) if (result == B_OK)
err = into->AddBool(kVerticalField, fOrientation == B_VERTICAL); result = into->AddBool(kVerticalField, fOrientation == B_VERTICAL);
return archiver.Finish(err); return archiver.Finish(result);
} }
@@ -234,12 +235,12 @@ BGroupLayout::ItemUnarchived(const BMessage* from,
BLayoutItem* item, int32 index) BLayoutItem* item, int32 index)
{ {
float weight; float weight;
status_t err = from->FindFloat(kItemWeightField, index, &weight); status_t result = from->FindFloat(kItemWeightField, index, &weight);
if (err == B_OK) if (result == B_OK)
_LayoutDataForItem(item)->weight = weight; _LayoutDataForItem(item)->weight = weight;
return err; return result;
} }
@@ -329,9 +330,7 @@ BGroupLayout::GetItemDimensions(BLayoutItem* item, Dimensions* dimensions)
BGroupLayout::ItemLayoutData* BGroupLayout::ItemLayoutData*
BGroupLayout::_LayoutDataForItem(BLayoutItem* item) const BGroupLayout::_LayoutDataForItem(BLayoutItem* item) const
{ {
if (!item) return item == NULL ? NULL : (ItemLayoutData*)item->LayoutData();
return NULL;
return (ItemLayoutData*)item->LayoutData();
} }
@@ -352,4 +351,3 @@ void BGroupLayout::_ReservedGroupLayout7() {}
void BGroupLayout::_ReservedGroupLayout8() {} void BGroupLayout::_ReservedGroupLayout8() {}
void BGroupLayout::_ReservedGroupLayout9() {} void BGroupLayout::_ReservedGroupLayout9() {}
void BGroupLayout::_ReservedGroupLayout10() {} void BGroupLayout::_ReservedGroupLayout10() {}
+5 -4
View File
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010, Haiku, Inc. * Copyright 2010 Haiku, Inc. All rights reserved.
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License. *
* Distributed under the terms of the MIT License.
*/ */
@@ -17,7 +18,7 @@ BGroupView::BGroupView(orientation orientation, float spacing)
BGroupView::BGroupView(const char* name, orientation orientation, BGroupView::BGroupView(const char* name, orientation orientation,
float spacing) float spacing)
: :
BView(name, 0, new BGroupLayout(orientation, spacing)) BView(name, 0, new BGroupLayout(orientation, spacing))
{ {
@@ -53,6 +54,7 @@ BGroupView::Instantiate(BMessage* from)
{ {
if (validate_instantiation(from, "BGroupView")) if (validate_instantiation(from, "BGroupView"))
return new BGroupView(from); return new BGroupView(from);
return NULL; return NULL;
} }
@@ -81,4 +83,3 @@ void BGroupView::_ReservedGroupView7() {}
void BGroupView::_ReservedGroupView8() {} void BGroupView::_ReservedGroupView8() {}
void BGroupView::_ReservedGroupView9() {} void BGroupView::_ReservedGroupView9() {}
void BGroupView::_ReservedGroupView10() {} void BGroupView::_ReservedGroupView10() {}
+3 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2010, Haiku, Inc. All Rights Reserved. * Copyright 2001-2010 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -32,7 +32,8 @@ BListItem::BListItem(uint32 level, bool expanded)
BListItem::BListItem(BMessage* data) BListItem::BListItem(BMessage* data)
: BArchivable(data), :
BArchivable(data),
fTop(0.0), fTop(0.0),
fWidth(0), fWidth(0),
fHeight(0), fHeight(0),
@@ -219,4 +220,3 @@ BListItem::SetItemVisible(bool visible)
{ {
fVisible = visible; fVisible = visible;
} }
+8 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2013 Haiku, Inc. * Copyright 2001-2013 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -10,8 +10,10 @@
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
*/ */
//! BOutlineListView represents a "nestable" list view. //! BOutlineListView represents a "nestable" list view.
#include <OutlineListView.h> #include <OutlineListView.h>
#include <algorithm> #include <algorithm>
@@ -27,6 +29,7 @@
typedef int (*compare_func)(const BListItem* a, const BListItem* b); typedef int (*compare_func)(const BListItem* a, const BListItem* b);
struct ListItemComparator { struct ListItemComparator {
ListItemComparator(compare_func compareFunc) ListItemComparator(compare_func compareFunc)
: :
@@ -73,7 +76,7 @@ _DoSwap(BList& list, int32 firstIndex, int32 secondIndex, BList* firstItems,
} }
// #pragma mark - // #pragma mark - BOutlineListView
BOutlineListView::BOutlineListView(BRect frame, const char* name, BOutlineListView::BOutlineListView(BRect frame, const char* name,
@@ -1059,6 +1062,7 @@ BOutlineListView::_SwapItems(int32 first, int32 second)
if (Superitem(firstItem) != Superitem(secondItem)) if (Superitem(firstItem) != Superitem(secondItem))
return false; return false;
if (!firstItem->IsItemVisible() || !secondItem->IsItemVisible()) if (!firstItem->IsItemVisible() || !secondItem->IsItemVisible())
return false; return false;
@@ -1077,6 +1081,7 @@ BOutlineListView::_SwapItems(int32 first, int32 second)
_RecalcItemTops(firstIndex); _RecalcItemTops(firstIndex);
_RescanSelection(firstIndex, secondIndex + secondSubItems.CountItems()); _RescanSelection(firstIndex, secondIndex + secondSubItems.CountItems());
Invalidate(Bounds()); Invalidate(Bounds());
return true; return true;
} }
@@ -1125,6 +1130,7 @@ BOutlineListView::_RemoveItem(BListItem* item, int32 fullListIndex)
if (child == NULL || child->OutlineLevel() <= super->OutlineLevel()) if (child == NULL || child->OutlineLevel() <= super->OutlineLevel())
super->fHasSubitems = false; super->fHasSubitems = false;
} }
return item; return item;
} }
+33 -26
View File
@@ -34,8 +34,7 @@ BSeparatorView::BSeparatorView(orientation orientation, border_style border)
BSeparatorView::BSeparatorView(const char* name, const char* label, BSeparatorView::BSeparatorView(const char* name, const char* label,
orientation orientation, border_style border, orientation orientation, border_style border, const BAlignment& alignment)
const BAlignment& alignment)
: :
BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{ {
@@ -44,8 +43,7 @@ BSeparatorView::BSeparatorView(const char* name, const char* label,
BSeparatorView::BSeparatorView(const char* name, BView* labelView, BSeparatorView::BSeparatorView(const char* name, BView* labelView,
orientation orientation, border_style border, orientation orientation, border_style border, const BAlignment& alignment)
const BAlignment& alignment)
: :
BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{ {
@@ -54,8 +52,7 @@ BSeparatorView::BSeparatorView(const char* name, BView* labelView,
BSeparatorView::BSeparatorView(const char* label, BSeparatorView::BSeparatorView(const char* label,
orientation orientation, border_style border, orientation orientation, border_style border, const BAlignment& alignment)
const BAlignment& alignment)
: :
BView("", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) BView("", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{ {
@@ -64,8 +61,7 @@ BSeparatorView::BSeparatorView(const char* label,
BSeparatorView::BSeparatorView(BView* labelView, BSeparatorView::BSeparatorView(BView* labelView,
orientation orientation, border_style border, orientation orientation, border_style border, const BAlignment& alignment)
const BAlignment& alignment)
: :
BView("", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) BView("", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{ {
@@ -115,7 +111,7 @@ BSeparatorView::~BSeparatorView()
} }
// #pragma mark - archiving // #pragma mark - Archiving
BArchivable* BArchivable*
@@ -132,28 +128,28 @@ status_t
BSeparatorView::Archive(BMessage* into, bool deep) const BSeparatorView::Archive(BMessage* into, bool deep) const
{ {
// TODO: Test this. // TODO: Test this.
status_t ret = BView::Archive(into, deep); status_t result = BView::Archive(into, deep);
if (ret != B_OK) if (result != B_OK)
return ret; return result;
if (fLabelView != NULL) if (fLabelView != NULL)
ret = into->AddString("_labelview", fLabelView->Name()); result = into->AddString("_labelview", fLabelView->Name());
else else
ret = into->AddString("_label", fLabel.String()); result = into->AddString("_label", fLabel.String());
if (ret == B_OK) if (result == B_OK)
ret = into->AddInt32("_orientation", fOrientation); result = into->AddInt32("_orientation", fOrientation);
if (ret == B_OK) if (result == B_OK)
ret = into->AddInt32("_halignment", fAlignment.horizontal); result = into->AddInt32("_halignment", fAlignment.horizontal);
if (ret == B_OK) if (result == B_OK)
ret = into->AddInt32("_valignment", fAlignment.vertical); result = into->AddInt32("_valignment", fAlignment.vertical);
if (ret == B_OK) if (result == B_OK)
ret = into->AddInt32("_border", fBorder); result = into->AddInt32("_border", fBorder);
return ret; return result;
} }
@@ -177,13 +173,15 @@ BSeparatorView::Draw(BRect updateRect)
float labelWidth = StringWidth(fLabel.String()); float labelWidth = StringWidth(fLabel.String());
if (fOrientation == B_HORIZONTAL) { if (fOrientation == B_HORIZONTAL) {
switch (fAlignment.horizontal) { switch (fAlignment.horizontal) {
default:
case B_ALIGN_LEFT: case B_ALIGN_LEFT:
default:
labelBounds.right = labelBounds.left + labelWidth; labelBounds.right = labelBounds.left + labelWidth;
break; break;
case B_ALIGN_RIGHT: case B_ALIGN_RIGHT:
labelBounds.left = labelBounds.right - labelWidth; labelBounds.left = labelBounds.right - labelWidth;
break; break;
case B_ALIGN_CENTER: case B_ALIGN_CENTER:
labelBounds.left = (labelBounds.left + labelBounds.right labelBounds.left = (labelBounds.left + labelBounds.right
- labelWidth) / 2; - labelWidth) / 2;
@@ -192,13 +190,15 @@ BSeparatorView::Draw(BRect updateRect)
} }
} else { } else {
switch (fAlignment.vertical) { switch (fAlignment.vertical) {
default:
case B_ALIGN_TOP: case B_ALIGN_TOP:
default:
labelBounds.bottom = labelBounds.top + labelWidth; labelBounds.bottom = labelBounds.top + labelWidth;
break; break;
case B_ALIGN_BOTTOM: case B_ALIGN_BOTTOM:
labelBounds.top = labelBounds.bottom - labelWidth; labelBounds.top = labelBounds.bottom - labelWidth;
break; break;
case B_ALIGN_MIDDLE: case B_ALIGN_MIDDLE:
labelBounds.top = (labelBounds.top + labelBounds.bottom labelBounds.top = (labelBounds.top + labelBounds.bottom
- labelWidth) / 2; - labelWidth) / 2;
@@ -234,6 +234,7 @@ BSeparatorView::Draw(BRect updateRect)
} }
if (labelBounds.IsValid()) if (labelBounds.IsValid())
region.Include(labelBounds); region.Include(labelBounds);
ConstrainClippingRegion(&region); ConstrainClippingRegion(&region);
} }
@@ -291,6 +292,7 @@ BSeparatorView::GetPreferredSize(float* _width, float* _height)
if (_width != NULL) if (_width != NULL)
*_width = width; *_width = width;
if (_height != NULL) if (_height != NULL)
*_height = height; *_height = height;
} }
@@ -313,6 +315,7 @@ BSeparatorView::MaxSize()
size.width = B_SIZE_UNLIMITED; size.width = B_SIZE_UNLIMITED;
else else
size.height = B_SIZE_UNLIMITED; size.height = B_SIZE_UNLIMITED;
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size); return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size);
} }
@@ -322,6 +325,7 @@ BSeparatorView::PreferredSize()
{ {
BSize size; BSize size;
GetPreferredSize(&size.width, &size.height); GetPreferredSize(&size.width, &size.height);
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size); return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size);
} }
@@ -341,6 +345,7 @@ BSeparatorView::SetOrientation(orientation orientation)
GetFont(&font); GetFont(&font);
if (fOrientation == B_VERTICAL) if (fOrientation == B_VERTICAL)
font.SetRotation(90.0f); font.SetRotation(90.0f);
SetFont(&font); SetFont(&font);
Invalidate(); Invalidate();
@@ -378,6 +383,7 @@ BSeparatorView::SetLabel(const char* label)
{ {
if (label == NULL) if (label == NULL)
label = ""; label = "";
if (fLabel == label) if (fLabel == label)
return; return;
@@ -461,6 +467,7 @@ BSeparatorView::_BorderSize() const
switch (fBorder) { switch (fBorder) {
case B_PLAIN_BORDER: case B_PLAIN_BORDER:
return 1.0f; return 1.0f;
case B_FANCY_BORDER: case B_FANCY_BORDER:
return 2.0f; return 2.0f;
@@ -479,6 +486,7 @@ BSeparatorView::_MaxLabelBounds() const
bounds.InsetBy(kMinBorderLength, 0.0f); bounds.InsetBy(kMinBorderLength, 0.0f);
else else
bounds.InsetBy(0.0f, kMinBorderLength); bounds.InsetBy(0.0f, kMinBorderLength);
return bounds; return bounds;
} }
@@ -496,4 +504,3 @@ void BSeparatorView::_ReservedSeparatorView7() {}
void BSeparatorView::_ReservedSeparatorView8() {} void BSeparatorView::_ReservedSeparatorView8() {}
void BSeparatorView::_ReservedSeparatorView9() {} void BSeparatorView::_ReservedSeparatorView9() {}
void BSeparatorView::_ReservedSeparatorView10() {} void BSeparatorView::_ReservedSeparatorView10() {}