Automatic whitespace cleanup.
This commit is contained in:
@@ -78,7 +78,7 @@ App::MessageReceived(BMessage* message)
|
||||
Quit();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
|
||||
@@ -104,7 +104,7 @@ BitmapButton::DrawBackground(BRect& bounds, BRect updateRect)
|
||||
uint32 flags = 0;
|
||||
if (fMouseDown)
|
||||
flags |= BControlLook::B_ACTIVATED;
|
||||
|
||||
|
||||
be_control_look->DrawButtonFrame(this, bounds, updateRect,
|
||||
color, color, flags);
|
||||
be_control_look->DrawButtonBackground(this, bounds, updateRect,
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
const BMessage* dragMessage);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void MouseUp(BPoint where);
|
||||
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BSize MaxSize();
|
||||
|
||||
@@ -46,26 +46,26 @@ BitmapView::Draw(BRect updateRect)
|
||||
{
|
||||
BRect bounds(Bounds());
|
||||
DrawBackground(bounds, updateRect);
|
||||
|
||||
|
||||
if (fBitmap == NULL)
|
||||
return;
|
||||
|
||||
BRect bitmapBounds = fBitmap->Bounds();
|
||||
if (bitmapBounds.Width() <= 0.0f || bitmapBounds.Height() <= 0.0f)
|
||||
return;
|
||||
|
||||
|
||||
float scale = 1.0f;
|
||||
|
||||
if (fScaleBitmap) {
|
||||
float hScale = bounds.Width() / bitmapBounds.Width();
|
||||
float vScale = bounds.Height() / bitmapBounds.Height();
|
||||
|
||||
|
||||
scale = std::min(hScale, vScale);
|
||||
}
|
||||
|
||||
|
||||
float width = bitmapBounds.Width() * scale;
|
||||
float height = bitmapBounds.Height() * scale;
|
||||
|
||||
|
||||
switch (LayoutAlignment().horizontal) {
|
||||
case B_ALIGN_LEFT:
|
||||
break;
|
||||
@@ -90,7 +90,7 @@ BitmapView::Draw(BRect updateRect)
|
||||
+ (bounds.Height() - height) / 2.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bounds.right = ceilf(bounds.left + width);
|
||||
bounds.bottom = ceilf(bounds.top + height);
|
||||
|
||||
@@ -103,13 +103,13 @@ BSize
|
||||
BitmapView::MinSize()
|
||||
{
|
||||
BSize size(0.0f, 0.0f);
|
||||
|
||||
|
||||
if (fBitmap != NULL) {
|
||||
BRect bounds = fBitmap->Bounds();
|
||||
size.width = bounds.Width();
|
||||
size.height = bounds.Height();
|
||||
}
|
||||
|
||||
|
||||
return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
|
||||
}
|
||||
|
||||
@@ -139,11 +139,11 @@ BitmapView::SetBitmap(const BBitmap* bitmap)
|
||||
BSize size = MinSize();
|
||||
|
||||
fBitmap = bitmap;
|
||||
|
||||
|
||||
BSize newSize = MinSize();
|
||||
if (size != newSize)
|
||||
InvalidateLayout();
|
||||
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
class BitmapView : public BView {
|
||||
public:
|
||||
BitmapView(const char* name);
|
||||
|
||||
|
||||
virtual ~BitmapView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BSize MaxSize();
|
||||
|
||||
|
||||
void SetBitmap(const BBitmap* bitmap);
|
||||
void SetScaleBitmap(bool scaleBitmap);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ FilterView::FilterView(const Model& model)
|
||||
B_TRANSLATE("Search terms:"), "", NULL);
|
||||
fSearchTermsText->SetModificationMessage(
|
||||
new BMessage(MSG_SEARCH_TERMS_MODIFIED));
|
||||
|
||||
|
||||
BSize minSearchSize = fSearchTermsText->MinSize();
|
||||
float minSearchWidth
|
||||
= be_plain_font->StringWidth(fSearchTermsText->Label())
|
||||
@@ -91,14 +91,14 @@ FilterView::FilterView(const Model& model)
|
||||
fSearchTermsText->SetExplicitMinSize(minSearchSize);
|
||||
float maxSearchWidth = minSearchWidth * 2;
|
||||
fSearchTermsText->SetExplicitMaxSize(BSize(maxSearchWidth, B_SIZE_UNSET));
|
||||
|
||||
|
||||
// Build layout
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.Add(fShowField, 0.0f)
|
||||
.Add(fRepositoryField, 0.0f)
|
||||
.AddGlue(0.5f)
|
||||
.Add(fSearchTermsText, 1.0f)
|
||||
|
||||
|
||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||
;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ FilterView::MessageReceived(BMessage* message)
|
||||
Window()->PostMessage(&searchTerms);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
BGroupView::MessageReceived(message);
|
||||
break;
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
if (fCount > 0)
|
||||
_Resize(fCount - 1);
|
||||
}
|
||||
|
||||
|
||||
inline void Remove(int32 index)
|
||||
{
|
||||
if (index < 0 || index >= (int32)fCount)
|
||||
@@ -163,21 +163,21 @@ public:
|
||||
memcpy(fItems + index, fItems + nextIndex,
|
||||
(fCount - nextIndex) * sizeof(ItemType));
|
||||
}
|
||||
|
||||
|
||||
fCount--;
|
||||
}
|
||||
|
||||
inline void Remove(const ItemType& item)
|
||||
{
|
||||
Remove(IndexOf(item));
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline bool Replace(int32 index, const ItemType& copyFrom)
|
||||
{
|
||||
if (index < 0 || index >= (int32)fCount)
|
||||
return false;
|
||||
|
||||
|
||||
ItemType* item = fItems + index;
|
||||
// Initialize the new object from the original.
|
||||
if (!PlainOldData) {
|
||||
|
||||
@@ -38,13 +38,13 @@ MainWindow::MainWindow(BRect frame)
|
||||
|
||||
BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
|
||||
_BuildMenu(menuBar);
|
||||
|
||||
|
||||
fFilterView = new FilterView(fModel);
|
||||
fPackageListView = new PackageListView(fModel.Lock());
|
||||
fPackageInfoView = new PackageInfoView(fModel.Lock(), &fPackageManager);
|
||||
|
||||
|
||||
fSplitView = new BSplitView(B_VERTICAL, 5.0f);
|
||||
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
|
||||
.Add(menuBar)
|
||||
.Add(fFilterView)
|
||||
@@ -77,7 +77,7 @@ MainWindow::QuitRequested()
|
||||
BMessage message(MSG_MAIN_WINDOW_CLOSED);
|
||||
message.AddRect("window frame", Frame());
|
||||
be_app->PostMessage(&message);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MSG_CATEGORY_SELECTED:
|
||||
{
|
||||
BString name;
|
||||
@@ -119,7 +119,7 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
_AdoptModel();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MSG_DEPOT_SELECTED:
|
||||
{
|
||||
BString name;
|
||||
@@ -129,7 +129,7 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
_AdoptModel();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case MSG_SEARCH_TERMS_MODIFIED:
|
||||
{
|
||||
// TODO: Do this with a delay!
|
||||
@@ -139,7 +139,7 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
fModel.SetSearchTerms(searchTerms);
|
||||
_AdoptModel();
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
@@ -160,7 +160,7 @@ void
|
||||
MainWindow::_AdoptModel()
|
||||
{
|
||||
fVisiblePackages = fModel.CreatePackageList();
|
||||
|
||||
|
||||
fPackageListView->Clear();
|
||||
for (int32 i = 0; i < fVisiblePackages.CountItems(); i++) {
|
||||
BAutolock _(fModel.Lock());
|
||||
@@ -193,7 +193,7 @@ MainWindow::_InitDummyModel()
|
||||
// for display, extra information is retrieved like screen-shots, user-
|
||||
// ratings and so on. This triggers notifications which in turn updates
|
||||
// the UI.
|
||||
|
||||
|
||||
DepotInfo depot(B_TRANSLATE("Default"));
|
||||
|
||||
// WonderBrush
|
||||
@@ -213,7 +213,7 @@ MainWindow::_InitDummyModel()
|
||||
"2.1.2 - Initial Haiku release."), true);
|
||||
wonderbrush->AddCategory(fModel.CategoryGraphics());
|
||||
wonderbrush->AddCategory(fModel.CategoryProductivity());
|
||||
|
||||
|
||||
depot.AddPackage(wonderbrush);
|
||||
|
||||
// Paladin
|
||||
@@ -252,7 +252,7 @@ MainWindow::_InitDummyModel()
|
||||
"and play back music from your computer. Sequitur is designed for "
|
||||
"people who like to tinker with their music. It facilitates rapid, "
|
||||
"dynamic, and radical processing of your performance.",
|
||||
|
||||
|
||||
"== Sequitur 2.1 Release Notes ==\n"
|
||||
"04 August 2002\n\n"
|
||||
"Features\n\n"
|
||||
@@ -303,7 +303,7 @@ MainWindow::_InitDummyModel()
|
||||
" * ''Note to filter developers:'' The filter API has changed. You "
|
||||
"will need to recompile your filters."), true);
|
||||
sequitur->AddCategory(fModel.CategoryAudio());
|
||||
|
||||
|
||||
depot.AddPackage(sequitur);
|
||||
|
||||
// Finish off
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
private:
|
||||
void _BuildMenu(BMenuBar* menuBar);
|
||||
void _AdoptModel();
|
||||
|
||||
|
||||
void _AdoptPackage(const PackageInfoRef& package);
|
||||
void _ClearPackage();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
fDepot(depot)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool AcceptsPackage(const PackageInfoRef& package) const
|
||||
{
|
||||
// TODO: Maybe a PackageInfo ought to know the Depot it came from?
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
DepotInfo fDepot;
|
||||
};
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
fCategory(category)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool AcceptsPackage(const PackageInfoRef& package) const
|
||||
{
|
||||
if (package.Get() == NULL)
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
fPackageList(packageList)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool AcceptsPackage(const PackageInfoRef& package) const
|
||||
{
|
||||
return fPackageList.Contains(package);
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
fPackageListB(packageListB)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool AcceptsPackage(const PackageInfoRef& package) const
|
||||
{
|
||||
return fPackageListA.Contains(package)
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
index = nextSpace + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual bool AcceptsPackage(const PackageInfoRef& package) const
|
||||
{
|
||||
if (package.Get() == NULL)
|
||||
@@ -234,7 +234,7 @@ Model::Model()
|
||||
B_TRANSLATE("Uninstalled packages"), "uninstalled"), true));
|
||||
|
||||
// A category for all packages that the user has installed or uninstalled.
|
||||
// Those packages resemble what makes their system different from a
|
||||
// Those packages resemble what makes their system different from a
|
||||
// fresh Haiku installation.
|
||||
fUserCategories.Add(CategoryRef(new PackageCategory(
|
||||
BitmapRef(),
|
||||
@@ -261,10 +261,10 @@ Model::CreatePackageList() const
|
||||
|
||||
for (int32 i = 0; i < fDepots.CountItems(); i++) {
|
||||
const DepotInfo& depot = fDepots.ItemAtFast(i);
|
||||
|
||||
|
||||
if (fDepotFilter.Length() > 0 && fDepotFilter != depot.Name())
|
||||
continue;
|
||||
|
||||
|
||||
const PackageList& packages = depot.Packages();
|
||||
|
||||
for (int32 j = 0; j < packages.CountItems(); j++) {
|
||||
@@ -326,7 +326,7 @@ void
|
||||
Model::SetCategory(const BString& category)
|
||||
{
|
||||
PackageFilter* filter;
|
||||
|
||||
|
||||
if (category.Length() == 0)
|
||||
filter = new AnyFilter();
|
||||
else if (category == "installed")
|
||||
@@ -358,7 +358,7 @@ void
|
||||
Model::SetSearchTerms(const BString& searchTerms)
|
||||
{
|
||||
PackageFilter* filter;
|
||||
|
||||
|
||||
if (searchTerms.Length() == 0)
|
||||
filter = new AnyFilter();
|
||||
else
|
||||
@@ -381,17 +381,17 @@ Model::PopulatePackage(const PackageInfoRef& package)
|
||||
|
||||
// TODO: Replace with actual backend that retrieves package extra
|
||||
// information and user-contributed package information.
|
||||
|
||||
|
||||
// TODO: There should probably also be a way to "unpopulate" the
|
||||
// package information. Maybe a cache of populated packages, so that
|
||||
// packages loose their extra information after a certain amount of
|
||||
// time when they have not been accessed/displayed in the UI. Otherwise
|
||||
// HaikuDepot will consume more and more resources in the packages.
|
||||
// Especially screen-shots will be a problem eventually.
|
||||
|
||||
|
||||
// TODO: Simulate a delay in retrieving this info, and do that on
|
||||
// a separate thread.
|
||||
|
||||
|
||||
fPopulatedPackages.Add(package);
|
||||
|
||||
if (package->Title() == "WonderBrush") {
|
||||
|
||||
@@ -69,7 +69,7 @@ SharedBitmap::Bitmap(Size which)
|
||||
{
|
||||
if (fResourceID == -1 && fMimeType.Length() == 0)
|
||||
return fBitmap[0];
|
||||
|
||||
|
||||
int32 index = 0;
|
||||
int32 size = 16;
|
||||
|
||||
@@ -87,14 +87,14 @@ SharedBitmap::Bitmap(Size which)
|
||||
size = 64;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (fBitmap[index] == NULL) {
|
||||
if (fResourceID >= 0)
|
||||
fBitmap[index] = _CreateBitmapFromResource(size);
|
||||
else if (fMimeType.Length() > 0)
|
||||
fBitmap[index] = _CreateBitmapFromMimeType(size);
|
||||
}
|
||||
|
||||
|
||||
return fBitmap[index];
|
||||
}
|
||||
|
||||
@@ -118,36 +118,36 @@ SharedBitmap::_CreateBitmapFromResource(int32 size) const
|
||||
status = BIconUtils::GetVectorIcon(
|
||||
reinterpret_cast<const uint8*>(data), dataSize, bitmap);
|
||||
};
|
||||
|
||||
|
||||
if (status != B_OK) {
|
||||
delete bitmap;
|
||||
bitmap = NULL;
|
||||
}
|
||||
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
data = resources.LoadResource(B_MESSAGE_TYPE, fResourceID, &dataSize);
|
||||
if (data != NULL) {
|
||||
BMemoryIO stream(data, dataSize);
|
||||
|
||||
|
||||
// Try to read as an archived bitmap.
|
||||
BMessage archive;
|
||||
status = archive.Unflatten(&stream);
|
||||
if (status != B_OK)
|
||||
return NULL;
|
||||
|
||||
|
||||
BBitmap* bitmap = new BBitmap(&archive);
|
||||
|
||||
|
||||
status = bitmap->InitCheck();
|
||||
if (status != B_OK) {
|
||||
delete bitmap;
|
||||
bitmap = NULL;
|
||||
}
|
||||
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ SharedBitmap::_CreateBitmapFromMimeType(int32 size) const
|
||||
delete bitmap;
|
||||
bitmap = NULL;
|
||||
}
|
||||
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@@ -553,10 +553,10 @@ PackageInfo::CalculateRatingSummary() const
|
||||
int starRatingCount = sizeof(summary.ratingCountByStar) / sizeof(int);
|
||||
for (int i = 0; i < starRatingCount; i++)
|
||||
summary.ratingCountByStar[i] = 0;
|
||||
|
||||
|
||||
if (summary.ratingCount <= 0)
|
||||
return summary;
|
||||
|
||||
|
||||
float ratingSum = 0.0f;
|
||||
|
||||
for (int i = 0; i < summary.ratingCount; i++) {
|
||||
@@ -566,7 +566,7 @@ PackageInfo::CalculateRatingSummary() const
|
||||
rating = 0.0f;
|
||||
else if (rating > 5.0f)
|
||||
rating = 5.0f;
|
||||
|
||||
|
||||
ratingSum += rating;
|
||||
|
||||
if (rating <= 1.0f)
|
||||
|
||||
@@ -54,20 +54,20 @@ public:
|
||||
{
|
||||
BRect innerFrame = Bounds();
|
||||
innerFrame.right -= B_V_SCROLL_BAR_WIDTH + 1;
|
||||
|
||||
|
||||
BView* target = Target();
|
||||
if (target != NULL) {
|
||||
Target()->MoveTo(innerFrame.left, innerFrame.top);
|
||||
Target()->ResizeTo(innerFrame.Width(), innerFrame.Height());
|
||||
}
|
||||
|
||||
|
||||
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
|
||||
if (scrollBar != NULL) {
|
||||
BRect rect = innerFrame;
|
||||
rect.left = rect.right + 1;
|
||||
rect.right = rect.left + B_V_SCROLL_BAR_WIDTH;
|
||||
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||
|
||||
|
||||
scrollBar->MoveTo(rect.left, rect.top);
|
||||
scrollBar->ResizeTo(rect.Width(), rect.Height());
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
virtual void DoLayout()
|
||||
{
|
||||
CustomScrollView::DoLayout();
|
||||
|
||||
|
||||
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
|
||||
BView* target = Target();
|
||||
if (target != NULL && scrollBar != NULL) {
|
||||
@@ -108,14 +108,14 @@ public:
|
||||
TextDocumentView(name)
|
||||
{
|
||||
CharacterStyle regularStyle;
|
||||
|
||||
|
||||
float fontSize = regularStyle.Font().Size();
|
||||
|
||||
|
||||
ParagraphStyle paragraphStyle;
|
||||
paragraphStyle.SetJustify(true);
|
||||
paragraphStyle.SetSpacingTop(ceilf(fontSize * 0.3f));
|
||||
paragraphStyle.SetLineSpacing(ceilf(fontSize * 0.2f));
|
||||
|
||||
|
||||
fMarkupParser.SetStyles(regularStyle, paragraphStyle);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
document->Append(paragraph);
|
||||
|
||||
fMarkupParser.AppendMarkup(document, markupText);
|
||||
|
||||
|
||||
SetTextDocument(document);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
fHoverColor((rgb_color){ 1, 141, 211, 255 })
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||
const BMessage* dragMessage)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
|
||||
virtual ~RatingView()
|
||||
{
|
||||
}
|
||||
@@ -208,18 +208,18 @@ public:
|
||||
virtual void Draw(BRect updateRect)
|
||||
{
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
|
||||
|
||||
if (fRating < 0.0f)
|
||||
return;
|
||||
|
||||
|
||||
const BBitmap* star = fStarBitmap.Bitmap(SharedBitmap::SIZE_16);
|
||||
if (star == NULL) {
|
||||
fprintf(stderr, "No star icon found in application resources.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
|
||||
|
||||
float x = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
DrawBitmap(star, BPoint(x, 0));
|
||||
@@ -230,14 +230,14 @@ public:
|
||||
return;
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
|
||||
|
||||
BRect rect(Bounds());
|
||||
rect.left = ceilf(rect.left + (fRating / 5.0f) * rect.Width());
|
||||
|
||||
|
||||
rgb_color color = LowColor();
|
||||
color.alpha = 190;
|
||||
SetHighColor(color);
|
||||
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
FillRect(rect, B_SOLID_HIGH);
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
}
|
||||
|
||||
|
||||
virtual ~DiagramBarView()
|
||||
{
|
||||
}
|
||||
@@ -297,13 +297,13 @@ public:
|
||||
virtual void Draw(BRect updateRect)
|
||||
{
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
|
||||
|
||||
if (fValue <= 0.0f)
|
||||
return;
|
||||
|
||||
|
||||
BRect rect(Bounds());
|
||||
rect.right = ceilf(rect.left + fValue * rect.Width());
|
||||
|
||||
|
||||
FillRect(rect, B_SOLID_HIGH);
|
||||
}
|
||||
|
||||
@@ -411,10 +411,10 @@ public:
|
||||
.Add(fVersionInfo)
|
||||
.AddGlue(3.0f)
|
||||
;
|
||||
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
virtual ~TitleView()
|
||||
{
|
||||
}
|
||||
@@ -427,7 +427,7 @@ public:
|
||||
fIconView->SetBitmap(NULL);
|
||||
|
||||
fTitleView->SetText(package.Title());
|
||||
|
||||
|
||||
BString publisher = B_TRANSLATE("by %Publisher%");
|
||||
publisher.ReplaceAll("%Publisher%", package.Publisher().Name());
|
||||
fPublisherView->SetText(publisher);
|
||||
@@ -493,15 +493,15 @@ public:
|
||||
fLayout(new BGroupLayout(B_HORIZONTAL))
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
|
||||
SetLayout(fLayout);
|
||||
}
|
||||
|
||||
|
||||
virtual ~PackageActionView()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
virtual void MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
@@ -522,7 +522,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
break;
|
||||
@@ -534,18 +534,18 @@ public:
|
||||
Clear();
|
||||
|
||||
fPackageActions = fPackageManager->GetPackageActions(package);
|
||||
|
||||
|
||||
// Add Buttons in reverse action order
|
||||
for (int32 i = fPackageActions.CountItems() - 1; i >= 0; i--) {
|
||||
const PackageActionRef& action = fPackageActions.ItemAtFast(i);
|
||||
|
||||
|
||||
BMessage* message = new BMessage(MSG_PACKAGE_ACTION);
|
||||
message->AddInt32("index", i);
|
||||
|
||||
|
||||
BButton* button = new BButton(action->Label(), message);
|
||||
fLayout->AddView(button);
|
||||
button->SetTarget(this);
|
||||
|
||||
|
||||
fButtons.AddItem(button);
|
||||
}
|
||||
}
|
||||
@@ -562,7 +562,7 @@ public:
|
||||
|
||||
private:
|
||||
PackageManager* fPackageManager;
|
||||
|
||||
|
||||
BGroupLayout* fLayout;
|
||||
PackageActionList fPackageActions;
|
||||
BList fButtons;
|
||||
@@ -588,18 +588,18 @@ public:
|
||||
{
|
||||
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
kContentTint));
|
||||
|
||||
|
||||
fDescriptionView = new MarkupTextView("description view");
|
||||
fDescriptionView->SetLowColor(ViewColor());
|
||||
fDescriptionView->SetInsets(be_plain_font->Size());
|
||||
|
||||
|
||||
BScrollView* scrollView = new CustomScrollView(
|
||||
"description scroll view", fDescriptionView);
|
||||
|
||||
|
||||
BFont smallFont;
|
||||
GetFont(&smallFont);
|
||||
smallFont.SetSize(std::max(9.0f, ceilf(smallFont.Size() * 0.85f)));
|
||||
|
||||
|
||||
// TODO: Clicking the screen shot view should open ShowImage with the
|
||||
// the screen shot. This could be done by writing the screen shot to
|
||||
// a temporary folder, launching ShowImage to display it, and writing
|
||||
@@ -612,7 +612,7 @@ public:
|
||||
BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
|
||||
fScreenshotView->SetExplicitAlignment(
|
||||
BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
||||
|
||||
|
||||
fEmailIconView = new BitmapView("email icon view");
|
||||
fEmailLinkView = new LinkView("email link view", "",
|
||||
new BMessage(MSG_EMAIL_PUBLISHER), kLightBlack);
|
||||
@@ -622,11 +622,11 @@ public:
|
||||
fWebsiteLinkView = new LinkView("website link view", "",
|
||||
new BMessage(MSG_VISIT_PUBLISHER_WEBSITE), kLightBlack);
|
||||
fWebsiteLinkView->SetFont(&smallFont);
|
||||
|
||||
|
||||
BGroupView* leftGroup = new BGroupView(B_VERTICAL,
|
||||
B_USE_DEFAULT_SPACING);
|
||||
leftGroup->SetViewColor(ViewColor());
|
||||
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0.0f)
|
||||
// .Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
||||
.AddGroup(leftGroup)
|
||||
@@ -648,7 +648,7 @@ public:
|
||||
.SetInsets(0.0f, -1.0f, -1.0f, -1.0f)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
virtual ~AboutView()
|
||||
{
|
||||
Clear();
|
||||
@@ -719,7 +719,7 @@ public:
|
||||
rating.User().Avatar()->Bitmap(SharedBitmap::SIZE_16));
|
||||
}
|
||||
fAvatarView->SetExplicitMinSize(BSize(16.0f, 16.0f));
|
||||
|
||||
|
||||
fNameView = new BStringView("user name", rating.User().NickName());
|
||||
BFont nameFont(be_bold_font);
|
||||
nameFont.SetSize(std::max(9.0f, floorf(nameFont.Size() * 0.9f)));
|
||||
@@ -727,7 +727,7 @@ public:
|
||||
fNameView->SetHighColor(kLightBlack);
|
||||
fNameView->SetExplicitMaxSize(
|
||||
BSize(nameFont.StringWidth("xxxxxxxxxxxxxxxxxxxxxx"), B_SIZE_UNSET));
|
||||
|
||||
|
||||
fRatingView = new RatingView();
|
||||
fRatingView->SetRating(rating.Rating());
|
||||
|
||||
@@ -754,7 +754,7 @@ public:
|
||||
fUpVoteCountView = new BStringView("up vote count", "");
|
||||
fVoteDownIconView = new BitmapButton("vote down icon", voteDownMessage);
|
||||
fDownVoteCountView = new BStringView("up vote count", "");
|
||||
|
||||
|
||||
fVoteUpIconView->SetBitmap(
|
||||
voteUpIcon->Bitmap(SharedBitmap::SIZE_16));
|
||||
fVoteDownIconView->SetBitmap(
|
||||
@@ -842,7 +842,7 @@ protected:
|
||||
BGroupView::DoLayout();
|
||||
if (BScrollBar* scrollBar = ScrollBar(B_VERTICAL)) {
|
||||
BRect layoutArea = GroupLayout()->LayoutArea();
|
||||
float layoutHeight = layoutArea.Height();
|
||||
float layoutHeight = layoutArea.Height();
|
||||
// Min size is not reliable with HasHeightForWidth() children,
|
||||
// since it does not reflect how thos children are currently
|
||||
// laid out, but what their theoretical minimum size would be.
|
||||
@@ -874,13 +874,13 @@ public:
|
||||
{
|
||||
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
kContentTint - 0.1));
|
||||
|
||||
|
||||
BLayoutBuilder::Grid<> layoutBuilder(this);
|
||||
|
||||
|
||||
BFont smallFont;
|
||||
GetFont(&smallFont);
|
||||
smallFont.SetSize(std::max(9.0f, floorf(smallFont.Size() * 0.85f)));
|
||||
|
||||
|
||||
for (int32 i = 0; i < 5; i++) {
|
||||
BString label;
|
||||
label.SetToFormat("%ld", 5 - i);
|
||||
@@ -891,14 +891,14 @@ public:
|
||||
|
||||
fDiagramBarViews[i] = new DiagramBarView();
|
||||
layoutBuilder.Add(fDiagramBarViews[i], 1, i);
|
||||
|
||||
|
||||
fCountViews[i] = new BStringView("", "");
|
||||
fCountViews[i]->SetFont(&smallFont);
|
||||
fCountViews[i]->SetHighColor(kLightBlack);
|
||||
fCountViews[i]->SetAlignment(B_ALIGN_RIGHT);
|
||||
layoutBuilder.Add(fCountViews[i], 2, i);
|
||||
}
|
||||
|
||||
|
||||
layoutBuilder.SetInsets(5);
|
||||
}
|
||||
|
||||
@@ -909,7 +909,7 @@ public:
|
||||
BString label;
|
||||
label.SetToFormat("%ld", count);
|
||||
fCountViews[i]->SetText(label);
|
||||
|
||||
|
||||
if (summary.ratingCount > 0) {
|
||||
fDiagramBarViews[i]->SetValue(
|
||||
(float)count / summary.ratingCount);
|
||||
@@ -942,15 +942,15 @@ public:
|
||||
{
|
||||
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
kContentTint));
|
||||
|
||||
|
||||
fRatingSummaryView = new RatingSummaryView();
|
||||
|
||||
|
||||
RatingContainerView* ratingsContainerView = new RatingContainerView();
|
||||
fRatingContainerLayout = ratingsContainerView->GroupLayout();
|
||||
|
||||
BScrollView* scrollView = new RatingsScrollView(
|
||||
"ratings scroll view", ratingsContainerView);
|
||||
|
||||
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.AddGroup(B_VERTICAL)
|
||||
.Add(fRatingSummaryView, 0.0f)
|
||||
@@ -961,7 +961,7 @@ public:
|
||||
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
virtual ~UserRatingsView()
|
||||
{
|
||||
Clear();
|
||||
@@ -975,10 +975,10 @@ public:
|
||||
fRatingSummaryView->SetToSummary(package.CalculateRatingSummary());
|
||||
|
||||
const UserRatingList& userRatings = package.UserRatings();
|
||||
|
||||
|
||||
// TODO: Sort by age or usefullness rating
|
||||
// TODO: Optionally hide ratings that are not in the system language
|
||||
|
||||
|
||||
for (int i = userRatings.CountItems() - 1; i >= 0; i--) {
|
||||
const UserRating& rating = userRatings.ItemAtFast(i);
|
||||
RatingItemView* view = new RatingItemView(rating, fThumbsUpIcon,
|
||||
@@ -1026,23 +1026,23 @@ public:
|
||||
{
|
||||
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
kContentTint));
|
||||
|
||||
|
||||
SetLayout(fLayout);
|
||||
|
||||
fTextView = new MarkupTextView("changelog view");
|
||||
fTextView->SetLowColor(ViewColor());
|
||||
fTextView->SetInsets(be_plain_font->Size());
|
||||
|
||||
|
||||
BScrollView* scrollView = new CustomScrollView(
|
||||
"changelog scroll view", fTextView);
|
||||
|
||||
|
||||
BLayoutBuilder::Group<>(fLayout)
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(32.0f))
|
||||
.Add(scrollView, 1.0f)
|
||||
.SetInsets(B_USE_DEFAULT_SPACING, -1.0f, -1.0f, -1.0f)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
virtual ~ChangelogView()
|
||||
{
|
||||
}
|
||||
@@ -1078,7 +1078,7 @@ public:
|
||||
fLayout(new BCardLayout())
|
||||
{
|
||||
SetBorder(B_NO_BORDER);
|
||||
|
||||
|
||||
fAboutView = new AboutView();
|
||||
fUserRatingsView = new UserRatingsView();
|
||||
fChangelogView = new ChangelogView();
|
||||
@@ -1086,14 +1086,14 @@ public:
|
||||
AddTab(fAboutView);
|
||||
AddTab(fUserRatingsView);
|
||||
AddTab(fChangelogView);
|
||||
|
||||
|
||||
TabAt(0)->SetLabel(B_TRANSLATE("About"));
|
||||
TabAt(1)->SetLabel(B_TRANSLATE("Ratings"));
|
||||
TabAt(2)->SetLabel(B_TRANSLATE("Changelog"));
|
||||
|
||||
Select(0);
|
||||
}
|
||||
|
||||
|
||||
virtual ~PagesView()
|
||||
{
|
||||
Clear();
|
||||
@@ -1116,7 +1116,7 @@ public:
|
||||
|
||||
private:
|
||||
BCardLayout* fLayout;
|
||||
|
||||
|
||||
AboutView* fAboutView;
|
||||
UserRatingsView* fUserRatingsView;
|
||||
ChangelogView* fChangelogView;
|
||||
@@ -1150,11 +1150,11 @@ public:
|
||||
return;
|
||||
|
||||
const PackageInfo& package = *event.Package().Get();
|
||||
|
||||
|
||||
BMessage message(MSG_UPDATE_PACKAGE);
|
||||
message.AddString("title", package.Title());
|
||||
message.AddUInt32("changes", event.Changes());
|
||||
|
||||
|
||||
messenger.SendMessage(&message);
|
||||
}
|
||||
|
||||
@@ -1246,9 +1246,9 @@ PackageInfoView::MessageReceived(BMessage* message)
|
||||
const PackageInfo& package = *fPackageListener->Package().Get();
|
||||
if (package.Title() != title)
|
||||
break;
|
||||
|
||||
|
||||
BAutolock _(fModelLock);
|
||||
|
||||
|
||||
if ((changes & PKG_CHANGED_DESCRIPTION) != 0
|
||||
|| (changes & PKG_CHANGED_SCREENSHOTS) != 0) {
|
||||
fTitleView->SetPackage(package);
|
||||
@@ -1271,13 +1271,13 @@ void
|
||||
PackageInfoView::SetPackage(const PackageInfoRef& packageRef)
|
||||
{
|
||||
BAutolock _(fModelLock);
|
||||
|
||||
|
||||
const PackageInfo& package = *packageRef.Get();
|
||||
|
||||
|
||||
fTitleView->SetPackage(package);
|
||||
fPackageActionView->SetPackage(package);
|
||||
fPagesView->SetPackage(package);
|
||||
|
||||
|
||||
if (fPagesView->IsHidden(fPagesView))
|
||||
fPagesView->Show();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
TitleView* fTitleView;
|
||||
PackageActionView* fPackageActionView;
|
||||
PagesView* fPagesView;
|
||||
|
||||
|
||||
Listener* fPackageListener;
|
||||
};
|
||||
|
||||
|
||||
@@ -117,17 +117,17 @@ public:
|
||||
{
|
||||
if ((event.Changes() & PKG_CHANGED_RATINGS) == 0)
|
||||
return;
|
||||
|
||||
|
||||
BMessenger messenger(fView);
|
||||
if (!messenger.IsValid())
|
||||
return;
|
||||
|
||||
const PackageInfo& package = *event.Package().Get();
|
||||
|
||||
|
||||
BMessage message(MSG_UPDATE_PACKAGE);
|
||||
message.AddString("title", package.Title());
|
||||
message.AddUInt32("changes", event.Changes());
|
||||
|
||||
|
||||
messenger.SendMessage(&message);
|
||||
}
|
||||
|
||||
@@ -185,10 +185,10 @@ RatingField::SetRating(float rating)
|
||||
rating = 0.0f;
|
||||
if (rating > 5.0f)
|
||||
rating = 5.0f;
|
||||
|
||||
|
||||
if (rating == fRating)
|
||||
return;
|
||||
|
||||
|
||||
fRating = rating;
|
||||
// TODO: cause a redraw?
|
||||
}
|
||||
@@ -292,7 +292,7 @@ PackageColumn::DrawField(BField* field, BRect rect, BView* parent)
|
||||
drawOverlay = false;
|
||||
stringWidth = parent->StringWidth(string);
|
||||
}
|
||||
|
||||
|
||||
switch (Alignment()) {
|
||||
default:
|
||||
case B_ALIGN_LEFT:
|
||||
@@ -320,15 +320,15 @@ PackageColumn::DrawField(BField* field, BRect rect, BView* parent)
|
||||
+ fontHeight.ascent;
|
||||
|
||||
parent->DrawString(string, BPoint(rect.left, y));
|
||||
|
||||
|
||||
if (drawOverlay) {
|
||||
rect.left = ceilf(rect.left
|
||||
+ (ratingField->Rating() / 5.0f) * rect.Width());
|
||||
|
||||
|
||||
rgb_color color = parent->LowColor();
|
||||
color.alpha = 190;
|
||||
parent->SetHighColor(color);
|
||||
|
||||
|
||||
parent->SetDrawingMode(B_OP_ALPHA);
|
||||
parent->FillRect(rect, B_SOLID_HIGH);
|
||||
|
||||
@@ -429,9 +429,9 @@ PackageRow::PackageRow(const PackageInfoRef& packageRef,
|
||||
{
|
||||
if (packageRef.Get() == NULL)
|
||||
return;
|
||||
|
||||
|
||||
PackageInfo& package = *packageRef.Get();
|
||||
|
||||
|
||||
// Package icon and title
|
||||
// NOTE: The icon BBitmap is referenced by the fPackage member.
|
||||
const BBitmap* icon = NULL;
|
||||
@@ -487,13 +487,13 @@ public:
|
||||
BFont font(be_plain_font);
|
||||
font.SetSize(9.0f);
|
||||
SetFont(&font);
|
||||
|
||||
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT));
|
||||
}
|
||||
|
||||
|
||||
virtual BSize MinSize()
|
||||
{
|
||||
BString label(_GetLabel());
|
||||
@@ -513,15 +513,15 @@ public:
|
||||
virtual void Draw(BRect updateRect)
|
||||
{
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
|
||||
|
||||
BString label(_GetLabel());
|
||||
|
||||
|
||||
font_height fontHeight;
|
||||
GetFontHeight(&fontHeight);
|
||||
|
||||
|
||||
BRect bounds(Bounds());
|
||||
float width = StringWidth(label);
|
||||
|
||||
|
||||
BPoint offset;
|
||||
offset.x = bounds.left + (bounds.Width() - width) / 2.0f;
|
||||
offset.y = bounds.top + (bounds.Height()
|
||||
@@ -576,7 +576,7 @@ PackageListView::PackageListView(BLocker* modelLock)
|
||||
B_TRUNCATE_END), kStatusColumn);
|
||||
|
||||
SetSortingEnabled(true);
|
||||
|
||||
|
||||
fItemCountView = new ItemCountView();
|
||||
AddStatusView(fItemCountView);
|
||||
}
|
||||
@@ -617,7 +617,7 @@ PackageListView::MessageReceived(BMessage* message)
|
||||
PackageRow* row = _FindRow(title);
|
||||
if (row != NULL)
|
||||
row->UpdateRating();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -632,13 +632,13 @@ void
|
||||
PackageListView::SelectionChanged()
|
||||
{
|
||||
BColumnListView::SelectionChanged();
|
||||
|
||||
|
||||
BMessage message(MSG_PACKAGE_SELECTED);
|
||||
|
||||
|
||||
PackageRow* selected = dynamic_cast<PackageRow*>(CurrentSelection());
|
||||
if (selected != NULL)
|
||||
message.AddString("title", selected->Package()->Title());
|
||||
|
||||
|
||||
Window()->PostMessage(&message);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual void SelectionChanged();
|
||||
|
||||
void AddPackage(const PackageInfoRef& package);
|
||||
|
||||
|
||||
private:
|
||||
PackageRow* _FindRow(const PackageInfoRef& package,
|
||||
PackageRow* parent = NULL);
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
private:
|
||||
class ItemCountView;
|
||||
|
||||
BLocker* fModelLock;
|
||||
BLocker* fModelLock;
|
||||
ItemCountView* fItemCountView;
|
||||
PackageListener* fPackageListener;
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
{
|
||||
return B_TRANSLATE("Install");
|
||||
}
|
||||
|
||||
|
||||
virtual status_t Perform()
|
||||
{
|
||||
// TODO: Trigger asynchronous installation of the package
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
virtual ~PackageAction();
|
||||
|
||||
virtual const char* Label() const = 0;
|
||||
|
||||
|
||||
// TODO: Perform() needs to be passed a progress listener
|
||||
// and it needs a mechanism to report and react to errors. The
|
||||
// Package Kit supports this stuff already.
|
||||
|
||||
@@ -59,7 +59,7 @@ save_settings(BMessage* message, const char* fileName, const char* folder)
|
||||
// passing folder is optional
|
||||
if (folder != NULL)
|
||||
ret = path.Append(folder);
|
||||
|
||||
|
||||
if (ret == B_OK)
|
||||
ret = create_directory(path.Path(), 0777);
|
||||
|
||||
@@ -83,7 +83,7 @@ make_sure_frame_is_on_screen(BRect& frame, float borderWidth,
|
||||
{
|
||||
if (!frame.IsValid())
|
||||
return false;
|
||||
|
||||
|
||||
BScreen* screen = window != NULL ? new BScreen(window)
|
||||
: new BScreen(B_MAIN_SCREEN_ID);
|
||||
|
||||
@@ -91,7 +91,7 @@ make_sure_frame_is_on_screen(BRect& frame, float borderWidth,
|
||||
delete screen;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
BRect screenFrame = screen->Frame();
|
||||
|
||||
// Validate borderWidth and tabHeight
|
||||
@@ -104,7 +104,7 @@ make_sure_frame_is_on_screen(BRect& frame, float borderWidth,
|
||||
tabHeight = 0.0f;
|
||||
else
|
||||
tabHeight = std::min(tabHeight, floorf(screenFrame.Height() / 4.0f));
|
||||
|
||||
|
||||
// Account for window border and tab. It doesn't matter much if the
|
||||
// decorator frame is wider, just as long as the user can grab a
|
||||
// border to move the window
|
||||
|
||||
@@ -35,7 +35,7 @@ Bullet::operator=(const Bullet& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
|
||||
fBulletData = other.fBulletData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ CharacterStyle::operator=(const CharacterStyle& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
|
||||
fStyleData = other.fStyleData;
|
||||
return *this;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ CharacterStyle::SetBold(bool bold)
|
||||
|| (!bold && (face & B_BOLD_FACE) == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
uint16 neededFace = face;
|
||||
if (bold) {
|
||||
if ((face & B_ITALIC_FACE) != 0)
|
||||
@@ -116,7 +116,7 @@ CharacterStyle::SetItalic(bool italic)
|
||||
|| (!italic && (face & B_ITALIC_FACE) == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
uint16 neededFace = face;
|
||||
if (italic) {
|
||||
if ((face & B_BOLD_FACE) != 0)
|
||||
@@ -345,7 +345,7 @@ BFont
|
||||
CharacterStyle::_FindFontForFace(uint16 face) const
|
||||
{
|
||||
BFont font(Font());
|
||||
|
||||
|
||||
font_family family;
|
||||
font_style style;
|
||||
font.GetFamilyAndStyle(&family, &style);
|
||||
@@ -360,7 +360,7 @@ CharacterStyle::_FindFontForFace(uint16 face) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,19 +88,19 @@ private:
|
||||
|
||||
private:
|
||||
BFont fFont;
|
||||
|
||||
|
||||
// The following three values override glyph metrics unless -1
|
||||
float fAscent;
|
||||
float fDescent;
|
||||
float fWidth;
|
||||
|
||||
float fGlyphSpacing;
|
||||
|
||||
|
||||
rgb_color fFgColor;
|
||||
rgb_color fBgColor;
|
||||
rgb_color fStrikeOutColor;
|
||||
rgb_color fUnderlineColor;
|
||||
|
||||
|
||||
uint8 fStrikeOutStyle;
|
||||
uint8 fUnderlineStyle;
|
||||
};
|
||||
|
||||
@@ -67,9 +67,9 @@ MarkupParser::CreateDocumentFromMarkup(const BString& text)
|
||||
TextDocumentRef document(new(std::nothrow) TextDocument(), true);
|
||||
if (document.Get() == NULL)
|
||||
return document;
|
||||
|
||||
|
||||
AppendMarkup(document, text);
|
||||
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
@@ -78,15 +78,15 @@ void
|
||||
MarkupParser::AppendMarkup(const TextDocumentRef& document, const BString& text)
|
||||
{
|
||||
fTextDocument.SetTo(document);
|
||||
|
||||
|
||||
fCurrentCharacterStyle = &fNormalStyle;
|
||||
fCurrentParagraphStyle = &fParagraphStyle;
|
||||
|
||||
|
||||
fCurrentParagraph = Paragraph(*fCurrentParagraphStyle);
|
||||
fSpanStartOffset = 0;
|
||||
|
||||
|
||||
_ParseText(text);
|
||||
|
||||
|
||||
fTextDocument.Unset();
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ MarkupParser::_ParseText(const BString& text)
|
||||
|
||||
int32 charCount = text.CountChars();
|
||||
const char* c = text.String();
|
||||
|
||||
|
||||
while (offset <= charCount) {
|
||||
uint32 nextChar = UTF8ToCharCode(&c);
|
||||
|
||||
@@ -158,7 +158,7 @@ MarkupParser::_ParseText(const BString& text)
|
||||
_ToggleStyle(fItalicStyle);
|
||||
else if (tickCount == 3)
|
||||
_ToggleStyle(fBoldStyle);
|
||||
|
||||
|
||||
// Don't include the ticks in the next span.
|
||||
offset += tickCount - 1;
|
||||
start = offset + 1;
|
||||
@@ -186,7 +186,7 @@ MarkupParser::_ParseText(const BString& text)
|
||||
|
||||
_CopySpan(text, start, offset - 1);
|
||||
_FinishParagraph();
|
||||
|
||||
|
||||
offset += 2;
|
||||
c += 2;
|
||||
|
||||
@@ -212,7 +212,7 @@ MarkupParser::_ParseText(const BString& text)
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ Paragraph::Insert(int32 offset, const TextSpan& newSpan)
|
||||
return fTextSpans.Add(newSpan, index);
|
||||
}
|
||||
|
||||
// Split the span,
|
||||
// Split the span,
|
||||
TextSpan spanBefore = span.SubSpan(0, offset);
|
||||
TextSpan spanAfter = span.SubSpan(offset, span.CharCount() - offset);
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ ParagraphLayout::ParagraphLayout(const ParagraphLayout& other)
|
||||
:
|
||||
fTextSpans(other.fTextSpans),
|
||||
fParagraphStyle(other.fParagraphStyle),
|
||||
|
||||
|
||||
fWidth(other.fWidth),
|
||||
fLayoutValid(false),
|
||||
|
||||
@@ -251,13 +251,13 @@ void
|
||||
ParagraphLayout::Draw(BView* view, const BPoint& offset)
|
||||
{
|
||||
_ValidateLayout();
|
||||
|
||||
|
||||
int lineCount = fLineInfos.CountItems();
|
||||
for (int i = 0; i < lineCount; i++) {
|
||||
const LineInfo& line = fLineInfos.ItemAtFast(i);
|
||||
_DrawLine(view, offset, line);
|
||||
}
|
||||
|
||||
|
||||
const Bullet& bullet = fParagraphStyle.Bullet();
|
||||
if (bullet.Spacing() > 0.0f && bullet.String().Length() > 0) {
|
||||
// Draw bullet at offset
|
||||
@@ -317,7 +317,7 @@ ParagraphLayout::_Layout()
|
||||
int glyphCount = fGlyphInfos.CountItems();
|
||||
for (int i = 0; i < glyphCount; i++) {
|
||||
GlyphInfo glyph = fGlyphInfos.ItemAtFast(i);
|
||||
|
||||
|
||||
uint32 charClassification = get_char_classification(glyph.charCode);
|
||||
|
||||
float advanceX = glyph.width;
|
||||
@@ -528,7 +528,7 @@ ParagraphLayout::_ApplyAlignment()
|
||||
whiteSpace = spaceLeftForSpace / spaceCount;
|
||||
if (charCount > 0)
|
||||
charSpace = spaceLeftForChars / charCount;
|
||||
|
||||
|
||||
LineInfo line = fLineInfos.ItemAtFast(lineIndex);
|
||||
line.extraGlyphSpacing = charSpace;
|
||||
line.extraWhiteSpacing = whiteSpace;
|
||||
@@ -583,7 +583,7 @@ ParagraphLayout::_AppendGlyphInfos(const TextSpan& span)
|
||||
int charCount = span.CharCount();
|
||||
if (charCount == 0)
|
||||
return true;
|
||||
|
||||
|
||||
const BString& text = span.Text();
|
||||
const BFont& font = span.Style().Font();
|
||||
|
||||
@@ -621,7 +621,7 @@ ParagraphLayout::_AppendGlyphInfo(uint32 charCode, float width,
|
||||
}
|
||||
|
||||
width += style.GlyphSpacing();
|
||||
|
||||
|
||||
return fGlyphInfos.Add(GlyphInfo(charCode, 0.0f, width, 0));
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ ParagraphLayout::_IncludeStyleInLine(LineInfo& line,
|
||||
float descent = style.Descent();
|
||||
if (descent > line.maxDescent)
|
||||
line.maxDescent = descent;
|
||||
|
||||
|
||||
float height = ascent + descent;
|
||||
if (style.Font().Size() > height)
|
||||
height = style.Font().Size();
|
||||
@@ -713,7 +713,7 @@ ParagraphLayout::_DrawSpan(BView* view, BPoint offset,
|
||||
|
||||
const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset);
|
||||
const LineInfo& line = fLineInfos.ItemAtFast(glyph.lineIndex);
|
||||
|
||||
|
||||
offset.x += glyph.x;
|
||||
offset.y += line.y + line.maxAscent;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
lineIndex(lineIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GlyphInfo(const GlyphInfo& other)
|
||||
:
|
||||
charCode(other.charCode),
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
layoutedSpans()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LineInfo(int32 textOffset, float y, float height, float maxAscent,
|
||||
float maxDescent)
|
||||
:
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
layoutedSpans()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LineInfo(const LineInfo& other)
|
||||
:
|
||||
textOffset(other.textOffset),
|
||||
|
||||
@@ -25,7 +25,7 @@ ParagraphStyle::operator=(const ParagraphStyle& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
|
||||
fStyleData = other.fStyleData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ TextDocumentLayout::Draw(BView* view, const BPoint& offset,
|
||||
const BRect& updateRect)
|
||||
{
|
||||
_ValidateLayout();
|
||||
|
||||
|
||||
int layoutCount = fParagraphLayouts.CountItems();
|
||||
for (int i = 0; i < layoutCount; i++) {
|
||||
const ParagraphLayoutInfo& layout = fParagraphLayouts.ItemAtFast(i);
|
||||
@@ -151,9 +151,9 @@ TextDocumentLayout::_Layout()
|
||||
|
||||
if (i > 0)
|
||||
y += style.SpacingTop();
|
||||
|
||||
|
||||
fParagraphLayouts.Replace(i, ParagraphLayoutInfo(y, info.layout));
|
||||
|
||||
|
||||
info.layout->SetWidth(fWidth);
|
||||
y += info.layout->Height() + style.SpacingBottom();
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ TextDocumentTest::ReadyToRun()
|
||||
;
|
||||
|
||||
CharacterStyle regularStyle;
|
||||
|
||||
|
||||
float fontSize = regularStyle.Font().Size();
|
||||
|
||||
|
||||
ParagraphStyle paragraphStyle;
|
||||
paragraphStyle.SetJustify(true);
|
||||
paragraphStyle.SetSpacingTop(ceilf(fontSize * 0.6f));
|
||||
paragraphStyle.SetLineSpacing(ceilf(fontSize * 0.2f));
|
||||
|
||||
|
||||
// CharacterStyle boldStyle(regularStyle);
|
||||
// boldStyle.SetBold(true);
|
||||
//
|
||||
@@ -57,7 +57,7 @@ TextDocumentTest::ReadyToRun()
|
||||
//
|
||||
// CharacterStyle italicAndBoldStyle(boldStyle);
|
||||
// italicAndBoldStyle.SetItalic(true);
|
||||
//
|
||||
//
|
||||
// CharacterStyle bigStyle(regularStyle);
|
||||
// bigStyle.SetFontSize(24);
|
||||
// bigStyle.SetForegroundColor(255, 50, 50);
|
||||
@@ -96,7 +96,7 @@ TextDocumentTest::ReadyToRun()
|
||||
// paragraph = Paragraph(paragraphStyle);
|
||||
// paragraph.Append(TextSpan("The wrapping in ", regularStyle));
|
||||
// paragraph.Append(TextSpan("this", italicStyle));
|
||||
//
|
||||
//
|
||||
// paragraph.Append(TextSpan(" bullet item should look visually "
|
||||
// "pleasing. And ", regularStyle));
|
||||
// paragraph.Append(TextSpan("why", italicAndBoldStyle));
|
||||
@@ -104,7 +104,7 @@ TextDocumentTest::ReadyToRun()
|
||||
// document->Append(paragraph);
|
||||
|
||||
MarkupParser parser(regularStyle, paragraphStyle);
|
||||
|
||||
|
||||
TextDocumentRef document = parser.CreateDocumentFromMarkup(
|
||||
"== Text document test ==\n"
|
||||
"This is a test to see if '''different''' "
|
||||
|
||||
@@ -142,7 +142,7 @@ TextSpan::_TruncateRemove(int32& start, int32& count) const
|
||||
count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (start < 0) {
|
||||
count += start;
|
||||
start = 0;
|
||||
|
||||
@@ -18,7 +18,7 @@ TextView::TextView(const char* name)
|
||||
|
||||
::ParagraphStyle style;
|
||||
style.SetLineSpacing(ceilf(font.Size() * 0.2));
|
||||
|
||||
|
||||
SetParagraphStyle(style);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ TextView::SetText(const BString& text)
|
||||
fText.Append(TextSpan(text, regularStyle));
|
||||
|
||||
fTextLayout.SetParagraph(fText);
|
||||
|
||||
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user