From d446cfc376b9248ce2b1159617e84f0cf3dd3403 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 8f3eb96ab1b6..53effb5b4ecd 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 06f99caa0929..5bdfbf487369 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 18d003959157..e72d24d1ffa1 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 05deb6e916f3..713843dde7b0 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 2df68c1f6580..35c2c5f365a3 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 c61c14fa147a..cc0b8a25e4b5 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; }