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
14StringView::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
25void
26StringView::SetLabel(const char* label)
27{
28	fLabel->SetText(label);
29}
30
31
32void
33StringView::SetText(const char* text)
34{
35	fText->SetText(text);
36}
37
38
39BLayoutItem*
40StringView::GetLabelLayoutItem()
41{
42	return fLabelItem;
43}
44
45
46BView*
47StringView::LabelView()
48{ return fLabel; }
49
50
51BLayoutItem*
52StringView::GetTextLayoutItem()
53{
54	return fTextItem;
55}
56
57
58BView*
59StringView::TextView()
60{ return fText; }
61
62
63void
64StringView::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*
83StringView::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
95const char*
96StringView::Label() const
97{
98	return fLabel->Text();
99}
100
101
102const char*
103StringView::Text() const
104{
105	return fText->Text();
106}
107
108