HaikuDepot: Use a TextDocumentView for the Changelog.

* This allows simple media wiki markup in the changelog.
This commit is contained in:
Stephan Aßmus
2013-09-08 14:40:42 +02:00
parent 2a059affa4
commit 0e61e1ef80
+22 -10
View File
@@ -24,7 +24,9 @@
#include "BitmapButton.h" #include "BitmapButton.h"
#include "BitmapView.h" #include "BitmapView.h"
#include "MarkupParser.h"
#include "PackageManager.h" #include "PackageManager.h"
#include "TextDocumentView.h"
#include "TextView.h" #include "TextView.h"
@@ -942,12 +944,21 @@ public:
kContentTint)); kContentTint));
SetLayout(fLayout); SetLayout(fLayout);
CharacterStyle regularStyle;
fTextView = new BTextView("changelog view"); float fontSize = regularStyle.Font().Size();
fTextView->SetViewColor(ViewColor());
fTextView->MakeEditable(false); ParagraphStyle paragraphStyle;
const float textInset = be_plain_font->Size(); paragraphStyle.SetJustify(true);
fTextView->SetInsets(textInset, textInset, textInset, 0.0f); paragraphStyle.SetSpacingTop(ceilf(fontSize * 0.3f));
paragraphStyle.SetLineSpacing(ceilf(fontSize * 0.2f));
fMarkupParser.SetStyles(regularStyle, paragraphStyle);
fTextView = new TextDocumentView("changelog view");
fTextView->SetLowColor(ViewColor());
fTextView->SetInsets(be_plain_font->Size());
BScrollView* scrollView = new CustomScrollView( BScrollView* scrollView = new CustomScrollView(
"changelog scroll view", fTextView); "changelog scroll view", fTextView);
@@ -961,7 +972,6 @@ public:
virtual ~ChangelogView() virtual ~ChangelogView()
{ {
Clear();
} }
virtual void Draw(BRect updateRect) virtual void Draw(BRect updateRect)
@@ -970,17 +980,19 @@ public:
void SetPackage(const PackageInfo& package) void SetPackage(const PackageInfo& package)
{ {
fTextView->SetText(package.Changelog()); fTextView->SetTextDocument(fMarkupParser.CreateDocumentFromMarkup(
package.Changelog()));
} }
void Clear() void Clear()
{ {
fTextView->SetText(""); fTextView->SetTextDocument(fMarkupParser.CreateDocumentFromMarkup(""));
} }
private: private:
BGroupLayout* fLayout; BGroupLayout* fLayout;
BTextView* fTextView; TextDocumentView* fTextView;
MarkupParser fMarkupParser;
}; };