Add AddText method to AboutWindow
* Factor out the code to add some data to the about window, with a header and a content under it * Make this method public so it's possible to add custom entries in an about box * If the method is called with only the header or only the content, the text is added non-bold and non-indented (like the description entry*). * Make the header text bold. I'm not sure it looks that good, after all. Thoughts ?
This commit is contained in:
@@ -37,6 +37,9 @@ class BAboutWindow : public BWindow {
|
|||||||
void AddVersionHistory(const char** history);
|
void AddVersionHistory(const char** history);
|
||||||
void AddExtraInfo(const char* extraInfo);
|
void AddExtraInfo(const char* extraInfo);
|
||||||
|
|
||||||
|
void AddText(const char* header,
|
||||||
|
const char** contents = NULL);
|
||||||
|
|
||||||
BBitmap* Icon();
|
BBitmap* Icon();
|
||||||
void SetIcon(BBitmap* icon);
|
void SetIcon(BBitmap* icon);
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ AboutView::AboutView(const char* appName, const char* signature)
|
|||||||
fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0);
|
fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0);
|
||||||
fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
|
fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
|
||||||
fInfoView->SetHighColor(ui_color(B_DOCUMENT_TEXT_COLOR));
|
fInfoView->SetHighColor(ui_color(B_DOCUMENT_TEXT_COLOR));
|
||||||
|
fInfoView->SetStylable(true);
|
||||||
|
|
||||||
BScrollView* infoViewScroller = new BScrollView(
|
BScrollView* infoViewScroller = new BScrollView(
|
||||||
"infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS,
|
"infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS,
|
||||||
@@ -435,16 +436,7 @@ BAboutWindow::AddDescription(const char* description)
|
|||||||
if (description == NULL)
|
if (description == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char* appDesc = B_TRANSLATE_MARK(description);
|
AddText(description);
|
||||||
appDesc = gSystemCatalog.GetString(appDesc, "AboutWindow");
|
|
||||||
|
|
||||||
BString desc("");
|
|
||||||
if (fAboutView->InfoView()->TextLength() > 0)
|
|
||||||
desc << "\n\n";
|
|
||||||
|
|
||||||
desc << appDesc;
|
|
||||||
|
|
||||||
fAboutView->InfoView()->Insert(desc.String());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -501,16 +493,7 @@ BAboutWindow::AddAuthors(const char** authors)
|
|||||||
const char* writtenBy = B_TRANSLATE_MARK("Written by:");
|
const char* writtenBy = B_TRANSLATE_MARK("Written by:");
|
||||||
writtenBy = gSystemCatalog.GetString(writtenBy, "AboutWindow");
|
writtenBy = gSystemCatalog.GetString(writtenBy, "AboutWindow");
|
||||||
|
|
||||||
BString text("");
|
AddText(writtenBy, authors);
|
||||||
if (fAboutView->InfoView()->TextLength() > 0)
|
|
||||||
text << "\n\n";
|
|
||||||
|
|
||||||
text << writtenBy;
|
|
||||||
text << "\n";
|
|
||||||
for (int32 i = 0; authors[i]; i++)
|
|
||||||
text << " " << authors[i] << "\n";
|
|
||||||
|
|
||||||
fAboutView->InfoView()->Insert(text.String());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -523,15 +506,7 @@ BAboutWindow::AddSpecialThanks(const char** thanks)
|
|||||||
const char* specialThanks = B_TRANSLATE_MARK("Special Thanks:");
|
const char* specialThanks = B_TRANSLATE_MARK("Special Thanks:");
|
||||||
specialThanks = gSystemCatalog.GetString(specialThanks, "AboutWindow");
|
specialThanks = gSystemCatalog.GetString(specialThanks, "AboutWindow");
|
||||||
|
|
||||||
BString text("");
|
AddText(specialThanks, thanks);
|
||||||
if (fAboutView->InfoView()->TextLength() > 0)
|
|
||||||
text << "\n\n";
|
|
||||||
|
|
||||||
text << specialThanks << "\n";
|
|
||||||
for (int32 i = 0; thanks[i]; i++)
|
|
||||||
text << " " << thanks[i] << "\n";
|
|
||||||
|
|
||||||
fAboutView->InfoView()->Insert(text.String());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -544,15 +519,7 @@ BAboutWindow::AddVersionHistory(const char** history)
|
|||||||
const char* versionHistory = B_TRANSLATE_MARK("Version history:");
|
const char* versionHistory = B_TRANSLATE_MARK("Version history:");
|
||||||
versionHistory = gSystemCatalog.GetString(versionHistory, "AboutWindow");
|
versionHistory = gSystemCatalog.GetString(versionHistory, "AboutWindow");
|
||||||
|
|
||||||
BString text("");
|
AddText(versionHistory, history);
|
||||||
if (fAboutView->InfoView()->TextLength() > 0)
|
|
||||||
text << "\n\n";
|
|
||||||
|
|
||||||
text << versionHistory << "\n";
|
|
||||||
for (int32 i = 0; history[i]; i++)
|
|
||||||
text << " " << history[i] << "\n";
|
|
||||||
|
|
||||||
fAboutView->InfoView()->Insert(text.String());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -575,6 +542,39 @@ BAboutWindow::AddExtraInfo(const char* extraInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BAboutWindow::AddText(const char* header, const char** contents)
|
||||||
|
{
|
||||||
|
BTextView* infoView = fAboutView->InfoView();
|
||||||
|
int32 textLength = infoView->TextLength();
|
||||||
|
BString text("");
|
||||||
|
|
||||||
|
if (textLength > 0) {
|
||||||
|
text << "\n\n";
|
||||||
|
textLength += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* indent = "";
|
||||||
|
if (header != NULL) {
|
||||||
|
indent = " ";
|
||||||
|
text << header;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contents != NULL) {
|
||||||
|
text << "\n";
|
||||||
|
for (int32 i = 0; contents[i]; i++)
|
||||||
|
text << indent << contents[i] << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
infoView->Insert(text.String());
|
||||||
|
|
||||||
|
if (contents != NULL && header != NULL) {
|
||||||
|
infoView->SetFontAndColor(textLength, textLength + strlen(header),
|
||||||
|
be_bold_font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
BAboutWindow::Name()
|
BAboutWindow::Name()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user