nux-1.14.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 "SpinBoxDouble.h" 00027 #include "SpinBoxDoublePropertyItem.h" 00028 00029 namespace nux 00030 { 00031 00032 SpinBoxDoublePropertyItem::SpinBoxDoublePropertyItem (const TCHAR *name, double Value, double Step, double MinValue, double MaxValue) 00033 : SectionProperty (name, NODE_TYPE_SPINBOX) 00034 , SpinBoxDouble (Value, Step, MinValue, MaxValue) 00035 { 00036 NODE_SIG_CONNECT (sigValueChanged, SpinBoxDoublePropertyItem, RecvPropertyChange); 00037 } 00038 00039 SpinBoxDoublePropertyItem::~SpinBoxDoublePropertyItem() 00040 { 00041 00042 } 00043 00044 long SpinBoxDoublePropertyItem::ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo) 00045 { 00046 long ret = TraverseInfo; 00047 00048 ret = ProcessEvent (ievent, TraverseInfo, ProcessEventInfo); 00049 return ret; 00050 } 00051 00052 void SpinBoxDoublePropertyItem::DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter, 00053 RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor) 00054 { 00055 Geometry geo2 = m_FirstColumnUsableGeometry; 00056 00057 if (isDirtyItem() || IsRedrawNeeded() ) 00058 { 00059 t_u32 nBackground = table->PushItemBackground (GfxContext, this); 00060 Painter.PaintTextLineStatic (GfxContext, GetFont (), m_FirstColumnUsableGeometry, row->_table_item->GetName(), GetItemTextColor() ); 00061 00062 if (m_ItemGeometryVector.size() >= 2) 00063 { 00064 Geometry geo2 = m_ItemGeometryVector[1]; 00065 Geometry prop_geo; 00066 prop_geo.SetX (geo.x + geo.GetWidth() ); 00067 prop_geo.SetY (geo.y); 00068 prop_geo.SetWidth (column_vector[1].m_header_area->GetBaseWidth() ); 00069 prop_geo.SetHeight (geo.GetHeight() ); 00070 00071 geo2.Expand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y); 00072 GfxContext.PushClippingRectangle (geo2); 00073 GfxContext.PushClippingRectangle (prop_geo); 00074 ProcessDraw (GfxContext, true); 00075 GfxContext.PopClippingRectangle(); 00076 GfxContext.PopClippingRectangle(); 00077 } 00078 00079 table->PopItemBackground (GfxContext, nBackground); 00080 } 00081 } 00082 00083 void SpinBoxDoublePropertyItem::ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector) 00084 { 00085 if (m_ItemGeometryVector.size() >= 2) 00086 { 00087 Geometry geo; 00088 geo = m_ItemGeometryVector[1]; 00089 geo = geo.GetExpand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y); 00090 SetGeometry (geo); 00091 } 00092 } 00093 00094 int SpinBoxDoublePropertyItem::GetItemBestHeight() 00095 { 00096 Size sz = GetMinimumSize(); 00097 return sz.height + 2 * PROPERTY_BORDER_Y; 00098 } 00099 00100 SpinBoxDoublePropertyItem *SpinBoxDoublePropertyItem::CreateFromXML (const TiXmlElement *elementxml, NodeNetCom *parent, const char *Name, int id) 00101 { 00102 double value = 0; 00103 double minvalue = 0; 00104 double maxvalue = 100; 00105 double step = 1; 00106 QueryNodeXMLDoubleAttribute (elementxml, "Value", &value, id); 00107 QueryNodeXMLDoubleAttribute (elementxml, "MinValue", &minvalue, id); 00108 QueryNodeXMLDoubleAttribute (elementxml, "MaxValue", &maxvalue, id); 00109 QueryNodeXMLDoubleAttribute (elementxml, "Step", &step, id); 00110 00111 SpinBoxDoublePropertyItem *node = new SpinBoxDoublePropertyItem (Name, value, step, minvalue, maxvalue); 00112 node->SetID (id); 00113 return node; 00114 } 00115 00116 TiXmlElement *SpinBoxDoublePropertyItem::ToXML() const 00117 { 00118 TiXmlElement *elementxml = NodeNetCom::ToXML(); 00119 elementxml->SetDoubleAttribute ("Value", GetValue() ); 00120 elementxml->SetDoubleAttribute ("Step", GetStep() ); 00121 elementxml->SetDoubleAttribute ("MinValue", GetMinValue() ); 00122 elementxml->SetDoubleAttribute ("MaxValue", GetMaxValue() ); 00123 return elementxml; 00124 } 00125 00126 bool SpinBoxDoublePropertyItem::FromXML (const TiXmlElement *elementxml) 00127 { 00128 double value = 0; 00129 double minvalue = 0; 00130 double maxvalue = 100; 00131 double step = 1; 00132 QueryNodeXMLDoubleAttribute (elementxml, "Value", &value, GetID() ); 00133 QueryNodeXMLDoubleAttribute (elementxml, "MinValue", &minvalue, GetID() ); 00134 QueryNodeXMLDoubleAttribute (elementxml, "MaxValue", &maxvalue, GetID() ); 00135 QueryNodeXMLDoubleAttribute (elementxml, "Step", &step, GetID() ); 00136 SetRange (minvalue, maxvalue); 00137 SetStep (step); 00138 SetValue (value); 00139 return NodeNetCom::FromXML (elementxml); 00140 } 00141 }