HaikuDepot: Extracted MarkupTextView into its own files
This commit is contained in:
@@ -39,12 +39,13 @@ Application HaikuDepot :
|
|||||||
BitmapButton.cpp
|
BitmapButton.cpp
|
||||||
BitmapView.cpp
|
BitmapView.cpp
|
||||||
DecisionProvider.cpp
|
DecisionProvider.cpp
|
||||||
FeaturedPackageView.cpp
|
FeaturedPackagesView.cpp
|
||||||
FilterView.cpp
|
FilterView.cpp
|
||||||
JobStateListener.cpp
|
JobStateListener.cpp
|
||||||
LinkView.cpp
|
LinkView.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
|
MarkupTextView.cpp
|
||||||
MessagePackageListener.cpp
|
MessagePackageListener.cpp
|
||||||
Model.cpp
|
Model.cpp
|
||||||
PackageAction.cpp
|
PackageAction.cpp
|
||||||
@@ -78,6 +79,7 @@ DoCatalogs HaikuDepot :
|
|||||||
x-vnd.Haiku-HaikuDepot
|
x-vnd.Haiku-HaikuDepot
|
||||||
:
|
:
|
||||||
App.cpp
|
App.cpp
|
||||||
|
FeaturedPackagesView.cpp
|
||||||
FilterView.cpp
|
FilterView.cpp
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
Model.cpp
|
Model.cpp
|
||||||
|
|||||||
+7
-7
@@ -3,7 +3,7 @@
|
|||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FeaturedPackageView.h"
|
#include "FeaturedPackagesView.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "FeaturedPackageView"
|
#define B_TRANSLATION_CONTEXT "FeaturedPackagesView"
|
||||||
|
|
||||||
|
|
||||||
static const rgb_color kLightBlack = (rgb_color){ 60, 60, 60, 255 };
|
static const rgb_color kLightBlack = (rgb_color){ 60, 60, 60, 255 };
|
||||||
@@ -148,10 +148,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - FeaturedPackageView
|
// #pragma mark - FeaturedPackagesView
|
||||||
|
|
||||||
|
|
||||||
FeaturedPackageView::FeaturedPackageView()
|
FeaturedPackagesView::FeaturedPackagesView()
|
||||||
:
|
:
|
||||||
BView("featured package view", 0)
|
BView("featured package view", 0)
|
||||||
{
|
{
|
||||||
@@ -171,13 +171,13 @@ FeaturedPackageView::FeaturedPackageView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FeaturedPackageView::~FeaturedPackageView()
|
FeaturedPackagesView::~FeaturedPackagesView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FeaturedPackageView::AddPackage(const PackageInfoRef& package)
|
FeaturedPackagesView::AddPackage(const PackageInfoRef& package)
|
||||||
{
|
{
|
||||||
PackageView* view = new PackageView();
|
PackageView* view = new PackageView();
|
||||||
view->SetPackage(package);
|
view->SetPackage(package);
|
||||||
@@ -186,7 +186,7 @@ FeaturedPackageView::AddPackage(const PackageInfoRef& package)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FeaturedPackageView::Clear()
|
FeaturedPackagesView::Clear()
|
||||||
{
|
{
|
||||||
for (int32 i = fPackageListLayout->CountItems() - 1;
|
for (int32 i = fPackageListLayout->CountItems() - 1;
|
||||||
BLayoutItem* item = fPackageListLayout->ItemAt(i); i--) {
|
BLayoutItem* item = fPackageListLayout->ItemAt(i); i--) {
|
||||||
+6
-6
@@ -2,8 +2,8 @@
|
|||||||
* Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
|
* Copyright 2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef FEATURED_PACKAGE_VIEW_H
|
#ifndef FEATURED_PACKAGES_VIEW_H
|
||||||
#define FEATURED_PACKAGE_VIEW_H
|
#define FEATURED_PACKAGES_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
@@ -15,10 +15,10 @@
|
|||||||
class BGroupLayout;
|
class BGroupLayout;
|
||||||
|
|
||||||
|
|
||||||
class FeaturedPackageView : public BView {
|
class FeaturedPackagesView : public BView {
|
||||||
public:
|
public:
|
||||||
FeaturedPackageView();
|
FeaturedPackagesView();
|
||||||
virtual ~FeaturedPackageView();
|
virtual ~FeaturedPackagesView();
|
||||||
|
|
||||||
void AddPackage(const PackageInfoRef& package);
|
void AddPackage(const PackageInfoRef& package);
|
||||||
void Clear();
|
void Clear();
|
||||||
@@ -29,4 +29,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // FEATURED_PACKAGE_VIEW_H
|
#endif // FEATURED_PACKAGES_VIEW_H
|
||||||
@@ -30,13 +30,12 @@
|
|||||||
#include "BitmapButton.h"
|
#include "BitmapButton.h"
|
||||||
#include "BitmapView.h"
|
#include "BitmapView.h"
|
||||||
#include "LinkView.h"
|
#include "LinkView.h"
|
||||||
#include "MarkupParser.h"
|
#include "MarkupTextView.h"
|
||||||
#include "MessagePackageListener.h"
|
#include "MessagePackageListener.h"
|
||||||
#include "PackageActionHandler.h"
|
#include "PackageActionHandler.h"
|
||||||
#include "PackageManager.h"
|
#include "PackageManager.h"
|
||||||
#include "RatingView.h"
|
#include "RatingView.h"
|
||||||
#include "ScrollableGroupView.h"
|
#include "ScrollableGroupView.h"
|
||||||
#include "TextDocumentView.h"
|
|
||||||
#include "TextView.h"
|
#include "TextView.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -109,66 +108,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MarkupTextView : public TextDocumentView {
|
|
||||||
public:
|
|
||||||
MarkupTextView(const char* name)
|
|
||||||
:
|
|
||||||
TextDocumentView(name)
|
|
||||||
{
|
|
||||||
SetEditingEnabled(false);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetText(const BString& markupText)
|
|
||||||
{
|
|
||||||
SetTextDocument(fMarkupParser.CreateDocumentFromMarkup(markupText));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetText(const BString heading, const BString& markupText)
|
|
||||||
{
|
|
||||||
TextDocumentRef document(new(std::nothrow) TextDocument(), true);
|
|
||||||
|
|
||||||
Paragraph paragraph(fMarkupParser.HeadingParagraphStyle());
|
|
||||||
paragraph.Append(TextSpan(heading,
|
|
||||||
fMarkupParser.HeadingCharacterStyle()));
|
|
||||||
document->Append(paragraph);
|
|
||||||
|
|
||||||
fMarkupParser.AppendMarkup(document, markupText);
|
|
||||||
|
|
||||||
SetTextDocument(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetDisabledText(const BString& text)
|
|
||||||
{
|
|
||||||
TextDocumentRef document(new(std::nothrow) TextDocument(), true);
|
|
||||||
|
|
||||||
ParagraphStyle paragraphStyle;
|
|
||||||
paragraphStyle.SetAlignment(ALIGN_CENTER);
|
|
||||||
|
|
||||||
CharacterStyle disabledStyle(fMarkupParser.NormalCharacterStyle());
|
|
||||||
disabledStyle.SetForegroundColor(kLightBlack);
|
|
||||||
|
|
||||||
Paragraph paragraph(paragraphStyle);
|
|
||||||
paragraph.Append(TextSpan(text, disabledStyle));
|
|
||||||
document->Append(paragraph);
|
|
||||||
|
|
||||||
SetTextDocument(document);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
MarkupParser fMarkupParser;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - rating stats
|
// #pragma mark - rating stats
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2014, Stephan Aßmus <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "MarkupTextView.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const rgb_color kLightBlack = (rgb_color){ 60, 60, 60, 255 };
|
||||||
|
|
||||||
|
|
||||||
|
MarkupTextView::MarkupTextView(const char* name)
|
||||||
|
:
|
||||||
|
TextDocumentView(name)
|
||||||
|
{
|
||||||
|
SetEditingEnabled(false);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MarkupTextView::SetText(const BString& markupText)
|
||||||
|
{
|
||||||
|
SetTextDocument(fMarkupParser.CreateDocumentFromMarkup(markupText));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MarkupTextView::SetText(const BString heading, const BString& markupText)
|
||||||
|
{
|
||||||
|
TextDocumentRef document(new(std::nothrow) TextDocument(), true);
|
||||||
|
|
||||||
|
Paragraph paragraph(fMarkupParser.HeadingParagraphStyle());
|
||||||
|
paragraph.Append(TextSpan(heading,
|
||||||
|
fMarkupParser.HeadingCharacterStyle()));
|
||||||
|
document->Append(paragraph);
|
||||||
|
|
||||||
|
fMarkupParser.AppendMarkup(document, markupText);
|
||||||
|
|
||||||
|
SetTextDocument(document);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MarkupTextView::SetDisabledText(const BString& text)
|
||||||
|
{
|
||||||
|
TextDocumentRef document(new(std::nothrow) TextDocument(), true);
|
||||||
|
|
||||||
|
ParagraphStyle paragraphStyle;
|
||||||
|
paragraphStyle.SetAlignment(ALIGN_CENTER);
|
||||||
|
|
||||||
|
CharacterStyle disabledStyle(fMarkupParser.NormalCharacterStyle());
|
||||||
|
disabledStyle.SetForegroundColor(kLightBlack);
|
||||||
|
|
||||||
|
Paragraph paragraph(paragraphStyle);
|
||||||
|
paragraph.Append(TextSpan(text, disabledStyle));
|
||||||
|
document->Append(paragraph);
|
||||||
|
|
||||||
|
SetTextDocument(document);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2014, Stephan Aßmus <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef MARKUP_TEXT_VIEW_H
|
||||||
|
#define MARKUP_TEXT_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "MarkupParser.h"
|
||||||
|
#include "TextDocumentView.h"
|
||||||
|
|
||||||
|
|
||||||
|
class MarkupTextView : public TextDocumentView {
|
||||||
|
public:
|
||||||
|
MarkupTextView(const char* name);
|
||||||
|
|
||||||
|
void SetText(const BString& markupText);
|
||||||
|
void SetText(const BString heading,
|
||||||
|
const BString& markupText);
|
||||||
|
|
||||||
|
void SetDisabledText(const BString& text);
|
||||||
|
|
||||||
|
private:
|
||||||
|
MarkupParser fMarkupParser;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MARKUP_TEXT_VIEW_H
|
||||||
Reference in New Issue
Block a user