nux-1.16.0
FilePropertyItem.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 "FilePropertyItem.h"
00027 
00028 namespace nux
00029 {
00030 
00031   FilePropertyItem::FilePropertyItem (const TCHAR *name)
00032     :   SectionProperty (name)
00033   {
00034     m_hlayout = new HLayout();
00035     m_TextEntry = new EditTextBox (TEXT (""), NUX_TRACKER_LOCATION);
00036     m_OpenButton = new Button ("", NUX_TRACKER_LOCATION);
00037     m_hlayout->AddView (m_TextEntry, 1, eCenter);
00038     m_hlayout->AddView (m_OpenButton, 0, eCenter);
00039     m_hlayout->SetHorizontalInternalMargin (2);
00040     GetWindowThread ()->ComputeElementLayout (m_hlayout);
00041 
00042     // FIXME - needs to be updated to the latest button codebase
00043     //m_OpenButton->SetCaption (TEXT ("...") );
00044     m_OpenButton->SetMinimumSize (32, DEFAULT_WIDGET_HEIGHT);
00045   }
00046 
00047   FilePropertyItem::~FilePropertyItem()
00048   {
00049   }
00050 
00051   long FilePropertyItem::ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
00052   {
00053     long ret = TraverseInfo;
00054 
00055 //     ret = m_TextEntry->BaseProcessEvent (ievent, ret, ProcessEventInfo);
00056 //     ret = m_OpenButton->BaseProcessEvent (ievent, ret, ProcessEventInfo);
00057     return ret;
00058   }
00059 
00060   void FilePropertyItem::DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter,
00061                                        RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor)
00062   {
00063     if (isDirtyItem() ||
00064         m_OpenButton->IsRedrawNeeded() ||
00065         m_TextEntry->IsRedrawNeeded() )
00066     {
00067       t_u32 nBackground = table->PushItemBackground (GfxContext, this);
00068       Painter.PaintTextLineStatic (GfxContext, GetSysFont(), m_FirstColumnUsableGeometry, row->_table_item->GetName(), GetItemTextColor() );
00069 
00070       if (m_ItemGeometryVector.size() >= 2)
00071       {
00072         Geometry prop_geo = m_ItemGeometryVector[1];
00073         Geometry geo2 = m_ItemGeometryVector[1];
00074         geo2.Expand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
00075         GfxContext.PushClippingRectangle (geo2);
00076         GfxContext.PushClippingRectangle (prop_geo);
00077         m_TextEntry->ProcessDraw (GfxContext, true);
00078         m_OpenButton->ProcessDraw (GfxContext, true);
00079         GfxContext.PopClippingRectangle();
00080         GfxContext.PopClippingRectangle();
00081       }
00082 
00083       table->PopItemBackground (GfxContext, nBackground);
00084     }
00085   }
00086 
00087   void FilePropertyItem::ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector)
00088   {
00089     if (m_ItemGeometryVector.size() >= 2)
00090     {
00091       Geometry geo;
00092       geo = m_ItemGeometryVector[1];
00093       geo = geo.GetExpand (-PROPERTY_BORDER_X, -PROPERTY_BORDER_Y);
00094       m_hlayout->SetGeometry (geo);
00095       GetWindowThread ()->ComputeElementLayout (m_hlayout);
00096     }
00097   }
00098 
00099   int FilePropertyItem::GetItemBestHeight()
00100   {
00101     Size sz = m_TextEntry->GetMinimumSize();
00102     return sz.height + 2 * PROPERTY_BORDER_Y;
00103   }
00104 
00105 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends