From 9fe4aa673814fe3ad6f66e013307afba4db0b0a8 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Thu, 10 Dec 1998 00:21:44 +0000 Subject: [PATCH] Nodes now track their correct indentation levels (from the content model). --- widget/src/xpwidgets/nsHTDataModel.cpp | 12 +++++++++--- widget/src/xpwidgets/nsHTDataModel.h | 2 +- widget/src/xpwidgets/nsHTItem.cpp | 8 +++++++- widget/src/xpwidgets/nsHTItem.h | 4 +++- widget/src/xpwidgets/nsHTTreeItem.h | 1 + widget/src/xpwidgets/nsHierarchicalDataItem.h | 2 ++ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/widget/src/xpwidgets/nsHTDataModel.cpp b/widget/src/xpwidgets/nsHTDataModel.cpp index 8f3eb96ab1b..53effb5b4ec 100644 --- a/widget/src/xpwidgets/nsHTDataModel.cpp +++ b/widget/src/xpwidgets/nsHTDataModel.cpp @@ -80,15 +80,21 @@ void nsHTDataModel::SetContentRootDelegate(nsIContent* pContent) // Reconstruct our visibility list (so that all items that are visible // are instantiated). Need to only look for folder and item children. All other children should be ignored. - AddNodesToArray(mContentRoot); + AddNodesToArray(mContentRoot, 0); } -void nsHTDataModel::AddNodesToArray(nsIContent* pContent) +void nsHTDataModel::AddNodesToArray(nsIContent* pContent, PRUint32 indentLevel) { // Add this child to the array (unless it is the root node). nsHierarchicalDataItem* pDataItem = CreateDataItemWithContentNode(pContent); if (pContent != mContentRoot) + { + // Add to our array mVisibleItemArray.AppendElement(pDataItem); + // Set the correct indent level for the item. + pDataItem->SetIndentationLevel(indentLevel); + indentLevel++; + } else mRootNode = pDataItem; nsHTItem* pItem = (nsHTItem*)(pDataItem->GetImplData()); @@ -110,7 +116,7 @@ void nsHTDataModel::AddNodesToArray(nsIContent* pContent) pContent->ChildAt(i, child); if (child) { - AddNodesToArray(child); + AddNodesToArray(child, indentLevel); } NS_IF_RELEASE(child); diff --git a/widget/src/xpwidgets/nsHTDataModel.h b/widget/src/xpwidgets/nsHTDataModel.h index 06f99caa092..5bdfbf48736 100644 --- a/widget/src/xpwidgets/nsHTDataModel.h +++ b/widget/src/xpwidgets/nsHTDataModel.h @@ -65,7 +65,7 @@ public: nsIImageGroup* GetImageGroup() const { NS_ADDREF(mImageGroup); return mImageGroup; } protected: - void AddNodesToArray(nsIContent* pContent); + void AddNodesToArray(nsIContent* pContent, PRUint32 indentLevel); // This recursive function is called to add nodes to the visibility array. enum { cDMImageLoaded = 0 } ; diff --git a/widget/src/xpwidgets/nsHTItem.cpp b/widget/src/xpwidgets/nsHTItem.cpp index 18d00395915..e72d24d1ffa 100644 --- a/widget/src/xpwidgets/nsHTItem.cpp +++ b/widget/src/xpwidgets/nsHTItem.cpp @@ -26,6 +26,7 @@ nsHTItem::nsHTItem(nsIContent* pContent, nsHierarchicalDataModel* pDataModel) NS_ADDREF(pContent); mContentNode = pContent; mDataModel = pDataModel; + mIndentationLevel = 0; } //-------------------------------------------------------------------- @@ -41,7 +42,12 @@ PRBool nsHTItem::IsExpandedDelegate() const PRUint32 nsHTItem::GetIndentationLevelDelegate() const { - return 0; + return mIndentationLevel; +} + +void nsHTItem::SetIndentationLevelDelegate(PRUint32 n) +{ + mIndentationLevel = n; } nsIContent* nsHTItem::FindChildWithName(const nsString& name) const diff --git a/widget/src/xpwidgets/nsHTItem.h b/widget/src/xpwidgets/nsHTItem.h index 05deb6e916f..713843dde7b 100644 --- a/widget/src/xpwidgets/nsHTItem.h +++ b/widget/src/xpwidgets/nsHTItem.h @@ -31,13 +31,15 @@ public: virtual PRBool IsExpandedDelegate() const; virtual PRUint32 GetIndentationLevelDelegate() const; - + virtual void SetIndentationLevelDelegate(PRUint32 n); + public: nsIContent* FindChildWithName(const nsString& name) const; // Caller must release the content ptr. protected: nsHierarchicalDataModel* mDataModel; nsIContent* mContentNode; + PRUint32 mIndentationLevel; }; #endif /* nsHTItem_h___ */ diff --git a/widget/src/xpwidgets/nsHTTreeItem.h b/widget/src/xpwidgets/nsHTTreeItem.h index 2df68c1f658..35c2c5f365a 100644 --- a/widget/src/xpwidgets/nsHTTreeItem.h +++ b/widget/src/xpwidgets/nsHTTreeItem.h @@ -56,6 +56,7 @@ public: // the concrete implementation. virtual PRBool IsExpanded() const { return IsExpandedDelegate(); }; virtual PRUint32 GetIndentationLevel() const { return GetIndentationLevelDelegate(); }; + virtual void SetIndentationLevel(PRUint32 n) { SetIndentationLevelDelegate(n); }; // End of delegated functions virtual void GetItemStyle(nsIDeviceContext* dc, diff --git a/widget/src/xpwidgets/nsHierarchicalDataItem.h b/widget/src/xpwidgets/nsHierarchicalDataItem.h index c61c14fa147..cc0b8a25e4b 100644 --- a/widget/src/xpwidgets/nsHierarchicalDataItem.h +++ b/widget/src/xpwidgets/nsHierarchicalDataItem.h @@ -35,7 +35,9 @@ public: virtual ~nsHierarchicalDataItem() {}; virtual PRBool IsExpanded() const = 0; + virtual PRUint32 GetIndentationLevel() const = 0; + virtual void SetIndentationLevel(PRUint32 n) = 0; public: void* GetImplData() { return mImplData; }