2 * Copyright (c) 2007-2014, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
6 * Łukasz 'Sil2100' Zemczak <sil2100@vexillium.org>
7 * Stephan Aßmus <superstippi@gmx.de>
11 #include "PackageTextViewer.h"
15 #include <LayoutBuilder.h>
17 #include <ScrollView.h>
21 P_MSG_ACCEPT
= 'pmac',
25 #undef B_TRANSLATION_CONTEXT
26 #define B_TRANSLATION_CONTEXT "PackageTextViewer"
29 PackageTextViewer::PackageTextViewer(const char *text
, bool disclaimer
)
31 BlockingWindow(BRect(125, 125, 675, 475), B_TRANSLATE("Disclaimer"),
32 B_AUTO_UPDATE_SIZE_LIMITS
)
34 _InitView(text
, disclaimer
);
40 PackageTextViewer::MessageReceived(BMessage
* message
)
42 switch (message
->what
) {
52 BWindow::MessageReceived(message
);
62 PackageTextViewer::_InitView(const char* text
, bool disclaimer
)
64 BTextView
* textView
= new BTextView("text_view");
65 textView
->MakeEditable(false);
66 textView
->MakeSelectable(true);
67 float margin
= ceilf(be_plain_font
->Size());
68 textView
->SetInsets(margin
, margin
, margin
, margin
);
69 BScrollView
* scrollView
= new BScrollView("scroll_view", textView
, 0, false,
72 BButton
* defaultButton
;
75 defaultButton
= new BButton("accept", B_TRANSLATE("Accept"),
76 new BMessage(P_MSG_ACCEPT
));
78 BButton
* decline
= new BButton("decline", B_TRANSLATE("Decline"),
79 new BMessage(P_MSG_DECLINE
));
81 BLayoutBuilder::Group
<>(this, B_VERTICAL
)
83 .AddGroup(B_HORIZONTAL
)
88 .SetInsets(B_USE_WINDOW_INSETS
)
91 defaultButton
= new BButton("accept", B_TRANSLATE("Continue"),
92 new BMessage(P_MSG_ACCEPT
));
94 BLayoutBuilder::Group
<>(this, B_VERTICAL
)
96 .AddGroup(B_HORIZONTAL
)
100 .SetInsets(B_USE_WINDOW_INSETS
)
104 defaultButton
->MakeDefault(true);
106 textView
->SetText(text
);