diff --git a/headers/private/interface/AboutWindow.h b/headers/private/interface/AboutWindow.h new file mode 100644 index 0000000000..7b731fcca8 --- /dev/null +++ b/headers/private/interface/AboutWindow.h @@ -0,0 +1,28 @@ +/* + * Copyright 2007 Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ryan Leavengood, leavengood@gmail.com + */ +#ifndef B_ABOUT_WINDOW_H +#define B_ABOUT_WINDOW_H + + +#include + + +class BAboutWindow { + public: + BAboutWindow(char *appName, int32 firstCopyrightYear, + int32 numAuthors, const char **authors, char *extraInfo = NULL); + virtual ~BAboutWindow(); + + void Show(); + + private: + BString* fAppName; + BString* fText; +}; + +#endif // B_ABOUT_WINDOW_H diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index dbcd86020e..87d24a0219 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src apps showimage ; -UsePrivateHeaders tracker ; +UsePrivateHeaders tracker interface ; SetSubDirSupportedPlatformsBeOSCompatible ; diff --git a/src/apps/showimage/ShowImageApp.cpp b/src/apps/showimage/ShowImageApp.cpp index cb7cf539e1..f924541103 100644 --- a/src/apps/showimage/ShowImageApp.cpp +++ b/src/apps/showimage/ShowImageApp.cpp @@ -14,6 +14,9 @@ #include "ShowImageConstants.h" #include "ShowImageWindow.h" +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +#include +#endif #include #include #include @@ -44,9 +47,20 @@ ShowImageApp::~ShowImageApp() void ShowImageApp::AboutRequested() { +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + const char *authors[] = { + "Fernando F. Oliveira", + "Michael Wilber", + "Michael Pfeiffer", + "Ryan Leavengood" + }; + BAboutWindow about("ShowImage", 2003, 4, authors); + about.Show(); +#else BAlert* alert = new BAlert("About ShowImage", "Haiku ShowImage\n\nby Fernando F. Oliveira, Michael Wilber, Michael Pfeiffer and Ryan Leavengood", "OK"); alert->Go(); +#endif } diff --git a/src/kits/interface/AboutWindow.cpp b/src/kits/interface/AboutWindow.cpp new file mode 100644 index 0000000000..3a0ff59358 --- /dev/null +++ b/src/kits/interface/AboutWindow.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2007 Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ryan Leavengood, leavengood@gmail.com + */ + +#include +#include +#include +#include +#include + +#include + + +BAboutWindow::BAboutWindow(char *appName, int32 firstCopyrightYear, + int32 numAuthors, const char **authors, char *extraInfo) +{ + fAppName = new BString(appName); + fText = new BString(); + + // Get current year + time_t tp; + time(&tp); + char currentYear[5]; + strftime(currentYear, 5, "%Y", localtime(&tp)); + + // Build the text to display + BString text(appName); + text << "\n\nCopyright " B_UTF8_COPYRIGHT " "; + text << firstCopyrightYear << "-" << currentYear << " Haiku, Inc.\n\n"; + text << "Written by:\n"; + for (int32 i = 0; i < numAuthors; i++) { + text << " " << authors[i] << "\n"; + } + if (extraInfo != NULL) { + text << "\n" << extraInfo << "\n"; + } + fText->Adopt(text); +} + + +BAboutWindow::~BAboutWindow() +{ + delete fText; +} + + +void +BAboutWindow::Show() +{ + BAlert *alert = new BAlert("About...", fText->String(), "Close"); + BTextView *view = alert->TextView(); + BFont font; + view->SetStylable(true); + view->GetFont(&font); + font.SetFace(B_BOLD_FACE); + font.SetSize(font.Size() * 1.7); + view->SetFontAndColor(0, fAppName->Length(), &font); + alert->Go(); +} + diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index abdfbd6c2f..cfc948f434 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -37,6 +37,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ; MergeObject interface_kit.o : + AboutWindow.cpp AbstractLayoutItem.cpp Alert.cpp Alignment.cpp