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