Back to index

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

#include <nsTreeBoxObject.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSITREEBOXOBJECT 
nsTreeBoxObject ()
 ~nsTreeBoxObject ()
NS_IMETHOD SetPropertyAsSupports (const PRUnichar *aPropertyName, nsISupports *aValue)
nsITreeBoxObjectGetTreeBody ()
nsITreeBoxObjectGetCachedTreeBody ()
NS_IMETHOD Init (nsIContent *aContent, nsIPresShell *aPresShell)
NS_IMETHOD SetDocument (nsIDocument *aDocument)
NS_IMETHOD InvalidatePresentationStuff ()
virtual void ClearCachedTreeBody ()
 Clear the cached tree body frame from this box object.
long getFirstVisibleRow ()
 Get the index of the first visible row.
long getLastVisibleRow ()
 Get the index of the last visible row.
long getPageLength ()
 Gets the number of possible visible rows.
void ensureRowIsVisible (in long index)
 Ensures that a row at a given index is visible.
void scrollToRow (in long index)
 Scrolls such that the row at index is at the top of the visible view.
void scrollByLines (in long numLines)
 Scroll the tree up or down by numLines lines.
void scrollByPages (in long numPages)
 Scroll the tree up or down by numPages pages.
void invalidate ()
 Invalidation methods for fine-grained painting control.
void invalidateColumn (in nsITreeColumn col)
void invalidateRow (in long index)
void invalidateCell (in long row, in nsITreeColumn col)
void invalidateRange (in long startIndex, in long endIndex)
long getRowAt (in long x, in long y)
 A hit test that can tell you what row the mouse is over.
void getCellAt (in long x, in long y, out long row, out nsITreeColumn col, out ACString childElt)
 A hit test that can tell you what cell the mouse is over.
void getCoordsForCellItem (in long row, in nsITreeColumn col, in ACString element, out long x, out long y, out long width, out long height)
 Find the coordinates of an element within a specific cell.
boolean isCellCropped (in long row, in nsITreeColumn col)
 Determine if the text of a cell is being cropped or not.
void rowCountChanged (in long index, in long count)
 The view is responsible for calling these notification methods when rows are added or removed.
void beginUpdateBatch ()
 Notify the tree that the view is about to perform a batch update, that is, add, remove or invalidate several rows at once.
void endUpdateBatch ()
 Notify the tree that the view has completed a batch update.
void clearStyleAndImageCaches ()
 Called on a theme switch to flush out the tree's style and image caches.
virtual nsIFrameGetFrame ()
already_AddRefed< nsIPresShellGetPresShell ()
nsresult GetOffsetRect (nsRect &aRect)
nsresult GetScreenPosition (nsIntPoint &aPoint)
nsISupports getPropertyAsSupports (in wstring propertyName)
void setPropertyAsSupports (in wstring propertyName, in nsISupports value)
wstring getProperty (in wstring propertyName)
void setProperty (in wstring propertyName, in wstring propertyValue)
void removeProperty (in wstring propertyName)
wstring getLookAndFeelMetric (in wstring propertyName)

Static Public Member Functions

static nsresult GetPreviousSibling (nsIFrame *aParentFrame, nsIFrame *aFrame, nsIDOMElement **aResult)

Public Attributes

readonly attribute nsITreeColumns columns
 Obtain the columns.
attribute nsITreeView view
 The view that backs the tree and that supplies it with its data.
attribute boolean focused
 Whether or not we are currently focused.
readonly attribute nsIDOMElement treeBody
 Obtain the treebody content node.
readonly attribute long rowHeight
 Obtain the height of a row.
readonly attribute nsIDOMElement element
attribute nsIBoxLayoutManager layoutManager
attribute nsIBoxPaintManager paintManager
readonly attribute long x
readonly attribute long y
readonly attribute long screenX
readonly attribute long screenY
readonly attribute long width
readonly attribute long height
readonly attribute nsIDOMElement parentBox
readonly attribute nsIDOMElement firstChild
readonly attribute nsIDOMElement lastChild
readonly attribute nsIDOMElement nextSibling
readonly attribute nsIDOMElement previousSibling

Protected Member Functions

nsresult GetDocShell (nsIDocShell **aDocShell)

Protected Attributes

nsITreeBoxObjectmTreeBody
nsCOMPtr< nsIBoxLayoutManagermLayoutManager
nsCOMPtr< nsIBoxPaintManagermPaintManager
nsAutoPtr< nsPresStatemPresState
nsIContentmContent
nsWeakPtr mPresShell

Detailed Description

Definition at line 46 of file nsTreeBoxObject.h.


Constructor & Destructor Documentation

Definition at line 92 of file nsTreeBoxObject.cpp.

  : mTreeBody(nsnull)
{
}

Definition at line 97 of file nsTreeBoxObject.cpp.

{
  /* destructor code */
}

Member Function Documentation

Notify the tree that the view is about to perform a batch update, that is, add, remove or invalidate several rows at once.

This must be followed by calling endUpdateBatch(), otherwise the tree will get out of sync.

Clear the cached tree body frame from this box object.

This should be called when the frame in question is destroyed.

Implements nsPITreeBoxObject.

Definition at line 433 of file nsTreeBoxObject.cpp.

Here is the caller graph for this function:

Called on a theme switch to flush out the tree's style and image caches.

Notify the tree that the view has completed a batch update.

Ensures that a row at a given index is visible.

Definition at line 59 of file nsTreeBoxObject.h.

{ return mTreeBody; }
void nsITreeBoxObject::getCellAt ( in long  x,
in long  y,
out long  row,
out nsITreeColumn  col,
out ACString  childElt 
) [inherited]

A hit test that can tell you what cell the mouse is over.

Row is the row index hit, returns -1 for invalid mouse coordinates. ColID is the column hit. ChildElt is the pseudoelement hit: this can have values of "cell", "twisty", "image", and "text".

The coordinate system is the client coordinate system for the document this boxObject lives in, and the units are CSS pixels.

void nsITreeBoxObject::getCoordsForCellItem ( in long  row,
in nsITreeColumn  col,
in ACString  element,
out long  x,
out long  y,
out long  width,
out long  height 
) [inherited]

Find the coordinates of an element within a specific cell.

nsresult nsBoxObject::GetDocShell ( nsIDocShell **  aDocShell) [protected, inherited]

Definition at line 567 of file nsBoxObject.cpp.

{
  *aResult = nsnull;

  nsIFrame *frame = GetFrame();

  if (frame) {
    nsIFrameFrame *frame_frame = nsnull;
    CallQueryInterface(frame, &frame_frame);

    if (frame_frame) {
      // Ok, the frame for mContent is a nsIFrameFrame, it knows how
      // to reach the docshell, so ask it...

      return frame_frame->GetDocShell(aResult);
    }
  }

  // No nsIFrameFrame available for mContent, try if there's a mapping
  // between mContent's document to mContent's subdocument.

  if (!mContent) {
    return NS_OK;
  }

  // XXXbz sXBL/XBL2 issue -- ownerDocument or currentDocument?
  nsIDocument *doc = mContent->GetDocument();

  if (!doc) {
    return NS_OK;
  }
  
  nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent);

  if (!sub_doc) {
    return NS_OK;
  }

  nsCOMPtr<nsISupports> container = sub_doc->GetContainer();

  if (!container) {
    return NS_OK;
  }

  return CallQueryInterface(container, aResult);
}

Here is the call graph for this function:

Get the index of the first visible row.

nsIFrame * nsBoxObject::GetFrame ( ) [virtual, inherited]

Definition at line 165 of file nsBoxObject.cpp.

{
  nsIFrame* frame = nsnull;
  nsCOMPtr<nsIPresShell> shell = GetPresShell();
  if (shell) {
    shell->FlushPendingNotifications(Flush_Frames);
    shell->GetPrimaryFrameFor(mContent, &frame);
  }
  return frame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the index of the last visible row.

wstring nsIBoxObject::getLookAndFeelMetric ( in wstring  propertyName) [inherited]
nsresult nsBoxObject::GetOffsetRect ( nsRect aRect) [inherited]

Definition at line 189 of file nsBoxObject.cpp.

{
  aRect.x = aRect.y = 0;
  aRect.Empty();
 
  if (!mContent)
    return NS_ERROR_NOT_INITIALIZED;

  nsresult res = NS_OK;
  nsCOMPtr<nsIDocument> doc = mContent->GetDocument();

  if (doc) {
    // Flush all pending notifications so that our frames are uptodate.  Must
    // do this before we get the presshell, since this can destroy presshells.
    doc->FlushPendingNotifications(Flush_Layout);

    // Get Presentation shell 0
    nsIPresShell *presShell = doc->GetShellAt(0);

    if(presShell) {
      // Get the Frame for our content
      nsIFrame* frame = nsnull;
      presShell->GetPrimaryFrameFor(mContent, &frame);
      if(frame != nsnull) {
        // Get its origin
        nsPoint origin = frame->GetPosition();

        // Get the union of all rectangles in this and continuation frames
        nsRect rcFrame;
        nsIFrame* next = frame;
        do {
          rcFrame.UnionRect(rcFrame, next->GetRect());
          next = next->GetNextInFlow();
        } while (nsnull != next);
        

        // Find the frame parent whose content's tagName either matches 
        // the tagName passed in or is the document element.
        nsIContent *docElement = doc->GetRootContent();
        nsIFrame* parent = frame->GetParent();
        while (parent) {
          // If we've hit the document element, break here
          if (parent->GetContent() == docElement) {
            break;
          }

          // Add the parent's origin to our own to get to the
          // right coordinate system
          origin += parent->GetPosition();

          parent = parent->GetParent();
        }
  
        // For the origin, add in the border for the frame
        const nsStyleBorder* border = frame->GetStyleBorder();
        origin.x += border->GetBorderWidth(NS_SIDE_LEFT);
        origin.y += border->GetBorderWidth(NS_SIDE_TOP);

        // And subtract out the border for the parent
        if (parent) {
          const nsStyleBorder* parentBorder = parent->GetStyleBorder();
          origin.x -= parentBorder->GetBorderWidth(NS_SIDE_LEFT);
          origin.y -= parentBorder->GetBorderWidth(NS_SIDE_TOP);
        }

        // Get the Presentation Context from the Shell
        nsPresContext *context = presShell->GetPresContext();
        if (context) {
          // Get the scale from that Presentation Context
          float scale;
          scale = context->TwipsToPixels();
              
          // Convert to pixels using that scale
          aRect.x = NSTwipsToIntPixels(origin.x, scale);
          aRect.y = NSTwipsToIntPixels(origin.y, scale);
          aRect.width = NSTwipsToIntPixels(rcFrame.width, scale);
          aRect.height = NSTwipsToIntPixels(rcFrame.height, scale);
        }
      }
    }
  }
 
  return res;
}

Here is the call graph for this function:

Gets the number of possible visible rows.

Definition at line 177 of file nsBoxObject.cpp.

{
  if (!mPresShell) {
    return nsnull;
  }

  nsIPresShell* shell = nsnull;
  CallQueryReferent(mPresShell.get(), &shell);
  return shell;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsBoxObject::GetPreviousSibling ( nsIFrame aParentFrame,
nsIFrame aFrame,
nsIDOMElement **  aResult 
) [static, inherited]

Definition at line 536 of file nsBoxObject.cpp.

{
  *aPreviousOrdinalSibling = nsnull;
  nsIFrame* frame = GetFrame();
  if (!frame) return NS_OK;
  nsIFrame* parentFrame = frame->GetParent();
  if (!parentFrame) return NS_OK;
  return GetPreviousSibling(parentFrame, frame, aPreviousOrdinalSibling);
}

Here is the call graph for this function:

wstring nsIBoxObject::getProperty ( in wstring  propertyName) [inherited]
nsISupports nsIBoxObject::getPropertyAsSupports ( in wstring  propertyName) [inherited]
long nsITreeBoxObject::getRowAt ( in long  x,
in long  y 
) [inherited]

A hit test that can tell you what row the mouse is over.

returns -1 for invalid mouse coordinates.

The coordinate system is the client coordinate system for the document this boxObject lives in, and the units are CSS pixels.

Definition at line 275 of file nsBoxObject.cpp.

{
  aPoint.x = aPoint.y = 0;
  
  if (!mContent)
    return NS_ERROR_NOT_INITIALIZED;

  nsCOMPtr<nsIDocument> doc = mContent->GetDocument();

  if (doc) {
    // Get Presentation shell 0
    nsIPresShell *presShell = doc->GetShellAt(0);

    if (presShell) {
      // Flush all pending notifications so that our frames are uptodate
      doc->FlushPendingNotifications(Flush_Layout);

      nsPresContext *presContext = presShell->GetPresContext();
      if (presContext) {
        nsIFrame* frame;
        presShell->GetPrimaryFrameFor(mContent, &frame);
        
        if (frame) {
          nsIntRect rect = frame->GetScreenRect();
          aPoint.x = rect.x;
          aPoint.y = rect.y;
        }
      }
    }
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 135 of file nsTreeBoxObject.cpp.

{
  if (mTreeBody) {
    return mTreeBody;
  }

  nsIFrame* frame = GetFrame();
  if (!frame)
    return nsnull;

  // Iterate over our content model children looking for the body.
  nsCOMPtr<nsIContent> content;
  FindBodyElement(frame->GetContent(), getter_AddRefs(content));

  nsCOMPtr<nsIPresShell> shell = GetPresShell();
  if (!shell) {
    return nsnull;
  }

  shell->GetPrimaryFrameFor(content, &frame);
  if (!frame)
     return nsnull;

  // It's a frame. Refcounts are irrelevant.
  CallQueryInterface(frame, &mTreeBody);
  return mTreeBody;
}

Here is the call graph for this function:

NS_IMETHODIMP nsTreeBoxObject::Init ( nsIContent aContent,
nsIPresShell aPresShell 
) [virtual]

Reimplemented from nsBoxObject.

Definition at line 103 of file nsTreeBoxObject.cpp.

{
  nsresult rv = nsBoxObject::Init(aContent, aPresShell);
  if (NS_FAILED(rv)) return rv;
  return NS_OK;
}

Invalidation methods for fine-grained painting control.

void nsITreeBoxObject::invalidateCell ( in long  row,
in nsITreeColumn  col 
) [inherited]

Reimplemented from nsBoxObject.

Definition at line 84 of file nsTreeBoxObject.cpp.

Here is the call graph for this function:

void nsITreeBoxObject::invalidateRange ( in long  startIndex,
in long  endIndex 
) [inherited]
void nsITreeBoxObject::invalidateRow ( in long  index) [inherited]

Determine if the text of a cell is being cropped or not.

void nsIBoxObject::removeProperty ( in wstring  propertyName) [inherited]
void nsITreeBoxObject::rowCountChanged ( in long  index,
in long  count 
) [inherited]

The view is responsible for calling these notification methods when rows are added or removed.

Index is the position at which the new rows were added or at which rows were removed. For non-contiguous additions/removals, this method should be called multiple times.

void nsITreeBoxObject::scrollByLines ( in long  numLines) [inherited]

Scroll the tree up or down by numLines lines.

Positive values move down in the tree. Prevents scrolling off the end of the tree.

void nsITreeBoxObject::scrollByPages ( in long  numPages) [inherited]

Scroll the tree up or down by numPages pages.

A page is considered to be the amount displayed by the tree. Positive values move down in the tree. Prevents scrolling off the end of the tree.

void nsITreeBoxObject::scrollToRow ( in long  index) [inherited]

Scrolls such that the row at index is at the top of the visible view.

Reimplemented from nsBoxObject.

void nsIBoxObject::setProperty ( in wstring  propertyName,
in wstring  propertyValue 
) [inherited]
NS_IMETHODIMP nsTreeBoxObject::SetPropertyAsSupports ( const PRUnichar aPropertyName,
nsISupports *  aValue 
)

Definition at line 186 of file nsTreeBoxObject.cpp.

{
  NS_ENSURE_ARG(aPropertyName);
  
  if (nsDependentString(aPropertyName).EqualsLiteral("view") &&
      !CanTrustView(aValue))
    return NS_ERROR_DOM_SECURITY_ERR;

  return nsBoxObject::SetPropertyAsSupports(aPropertyName, aValue);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIBoxObject::setPropertyAsSupports ( in wstring  propertyName,
in nsISupports  value 
) [inherited]

Member Data Documentation

Obtain the columns.

Definition at line 55 of file nsITreeBoxObject.idl.

Definition at line 48 of file nsIBoxObject.idl.

Definition at line 68 of file nsIBoxObject.idl.

Whether or not we are currently focused.

Definition at line 67 of file nsITreeBoxObject.idl.

readonly attribute long nsIBoxObject::height [inherited]

Definition at line 58 of file nsIBoxObject.idl.

Definition at line 69 of file nsIBoxObject.idl.

Definition at line 50 of file nsIBoxObject.idl.

nsIContent* nsBoxObject::mContent [protected, inherited]

Definition at line 89 of file nsBoxObject.h.

Definition at line 85 of file nsBoxObject.h.

Definition at line 86 of file nsBoxObject.h.

nsWeakPtr nsBoxObject::mPresShell [protected, inherited]

Definition at line 90 of file nsBoxObject.h.

Definition at line 87 of file nsBoxObject.h.

Definition at line 70 of file nsTreeBoxObject.h.

Definition at line 70 of file nsIBoxObject.idl.

Definition at line 51 of file nsIBoxObject.idl.

Definition at line 67 of file nsIBoxObject.idl.

Definition at line 71 of file nsIBoxObject.idl.

Obtain the height of a row.

Definition at line 77 of file nsITreeBoxObject.idl.

readonly attribute long nsIBoxObject::screenX [inherited]

Definition at line 55 of file nsIBoxObject.idl.

readonly attribute long nsIBoxObject::screenY [inherited]

Definition at line 56 of file nsIBoxObject.idl.

Obtain the treebody content node.

Definition at line 72 of file nsITreeBoxObject.idl.

The view that backs the tree and that supplies it with its data.

It is dynamically settable, either using a view attribute on the tree tag or by setting this attribute to a new value.

Definition at line 62 of file nsITreeBoxObject.idl.

readonly attribute long nsIBoxObject::width [inherited]

Definition at line 57 of file nsIBoxObject.idl.

readonly attribute long nsIBoxObject::x [inherited]

Definition at line 53 of file nsIBoxObject.idl.

readonly attribute long nsIBoxObject::y [inherited]

Definition at line 54 of file nsIBoxObject.idl.


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