2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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 mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsIView_h___
|
|
|
|
#define nsIView_h___
|
|
|
|
|
2009-04-01 14:59:02 -07:00
|
|
|
#include "nsISupports.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsPoint.h"
|
2009-04-01 14:59:02 -07:00
|
|
|
#include "nsNativeWidget.h"
|
2009-07-21 17:45:00 -07:00
|
|
|
#include "nsIWidget.h"
|
2009-04-01 14:59:02 -07:00
|
|
|
#include "nsWidgetInitData.h"
|
2011-11-21 09:53:20 -08:00
|
|
|
#include "nsIFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIViewManager;
|
|
|
|
class nsViewManager;
|
|
|
|
class nsView;
|
2007-11-22 07:08:13 -08:00
|
|
|
class nsWeakView;
|
2009-04-01 14:59:02 -07:00
|
|
|
class nsIWidget;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Enumerated type to indicate the visibility of a layer.
|
|
|
|
// hide - the layer is not shown.
|
|
|
|
// show - the layer is shown irrespective of the visibility of
|
|
|
|
// the layer's parent.
|
|
|
|
enum nsViewVisibility {
|
|
|
|
nsViewVisibility_kHide = 0,
|
|
|
|
nsViewVisibility_kShow = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NS_IVIEW_IID \
|
2011-11-21 09:53:20 -08:00
|
|
|
{ 0xda62efbf, 0x0711, 0x4b79, \
|
|
|
|
{ 0x87, 0x85, 0x9e, 0xec, 0xed, 0xf5, 0xb0, 0x32 } }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Public view flags
|
|
|
|
|
|
|
|
// Indicates that the view is using auto z-indexing
|
|
|
|
#define NS_VIEW_FLAG_AUTO_ZINDEX 0x0004
|
|
|
|
|
|
|
|
// Indicates that the view is a floating view.
|
|
|
|
#define NS_VIEW_FLAG_FLOATING 0x0008
|
|
|
|
|
|
|
|
// If set it indicates that this view should be
|
|
|
|
// displayed above z-index:auto views if this view
|
|
|
|
// is z-index:auto also
|
|
|
|
#define NS_VIEW_FLAG_TOPMOST 0x0010
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View interface
|
|
|
|
*
|
|
|
|
* Views are NOT reference counted. Use the Destroy() member function to
|
|
|
|
* destroy a view.
|
|
|
|
*
|
|
|
|
* The lifetime of the view hierarchy is bounded by the lifetime of the
|
|
|
|
* view manager that owns the views.
|
|
|
|
*
|
|
|
|
* Most of the methods here are read-only. To set the corresponding properties
|
|
|
|
* of a view, go through nsIViewManager.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsIView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEW_IID)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the view for the given widget, if there is one.
|
|
|
|
* @return the view the widget belongs to, or null if the widget doesn't
|
|
|
|
* belong to any view.
|
|
|
|
*/
|
|
|
|
static nsIView* GetViewFor(nsIWidget* aWidget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the view manager which "owns" the view.
|
|
|
|
* This method might require some expensive traversal work in the future. If you can get the
|
|
|
|
* view manager from somewhere else, do that instead.
|
|
|
|
* @result the view manager
|
|
|
|
*/
|
|
|
|
nsIViewManager* GetViewManager() const
|
2007-07-08 00:08:04 -07:00
|
|
|
{ return reinterpret_cast<nsIViewManager*>(mViewManager); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy the view.
|
|
|
|
*
|
|
|
|
* The view destroys its child views, and destroys and releases its
|
|
|
|
* widget (if it has one).
|
|
|
|
*
|
|
|
|
* Also informs the view manager that the view is destroyed by calling
|
|
|
|
* SetRootView(NULL) if the view is the root view and calling RemoveChild()
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to get the position of a view.
|
2010-07-18 19:23:47 -07:00
|
|
|
* The specified coordinates are relative to the parent view's origin, but
|
|
|
|
* are in appunits of this.
|
2007-03-22 10:30:00 -07:00
|
|
|
* This is the (0, 0) origin of the coordinate space established by this view.
|
|
|
|
* @param x out parameter for x position
|
|
|
|
* @param y out parameter for y position
|
|
|
|
*/
|
|
|
|
nsPoint GetPosition() const {
|
|
|
|
// Call ExternalIsRoot here so that we can get to it from other
|
|
|
|
// components
|
|
|
|
NS_ASSERTION(!ExternalIsRoot() || (mPosX == 0 && mPosY == 0),
|
|
|
|
"root views should always have explicit position of (0,0)");
|
|
|
|
return nsPoint(mPosX, mPosY);
|
|
|
|
}
|
2009-10-07 20:01:15 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the position of a view. This does not cause any invalidation. It
|
|
|
|
* does reposition any widgets in this view or its descendants.
|
|
|
|
*/
|
|
|
|
virtual void SetPosition(nscoord aX, nscoord aY) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to get the dimensions and position of the view's bounds.
|
2010-07-18 19:23:47 -07:00
|
|
|
* The view's bounds (x,y) are relative to the origin of the parent view, but
|
|
|
|
* are in appunits of this.
|
2007-03-22 10:30:00 -07:00
|
|
|
* The view's bounds (x,y) might not be the same as the view's position,
|
|
|
|
* if the view has content above or to the left of its origin.
|
|
|
|
* @param aBounds out parameter for bounds
|
|
|
|
*/
|
|
|
|
nsRect GetBounds() const { return mDimBounds; }
|
|
|
|
|
2011-05-11 08:49:16 -07:00
|
|
|
/**
|
|
|
|
* The bounds of this view relative to this view. So this is the same as
|
|
|
|
* GetBounds except this is relative to this view instead of the parent view.
|
|
|
|
*/
|
|
|
|
nsRect GetDimensions() const {
|
|
|
|
nsRect r = mDimBounds; r.MoveBy(-mPosX, -mPosY); return r;
|
|
|
|
}
|
|
|
|
|
2011-03-11 15:12:11 -08:00
|
|
|
/**
|
|
|
|
* Set the dimensions at which invalidations are clipped, which can
|
|
|
|
* be different than |GetDimensions()|. |aRect| is relative to
|
|
|
|
* |this|. It can be null, in which case invalidations return to
|
|
|
|
* being clipped to the view dimensions.
|
|
|
|
*
|
|
|
|
* The caller is responsible for invalidating the area that may lie
|
|
|
|
* outside the view dimensions but inside |aRect| after this call.
|
|
|
|
*/
|
|
|
|
void SetInvalidationDimensions(const nsRect* aRect);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Get the offset between the coordinate systems of |this| and aOther.
|
|
|
|
* Adding the return value to a point in the coordinate system of |this|
|
|
|
|
* will transform the point to the coordinate system of aOther.
|
|
|
|
*
|
2010-07-18 19:23:47 -07:00
|
|
|
* The offset is expressed in appunits of |this|. So if you are getting the
|
|
|
|
* offset between views in different documents that might have different
|
|
|
|
* appunits per devpixel ratios you need to be careful how you use the
|
|
|
|
* result.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* If aOther is null, this will return the offset of |this| from the
|
|
|
|
* root of the viewmanager tree.
|
|
|
|
*
|
|
|
|
* This function is fastest when aOther is an ancestor of |this|.
|
|
|
|
*
|
|
|
|
* NOTE: this actually returns the offset from aOther to |this|, but
|
|
|
|
* that offset is added to transform _coordinates_ from |this| to aOther.
|
|
|
|
*/
|
|
|
|
nsPoint GetOffsetTo(const nsIView* aOther) const;
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
/**
|
|
|
|
* Get the offset between the origin of |this| and the origin of aWidget.
|
|
|
|
* Adding the return value to a point in the coordinate system of |this|
|
|
|
|
* will transform the point to the coordinate system of aWidget.
|
|
|
|
*
|
|
|
|
* The offset is expressed in appunits of |this|.
|
|
|
|
*/
|
|
|
|
nsPoint GetOffsetToWidget(nsIWidget* aWidget) const;
|
|
|
|
|
2011-05-11 08:49:16 -07:00
|
|
|
/**
|
|
|
|
* Takes a point aPt that is in the coordinate system of |this|'s parent view
|
|
|
|
* and converts it to be in the coordinate system of |this| taking into
|
|
|
|
* account the offset and any app unit per dev pixel ratio differences.
|
|
|
|
*/
|
|
|
|
nsPoint ConvertFromParentCoords(nsPoint aPt) const;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Called to query the visibility state of a view.
|
|
|
|
* @result current visibility state
|
|
|
|
*/
|
|
|
|
nsViewVisibility GetVisibility() const { return mVis; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether the view "floats" above all other views,
|
|
|
|
* which tells the compositor not to consider higher views in
|
|
|
|
* the view hierarchy that would geometrically intersect with
|
|
|
|
* this view. This is a hack, but it fixes some problems with
|
|
|
|
* views that need to be drawn in front of all other views.
|
2011-10-17 07:59:28 -07:00
|
|
|
* @result true if the view floats, false otherwise.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetFloating() const { return (mVFlags & NS_VIEW_FLAG_FLOATING) != 0; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to query the parent of the view.
|
|
|
|
* @result view's parent
|
|
|
|
*/
|
2007-07-08 00:08:04 -07:00
|
|
|
nsIView* GetParent() const { return reinterpret_cast<nsIView*>(mParent); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The view's first child is the child which is earliest in document order.
|
|
|
|
* @result first child
|
|
|
|
*/
|
2007-07-08 00:08:04 -07:00
|
|
|
nsIView* GetFirstChild() const { return reinterpret_cast<nsIView*>(mFirstChild); }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to query the next sibling of the view.
|
|
|
|
* @result view's next sibling
|
|
|
|
*/
|
2007-07-08 00:08:04 -07:00
|
|
|
nsIView* GetNextSibling() const { return reinterpret_cast<nsIView*>(mNextSibling); }
|
2010-09-18 04:28:49 -07:00
|
|
|
void SetNextSibling(nsIView *aSibling) {
|
|
|
|
mNextSibling = reinterpret_cast<nsView*>(aSibling);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2011-11-21 09:53:20 -08:00
|
|
|
* Set the view's frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-11-21 09:53:20 -08:00
|
|
|
void SetFrame(nsIFrame* aRootFrame) { mFrame = aRootFrame; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2011-11-21 09:53:20 -08:00
|
|
|
* Retrieve the view's frame.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-11-21 09:53:20 -08:00
|
|
|
nsIFrame* GetFrame() const { return mFrame; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the nearest widget in this view or a parent of this view and
|
|
|
|
* the offset from the widget's origin to this view's origin
|
2011-03-01 08:15:23 -08:00
|
|
|
* @param aOffset - if non-null the offset from this view's origin to the
|
|
|
|
* widget's origin (usually positive) expressed in appunits of this will be
|
|
|
|
* returned in aOffset.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return the widget closest to this view; can be null because some view trees
|
|
|
|
* don't have widgets at all (e.g., printing), but if any view in the view tree
|
|
|
|
* has a widget, then it's safe to assume this will not return null
|
|
|
|
* XXX Remove this 'virtual' when gfx+widget are merged into gklayout;
|
|
|
|
* Mac widget depends on this method, which is BOGUS!
|
|
|
|
*/
|
|
|
|
virtual nsIWidget* GetNearestWidget(nsPoint* aOffset) const;
|
|
|
|
|
|
|
|
/**
|
2010-08-20 12:29:02 -07:00
|
|
|
* Create a widget to associate with this view. This variant of
|
|
|
|
* CreateWidget*() will look around in the view hierarchy for an
|
|
|
|
* appropriate parent widget for the view.
|
|
|
|
*
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aWidgetInitData data used to initialize this view's widget before
|
|
|
|
* its create is called.
|
|
|
|
* @return error status
|
|
|
|
*/
|
2010-08-20 12:29:02 -07:00
|
|
|
nsresult CreateWidget(nsWidgetInitData *aWidgetInitData = nsnull,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEnableDragDrop = true,
|
|
|
|
bool aResetVisibility = true);
|
2010-08-20 12:29:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a widget for this view with an explicit parent widget.
|
|
|
|
* |aParentWidget| must be nonnull. The other params are the same
|
|
|
|
* as for |CreateWidget()|.
|
|
|
|
*/
|
2010-08-20 12:29:02 -07:00
|
|
|
nsresult CreateWidgetForParent(nsIWidget* aParentWidget,
|
2010-08-20 12:29:02 -07:00
|
|
|
nsWidgetInitData *aWidgetInitData = nsnull,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEnableDragDrop = true,
|
|
|
|
bool aResetVisibility = true);
|
2010-08-20 12:29:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a popup widget for this view. Pass |aParentWidget| to
|
|
|
|
* explicitly set the popup's parent. If it's not passed, the view
|
|
|
|
* hierarchy will be searched for an appropriate parent widget. The
|
|
|
|
* other params are the same as for |CreateWidget()|, except that
|
|
|
|
* |aWidgetInitData| must be nonnull.
|
|
|
|
*/
|
2010-08-20 12:29:02 -07:00
|
|
|
nsresult CreateWidgetForPopup(nsWidgetInitData *aWidgetInitData,
|
2010-08-20 12:29:02 -07:00
|
|
|
nsIWidget* aParentWidget = nsnull,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aEnableDragDrop = true,
|
|
|
|
bool aResetVisibility = true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-21 11:28:10 -07:00
|
|
|
/**
|
|
|
|
* Destroys the associated widget for this view. If this method is
|
|
|
|
* not called explicitly, the widget when be destroyed when its
|
|
|
|
* view gets destroyed.
|
|
|
|
*/
|
|
|
|
void DestroyWidget();
|
|
|
|
|
2010-06-24 19:01:06 -07:00
|
|
|
/**
|
|
|
|
* Attach/detach a top level widget from this view. When attached, the view
|
|
|
|
* updates the widget's device context and allows the view to begin receiving
|
|
|
|
* gecko events. The underlying base window associated with the widget will
|
|
|
|
* continues to receive events it expects.
|
|
|
|
*
|
|
|
|
* An attached widget will not be destroyed when the view is destroyed,
|
|
|
|
* allowing the recycling of a single top level widget over multiple views.
|
|
|
|
*
|
|
|
|
* @param aWidget The widget to attach to / detach from.
|
|
|
|
*/
|
|
|
|
nsresult AttachToTopLevelWidget(nsIWidget* aWidget);
|
|
|
|
nsresult DetachFromTopLevelWidget();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a flag indicating whether the view owns it's widget
|
|
|
|
* or is attached to an existing top level widget.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAttachedToTopLevel() const { return mWidgetIsTopLevel; }
|
2010-06-24 19:01:06 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* In 4.0, the "cutout" nature of a view is queryable.
|
|
|
|
* If we believe that all cutout view have a native widget, this
|
|
|
|
* could be a replacement.
|
|
|
|
* @param aWidget out parameter for widget that this view contains,
|
|
|
|
* or nsnull if there is none.
|
|
|
|
*/
|
|
|
|
nsIWidget* GetWidget() const { return mWindow; }
|
|
|
|
|
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* Returns true if the view has a widget associated with it.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasWidget() const { return mWindow != nsnull; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-21 17:45:00 -07:00
|
|
|
/**
|
|
|
|
* Make aWidget direct its events to this view.
|
|
|
|
* The caller must call DetachWidgetEventHandler before this view
|
|
|
|
* is destroyed.
|
|
|
|
*/
|
|
|
|
EVENT_CALLBACK AttachWidgetEventHandler(nsIWidget* aWidget);
|
|
|
|
/**
|
|
|
|
* Stop aWidget directing its events to this view.
|
|
|
|
*/
|
|
|
|
void DetachWidgetEventHandler(nsIWidget* aWidget);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* Output debug info to FILE
|
|
|
|
* @param out output file handle
|
|
|
|
* @param aIndent indentation depth
|
|
|
|
* NOTE: virtual so that debugging tools not linked into gklayout can access it
|
|
|
|
*/
|
|
|
|
virtual void List(FILE* out, PRInt32 aIndent = 0) const;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @result true iff this is the root view for its view manager
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRoot() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ExternalIsRoot() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-22 07:08:13 -08:00
|
|
|
void SetDeletionObserver(nsWeakView* aDeletionObserver);
|
2010-02-24 00:33:41 -08:00
|
|
|
|
|
|
|
nsIntRect CalcWidgetBounds(nsWindowType aType);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsEffectivelyVisible();
|
2010-02-24 00:33:41 -08:00
|
|
|
|
2010-04-22 17:21:54 -07:00
|
|
|
// This is an app unit offset to add when converting view coordinates to
|
|
|
|
// widget coordinates. It is the offset in view coordinates from widget
|
2010-07-18 19:23:47 -07:00
|
|
|
// origin (unlike views, widgets can't extend above or to the left of their
|
|
|
|
// origin) to view origin expressed in appunits of this.
|
2010-06-25 14:51:17 -07:00
|
|
|
nsPoint ViewToWidgetOffset() const { return mViewToWidgetOffset; }
|
2010-04-22 17:21:54 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2007-11-22 07:08:13 -08:00
|
|
|
friend class nsWeakView;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsViewManager *mViewManager;
|
|
|
|
nsView *mParent;
|
|
|
|
nsIWidget *mWindow;
|
|
|
|
nsView *mNextSibling;
|
|
|
|
nsView *mFirstChild;
|
2011-11-21 09:53:20 -08:00
|
|
|
nsIFrame *mFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 mZIndex;
|
|
|
|
nsViewVisibility mVis;
|
2010-07-18 19:23:47 -07:00
|
|
|
// position relative our parent view origin but in our appunits
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord mPosX, mPosY;
|
2010-07-18 19:23:47 -07:00
|
|
|
// relative to parent, but in our appunits
|
|
|
|
nsRect mDimBounds;
|
|
|
|
// in our appunits
|
2010-02-24 00:33:41 -08:00
|
|
|
nsPoint mViewToWidgetOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
float mOpacity;
|
|
|
|
PRUint32 mVFlags;
|
2007-11-22 07:08:13 -08:00
|
|
|
nsWeakView* mDeletionObserver;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mWidgetIsTopLevel;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual ~nsIView() {}
|
2010-08-20 12:29:01 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsView* Impl();
|
|
|
|
const nsView* Impl() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIView, NS_IVIEW_IID)
|
|
|
|
|
2007-11-22 07:08:13 -08:00
|
|
|
// nsWeakViews must *not* be used in heap!
|
|
|
|
class nsWeakView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsWeakView(nsIView* aView) : mPrev(nsnull), mView(aView)
|
|
|
|
{
|
|
|
|
if (mView) {
|
|
|
|
mView->SetDeletionObserver(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsWeakView()
|
|
|
|
{
|
|
|
|
if (mView) {
|
|
|
|
NS_ASSERTION(mView->mDeletionObserver == this,
|
|
|
|
"nsWeakViews deleted in wrong order!");
|
|
|
|
// Clear deletion observer temporarily.
|
|
|
|
mView->SetDeletionObserver(nsnull);
|
|
|
|
// Put back the previous deletion observer.
|
|
|
|
mView->SetDeletionObserver(mPrev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsAlive() { return !!mView; }
|
2007-11-22 07:08:13 -08:00
|
|
|
|
|
|
|
nsIView* GetView() { return mView; }
|
|
|
|
|
|
|
|
void SetPrevious(nsWeakView* aWeakView) { mPrev = aWeakView; }
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
if (mPrev) {
|
|
|
|
mPrev->Clear();
|
|
|
|
}
|
|
|
|
mView = nsnull;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
|
|
|
static void operator delete(void*, size_t) {}
|
|
|
|
nsWeakView* mPrev;
|
|
|
|
nsIView* mView;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|