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 "Int64ValueView.h"
10
11#include <stdio.h>
12
13#include "NummericalTextView.h"
14
15// constructor
16Int64ValueView::Int64ValueView(Int64Property* 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(false);
27
28// TODO: make NummericalTextView support int64?
29	if (fProperty)
30		fTextView->SetValue((int32)fProperty->Value());
31}
32
33// destructor
34Int64ValueView::~Int64ValueView()
35{
36}
37
38// TextView
39InputTextView*
40Int64ValueView::TextView() const
41{
42	return fTextView;
43}
44
45// ValueChanged
46void
47Int64ValueView::ValueChanged()
48{
49	if (fProperty) {
50		fProperty->SetValue(fTextView->IntValue());
51// TODO: make NummericalTextView support int64?
52		fTextView->SetValue((int32)fProperty->Value());
53		TextInputValueView::ValueChanged();
54	}
55}
56
57// AdoptProperty
58bool
59Int64ValueView::AdoptProperty(Property* property)
60{
61	Int64Property* p = dynamic_cast<Int64Property*>(property);
62	if (p) {
63// TODO: make NummericalTextView support int64?
64		if (fTextView->IntValue() != (int32)p->Value())
65			fTextView->SetValue((int32)p->Value());
66		fProperty = p;
67		return true;
68	}
69	return false;
70}
71
72// GetProperty
73Property*
74Int64ValueView::GetProperty() const
75{
76	return fProperty;
77}
78
79