* Copyright 2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
*/
#include "PropertyEditorView.h"
#include <stdio.h>
#include "Property.h"
#include "PropertyItemView.h"
PropertyEditorView::PropertyEditorView()
: BView(BRect(0.0, 0.0, 10.0, 10.0), "property item",
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE),
fParent(NULL),
fSelected(false)
{
}
PropertyEditorView::~PropertyEditorView()
{
}
void
PropertyEditorView::Draw(BRect updateRect)
{
FillRect(Bounds(), B_SOLID_LOW);
}
void
PropertyEditorView::MouseDown(BPoint where)
{
if (fParent) {
fParent->MouseDown(ConvertToParent(where));
}
}
void
PropertyEditorView::MouseUp(BPoint where)
{
if (fParent) {
fParent->MouseUp(ConvertToParent(where));
}
}
void
PropertyEditorView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{
if (fParent) {
fParent->MouseMoved(ConvertToParent(where), transit, dragMessage);
}
}
float
PropertyEditorView::PreferredHeight() const
{
font_height fh;
GetFontHeight(&fh);
float height = floorf(4.0 + fh.ascent + fh.descent);
return height;
}
void
PropertyEditorView::SetSelected(bool selected)
{
fSelected = selected;
}
void
PropertyEditorView::SetItemView(PropertyItemView* parent)
{
fParent = parent;
if (fParent) {
BFont font;
fParent->GetFont(&font);
SetFont(&font);
SetLowColor(fParent->LowColor());
}
}
void
PropertyEditorView::ValueChanged()
{
if (fParent)
fParent->UpdateObject();
}