btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / bootmanager / WizardPageView.cpp
blob25b641925614b3a1c2ac34685c6598e52efdb07c
1 /*
2 * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 */
10 #include "WizardPageView.h"
12 #include <math.h>
13 #include <string.h>
15 #include <TextView.h>
18 WizardPageView::WizardPageView(BMessage* settings, BRect frame,
19 const char* name, uint32 resizingMode, uint32 flags)
21 BView(frame, name, resizingMode, flags),
22 fSettings(settings)
24 SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
28 WizardPageView::WizardPageView(BMessage* settings, const char* name)
30 BView(name, B_WILL_DRAW),
31 fSettings(settings)
33 SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
37 WizardPageView::~WizardPageView()
42 void
43 WizardPageView::PageCompleted()
48 BTextView*
49 WizardPageView::CreateDescription(BRect frame, const char* name,
50 const char* description)
52 BTextView* view = new BTextView(frame, "text",
53 frame.OffsetToCopy(0, 0),
54 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
55 B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS);
56 view->MakeEditable(false);
57 view->SetViewUIColor(ViewUIColor());
58 view->SetStylable(true);
59 view->SetText(description);
61 return view;
65 BTextView*
66 WizardPageView::CreateDescription(const char* name,
67 const char* description)
69 BTextView* view = new BTextView("text");
70 view->MakeEditable(false);
71 view->SetViewUIColor(ViewUIColor());
72 view->SetStylable(true);
73 view->SetText(description);
75 return view;
79 void
80 WizardPageView::MakeHeading(BTextView* view)
82 const char* text = view->Text();
83 const char* firstLineEnd = strchr(text, '\n');
84 if (firstLineEnd != NULL) {
85 int indexFirstLineEnd = firstLineEnd - text;
86 BFont font;
87 view->GetFont(&font);
88 font.SetFace(B_BOLD_FACE);
89 font.SetSize(font.Size() + 1);
90 rgb_color color = ui_color(B_PANEL_TEXT_COLOR);
91 view->SetFontAndColor(0, indexFirstLineEnd, &font, B_FONT_ALL,
92 &color);
94 font.SetFace(B_REGULAR_FACE);
95 font.SetSize(font.Size() - 1);
96 view->SetFontAndColor(indexFirstLineEnd + 1, view->TextLength(),
97 &font, B_FONT_ALL, &color);
102 void
103 WizardPageView::LayoutDescriptionVertically(BTextView* view)
105 view->SetTextRect(view->Bounds());
107 float height = view->TextHeight(0, 32000);
108 float width = view->Bounds().Width();
110 view->ResizeTo(width, height);
111 view->SetTextRect(view->Bounds());