nux-1.16.0
EditTextLinePropertyItem.cpp
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 "EditTextBox.h"
00027 #include "EditTextLinePropertyItem.h"
00028 
00029 namespace nux
00030 {
00031 
00032   EditTextLinePropertyItem::EditTextLinePropertyItem (const TCHAR *name, const TCHAR *text)
00033     :   SectionProperty (name, NODE_TYPE_EDITTEXT)
00034     ,   EditTextBox (text, NUX_TRACKER_LOCATION)
00035   {
00036     SetText (text);
00037     SetTextColor (GPropertyItemTextColor1);
00038     NODE_SIG_CONNECT (sigValidateEntry, EditTextLinePropertyItem, RecvPropertyChange);
00039   }
00040 
00041   EditTextLinePropertyItem::~EditTextLinePropertyItem()
00042   {
00043 
00044   }
00045 
00046   long EditTextLinePropertyItem::ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
00047   {
00048     long ret = TraverseInfo;
00049 
00050     ret = ProcessEvent (ievent, TraverseInfo, ProcessEventInfo);
00051     return ret;
00052   }
00053 
00054   void EditTextLinePropertyItem::DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter,
00055       RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor)
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 prop_geo = m_ItemGeometryVector[1];
00065         prop_geo.Expand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
00066         GfxContext.PushClippingRectangle (prop_geo);
00067         ProcessDraw (GfxContext, true);
00068         GfxContext.PopClippingRectangle();
00069       }
00070 
00071       table->PopItemBackground (GfxContext, nBackground);
00072     }
00073   }
00074 
00075   void EditTextLinePropertyItem::ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector)
00076   {
00077     if (m_ItemGeometryVector.size() >= 2)
00078     {
00079       Geometry geo;
00080       geo = m_ItemGeometryVector[1];
00081       geo = geo.GetExpand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
00082       SetGeometry (geo);
00083     }
00084   }
00085 
00086   int EditTextLinePropertyItem::GetItemBestHeight()
00087   {
00088     Size sz = GetMinimumSize();
00089     return sz.height + 2 * PROPERTY_BORDER_Y;
00090   }
00091 
00092   void EditTextLinePropertyItem::SetBackgroundColor (Color c)
00093   {
00094     EditTextBox::SetTextBackgroundColor (c);
00095     m_ItemBackgroundColor = c;
00096   }
00097 
00098   EditTextLinePropertyItem *EditTextLinePropertyItem::CreateFromXML (const TiXmlElement *elementxml, NodeNetCom *parent, const char *Name, int id)
00099   {
00100     tstring text;
00101     QueryNodeXMLStringAttribute (elementxml, "EditText",       text,     id);
00102     EditTextLinePropertyItem *node = new EditTextLinePropertyItem (Name);
00103     node->SetText (text);
00104     node->SetID (id);
00105     return node;
00106   }
00107 
00108   TiXmlElement *EditTextLinePropertyItem::ToXML() const
00109   {
00110     TiXmlElement *elementxml = NodeNetCom::ToXML();
00111     elementxml->SetAttribute ("EditText", GetText() );
00112     return elementxml;
00113   }
00114 
00115   bool EditTextLinePropertyItem::FromXML (const TiXmlElement *elementxml)
00116   {
00117     tstring text;
00118 
00119     if (QueryNodeXMLStringAttribute (elementxml, "EditText", text, GetID() ) )
00120     {
00121       SetText (text);
00122       return NodeNetCom::FromXML (elementxml);
00123     }
00124 
00125     return false;
00126   }
00127 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends