[commit] r1944 - trunk/GME/GMEActiveBrowser
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Thu Jun 28 14:08:00 CDT 2012
Author: ksmyth
Date: Thu Jun 28 14:08:00 2012
New Revision: 1944
Log:
Render treeIcon in TreeBrowser
Deleted:
trunk/GME/GMEActiveBrowser/MgaObjectProxy.cpp
trunk/GME/GMEActiveBrowser/MgaObjectProxyMapItem.cpp
Modified:
trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.cpp
trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.h
trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj
trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj.filters
trunk/GME/GMEActiveBrowser/MgaMap.h
trunk/GME/GMEActiveBrowser/MgaObjectProxy.h
Modified: trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.cpp
==============================================================================
--- trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.cpp Thu Jun 28 14:07:45 2012 (r1943)
+++ trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.cpp Thu Jun 28 14:08:00 2012 (r1944)
@@ -8,6 +8,10 @@
#include "ActiveBrowserPropertyPage.h"
#include "..\gme\GMEOLEData.h"
+#include <GdiPlus.h>
+#pragma comment(lib, "gdiplus.lib")
+#include "..\..\SDK\DecoratorLib\PathUtil.h"
+
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
@@ -113,18 +117,17 @@
}
// Inserting item into the tree control
- HTREEITEM hItem=CTreeCtrl::InsertItem(&tvInsert);
+ HTREEITEM hItem = CTreeCtrl::InsertItem(&tvInsert);
strObjectName.ReleaseBuffer();
SetItemData(hItem,(DWORD)hItem);
- CMgaObjectProxy ObjectProxy(pUnknown,otObjectType);
- m_MgaMap.AddEntry(hItem,ObjectProxy);
+ CAggregateMgaObjectProxy ObjectProxy(pUnknown, otObjectType);
+ CAggregateMgaObjectProxy& insertedProxy = m_MgaMap.AddEntry(hItem, ObjectProxy);
- SetItemProperties(hItem, sourceControlLatentState);
+ SetItemProperties(hItem, sourceControlLatentState, &insertedProxy);
return hItem;
-
}
@@ -208,10 +211,10 @@
SetItemData(hItem,(DWORD)hItem);
- CMgaObjectProxy ObjectProxy(pUnknown,otObjectType);
- m_MgaMap.AddEntry(hItem,ObjectProxy);
+ CAggregateMgaObjectProxy ObjectProxy(pUnknown,otObjectType);
+ CAggregateMgaObjectProxy& insertedProxy = m_MgaMap.AddEntry(hItem, ObjectProxy);
- SetItemProperties(hItem, sourceControlLatentState);
+ SetItemProperties(hItem, sourceControlLatentState, &insertedProxy);
return hItem;
@@ -1222,7 +1225,7 @@
return res;
}
-void CAggregateTreeCtrl::SetItemProperties(HTREEITEM hItem, int p_fileLatentState)
+void CAggregateTreeCtrl::SetItemProperties(HTREEITEM hItem, int p_fileLatentState, CAggregateMgaObjectProxy* insertedProxy)
{
@@ -1289,6 +1292,33 @@
pMgaContext->BeginTransaction();
+
+ if (insertedProxy != nullptr)
+ {
+ CComPtr<IMgaMetaFCO> meta;
+ COMTHROW(ccpMgaFCO->get_Meta(&meta));
+ _bstr_t treeIcon;
+ meta->get_RegistryValue(CComBSTR(L"treeIcon"), treeIcon.GetAddress());
+ CComPtr<IMgaProject> project;
+ COMTHROW(ccpMgaFCO->get_Project(&project));
+ PathUtil pathUtil;
+ if (treeIcon.length() && pathUtil.loadPaths(project, true))
+ {
+ std::vector<CString> paths = pathUtil.getPaths();
+ for (auto pathsIt = paths.begin(); pathsIt != paths.end(); pathsIt++)
+ {
+ std::shared_ptr<Gdiplus::Bitmap> bmp =
+ std::shared_ptr<Gdiplus::Bitmap>(Gdiplus::Bitmap::FromFile(*pathsIt + L"\\" + static_cast<const wchar_t*>(treeIcon)));
+ if (bmp->GetLastStatus() == Gdiplus::Ok)
+ {
+ insertedProxy->treeIcon = (bmp);
+ break;
+ }
+ }
+ }
+ }
+
+
// Is it instance?
VARIANT_BOOL vtbIsInstance=VARIANT_FALSE;
COMTHROW(ccpMgaFCO->get_IsInstance(&vtbIsInstance));
@@ -1396,17 +1426,22 @@
HTREEITEM hItem = NULL;
CRect rItem;
- // Get the current top item, if any...
hItem = GetFirstVisibleItem();
-
- // Work through them one at a time...
while ( hItem )
{
-
- this->GetItemRect(hItem, rItem, TRUE);
- rItem += rClient;
- rItem.left -= 16;
- //dc->DrawText(L"xx", 2, rItem, DT_LEFT | DT_BOTTOM);
+ CAggregateMgaObjectProxy MgaObjectProxyItem;
+ if (m_MgaMap.LookupObjectProxy(hItem,MgaObjectProxyItem) &&
+ MgaObjectProxyItem.treeIcon)
+ {
+ this->GetItemRect(hItem, rItem, TRUE);
+ rItem += rClient;
+ // FIXME: fix for high DPI
+ rItem.left -= 16 + 2;
+ Gdiplus::Graphics plus(*dc);
+ // FIXME: fix for high DPI
+ Gdiplus::Rect dst(rItem.left, rItem.top, 16, 16);
+ plus.DrawImage(MgaObjectProxyItem.treeIcon.get(), dst, 0, 0, 16, 16, Gdiplus::UnitPixel);
+ }
hItem = this->GetNextVisibleItem(hItem);
}
}
Modified: trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.h
==============================================================================
--- trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.h Thu Jun 28 14:07:45 2012 (r1943)
+++ trunk/GME/GMEActiveBrowser/AggregateTreeCtrl.h Thu Jun 28 14:08:00 2012 (r1944)
@@ -11,11 +11,17 @@
#include "MgaMappedTreeCtrl.h"
+#include <GdiPlus.h>
+#include <memory>
+
struct CAggregateMgaObjectProxy : public CMgaObjectProxy
{
CAggregateMgaObjectProxy() : CMgaObjectProxy() { };
- CAggregateMgaObjectProxy(LPUNKNOWN pMgaObject, objtype_enum type) : CMgaObjectProxy(pMgaObject, type) {};
- CAggregateMgaObjectProxy(CMgaObjectProxy& proxy) : CMgaObjectProxy(proxy) {};
+ CAggregateMgaObjectProxy(const CMgaObjectProxy& proxy) : CMgaObjectProxy(proxy) {};
+ CAggregateMgaObjectProxy(LPUNKNOWN pMgaObject, objtype_enum type) :
+ CMgaObjectProxy(pMgaObject, type) {};
+
+ std::shared_ptr<Gdiplus::Bitmap> treeIcon;
};
class CAggregateTreeCtrl : public CMgaMappedTreeCtrl<CAggregateMgaObjectProxy>
@@ -23,7 +29,7 @@
friend class CAggregatePropertyPage;
friend class CAggregateContextMenu;
-
+ // TODO std::map<_bstr_t, std::shared_ptr<Gdiplus::Bitmap>> treeIconCache;
CMapStringToString m_StateBuffer;
BOOL m_bIsStateStored;
@@ -32,7 +38,7 @@
static bool IsUngroupedLibrary(CComPtr<IMgaFolder> ptr);
- void SetItemProperties(HTREEITEM hItem, int p_fileLatentState = 0);
+ void SetItemProperties(HTREEITEM hItem, int p_fileLatentState=0, CAggregateMgaObjectProxy* insertedProxy=nullptr);
BOOL DoDrop(eDragOperation doDragOp, COleDataObject *pDataObject, CPoint point);
BOOL DoDropWithoutChecking(eDragOperation doDragOp, COleDataObject *pDataObject, CPoint point);
void MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>& fco);
Modified: trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj
==============================================================================
--- trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj Thu Jun 28 14:07:45 2012 (r1943)
+++ trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj Thu Jun 28 14:08:00 2012 (r1944)
@@ -270,7 +270,6 @@
<ClCompile Include="MgaContext.cpp" />
<ClCompile Include="MgaMappedTreeCtrl.cpp" />
<ClCompile Include="MgaObjectEventList.cpp" />
- <ClCompile Include="MgaObjectProxy.cpp" />
<ClCompile Include="ObjectEventWrapper.cpp" />
<ClCompile Include="StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
Modified: trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj.filters
==============================================================================
--- trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj.filters Thu Jun 28 14:07:45 2012 (r1943)
+++ trunk/GME/GMEActiveBrowser/GMEActiveBrowser.vcxproj.filters Thu Jun 28 14:08:00 2012 (r1944)
@@ -90,9 +90,6 @@
<ClCompile Include="MgaObjectEventList.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="MgaObjectProxy.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="ObjectEventWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Modified: trunk/GME/GMEActiveBrowser/MgaMap.h
==============================================================================
--- trunk/GME/GMEActiveBrowser/MgaMap.h Thu Jun 28 14:07:45 2012 (r1943)
+++ trunk/GME/GMEActiveBrowser/MgaMap.h Thu Jun 28 14:08:00 2012 (r1944)
@@ -21,7 +21,6 @@
class CMgaObjectProxyMapItem : public ObjectProxy
{
public:
- CMgaObjectProxyMapItem(LPUNKNOWN pMgaObject, objtype_enum type, HTREEITEM hTreeItem) : ObjectProxy(pMgaObject,type),m_hTreeItem(hTreeItem) {};
CMgaObjectProxyMapItem(CMgaObjectProxy& rSourceMgaObjectProxy, HTREEITEM hTreeItem) : ObjectProxy(rSourceMgaObjectProxy),m_hTreeItem(hTreeItem) {};
virtual ~CMgaObjectProxyMapItem() {}
HTREEITEM m_hTreeItem;
@@ -135,7 +134,7 @@
// Adds a new TreeItem Handle - ObjectProxy pair to the map
- void AddEntry(HTREEITEM hTreeItem, ObjectProxy MgaObjectProxy)
+ ObjectProxy& AddEntry(HTREEITEM hTreeItem, ObjectProxy MgaObjectProxy)
{
// Removing the elements from the maps with the keys, because CMap::SetAt would overwrite
@@ -154,6 +153,7 @@
CMgaObjectProxyMapItem* pMgaObjectProxyMapItem= new CMgaObjectProxyMapItem(MgaObjectProxy, hTreeItem);
m_MapObject2Item.SetAt(MgaObjectProxy.m_pMgaObject,pMgaObjectProxyMapItem);
+ return *pMgaObjectProxyMapItem;
}
Modified: trunk/GME/GMEActiveBrowser/MgaObjectProxy.h
==============================================================================
--- trunk/GME/GMEActiveBrowser/MgaObjectProxy.h Thu Jun 28 14:07:45 2012 (r1943)
+++ trunk/GME/GMEActiveBrowser/MgaObjectProxy.h Thu Jun 28 14:08:00 2012 (r1944)
@@ -15,10 +15,20 @@
{
public:
CMgaObjectProxy(){};
- CMgaObjectProxy(LPUNKNOWN pMgaObject, objtype_enum type);
- CMgaObjectProxy(CMgaObjectProxy&);
- virtual ~CMgaObjectProxy();
- void CMgaObjectProxy::operator =(CMgaObjectProxy &rSourceObjectProxy);
+ CMgaObjectProxy(LPUNKNOWN pMgaObject, objtype_enum type) :
+ m_pMgaObject(pMgaObject),
+ m_TypeInfo(type)
+ {
+ }
+
+ CMgaObjectProxy(const CMgaObjectProxy& that) { *this = that; }
+ virtual ~CMgaObjectProxy() {}
+
+ void CMgaObjectProxy::operator =(const CMgaObjectProxy &rSourceObjectProxy)
+ {
+ m_pMgaObject = rSourceObjectProxy.m_pMgaObject;
+ m_TypeInfo = rSourceObjectProxy.m_TypeInfo;
+ }
LPUNKNOWN m_pMgaObject;
objtype_enum m_TypeInfo;
More information about the gme-commit
mailing list