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 "FloatValueView.h"
10
11#include <stdio.h>
12
13#include "NummericalTextView.h"
14
15// constructor
16FloatValueView::FloatValueView(FloatProperty* property)
17	: TextInputValueView(),
18	  fProperty(property)
19{
20	BRect b = Bounds();
21	fTextView = new NummericalTextView(b, "nummerical input", b,
22									   B_FOLLOW_LEFT | B_FOLLOW_TOP,
23									   B_WILL_DRAW);
24
25	AddChild(fTextView);
26	fTextView->SetFloatMode(true);
27
28	if (fProperty)
29		fTextView->SetValue(fProperty->Value());
30}
31
32// destructor
33FloatValueView::~FloatValueView()
34{
35}
36
37// TextView
38InputTextView*
39FloatValueView::TextView() const
40{
41	return fTextView;
42}
43
44// ValueChanged
45void
46FloatValueView::ValueChanged()
47{
48	if (fProperty) {
49		fProperty->SetValue(fTextView->FloatValue());
50		fTextView->SetValue(fProperty->Value());
51		TextInputValueView::ValueChanged();
52	}
53}
54
55// AdoptProperty
56bool
57FloatValueView::AdoptProperty(Property* property)
58{
59	FloatProperty* p = dynamic_cast<FloatProperty*>(property);
60	if (p) {
61		if (fTextView->FloatValue() != p->Value())
62			fTextView->SetValue(p->Value());
63		fProperty = p;
64		return true;
65	}
66	return false;
67}
68
69// GetProperty
70Property*
71FloatValueView::GetProperty() const
72{
73	return fProperty;
74}
75
76
77
78