2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-02-02 22:34:52 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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/
|
2001-02-02 22:34:52 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
2001-02-02 22:34:52 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-02-02 22:34:52 +00:00
|
|
|
*
|
2001-12-11 06:55:21 +00:00
|
|
|
* Contributor(s):
|
2004-05-04 14:26:17 +00:00
|
|
|
* Dave Hyatt <hyatt@mozilla.org> (Original Author)
|
2004-04-17 05:53:38 +00:00
|
|
|
* Dean Tessman <dean_tessman@hotmail.com>
|
|
|
|
* Brian Ryner <bryner@brianryner.com>
|
2004-10-22 18:33:55 +00:00
|
|
|
* Jan Varga <varga@ku.sk>
|
2005-08-30 18:36:15 +00:00
|
|
|
* Nate Nielsen <nielsen@memberwebs.com>
|
2006-05-12 16:30:53 +00:00
|
|
|
* Mark Banner <mark@standard8.demon.co.uk>
|
2001-12-11 06:55:21 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-02-02 22:34:52 +00:00
|
|
|
|
|
|
|
#include "nsLeafBoxFrame.h"
|
2006-01-30 21:29:10 +00:00
|
|
|
#include "nsPITreeBoxObject.h"
|
2002-03-29 02:46:01 +00:00
|
|
|
#include "nsITreeView.h"
|
2001-02-06 02:22:31 +00:00
|
|
|
#include "nsICSSPseudoComparator.h"
|
2001-02-09 12:12:53 +00:00
|
|
|
#include "nsIScrollbarMediator.h"
|
2001-05-11 01:51:04 +00:00
|
|
|
#include "nsIDragSession.h"
|
2001-12-11 06:55:21 +00:00
|
|
|
#include "nsITimer.h"
|
2002-07-19 22:36:46 +00:00
|
|
|
#include "nsIReflowCallback.h"
|
2003-03-16 23:26:31 +00:00
|
|
|
#include "nsILookAndFeel.h"
|
2003-04-15 03:07:34 +00:00
|
|
|
#include "nsValueArray.h"
|
2004-04-17 05:53:38 +00:00
|
|
|
#include "nsTreeStyleCache.h"
|
|
|
|
#include "nsTreeColumns.h"
|
|
|
|
#include "nsTreeImageListener.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2006-01-30 18:57:38 +00:00
|
|
|
#include "nsDataHashtable.h"
|
2006-01-30 20:49:02 +00:00
|
|
|
#include "imgIRequest.h"
|
|
|
|
#include "imgIDecoderObserver.h"
|
2006-01-30 18:57:38 +00:00
|
|
|
|
|
|
|
// An entry in the tree's image cache
|
|
|
|
struct nsTreeImageCacheEntry
|
|
|
|
{
|
2006-01-30 19:35:57 +00:00
|
|
|
nsTreeImageCacheEntry() {}
|
2006-01-30 19:34:51 +00:00
|
|
|
nsTreeImageCacheEntry(imgIRequest *aRequest, imgIDecoderObserver *aListener)
|
|
|
|
: request(aRequest), listener(aListener) {}
|
|
|
|
|
2006-01-30 18:57:38 +00:00
|
|
|
nsCOMPtr<imgIRequest> request;
|
|
|
|
nsCOMPtr<imgIDecoderObserver> listener;
|
|
|
|
};
|
2001-03-24 01:50:33 +00:00
|
|
|
|
2001-02-05 02:01:24 +00:00
|
|
|
// The actual frame that paints the cells and rows.
|
2004-04-17 05:53:38 +00:00
|
|
|
class nsTreeBodyFrame : public nsLeafBoxFrame,
|
|
|
|
public nsITreeBoxObject,
|
|
|
|
public nsICSSPseudoComparator,
|
2002-08-15 05:06:19 +00:00
|
|
|
public nsIScrollbarMediator,
|
2002-07-19 22:36:46 +00:00
|
|
|
public nsIReflowCallback
|
2001-02-02 22:34:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2004-04-17 05:53:38 +00:00
|
|
|
virtual ~nsTreeBodyFrame();
|
|
|
|
|
2001-02-02 22:34:52 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2002-03-29 02:46:01 +00:00
|
|
|
NS_DECL_NSITREEBOXOBJECT
|
2001-02-02 22:34:52 +00:00
|
|
|
|
2002-01-05 07:17:10 +00:00
|
|
|
// nsIBox
|
2003-03-25 04:44:31 +00:00
|
|
|
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
2004-07-16 16:56:21 +00:00
|
|
|
NS_IMETHOD SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
|
|
|
|
PRBool aRemoveOverflowArea = PR_FALSE);
|
2002-01-05 07:17:10 +00:00
|
|
|
|
2002-07-19 22:36:46 +00:00
|
|
|
// nsIReflowCallback
|
|
|
|
NS_IMETHOD ReflowFinished(nsIPresShell* aPresShell, PRBool* aFlushFlag);
|
|
|
|
|
2001-02-06 02:22:31 +00:00
|
|
|
// nsICSSPseudoComparator
|
|
|
|
NS_IMETHOD PseudoMatches(nsIAtom* aTag, nsCSSSelector* aSelector, PRBool* aResult);
|
|
|
|
|
2001-02-09 12:12:53 +00:00
|
|
|
// nsIScrollbarMediator
|
2004-05-29 00:09:05 +00:00
|
|
|
NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex);
|
|
|
|
NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex);
|
|
|
|
NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) { Invalidate(); return NS_OK; };
|
2001-02-09 12:12:53 +00:00
|
|
|
|
2001-02-09 09:48:33 +00:00
|
|
|
// Overridden from nsIFrame to cache our pres context.
|
2006-03-09 18:55:21 +00:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
2006-04-10 00:16:29 +00:00
|
|
|
virtual void Destroy();
|
|
|
|
|
2004-12-30 21:56:11 +00:00
|
|
|
NS_IMETHOD GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor);
|
2004-04-17 05:53:38 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
2001-02-09 09:48:33 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
|
|
|
|
|
|
|
void PaintTreeBody(nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect, nsPoint aPt);
|
2001-02-02 22:44:39 +00:00
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// This method paints a specific column background of the tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintColumn(nsTreeColumn* aColumn,
|
|
|
|
const nsRect& aColumnRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
2001-02-16 01:37:19 +00:00
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// This method paints a single row in the tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintRow(PRInt32 aRowIndex,
|
|
|
|
const nsRect& aRowRect,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsPoint aPt);
|
2004-04-17 05:53:38 +00:00
|
|
|
|
|
|
|
// This method paints a single separator in the tree.
|
|
|
|
void PaintSeparator(PRInt32 aRowIndex,
|
|
|
|
const nsRect& aSeparatorRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
2001-02-02 22:44:39 +00:00
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// This method paints a specific cell in a given row of the tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintCell(PRInt32 aRowIndex,
|
|
|
|
nsTreeColumn* aColumn,
|
|
|
|
const nsRect& aCellRect,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
2006-01-26 02:29:17 +00:00
|
|
|
nscoord& aCurrX,
|
|
|
|
nsPoint aPt);
|
2002-11-06 06:38:14 +00:00
|
|
|
|
|
|
|
// This method paints the twisty inside a cell in the primary column of an tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintTwisty(PRInt32 aRowIndex,
|
|
|
|
nsTreeColumn* aColumn,
|
|
|
|
const nsRect& aTwistyRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nscoord& aRemainingWidth,
|
|
|
|
nscoord& aCurrX);
|
2001-03-24 01:50:33 +00:00
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// This method paints the image inside the cell of an tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintImage(PRInt32 aRowIndex,
|
|
|
|
nsTreeColumn* aColumn,
|
|
|
|
const nsRect& aImageRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nscoord& aRemainingWidth,
|
|
|
|
nscoord& aCurrX);
|
2001-03-22 02:51:39 +00:00
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// This method paints the text string inside a particular cell of the tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintText(PRInt32 aRowIndex,
|
|
|
|
nsTreeColumn* aColumn,
|
|
|
|
const nsRect& aTextRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nscoord& aCurrX);
|
|
|
|
|
|
|
|
// This method paints the checkbox inside a particular cell of the tree.
|
|
|
|
void PaintCheckbox(PRInt32 aRowIndex,
|
2002-11-06 06:38:14 +00:00
|
|
|
nsTreeColumn* aColumn,
|
2004-04-17 05:53:38 +00:00
|
|
|
const nsRect& aCheckboxRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2002-11-06 06:38:14 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
const nsRect& aDirtyRect);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
|
|
|
// This method paints the progress meter inside a particular cell of the tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintProgressMeter(PRInt32 aRowIndex,
|
|
|
|
nsTreeColumn* aColumn,
|
|
|
|
const nsRect& aProgressMeterRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
|
|
|
// This method paints a drop feedback of the tree.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintDropFeedback(const nsRect& aDropFeedbackRect,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
2002-02-08 22:35:18 +00:00
|
|
|
|
2001-02-09 07:21:01 +00:00
|
|
|
// This method is called with a specific style context and rect to
|
|
|
|
// paint the background rect as if it were a full-blown frame.
|
2004-04-17 05:53:38 +00:00
|
|
|
void PaintBackgroundLayer(nsStyleContext* aStyleContext,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aRect,
|
|
|
|
const nsRect& aDirtyRect);
|
2002-07-19 22:36:46 +00:00
|
|
|
|
2005-10-26 21:46:39 +00:00
|
|
|
friend nsIFrame* NS_NewTreeBodyFrame(nsIPresShell* aPresShell);
|
2001-02-02 22:34:52 +00:00
|
|
|
|
2006-04-26 01:47:58 +00:00
|
|
|
struct ScrollParts {
|
|
|
|
nsIScrollbarFrame* mVScrollbar;
|
|
|
|
nsIContent* mVScrollbarContent;
|
|
|
|
nsIScrollbarFrame* mHScrollbar;
|
|
|
|
nsIContent* mHScrollbarContent;
|
|
|
|
nsIScrollableView* mColumnsScrollableView;
|
|
|
|
};
|
|
|
|
|
2001-02-02 22:34:52 +00:00
|
|
|
protected:
|
2004-04-17 05:53:38 +00:00
|
|
|
PRInt32 GetLastVisibleRow() {
|
|
|
|
return mTopRowIndex + mPageLength;
|
|
|
|
};
|
2001-02-02 22:34:52 +00:00
|
|
|
|
2005-04-18 05:22:35 +00:00
|
|
|
// An internal hit test. aX and aY are expected to be in twips in the
|
|
|
|
// coordinate system of this frame.
|
|
|
|
PRInt32 GetRowAt(nscoord aX, nscoord aY);
|
2001-03-08 00:46:58 +00:00
|
|
|
|
2006-06-06 20:05:13 +00:00
|
|
|
void AdjustForCellText(nsAutoString& aText,
|
|
|
|
PRInt32 aRowIndex, nsTreeColumn* aColumn,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
nsRect& aTextRect);
|
|
|
|
|
2001-03-28 22:45:43 +00:00
|
|
|
// A helper used when hit testing.
|
2005-04-18 05:22:35 +00:00
|
|
|
nsIAtom* GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
|
|
|
|
PRInt32 aRowIndex, nsTreeColumn* aColumn);
|
2004-04-17 05:53:38 +00:00
|
|
|
|
2005-04-18 05:22:35 +00:00
|
|
|
// An internal hit test. aX and aY are expected to be in twips in the
|
|
|
|
// coordinate system of this frame.
|
|
|
|
void GetCellAt(nscoord aX, nscoord aY, PRInt32* aRow, nsTreeColumn** aCol,
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIAtom** aChildElt);
|
2001-03-28 22:45:43 +00:00
|
|
|
|
2006-06-06 14:36:45 +00:00
|
|
|
// Retrieve the area for the twisty for a cell.
|
|
|
|
nsITheme* GetTwistyRect(PRInt32 aRowIndex,
|
|
|
|
nsTreeColumn* aColumn,
|
|
|
|
nsRect& aImageRect,
|
|
|
|
nsRect& aTwistyRect,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
nsStyleContext* aTwistyContext);
|
|
|
|
|
2001-03-22 02:51:39 +00:00
|
|
|
// Fetch an image from the image cache.
|
2004-04-17 05:53:38 +00:00
|
|
|
nsresult GetImage(PRInt32 aRowIndex, nsTreeColumn* aCol, PRBool aUseContext,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext, PRBool& aAllowImageRegions, imgIContainer** aResult);
|
2001-03-22 02:51:39 +00:00
|
|
|
|
|
|
|
// Returns the size of a given image. This size *includes* border and
|
|
|
|
// padding. It does not include margins.
|
2004-04-17 05:53:38 +00:00
|
|
|
nsRect GetImageSize(PRInt32 aRowIndex, nsTreeColumn* aCol, PRBool aUseContext, nsStyleContext* aStyleContext);
|
2001-03-22 02:51:39 +00:00
|
|
|
|
2006-05-04 18:45:45 +00:00
|
|
|
// Returns the destination size of the image, not including borders and padding.
|
|
|
|
nsSize GetImageDestSize(nsStyleContext* aStyleContext, PRBool useImageRegion, imgIContainer* image);
|
|
|
|
|
|
|
|
// Returns the source rectangle of the image to be displayed.
|
|
|
|
nsRect GetImageSourceRect(nsStyleContext* aStyleContext, PRBool useImageRegion, imgIContainer* image);
|
|
|
|
|
2001-02-04 09:50:59 +00:00
|
|
|
// Returns the height of rows in the tree.
|
2001-02-15 09:43:11 +00:00
|
|
|
PRInt32 GetRowHeight();
|
2001-02-04 09:50:59 +00:00
|
|
|
|
2001-03-06 02:27:50 +00:00
|
|
|
// Returns our indentation width.
|
|
|
|
PRInt32 GetIndentation();
|
|
|
|
|
2003-02-26 08:18:28 +00:00
|
|
|
// Calculates our width/height once border and padding have been removed.
|
|
|
|
void CalcInnerBox();
|
2001-02-04 09:50:59 +00:00
|
|
|
|
2005-08-30 18:36:15 +00:00
|
|
|
// Calculate the total width of our scrollable portion
|
2006-04-26 01:47:58 +00:00
|
|
|
nscoord CalcHorzWidth(const ScrollParts& aParts);
|
2005-08-30 18:36:15 +00:00
|
|
|
|
2001-02-04 09:50:59 +00:00
|
|
|
// Looks up a style context in the style cache. On a cache miss we resolve
|
|
|
|
// the pseudo-styles passed in and place them into the cache.
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* GetPseudoStyleContext(nsIAtom* aPseudoElement);
|
2001-02-04 09:50:59 +00:00
|
|
|
|
2006-04-26 01:47:58 +00:00
|
|
|
// Retrieves the scrollbars and scrollview relevant to this treebody. We
|
|
|
|
// traverse the frame tree under our base element, in frame order, looking
|
|
|
|
// for the first relevant vertical scrollbar, horizontal scrollbar, and
|
|
|
|
// scrollable frame (with associated content and scrollable view). These
|
|
|
|
// are all volatile and should not be retained.
|
|
|
|
ScrollParts GetScrollParts();
|
2002-03-07 23:48:26 +00:00
|
|
|
|
2001-03-06 02:27:50 +00:00
|
|
|
// Update the curpos of the scrollbar.
|
2006-04-26 01:47:58 +00:00
|
|
|
void UpdateScrollbars(const ScrollParts& aParts);
|
2001-03-06 02:27:50 +00:00
|
|
|
|
2003-09-15 11:30:20 +00:00
|
|
|
// Update the maxpos of the scrollbar.
|
2006-04-26 01:47:58 +00:00
|
|
|
void InvalidateScrollbars(const ScrollParts& aParts);
|
2003-09-15 11:30:20 +00:00
|
|
|
|
2005-08-30 18:36:15 +00:00
|
|
|
// Check overflow and generate events.
|
2006-04-26 01:47:58 +00:00
|
|
|
void CheckOverflow(const ScrollParts& aParts);
|
2001-05-13 05:30:46 +00:00
|
|
|
|
2001-02-14 19:39:20 +00:00
|
|
|
// Use to auto-fill some of the common properties without the view having to do it.
|
2001-03-24 01:50:33 +00:00
|
|
|
// Examples include container, open, selected, and focus.
|
2002-03-29 02:46:01 +00:00
|
|
|
void PrefillPropertyArray(PRInt32 aRowIndex, nsTreeColumn* aCol);
|
2001-02-14 19:39:20 +00:00
|
|
|
|
2001-03-06 02:27:50 +00:00
|
|
|
// Our internal scroll method, used by all the public scroll methods.
|
2006-04-26 01:47:58 +00:00
|
|
|
nsresult ScrollInternal(const ScrollParts& aParts, PRInt32 aRow);
|
|
|
|
nsresult ScrollToRowInternal(const ScrollParts& aParts, PRInt32 aRow);
|
|
|
|
nsresult ScrollToColumnInternal(const ScrollParts& aParts, nsITreeColumn* aCol);
|
|
|
|
nsresult ScrollHorzInternal(const ScrollParts& aParts, PRInt32 aPosition);
|
|
|
|
nsresult EnsureRowIsVisibleInternal(const ScrollParts& aParts, PRInt32 aRow);
|
2001-05-11 01:51:04 +00:00
|
|
|
|
2005-04-18 05:22:35 +00:00
|
|
|
// Convert client pixels into twips in our coordinate space.
|
|
|
|
void AdjustClientCoordsToBoxCoordSpace(PRInt32 aX, PRInt32 aY,
|
|
|
|
nscoord* aResultX, nscoord* aResultY);
|
2001-03-06 02:27:50 +00:00
|
|
|
|
2001-10-02 04:42:48 +00:00
|
|
|
// Convert a border style into line style.
|
|
|
|
nsLineStyle ConvertBorderStyleToLineStyle(PRUint8 aBorderStyle);
|
|
|
|
|
2002-01-05 01:32:12 +00:00
|
|
|
// Cache the box object
|
|
|
|
void EnsureBoxObject();
|
|
|
|
|
2002-06-20 20:06:25 +00:00
|
|
|
void EnsureView();
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// Get the base element, <tree> or <select>
|
2004-04-17 05:53:38 +00:00
|
|
|
nsIContent* GetBaseElement();
|
2002-01-05 07:17:10 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
void GetCellWidth(PRInt32 aRow, nsTreeColumn* aCol,
|
2002-08-17 05:36:24 +00:00
|
|
|
nsIRenderingContext* aRenderingContext,
|
|
|
|
nscoord& aDesiredSize, nscoord& aCurrentSize);
|
2004-04-17 05:53:38 +00:00
|
|
|
nscoord CalcMaxRowWidth();
|
2002-01-05 07:17:10 +00:00
|
|
|
|
2005-08-31 04:37:24 +00:00
|
|
|
// Translate the given rect horizontally from tree coordinates into the
|
|
|
|
// coordinate system of our nsTreeBodyFrame. If clip is true, then clip the
|
|
|
|
// rect to its intersection with mInnerBox in the horizontal direction.
|
|
|
|
// Return whether the result has a nonempty intersection with mInnerBox
|
|
|
|
// after projecting both onto the horizontal coordinate axis.
|
|
|
|
PRBool OffsetForHorzScroll(nsRect& rect, PRBool clip);
|
2005-08-30 18:36:15 +00:00
|
|
|
|
2005-10-06 18:18:12 +00:00
|
|
|
// Fills in rect with column args and x/width coords. Does some extra
|
|
|
|
// calculations for the last column
|
|
|
|
void CalcColumnRect(nsRect& rect, nsTreeColumn* aCol, nscoord y, nscoord height);
|
|
|
|
|
2002-08-15 05:06:19 +00:00
|
|
|
PRBool CanAutoScroll(PRInt32 aRowIndex);
|
2002-01-16 03:01:28 +00:00
|
|
|
|
2002-08-15 05:06:19 +00:00
|
|
|
// Calc the row and above/below/on status given where the mouse currently is hovering.
|
|
|
|
// Also calc if we're in the region in which we want to auto-scroll the tree.
|
|
|
|
// A positive value of |aScrollLines| means scroll down, a negative value
|
|
|
|
// means scroll up, a zero value means that we aren't in drag scroll region.
|
2004-04-17 05:53:38 +00:00
|
|
|
void ComputeDropPosition(nsGUIEvent* aEvent, PRInt32* aRow, PRInt16* aOrient,
|
2002-08-15 05:06:19 +00:00
|
|
|
PRInt16* aScrollLines);
|
2002-01-16 03:01:28 +00:00
|
|
|
|
2002-04-16 05:09:35 +00:00
|
|
|
// Mark ourselves dirty if we're a select widget
|
|
|
|
void MarkDirtyIfSelect();
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
void InvalidateDropFeedback(PRInt32 aRow, PRInt16 aOrientation) {
|
|
|
|
InvalidateRow(aRow);
|
|
|
|
if (aOrientation != nsITreeView::DROP_ON)
|
|
|
|
InvalidateRow(aRow + aOrientation);
|
|
|
|
};
|
|
|
|
|
2003-03-16 23:26:31 +00:00
|
|
|
// Create a new timer. This method is used to delay various actions like
|
|
|
|
// opening/closing folders or tree scrolling.
|
|
|
|
// aID is type of the action, aFunc is the function to be called when
|
|
|
|
// the timer fires and aType is type of timer - one shot or repeating.
|
|
|
|
nsresult CreateTimer(const nsILookAndFeel::nsMetricID aID,
|
|
|
|
nsTimerCallbackFunc aFunc, PRInt32 aType,
|
|
|
|
nsITimer** aTimer);
|
|
|
|
|
2002-08-15 05:06:19 +00:00
|
|
|
static void OpenCallback(nsITimer *aTimer, void *aClosure);
|
|
|
|
|
2003-03-16 23:26:31 +00:00
|
|
|
static void CloseCallback(nsITimer *aTimer, void *aClosure);
|
|
|
|
|
|
|
|
static void LazyScrollCallback(nsITimer *aTimer, void *aClosure);
|
|
|
|
|
2002-08-15 05:06:19 +00:00
|
|
|
static void ScrollCallback(nsITimer *aTimer, void *aClosure);
|
|
|
|
|
2001-02-02 22:34:52 +00:00
|
|
|
protected: // Data Members
|
2001-03-08 00:46:58 +00:00
|
|
|
// The cached box object parent.
|
2006-01-30 21:29:10 +00:00
|
|
|
nsCOMPtr<nsPITreeBoxObject> mTreeBoxObject;
|
2001-03-08 00:46:58 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
// Cached column information.
|
|
|
|
nsRefPtr<nsTreeColumns> mColumns;
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
// The current view for this tree widget. We get all of our row and cell data
|
2001-02-03 23:13:53 +00:00
|
|
|
// from the view.
|
2002-03-29 02:46:01 +00:00
|
|
|
nsCOMPtr<nsITreeView> mView;
|
2004-04-17 05:53:38 +00:00
|
|
|
|
2001-02-04 09:50:59 +00:00
|
|
|
// A cache of all the style contexts we have seen for rows and cells of the tree. This is a mapping from
|
2001-02-02 22:34:52 +00:00
|
|
|
// a list of atoms to a corresponding style context. This cache stores every combination that
|
2001-02-04 09:50:59 +00:00
|
|
|
// occurs in the tree, so for n distinct properties, this cache could have 2 to the n entries
|
2001-02-02 22:34:52 +00:00
|
|
|
// (the power set of all row properties).
|
2002-03-29 02:46:01 +00:00
|
|
|
nsTreeStyleCache mStyleCache;
|
2001-02-02 22:34:52 +00:00
|
|
|
|
2006-01-30 18:57:38 +00:00
|
|
|
// A hashtable that maps from URLs to image request/listener pairs. The URL
|
|
|
|
// is provided by the view or by the style context. The style context
|
|
|
|
// represents a resolved :-moz-tree-cell-image (or twisty) pseudo-element.
|
2002-03-29 02:46:01 +00:00
|
|
|
// It maps directly to an imgIRequest.
|
2006-01-30 18:57:38 +00:00
|
|
|
nsDataHashtable<nsStringHashKey, nsTreeImageCacheEntry> mImageCache;
|
2001-03-22 02:51:39 +00:00
|
|
|
|
2001-02-02 22:34:52 +00:00
|
|
|
// The index of the first visible row and the # of rows visible onscreen.
|
2002-03-29 02:46:01 +00:00
|
|
|
// The tree only examines onscreen rows, starting from
|
2004-04-17 05:53:38 +00:00
|
|
|
// this index and going up to index+pageLength.
|
2001-02-02 22:34:52 +00:00
|
|
|
PRInt32 mTopRowIndex;
|
2004-04-17 05:53:38 +00:00
|
|
|
PRInt32 mPageLength;
|
2001-02-04 09:50:59 +00:00
|
|
|
|
2005-08-30 18:36:15 +00:00
|
|
|
// The horizontal scroll position
|
|
|
|
nscoord mHorzPosition;
|
2005-08-31 04:37:24 +00:00
|
|
|
// Our desired horizontal width (the width for which we actually have tree
|
|
|
|
// columns).
|
2005-08-30 18:36:15 +00:00
|
|
|
nscoord mHorzWidth;
|
|
|
|
|
2001-05-11 01:51:04 +00:00
|
|
|
// Cached heights and indent info.
|
2001-02-05 02:01:24 +00:00
|
|
|
nsRect mInnerBox;
|
2001-02-04 09:50:59 +00:00
|
|
|
PRInt32 mRowHeight;
|
2001-03-06 02:27:50 +00:00
|
|
|
PRInt32 mIndentation;
|
2002-01-05 07:17:10 +00:00
|
|
|
nscoord mStringWidth;
|
2001-09-25 22:17:47 +00:00
|
|
|
|
2001-02-04 09:50:59 +00:00
|
|
|
// A scratch array used when looking up cached style contexts.
|
|
|
|
nsCOMPtr<nsISupportsArray> mScratchArray;
|
2001-05-11 01:51:04 +00:00
|
|
|
|
2002-01-05 07:17:10 +00:00
|
|
|
// Whether or not we're currently focused.
|
|
|
|
PRPackedBool mFocused;
|
|
|
|
|
|
|
|
// Do we have a fixed number of onscreen rows?
|
|
|
|
PRPackedBool mHasFixedRowCount;
|
|
|
|
|
|
|
|
PRPackedBool mVerticalOverflow;
|
2005-08-30 18:36:15 +00:00
|
|
|
PRPackedBool mHorizontalOverflow;
|
2002-01-05 07:17:10 +00:00
|
|
|
|
2002-07-19 22:36:46 +00:00
|
|
|
PRPackedBool mReflowCallbackPosted;
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
PRInt32 mUpdateBatchNest;
|
2002-08-15 05:06:19 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
// Cached row count.
|
|
|
|
PRInt32 mRowCount;
|
2002-08-15 05:06:19 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
class Slots {
|
|
|
|
public:
|
|
|
|
Slots()
|
|
|
|
: mValueArray(~PRInt32(0)) {
|
|
|
|
};
|
2002-08-15 05:06:19 +00:00
|
|
|
|
2004-05-13 18:06:09 +00:00
|
|
|
~Slots() {
|
|
|
|
if (mTimer)
|
|
|
|
mTimer->Cancel();
|
|
|
|
};
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
friend class nsTreeBodyFrame;
|
2002-01-16 03:01:28 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
protected:
|
|
|
|
// If the drop is actually allowed here or not.
|
|
|
|
PRBool mDropAllowed;
|
2002-01-03 22:58:23 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
// The row the mouse is hovering over during a drop.
|
|
|
|
PRInt32 mDropRow;
|
2003-03-16 23:26:31 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
// Where we want to draw feedback (above/on this row/below) if allowed.
|
|
|
|
PRInt16 mDropOrient;
|
2003-07-01 11:03:53 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
// Number of lines to be scrolled.
|
|
|
|
PRInt16 mScrollLines;
|
|
|
|
|
2006-05-12 16:30:53 +00:00
|
|
|
// The drag action that was received for this slot
|
|
|
|
PRUint32 mDragAction;
|
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
nsCOMPtr<nsIDragSession> mDragSession;
|
|
|
|
|
|
|
|
// Timer for opening/closing spring loaded folders or scrolling the tree.
|
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
|
|
|
|
// A value array used to keep track of all spring loaded folders.
|
|
|
|
nsValueArray mValueArray;
|
|
|
|
};
|
2003-05-23 12:03:40 +00:00
|
|
|
|
2004-04-17 05:53:38 +00:00
|
|
|
Slots* mSlots;
|
2002-03-29 02:46:01 +00:00
|
|
|
}; // class nsTreeBodyFrame
|