1/*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan A��mus <superstippi@gmx.de>
7 */
8
9#include "PropertyEditorView.h"
10
11#include <stdio.h>
12
13#include "Property.h"
14#include "PropertyItemView.h"
15
16// constructor
17PropertyEditorView::PropertyEditorView()
18	: BView(BRect(0.0, 0.0, 10.0, 10.0), "property item",
19			B_FOLLOW_LEFT | B_FOLLOW_TOP,
20			B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE),
21	  fParent(NULL),
22	  fSelected(false)
23{
24}
25
26// destructor
27PropertyEditorView::~PropertyEditorView()
28{
29}
30
31// Draw
32void
33PropertyEditorView::Draw(BRect updateRect)
34{
35	// just draw background
36	FillRect(Bounds(), B_SOLID_LOW);
37}
38
39// MouseDown
40void
41PropertyEditorView::MouseDown(BPoint where)
42{
43	if (fParent) {
44		// forward click
45		fParent->MouseDown(ConvertToParent(where));
46	}
47}
48
49// MouseUp
50void
51PropertyEditorView::MouseUp(BPoint where)
52{
53	if (fParent) {
54		// forward click
55		fParent->MouseUp(ConvertToParent(where));
56	}
57}
58
59// MouseMoved
60void
61PropertyEditorView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
62{
63	if (fParent) {
64		// forward click
65		fParent->MouseMoved(ConvertToParent(where), transit, dragMessage);
66	}
67}
68
69// PreferredHeight
70float
71PropertyEditorView::PreferredHeight() const
72{
73	font_height fh;
74	GetFontHeight(&fh);
75
76	float height = floorf(4.0 + fh.ascent + fh.descent);
77
78	return height;
79}
80
81// SetSelected
82void
83PropertyEditorView::SetSelected(bool selected)
84{
85	fSelected = selected;
86}
87
88// SetItemView
89void
90PropertyEditorView::SetItemView(PropertyItemView* parent)
91{
92	fParent = parent;
93	if (fParent) {
94		BFont font;
95		fParent->GetFont(&font);
96		SetFont(&font);
97		SetLowColor(fParent->LowColor());
98	}
99}
100
101// ValueChanged
102void
103PropertyEditorView::ValueChanged()
104{
105	if (fParent)
106		fParent->UpdateObject();
107}
108
109