Add methods to get and set the name, version, and icon
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class AboutView;
|
class AboutView;
|
||||||
|
class BBitmap;
|
||||||
class BPoint;
|
class BPoint;
|
||||||
class BHandler;
|
class BHandler;
|
||||||
|
|
||||||
@@ -37,6 +38,15 @@ class BAboutWindow : public BWindow {
|
|||||||
void AddVersionHistory(const char** history);
|
void AddVersionHistory(const char** history);
|
||||||
void AddExtraInfo(const char* extraInfo);
|
void AddExtraInfo(const char* extraInfo);
|
||||||
|
|
||||||
|
BBitmap* Icon();
|
||||||
|
void SetIcon(BBitmap* icon);
|
||||||
|
|
||||||
|
const char* Name();
|
||||||
|
void SetName(const char* name);
|
||||||
|
|
||||||
|
const char* Version();
|
||||||
|
void SetVersion(const char* version);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AboutView* fAboutView;
|
AboutView* fAboutView;
|
||||||
BHandler* fCaller;
|
BHandler* fCaller;
|
||||||
|
|||||||
+149
-10
@@ -49,6 +49,9 @@ class StripeView : public BView {
|
|||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
|
BBitmap* Icon() const { return fIcon; };
|
||||||
|
void SetIcon(BBitmap* icon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BBitmap* fIcon;
|
BBitmap* fIcon;
|
||||||
};
|
};
|
||||||
@@ -62,14 +65,24 @@ class AboutView : public BGroupView {
|
|||||||
|
|
||||||
BTextView* InfoView() const { return fInfoView; };
|
BTextView* InfoView() const { return fInfoView; };
|
||||||
|
|
||||||
|
BBitmap* Icon();
|
||||||
|
status_t SetIcon(BBitmap* icon);
|
||||||
|
|
||||||
|
const char* Name();
|
||||||
|
status_t SetName(const char* name);
|
||||||
|
|
||||||
|
const char* Version();
|
||||||
|
status_t SetVersion(const char* version);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char* AppVersion(const char* signature);
|
const char* _GetVersionFromSignature(const char* signature);
|
||||||
BBitmap* AppIcon(const char* signature);
|
BBitmap* _GetIconFromSignature(const char* signature);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BStringView* fNameView;
|
BStringView* fNameView;
|
||||||
BStringView* fVersionView;
|
BStringView* fVersionView;
|
||||||
BTextView* fInfoView;
|
BTextView* fInfoView;
|
||||||
|
StripeView* fStripeView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -81,13 +94,14 @@ StripeView::StripeView(BBitmap* icon)
|
|||||||
BView("StripeView", B_WILL_DRAW),
|
BView("StripeView", B_WILL_DRAW),
|
||||||
fIcon(icon)
|
fIcon(icon)
|
||||||
{
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
float width = 0.0f;
|
float width = 0.0f;
|
||||||
if (icon != NULL)
|
if (icon != NULL)
|
||||||
width += icon->Bounds().Width() + 32.0f;
|
width += icon->Bounds().Width() + 32.0f;
|
||||||
|
|
||||||
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||||
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,7 +130,24 @@ StripeView::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
void
|
||||||
|
StripeView::SetIcon(BBitmap* icon)
|
||||||
|
{
|
||||||
|
if (fIcon != NULL)
|
||||||
|
delete fIcon;
|
||||||
|
|
||||||
|
fIcon = icon;
|
||||||
|
|
||||||
|
float width = 0.0f;
|
||||||
|
if (icon != NULL)
|
||||||
|
width += icon->Bounds().Width() + 32.0f;
|
||||||
|
|
||||||
|
SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||||
|
SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - AboutView
|
||||||
|
|
||||||
|
|
||||||
AboutView::AboutView(const char* appName, const char* signature)
|
AboutView::AboutView(const char* appName, const char* signature)
|
||||||
@@ -131,7 +162,8 @@ AboutView::AboutView(const char* appName, const char* signature)
|
|||||||
fNameView->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE
|
fNameView->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE
|
||||||
| B_FONT_FLAGS);
|
| B_FONT_FLAGS);
|
||||||
|
|
||||||
fVersionView = new BStringView("version", AppVersion(signature));
|
fVersionView = new BStringView("version",
|
||||||
|
_GetVersionFromSignature(signature));
|
||||||
|
|
||||||
fInfoView = new BTextView("info", B_WILL_DRAW);
|
fInfoView = new BTextView("info", B_WILL_DRAW);
|
||||||
fInfoView->SetExplicitMinSize(BSize(210.0, 160.0));
|
fInfoView->SetExplicitMinSize(BSize(210.0, 160.0));
|
||||||
@@ -145,10 +177,12 @@ AboutView::AboutView(const char* appName, const char* signature)
|
|||||||
"infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS,
|
"infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS,
|
||||||
false, true, B_PLAIN_BORDER);
|
false, true, B_PLAIN_BORDER);
|
||||||
|
|
||||||
|
fStripeView = new StripeView(_GetIconFromSignature(signature));
|
||||||
|
|
||||||
GroupLayout()->SetSpacing(0);
|
GroupLayout()->SetSpacing(0);
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
.AddGroup(B_HORIZONTAL, 0)
|
.AddGroup(B_HORIZONTAL, 0)
|
||||||
.Add(new StripeView(AppIcon(signature)))
|
.Add(fStripeView)
|
||||||
.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
|
.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
|
||||||
.SetInsets(0, B_USE_DEFAULT_SPACING,
|
.SetInsets(0, B_USE_DEFAULT_SPACING,
|
||||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
@@ -166,8 +200,11 @@ AboutView::~AboutView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - AboutView protected methods
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
AboutView::AppVersion(const char* signature)
|
AboutView::_GetVersionFromSignature(const char* signature)
|
||||||
{
|
{
|
||||||
if (signature == NULL)
|
if (signature == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -228,7 +265,7 @@ AboutView::AppVersion(const char* signature)
|
|||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
AboutView::AppIcon(const char* signature)
|
AboutView::_GetIconFromSignature(const char* signature)
|
||||||
{
|
{
|
||||||
if (signature == NULL)
|
if (signature == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -251,7 +288,64 @@ AboutView::AppIcon(const char* signature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - AboutView public methods
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
AboutView::Name()
|
||||||
|
{
|
||||||
|
return fNameView->Text();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AboutView::SetName(const char* name)
|
||||||
|
{
|
||||||
|
fNameView->SetText(name);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
AboutView::Version()
|
||||||
|
{
|
||||||
|
return fVersionView->Text();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AboutView::SetVersion(const char* version)
|
||||||
|
{
|
||||||
|
fVersionView->SetText(version);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BBitmap*
|
||||||
|
AboutView::Icon()
|
||||||
|
{
|
||||||
|
if (fStripeView == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return fStripeView->Icon();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AboutView::SetIcon(BBitmap* icon)
|
||||||
|
{
|
||||||
|
if (fStripeView == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
fStripeView->SetIcon(icon);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - BAboutWindow
|
||||||
|
|
||||||
|
|
||||||
BAboutWindow::BAboutWindow(const char* appName, const char* signature)
|
BAboutWindow::BAboutWindow(const char* appName, const char* signature)
|
||||||
@@ -283,6 +377,9 @@ BAboutWindow::~BAboutWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - BAboutWindow virtual methods
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BAboutWindow::QuitRequested()
|
BAboutWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
@@ -292,7 +389,7 @@ BAboutWindow::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - BAboutWindow public methods
|
||||||
|
|
||||||
|
|
||||||
BPoint
|
BPoint
|
||||||
@@ -463,3 +560,45 @@ BAboutWindow::AddExtraInfo(const char* extraInfo)
|
|||||||
|
|
||||||
fAboutView->InfoView()->Insert(extra.String());
|
fAboutView->InfoView()->Insert(extra.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
BAboutWindow::Name()
|
||||||
|
{
|
||||||
|
return fAboutView->Name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BAboutWindow::SetName(const char* name)
|
||||||
|
{
|
||||||
|
fAboutView->SetName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
BAboutWindow::Version()
|
||||||
|
{
|
||||||
|
return fAboutView->Version();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BAboutWindow::SetVersion(const char* version)
|
||||||
|
{
|
||||||
|
fAboutView->SetVersion(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BBitmap*
|
||||||
|
BAboutWindow::Icon()
|
||||||
|
{
|
||||||
|
return fAboutView->Icon();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BAboutWindow::SetIcon(BBitmap* icon)
|
||||||
|
{
|
||||||
|
fAboutView->SetIcon(icon);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user