xref: /haiku/src/apps/bootmanager/WizardPageView.cpp (revision 220d04022750f40f8bac8f01fa551211e28d04f2)
1 /*
2  * Copyright 2008-2011, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Pfeiffer <laplace@users.sourceforge.net>
7  */
8 
9 
10 #include "WizardPageView.h"
11 
12 #include <math.h>
13 #include <string.h>
14 
15 #include <TextView.h>
16 
17 
18 WizardPageView::WizardPageView(BMessage* settings, BRect frame,
19 	const char* name, uint32 resizingMode, uint32 flags)
20 	:
21 	BView(frame, name, resizingMode, flags),
22 	fSettings(settings)
23 {
24 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
25 }
26 
27 
28 WizardPageView::WizardPageView(BMessage* settings, const char* name)
29 	:
30 	BView(name, B_WILL_DRAW),
31 	fSettings(settings)
32 {
33 	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
34 }
35 
36 
37 WizardPageView::~WizardPageView()
38 {
39 }
40 
41 
42 void
43 WizardPageView::PageCompleted()
44 {
45 }
46 
47 
48 BTextView*
49 WizardPageView::CreateDescription(BRect frame, const char* name,
50 	const char* description)
51 {
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->SetViewColor(ViewColor());
58 	view->SetStylable(true);
59 	view->SetText(description);
60 	return view;
61 }
62 
63 
64 BTextView*
65 WizardPageView::CreateDescription(const char* name,
66 	const char* description)
67 {
68 	BTextView* view = new BTextView("text");
69 	view->MakeEditable(false);
70 	view->SetViewColor(ViewColor());
71 	view->SetStylable(true);
72 	view->SetText(description);
73 	return view;
74 }
75 
76 
77 void
78 WizardPageView::MakeHeading(BTextView* view)
79 {
80 	const char* text = view->Text();
81 	const char* firstLineEnd = strchr(text, '\n');
82 	if (firstLineEnd != NULL) {
83 		int indexFirstLineEnd = firstLineEnd - text;
84 		BFont font;
85 		view->GetFont(&font);
86 		font.SetFace(B_BOLD_FACE);
87 		view->SetFontAndColor(0, indexFirstLineEnd, &font);
88 	}
89 }
90 
91 
92 void
93 WizardPageView::LayoutDescriptionVertically(BTextView* view)
94 {
95 	view->SetTextRect(view->Bounds());
96 
97 	float height = view->TextHeight(0, 32000);
98 	float width = view->Bounds().Width();
99 
100 	view->ResizeTo(width, height);
101 	view->SetTextRect(view->Bounds());
102 }
103 
104