btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / kits / interface / ZombieReplicantView.cpp
blobf9c6dcd2dceec895a17541ac8ce51ecbb35e51df
1 /*
2 * Copyright 2001-2010, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Marc Flerackers (mflerackers@androme.be)
7 */
9 #include <Alert.h>
10 #include <Message.h>
11 #include <MimeType.h>
12 #include <String.h>
13 #include <SystemCatalog.h>
15 #include "ZombieReplicantView.h"
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <new>
22 using BPrivate::gSystemCatalog;
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "ZombieReplicantView"
27 #undef B_TRANSLATE
28 #define B_TRANSLATE(str) \
29 gSystemCatalog.GetString(B_TRANSLATE_MARK(str), "ZombieReplicantView")
32 _BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error)
34 BBox(frame, "<Zombie>", B_FOLLOW_NONE, B_WILL_DRAW),
35 fError(error)
37 BFont font(be_bold_font);
38 font.SetSize(9.0f); // TODO
39 SetFont(&font);
40 SetViewColor(kZombieColor);
44 _BZombieReplicantView_::~_BZombieReplicantView_()
49 void
50 _BZombieReplicantView_::MessageReceived(BMessage* msg)
52 switch (msg->what) {
53 case B_ABOUT_REQUESTED:
55 const char* addOn = NULL;
56 BString error;
57 if (fArchive->FindString("add_on", &addOn) == B_OK) {
58 char description[B_MIME_TYPE_LENGTH] = "";
59 BMimeType type(addOn);
60 type.GetShortDescription(description);
61 error = B_TRANSLATE("Cannot create the replicant for "
62 "\"%description\".\n%error");
63 error.ReplaceFirst("%description", description);
64 } else
65 error = B_TRANSLATE("Cannot locate the application for the "
66 "replicant. No application signature supplied.\n%error");
68 error.ReplaceFirst("%error", strerror(fError));
70 BAlert* alert = new (std::nothrow) BAlert(B_TRANSLATE("Error"),
71 error.String(), B_TRANSLATE("OK"), NULL, NULL,
72 B_WIDTH_AS_USUAL, B_STOP_ALERT);
73 if (alert != NULL) {
74 alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
75 alert->Go();
78 break;
80 default:
81 BView::MessageReceived(msg);
86 void
87 _BZombieReplicantView_::Draw(BRect updateRect)
89 BRect bounds(Bounds());
90 font_height fh;
92 GetFontHeight(&fh);
94 DrawChar('?', BPoint(bounds.Width() / 2.0f - StringWidth("?") / 2.0f,
95 bounds.Height() / 2.0f - fh.ascent / 2.0f));
97 BBox::Draw(updateRect);
101 void
102 _BZombieReplicantView_::MouseDown(BPoint)
107 status_t
108 _BZombieReplicantView_::Archive(BMessage* archive, bool) const
110 *archive = *fArchive;
112 return B_OK;
116 void
117 _BZombieReplicantView_::SetArchive(BMessage* archive)
119 fArchive = archive;