19ce450b9SJohn Scipione /* 2*7a96554cSlooncraz * Copyright 2007-2015 Haiku, Inc. 39ce450b9SJohn Scipione * Distributed under the terms of the MIT License. 49ce450b9SJohn Scipione * 59ce450b9SJohn Scipione * Authors: 69ce450b9SJohn Scipione * Ryan Leavengood <leavengood@gmail.com> 79ce450b9SJohn Scipione * John Scipione <jscipione@gmail.com> 8*7a96554cSlooncraz * Joseph Groover <looncraz@looncraz.net> 99ce450b9SJohn Scipione */ 109ce450b9SJohn Scipione 119ce450b9SJohn Scipione 129ce450b9SJohn Scipione #include <AboutWindow.h> 139ce450b9SJohn Scipione 149ce450b9SJohn Scipione #include <stdarg.h> 159ce450b9SJohn Scipione #include <time.h> 169ce450b9SJohn Scipione 179ce450b9SJohn Scipione #include <Alert.h> 189ce450b9SJohn Scipione #include <AppFileInfo.h> 199ce450b9SJohn Scipione #include <Bitmap.h> 209ce450b9SJohn Scipione #include <Button.h> 219ce450b9SJohn Scipione #include <File.h> 229ce450b9SJohn Scipione #include <Font.h> 239ce450b9SJohn Scipione #include <GroupLayoutBuilder.h> 249ce450b9SJohn Scipione #include <GroupView.h> 259ce450b9SJohn Scipione #include <InterfaceDefs.h> 269ce450b9SJohn Scipione #include <LayoutBuilder.h> 279ce450b9SJohn Scipione #include <Message.h> 289ce450b9SJohn Scipione #include <MessageFilter.h> 299ce450b9SJohn Scipione #include <Point.h> 309ce450b9SJohn Scipione #include <Roster.h> 319ce450b9SJohn Scipione #include <Screen.h> 329ce450b9SJohn Scipione #include <ScrollView.h> 339ce450b9SJohn Scipione #include <Size.h> 349ce450b9SJohn Scipione #include <String.h> 359ce450b9SJohn Scipione #include <StringView.h> 369ce450b9SJohn Scipione #include <SystemCatalog.h> 379ce450b9SJohn Scipione #include <TextView.h> 389ce450b9SJohn Scipione #include <View.h> 399ce450b9SJohn Scipione #include <Window.h> 409ce450b9SJohn Scipione 419ce450b9SJohn Scipione 429ce450b9SJohn Scipione static const float kStripeWidth = 30.0; 439ce450b9SJohn Scipione 449ce450b9SJohn Scipione using BPrivate::gSystemCatalog; 459ce450b9SJohn Scipione 469ce450b9SJohn Scipione 479ce450b9SJohn Scipione #undef B_TRANSLATION_CONTEXT 489ce450b9SJohn Scipione #define B_TRANSLATION_CONTEXT "AboutWindow" 499ce450b9SJohn Scipione 509ce450b9SJohn Scipione 519ce450b9SJohn Scipione class StripeView : public BView { 529ce450b9SJohn Scipione public: 539ce450b9SJohn Scipione StripeView(BBitmap* icon); 549ce450b9SJohn Scipione virtual ~StripeView(); 559ce450b9SJohn Scipione 569ce450b9SJohn Scipione virtual void Draw(BRect updateRect); 579ce450b9SJohn Scipione 589ce450b9SJohn Scipione BBitmap* Icon() const { return fIcon; }; 599ce450b9SJohn Scipione void SetIcon(BBitmap* icon); 609ce450b9SJohn Scipione 619ce450b9SJohn Scipione private: 629ce450b9SJohn Scipione BBitmap* fIcon; 639ce450b9SJohn Scipione }; 649ce450b9SJohn Scipione 659ce450b9SJohn Scipione 669ce450b9SJohn Scipione class AboutView : public BGroupView { 679ce450b9SJohn Scipione public: 689ce450b9SJohn Scipione AboutView(const char* name, 699ce450b9SJohn Scipione const char* signature); 709ce450b9SJohn Scipione virtual ~AboutView(); 719ce450b9SJohn Scipione 72*7a96554cSlooncraz virtual void AllAttached(); 73*7a96554cSlooncraz 749ce450b9SJohn Scipione BTextView* InfoView() const { return fInfoView; }; 759ce450b9SJohn Scipione 769ce450b9SJohn Scipione BBitmap* Icon(); 779ce450b9SJohn Scipione status_t SetIcon(BBitmap* icon); 789ce450b9SJohn Scipione 799ce450b9SJohn Scipione const char* Name(); 809ce450b9SJohn Scipione status_t SetName(const char* name); 819ce450b9SJohn Scipione 829ce450b9SJohn Scipione const char* Version(); 839ce450b9SJohn Scipione status_t SetVersion(const char* version); 849ce450b9SJohn Scipione 859ce450b9SJohn Scipione private: 869ce450b9SJohn Scipione const char* _GetVersionFromSignature(const char* signature); 879ce450b9SJohn Scipione BBitmap* _GetIconFromSignature(const char* signature); 889ce450b9SJohn Scipione 899ce450b9SJohn Scipione private: 909ce450b9SJohn Scipione BStringView* fNameView; 919ce450b9SJohn Scipione BStringView* fVersionView; 929ce450b9SJohn Scipione BTextView* fInfoView; 939ce450b9SJohn Scipione StripeView* fStripeView; 949ce450b9SJohn Scipione }; 959ce450b9SJohn Scipione 969ce450b9SJohn Scipione 979ce450b9SJohn Scipione // #pragma mark - StripeView 989ce450b9SJohn Scipione 999ce450b9SJohn Scipione 1009ce450b9SJohn Scipione StripeView::StripeView(BBitmap* icon) 1019ce450b9SJohn Scipione : 1029ce450b9SJohn Scipione BView("StripeView", B_WILL_DRAW), 1039ce450b9SJohn Scipione fIcon(icon) 1049ce450b9SJohn Scipione { 105*7a96554cSlooncraz SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 1069ce450b9SJohn Scipione 1079ce450b9SJohn Scipione float width = 0.0f; 1089ce450b9SJohn Scipione if (icon != NULL) 1099ce450b9SJohn Scipione width += icon->Bounds().Width() + 32.0f; 1109ce450b9SJohn Scipione 1119ce450b9SJohn Scipione SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); 1129ce450b9SJohn Scipione SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED)); 1139ce450b9SJohn Scipione } 1149ce450b9SJohn Scipione 1159ce450b9SJohn Scipione 1169ce450b9SJohn Scipione StripeView::~StripeView() 1179ce450b9SJohn Scipione { 1189ce450b9SJohn Scipione } 1199ce450b9SJohn Scipione 1209ce450b9SJohn Scipione 1219ce450b9SJohn Scipione void 1229ce450b9SJohn Scipione StripeView::Draw(BRect updateRect) 1239ce450b9SJohn Scipione { 1249ce450b9SJohn Scipione if (fIcon == NULL) 1259ce450b9SJohn Scipione return; 1269ce450b9SJohn Scipione 1279ce450b9SJohn Scipione SetHighColor(ViewColor()); 1289ce450b9SJohn Scipione FillRect(updateRect); 1299ce450b9SJohn Scipione 1309ce450b9SJohn Scipione BRect stripeRect = Bounds(); 1319ce450b9SJohn Scipione stripeRect.right = kStripeWidth; 1329ce450b9SJohn Scipione SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); 1339ce450b9SJohn Scipione FillRect(stripeRect); 1349ce450b9SJohn Scipione 1359ce450b9SJohn Scipione SetDrawingMode(B_OP_ALPHA); 1369ce450b9SJohn Scipione SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); 1379ce450b9SJohn Scipione DrawBitmapAsync(fIcon, BPoint(15.0f, 10.0f)); 1389ce450b9SJohn Scipione } 1399ce450b9SJohn Scipione 1409ce450b9SJohn Scipione 1419ce450b9SJohn Scipione void 1429ce450b9SJohn Scipione StripeView::SetIcon(BBitmap* icon) 1439ce450b9SJohn Scipione { 1449ce450b9SJohn Scipione if (fIcon != NULL) 1459ce450b9SJohn Scipione delete fIcon; 1469ce450b9SJohn Scipione 1479ce450b9SJohn Scipione fIcon = icon; 1489ce450b9SJohn Scipione 1499ce450b9SJohn Scipione float width = 0.0f; 1509ce450b9SJohn Scipione if (icon != NULL) 1519ce450b9SJohn Scipione width += icon->Bounds().Width() + 32.0f; 1529ce450b9SJohn Scipione 1539ce450b9SJohn Scipione SetExplicitMinSize(BSize(width, B_SIZE_UNSET)); 1549ce450b9SJohn Scipione SetExplicitPreferredSize(BSize(width, B_SIZE_UNLIMITED)); 1559ce450b9SJohn Scipione }; 1569ce450b9SJohn Scipione 1579ce450b9SJohn Scipione 1589ce450b9SJohn Scipione // #pragma mark - AboutView 1599ce450b9SJohn Scipione 1609ce450b9SJohn Scipione 1619ce450b9SJohn Scipione AboutView::AboutView(const char* appName, const char* signature) 1629ce450b9SJohn Scipione : 1639ce450b9SJohn Scipione BGroupView("AboutView", B_VERTICAL) 1649ce450b9SJohn Scipione { 165*7a96554cSlooncraz SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 1669ce450b9SJohn Scipione fNameView = new BStringView("name", appName); 1679ce450b9SJohn Scipione BFont font; 1689ce450b9SJohn Scipione fNameView->GetFont(&font); 1699ce450b9SJohn Scipione font.SetFace(B_BOLD_FACE); 1709ce450b9SJohn Scipione font.SetSize(font.Size() * 2.0); 1719ce450b9SJohn Scipione fNameView->SetFont(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE 1729ce450b9SJohn Scipione | B_FONT_FLAGS); 1739ce450b9SJohn Scipione 1749ce450b9SJohn Scipione fVersionView = new BStringView("version", 1759ce450b9SJohn Scipione _GetVersionFromSignature(signature)); 1769ce450b9SJohn Scipione 1774cb7d0e7SPhilippe Saint-Pierre rgb_color documentColor = ui_color(B_DOCUMENT_TEXT_COLOR); 1784cb7d0e7SPhilippe Saint-Pierre fInfoView = new BTextView("info", NULL, &documentColor, B_WILL_DRAW); 1799ce450b9SJohn Scipione fInfoView->SetExplicitMinSize(BSize(210.0, 160.0)); 1809ce450b9SJohn Scipione fInfoView->MakeEditable(false); 1819ce450b9SJohn Scipione fInfoView->SetWordWrap(true); 1829ce450b9SJohn Scipione fInfoView->SetInsets(5.0, 5.0, 5.0, 5.0); 1839ce450b9SJohn Scipione fInfoView->SetStylable(true); 1849ce450b9SJohn Scipione 1859ce450b9SJohn Scipione BScrollView* infoViewScroller = new BScrollView( 1869ce450b9SJohn Scipione "infoViewScroller", fInfoView, B_WILL_DRAW | B_FRAME_EVENTS, 1879ce450b9SJohn Scipione false, true, B_PLAIN_BORDER); 1889ce450b9SJohn Scipione 1899ce450b9SJohn Scipione fStripeView = new StripeView(_GetIconFromSignature(signature)); 1909ce450b9SJohn Scipione 19176a607d2SHumdinger const char* ok = B_TRANSLATE_MARK("OK"); 1929ce450b9SJohn Scipione BButton* closeButton = new BButton("ok", 1939ce450b9SJohn Scipione gSystemCatalog.GetString(ok, "AboutWindow"), 1949ce450b9SJohn Scipione new BMessage(B_QUIT_REQUESTED)); 1959ce450b9SJohn Scipione 1969ce450b9SJohn Scipione GroupLayout()->SetSpacing(0); 1979ce450b9SJohn Scipione BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0) 1989ce450b9SJohn Scipione .Add(fStripeView) 1999ce450b9SJohn Scipione .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) 2009ce450b9SJohn Scipione .SetInsets(0, B_USE_DEFAULT_SPACING, 2019ce450b9SJohn Scipione B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) 2029ce450b9SJohn Scipione .Add(fNameView) 2039ce450b9SJohn Scipione .Add(fVersionView) 2049ce450b9SJohn Scipione .Add(infoViewScroller) 2059ce450b9SJohn Scipione .AddGroup(B_HORIZONTAL, 0) 2069ce450b9SJohn Scipione .AddGlue() 2079ce450b9SJohn Scipione .Add(closeButton) 2089ce450b9SJohn Scipione .End() 2099ce450b9SJohn Scipione .End() 2109ce450b9SJohn Scipione .AddGlue() 211*7a96554cSlooncraz .View()->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 212*7a96554cSlooncraz 2139ce450b9SJohn Scipione } 2149ce450b9SJohn Scipione 2159ce450b9SJohn Scipione 2169ce450b9SJohn Scipione AboutView::~AboutView() 2179ce450b9SJohn Scipione { 2189ce450b9SJohn Scipione } 2199ce450b9SJohn Scipione 2209ce450b9SJohn Scipione 221*7a96554cSlooncraz void 222*7a96554cSlooncraz AboutView::AllAttached() 223*7a96554cSlooncraz { 224*7a96554cSlooncraz fNameView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 225*7a96554cSlooncraz fInfoView->SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR); 226*7a96554cSlooncraz fVersionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 227*7a96554cSlooncraz } 228*7a96554cSlooncraz 229*7a96554cSlooncraz 2309ce450b9SJohn Scipione // #pragma mark - AboutView private methods 2319ce450b9SJohn Scipione 2329ce450b9SJohn Scipione 2339ce450b9SJohn Scipione const char* 2349ce450b9SJohn Scipione AboutView::_GetVersionFromSignature(const char* signature) 2359ce450b9SJohn Scipione { 2369ce450b9SJohn Scipione if (signature == NULL) 2379ce450b9SJohn Scipione return NULL; 2389ce450b9SJohn Scipione 2399ce450b9SJohn Scipione entry_ref ref; 2409ce450b9SJohn Scipione if (be_roster->FindApp(signature, &ref) != B_OK) 2419ce450b9SJohn Scipione return NULL; 2429ce450b9SJohn Scipione 2439ce450b9SJohn Scipione BFile file(&ref, B_READ_ONLY); 2449ce450b9SJohn Scipione BAppFileInfo appMime(&file); 2459ce450b9SJohn Scipione if (appMime.InitCheck() != B_OK) 2469ce450b9SJohn Scipione return NULL; 2479ce450b9SJohn Scipione 2489ce450b9SJohn Scipione version_info versionInfo; 2499ce450b9SJohn Scipione if (appMime.GetVersionInfo(&versionInfo, B_APP_VERSION_KIND) == B_OK) { 2509ce450b9SJohn Scipione if (versionInfo.major == 0 && versionInfo.middle == 0 2519ce450b9SJohn Scipione && versionInfo.minor == 0) { 2529ce450b9SJohn Scipione return NULL; 2539ce450b9SJohn Scipione } 2549ce450b9SJohn Scipione 2559ce450b9SJohn Scipione const char* version = B_TRANSLATE_MARK("Version"); 2569ce450b9SJohn Scipione version = gSystemCatalog.GetString(version, "AboutWindow"); 2579ce450b9SJohn Scipione BString appVersion(version); 2589ce450b9SJohn Scipione appVersion << " " << versionInfo.major << "." << versionInfo.middle; 2599ce450b9SJohn Scipione if (versionInfo.minor > 0) 2609ce450b9SJohn Scipione appVersion << "." << versionInfo.minor; 2619ce450b9SJohn Scipione 2629ce450b9SJohn Scipione // Add the version variety 2639ce450b9SJohn Scipione const char* variety = NULL; 2649ce450b9SJohn Scipione switch (versionInfo.variety) { 2659ce450b9SJohn Scipione case B_DEVELOPMENT_VERSION: 2669ce450b9SJohn Scipione variety = B_TRANSLATE_MARK("development"); 2679ce450b9SJohn Scipione break; 2689ce450b9SJohn Scipione case B_ALPHA_VERSION: 2699ce450b9SJohn Scipione variety = B_TRANSLATE_MARK("alpha"); 2709ce450b9SJohn Scipione break; 2719ce450b9SJohn Scipione case B_BETA_VERSION: 2729ce450b9SJohn Scipione variety = B_TRANSLATE_MARK("beta"); 2739ce450b9SJohn Scipione break; 2749ce450b9SJohn Scipione case B_GAMMA_VERSION: 2759ce450b9SJohn Scipione variety = B_TRANSLATE_MARK("gamma"); 2769ce450b9SJohn Scipione break; 2779ce450b9SJohn Scipione case B_GOLDEN_MASTER_VERSION: 2789ce450b9SJohn Scipione variety = B_TRANSLATE_MARK("gold master"); 2799ce450b9SJohn Scipione break; 2809ce450b9SJohn Scipione } 2819ce450b9SJohn Scipione 2829ce450b9SJohn Scipione if (variety != NULL) { 2839ce450b9SJohn Scipione variety = gSystemCatalog.GetString(variety, "AboutWindow"); 2849ce450b9SJohn Scipione appVersion << "-" << variety; 2859ce450b9SJohn Scipione } 2869ce450b9SJohn Scipione 2879ce450b9SJohn Scipione return appVersion.String(); 2889ce450b9SJohn Scipione } 2899ce450b9SJohn Scipione 2909ce450b9SJohn Scipione return NULL; 2919ce450b9SJohn Scipione } 2929ce450b9SJohn Scipione 2939ce450b9SJohn Scipione 2949ce450b9SJohn Scipione BBitmap* 2959ce450b9SJohn Scipione AboutView::_GetIconFromSignature(const char* signature) 2969ce450b9SJohn Scipione { 2979ce450b9SJohn Scipione if (signature == NULL) 2989ce450b9SJohn Scipione return NULL; 2999ce450b9SJohn Scipione 3009ce450b9SJohn Scipione entry_ref ref; 3019ce450b9SJohn Scipione if (be_roster->FindApp(signature, &ref) != B_OK) 3029ce450b9SJohn Scipione return NULL; 3039ce450b9SJohn Scipione 3049ce450b9SJohn Scipione BFile file(&ref, B_READ_ONLY); 3059ce450b9SJohn Scipione BAppFileInfo appMime(&file); 3069ce450b9SJohn Scipione if (appMime.InitCheck() != B_OK) 3079ce450b9SJohn Scipione return NULL; 3089ce450b9SJohn Scipione 3099ce450b9SJohn Scipione BBitmap* icon = new BBitmap(BRect(0.0, 0.0, 127.0, 127.0), B_RGBA32); 3109ce450b9SJohn Scipione if (appMime.GetIcon(icon, (icon_size)128) == B_OK) 3119ce450b9SJohn Scipione return icon; 3129ce450b9SJohn Scipione 3139ce450b9SJohn Scipione delete icon; 3149ce450b9SJohn Scipione return NULL; 3159ce450b9SJohn Scipione } 3169ce450b9SJohn Scipione 3179ce450b9SJohn Scipione 3189ce450b9SJohn Scipione // #pragma mark - AboutView public methods 3199ce450b9SJohn Scipione 3209ce450b9SJohn Scipione 3219ce450b9SJohn Scipione BBitmap* 3229ce450b9SJohn Scipione AboutView::Icon() 3239ce450b9SJohn Scipione { 3249ce450b9SJohn Scipione if (fStripeView == NULL) 3259ce450b9SJohn Scipione return NULL; 3269ce450b9SJohn Scipione 3279ce450b9SJohn Scipione return fStripeView->Icon(); 3289ce450b9SJohn Scipione } 3299ce450b9SJohn Scipione 3309ce450b9SJohn Scipione 3319ce450b9SJohn Scipione status_t 3329ce450b9SJohn Scipione AboutView::SetIcon(BBitmap* icon) 3339ce450b9SJohn Scipione { 3349ce450b9SJohn Scipione if (fStripeView == NULL) 3359ce450b9SJohn Scipione return B_NO_INIT; 3369ce450b9SJohn Scipione 3379ce450b9SJohn Scipione fStripeView->SetIcon(icon); 3389ce450b9SJohn Scipione 3399ce450b9SJohn Scipione return B_OK; 3409ce450b9SJohn Scipione } 3419ce450b9SJohn Scipione 3429ce450b9SJohn Scipione 3439ce450b9SJohn Scipione const char* 3449ce450b9SJohn Scipione AboutView::Name() 3459ce450b9SJohn Scipione { 3469ce450b9SJohn Scipione return fNameView->Text(); 3479ce450b9SJohn Scipione } 3489ce450b9SJohn Scipione 3499ce450b9SJohn Scipione 3509ce450b9SJohn Scipione status_t 3519ce450b9SJohn Scipione AboutView::SetName(const char* name) 3529ce450b9SJohn Scipione { 3539ce450b9SJohn Scipione fNameView->SetText(name); 3549ce450b9SJohn Scipione 3559ce450b9SJohn Scipione return B_OK; 3569ce450b9SJohn Scipione } 3579ce450b9SJohn Scipione 3589ce450b9SJohn Scipione 3599ce450b9SJohn Scipione const char* 3609ce450b9SJohn Scipione AboutView::Version() 3619ce450b9SJohn Scipione { 3629ce450b9SJohn Scipione return fVersionView->Text(); 3639ce450b9SJohn Scipione } 3649ce450b9SJohn Scipione 3659ce450b9SJohn Scipione 3669ce450b9SJohn Scipione status_t 3679ce450b9SJohn Scipione AboutView::SetVersion(const char* version) 3689ce450b9SJohn Scipione { 3699ce450b9SJohn Scipione fVersionView->SetText(version); 3709ce450b9SJohn Scipione 3719ce450b9SJohn Scipione return B_OK; 3729ce450b9SJohn Scipione } 3739ce450b9SJohn Scipione 3749ce450b9SJohn Scipione 3759ce450b9SJohn Scipione // #pragma mark - BAboutWindow 3769ce450b9SJohn Scipione 3779ce450b9SJohn Scipione 3789ce450b9SJohn Scipione BAboutWindow::BAboutWindow(const char* appName, const char* signature) 3799ce450b9SJohn Scipione : 3809ce450b9SJohn Scipione BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_MODAL_WINDOW, 3819ce450b9SJohn Scipione B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE 3829ce450b9SJohn Scipione | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE) 3839ce450b9SJohn Scipione { 3849ce450b9SJohn Scipione SetLayout(new BGroupLayout(B_VERTICAL)); 3859ce450b9SJohn Scipione 3869ce450b9SJohn Scipione const char* about = B_TRANSLATE_MARK("About %app%"); 3879ce450b9SJohn Scipione about = gSystemCatalog.GetString(about, "AboutWindow"); 3889ce450b9SJohn Scipione 3899ce450b9SJohn Scipione BString title(about); 3909ce450b9SJohn Scipione title.ReplaceFirst("%app%", appName); 3919ce450b9SJohn Scipione SetTitle(title.String()); 3929ce450b9SJohn Scipione 3939ce450b9SJohn Scipione fAboutView = new AboutView(appName, signature); 3949ce450b9SJohn Scipione AddChild(fAboutView); 3959ce450b9SJohn Scipione 3969ce450b9SJohn Scipione MoveTo(AboutPosition(Frame().Width(), Frame().Height())); 3979ce450b9SJohn Scipione } 3989ce450b9SJohn Scipione 3999ce450b9SJohn Scipione 4009ce450b9SJohn Scipione BAboutWindow::~BAboutWindow() 4019ce450b9SJohn Scipione { 4029ce450b9SJohn Scipione fAboutView->RemoveSelf(); 4039ce450b9SJohn Scipione delete fAboutView; 4049ce450b9SJohn Scipione fAboutView = NULL; 4059ce450b9SJohn Scipione } 4069ce450b9SJohn Scipione 4079ce450b9SJohn Scipione 4089ce450b9SJohn Scipione // #pragma mark - BAboutWindow virtual methods 4099ce450b9SJohn Scipione 4109ce450b9SJohn Scipione 4119ce450b9SJohn Scipione void 4129ce450b9SJohn Scipione BAboutWindow::Show() 4139ce450b9SJohn Scipione { 4149ce450b9SJohn Scipione if (IsHidden()) { 4159ce450b9SJohn Scipione // move to current workspace 4169ce450b9SJohn Scipione SetWorkspaces(B_CURRENT_WORKSPACE); 4179ce450b9SJohn Scipione } 4189ce450b9SJohn Scipione 4199ce450b9SJohn Scipione BWindow::Show(); 4209ce450b9SJohn Scipione } 4219ce450b9SJohn Scipione 4229ce450b9SJohn Scipione 4239ce450b9SJohn Scipione // #pragma mark - BAboutWindow public methods 4249ce450b9SJohn Scipione 4259ce450b9SJohn Scipione 4269ce450b9SJohn Scipione BPoint 4279ce450b9SJohn Scipione BAboutWindow::AboutPosition(float width, float height) 4289ce450b9SJohn Scipione { 4299ce450b9SJohn Scipione BPoint result(100, 100); 4309ce450b9SJohn Scipione 4319ce450b9SJohn Scipione BWindow* window = 4329ce450b9SJohn Scipione dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL))); 4339ce450b9SJohn Scipione 4349ce450b9SJohn Scipione BScreen screen(window); 4359ce450b9SJohn Scipione BRect screenFrame(0, 0, 640, 480); 4369ce450b9SJohn Scipione if (screen.IsValid()) 4379ce450b9SJohn Scipione screenFrame = screen.Frame(); 4389ce450b9SJohn Scipione 4399ce450b9SJohn Scipione // Horizontally, we're smack in the middle 4409ce450b9SJohn Scipione result.x = screenFrame.left + (screenFrame.Width() / 2.0) - (width / 2.0); 4419ce450b9SJohn Scipione 4429ce450b9SJohn Scipione // This is probably sooo wrong, but it looks right on 1024 x 768 4439ce450b9SJohn Scipione result.y = screenFrame.top + (screenFrame.Height() / 4.0) 4449ce450b9SJohn Scipione - ceil(height / 3.0); 4459ce450b9SJohn Scipione 4469ce450b9SJohn Scipione return result; 4479ce450b9SJohn Scipione } 4489ce450b9SJohn Scipione 4499ce450b9SJohn Scipione 4509ce450b9SJohn Scipione void 4519ce450b9SJohn Scipione BAboutWindow::AddDescription(const char* description) 4529ce450b9SJohn Scipione { 4539ce450b9SJohn Scipione if (description == NULL) 4549ce450b9SJohn Scipione return; 4559ce450b9SJohn Scipione 4569ce450b9SJohn Scipione AddText(description); 4579ce450b9SJohn Scipione } 4589ce450b9SJohn Scipione 4599ce450b9SJohn Scipione 4609ce450b9SJohn Scipione void 4619ce450b9SJohn Scipione BAboutWindow::AddCopyright(int32 firstCopyrightYear, 4629ce450b9SJohn Scipione const char* copyrightHolder, const char** extraCopyrights) 4639ce450b9SJohn Scipione { 4649ce450b9SJohn Scipione BString copyright(B_UTF8_COPYRIGHT " %years% %holder%"); 4659ce450b9SJohn Scipione 4669ce450b9SJohn Scipione // Get current year 4679ce450b9SJohn Scipione time_t tp; 4689ce450b9SJohn Scipione time(&tp); 4699ce450b9SJohn Scipione char currentYear[5]; 4709ce450b9SJohn Scipione strftime(currentYear, 5, "%Y", localtime(&tp)); 4719ce450b9SJohn Scipione BString copyrightYears; 4729ce450b9SJohn Scipione copyrightYears << firstCopyrightYear; 4739ce450b9SJohn Scipione if (copyrightYears != currentYear) 4749ce450b9SJohn Scipione copyrightYears << "-" << currentYear; 4759ce450b9SJohn Scipione 4769ce450b9SJohn Scipione BString text(""); 4779ce450b9SJohn Scipione if (fAboutView->InfoView()->TextLength() > 0) 4789ce450b9SJohn Scipione text << "\n\n"; 4799ce450b9SJohn Scipione 4809ce450b9SJohn Scipione text << copyright; 4819ce450b9SJohn Scipione 4829ce450b9SJohn Scipione // Fill out the copyright year placeholder 4839ce450b9SJohn Scipione text.ReplaceAll("%years%", copyrightYears.String()); 4849ce450b9SJohn Scipione 4859ce450b9SJohn Scipione // Fill in the copyright holder placeholder 4869ce450b9SJohn Scipione text.ReplaceAll("%holder%", copyrightHolder); 4879ce450b9SJohn Scipione 4889ce450b9SJohn Scipione // Add extra copyright strings 4899ce450b9SJohn Scipione if (extraCopyrights != NULL) { 4909ce450b9SJohn Scipione // Add optional extra copyright information 4919ce450b9SJohn Scipione for (int32 i = 0; extraCopyrights[i]; i++) 4929ce450b9SJohn Scipione text << "\n" << B_UTF8_COPYRIGHT << " " << extraCopyrights[i]; 4939ce450b9SJohn Scipione } 4949ce450b9SJohn Scipione 4959ce450b9SJohn Scipione const char* allRightsReserved = B_TRANSLATE_MARK("All Rights Reserved."); 4969ce450b9SJohn Scipione allRightsReserved = gSystemCatalog.GetString(allRightsReserved, 4979ce450b9SJohn Scipione "AboutWindow"); 4989ce450b9SJohn Scipione text << "\n " << allRightsReserved; 4999ce450b9SJohn Scipione 5009ce450b9SJohn Scipione fAboutView->InfoView()->Insert(text.String()); 5019ce450b9SJohn Scipione } 5029ce450b9SJohn Scipione 5039ce450b9SJohn Scipione 5049ce450b9SJohn Scipione void 5059ce450b9SJohn Scipione BAboutWindow::AddAuthors(const char** authors) 5069ce450b9SJohn Scipione { 5079ce450b9SJohn Scipione if (authors == NULL) 5089ce450b9SJohn Scipione return; 5099ce450b9SJohn Scipione 5109ce450b9SJohn Scipione const char* writtenBy = B_TRANSLATE_MARK("Written by:"); 5119ce450b9SJohn Scipione writtenBy = gSystemCatalog.GetString(writtenBy, "AboutWindow"); 5129ce450b9SJohn Scipione 5139ce450b9SJohn Scipione AddText(writtenBy, authors); 5149ce450b9SJohn Scipione } 5159ce450b9SJohn Scipione 5169ce450b9SJohn Scipione 5179ce450b9SJohn Scipione void 5189ce450b9SJohn Scipione BAboutWindow::AddSpecialThanks(const char** thanks) 5199ce450b9SJohn Scipione { 5209ce450b9SJohn Scipione if (thanks == NULL) 5219ce450b9SJohn Scipione return; 5229ce450b9SJohn Scipione 5239ce450b9SJohn Scipione const char* specialThanks = B_TRANSLATE_MARK("Special Thanks:"); 5249ce450b9SJohn Scipione specialThanks = gSystemCatalog.GetString(specialThanks, "AboutWindow"); 5259ce450b9SJohn Scipione 5269ce450b9SJohn Scipione AddText(specialThanks, thanks); 5279ce450b9SJohn Scipione } 5289ce450b9SJohn Scipione 5299ce450b9SJohn Scipione 5309ce450b9SJohn Scipione void 5319ce450b9SJohn Scipione BAboutWindow::AddVersionHistory(const char** history) 5329ce450b9SJohn Scipione { 5339ce450b9SJohn Scipione if (history == NULL) 5349ce450b9SJohn Scipione return; 5359ce450b9SJohn Scipione 5369ce450b9SJohn Scipione const char* versionHistory = B_TRANSLATE_MARK("Version history:"); 5379ce450b9SJohn Scipione versionHistory = gSystemCatalog.GetString(versionHistory, "AboutWindow"); 5389ce450b9SJohn Scipione 5399ce450b9SJohn Scipione AddText(versionHistory, history); 5409ce450b9SJohn Scipione } 5419ce450b9SJohn Scipione 5429ce450b9SJohn Scipione 5439ce450b9SJohn Scipione void 5449ce450b9SJohn Scipione BAboutWindow::AddExtraInfo(const char* extraInfo) 5459ce450b9SJohn Scipione { 5469ce450b9SJohn Scipione if (extraInfo == NULL) 5479ce450b9SJohn Scipione return; 5489ce450b9SJohn Scipione 5499ce450b9SJohn Scipione const char* appExtraInfo = B_TRANSLATE_MARK(extraInfo); 5509ce450b9SJohn Scipione appExtraInfo = gSystemCatalog.GetString(extraInfo, "AboutWindow"); 5519ce450b9SJohn Scipione 5529ce450b9SJohn Scipione BString extra(""); 5539ce450b9SJohn Scipione if (fAboutView->InfoView()->TextLength() > 0) 5549ce450b9SJohn Scipione extra << "\n\n"; 5559ce450b9SJohn Scipione 5569ce450b9SJohn Scipione extra << appExtraInfo; 5579ce450b9SJohn Scipione 5589ce450b9SJohn Scipione fAboutView->InfoView()->Insert(extra.String()); 5599ce450b9SJohn Scipione } 5609ce450b9SJohn Scipione 5619ce450b9SJohn Scipione 5629ce450b9SJohn Scipione void 5639ce450b9SJohn Scipione BAboutWindow::AddText(const char* header, const char** contents) 5649ce450b9SJohn Scipione { 5659ce450b9SJohn Scipione BTextView* infoView = fAboutView->InfoView(); 5669ce450b9SJohn Scipione int32 textLength = infoView->TextLength(); 5679ce450b9SJohn Scipione BString text(""); 5689ce450b9SJohn Scipione 5699ce450b9SJohn Scipione if (textLength > 0) { 5709ce450b9SJohn Scipione text << "\n\n"; 5719ce450b9SJohn Scipione textLength += 2; 5729ce450b9SJohn Scipione } 5739ce450b9SJohn Scipione 5749ce450b9SJohn Scipione const char* indent = ""; 5759ce450b9SJohn Scipione if (header != NULL) { 5769ce450b9SJohn Scipione indent = " "; 5779ce450b9SJohn Scipione text << header; 5789ce450b9SJohn Scipione } 5799ce450b9SJohn Scipione 5809ce450b9SJohn Scipione if (contents != NULL) { 5819ce450b9SJohn Scipione text << "\n"; 5829ce450b9SJohn Scipione for (int32 i = 0; contents[i]; i++) 5839ce450b9SJohn Scipione text << indent << contents[i] << "\n"; 5849ce450b9SJohn Scipione } 5859ce450b9SJohn Scipione 5869ce450b9SJohn Scipione infoView->Insert(text.String()); 5879ce450b9SJohn Scipione 5889ce450b9SJohn Scipione if (contents != NULL && header != NULL) { 5899ce450b9SJohn Scipione infoView->SetFontAndColor(textLength, textLength + strlen(header), 5909ce450b9SJohn Scipione be_bold_font); 5919ce450b9SJohn Scipione } 5929ce450b9SJohn Scipione } 5939ce450b9SJohn Scipione 5949ce450b9SJohn Scipione 5959ce450b9SJohn Scipione BBitmap* 5969ce450b9SJohn Scipione BAboutWindow::Icon() 5979ce450b9SJohn Scipione { 5989ce450b9SJohn Scipione return fAboutView->Icon(); 5999ce450b9SJohn Scipione } 6009ce450b9SJohn Scipione 6019ce450b9SJohn Scipione 6029ce450b9SJohn Scipione void 6039ce450b9SJohn Scipione BAboutWindow::SetIcon(BBitmap* icon) 6049ce450b9SJohn Scipione { 6059ce450b9SJohn Scipione fAboutView->SetIcon(icon); 6069ce450b9SJohn Scipione } 6079ce450b9SJohn Scipione 6089ce450b9SJohn Scipione 6099ce450b9SJohn Scipione const char* 6109ce450b9SJohn Scipione BAboutWindow::Name() 6119ce450b9SJohn Scipione { 6129ce450b9SJohn Scipione return fAboutView->Name(); 6139ce450b9SJohn Scipione } 6149ce450b9SJohn Scipione 6159ce450b9SJohn Scipione 6169ce450b9SJohn Scipione void 6179ce450b9SJohn Scipione BAboutWindow::SetName(const char* name) 6189ce450b9SJohn Scipione { 6199ce450b9SJohn Scipione fAboutView->SetName(name); 6209ce450b9SJohn Scipione } 6219ce450b9SJohn Scipione 6229ce450b9SJohn Scipione 6239ce450b9SJohn Scipione const char* 6249ce450b9SJohn Scipione BAboutWindow::Version() 6259ce450b9SJohn Scipione { 6269ce450b9SJohn Scipione return fAboutView->Version(); 6279ce450b9SJohn Scipione } 6289ce450b9SJohn Scipione 6299ce450b9SJohn Scipione 6309ce450b9SJohn Scipione void 6319ce450b9SJohn Scipione BAboutWindow::SetVersion(const char* version) 6329ce450b9SJohn Scipione { 6339ce450b9SJohn Scipione fAboutView->SetVersion(version); 6349ce450b9SJohn Scipione } 6359ce450b9SJohn Scipione 6369ce450b9SJohn Scipione 6379ce450b9SJohn Scipione // FBC padding 6389ce450b9SJohn Scipione 6399ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow20() {} 6409ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow19() {} 6419ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow18() {} 6429ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow17() {} 6439ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow16() {} 6449ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow15() {} 6459ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow14() {} 6469ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow13() {} 6479ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow12() {} 6489ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow11() {} 6499ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow10() {} 6509ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow9() {} 6519ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow8() {} 6529ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow7() {} 6539ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow6() {} 6549ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow5() {} 6559ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow4() {} 6569ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow3() {} 6579ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow2() {} 6589ce450b9SJohn Scipione void BAboutWindow::_ReservedAboutWindow1() {} 659