docs/ikteam: Delete most files.
[haiku.git] / src / preferences / filetypes / StringView.cpp
blobc67ed7242a0c934ff773842b7015337062cb3a45
1 /*
2 * Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <GroupView.h>
8 #include <LayoutItem.h>
9 #include <StringView.h>
11 #include "StringView.h"
14 StringView::StringView(const char* label, const char* text)
16 fView(NULL),
17 fLabel(new BStringView(NULL, label)),
18 fLabelItem(NULL),
19 fText(new BStringView(NULL, text)),
20 fTextItem(NULL)
25 void
26 StringView::SetLabel(const char* label)
28 fLabel->SetText(label);
32 void
33 StringView::SetText(const char* text)
35 fText->SetText(text);
39 BLayoutItem*
40 StringView::GetLabelLayoutItem()
42 return fLabelItem;
46 BView*
47 StringView::LabelView()
48 { return fLabel; }
51 BLayoutItem*
52 StringView::GetTextLayoutItem()
54 return fTextItem;
58 BView*
59 StringView::TextView()
60 { return fText; }
63 void
64 StringView::SetEnabled(bool enabled)
67 rgb_color color;
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);
75 fLabel->SetHighColor(color);
76 fText->SetHighColor(color);
77 fLabel->Invalidate();
78 fText->Invalidate();
82 //cast operator BView*
83 StringView::operator BView*()
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;
95 const char*
96 StringView::Label() const
98 return fLabel->Text();
102 const char*
103 StringView::Text() const
105 return fText->Text();