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 18WizardPageView::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 SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 25} 26 27 28WizardPageView::WizardPageView(BMessage* settings, const char* name) 29 : 30 BView(name, B_WILL_DRAW), 31 fSettings(settings) 32{ 33 SetViewUIColor(B_PANEL_BACKGROUND_COLOR); 34} 35 36 37WizardPageView::~WizardPageView() 38{ 39} 40 41 42void 43WizardPageView::PageCompleted() 44{ 45} 46 47 48BTextView* 49WizardPageView::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->SetViewUIColor(ViewUIColor()); 58 view->SetStylable(true); 59 view->SetText(description); 60 61 return view; 62} 63 64 65BTextView* 66WizardPageView::CreateDescription(const char* name, 67 const char* description) 68{ 69 BTextView* view = new BTextView("text"); 70 view->MakeEditable(false); 71 view->SetViewUIColor(ViewUIColor()); 72 view->SetStylable(true); 73 view->SetText(description); 74 75 return view; 76} 77 78 79void 80WizardPageView::MakeHeading(BTextView* view) 81{ 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); 93 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); 98 } 99} 100 101 102void 103WizardPageView::LayoutDescriptionVertically(BTextView* view) 104{ 105 view->SetTextRect(view->Bounds()); 106 107 float height = view->TextHeight(0, 32000); 108 float width = view->Bounds().Width(); 109 110 view->ResizeTo(width, height); 111 view->SetTextRect(view->Bounds()); 112} 113 114