2 * Copyright 2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Artur Wyszynski <harakash@gmail.com>
7 * Modified by Pieter Panman
10 #include "PropertyListPlain.h"
12 #include <GridLayout.h>
13 #include <GridLayoutBuilder.h>
14 #include <GroupLayout.h>
15 #include <GroupLayoutBuilder.h>
17 #include <SpaceLayoutItem.h>
19 #include <StringView.h>
25 PropertyListPlain::PropertyListPlain(const char* name
)
29 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
30 SetLayout(new BGroupLayout(B_VERTICAL
));
34 PropertyListPlain::~PropertyListPlain()
41 PropertyListPlain::AddAttributes(const Attributes
& attributes
)
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
));
65 fAttributeViews
.AddItem(view
);
71 PropertyListPlain::RemoveAll()
74 while ((child
= ChildAt(0))) {
82 PropertyListPlain::MessageReceived(BMessage
* message
)
84 switch (message
->what
) {
85 case B_COLORS_UPDATED
:
88 if (message
->FindColor(ui_color_name(B_PANEL_TEXT_COLOR
), &color
)
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
);
102 BView::MessageReceived(message
);
108 PropertyListPlain::AttachedToWindow()
114 PropertyListPlain::DetachedFromWindow()