1 /*
2 * Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7 #include <GroupView.h>
8 #include <LayoutItem.h>
9 #include <StringView.h>
10
11 #include "StringView.h"
12
13
StringView(const char * label,const char * text)14 StringView::StringView(const char* label, const char* text)
15 :
16 fView(NULL),
17 fLabel(new BStringView(NULL, label)),
18 fLabelItem(NULL),
19 fText(new BStringView(NULL, text)),
20 fTextItem(NULL)
21 {
22 }
23
24
25 void
SetLabel(const char * label)26 StringView::SetLabel(const char* label)
27 {
28 fLabel->SetText(label);
29 }
30
31
32 void
SetText(const char * text)33 StringView::SetText(const char* text)
34 {
35 fText->SetText(text);
36 }
37
38
39 BLayoutItem*
GetLabelLayoutItem()40 StringView::GetLabelLayoutItem()
41 {
42 return fLabelItem;
43 }
44
45
46 BView*
LabelView()47 StringView::LabelView()
48 { return fLabel; }
49
50
51 BLayoutItem*
GetTextLayoutItem()52 StringView::GetTextLayoutItem()
53 {
54 return fTextItem;
55 }
56
57
58 BView*
TextView()59 StringView::TextView()
60 { return fText; }
61
62
63 void
SetEnabled(bool enabled)64 StringView::SetEnabled(bool enabled)
65 {
66
67 rgb_color color;
68
69 if (!enabled) {
70 color = tint_color(
71 ui_color(B_PANEL_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT);
72 } else
73 color = ui_color(B_CONTROL_TEXT_COLOR);
74
75 fLabel->SetHighColor(color);
76 fText->SetHighColor(color);
77 fLabel->Invalidate();
78 fText->Invalidate();
79 }
80
81
82 //cast operator BView*
operator BView*()83 StringView::operator BView*()
84 {
85 if (fView)
86 return fView;
87 fView = new BGroupView(B_HORIZONTAL);
88 BLayout* layout = fView->GroupLayout();
89 fLabelItem = layout->AddView(fLabel);
90 fTextItem = layout->AddView(fText);
91 return fView;
92 }
93
94
95 const char*
Label() const96 StringView::Label() const
97 {
98 return fLabel->Text();
99 }
100
101
102 const char*
Text() const103 StringView::Text() const
104 {
105 return fText->Text();
106 }
107
108