LCOV - app.info - layout/xul/base/src/tree/src/nsTreeColumns.h

LCOV - code coverage report
| Current view: | directory - layout/xul/base/src/tree/src - nsTreeColumns.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 27 | 1 | 3.7 %
| Date: | 2012-06-02 | Functions: | 24 | 1 | 4.2 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is mozilla.org code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 2003
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *   Dave Hyatt <hyatt@mozilla.org> (Original Author)
          24                 :  *   Jan Varga <varga@ku.sk>
          25                 :  *
          26                 :  * Alternatively, the contents of this file may be used under the terms of
          27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          30                 :  * of those above. If you wish to allow use of your version of this file only
          31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          32                 :  * use your version of this file under the terms of the MPL, indicate your
          33                 :  * decision by deleting the provisions above and replace them with the notice
          34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          35                 :  * the provisions above, a recipient may use your version of this file under
          36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          37                 :  *
          38                 :  * ***** END LICENSE BLOCK ***** */
          39                 :
          40                 : #ifndef nsTreeColumns_h__
          41                 : #define nsTreeColumns_h__
          42                 :
          43                 : #include "nsITreeColumns.h"
          44                 : #include "nsITreeBoxObject.h"
          45                 : #include "nsIContent.h"
          46                 : #include "nsIFrame.h"
          47                 :
          48                 : class nsTreeBodyFrame;
          49                 : class nsTreeColumns;
          50                 :
          51                 : #define NS_TREECOLUMN_IMPL_CID                       \
          52                 : { /* 02cd1963-4b5d-4a6c-9223-814d3ade93a3 */         \
          53                 :     0x02cd1963,                                      \
          54                 :     0x4b5d,                                          \
          55                 :     0x4a6c,                                          \
          56                 :     {0x92, 0x23, 0x81, 0x4d, 0x3a, 0xde, 0x93, 0xa3} \
          57                 : }
          58                 :
          59                 : // This class is our column info.  We use it to iterate our columns and to obtain
          60                 : // information about each column.
          61                 : class nsTreeColumn : public nsITreeColumn {
          62                 : public:
          63                 :   nsTreeColumn(nsTreeColumns* aColumns, nsIContent* aContent);
          64                 :   ~nsTreeColumn();
          65                 :
          66                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID)
          67                 :
          68               0 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
          69            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeColumn)
          70                 :   NS_DECL_NSITREECOLUMN
          71                 :
          72                 :   friend class nsTreeBodyFrame;
          73                 :   friend class nsTreeColumns;
          74                 :
          75                 : protected:
          76                 :   nsIFrame* GetFrame();
          77                 :   nsIFrame* GetFrame(nsTreeBodyFrame* aBodyFrame);
          78                 :   // Don't call this if GetWidthInTwips or GetRect fails
          79                 :   bool IsLastVisible(nsTreeBodyFrame* aBodyFrame);
          80                 :
          81                 :   /**
          82                 :    * Returns a rect with x and width taken from the frame's rect and specified
          83                 :    * y and height. May fail in case there's no frame for the column.
          84                 :    */
          85                 :   nsresult GetRect(nsTreeBodyFrame* aBodyFrame, nscoord aY, nscoord aHeight,
          86                 :                    nsRect* aResult);
          87                 :
          88                 :   nsresult GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult);
          89                 :   nsresult GetWidthInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult);
          90                 :
          91               0 :   void SetColumns(nsTreeColumns* aColumns) { mColumns = aColumns; }
          92                 :
          93               0 :   const nsAString& GetId() { return mId; }
          94               0 :   nsIAtom* GetAtom() { return mAtom; }
          95                 :
          96               0 :   PRInt32 GetIndex() { return mIndex; }
          97                 :
          98               0 :   bool IsPrimary() { return mIsPrimary; }
          99               0 :   bool IsCycler() { return mIsCycler; }
         100               0 :   bool IsEditable() { return mIsEditable; }
         101               0 :   bool IsSelectable() { return mIsSelectable; }
         102               0 :   bool Overflow() { return mOverflow; }
         103                 :
         104               0 :   PRInt16 GetType() { return mType; }
         105                 :
         106               0 :   PRInt8 GetCropStyle() { return mCropStyle; }
         107               0 :   PRInt32 GetTextAlignment() { return mTextAlignment; }
         108                 :
         109               0 :   nsTreeColumn* GetNext() { return mNext; }
         110               0 :   nsTreeColumn* GetPrevious() { return mPrevious; }
         111               0 :   void SetNext(nsTreeColumn* aNext) {
         112               0 :     NS_ASSERTION(!mNext, "already have a next sibling");
         113               0 :     mNext = aNext;
         114               0 :   }
         115               0 :   void SetPrevious(nsTreeColumn* aPrevious) { mPrevious = aPrevious; }
         116                 :
         117                 : private:
         118                 :   /**
         119                 :    * Non-null nsIContent for the associated <treecol> element.
         120                 :    */
         121                 :   nsCOMPtr<nsIContent> mContent;
         122                 :
         123                 :   nsTreeColumns* mColumns;
         124                 :
         125                 :   nsString mId;
         126                 :   nsCOMPtr<nsIAtom> mAtom;
         127                 :
         128                 :   PRInt32 mIndex;
         129                 :
         130                 :   bool mIsPrimary;
         131                 :   bool mIsCycler;
         132                 :   bool mIsEditable;
         133                 :   bool mIsSelectable;
         134                 :   bool mOverflow;
         135                 :
         136                 :   PRInt16 mType;
         137                 :
         138                 :   PRInt8 mCropStyle;
         139                 :   PRInt8 mTextAlignment;
         140                 :
         141                 :   nsRefPtr<nsTreeColumn> mNext;
         142                 :   nsTreeColumn* mPrevious;
         143                 : };
         144                 :
         145                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID)
         146                 :
         147                 : class nsTreeColumns : public nsITreeColumns {
         148                 : public:
         149                 :   nsTreeColumns(nsITreeBoxObject* aTree);
         150                 :   ~nsTreeColumns();
         151                 :
         152                 :   NS_DECL_ISUPPORTS
         153                 :   NS_DECL_NSITREECOLUMNS
         154                 :
         155                 :   nsITreeColumn* GetColumnAt(PRInt32 aIndex);
         156                 :   nsITreeColumn* GetNamedColumn(const nsAString& aId);
         157                 :
         158               0 :   static nsTreeColumns* FromSupports(nsISupports* aSupports)
         159                 :   {
         160                 : #ifdef DEBUG
         161                 :     {
         162               0 :       nsCOMPtr<nsITreeColumns> columns_qi = do_QueryInterface(aSupports);
         163                 :
         164                 :       // If this assertion fires the QI implementation for the object in
         165                 :       // question doesn't use the nsITreeColumns pointer as the nsISupports
         166                 :       // pointer. That must be fixed, or we'll crash...
         167               0 :       NS_ASSERTION(columns_qi == static_cast<nsITreeColumns*>(aSupports),
         168                 :                    "Uh, fix QI!");
         169                 :     }
         170                 : #endif
         171                 :
         172               0 :     return static_cast<nsTreeColumns*>(aSupports);
         173                 :   }
         174                 :
         175                 :   friend class nsTreeBodyFrame;
         176                 : protected:
         177               0 :   void SetTree(nsITreeBoxObject* aTree) { mTree = aTree; }
         178                 :
         179                 :   // Builds our cache of column info.
         180                 :   void EnsureColumns();
         181                 :
         182               0 :   nsTreeColumn* GetFirstColumn() { EnsureColumns(); return mFirstColumn; }
         183                 :   nsTreeColumn* GetPrimaryColumn();
         184                 :
         185                 : private:
         186                 :   nsITreeBoxObject* mTree;
         187                 :
         188                 :   /**
         189                 :    * The first column in the list of columns. All of the columns are supposed
         190                 :    * to be "alive", i.e. have a frame. This is achieved by clearing the columns
         191                 :    * list each time an nsTreeColFrame is destroyed.
         192                 :    *
         193                 :    * XXX this means that new nsTreeColumn objects are unnecessarily created
         194                 :    *     for untouched columns.
         195                 :    */
         196                 :   nsTreeColumn* mFirstColumn;
         197                 : };
         198                 :
         199                 : #endif // nsTreeColumns_h__

Generated by: LCOV version 1.7