Skip to content

Commit

Permalink
Merge pull request #12 from cinience/dev
Browse files Browse the repository at this point in the history
Merge dev to master
  • Loading branch information
cinience committed Dec 27, 2014
2 parents cc78537 + e10243e commit 13c441a
Show file tree
Hide file tree
Showing 71 changed files with 6,014 additions and 5,456 deletions.
130 changes: 105 additions & 25 deletions DuiLib/Control/UITreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,28 +232,91 @@ namespace DuiLib
//************************************
bool CTreeNodeUI::AddAt( CControlUI* pControl, int iIndex )
{
if(NULL == static_cast<CTreeNodeUI*>(pControl->GetInterface(_T("TreeNode"))))
return false;
if (!pControl)
return false;

CTreeNodeUI* pIndexNode = static_cast<CTreeNodeUI*>(mTreeNodes.GetAt(iIndex));
if(!pIndexNode){
if(!mTreeNodes.Add(pControl))
return false;
if(_tcsicmp(pControl->GetClass(), _T("TreeNodeUI")) != 0)
return false;

if (!GetFolderButton()->IsSelected()) //add by:Redrain 2014.8.8
{
m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMDBCLICK);
}
else if(pIndexNode && !mTreeNodes.InsertAt(iIndex,pControl))
return false;

if(!pIndexNode && pTreeView && pTreeView->GetItemAt(GetTreeIndex()+1))
pIndexNode = static_cast<CTreeNodeUI*>(pTreeView->GetItemAt(GetTreeIndex()+1)->GetInterface(_T("TreeNode")));
//filter invalidate index
int iDestIndex = iIndex;
if (iDestIndex < 0)
{
iDestIndex = 0;
}
else if (iDestIndex > GetCountChild())
{
iDestIndex = GetCountChild();
}
if(iIndex != iDestIndex) iIndex = iDestIndex;

pControl = CalLocation((CTreeNodeUI*)pControl);
CTreeNodeUI* pIndexNode = static_cast<CTreeNodeUI*>(mTreeNodes.GetAt(iIndex));

if(pTreeView && pIndexNode)
return pTreeView->AddAt((CTreeNodeUI*)pControl,pIndexNode);
else
return pTreeView->Add((CTreeNodeUI*)pControl);
pControl = CalLocation((CTreeNodeUI*)pControl);

return true;
bool bRet = false;
int iTreeIndex = -1;
if (pTreeView)
{
//Get TreeView insert index
if (pIndexNode)
{
iTreeIndex = pIndexNode->GetTreeIndex();
bRet = pTreeView->AddAt((CTreeNodeUI*)pControl, iTreeIndex) >= 0;
if (bRet)
{
mTreeNodes.InsertAt(iIndex, pControl);
}
}
else
{
CTreeNodeUI *pChildNode = NULL;
//insert child node position index(new node insert to tail, default add tail)
int iChIndex = -1;
//insert child node tree-view position index(new node insert to tail)
int iChTreeIndex = -1;
//search tree index reverse
for (int i = GetCountChild(); i > 0; i++)
{
pChildNode = GetChildNode(i - 1);
iChTreeIndex = pChildNode->GetTreeIndex();
if (iChTreeIndex >= GetTreeIndex() && iChTreeIndex <= GetTreeIndex() + GetCountChild() )
{
//new child node position
iChIndex = i;
//child node tree position
iTreeIndex = iChTreeIndex + 1;
break;
}
}
//child not find tree index directly insert to parent tail
if (iTreeIndex <= GetTreeIndex())
{
iTreeIndex = GetTreeIndex() + 1;
}
//insert TreeNode to TreeView
bRet = pTreeView->AddAt((CTreeNodeUI*)pControl, iTreeIndex) >= 0;
//insert TreeNode to parent TreeNode
if (bRet)
{
if (iChIndex > 0)
bRet = mTreeNodes.InsertAt(iChIndex, pControl);
else
bRet = mTreeNodes.Add(pControl);
}
}
}
else
{
//parent TreeNode not bind TreeView just insert to parent TreeNode
bRet = mTreeNodes.InsertAt(iIndex, pControl);
}
return bRet;
}

//************************************
Expand Down Expand Up @@ -354,6 +417,10 @@ namespace DuiLib
if (_tcsicmp(_pTreeNodeUI->GetClass(), _T("TreeNodeUI")) != 0)
return false;

if (!GetFolderButton()->IsSelected()) //add by:Redrain 2014.8.8
{
m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMDBCLICK);
}
_pTreeNodeUI = CalLocation(_pTreeNodeUI);

bool nRet = true;
Expand Down Expand Up @@ -792,8 +859,8 @@ namespace DuiLib
pControl->GetFolderButton()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnFolderChanged);
pControl->GetCheckBox()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnCheckBoxChanged);

pControl->SetVisibleFolderBtn(m_bVisibleFolderBtn);
pControl->SetVisibleCheckBtn(m_bVisibleCheckBtn);
pControl->SetVisibleFolderBtn(m_bVisibleFolderBtn);
if(m_uItemMinWidth > 0)
pControl->SetMinWidth(m_uItemMinWidth);

Expand All @@ -809,6 +876,7 @@ namespace DuiLib
Add(pNode);
}
}
else

pControl->SetTreeView(this);
return true;
Expand All @@ -829,16 +897,29 @@ namespace DuiLib
if (_tcsicmp(pControl->GetClass(), _T("TreeNodeUI")) != 0)
return -1;

CTreeNodeUI* pParent = static_cast<CTreeNodeUI*>(GetItemAt(iIndex - 1));
if(!pParent)
return -1;
//filter invalidate index
int iDestIndex = iIndex;
if (iDestIndex < 0)
{
iDestIndex = 0;
}
else if (iDestIndex > GetCount())
{
iDestIndex = GetCount();
}
if(iIndex != iDestIndex) iIndex = iDestIndex;

//CTreeNodeUI* pParent = static_cast<CTreeNodeUI*>(GetItemAt(iIndex));
//if(!pParent)
// return -1;

pControl->OnNotify += MakeDelegate(this,&CTreeViewUI::OnDBClickItem);
pControl->GetFolderButton()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnFolderChanged);
pControl->GetCheckBox()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnCheckBoxChanged);

pControl->SetVisibleFolderBtn(m_bVisibleFolderBtn);
pControl->SetVisibleCheckBtn(m_bVisibleCheckBtn);
pControl->SetTreeView(this);

if(m_uItemMinWidth > 0)
pControl->SetMinWidth(m_uItemMinWidth);
Expand All @@ -852,13 +933,12 @@ namespace DuiLib
{
CTreeNodeUI* pNode = pControl->GetChildNode(nIndex);
if(pNode)
return AddAt(pNode,iIndex+1);
{
iIndex = AddAt(pNode, iIndex +1);
}
}
}
else
return iIndex+1;

return -1;
return iIndex;
}

//************************************
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
2. Kernel is MSOpen hiredis, GUILIB is duilib
3. Support official Redis 2.6 2.7 2.8 new..

![UI](https://raw.githubusercontent.com/cinience/RedisStudio/master/package/redis.png "RedisStudio UI")
![UI](https://raw.githubusercontent.com/cinience/RedisStudio/master/docs/redis.png "RedisStudio UI")

## Supported platforms

Expand Down
92 changes: 46 additions & 46 deletions RedisStudio/AbstractUI.h
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
#pragma once

class AbstraceUI : public CContainerUI, public CNotifyPump
{
public:
AbstraceUI(CPaintManagerUI* pm):m_hWnd(NULL),m_pPaintManager(pm){};

virtual ~AbstraceUI(){};

virtual void Initialize() {};

virtual CDuiString GetVirtualwndName() = 0;

virtual void RefreshWnd() = 0;

virtual int GetIndex() = 0;

virtual bool CanChange()
{
return true;
}

virtual LRESULT HandleCustomMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
bHandled = FALSE;
return 0;
}

// ÉèÖô°¿Ú¾ä±ú
inline void SetHWND(HWND hwnd)
{
m_hWnd = hwnd;
}

inline HWND GetHWND()
{
return m_hWnd;
}

inline CPaintManagerUI* GetPaintMgr()
{
return m_pPaintManager;
}
private:
CPaintManagerUI* m_pPaintManager;
HWND m_hWnd;
#pragma once

class AbstraceUI : public CContainerUI, public CNotifyPump
{
public:
AbstraceUI(CPaintManagerUI* pm):m_hWnd(NULL),m_pPaintManager(pm){};

virtual ~AbstraceUI(){};

virtual void Initialize() {};

virtual CDuiString GetVirtualwndName() = 0;

virtual void RefreshWnd() = 0;

virtual int GetIndex() = 0;

virtual bool CanChange()
{
return true;
}

virtual LRESULT HandleCustomMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
bHandled = FALSE;
return 0;
}

/// 设置窗口句柄
inline void SetHWND(HWND hwnd)
{
m_hWnd = hwnd;
}

inline HWND GetHWND()
{
return m_hWnd;
}

inline CPaintManagerUI* GetPaintMgr()
{
return m_pPaintManager;
}
private:
CPaintManagerUI* m_pPaintManager;
HWND m_hWnd;
};
Loading

0 comments on commit 13c441a

Please sign in to comment.