This commit is contained in:
hyatt%netscape.com 2001-02-14 19:39:20 +00:00
Родитель de9e4a3fe2
Коммит f605fd6cb5
12 изменённых файлов: 482 добавлений и 12 удалений

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

@ -23,7 +23,6 @@
*/
interface nsIOutlinerBoxObject;
interface nsIOutlinerRangeList;
#include "nsISupports.idl"
@ -33,9 +32,6 @@ interface nsIOutlinerSelection : nsISupports
// The outliner widget for this selection.
attribute nsIOutlinerBoxObject outliner;
// The current selected indices.
attribute nsIOutlinerRangeList selectedRows;
// Indicates whether or not the row at the specified index is
// part of the selection.
boolean isSelected(in long index);
@ -57,6 +53,17 @@ interface nsIOutlinerSelection : nsISupports
// Selects all rows.
void selectAll();
// This attribute is a boolean indicating whether or not the
// "select" event should fire when the selection is changed using
// one of our methods. A view can use this to temporarily suppress
// the selection while manipulating all of the indices, e.g., on
// a sort.
attribute boolean selectEventsSuppressed;
// The current item (the one that gets a focus rect in addition to being
// selected).
attribute long currentIndex;
};
%{C++

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

@ -30,12 +30,14 @@ CPPSRCS= \
nsOutlinerBoxObject.cpp \
nsOutlinerBodyFrame.cpp \
nsOutlinerColFrame.cpp \
nsOutlinerSelection.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsOutlinerBoxObject.obj \
.\$(OBJDIR)\nsOutlinerBodyFrame.obj \
.\$(OBJDIR)\nsOutlinerColFrame.obj \
.\$(OBJDIR)\nsOutlinerSelection.obj \
$(NULL)
EXPORTS = \

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

@ -29,6 +29,8 @@
#include "nsIScrollbarFrame.h"
#include "nsOutlinerBodyFrame.h"
#include "nsOutlinerSelection.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
@ -280,9 +282,16 @@ NS_IMETHODIMP nsOutlinerBodyFrame::SetView(nsIOutlinerView * aView)
// Outliner, meet the view.
mView = aView;
if (mView)
if (mView) {
// View, meet the outliner.
mView->SetOutliner(this);
// Give the view a new empty selection object to play with.
nsCOMPtr<nsIOutlinerSelection> sel;
NS_NewOutlinerSelection(this, getter_AddRefs(sel));
mView->SetSelection(sel);
}
// Changing the view causes us to refetch our data. This will
// necessarily entail a full invalidation of the outliner.
@ -382,6 +391,22 @@ NS_IMETHODIMP nsOutlinerBodyFrame::RowsRemoved(PRInt32 index, PRInt32 count)
return NS_OK;
}
void
nsOutlinerBodyFrame::PrefillPropertyArray(PRInt32 aRowIndex, const PRUnichar* aColID)
{
// XXX Automatically fill in the following props: container, open, selected, focused
// And colID too, if it is non-empty.
mScratchArray->Clear();
nsCOMPtr<nsIOutlinerSelection> selection;
mView->GetSelection(getter_AddRefs(selection));
PRBool isSelected;
selection->IsSelected(aRowIndex, &isSelected);
if (isSelected)
mScratchArray->AppendElement(nsHTMLAtoms::selected);
}
PRInt32 nsOutlinerBodyFrame::GetRowHeight(nsIPresContext* aPresContext)
{
// Look up the correct height. It is equal to the specified height
@ -492,7 +517,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec
// Now obtain the properties for our row.
// XXX Automatically fill in the following props: open, container, selected, focused
mScratchArray->Clear();
PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING(""));
mView->GetRowProperties(aRowIndex, mScratchArray);
// Resolve style for the row. It contains all the info we need to lay ourselves

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

@ -224,6 +224,10 @@ protected:
// Builds our cache of column info.
void EnsureColumns(nsIPresContext* aContext);
// Use to auto-fill some of the common properties without the view having to do it.
// Examples include container, open, selected, and focused.
void PrefillPropertyArray(PRInt32 aRowIndex, const PRUnichar* aColID);
protected: // Data Members
// Our cached pres context.
nsIPresContext* mPresContext;

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

@ -0,0 +1,118 @@
/* -*- 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)
*
*/
#include "nsCOMPtr.h"
#include "nsOutlinerSelection.h"
#include "nsIOutlinerBoxObject.h"
nsOutlinerSelection::nsOutlinerSelection(nsIOutlinerBoxObject* aOutliner)
{
NS_INIT_ISUPPORTS();
mOutliner = aOutliner;
}
nsOutlinerSelection::~nsOutlinerSelection()
{
}
NS_IMPL_ISUPPORTS1(nsOutlinerSelection, nsIOutlinerSelection)
NS_IMETHODIMP nsOutlinerSelection::GetOutliner(nsIOutlinerBoxObject * *aOutliner)
{
NS_IF_ADDREF(mOutliner);
*aOutliner = mOutliner;
return NS_OK;
}
NS_IMETHODIMP nsOutlinerSelection::SetOutliner(nsIOutlinerBoxObject * aOutliner)
{
mOutliner = aOutliner; // WEAK
return NS_OK;
}
NS_IMETHODIMP nsOutlinerSelection::IsSelected(PRInt32 index, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::Select(PRInt32 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::ToggleSelect(PRInt32 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::RangedSelect(PRInt32 startIndex, PRInt32 endIndex)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::ClearSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::InvertSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::SelectAll()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::GetSelectEventsSuppressed(PRBool *aSelectEventsSuppressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::SetSelectEventsSuppressed(PRBool aSelectEventsSuppressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::GetCurrentIndex(PRInt32 *aCurrentIndex)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::SetCurrentIndex(PRInt32 aCurrentIndex)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////////
nsresult
NS_NewOutlinerSelection(nsIOutlinerBoxObject* aOutliner, nsIOutlinerSelection** aResult)
{
*aResult = new nsOutlinerSelection(aOutliner);
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

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

@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
* David W. Hyatt <hyatt@netscape.com> (Original Author)
*/
#ifndef nsOutlinerSelection_h__
#define nsOutlinerSelection_h__
#include "nsIOutlinerSelection.h"
class nsIOutlinerBoxObject;
class nsOutlinerSelection : public nsIOutlinerSelection
{
public:
nsOutlinerSelection(nsIOutlinerBoxObject* aOutliner);
virtual ~nsOutlinerSelection();
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERSELECTION
protected:
// Members
nsIOutlinerBoxObject* mOutliner; // [Weak]. The outliner will hold on to us through the view and let go when it dies.
};
extern nsresult
NS_NewOutlinerSelection(nsIOutlinerBoxObject* aOutliner,
nsIOutlinerSelection** aResult);
#endif

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

@ -23,7 +23,6 @@
*/
interface nsIOutlinerBoxObject;
interface nsIOutlinerRangeList;
#include "nsISupports.idl"
@ -33,9 +32,6 @@ interface nsIOutlinerSelection : nsISupports
// The outliner widget for this selection.
attribute nsIOutlinerBoxObject outliner;
// The current selected indices.
attribute nsIOutlinerRangeList selectedRows;
// Indicates whether or not the row at the specified index is
// part of the selection.
boolean isSelected(in long index);
@ -57,6 +53,17 @@ interface nsIOutlinerSelection : nsISupports
// Selects all rows.
void selectAll();
// This attribute is a boolean indicating whether or not the
// "select" event should fire when the selection is changed using
// one of our methods. A view can use this to temporarily suppress
// the selection while manipulating all of the indices, e.g., on
// a sort.
attribute boolean selectEventsSuppressed;
// The current item (the one that gets a focus rect in addition to being
// selected).
attribute long currentIndex;
};
%{C++

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

@ -29,6 +29,8 @@
#include "nsIScrollbarFrame.h"
#include "nsOutlinerBodyFrame.h"
#include "nsOutlinerSelection.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
@ -280,9 +282,16 @@ NS_IMETHODIMP nsOutlinerBodyFrame::SetView(nsIOutlinerView * aView)
// Outliner, meet the view.
mView = aView;
if (mView)
if (mView) {
// View, meet the outliner.
mView->SetOutliner(this);
// Give the view a new empty selection object to play with.
nsCOMPtr<nsIOutlinerSelection> sel;
NS_NewOutlinerSelection(this, getter_AddRefs(sel));
mView->SetSelection(sel);
}
// Changing the view causes us to refetch our data. This will
// necessarily entail a full invalidation of the outliner.
@ -382,6 +391,22 @@ NS_IMETHODIMP nsOutlinerBodyFrame::RowsRemoved(PRInt32 index, PRInt32 count)
return NS_OK;
}
void
nsOutlinerBodyFrame::PrefillPropertyArray(PRInt32 aRowIndex, const PRUnichar* aColID)
{
// XXX Automatically fill in the following props: container, open, selected, focused
// And colID too, if it is non-empty.
mScratchArray->Clear();
nsCOMPtr<nsIOutlinerSelection> selection;
mView->GetSelection(getter_AddRefs(selection));
PRBool isSelected;
selection->IsSelected(aRowIndex, &isSelected);
if (isSelected)
mScratchArray->AppendElement(nsHTMLAtoms::selected);
}
PRInt32 nsOutlinerBodyFrame::GetRowHeight(nsIPresContext* aPresContext)
{
// Look up the correct height. It is equal to the specified height
@ -492,7 +517,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec
// Now obtain the properties for our row.
// XXX Automatically fill in the following props: open, container, selected, focused
mScratchArray->Clear();
PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING(""));
mView->GetRowProperties(aRowIndex, mScratchArray);
// Resolve style for the row. It contains all the info we need to lay ourselves

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

@ -224,6 +224,10 @@ protected:
// Builds our cache of column info.
void EnsureColumns(nsIPresContext* aContext);
// Use to auto-fill some of the common properties without the view having to do it.
// Examples include container, open, selected, and focused.
void PrefillPropertyArray(PRInt32 aRowIndex, const PRUnichar* aColID);
protected: // Data Members
// Our cached pres context.
nsIPresContext* mPresContext;

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

@ -0,0 +1,118 @@
/* -*- 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)
*
*/
#include "nsCOMPtr.h"
#include "nsOutlinerSelection.h"
#include "nsIOutlinerBoxObject.h"
nsOutlinerSelection::nsOutlinerSelection(nsIOutlinerBoxObject* aOutliner)
{
NS_INIT_ISUPPORTS();
mOutliner = aOutliner;
}
nsOutlinerSelection::~nsOutlinerSelection()
{
}
NS_IMPL_ISUPPORTS1(nsOutlinerSelection, nsIOutlinerSelection)
NS_IMETHODIMP nsOutlinerSelection::GetOutliner(nsIOutlinerBoxObject * *aOutliner)
{
NS_IF_ADDREF(mOutliner);
*aOutliner = mOutliner;
return NS_OK;
}
NS_IMETHODIMP nsOutlinerSelection::SetOutliner(nsIOutlinerBoxObject * aOutliner)
{
mOutliner = aOutliner; // WEAK
return NS_OK;
}
NS_IMETHODIMP nsOutlinerSelection::IsSelected(PRInt32 index, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::Select(PRInt32 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::ToggleSelect(PRInt32 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::RangedSelect(PRInt32 startIndex, PRInt32 endIndex)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::ClearSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::InvertSelection()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::SelectAll()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::GetSelectEventsSuppressed(PRBool *aSelectEventsSuppressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::SetSelectEventsSuppressed(PRBool aSelectEventsSuppressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::GetCurrentIndex(PRInt32 *aCurrentIndex)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsOutlinerSelection::SetCurrentIndex(PRInt32 aCurrentIndex)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////////
nsresult
NS_NewOutlinerSelection(nsIOutlinerBoxObject* aOutliner, nsIOutlinerSelection** aResult)
{
*aResult = new nsOutlinerSelection(aOutliner);
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

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

@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
* David W. Hyatt <hyatt@netscape.com> (Original Author)
*/
#ifndef nsOutlinerSelection_h__
#define nsOutlinerSelection_h__
#include "nsIOutlinerSelection.h"
class nsIOutlinerBoxObject;
class nsOutlinerSelection : public nsIOutlinerSelection
{
public:
nsOutlinerSelection(nsIOutlinerBoxObject* aOutliner);
virtual ~nsOutlinerSelection();
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTLINERSELECTION
protected:
// Members
nsIOutlinerBoxObject* mOutliner; // [Weak]. The outliner will hold on to us through the view and let go when it dies.
};
extern nsresult
NS_NewOutlinerSelection(nsIOutlinerBoxObject* aOutliner,
nsIOutlinerSelection** aResult);
#endif

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

@ -21,6 +21,70 @@
<children/>
<xul:scrollbar align="vertical" class="outliner-scrollbar"/>
</content>
<handlers>
<!-- If there is no modifier key, we select on mousedown, not
click, so that drags work correctly. -->
<handler event="mousedown">
<![CDATA[
if (!event.ctrlKey && !event.shiftKey && !event.metaKey) {
var row = {};
var col = {};
var v = this.parentNode.outlinerBoxObject.view;
v.getCellAt(event.x, event.y, row, col);
// XXX Check the col to see if it's a cycler. If so,
// don't select.
if (!v.selection.isSelected(row.value))
v.selection.select(row.value);
v.selection.currentIndex = row.value;
}
]]>
</handler>
<!-- On a click (up+down on the same item), deselect everything
except this item. -->
<handler event="click">
<![CDATA[
// XXX Check for cycler.
if (event.button != 1) return;
var row = {};
var col = {};
var v = this.parentNode.outlinerBoxObject.view;
v.getCellAt(event.x, event.y, row, col);
if (event.ctrlKey || event.metaKey) {
v.selection.toggleSelect(row.value);
v.selection.currentIndex = row.value;
}
else if (event.shiftKey) {
v.selection.rangedSelect(null, row.value);
v.currentIndex = row.value;
}
else {
/* We want to deselect all the selected items except what was
clicked, UNLESS it was a right-click. We have to do this
in click rather than mousedown so that you can drag a
selected group of items */
if (event.button == 1)
v.selection.select(row.value);
}
]]>
</handler>
<!-- double-click -->
<handler event="click" clickcount="2">
<![CDATA[
var row = {};
var col = {};
// XXX Again, we need to check the cycler.
var v = this.parentNode.outlinerBoxObject.view;
v.getCellAt(event.x, event.y, row, col);
if (v.isContainer(row.value))
v.toggleOpenState(row.value);
]]>
</handler>
</handlers>
</binding>
<binding id="outlinerbody"/>