Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends
nsIView_MOZILLA_1_8_BRANCH Class Reference

#include <nsIView.h>

Inheritance diagram for nsIView_MOZILLA_1_8_BRANCH:
Inheritance graph
[legend]
Collaboration diagram for nsIView_MOZILLA_1_8_BRANCH:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void SetDeletionObserver (nsWeakView *aDeletionObserver)
virtual nsIScrollableViewToScrollableView ()
 See if this view is scrollable.
nsIViewManagerGetViewManager () const
 Get the view manager which "owns" the view.
void Destroy ()
 Destroy the view.
nsPoint GetPosition () const
 Called to get the position of a view.
nsRect GetBounds () const
 Called to get the dimensions and position of the view's bounds.
nsPoint GetOffsetTo (const nsIView *aOther) const
 Get the offset between the coordinate systems of |this| and aOther.
nsIntPoint GetScreenPosition () const
 Get the screen position of the view.
nsViewVisibility GetVisibility () const
 Called to query the visibility state of a view.
nsViewZIndex GetZIndex () const
 Called to query the z-index of a view.
PRBool GetFloating () const
 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.
nsIViewGetParent () const
 Called to query the parent of the view.
nsIViewGetFirstChild () const
 The view's first child is the child which is earliest in document order.
nsIViewGetNextSibling () const
 Called to query the next sibling of the view.
float GetOpacity () const
 Note: This didn't exist in 4.0.
PRBool IsTransparent () const
 Used to ask a view if it has any areas within its bounding box that are transparent.
void SetHasUniformBackground (PRBool aUniform)
 Indicate that this view is always painted onto a uniform field of pixels.
PRBool HasUniformBackground ()
void SetClientData (void *aData)
 Set the view's link to client owned data.
voidGetClientData () const
 Query the view for it's link to client owned data.
virtual nsIWidgetGetNearestWidget (nsPoint *aOffset) const
 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.
nsresult CreateWidget (const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData=nsnull, nsNativeWidget aNative=nsnull, PRBool aEnableDragDrop=PR_TRUE, PRBool aResetVisibility=PR_TRUE, nsContentType aWindowType=eContentTypeInherit)
 Create a widget to associate with this view.
nsIWidgetGetWidget () const
 In 4.0, the "cutout" nature of a view is queryable.
PRBool HasWidget () const
 Returns PR_TRUE if the view has a widget associated with it.
PRBool IsRoot () const
virtual PRBool ExternalIsRoot () const

Static Public Member Functions

static nsIViewGetViewFor (nsIWidget *aWidget)
 Find the view for the given widget, if there is one.

Protected Attributes

nsWeakViewmDeletionObserver
nsViewManagermViewManager
nsViewmParent
nsIWidgetmWindow
nsViewmNextSibling
nsViewmFirstChild
voidmClientData
PRInt32 mZIndex
nsViewVisibility mVis
nscoord mPosX
nscoord mPosY
nsRect mDimBounds
float mOpacity
PRUint32 mVFlags

Friends

class nsWeakView

Detailed Description

Definition at line 383 of file nsIView.h.


Member Function Documentation

nsresult nsIView::CreateWidget ( const nsIID aWindowIID,
nsWidgetInitData aWidgetInitData = nsnull,
nsNativeWidget  aNative = nsnull,
PRBool  aEnableDragDrop = PR_TRUE,
PRBool  aResetVisibility = PR_TRUE,
nsContentType  aWindowType = eContentTypeInherit 
) [inherited]

Create a widget to associate with this view.

Parameters:
aWindowIIDIID for Widget type that this view should have associated with it. if nsull, then no width will be created for this view
aWidgetInitDatadata used to initialize this view's widget before its create is called.
aNativenative window that will be used as parent of aWindowIID. if nsnull, then parent will be derived from parent view and it's ancestors
aWindowTypeis either content, UI or inherit from parent window. This is used to expose what type of window this is to assistive technology like screen readers.
Returns:
error status

Definition at line 650 of file nsView.cpp.

{
  nsIDeviceContext  *dx;
  nsRect            trect = mDimBounds;

  if (NS_UNLIKELY(!!mWindow)) {
    NS_ERROR("We already have a window for this view? BAD");
    ViewWrapper* wrapper = GetWrapperFor(mWindow);
    NS_IF_RELEASE(wrapper);
    mWindow->SetClientData(nsnull);
    NS_RELEASE(mWindow);
  }

  mViewManager->GetDeviceContext(dx);
  float scale = dx->AppUnitsToDevUnits();

  trect *= scale;

  nsView* v = NS_STATIC_CAST(nsView*, this);
  if (NS_OK == v->LoadWidget(aWindowIID))
  {
    PRBool usewidgets;

    dx->SupportsNativeWidgets(usewidgets);

    if (PR_TRUE == usewidgets)
    {
      PRBool initDataPassedIn = PR_TRUE;
      nsWidgetInitData initData;
      if (!aWidgetInitData) {
        // No initData, we're a child window
        // Create initData to pass in params
        initDataPassedIn = PR_FALSE;
        initData.clipChildren = PR_TRUE; // Clip child window's children
        initData.clipSiblings = PR_TRUE; // Clip child window's siblings
        aWidgetInitData = &initData;
      }
      aWidgetInitData->mContentType = aContentType;

      if (aNative)
        mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
      else
      {
        if (!initDataPassedIn && GetParent() && 
          GetParent()->GetViewManager() != mViewManager)
          initData.mListenForResizes = PR_TRUE;

        nsPoint offset(0, 0);
        nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(&offset)
          : nsnull;
        trect += offset;
        if (aWidgetInitData->mWindowType == eWindowType_popup) {
          mWindow->Create(parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
        } else {
          mWindow->Create(parentWidget, trect,
                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
        }
      }
      if (aEnableDragDrop) {
        mWindow->EnableDragDrop(PR_TRUE);
      }
      
      // propagate the z-index to the widget.
      UpdateNativeWidgetZIndexes(v, FindNonAutoZIndex(v));
    }
  }

  //make sure visibility state is accurate
  
  if (aResetVisibility) {
    v->SetVisibility(GetVisibility());
  }

  NS_RELEASE(dx);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIView::Destroy ( void  ) [inherited]

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.

Definition at line 307 of file nsView.cpp.

{
  delete this;
}

Here is the caller graph for this function:

PRBool nsIView::ExternalIsRoot ( ) const [virtual, inherited]

Definition at line 916 of file nsView.cpp.

{
  return nsIView::IsRoot();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsRect nsIView::GetBounds ( ) const [inline, inherited]

Called to get the dimensions and position of the view's bounds.

The view's bounds (x,y) are in the coordinate space of the parent view. 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.

Parameters:
aBoundsout parameter for bounds

Definition at line 179 of file nsIView.h.

{ return mDimBounds; }

Here is the caller graph for this function:

void* nsIView::GetClientData ( ) const [inline, inherited]

Query the view for it's link to client owned data.

Returns:
data associated with view or nsnull if there is none.

Definition at line 297 of file nsIView.h.

{ return mClientData; }

Here is the caller graph for this function:

nsIView* nsIView::GetFirstChild ( ) const [inline, inherited]

The view's first child is the child which is earliest in document order.

Returns:
first child

Reimplemented in nsView.

Definition at line 242 of file nsIView.h.

Here is the caller graph for this function:

PRBool nsIView::GetFloating ( ) const [inline, inherited]

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.

Returns:
PR_TRUE if the view floats, PR_FALSE otherwise.

Definition at line 230 of file nsIView.h.

{ return (mVFlags & NS_VIEW_FLAG_FLOATING) != 0; }

Here is the caller graph for this function:

nsIWidget * nsIView::GetNearestWidget ( nsPoint aOffset) const [virtual, inherited]

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.

Parameters:
aOffsetthe offset from this view's origin to the widget's origin (usually positive)
Returns:
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!

Definition at line 885 of file nsView.cpp.

{
  nsPoint pt(0, 0);
  const nsView* v;
  for (v = NS_STATIC_CAST(const nsView*, this);
       v && !v->HasWidget(); v = v->GetParent()) {
    pt += v->GetPosition();
  }
  if (!v) {
    if (aOffset) {
      *aOffset = pt;
    }
    return NS_STATIC_CAST(const nsView*, this)->GetViewManager()->GetWidget();
  }

  // pt is now the offset from v's origin to this's origin
  // The widget's origin is the top left corner of v's bounds, which may
  // not coincide with v's origin
  if (aOffset) {
    nsRect vBounds = v->GetBounds();
    *aOffset = pt + v->GetPosition() -  nsPoint(vBounds.x, vBounds.y);
  }
  return v->GetWidget();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIView* nsIView::GetNextSibling ( ) const [inline, inherited]

Called to query the next sibling of the view.

Returns:
view's next sibling

Reimplemented in nsView.

Definition at line 248 of file nsIView.h.

Here is the caller graph for this function:

nsPoint nsIView::GetOffsetTo ( const nsIView aOther) const [inherited]

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.

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.

Definition at line 845 of file nsView.cpp.

{
  nsPoint offset(0, 0);
  const nsIView* v;
  for (v = this; v != aOther && v; v = v->GetParent()) {
    offset += v->GetPosition();
  }

  if (v != aOther) {
    // Looks like aOther wasn't an ancestor of |this|.  So now we have
    // the root-VM-relative position of |this| in |offset|.  Convert back
    // to the coordinates of aOther
    while (aOther) {
      offset -= aOther->GetPosition();
      aOther = aOther->GetParent();
    }
  }

  return offset;
}

Here is the call graph for this function:

Here is the caller graph for this function:

float nsIView::GetOpacity ( ) const [inline, inherited]

Note: This didn't exist in 4.0.

Called to get the opacity of a view. A value of 0.0 means completely transparent. A value of 1.0 means completely opaque.

Returns:
view's opacity value

Definition at line 256 of file nsIView.h.

{ return mOpacity; }

Here is the caller graph for this function:

nsIView* nsIView::GetParent ( ) const [inline, inherited]

Called to query the parent of the view.

Returns:
view's parent

Reimplemented in nsView.

Definition at line 236 of file nsIView.h.

Here is the caller graph for this function:

nsPoint nsIView::GetPosition ( ) const [inline, inherited]

Called to get the position of a view.

The specified coordinates are in the parent view's coordinate space. This is the (0, 0) origin of the coordinate space established by this view.

Parameters:
xout parameter for x position
yout parameter for y position

Definition at line 164 of file nsIView.h.

                              {
    // 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);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

nsIntPoint nsIView::GetScreenPosition ( ) const [inherited]

Get the screen position of the view.

Returns:
the pixel position of the top-left of the view in screen coordinates.

Definition at line 866 of file nsView.cpp.

{
  nsIntRect screenRect(0,0,0,0);  
  nsPoint toWidgetOffset(0,0);
  nsIWidget* widget = GetNearestWidget(&toWidgetOffset);
  if (widget) {
    nsCOMPtr<nsIDeviceContext> dx;
    mViewManager->GetDeviceContext(*getter_AddRefs(dx));
    float t2p = dx->AppUnitsToDevUnits();
    nsIntRect ourRect(NSTwipsToIntPixels(toWidgetOffset.x, t2p),
                      NSTwipsToIntPixels(toWidgetOffset.y, t2p),
                      0,
                      0);
    widget->WidgetToScreen(ourRect, screenRect);
  }
  
  return nsIntPoint(screenRect.x, screenRect.y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIView * nsIView::GetViewFor ( nsIWidget aWidget) [static, inherited]

Find the view for the given widget, if there is one.

Returns:
the view the widget belongs to, or null if the widget doesn't belong to any view.

Reimplemented in nsView.

Definition at line 297 of file nsView.cpp.

{           
  NS_PRECONDITION(nsnull != aWidget, "null widget ptr");

  ViewWrapper* wrapper = GetWrapperFor(aWidget);
  if (wrapper)
    return wrapper->GetView();  
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIViewManager* nsIView::GetViewManager ( ) const [inline, inherited]

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.

Returns:
the view manager

Reimplemented in nsView.

Definition at line 142 of file nsIView.h.

nsViewVisibility nsIView::GetVisibility ( ) const [inline, inherited]

Called to query the visibility state of a view.

Returns:
current visibility state

Definition at line 207 of file nsIView.h.

{ return mVis; }

Here is the caller graph for this function:

nsIWidget* nsIView::GetWidget ( ) const [inline, inherited]

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.

Parameters:
aWidgetout parameter for widget that this view contains, or nsnull if there is none.

Definition at line 341 of file nsIView.h.

{ return mWindow; }
nsViewZIndex nsIView::GetZIndex ( ) const [inline, inherited]

Called to query the z-index of a view.

The z-index is relative to all siblings of the view.

Returns:
mZIndex: explicit z-index value or 0 if none is set mIsAuto: PR_TRUE if the view is zindex:auto mIsTopMost: used when this view is zindex:auto PR_TRUE if the view is topmost when compared with another z-index:auto view

Reimplemented in nsView.

Definition at line 218 of file nsIView.h.

PRBool nsIView::HasUniformBackground ( ) [inline, inherited]

Definition at line 283 of file nsIView.h.

Here is the caller graph for this function:

PRBool nsIView::HasWidget ( ) const [inline, inherited]

Returns PR_TRUE if the view has a widget associated with it.

Definition at line 346 of file nsIView.h.

{ return mWindow != nsnull; }

Here is the caller graph for this function:

PRBool nsIView::IsRoot ( ) const [inherited]
Returns:
true iff this is the root view for its view manager

Definition at line 910 of file nsView.cpp.

{
  NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
  return mViewManager->GetRootView() == this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsIView::IsTransparent ( ) const [inline, inherited]

Used to ask a view if it has any areas within its bounding box that are transparent.

This is not the same as opacity - opacity can be set externally, transparency is a quality of the view itself.

Returns:
Returns PR_TRUE if there are transparent areas, PR_FALSE otherwise.

Definition at line 264 of file nsIView.h.

{ return (mVFlags & NS_VIEW_FLAG_TRANSPARENT) != 0; }

Here is the caller graph for this function:

void nsIView::SetClientData ( void aData) [inline, inherited]

Set the view's link to client owned data.

Parameters:
aData- data to associate with view. nsnull to disassociate

Definition at line 291 of file nsIView.h.

Here is the caller graph for this function:

Definition at line 922 of file nsView.cpp.

{
  if (mDeletionObserver && aDeletionObserver) {
    aDeletionObserver->SetPrevious(mDeletionObserver);
  }
  mDeletionObserver = aDeletionObserver;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIView::SetHasUniformBackground ( PRBool  aUniform) [inline, inherited]

Indicate that this view is always painted onto a uniform field of pixels.

Thus, even if the view is transparent, it may still be bitblit scrollable because the background that shines through does not vary with position. Caller must ensure that the pixel field belongs to the same element as this view or some ancestor element, so that if the pixel field is in some opacity group, then this view is also in the opacity group (or some subgroup).

Definition at line 275 of file nsIView.h.

Here is the caller graph for this function:

virtual nsIScrollableView* nsIView::ToScrollableView ( ) [inline, virtual, inherited]

See if this view is scrollable.

Returns:
an nsIScrollableView* if the view is scrollable, or nsnull if not.

Reimplemented in nsScrollPortView.

Definition at line 127 of file nsIView.h.

{ return nsnull; }

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsWeakView [friend]

Definition at line 388 of file nsIView.h.


Member Data Documentation

void* nsIView::mClientData [protected, inherited]

Definition at line 371 of file nsIView.h.

Definition at line 389 of file nsIView.h.

nsRect nsIView::mDimBounds [protected, inherited]

Definition at line 375 of file nsIView.h.

nsView* nsIView::mFirstChild [protected, inherited]

Definition at line 370 of file nsIView.h.

nsView* nsIView::mNextSibling [protected, inherited]

Definition at line 369 of file nsIView.h.

float nsIView::mOpacity [protected, inherited]

Definition at line 376 of file nsIView.h.

nsView* nsIView::mParent [protected, inherited]

Definition at line 367 of file nsIView.h.

nscoord nsIView::mPosX [protected, inherited]

Definition at line 374 of file nsIView.h.

nscoord nsIView::mPosY [protected, inherited]

Definition at line 374 of file nsIView.h.

PRUint32 nsIView::mVFlags [protected, inherited]

Definition at line 377 of file nsIView.h.

nsViewManager* nsIView::mViewManager [protected, inherited]

Definition at line 366 of file nsIView.h.

nsViewVisibility nsIView::mVis [protected, inherited]

Definition at line 373 of file nsIView.h.

nsIWidget* nsIView::mWindow [protected, inherited]

Definition at line 368 of file nsIView.h.

PRInt32 nsIView::mZIndex [protected, inherited]

Definition at line 372 of file nsIView.h.


The documentation for this class was generated from the following files: