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 00025 #include "FolderTreeItem.h" 00026 00027 namespace nux 00028 { 00029 00030 FolderTreeItem::FolderTreeItem (const TCHAR *name, const TCHAR *Path, bool Searchable, NodeParameterType type) 00031 : TreeItem (name, type) 00032 { 00033 m_Synchronize = false; 00034 m_Path = Path; 00035 m_Searchable = Searchable; 00036 00037 TableItem::SetAlwaysShowOpeningButton (true); 00038 00039 NString IconPath = NUX_FINDRESOURCELOCATION (TEXT ("Icons/FolderOpen-16x16.png") ); 00040 FolderOpenIcon = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture (); 00041 FolderOpenIcon->Update (IconPath.GetTCharPtr() ); 00042 IconPath = NUX_FINDRESOURCELOCATION (TEXT ("Icons/FolderClose-16x16.png") ); 00043 FolderClosedIcon = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture (); 00044 FolderClosedIcon->Update (IconPath.GetTCharPtr() ); 00045 //FolderOpenIcon.Update(TEXT("../Media/Icons/FolderOpenGrey-16x16.png")); 00046 //FolderClosedIcon.Update(TEXT("../Media/Icons/FolderClosedGrey-16x16.png")); 00047 } 00048 00049 FolderTreeItem::~FolderTreeItem() 00050 { 00051 if (FolderOpenIcon->OwnsTheReference()) 00052 FolderOpenIcon->UnReference (); 00053 else 00054 FolderOpenIcon->Dispose (); 00055 00056 if (FolderClosedIcon->OwnsTheReference()) 00057 FolderClosedIcon->UnReference (); 00058 else 00059 FolderClosedIcon->Dispose (); 00060 } 00061 00062 void FolderTreeItem::DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter, RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor) 00063 { 00064 Geometry FirstColumnGeometry = m_ItemGeometryVector[0]; 00065 00066 if (isDirtyItem() ) 00067 { 00068 t_u32 nBackground; 00069 00070 if (m_bIsMouseInside) 00071 { 00072 nBackground = table->PushItemBackground (GfxContext, this, true); 00073 } 00074 else 00075 { 00076 nBackground = table->PushItemBackground (GfxContext, this, false); 00077 } 00078 00079 GfxContext.PushClippingRectangle (geo); 00080 { 00081 Geometry IconGeometry (geo.x, geo.y, 16, 16); 00082 Geometry TextGeometry (geo); 00083 TextGeometry.OffsetPosition (18, 0); 00084 { 00085 GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (TRUE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00086 GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetColorMask (TRUE, TRUE, TRUE, FALSE); 00087 nux::TexCoordXForm texxform; 00088 00089 if (isOpen() ) 00090 { 00091 GfxContext.QRP_1Tex (IconGeometry.x, IconGeometry.y, IconGeometry.width, IconGeometry.height, FolderOpenIcon->GetDeviceTexture(), texxform, nux::color::White); 00092 } 00093 else 00094 { 00095 GfxContext.QRP_1Tex (IconGeometry.x, IconGeometry.y, IconGeometry.width, IconGeometry.height, FolderClosedIcon->GetDeviceTexture(), texxform, nux::color::White); 00096 } 00097 00098 GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetColorMask (TRUE, TRUE, TRUE, TRUE); 00099 GetGraphicsDisplay()->GetGraphicsEngine()->GetRenderStates().SetBlend (FALSE); 00100 } 00101 Painter.PaintTextLineStatic (GfxContext, GetSysFont(), TextGeometry, row->_table_item->GetName(), GetItemTextColor() ); 00102 } 00103 GfxContext.PopClippingRectangle(); 00104 table->PopItemBackground (GfxContext, nBackground); 00105 } 00106 } 00107 00108 00109 }