LCOV - code coverage report
Current view: directory - view/src - nsView.h (source / functions) Found Hit Coverage
Test: app.info Lines: 23 0 0.0 %
Date: 2012-06-02 Functions: 16 0 0.0 %

       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) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsView_h___
      39                 : #define nsView_h___
      40                 : 
      41                 : #include "nsIView.h"
      42                 : #include "nsRegion.h"
      43                 : #include "nsRect.h"
      44                 : #include "nsCRT.h"
      45                 : #include "nsIFactory.h"
      46                 : #include "nsEvent.h"
      47                 : #include <stdio.h>
      48                 : 
      49                 : //mmptemp
      50                 : 
      51                 : class nsIViewManager;
      52                 : class nsViewManager;
      53                 : 
      54                 : class nsView : public nsIView
      55                 : {
      56                 : public:
      57                 :   nsView(nsViewManager* aViewManager = nsnull,
      58                 :          nsViewVisibility aVisibility = nsViewVisibility_kShow);
      59                 : 
      60               0 :   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
      61                 : 
      62                 :   NS_IMETHOD  QueryInterface(const nsIID& aIID, void** aInstancePtr);
      63                 : 
      64                 :   /**
      65                 :    * Called to indicate that the position of the view has been changed.
      66                 :    * The specified coordinates are in the parent view's coordinate space.
      67                 :    * @param x new x position
      68                 :    * @param y new y position
      69                 :    */
      70                 :   virtual void SetPosition(nscoord aX, nscoord aY);
      71                 :   /**
      72                 :    * Called to indicate that the dimensions of the view have been changed.
      73                 :    * The x and y coordinates may be < 0, indicating that the view extends above
      74                 :    * or to the left of its origin position. The term 'dimensions' indicates it
      75                 :    * is relative to this view.
      76                 :    */
      77                 :   virtual void SetDimensions(const nsRect &aRect, bool aPaint = true,
      78                 :                              bool aResizeWidget = true);
      79                 :   void SetInvalidationDimensions(const nsRect* aRect);
      80                 : 
      81                 :   /**
      82                 :    * Called to indicate that the visibility of a view has been
      83                 :    * changed.
      84                 :    * @param visibility new visibility state
      85                 :    */
      86                 :   NS_IMETHOD  SetVisibility(nsViewVisibility visibility);
      87                 : 
      88                 :   /**
      89                 :    * Called to indicate that the z-index of a view has been changed.
      90                 :    * The z-index is relative to all siblings of the view.
      91                 :    * @param aAuto Indicate that the z-index of a view is "auto". An "auto" z-index
      92                 :    * means that the view does not define a new stacking context,
      93                 :    * which means that the z-indicies of the view's children are
      94                 :    * relative to the view's siblings.
      95                 :    * @param zindex new z depth
      96                 :    */
      97                 :   void SetZIndex(bool aAuto, PRInt32 aZIndex, bool aTopMost);
      98                 : 
      99                 :   /**
     100                 :    * Set/Get whether the view "floats" above all other views,
     101                 :    * which tells the compositor not to consider higher views in
     102                 :    * the view hierarchy that would geometrically intersect with
     103                 :    * this view. This is a hack, but it fixes some problems with
     104                 :    * views that need to be drawn in front of all other views.
     105                 :    * @result true if the view floats, false otherwise.
     106                 :    */
     107                 :   NS_IMETHOD  SetFloating(bool aFloatingView);
     108                 : 
     109                 :   // Helper function to get the view that's associated with a widget
     110               0 :   static nsView* GetViewFor(nsIWidget* aWidget) {
     111               0 :     return static_cast<nsView*>(nsIView::GetViewFor(aWidget));
     112                 :   }
     113                 : 
     114                 :   // Helper function to get mouse grabbing off this view (by moving it to the
     115                 :   // parent, if we can)
     116                 :   void DropMouseGrabbing();
     117                 : 
     118                 : public:
     119                 :   // See nsIView::CreateWidget.
     120                 :   nsresult CreateWidget(nsWidgetInitData *aWidgetInitData,
     121                 :                         bool aEnableDragDrop,
     122                 :                         bool aResetVisibility);
     123                 : 
     124                 :   // See nsIView::CreateWidgetForParent.
     125                 :   nsresult CreateWidgetForParent(nsIWidget* aParentWidget,
     126                 :                                  nsWidgetInitData *aWidgetInitData,
     127                 :                                  bool aEnableDragDrop,
     128                 :                                  bool aResetVisibility);
     129                 : 
     130                 :   // See nsIView::CreateWidgetForPopup.
     131                 :   nsresult CreateWidgetForPopup(nsWidgetInitData *aWidgetInitData,
     132                 :                                 nsIWidget* aParentWidget,
     133                 :                                 bool aEnableDragDrop,
     134                 :                                 bool aResetVisibility);
     135                 : 
     136                 :   // See nsIView::DestroyWidget
     137                 :   void DestroyWidget();
     138                 : 
     139                 :   // NOT in nsIView, so only available in view module
     140                 :   // These are also present in nsIView, but these versions return nsView and nsViewManager
     141                 :   // instead of nsIView and nsIViewManager.
     142               0 :   nsView* GetFirstChild() const { return mFirstChild; }
     143               0 :   nsView* GetNextSibling() const { return mNextSibling; }
     144               0 :   nsView* GetParent() const { return mParent; }
     145               0 :   nsViewManager* GetViewManager() const { return mViewManager; }
     146                 :   // These are superseded by a better interface in nsIView
     147               0 :   PRInt32 GetZIndex() const { return mZIndex; }
     148               0 :   bool GetZIndexIsAuto() const { return (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; }
     149                 :   // Same as GetBounds but converts to parent appunits if they are different.
     150                 :   nsRect GetBoundsInParentUnits() const;
     151                 : 
     152               0 :   nsRect GetInvalidationDimensions() const {
     153               0 :     return mHaveInvalidationDimensions ? mInvalidationDimensions : GetDimensions();
     154                 :   }
     155                 : 
     156                 :   // These are defined exactly the same in nsIView, but for now they have to be redeclared
     157                 :   // here because of stupid C++ method hiding rules
     158                 : 
     159               0 :   bool HasNonEmptyDirtyRegion() {
     160               0 :     return mDirtyRegion && !mDirtyRegion->IsEmpty();
     161                 :   }
     162               0 :   nsRegion* GetDirtyRegion() {
     163               0 :     if (!mDirtyRegion) {
     164               0 :       NS_ASSERTION(!mParent || GetFloating(),
     165                 :                    "Only display roots should have dirty regions");
     166               0 :       mDirtyRegion = new nsRegion();
     167               0 :       NS_ASSERTION(mDirtyRegion, "Out of memory!");
     168                 :     }
     169               0 :     return mDirtyRegion;
     170                 :   }
     171                 : 
     172                 :   void InsertChild(nsView *aChild, nsView *aSibling);
     173                 :   void RemoveChild(nsView *aChild);
     174                 : 
     175               0 :   void SetParent(nsView *aParent) { mParent = aParent; }
     176               0 :   void SetNextSibling(nsView *aSibling) { mNextSibling = aSibling; }
     177                 : 
     178                 :   PRUint32 GetViewFlags() const { return mVFlags; }
     179                 :   void SetViewFlags(PRUint32 aFlags) { mVFlags = aFlags; }
     180                 : 
     181               0 :   void SetTopMost(bool aTopMost) { aTopMost ? mVFlags |= NS_VIEW_FLAG_TOPMOST : mVFlags &= ~NS_VIEW_FLAG_TOPMOST; }
     182               0 :   bool IsTopMost() { return((mVFlags & NS_VIEW_FLAG_TOPMOST) != 0); }
     183                 : 
     184                 :   void ResetWidgetBounds(bool aRecurse, bool aForceSync);
     185                 :   void AssertNoWindow();
     186                 : 
     187                 :   void NotifyEffectiveVisibilityChanged(bool aEffectivelyVisible);
     188                 : 
     189                 :   // Update the cached RootViewManager for all view manager descendents,
     190                 :   // If the hierarchy is being removed, aViewManagerParent points to the view
     191                 :   // manager for the hierarchy's old parent, and will have its mouse grab
     192                 :   // released if it points to any view in this view hierarchy.
     193                 :   void InvalidateHierarchy(nsViewManager *aViewManagerParent);
     194                 : 
     195                 :   virtual ~nsView();
     196                 : 
     197                 :   nsPoint GetOffsetTo(const nsView* aOther) const;
     198                 :   nsIWidget* GetNearestWidget(nsPoint* aOffset) const;
     199                 :   nsPoint GetOffsetTo(const nsView* aOther, const PRInt32 aAPD) const;
     200                 :   nsIWidget* GetNearestWidget(nsPoint* aOffset, const PRInt32 aAPD) const;
     201                 : 
     202                 : protected:
     203                 :   // Do the actual work of ResetWidgetBounds, unconditionally.  Don't
     204                 :   // call this method if we have no widget.
     205                 :   void DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize);
     206                 : 
     207                 :   nsRegion*    mDirtyRegion;
     208                 :   // invalidations are clipped to mInvalidationDimensions, not
     209                 :   // GetDimensions(), when mHaveInvalidationDimensions is true.  This
     210                 :   // is used to support persistent "displayport" rendering; see
     211                 :   // nsPresShell.cpp.  The coordinates of mInvalidationDimensions are
     212                 :   // relative to |this|.
     213                 :   nsRect       mInvalidationDimensions;
     214                 :   bool mHaveInvalidationDimensions;
     215                 : 
     216                 : private:
     217                 :   void InitializeWindow(bool aEnableDragDrop, bool aResetVisibility);
     218                 : };
     219                 : 
     220                 : #endif

Generated by: LCOV version 1.7