Files aren't part of Mozilla build.

This commit is contained in:
hyatt%netscape.com 2001-02-02 22:34:52 +00:00
Родитель 2863e449d8
Коммит 67cc4074e9
11 изменённых файлов: 1198 добавлений и 13 удалений

Просмотреть файл

@ -0,0 +1,26 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..\..
DIRS=public src
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -40,8 +40,8 @@ interface nsIOutlinerBoxObject : nsISupports
// Toggle the selection state of the row at the specified index.
void toggleSelect(in long index);
// Select the range specified by the range.
void rangedSelect(in nsIOutlinerRange range);
// Select the range specified by the indices.
void rangedSelect(in long startIndex, in long endIndex);
// The selected row indices in a sorted list of ranges.
readonly attribute nsIOutlinerRangeList selectedRows;
@ -65,7 +65,7 @@ interface nsIOutlinerBoxObject : nsISupports
void invalidate();
void invalidateRow(in long index);
void invalidateCell(in long row, in wstring colID);
void invalidateRange(in nsIOutlinerRange range);
void invalidateRange(in long startIndex, in long endIndex);
void invalidateScrollbar();
// A hit test that can tell you what cell the mouse is over.
@ -74,7 +74,7 @@ interface nsIOutlinerBoxObject : nsISupports
// The store is responsible for calling these notification methods when
// nodes are added or removed. Index is the position at which the new
// rows start. count is the number of new contiguous rows added. For
// non-contiguous additions, this method should be called multiple times.
// non-contiguous additions, these methods should be called multiple times.
void rowsAdded(in long index, in long count);
void rowsRemoved(in long index, in long count);
};

Просмотреть файл

@ -47,11 +47,17 @@ interface nsIOutlinerStore : nsISupports
nsISupportsArray getCellProperties(in long row, in wstring colID);
// The text for a given cell. If a column consists only of an image, then
// the empty string is returned. The alignment variable has values of 0 for left
// alignment (the default) and 1 for right alignment. The crop style has values
// 0 (for right cropping, the default), 1 for middle cropping, and 2 for left
// cropping.
wstring getCellText(in long row, in wstring colID, out long alignment, out long cropstyle);
// the empty string is returned. The level is an integer value that represents
// the level of indentation. It is multiplied by the width specified in the
// :moz-outliner-indentation element to compute the exact indendation.
//
// The alignment variable has values of 0 for left
// alignment (the default) and 1 for right alignment.
//
// The crop style has values 0 (for right cropping, the default), 1 for middle
// cropping, and 2 for left cropping.
wstring getCellText(in long row, in wstring colID, out long level,
out long alignment, out long cropstyle);
// Ensures that a row at a given index is visible.
void scrollToRow(in long index);
@ -70,6 +76,15 @@ interface nsIOutlinerStore : nsISupports
// Called on the store when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
void cycleCell(in long row, in wstring colID);
// A command API that can be used to invoke commands on the selection.
void performAction(in wstring action);
// A command API that can be used to invoke commands on a specific row.
void performActionOnRow(in wstring action, in long row);
// A command API that can be used to invoke commands on a specific cell.
void performActionOnCell(in wstring action, in long row, in wstring colID);
};
%{C++

Просмотреть файл

@ -0,0 +1,62 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..\..\..
LIBRARY_NAME=raptorxuloutliner_s
MODULE=raptor
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
CPPSRCS= \
nsOutlinerBoxObject.cpp \
nsOutlinerBodyFrame.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsOutlinerBoxObject.obj \
.\$(OBJDIR)\nsOutlinerBodyFrame.obj \
$(NULL)
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
-I..\.. \
-I..\..\..\..\..\html\style\src -I..\..\..\..\..\html\base\src -I$(PUBLIC)\dom \
-I..\..\..\..\content\src \
-I..\..\..\..\..\html\forms\src \
-I$(PUBLIC)\netlib -I..\..\..\..\..\base\src -I$(PUBLIC)\pref \
-I..\..\..\..\..\xml\content\src \
-I..\..\..\..\..\base\public
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

Просмотреть файл

@ -0,0 +1,192 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nsOutlinerBodyFrame.h"
#include "nsXULAtoms.h"
#include "nsIContent.h"
#include "nsIStyleContext.h"
//
// NS_NewOutlinerFrame
//
// Creates a new TreeCell frame
//
nsresult
NS_NewOutlinerBodyFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsOutlinerBodyFrame* it = new (aPresShell) nsOutlinerBodyFrame(aPresShell);
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewOutlinerFrame
// Constructor
nsOutlinerBodyFrame::nsOutlinerBodyFrame(nsIPresShell* aPresShell)
:nsLeafBoxFrame(aPresShell),
mRowStyleCache(nsnull),
mCellStyleCache(nsnull),
mTopRowIndex(0)
{}
// Destructor
nsOutlinerBodyFrame::~nsOutlinerBodyFrame()
{
}
NS_IMETHODIMP_(nsrefcnt)
nsOutlinerBodyFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsOutlinerBodyFrame::Release(void)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetStore(nsIOutlinerStore * *aStore)
{
*aStore = mStore;
NS_IF_ADDREF(*aStore);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::SetStore(nsIOutlinerStore * aStore)
{
mStore = aStore;
// Changing the store causes us to refetch our data. This will
// necessarily entail a full invalidation of the outliner.
mTopRowIndex = 0;
Invalidate();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::Select(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::ToggleSelect(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::RangedSelect(PRInt32 aStartIndex, PRInt32 aEndIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetSelectedRows(nsIOutlinerRangeList** aResult)
{
*aResult = mSelectedRows;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::ClearSelection()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvertSelection()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::SelectAll()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetIndexOfVisibleRow(PRInt32 *_retval)
{
*_retval = mTopRowIndex;
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetPageCount(PRInt32 *_retval)
{
*_retval = mPageCount;
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::Invalidate()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateRow(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateCell(PRInt32 aRow, const PRUnichar *aColID)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateRange(PRInt32 aStart, PRInt32 aEnd)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateScrollbar()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetCellAt(PRInt32 x, PRInt32 y, PRInt32 *row, PRUnichar **colID)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::RowsAdded(PRInt32 index, PRInt32 count)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::RowsRemoved(PRInt32 index, PRInt32 count)
{
return NS_OK;
}
//
// QueryInterface
//
NS_INTERFACE_MAP_BEGIN(nsOutlinerBodyFrame)
NS_INTERFACE_MAP_ENTRY(nsIOutlinerBoxObject)
NS_INTERFACE_MAP_END_INHERITING(nsLeafFrame)

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsLeafBoxFrame.h"
#include "nsIOutlinerBoxObject.h"
#include "nsIOutlinerStore.h"
#include "nsIOutlinerRangeList.h"
class nsSupportsHashtable;
class nsOutlinerBodyFrame : public nsLeafBoxFrame, public nsIOutlinerBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERBOXOBJECT
friend nsresult NS_NewOutlinerBodyFrame(nsIPresShell* aPresShell,
nsIFrame** aNewFrame);
protected:
nsOutlinerBodyFrame(nsIPresShell* aPresShell);
virtual ~nsOutlinerBodyFrame();
protected: // Data Members
// The current store for this outliner widget. We get all of our row and cell data
// from the store.
nsCOMPtr<nsIOutlinerStore> mStore;
// A cache of all the style contexts we have seen for rows of the tree. This is a mapping from
// a list of atoms to a corresponding style context. This cache stores every combination that
// occurs in the tree, so for n distinct row properties, this cache could have 2 to the n entries
// (the power set of all row properties).
nsSupportsHashtable* mRowStyleCache;
// A cache of all the style contexts we have seen for cells of the tree. This is a mapping from
// a list of atoms to a corresponding style context. This cache stores every combination that
// occurs in the tree, so for n distinct cell properties, this cache could have 2 to the n entries
// (the power set of all cell properties).
nsSupportsHashtable* mCellStyleCache;
// The index of the first visible row and the # of rows visible onscreen.
// The outliner only examines onscreen rows, starting from
// this index and going up to index+pageCount.
PRInt32 mTopRowIndex;
PRInt32 mPageCount;
// Our current selection.
nsCOMPtr<nsIOutlinerRangeList> mSelectedRows;
}; // class nsOutlinerBodyFrame

Просмотреть файл

@ -0,0 +1,278 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nsIOutlinerBoxObject.h"
#include "nsBoxObject.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsIFrame.h"
class nsOutlinerBoxObject : public nsIOutlinerBoxObject, public nsBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERBOXOBJECT
nsOutlinerBoxObject();
virtual ~nsOutlinerBoxObject();
nsIOutlinerBoxObject* GetOutlinerBody();
//NS_PIBOXOBJECT interfaces
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aPresShell);
NS_IMETHOD SetDocument(nsIDocument* aDocument);
};
/* Implementation file */
NS_IMPL_ISUPPORTS_INHERITED(nsOutlinerBoxObject, nsBoxObject, nsIOutlinerBoxObject)
NS_IMETHODIMP
nsOutlinerBoxObject::SetDocument(nsIDocument* aDocument)
{
// this should only be called with a null document, which indicates
// that we're being torn down.
NS_ASSERTION(aDocument == nsnull, "SetDocument called with non-null document");
return nsBoxObject::SetDocument(aDocument);
}
nsOutlinerBoxObject::nsOutlinerBoxObject()
{
NS_INIT_ISUPPORTS();
}
nsOutlinerBoxObject::~nsOutlinerBoxObject()
{
/* destructor code */
}
NS_IMETHODIMP nsOutlinerBoxObject::Init(nsIContent* aContent, nsIPresShell* aPresShell)
{
nsresult rv = nsBoxObject::Init(aContent, aPresShell);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsIOutlinerBoxObject*
nsOutlinerBoxObject::GetOutlinerBody()
{
nsIFrame* frame = GetFrame();
if (!frame)
return nsnull;
// For now we assume that the outliner body is under child 1 somewhere (since child 0 holds
// the columns).
nsCOMPtr<nsIPresContext> cx;
mPresShell->GetPresContext(getter_AddRefs(cx));
nsIFrame* currFrame;
frame->FirstChild(cx, nsnull, &currFrame);
if (!currFrame)
return nsnull;
currFrame->GetNextSibling(&currFrame);
if (!currFrame)
return nsnull;
nsIFrame* childFrame;
currFrame->FirstChild(cx, nsnull, &childFrame);
while (childFrame) {
nsIOutlinerBoxObject* result = nsnull;
childFrame->QueryInterface(NS_GET_IID(nsIOutlinerBoxObject), (void**)&result);
if (result)
return result;
childFrame->GetNextSibling(&childFrame);
}
return nsnull;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetStore(nsIOutlinerStore * *aStore)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetStore(aStore);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::SetStore(nsIOutlinerStore * aStore)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->SetStore(aStore);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::Select(PRInt32 aIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->Select(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::ToggleSelect(PRInt32 aIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->ToggleSelect(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::RangedSelect(PRInt32 aStartIndex, PRInt32 aEndIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->RangedSelect(aStartIndex, aEndIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetSelectedRows(nsIOutlinerRangeList * *aSelectedRows)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetSelectedRows(aSelectedRows);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::ClearSelection()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->ClearSelection();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvertSelection()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvertSelection();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::SelectAll()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->SelectAll();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetIndexOfVisibleRow(PRInt32 *_retval)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetIndexOfVisibleRow(_retval);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetPageCount(PRInt32 *_retval)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetPageCount(_retval);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::Invalidate()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->Invalidate();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateRow(PRInt32 aIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateRow(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateCell(PRInt32 aRow, const PRUnichar *aColID)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateCell(aRow, aColID);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateRange(PRInt32 aStart, PRInt32 aEnd)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateRange(aStart, aEnd);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateScrollbar()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateScrollbar();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetCellAt(PRInt32 x, PRInt32 y, PRInt32 *row, PRUnichar **colID)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetCellAt(x, y, row, colID);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::RowsAdded(PRInt32 index, PRInt32 count)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->RowsAdded(index, count);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::RowsRemoved(PRInt32 index, PRInt32 count)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->RowsRemoved(index, count);
return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewOutlinerBoxObject(nsIBoxObject** aResult)
{
*aResult = new nsOutlinerBoxObject;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

Просмотреть файл

@ -40,8 +40,8 @@ interface nsIOutlinerBoxObject : nsISupports
// Toggle the selection state of the row at the specified index.
void toggleSelect(in long index);
// Select the range specified by the range.
void rangedSelect(in nsIOutlinerRange range);
// Select the range specified by the indices.
void rangedSelect(in long startIndex, in long endIndex);
// The selected row indices in a sorted list of ranges.
readonly attribute nsIOutlinerRangeList selectedRows;
@ -65,7 +65,7 @@ interface nsIOutlinerBoxObject : nsISupports
void invalidate();
void invalidateRow(in long index);
void invalidateCell(in long row, in wstring colID);
void invalidateRange(in nsIOutlinerRange range);
void invalidateRange(in long startIndex, in long endIndex);
void invalidateScrollbar();
// A hit test that can tell you what cell the mouse is over.
@ -74,7 +74,7 @@ interface nsIOutlinerBoxObject : nsISupports
// The store is responsible for calling these notification methods when
// nodes are added or removed. Index is the position at which the new
// rows start. count is the number of new contiguous rows added. For
// non-contiguous additions, this method should be called multiple times.
// non-contiguous additions, these methods should be called multiple times.
void rowsAdded(in long index, in long count);
void rowsRemoved(in long index, in long count);
};

Просмотреть файл

@ -0,0 +1,192 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nsOutlinerBodyFrame.h"
#include "nsXULAtoms.h"
#include "nsIContent.h"
#include "nsIStyleContext.h"
//
// NS_NewOutlinerFrame
//
// Creates a new TreeCell frame
//
nsresult
NS_NewOutlinerBodyFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsOutlinerBodyFrame* it = new (aPresShell) nsOutlinerBodyFrame(aPresShell);
if (!it)
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
return NS_OK;
} // NS_NewOutlinerFrame
// Constructor
nsOutlinerBodyFrame::nsOutlinerBodyFrame(nsIPresShell* aPresShell)
:nsLeafBoxFrame(aPresShell),
mRowStyleCache(nsnull),
mCellStyleCache(nsnull),
mTopRowIndex(0)
{}
// Destructor
nsOutlinerBodyFrame::~nsOutlinerBodyFrame()
{
}
NS_IMETHODIMP_(nsrefcnt)
nsOutlinerBodyFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsOutlinerBodyFrame::Release(void)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetStore(nsIOutlinerStore * *aStore)
{
*aStore = mStore;
NS_IF_ADDREF(*aStore);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::SetStore(nsIOutlinerStore * aStore)
{
mStore = aStore;
// Changing the store causes us to refetch our data. This will
// necessarily entail a full invalidation of the outliner.
mTopRowIndex = 0;
Invalidate();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::Select(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::ToggleSelect(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::RangedSelect(PRInt32 aStartIndex, PRInt32 aEndIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetSelectedRows(nsIOutlinerRangeList** aResult)
{
*aResult = mSelectedRows;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::ClearSelection()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvertSelection()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::SelectAll()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetIndexOfVisibleRow(PRInt32 *_retval)
{
*_retval = mTopRowIndex;
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetPageCount(PRInt32 *_retval)
{
*_retval = mPageCount;
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::Invalidate()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateRow(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateCell(PRInt32 aRow, const PRUnichar *aColID)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateRange(PRInt32 aStart, PRInt32 aEnd)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::InvalidateScrollbar()
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::GetCellAt(PRInt32 x, PRInt32 y, PRInt32 *row, PRUnichar **colID)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::RowsAdded(PRInt32 index, PRInt32 count)
{
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBodyFrame::RowsRemoved(PRInt32 index, PRInt32 count)
{
return NS_OK;
}
//
// QueryInterface
//
NS_INTERFACE_MAP_BEGIN(nsOutlinerBodyFrame)
NS_INTERFACE_MAP_ENTRY(nsIOutlinerBoxObject)
NS_INTERFACE_MAP_END_INHERITING(nsLeafFrame)

Просмотреть файл

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsLeafBoxFrame.h"
#include "nsIOutlinerBoxObject.h"
#include "nsIOutlinerStore.h"
#include "nsIOutlinerRangeList.h"
class nsSupportsHashtable;
class nsOutlinerBodyFrame : public nsLeafBoxFrame, public nsIOutlinerBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERBOXOBJECT
friend nsresult NS_NewOutlinerBodyFrame(nsIPresShell* aPresShell,
nsIFrame** aNewFrame);
protected:
nsOutlinerBodyFrame(nsIPresShell* aPresShell);
virtual ~nsOutlinerBodyFrame();
protected: // Data Members
// The current store for this outliner widget. We get all of our row and cell data
// from the store.
nsCOMPtr<nsIOutlinerStore> mStore;
// A cache of all the style contexts we have seen for rows of the tree. This is a mapping from
// a list of atoms to a corresponding style context. This cache stores every combination that
// occurs in the tree, so for n distinct row properties, this cache could have 2 to the n entries
// (the power set of all row properties).
nsSupportsHashtable* mRowStyleCache;
// A cache of all the style contexts we have seen for cells of the tree. This is a mapping from
// a list of atoms to a corresponding style context. This cache stores every combination that
// occurs in the tree, so for n distinct cell properties, this cache could have 2 to the n entries
// (the power set of all cell properties).
nsSupportsHashtable* mCellStyleCache;
// The index of the first visible row and the # of rows visible onscreen.
// The outliner only examines onscreen rows, starting from
// this index and going up to index+pageCount.
PRInt32 mTopRowIndex;
PRInt32 mPageCount;
// Our current selection.
nsCOMPtr<nsIOutlinerRangeList> mSelectedRows;
}; // class nsOutlinerBodyFrame

Просмотреть файл

@ -0,0 +1,278 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nsIOutlinerBoxObject.h"
#include "nsBoxObject.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsIFrame.h"
class nsOutlinerBoxObject : public nsIOutlinerBoxObject, public nsBoxObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERBOXOBJECT
nsOutlinerBoxObject();
virtual ~nsOutlinerBoxObject();
nsIOutlinerBoxObject* GetOutlinerBody();
//NS_PIBOXOBJECT interfaces
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aPresShell);
NS_IMETHOD SetDocument(nsIDocument* aDocument);
};
/* Implementation file */
NS_IMPL_ISUPPORTS_INHERITED(nsOutlinerBoxObject, nsBoxObject, nsIOutlinerBoxObject)
NS_IMETHODIMP
nsOutlinerBoxObject::SetDocument(nsIDocument* aDocument)
{
// this should only be called with a null document, which indicates
// that we're being torn down.
NS_ASSERTION(aDocument == nsnull, "SetDocument called with non-null document");
return nsBoxObject::SetDocument(aDocument);
}
nsOutlinerBoxObject::nsOutlinerBoxObject()
{
NS_INIT_ISUPPORTS();
}
nsOutlinerBoxObject::~nsOutlinerBoxObject()
{
/* destructor code */
}
NS_IMETHODIMP nsOutlinerBoxObject::Init(nsIContent* aContent, nsIPresShell* aPresShell)
{
nsresult rv = nsBoxObject::Init(aContent, aPresShell);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsIOutlinerBoxObject*
nsOutlinerBoxObject::GetOutlinerBody()
{
nsIFrame* frame = GetFrame();
if (!frame)
return nsnull;
// For now we assume that the outliner body is under child 1 somewhere (since child 0 holds
// the columns).
nsCOMPtr<nsIPresContext> cx;
mPresShell->GetPresContext(getter_AddRefs(cx));
nsIFrame* currFrame;
frame->FirstChild(cx, nsnull, &currFrame);
if (!currFrame)
return nsnull;
currFrame->GetNextSibling(&currFrame);
if (!currFrame)
return nsnull;
nsIFrame* childFrame;
currFrame->FirstChild(cx, nsnull, &childFrame);
while (childFrame) {
nsIOutlinerBoxObject* result = nsnull;
childFrame->QueryInterface(NS_GET_IID(nsIOutlinerBoxObject), (void**)&result);
if (result)
return result;
childFrame->GetNextSibling(&childFrame);
}
return nsnull;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetStore(nsIOutlinerStore * *aStore)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetStore(aStore);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::SetStore(nsIOutlinerStore * aStore)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->SetStore(aStore);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::Select(PRInt32 aIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->Select(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::ToggleSelect(PRInt32 aIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->ToggleSelect(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::RangedSelect(PRInt32 aStartIndex, PRInt32 aEndIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->RangedSelect(aStartIndex, aEndIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetSelectedRows(nsIOutlinerRangeList * *aSelectedRows)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetSelectedRows(aSelectedRows);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::ClearSelection()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->ClearSelection();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvertSelection()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvertSelection();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::SelectAll()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->SelectAll();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetIndexOfVisibleRow(PRInt32 *_retval)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetIndexOfVisibleRow(_retval);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetPageCount(PRInt32 *_retval)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetPageCount(_retval);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::Invalidate()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->Invalidate();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateRow(PRInt32 aIndex)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateRow(aIndex);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateCell(PRInt32 aRow, const PRUnichar *aColID)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateCell(aRow, aColID);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateRange(PRInt32 aStart, PRInt32 aEnd)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateRange(aStart, aEnd);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::InvalidateScrollbar()
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->InvalidateScrollbar();
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::GetCellAt(PRInt32 x, PRInt32 y, PRInt32 *row, PRUnichar **colID)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->GetCellAt(x, y, row, colID);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::RowsAdded(PRInt32 index, PRInt32 count)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->RowsAdded(index, count);
return NS_OK;
}
NS_IMETHODIMP nsOutlinerBoxObject::RowsRemoved(PRInt32 index, PRInt32 count)
{
nsIOutlinerBoxObject* body = GetOutlinerBody();
if (body)
return body->RowsRemoved(index, count);
return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewOutlinerBoxObject(nsIBoxObject** aResult)
{
*aResult = new nsOutlinerBoxObject;
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}