BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / devices / PropertyListPlain.cpp
blobf8687d50067412a73c909b1922c5f1f35c6fbd67
1 /*
2 * Copyright 2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Author:
6 * Artur Wyszynski <harakash@gmail.com>
7 * Modified by Pieter Panman
8 */
10 #include "PropertyListPlain.h"
12 #include <GridLayout.h>
13 #include <GridLayoutBuilder.h>
14 #include <GroupLayout.h>
15 #include <GroupLayoutBuilder.h>
16 #include <Message.h>
17 #include <SpaceLayoutItem.h>
18 #include <String.h>
19 #include <StringView.h>
20 #include <TextView.h>
22 #include "Device.h"
25 PropertyListPlain::PropertyListPlain(const char* name)
27 BView(name, 0, NULL)
29 SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
30 SetLayout(new BGroupLayout(B_VERTICAL));
34 PropertyListPlain::~PropertyListPlain()
40 void
41 PropertyListPlain::AddAttributes(const Attributes& attributes)
43 RemoveAll();
44 BGroupLayoutBuilder layout(B_VERTICAL);
46 BTextView* view = new BTextView(BRect(0, 0, 1000, 1000),
47 "attribs", BRect(5, 5, 995, 995), B_FOLLOW_ALL_SIDES);
49 rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
50 view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
51 view->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
52 view->MakeEditable(false);
54 for (unsigned int i = 0; i < attributes.size(); i++) {
55 BString attributeLine;
56 attributeLine << attributes[i].fName
57 << "\t" << attributes[i].fValue << "\n";
58 view->Insert(attributeLine);
60 view->SetExplicitAlignment(
61 BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));
63 layout.Add(view);
65 fAttributeViews.AddItem(view);
66 AddChild(layout);
70 void
71 PropertyListPlain::RemoveAll()
73 BView *child;
74 while ((child = ChildAt(0))) {
75 RemoveChild(child);
76 delete child;
81 void
82 PropertyListPlain::MessageReceived(BMessage* message)
84 switch (message->what) {
85 case B_COLORS_UPDATED:
87 rgb_color color;
88 if (message->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &color)
89 != B_OK)
90 break;
92 BTextView* view = NULL;
93 int32 count = fAttributeViews.CountItems();
94 for (int32 index = 0; index < count; ++index) {
95 view = fAttributeViews.ItemAt(index);
96 view->SetFontAndColor(be_plain_font, 0, &color);
98 break;
101 default:
102 BView::MessageReceived(message);
107 void
108 PropertyListPlain::AttachedToWindow()
113 void
114 PropertyListPlain::DetachedFromWindow()