Initial implementation of the common BAboutWindow class. Of course I just
realized that calling it a window may not be strictly correct since it isn't a decendent of BWindow, but just uses a BAlert. Oh well, it can be changed if need be. I'm also checking in the first use of it, in ShowImage. Since ShowImage can still be compiled for R5 I've added a #ifdef around the new BAboutWindow related code. I'm open for suggestions for the interface for this class, well mostly the constructor. I'm not a big fan of having to specify the number of authors. For now I'm making the header private, but I don't think it would be a big deal to expose it publically. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21389 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
59ab99e7c6
commit
a8a83855b0
28
headers/private/interface/AboutWindow.h
Normal file
28
headers/private/interface/AboutWindow.h
Normal file
@ -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 <String.h>
|
||||
|
||||
|
||||
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
|
@ -1,6 +1,6 @@
|
||||
SubDir HAIKU_TOP src apps showimage ;
|
||||
|
||||
UsePrivateHeaders tracker ;
|
||||
UsePrivateHeaders tracker interface ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
#include "ShowImageConstants.h"
|
||||
#include "ShowImageWindow.h"
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
#include <AboutWindow.h>
|
||||
#endif
|
||||
#include <Alert.h>
|
||||
#include <Clipboard.h>
|
||||
#include <FilePanel.h>
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
64
src/kits/interface/AboutWindow.cpp
Normal file
64
src/kits/interface/AboutWindow.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2007 Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ryan Leavengood, leavengood@gmail.com
|
||||
*/
|
||||
|
||||
#include <AboutWindow.h>
|
||||
#include <Alert.h>
|
||||
#include <Font.h>
|
||||
#include <String.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
|
||||
|
||||
MergeObject <libbe>interface_kit.o :
|
||||
AboutWindow.cpp
|
||||
AbstractLayoutItem.cpp
|
||||
Alert.cpp
|
||||
Alignment.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user