24
#include "PropertyList.h"
26
#include "ValuatorDouble.h"
27
#include "DoubleValuatorPropertyItem.h"
31
DoubleValuatorPropertyItem::DoubleValuatorPropertyItem(const TCHAR* name, float Value, float Step, float MinValue, float MaxValue)
32
: SectionProperty(name, NODE_TYPE_DOUBLEVALUATOR)
34
SetRange(MinValue, MaxValue);
37
NODE_SIG_CONNECT(sigValueChanged, DoubleValuatorPropertyItem, RecvPropertyChange);
40
DoubleValuatorPropertyItem::~DoubleValuatorPropertyItem()
45
long DoubleValuatorPropertyItem::ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
47
long ret = TraverseInfo;
49
Geometry geo = m_ItemGeometryVector[1];
50
if((ievent.e_event == INL_MOUSE_PRESSED) && geo.IsPointInside(ievent.e_x, ievent.e_y) == false)
52
// This will filter out mouse down event that happened in the item in the same row on the right.
53
// This is necessary because the widget we are testing maybe larger that the table element where it resides.
55
// ____________________________________________________________
56
// | NAME | WIDGET | : |
57
// |___________|________________|_____:_____________|___________
62
ret = ProcessEvent(ievent, TraverseInfo, eDoNotProcess | ProcessEventInfo);
66
ret = ProcessEvent(ievent, TraverseInfo, ProcessEventInfo);
71
void DoubleValuatorPropertyItem::DrawProperty(GraphicsContext& GfxContext, TableCtrl* table, bool force_draw, Geometry geo, const BasePainter& Painter,
72
RowHeader* row, const std::vector<header2>& column_vector, Color ItemBackgroundColor)
74
bool isSelected = (this == table->GetSelectedItem());
75
if(isDirtyItem() || IsRedrawNeeded())
77
UINT nBackground = table->PushItemBackground(GfxContext, this);
78
Painter.PaintTextLineStatic(GfxContext, GetFont(), m_FirstColumnUsableGeometry, row->item->GetName(), GetItemTextColor());
80
if(m_ItemGeometryVector.size() >= 2)
82
Geometry geo2 = m_ItemGeometryVector[1];
84
prop_geo.SetX(geo.x + geo.GetWidth());
86
prop_geo.SetWidth(column_vector[1].header.GetBaseWidth());
87
prop_geo.SetHeight(geo.GetHeight());
89
geo2.Expand(-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
90
GfxContext.PushClippingRectangle(geo2);
91
GfxContext.PushClippingRectangle(prop_geo);
92
ProcessDraw(GfxContext, true);
93
GfxContext.PopClippingRectangle();
94
GfxContext.PopClippingRectangle();
96
table->PopItemBackground(GfxContext, nBackground);
100
void DoubleValuatorPropertyItem::ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<header2>& column_vector)
102
if(m_ItemGeometryVector.size() >= 2)
105
geo = m_ItemGeometryVector[1];
106
geo = geo.GetExpand(-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
111
int DoubleValuatorPropertyItem::GetItemBestHeight()
113
Size sz = GetMinimumSize();
114
return sz.GetHeight() + 2 * PROPERTY_BORDER_Y;
117
DoubleValuatorPropertyItem* DoubleValuatorPropertyItem::CreateFromXML(const TiXmlElement* elementxml, NodeNetCom* parent, const char* Name, int id)
120
double minvalue = 0.0;
121
double maxvalue = 100.0;
123
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Value"), &value, -1);
124
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Value"), &value, -1);
125
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Step"), &step, -1);
126
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MinValue"), &minvalue, -1);
127
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MaxValue"), &maxvalue, -1);
129
DoubleValuatorPropertyItem *node = new DoubleValuatorPropertyItem(Name, value, step, minvalue, maxvalue);
134
TiXmlElement* DoubleValuatorPropertyItem::ToXML() const
136
TiXmlElement* elementxml = NodeNetCom::ToXML();
137
elementxml->SetDoubleAttribute(TEXT("Value"), GetValue());
138
elementxml->SetDoubleAttribute(TEXT("Step"), GetStep());
139
elementxml->SetDoubleAttribute(TEXT("MinValue"), GetMinValue());
140
elementxml->SetDoubleAttribute(TEXT("MaxValue"), GetMaxValue());
144
bool DoubleValuatorPropertyItem::FromXML(const TiXmlElement* elementxml)
148
double minvalue = 0.0;
149
double maxvalue = 1.0;
151
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Value"), &value, GetID());
152
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Step"), &step, GetID());
153
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MinValue"), &minvalue, GetID());
154
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MaxValue"), &maxvalue, GetID());
155
//QueryNodeXMLIntAttribute(elementxml, "Step", &step, GetID());
156
SetRange(minvalue, maxvalue);
159
return NodeNetCom::FromXML(elementxml);
24
#include "PropertyList.h"
26
#include "ValuatorDouble.h"
27
#include "DoubleValuatorPropertyItem.h"
31
DoubleValuatorPropertyItem::DoubleValuatorPropertyItem(const TCHAR* name, float Value, float Step, float MinValue, float MaxValue)
32
: SectionProperty(name, NODE_TYPE_DOUBLEVALUATOR)
34
SetRange(MinValue, MaxValue);
37
NODE_SIG_CONNECT(sigValueChanged, DoubleValuatorPropertyItem, RecvPropertyChange);
40
DoubleValuatorPropertyItem::~DoubleValuatorPropertyItem()
45
long DoubleValuatorPropertyItem::ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
47
long ret = TraverseInfo;
49
Geometry geo = m_ItemGeometryVector[1];
50
if((ievent.e_event == INL_MOUSE_PRESSED) && geo.IsPointInside(ievent.e_x, ievent.e_y) == false)
52
// This will filter out mouse down event that happened in the item in the same row on the right.
53
// This is necessary because the widget we are testing maybe larger that the table element where it resides.
55
// ____________________________________________________________
56
// | NAME | WIDGET | : |
57
// |___________|________________|_____:_____________|___________
62
ret = ProcessEvent(ievent, TraverseInfo, eDoNotProcess | ProcessEventInfo);
66
ret = ProcessEvent(ievent, TraverseInfo, ProcessEventInfo);
71
void DoubleValuatorPropertyItem::DrawProperty(GraphicsContext& GfxContext, TableCtrl* table, bool force_draw, Geometry geo, const BasePainter& Painter,
72
RowHeader* row, const std::vector<header2>& column_vector, Color ItemBackgroundColor)
74
bool isSelected = (this == table->GetSelectedItem());
75
if(isDirtyItem() || IsRedrawNeeded())
77
UINT nBackground = table->PushItemBackground(GfxContext, this);
78
Painter.PaintTextLineStatic(GfxContext, GetFont(), m_FirstColumnUsableGeometry, row->item->GetName(), GetItemTextColor());
80
if(m_ItemGeometryVector.size() >= 2)
82
Geometry geo2 = m_ItemGeometryVector[1];
84
prop_geo.SetX(geo.x + geo.GetWidth());
86
prop_geo.SetWidth(column_vector[1].header.GetBaseWidth());
87
prop_geo.SetHeight(geo.GetHeight());
89
geo2.Expand(-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
90
GfxContext.PushClippingRectangle(geo2);
91
GfxContext.PushClippingRectangle(prop_geo);
92
ProcessDraw(GfxContext, true);
93
GfxContext.PopClippingRectangle();
94
GfxContext.PopClippingRectangle();
96
table->PopItemBackground(GfxContext, nBackground);
100
void DoubleValuatorPropertyItem::ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<header2>& column_vector)
102
if(m_ItemGeometryVector.size() >= 2)
105
geo = m_ItemGeometryVector[1];
106
geo = geo.GetExpand(-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
111
int DoubleValuatorPropertyItem::GetItemBestHeight()
113
Size sz = GetMinimumSize();
114
return sz.GetHeight() + 2 * PROPERTY_BORDER_Y;
117
DoubleValuatorPropertyItem* DoubleValuatorPropertyItem::CreateFromXML(const TiXmlElement* elementxml, NodeNetCom* parent, const char* Name, int id)
120
double minvalue = 0.0;
121
double maxvalue = 100.0;
123
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Value"), &value, -1);
124
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Value"), &value, -1);
125
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Step"), &step, -1);
126
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MinValue"), &minvalue, -1);
127
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MaxValue"), &maxvalue, -1);
129
DoubleValuatorPropertyItem *node = new DoubleValuatorPropertyItem(Name, value, step, minvalue, maxvalue);
134
TiXmlElement* DoubleValuatorPropertyItem::ToXML() const
136
TiXmlElement* elementxml = NodeNetCom::ToXML();
137
elementxml->SetDoubleAttribute(TEXT("Value"), GetValue());
138
elementxml->SetDoubleAttribute(TEXT("Step"), GetStep());
139
elementxml->SetDoubleAttribute(TEXT("MinValue"), GetMinValue());
140
elementxml->SetDoubleAttribute(TEXT("MaxValue"), GetMaxValue());
144
bool DoubleValuatorPropertyItem::FromXML(const TiXmlElement* elementxml)
148
double minvalue = 0.0;
149
double maxvalue = 1.0;
151
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Value"), &value, GetID());
152
QueryNodeXMLDoubleAttribute(elementxml, TEXT("Step"), &step, GetID());
153
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MinValue"), &minvalue, GetID());
154
QueryNodeXMLDoubleAttribute(elementxml, TEXT("MaxValue"), &maxvalue, GetID());
155
//QueryNodeXMLIntAttribute(elementxml, "Step", &step, GetID());
156
SetRange(minvalue, maxvalue);
159
return NodeNetCom::FromXML(elementxml);