Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsButtonFrameRenderer Class Reference

#include <nsButtonFrameRenderer.h>

Collaboration diagram for nsButtonFrameRenderer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsButtonFrameRenderer ()
virtual ~nsButtonFrameRenderer ()
virtual void PaintButton (nsPresContext *aPresContext, nsIRenderingContext &aRenderingContext, const nsRect &aDirtyRect, const nsRect &aRect)
virtual void PaintOutlineAndFocusBorders (nsPresContext *aPresContext, nsIRenderingContext &aRenderingContext, const nsRect &aDirtyRect, const nsRect &aRect)
virtual void PaintBorderAndBackground (nsPresContext *aPresContext, nsIRenderingContext &aRenderingContext, const nsRect &aDirtyRect, const nsRect &aRect)
virtual void SetFrame (nsFrame *aFrame, nsPresContext *aPresContext)
virtual void SetDisabled (PRBool aDisabled, PRBool notify)
PRBool isActive ()
PRBool isDisabled ()
virtual void GetButtonOutlineRect (const nsRect &aRect, nsRect &aResult)
virtual void GetButtonOuterFocusRect (const nsRect &aRect, nsRect &aResult)
virtual void GetButtonRect (const nsRect &aRect, nsRect &aResult)
virtual void GetButtonInnerFocusRect (const nsRect &aRect, nsRect &aResult)
virtual void GetButtonContentRect (const nsRect &aRect, nsRect &aResult)
virtual nsMargin GetButtonOuterFocusBorderAndPadding ()
virtual nsMargin GetButtonBorderAndPadding ()
virtual nsMargin GetButtonInnerFocusMargin ()
 Gets the size of the buttons border this is the union of the normal and disabled borders.
virtual nsMargin GetButtonInnerFocusBorderAndPadding ()
virtual nsMargin GetButtonOutlineBorderAndPadding ()
virtual nsMargin GetFullButtonBorderAndPadding ()
virtual nsMargin GetAddedButtonBorderAndPadding ()
virtual nsStyleContextGetStyleContext (PRInt32 aIndex) const
virtual void SetStyleContext (PRInt32 aIndex, nsStyleContext *aStyleContext)
virtual void ReResolveStyles (nsPresContext *aPresContext)
 Call this when styles change.
virtual nsIFrameGetFrame ()

Private Attributes

nsRefPtr< nsStyleContextmBorderStyle
nsRefPtr< nsStyleContextmInnerFocusStyle
nsRefPtr< nsStyleContextmOuterFocusStyle
nsFramemFrame
nsRect mOutlineRect

Detailed Description

Definition at line 57 of file nsButtonFrameRenderer.h.


Constructor & Destructor Documentation


Member Function Documentation

Definition at line 291 of file nsButtonFrameRenderer.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 228 of file nsButtonFrameRenderer.cpp.

{
  nsStyleContext* context = mFrame->GetStyleContext();

  nsMargin innerFocusBorderAndPadding(0,0,0,0);
  nsStyleBorderPadding  bPad;
  context->GetBorderPaddingFor(bPad);
  if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
    NS_NOTYETIMPLEMENTED("percentage border");
  }
  return innerFocusBorderAndPadding;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::GetButtonContentRect ( const nsRect aRect,
nsRect aResult 
) [virtual]

Definition at line 204 of file nsButtonFrameRenderer.cpp.

Here is the call graph for this function:

Definition at line 259 of file nsButtonFrameRenderer.cpp.

{
  nsMargin innerFocusBorderAndPadding(0,0,0,0);

  if (mInnerFocusStyle) {
    // get the outer focus border and padding
    nsStyleBorderPadding  bPad;
    mInnerFocusStyle->GetBorderPaddingFor(bPad);
    if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
      NS_NOTYETIMPLEMENTED("percentage border");
    }
  }

  return innerFocusBorderAndPadding;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the size of the buttons border this is the union of the normal and disabled borders.

Definition at line 245 of file nsButtonFrameRenderer.cpp.

{
  nsMargin innerFocusMargin(0,0,0,0);

  if (mInnerFocusStyle) {
    // get the outer focus border and padding
    const nsStyleMargin* margin = mInnerFocusStyle->GetStyleMargin();
    margin->GetMargin(innerFocusMargin);
  }

  return innerFocusMargin;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::GetButtonInnerFocusRect ( const nsRect aRect,
nsRect aResult 
) [virtual]

Definition at line 196 of file nsButtonFrameRenderer.cpp.

{
  GetButtonRect(aRect, focusRect);
  focusRect.Deflate(GetButtonBorderAndPadding());
  focusRect.Deflate(GetButtonInnerFocusMargin());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 212 of file nsButtonFrameRenderer.cpp.

{
  nsMargin focusBorderAndPadding(0,0,0,0);

  if (mOuterFocusStyle) {
    nsStyleBorderPadding  bPad;
    mOuterFocusStyle->GetBorderPaddingFor(bPad);
    if (!bPad.GetBorderPadding(focusBorderAndPadding)) {
      NS_NOTYETIMPLEMENTED("percentage border");
    }
  }

  return focusBorderAndPadding;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::GetButtonOuterFocusRect ( const nsRect aRect,
nsRect aResult 
) [virtual]

Definition at line 182 of file nsButtonFrameRenderer.cpp.

{
  focusRect = aRect;
}

Here is the caller graph for this function:

Definition at line 276 of file nsButtonFrameRenderer.cpp.

{
  nsMargin borderAndPadding(0,0,0,0);
  return borderAndPadding;
}

Here is the caller graph for this function:

void nsButtonFrameRenderer::GetButtonOutlineRect ( const nsRect aRect,
nsRect aResult 
) [virtual]

Definition at line 174 of file nsButtonFrameRenderer.cpp.

{
  outlineRect = aRect;
  outlineRect.Inflate(GetButtonOutlineBorderAndPadding());
}

Here is the call graph for this function:

void nsButtonFrameRenderer::GetButtonRect ( const nsRect aRect,
nsRect aResult 
) [virtual]

Definition at line 188 of file nsButtonFrameRenderer.cpp.

{
  r = aRect;
  r.Deflate(GetButtonOuterFocusBorderAndPadding());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 72 of file nsButtonFrameRenderer.cpp.

{
  return mFrame;
}

Definition at line 284 of file nsButtonFrameRenderer.cpp.

Here is the call graph for this function:

Definition at line 318 of file nsButtonFrameRenderer.cpp.

Here is the caller graph for this function:

Definition at line 88 of file nsButtonFrameRenderer.cpp.

{
  // get the content
  nsAutoString value;
  if (NS_CONTENT_ATTR_HAS_VALUE ==
      mFrame->GetContent()->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, value))
    return PR_TRUE;

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::PaintBorderAndBackground ( nsPresContext aPresContext,
nsIRenderingContext aRenderingContext,
const nsRect aDirtyRect,
const nsRect aRect 
) [virtual]

Definition at line 150 of file nsButtonFrameRenderer.cpp.

{
  // get the button rect this is inside the focus and outline rects
  nsRect buttonRect;
  GetButtonRect(aRect, buttonRect);

  nsStyleContext* context = mFrame->GetStyleContext();

  const nsStyleBorder* border = context->GetStyleBorder();
  const nsStylePadding* padding = context->GetStylePadding();

  nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
                                  aDirtyRect, buttonRect, *border, *padding,
                                  PR_FALSE);
  nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
                              aDirtyRect, buttonRect, *border, context, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::PaintButton ( nsPresContext aPresContext,
nsIRenderingContext aRenderingContext,
const nsRect aDirtyRect,
const nsRect aRect 
) [virtual]

Definition at line 100 of file nsButtonFrameRenderer.cpp.

{
  //printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);

  // draw the border and background inside the focus and outline borders
  PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aRect);

  // draw the focus and outline borders
  PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aRect);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::PaintOutlineAndFocusBorders ( nsPresContext aPresContext,
nsIRenderingContext aRenderingContext,
const nsRect aDirtyRect,
const nsRect aRect 
) [virtual]

Definition at line 115 of file nsButtonFrameRenderer.cpp.

{
  // once we have all that let draw the focus if we have it. We will need to draw 2 focuses.
  // the inner and the outer. This is so we can do any kind of look and feel some buttons have
  // focus on the outside like mac and motif. While others like windows have it inside (dotted line).
  // Usually only one will be specifed. But I guess you could have both if you wanted to.

  nsRect rect;

  if (mOuterFocusStyle) {
    // ---------- paint the outer focus border -------------

    GetButtonOuterFocusRect(aRect, rect);

    const nsStyleBorder* border = mOuterFocusStyle->GetStyleBorder();
    nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
                                aDirtyRect, rect, *border, mOuterFocusStyle, 0);
  }

  if (mInnerFocusStyle) { 
    // ---------- paint the inner focus border -------------

    GetButtonInnerFocusRect(aRect, rect);

    const nsStyleBorder* border = mInnerFocusStyle->GetStyleBorder();
    nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
                                aDirtyRect, rect, *border, mInnerFocusStyle, 0);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Call this when styles change.

Definition at line 300 of file nsButtonFrameRenderer.cpp.

{
  // get all the styles
  nsStyleContext* context = mFrame->GetStyleContext();
  nsStyleSet *styleSet = aPresContext->StyleSet();

  // style for the inner such as a dotted line (Windows)
  mInnerFocusStyle = styleSet->ProbePseudoStyleFor(mFrame->GetContent(),
                                                   nsCSSPseudoElements::mozFocusInner,
                                                   context);

  // style for outer focus like a ridged border (MAC).
  mOuterFocusStyle = styleSet->ProbePseudoStyleFor(mFrame->GetContent(),
                                                   nsCSSPseudoElements::mozFocusOuter,
                                                   context);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::SetDisabled ( PRBool  aDisabled,
PRBool  notify 
) [virtual]

Definition at line 78 of file nsButtonFrameRenderer.cpp.

{
  if (aDisabled)
    mFrame->GetContent()->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, EmptyString(),
                                  notify);
  else
    mFrame->GetContent()->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, notify);
}

Here is the call graph for this function:

void nsButtonFrameRenderer::SetFrame ( nsFrame aFrame,
nsPresContext aPresContext 
) [virtual]

Definition at line 65 of file nsButtonFrameRenderer.cpp.

{
  mFrame = aFrame;
  ReResolveStyles(aPresContext);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsButtonFrameRenderer::SetStyleContext ( PRInt32  aIndex,
nsStyleContext aStyleContext 
) [virtual]

Definition at line 331 of file nsButtonFrameRenderer.cpp.

{
  switch (aIndex) {
  case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
    mInnerFocusStyle = aStyleContext;
    break;
  case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
    mOuterFocusStyle = aStyleContext;
    break;
  }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 112 of file nsButtonFrameRenderer.h.

Definition at line 116 of file nsButtonFrameRenderer.h.

Definition at line 113 of file nsButtonFrameRenderer.h.

Definition at line 114 of file nsButtonFrameRenderer.h.

Definition at line 118 of file nsButtonFrameRenderer.h.


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