2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsTreeColumns_h__
|
|
|
|
#define nsTreeColumns_h__
|
|
|
|
|
|
|
|
#include "nsITreeColumns.h"
|
|
|
|
#include "nsITreeBoxObject.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-08-05 20:00:56 -07:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-04-20 23:42:26 -07:00
|
|
|
#include "nsWrapperCache.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-08-23 05:48:51 -07:00
|
|
|
class nsTreeBodyFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsTreeColumns;
|
2012-08-05 20:00:56 -07:00
|
|
|
class nsIFrame;
|
|
|
|
class nsIContent;
|
|
|
|
struct nsRect;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-20 23:42:26 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2008-10-27 21:47:19 -07:00
|
|
|
#define NS_TREECOLUMN_IMPL_CID \
|
|
|
|
{ /* 02cd1963-4b5d-4a6c-9223-814d3ade93a3 */ \
|
|
|
|
0x02cd1963, \
|
|
|
|
0x4b5d, \
|
|
|
|
0x4a6c, \
|
|
|
|
{0x92, 0x23, 0x81, 0x4d, 0x3a, 0xde, 0x93, 0xa3} \
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// This class is our column info. We use it to iterate our columns and to obtain
|
|
|
|
// information about each column.
|
2012-06-18 19:30:09 -07:00
|
|
|
class nsTreeColumn MOZ_FINAL : public nsITreeColumn {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
nsTreeColumn(nsTreeColumns* aColumns, nsIContent* aContent);
|
|
|
|
~nsTreeColumn();
|
|
|
|
|
2008-10-27 21:47:19 -07:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID)
|
|
|
|
|
2009-08-21 05:50:15 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeColumn)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSITREECOLUMN
|
|
|
|
|
|
|
|
friend class nsTreeBodyFrame;
|
|
|
|
friend class nsTreeColumns;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsIFrame* GetFrame();
|
2007-08-23 05:27:50 -07:00
|
|
|
nsIFrame* GetFrame(nsTreeBodyFrame* aBodyFrame);
|
2007-09-04 02:08:15 -07:00
|
|
|
// Don't call this if GetWidthInTwips or GetRect fails
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsLastVisible(nsTreeBodyFrame* aBodyFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a rect with x and width taken from the frame's rect and specified
|
|
|
|
* y and height. May fail in case there's no frame for the column.
|
|
|
|
*/
|
2007-08-23 05:27:50 -07:00
|
|
|
nsresult GetRect(nsTreeBodyFrame* aBodyFrame, nscoord aY, nscoord aHeight,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect* aResult);
|
|
|
|
|
2007-08-23 05:27:50 -07:00
|
|
|
nsresult GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult);
|
|
|
|
nsresult GetWidthInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
void SetColumns(nsTreeColumns* aColumns) { mColumns = aColumns; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
const nsAString& GetId() { return mId; }
|
|
|
|
nsIAtom* GetAtom() { return mAtom; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetIndex() { return mIndex; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPrimary() { return mIsPrimary; }
|
|
|
|
bool IsCycler() { return mIsCycler; }
|
|
|
|
bool IsEditable() { return mIsEditable; }
|
|
|
|
bool IsSelectable() { return mIsSelectable; }
|
|
|
|
bool Overflow() { return mOverflow; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t GetType() { return mType; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int8_t GetCropStyle() { return mCropStyle; }
|
|
|
|
int32_t GetTextAlignment() { return mTextAlignment; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
nsTreeColumn* GetNext() { return mNext; }
|
|
|
|
nsTreeColumn* GetPrevious() { return mPrevious; }
|
2009-08-07 14:17:02 -07:00
|
|
|
void SetNext(nsTreeColumn* aNext) {
|
|
|
|
NS_ASSERTION(!mNext, "already have a next sibling");
|
2011-08-28 07:07:26 -07:00
|
|
|
mNext = aNext;
|
2009-08-07 14:17:02 -07:00
|
|
|
}
|
2007-04-23 07:21:53 -07:00
|
|
|
void SetPrevious(nsTreeColumn* aPrevious) { mPrevious = aPrevious; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Non-null nsIContent for the associated <treecol> element.
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
|
|
|
|
nsTreeColumns* mColumns;
|
|
|
|
|
|
|
|
nsString mId;
|
|
|
|
nsCOMPtr<nsIAtom> mAtom;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsPrimary;
|
|
|
|
bool mIsCycler;
|
|
|
|
bool mIsEditable;
|
|
|
|
bool mIsSelectable;
|
|
|
|
bool mOverflow;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t mType;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int8_t mCropStyle;
|
|
|
|
int8_t mTextAlignment;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-28 07:07:26 -07:00
|
|
|
nsRefPtr<nsTreeColumn> mNext;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTreeColumn* mPrevious;
|
|
|
|
};
|
|
|
|
|
2008-10-27 21:47:19 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-20 23:42:26 -07:00
|
|
|
class nsTreeColumns MOZ_FINAL : public nsITreeColumns
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-11-18 04:37:19 -08:00
|
|
|
nsTreeColumns(nsTreeBodyFrame* aTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
~nsTreeColumns();
|
|
|
|
|
2013-04-20 23:42:26 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumns)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSITREECOLUMNS
|
|
|
|
|
2013-04-20 23:42:26 -07:00
|
|
|
nsIContent* GetParentObject() const;
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-04-20 23:42:26 -07:00
|
|
|
// WebIDL
|
|
|
|
nsITreeBoxObject* GetTree() const;
|
|
|
|
uint32_t Count();
|
|
|
|
uint32_t Length()
|
2008-10-22 07:31:14 -07:00
|
|
|
{
|
2013-04-20 23:42:26 -07:00
|
|
|
return Count();
|
2008-10-22 07:31:14 -07:00
|
|
|
}
|
|
|
|
|
2013-04-20 23:42:26 -07:00
|
|
|
nsTreeColumn* GetFirstColumn() { EnsureColumns(); return mFirstColumn; }
|
|
|
|
nsTreeColumn* GetLastColumn();
|
|
|
|
|
|
|
|
nsTreeColumn* GetPrimaryColumn();
|
|
|
|
nsTreeColumn* GetSortedColumn();
|
|
|
|
nsTreeColumn* GetKeyColumn();
|
|
|
|
|
|
|
|
nsTreeColumn* GetColumnFor(mozilla::dom::Element* aElement);
|
|
|
|
|
|
|
|
nsTreeColumn* IndexedGetter(uint32_t aIndex, bool& aFound);
|
|
|
|
nsTreeColumn* GetColumnAt(uint32_t aIndex);
|
|
|
|
nsTreeColumn* NamedGetter(const nsAString& aId, bool& aFound);
|
|
|
|
nsTreeColumn* GetNamedColumn(const nsAString& aId);
|
|
|
|
void GetSupportedNames(nsTArray<nsString>& aNames);
|
|
|
|
|
|
|
|
// Uses XPCOM InvalidateColumns().
|
|
|
|
// Uses XPCOM RestoreNaturalOrder().
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
friend class nsTreeBodyFrame;
|
|
|
|
protected:
|
2012-11-18 04:37:19 -08:00
|
|
|
void SetTree(nsTreeBodyFrame* aTree) { mTree = aTree; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Builds our cache of column info.
|
|
|
|
void EnsureColumns();
|
|
|
|
|
|
|
|
private:
|
2012-11-18 04:37:19 -08:00
|
|
|
nsTreeBodyFrame* mTree;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The first column in the list of columns. All of the columns are supposed
|
|
|
|
* to be "alive", i.e. have a frame. This is achieved by clearing the columns
|
|
|
|
* list each time an nsTreeColFrame is destroyed.
|
|
|
|
*
|
|
|
|
* XXX this means that new nsTreeColumn objects are unnecessarily created
|
|
|
|
* for untouched columns.
|
|
|
|
*/
|
|
|
|
nsTreeColumn* mFirstColumn;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTreeColumns_h__
|