nux-1.16.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #include "Nux.h" 00024 #include "PropertyList.h" 00025 00026 #include "Vector3ValuatorDouble.h" 00027 #include "Vector3ValuatorPropertyItem.h" 00028 00029 namespace nux 00030 { 00031 00032 Vector3ValuatorPropertyItem::Vector3ValuatorPropertyItem (const TCHAR *name, double X, double Y, double Z, 00033 double Step, double MinValue, double MaxValue) 00034 : SectionProperty (name, NODE_TYPE_SPINBOX) 00035 , Vector3DoubleValuator (X, Y, Z, Step, MinValue, MaxValue) 00036 { 00037 NODE_SIG_CONNECT (sigValueChanged, Vector3ValuatorPropertyItem, RecvPropertyChange); 00038 } 00039 00040 Vector3ValuatorPropertyItem::~Vector3ValuatorPropertyItem() 00041 { 00042 00043 } 00044 00045 long Vector3ValuatorPropertyItem::ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) 00046 { 00047 long ret = TraverseInfo; 00048 00049 ret = ProcessEvent (ievent, TraverseInfo, ProcessEventInfo); 00050 return ret; 00051 } 00052 00053 void Vector3ValuatorPropertyItem::DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter, 00054 RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor) 00055 { 00056 Geometry geo2 = m_FirstColumnUsableGeometry; 00057 00058 if (isDirtyItem() || IsRedrawNeeded() ) 00059 { 00060 t_u32 nBackground = table->PushItemBackground (GfxContext, this); 00061 Painter.PaintTextLineStatic (GfxContext, GetFont (), m_FirstColumnUsableGeometry, row->_table_item->GetName(), GetItemTextColor() ); 00062 00063 if (m_ItemGeometryVector.size() >= 2) 00064 { 00065 Geometry geo2 = m_ItemGeometryVector[1]; 00066 Geometry prop_geo; 00067 prop_geo.SetX (geo.x + geo.GetWidth() ); 00068 prop_geo.SetY (geo.y); 00069 prop_geo.SetWidth (column_vector[1].m_header_area->GetBaseWidth() ); 00070 prop_geo.SetHeight (geo.GetHeight() ); 00071 00072 geo2.Expand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y); 00073 GfxContext.PushClippingRectangle (geo2); 00074 GfxContext.PushClippingRectangle (prop_geo); 00075 ProcessDraw (GfxContext, true); 00076 GfxContext.PopClippingRectangle(); 00077 GfxContext.PopClippingRectangle(); 00078 } 00079 00080 table->PopItemBackground (GfxContext, nBackground); 00081 } 00082 } 00083 00084 void Vector3ValuatorPropertyItem::ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector) 00085 { 00086 if (m_ItemGeometryVector.size() >= 2) 00087 { 00088 Geometry geo; 00089 geo = m_ItemGeometryVector[1]; 00090 geo = geo.GetExpand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y); 00091 SetGeometry (geo); 00092 } 00093 } 00094 00095 int Vector3ValuatorPropertyItem::GetItemBestHeight() 00096 { 00097 Size sz = GetMinimumSize(); 00098 return sz.height + 2 * PROPERTY_BORDER_Y; 00099 } 00100 00101 Vector3ValuatorPropertyItem *Vector3ValuatorPropertyItem::CreateFromXML (const TiXmlElement *elementxml, NodeNetCom *parent, const char *Name, int id) 00102 { 00103 double value = 0; 00104 double minvalue = 0; 00105 double maxvalue = 100; 00106 double step = 1; 00107 double X, Y, Z; 00108 QueryNodeXMLDoubleAttribute (elementxml, "X", &X, id); 00109 QueryNodeXMLDoubleAttribute (elementxml, "Y", &Y, id); 00110 QueryNodeXMLDoubleAttribute (elementxml, "Z", &Z, id); 00111 QueryNodeXMLDoubleAttribute (elementxml, "MinValue", &minvalue, id); 00112 QueryNodeXMLDoubleAttribute (elementxml, "MaxValue", &maxvalue, id); 00113 QueryNodeXMLDoubleAttribute (elementxml, "Step", &step, id); 00114 00115 Vector3ValuatorPropertyItem *node = new Vector3ValuatorPropertyItem (Name, value, step, minvalue, maxvalue); 00116 node->SetID (id); 00117 return node; 00118 } 00119 00120 TiXmlElement *Vector3ValuatorPropertyItem::ToXML() const 00121 { 00122 TiXmlElement *elementxml = NodeNetCom::ToXML(); 00123 elementxml->SetDoubleAttribute ("X", GetVectorX() ); 00124 elementxml->SetDoubleAttribute ("Y", GetVectorY() ); 00125 elementxml->SetDoubleAttribute ("Z", GetVectorZ() ); 00126 elementxml->SetDoubleAttribute ("Step", GetStep() ); 00127 elementxml->SetDoubleAttribute ("MinValue", GetMinValue() ); 00128 elementxml->SetDoubleAttribute ("MaxValue", GetMaxValue() ); 00129 return elementxml; 00130 } 00131 00132 bool Vector3ValuatorPropertyItem::FromXML (const TiXmlElement *elementxml) 00133 { 00134 double minvalue = 0; 00135 double maxvalue = 100; 00136 double step = 1; 00137 double X, Y, Z; 00138 QueryNodeXMLDoubleAttribute (elementxml, "X", &X, GetID() ); 00139 QueryNodeXMLDoubleAttribute (elementxml, "Y", &Y, GetID() ); 00140 QueryNodeXMLDoubleAttribute (elementxml, "Z", &Z, GetID() ); 00141 QueryNodeXMLDoubleAttribute (elementxml, "MinValue", &minvalue, GetID() ); 00142 QueryNodeXMLDoubleAttribute (elementxml, "MaxValue", &maxvalue, GetID() ); 00143 QueryNodeXMLDoubleAttribute (elementxml, "Step", &step, GetID() ); 00144 SetRange (minvalue, maxvalue); 00145 SetStep (step); 00146 SetValue (X, Y, Z); 00147 return NodeNetCom::FromXML (elementxml); 00148 } 00149 }