2
* Copyright 2010 Inalogic® Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License, as
6
* published by the Free Software Foundation; either version 2.1 or 3.0
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranties of
11
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the applicable version of the GNU Lesser General Public
13
* License for more details.
15
* You should have received a copy of both the GNU Lesser General Public
16
* License along with this program. If not, see <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jaytaoko@inalogic.com>
24
#include "PropertyList.h"
27
#include "CheckBoxProperty.h"
32
CheckBoxPropertyItem::CheckBoxPropertyItem (std::string label, NUX_FILE_LINE_DECL)
33
: SectionProperty (label.c_str(), NODE_TYPE_CHECKBOX)
34
, CheckBox (label, NUX_FILE_LINE_PARAM)
36
//FIXME - needs updating to the latest Button codebase
38
SetUsingStyleDrawing (false);
39
//FIXME needs to be updated to the latest button codebase
40
//NODE_SIG_CONNECT (sigStateToggled, CheckBoxPropertyItem, RecvPropertyChange);
43
CheckBoxPropertyItem::~CheckBoxPropertyItem()
48
long CheckBoxPropertyItem::ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
50
long ret = TraverseInfo;
52
ret = ProcessEvent (ievent, TraverseInfo, ProcessEventInfo);
56
void CheckBoxPropertyItem::DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry ItemGeo, const BasePainter &Painter,
57
RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor)
59
Geometry geo2 = m_FirstColumnUsableGeometry;
61
if (isDirtyItem() || IsRedrawNeeded() )
63
t_u32 nBackground = table->PushItemBackground (GfxContext, this);
64
Painter.PaintTextLineStatic (GfxContext, GetFont (), m_FirstColumnUsableGeometry, row->_table_item->GetName(), GetItemTextColor() );
66
if (m_ItemGeometryVector.size() >= 2)
68
Geometry geo2 = m_ItemGeometryVector[1];
70
prop_geo.SetX (ItemGeo.x + ItemGeo.GetWidth() );
71
prop_geo.SetY (ItemGeo.y);
72
prop_geo.SetWidth (column_vector[1].m_header_area->GetBaseWidth() );
73
prop_geo.SetHeight (ItemGeo.GetHeight() );
75
geo2.Expand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
76
GfxContext.PushClippingRectangle (geo2);
77
GfxContext.PushClippingRectangle (prop_geo);
78
Painter.Paint2DQuadColor (GfxContext, geo2, ItemBackgroundColor);
79
ProcessDraw (GfxContext, true);
80
GfxContext.PopClippingRectangle();
81
GfxContext.PopClippingRectangle();
84
table->PopItemBackground (GfxContext, nBackground);
88
void CheckBoxPropertyItem::ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector)
90
if (m_ItemGeometryVector.size() >= 2)
93
geo = m_ItemGeometryVector[1];
94
geo = geo.GetExpand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
99
int CheckBoxPropertyItem::GetItemBestHeight()
101
Size sz = GetMinimumSize();
102
return sz.height + 2 * PROPERTY_BORDER_Y;
105
CheckBoxPropertyItem *CheckBoxPropertyItem::CreateFromXML (const TiXmlElement *elementxml, NodeNetCom *parent, const char *Name, int id)
108
QueryNodeXMLIntAttribute (elementxml, "Check", &check, id);
109
CheckBoxPropertyItem *node = new CheckBoxPropertyItem (Name);
110
node->active = check ? true : false;
115
TiXmlElement *CheckBoxPropertyItem::ToXML() const
117
TiXmlElement *elementxml = NodeNetCom::ToXML();
118
//FIXME needs to be updated to the latest button codebase
119
//elementxml->SetAttribute ("Check", GetState() ? 1 : 0);
123
bool CheckBoxPropertyItem::FromXML (const TiXmlElement *elementxml)
127
if (QueryNodeXMLIntAttribute (elementxml, "Check", &check, GetID() ) )
129
//FIXME needs to be updated to the latest button codebase
130
//SetState (check ? true : false);
131
//nuxDebugMsg(TEXT("Updated Node %s - ID: %d - Type: %s"), GetName().c_str(), GetID(), ConvertTypeToString(GetParameterType()));
132
return NodeNetCom::FromXML (elementxml);