Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
nsNativeThemeGTK Class Reference

#include <nsNativeThemeGTK.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER NS_IMETHOD 
DrawWidgetBackground (nsIRenderingContext *aContext, nsIFrame *aFrame, PRUint8 aWidgetType, const nsRect &aRect, const nsRect &aClipRect)
NS_IMETHOD GetWidgetBorder (nsIDeviceContext *aContext, nsIFrame *aFrame, PRUint8 aWidgetType, nsMargin *aResult)
virtual NS_HIDDEN_ (PRBool) GetWidgetPadding(nsIDeviceContext *aContext
virtual NS_HIDDEN_ (PRBool) GetWidgetOverflow(nsIDeviceContext *aContext
NS_IMETHOD GetMinimumWidgetSize (nsIRenderingContext *aContext, nsIFrame *aFrame, PRUint8 aWidgetType, nsSize *aResult, PRBool *aIsOverridable)
NS_IMETHOD WidgetStateChanged (nsIFrame *aFrame, PRUint8 aWidgetType, nsIAtom *aAttribute, PRBool *aShouldRepaint)
NS_IMETHOD ThemeChanged ()
 NS_IMETHOD_ (PRBool) ThemeSupportsWidget(nsPresContext *aPresContext
 NS_IMETHOD_ (PRBool) WidgetIsContainer(PRUint8 aWidgetType)
 nsNativeThemeGTK ()
virtual ~nsNativeThemeGTK ()
virtual PRBool GetWidgetPadding (nsIDeviceContext *aContext, nsIFrame *aFrame, PRUint8 aWidgetType, nsMargin *aResult)=0
virtual PRBool GetWidgetOverflow (nsIDeviceContext *aContext, nsIFrame *aFrame, PRUint8 aWidgetType, nsRect *aResult)
virtual PRBool ThemeSupportsWidget (nsPresContext *aPresContext, nsIFrame *aFrame, PRUint8 aWidgetType)=0
virtual PRBool WidgetIsContainer (PRUint8 aWidgetType)=0
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

virtual nsIFrameaFrame
virtual nsIFrame PRUint8 aWidgetType
virtual nsIFrame PRUint8 nsMarginaResult
virtual nsIFrame PRUint8 nsRectaResult
nsIFrameaFrame
nsIFrame PRUint8 aWidgetType

Private Types

enum  TreeSortDirection { eTreeSortDirection_Descending, eTreeSortDirection_Natural, eTreeSortDirection_Ascending }

Private Member Functions

PRBool GetGtkWidgetAndState (PRUint8 aWidgetType, nsIFrame *aFrame, GtkThemeWidgetType &aGtkWidgetType, GtkWidgetState *aState, gint *aWidgetFlags)
void RefreshWidgetWindow (nsIFrame *aFrame)
PRInt32 GetContentState (nsIFrame *aFrame, PRUint8 aWidgetType)
PRBool IsWidgetStyled (nsPresContext *aPresContext, nsIFrame *aFrame, PRUint8 aWidgetType)
PRBool IsDisabled (nsIFrame *aFrame)
PRBool IsDefaultButton (nsIFrame *aFrame)
PRBool IsChecked (nsIFrame *aFrame)
PRBool IsSelected (nsIFrame *aFrame)
PRBool IsFocused (nsIFrame *aFrame)
PRBool IsSelectedTab (nsIFrame *aFrame)
PRBool IsCheckedButton (nsIFrame *aFrame)
TreeSortDirection GetTreeSortDirection (nsIFrame *aFrame)
PRBool IsBottomTab (nsIFrame *aFrame)
PRBool IsIndeterminateProgress (nsIFrame *aFrame)
PRInt32 GetProgressValue (nsIFrame *aFrame)
PRBool IsReadOnly (nsIFrame *aFrame)
nsIPresShellGetPresShell (nsIFrame *aFrame)
PRInt32 CheckIntAttr (nsIFrame *aFrame, nsIAtom *aAtom)
PRBool CheckBooleanAttr (nsIFrame *aFrame, nsIAtom *aAtom)

Private Attributes

nsCOMPtr< nsIAtommTypeAtom
nsCOMPtr< nsIAtommInputCheckedAtom
nsCOMPtr< nsIAtommInputAtom
nsCOMPtr< nsIAtommCurPosAtom
nsCOMPtr< nsIAtommMaxPosAtom
nsCOMPtr< nsIAtommMenuActiveAtom
PRUint8 mDisabledWidgetTypes [32]
PRUint8 mSafeWidgetStates [1024]
nsCOMPtr< nsIAtommDisabledAtom
nsCOMPtr< nsIAtommCheckedAtom
nsCOMPtr< nsIAtommSelectedAtom
nsCOMPtr< nsIAtommReadOnlyAtom
nsCOMPtr< nsIAtommFirstTabAtom
nsCOMPtr< nsIAtommFocusedAtom
nsCOMPtr< nsIAtommSortDirectionAtom

Static Private Attributes

static const char * sDisabledEngines []
static nsMargin sButtonBorderSize
static nsMargin sButtonDisabledBorderSize
static PRUint8 sButtonActiveBorderStyle = NS_STYLE_BORDER_STYLE_INSET
static PRUint8 sButtonInactiveBorderStyle = NS_STYLE_BORDER_STYLE_OUTSET
static nsILookAndFeel::nsColorID sButtonBorderColorID = nsILookAndFeel::eColor_threedface
static nsILookAndFeel::nsColorID sButtonDisabledBorderColorID = nsILookAndFeel::eColor_threedshadow
static nsILookAndFeel::nsColorID sButtonBGColorID = nsILookAndFeel::eColor_threedface
static nsILookAndFeel::nsColorID sButtonDisabledBGColorID = nsILookAndFeel::eColor_threedface
static nsMargin sTextfieldBorderSize
static PRUint8 sTextfieldBorderStyle = NS_STYLE_BORDER_STYLE_INSET
static nsILookAndFeel::nsColorID sTextfieldBorderColorID = nsILookAndFeel::eColor_threedface
static PRBool sTextfieldBGTransparent = PR_FALSE
static nsILookAndFeel::nsColorID sTextfieldBGColorID = nsILookAndFeel::eColor__moz_field
static nsILookAndFeel::nsColorID sTextfieldDisabledBGColorID = nsILookAndFeel::eColor_threedface
static nsMargin sListboxBorderSize
static PRUint8 sListboxBorderStyle = NS_STYLE_BORDER_STYLE_INSET
static nsILookAndFeel::nsColorID sListboxBorderColorID = nsILookAndFeel::eColor_threedface
static PRBool sListboxBGTransparent = PR_FALSE
static nsILookAndFeel::nsColorID sListboxBGColorID = nsILookAndFeel::eColor__moz_field
static nsILookAndFeel::nsColorID sListboxDisabledBGColorID = nsILookAndFeel::eColor_threedface

Detailed Description

Definition at line 48 of file nsNativeThemeGTK.h.


Member Enumeration Documentation

enum nsNativeTheme::TreeSortDirection [protected, inherited]
Enumerator:
eTreeSortDirection_Descending 
eTreeSortDirection_Natural 
eTreeSortDirection_Ascending 

Definition at line 57 of file nsNativeTheme.h.


Constructor & Destructor Documentation

Definition at line 69 of file nsNativeThemeGTK.cpp.

{
  if (moz_gtk_init() != MOZ_GTK_SUCCESS) {
    memset(mDisabledWidgetTypes, 0xff, sizeof(mDisabledWidgetTypes));
    return;
  }

  // We have to call moz_gtk_shutdown before the event loop stops running.
  nsCOMPtr<nsIObserverService> obsServ =
    do_GetService("@mozilla.org/observer-service;1");
  obsServ->AddObserver(this, "xpcom-shutdown", PR_FALSE);

  mInputCheckedAtom = do_GetAtom("_moz-input-checked");
  mInputAtom = do_GetAtom("input");
  mCurPosAtom = do_GetAtom("curpos");
  mMaxPosAtom = do_GetAtom("maxpos");
  mMenuActiveAtom = do_GetAtom("_moz-menuactive");

  memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
  memset(mSafeWidgetStates, 0, sizeof(mSafeWidgetStates));

#ifdef MOZ_WIDGET_GTK
  // Look up the symbol for gtk_style_get_prop_experimental
  PRLibrary* gtkLibrary;
  PRFuncPtr stylePropFunc = PR_FindFunctionSymbolAndLibrary("gtk_style_get_prop_experimental", &gtkLibrary);
  if (stylePropFunc) {
    moz_gtk_enable_style_props((style_prop_t) stylePropFunc);
    PR_UnloadLibrary(gtkLibrary);
  }
#endif
}

Here is the call graph for this function:

Definition at line 101 of file nsNativeThemeGTK.cpp.

                                    {
}

Member Function Documentation

PRBool nsNativeTheme::CheckBooleanAttr ( nsIFrame aFrame,
nsIAtom aAtom 
) [protected, inherited]

Definition at line 129 of file nsNativeTheme.cpp.

{
  if (!aFrame)
    return PR_FALSE;

  nsIContent* content = aFrame->GetContent();
  if (content->IsContentOfType(nsIContent::eHTML))
    return content->HasAttr(kNameSpaceID_None, aAtom);

  nsAutoString attr;
  content->GetAttr(kNameSpaceID_None, aAtom, attr);

  // For XML/XUL elements, an attribute must be equal to the literal
  // string "true" to be counted as true.  An empty string should _not_
  // be counted as true.

  return attr.EqualsLiteral("true");
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsNativeTheme::CheckIntAttr ( nsIFrame aFrame,
nsIAtom aAtom 
) [protected, inherited]

Definition at line 149 of file nsNativeTheme.cpp.

{
  if (!aFrame)
    return 0;

  nsAutoString attr;
  aFrame->GetContent()->GetAttr(kNameSpaceID_None, aAtom, attr);
  PRInt32 err, value = attr.ToInteger(&err);
  if (NS_FAILED(err))
    return 0;

  return value;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsNativeThemeGTK::DrawWidgetBackground ( nsIRenderingContext aContext,
nsIFrame aFrame,
PRUint8  aWidgetType,
const nsRect aRect,
const nsRect aClipRect 
) [virtual]

Implements nsITheme.

Definition at line 423 of file nsNativeThemeGTK.cpp.

{
  GtkWidgetState state;
  GtkThemeWidgetType gtkWidgetType;
  gint flags;
  if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state,
                            &flags))
    return NS_OK;

  nsDrawingSurfaceGTK* surface;
  aContext->GetDrawingSurface((nsIDrawingSurface**)&surface);
  NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
  GdkWindow* window = (GdkWindow*) surface->GetDrawable();
  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);

  nsTransform2D* transformMatrix;
  aContext->GetCurrentTransform(transformMatrix);

  nsRect tr(aRect);
  transformMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
  GdkRectangle gdk_rect = {tr.x, tr.y, tr.width, tr.height};

  nsRect cr(aClipRect);
  transformMatrix->TransformCoord(&cr.x, &cr.y, &cr.width, &cr.height);
  GdkRectangle gdk_clip = {cr.x, cr.y, cr.width, cr.height};

  NS_ASSERTION(!IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType),
               "Trying to render an unsafe widget!");

  PRBool safeState = IsWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
  XErrorHandler oldHandler = nsnull;
  if (!safeState) {
    gLastXError = 0;
    oldHandler = XSetErrorHandler(NativeThemeErrorHandler);
  }

  moz_gtk_widget_paint(gtkWidgetType, window, &gdk_rect, &gdk_clip, &state,
                       flags);

  if (!safeState) {
    gdk_flush();
    XSetErrorHandler(oldHandler);

    if (gLastXError) {
#ifdef DEBUG
      printf("GTK theme failed for widget type %d, error was %d, state was "
             "[active=%d,focused=%d,inHover=%d,disabled=%d]\n",
             aWidgetType, gLastXError, state.active, state.focused,
             state.inHover, state.disabled);
#endif
      NS_WARNING("GTK theme failed; disabling unsafe widget");
      SetWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType);
      // force refresh of the window, because the widget was not
      // successfully drawn it must be redrawn using the default look
      RefreshWidgetWindow(aFrame);
    } else {
      SetWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

PRInt32 nsNativeTheme::GetContentState ( nsIFrame aFrame,
PRUint8  aWidgetType 
) [protected, inherited]

Definition at line 102 of file nsNativeTheme.cpp.

{
  if (!aFrame)
    return 0;

  PRBool isXULCheckboxRadio = 
    (aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_RADIO) &&
    aFrame->GetContent()->IsContentOfType(nsIContent::eXUL);
  if (isXULCheckboxRadio)
    aFrame = aFrame->GetParent();

  nsIPresShell *shell = GetPresShell(aFrame);
  if (!shell)
    return 0;

  PRInt32 flags = 0;
  shell->GetPresContext()->EventStateManager()->GetContentState(aFrame->GetContent(), flags);
  
  if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) {
    if (IsFocused(aFrame))
      flags |= NS_EVENT_STATE_FOCUS;
  }
  
  return flags;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeThemeGTK::GetGtkWidgetAndState ( PRUint8  aWidgetType,
nsIFrame aFrame,
GtkThemeWidgetType aGtkWidgetType,
GtkWidgetState aState,
gint *  aWidgetFlags 
) [private]

Definition at line 168 of file nsNativeThemeGTK.cpp.

{
  if (aState) {
    if (!aFrame) {
      // reset the entire struct to zero
      memset(aState, 0, sizeof(GtkWidgetState));
    } else {

      // for dropdown textfields, look at the parent frame (textbox or menulist)
      if (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD)
        aFrame = aFrame->GetParent();

      // For XUL checkboxes and radio buttons, the state of the parent
      // determines our state.
      nsIFrame *stateFrame = aFrame;
      if (aFrame && ((aWidgetFlags && (aWidgetType == NS_THEME_CHECKBOX ||
                                       aWidgetType == NS_THEME_RADIO)) ||
                     aWidgetType == NS_THEME_CHECKBOX_LABEL ||
                     aWidgetType == NS_THEME_RADIO_LABEL)) {

        nsIAtom* atom = nsnull;
        nsIContent *content = aFrame->GetContent();
        if (content->IsContentOfType(nsIContent::eXUL)) {
          if (aWidgetType == NS_THEME_CHECKBOX_LABEL ||
              aWidgetType == NS_THEME_RADIO_LABEL) {
            // Adjust stateFrame so GetContentState finds the correct state.
            stateFrame = aFrame = aFrame->GetParent()->GetParent();
          } else {
            // GetContentState knows to look one frame up for radio/checkbox
            // widgets, so don't adjust stateFrame here.
            aFrame = aFrame->GetParent();
          }
        } else if (content->Tag() == mInputAtom) {
          atom = mInputCheckedAtom;
        }

        if (aWidgetFlags) {
          if (!atom) {
            atom = (aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_CHECKBOX_LABEL) ? mCheckedAtom : mSelectedAtom;
          }
          *aWidgetFlags = CheckBooleanAttr(aFrame, atom);
        }
      }

      PRInt32 eventState = GetContentState(stateFrame, aWidgetType);

      aState->disabled = IsDisabled(aFrame);
      aState->active  = (eventState & NS_EVENT_STATE_ACTIVE) == NS_EVENT_STATE_ACTIVE;
      aState->focused = (eventState & NS_EVENT_STATE_FOCUS) == NS_EVENT_STATE_FOCUS;
      aState->inHover = (eventState & NS_EVENT_STATE_HOVER) == NS_EVENT_STATE_HOVER;
      aState->isDefault = FALSE; // XXX fix me
      aState->canDefault = FALSE; // XXX fix me

      // For these widget types, some element (either a child or parent)
      // actually has element focus, so we check the focused attribute
      // to see whether to draw in the focused state.
      if (aWidgetType == NS_THEME_TEXTFIELD ||
          aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
          aWidgetType == NS_THEME_RADIO_CONTAINER ||
          aWidgetType == NS_THEME_RADIO_LABEL ||
          aWidgetType == NS_THEME_RADIO) {
        aState->focused = IsFocused(aFrame);
      }

      if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
          aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
        // for scrollbars we need to go up two to go from the thumb to
        // the slider to the actual scrollbar object
        nsIFrame *tmpFrame = aFrame->GetParent()->GetParent();

        aState->curpos = CheckIntAttr(tmpFrame, mCurPosAtom);
        aState->maxpos = CheckIntAttr(tmpFrame, mMaxPosAtom);
      }

      // menu item state is determined by the attribute "_moz-menuactive",
      // and not by the mouse hovering (accessibility).  as a special case,
      // menus which are children of a menu bar are only marked as prelight
      // if they are open, not on normal hover.

      if (aWidgetType == NS_THEME_MENUITEM ||
          aWidgetType == NS_THEME_CHECKMENUITEM ||
          aWidgetType == NS_THEME_RADIOMENUITEM) {
        PRBool isTopLevel = PR_FALSE;
        nsIMenuFrame *menuFrame;
        CallQueryInterface(aFrame, &menuFrame);

        if (menuFrame) {
          nsIMenuParent *menuParent = menuFrame->GetMenuParent();
          if (menuParent)
            menuParent->IsMenuBar(isTopLevel);
        }

        if (isTopLevel) {
          PRBool isOpen;
          menuFrame->MenuIsOpen(isOpen);
          aState->inHover = isOpen;
        } else {
          aState->inHover = CheckBooleanAttr(aFrame, mMenuActiveAtom);
        }

        aState->active = FALSE;
        
        if (aWidgetType == NS_THEME_CHECKMENUITEM ||
            aWidgetType == NS_THEME_RADIOMENUITEM) {
          if (aFrame) {
            nsAutoString attr;
            nsresult res = aFrame->GetContent()->GetAttr(kNameSpaceID_None, mCheckedAtom, attr);
            if (res == NS_CONTENT_ATTR_NO_VALUE ||
               (res != NS_CONTENT_ATTR_NOT_THERE && attr.IsEmpty()))
              *aWidgetFlags = FALSE;
            else
              *aWidgetFlags = attr.EqualsIgnoreCase("true");
          } else {
            *aWidgetFlags = FALSE;
          }
        }
      }
    }
  }

  switch (aWidgetType) {
  case NS_THEME_BUTTON:
  case NS_THEME_TOOLBAR_BUTTON:
  case NS_THEME_TOOLBAR_DUAL_BUTTON:
    if (aWidgetFlags)
      *aWidgetFlags = (aWidgetType == NS_THEME_BUTTON) ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE;
    aGtkWidgetType = MOZ_GTK_BUTTON;
    break;
  case NS_THEME_CHECKBOX:
  case NS_THEME_RADIO:
    aGtkWidgetType = (aWidgetType == NS_THEME_RADIO) ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON;
    break;
  case NS_THEME_SCROLLBAR_BUTTON_UP:
  case NS_THEME_SCROLLBAR_BUTTON_DOWN:
  case NS_THEME_SCROLLBAR_BUTTON_LEFT:
  case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
    if (aWidgetFlags)
      *aWidgetFlags = GtkArrowType(aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP);
    aGtkWidgetType = MOZ_GTK_SCROLLBAR_BUTTON;
    break;
  case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
    aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_VERTICAL;
    break;
  case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
    aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL;
    break;
  case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
    aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL;
    break;
  case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
    aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
    break;
  case NS_THEME_TOOLBAR_GRIPPER:
    aGtkWidgetType = MOZ_GTK_GRIPPER;
    break;
  case NS_THEME_TEXTFIELD:
  case NS_THEME_DROPDOWN_TEXTFIELD:
    aGtkWidgetType = MOZ_GTK_ENTRY;
    break;
  case NS_THEME_DROPDOWN:
    aGtkWidgetType = MOZ_GTK_DROPDOWN;
    break;
  case NS_THEME_DROPDOWN_TEXT:
    return PR_FALSE; // nothing to do, but prevents the bg from being drawn
  case NS_THEME_DROPDOWN_BUTTON:
    aGtkWidgetType = MOZ_GTK_DROPDOWN_ARROW;
    break;
  case NS_THEME_CHECKBOX_CONTAINER:
    aGtkWidgetType = MOZ_GTK_CHECKBUTTON_CONTAINER;
    break;
  case NS_THEME_RADIO_CONTAINER:
    aGtkWidgetType = MOZ_GTK_RADIOBUTTON_CONTAINER;
    break;
  case NS_THEME_CHECKBOX_LABEL:
    aGtkWidgetType = MOZ_GTK_CHECKBUTTON_LABEL;
    break;
  case NS_THEME_RADIO_LABEL:
    aGtkWidgetType = MOZ_GTK_RADIOBUTTON_LABEL;
    break;
  case NS_THEME_TOOLBAR:
    aGtkWidgetType = MOZ_GTK_TOOLBAR;
    break;
  case NS_THEME_TOOLTIP:
    aGtkWidgetType = MOZ_GTK_TOOLTIP;
    break;
  case NS_THEME_STATUSBAR_PANEL:
    aGtkWidgetType = MOZ_GTK_FRAME;
    break;
  case NS_THEME_PROGRESSBAR:
  case NS_THEME_PROGRESSBAR_VERTICAL:
    aGtkWidgetType = MOZ_GTK_PROGRESSBAR;
    break;
  case NS_THEME_PROGRESSBAR_CHUNK:
  case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
    aGtkWidgetType = MOZ_GTK_PROGRESS_CHUNK;
    break;
  case NS_THEME_TAB_PANELS:
    aGtkWidgetType = MOZ_GTK_TABPANELS;
    break;
  case NS_THEME_TAB:
  case NS_THEME_TAB_LEFT_EDGE:
  case NS_THEME_TAB_RIGHT_EDGE:
    {
      if (aWidgetFlags) {
        *aWidgetFlags = 0;

        if (aWidgetType == NS_THEME_TAB &&
            CheckBooleanAttr(aFrame, mSelectedAtom))
          *aWidgetFlags |= MOZ_GTK_TAB_SELECTED;
        else if (aWidgetType == NS_THEME_TAB_LEFT_EDGE)
          *aWidgetFlags |= MOZ_GTK_TAB_BEFORE_SELECTED;

        if (aFrame->GetContent()->HasAttr(kNameSpaceID_None, mFirstTabAtom))
          *aWidgetFlags |= MOZ_GTK_TAB_FIRST;
      }

      aGtkWidgetType = MOZ_GTK_TAB;
    }
    break;
  case NS_THEME_MENUBAR:
    aGtkWidgetType = MOZ_GTK_MENUBAR;
    break;
  case NS_THEME_MENUPOPUP:
    aGtkWidgetType = MOZ_GTK_MENUPOPUP;
    break;
  case NS_THEME_MENUITEM:
    aGtkWidgetType = MOZ_GTK_MENUITEM;
    break;
  case NS_THEME_CHECKMENUITEM:
    aGtkWidgetType = MOZ_GTK_CHECKMENUITEM;
    break;
  case NS_THEME_RADIOMENUITEM:
    aGtkWidgetType = MOZ_GTK_RADIOMENUITEM;
    break;
  case NS_THEME_WINDOW:
  case NS_THEME_DIALOG:
    aGtkWidgetType = MOZ_GTK_WINDOW;
    break;
  default:
    return PR_FALSE;
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsNativeThemeGTK::GetMinimumWidgetSize ( nsIRenderingContext aContext,
nsIFrame aFrame,
PRUint8  aWidgetType,
nsSize aResult,
PRBool aIsOverridable 
) [virtual]

Implements nsITheme.

Definition at line 580 of file nsNativeThemeGTK.cpp.

{
  aResult->width = aResult->height = 0;
  *aIsOverridable = PR_TRUE;

  switch (aWidgetType) {
    case NS_THEME_SCROLLBAR_BUTTON_UP:
    case NS_THEME_SCROLLBAR_BUTTON_DOWN:
      {
        MozGtkScrollbarMetrics metrics;
        moz_gtk_get_scrollbar_metrics(&metrics);

        aResult->width = metrics.slider_width;
        aResult->height = metrics.stepper_size;
        *aIsOverridable = PR_FALSE;
      }
      break;
    case NS_THEME_SCROLLBAR_BUTTON_LEFT:
    case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
      {
        MozGtkScrollbarMetrics metrics;
        moz_gtk_get_scrollbar_metrics(&metrics);

        aResult->width = metrics.stepper_size;
        aResult->height = metrics.slider_width;
        *aIsOverridable = PR_FALSE;
      }
      break;
    case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
    case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
      {
        MozGtkScrollbarMetrics metrics;
        moz_gtk_get_scrollbar_metrics(&metrics);

        if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL) {
          aResult->width = metrics.slider_width;
          aResult->height = metrics.min_slider_size;
        } else {
          aResult->width = metrics.min_slider_size;
          aResult->height = metrics.slider_width;
        }

        *aIsOverridable = PR_FALSE;
      }
      break;
  case NS_THEME_DROPDOWN_BUTTON:
    {
      moz_gtk_get_dropdown_arrow_size(&aResult->width, &aResult->height);
      *aIsOverridable = PR_FALSE;
    }
    break;
  case NS_THEME_CHECKBOX:
  case NS_THEME_RADIO:
    {
      gint indicator_size, indicator_spacing;

      if (aWidgetType == NS_THEME_CHECKBOX) {
        moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
      } else {
        moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
      }

      // Include space for the indicator and the padding around it.
      aResult->width = indicator_size + 3 * indicator_spacing;
      aResult->height = indicator_size + 2 * indicator_spacing;
      *aIsOverridable = PR_FALSE;
    }
    break;

  case NS_THEME_CHECKBOX_CONTAINER:
  case NS_THEME_RADIO_CONTAINER:
  case NS_THEME_CHECKBOX_LABEL:
  case NS_THEME_RADIO_LABEL:
  case NS_THEME_BUTTON:
  case NS_THEME_TOOLBAR_BUTTON:
    {
      // Just include our border, and let the box code augment the size.

      nsCOMPtr<nsIDeviceContext> dc;
      aContext->GetDeviceContext(*getter_AddRefs(dc));

      nsMargin border;
      nsNativeThemeGTK::GetWidgetBorder(dc, aFrame, aWidgetType, &border);
      aResult->width = border.left + border.right;
      aResult->height = border.top + border.bottom;
    }
    break;
  }

  return NS_OK;
}

Here is the call graph for this function:

nsIPresShell * nsNativeTheme::GetPresShell ( nsIFrame aFrame) [protected, inherited]

Definition at line 90 of file nsNativeTheme.cpp.

{
  if (!aFrame)
    return nsnull;

  // this is a workaround for the egcs 1.1.2 not inliningg
  // aFrame->GetPresContext(), which causes an undefined symbol
  nsPresContext *context = aFrame->GetStyleContext()->GetRuleNode()->GetPresContext();
  return context ? context->GetPresShell() : nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsNativeTheme::GetProgressValue ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 139 of file nsNativeTheme.h.

                                             {
    return CheckIntAttr(aFrame, mValueAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

TreeSortDirection nsNativeTheme::GetTreeSortDirection ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 111 of file nsNativeTheme.h.

                                                           {
    nsAutoString sortdir;
    if (GetAttr(aFrame, mSortDirectionAtom, sortdir)) {
      if (sortdir.EqualsLiteral("descending"))
        return eTreeSortDirection_Descending;
      else if (sortdir.EqualsLiteral("ascending"))
        return eTreeSortDirection_Ascending;
    }

    return eTreeSortDirection_Natural;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsNativeThemeGTK::GetWidgetBorder ( nsIDeviceContext aContext,
nsIFrame aFrame,
PRUint8  aWidgetType,
nsMargin aResult 
) [virtual]

Implements nsITheme.

Definition at line 491 of file nsNativeThemeGTK.cpp.

{
  aResult->top = aResult->left = 0;
  switch (aWidgetType) {
  case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
  case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
    {
      MozGtkScrollbarMetrics metrics;
      moz_gtk_get_scrollbar_metrics(&metrics);
      aResult->top = aResult->left = metrics.trough_border;
    }
    break;
  case NS_THEME_TOOLBOX:
    // gtk has no toolbox equivalent.  So, although we map toolbox to
    // gtk's 'toolbar' for purposes of painting the widget background,
    // we don't use the toolbar border for toolbox.
    break;
  case NS_THEME_TOOLBAR_DUAL_BUTTON:
    // TOOLBAR_DUAL_BUTTON is an interesting case.  We want a border to draw
    // around the entire button + dropdown, and also an inner border if you're
    // over the button part.  But, we want the inner button to be right up
    // against the edge of the outer button so that the borders overlap.
    // To make this happen, we draw a button border for the outer button,
    // but don't reserve any space for it.
    break;
  default:
    {
      GtkThemeWidgetType gtkWidgetType;
      if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nsnull,
                               nsnull))
        moz_gtk_get_widget_border(gtkWidgetType, &aResult->left,
                                  &aResult->top);
    }
  }

  aResult->right = aResult->left;
  aResult->bottom = aResult->top;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual PRBool nsITheme::GetWidgetOverflow ( nsIDeviceContext aContext,
nsIFrame aFrame,
PRUint8  aWidgetType,
nsRect aResult 
) [inline, virtual, inherited]

Definition at line 92 of file nsITheme.h.

  { return PR_FALSE; }
virtual PRBool nsITheme::GetWidgetPadding ( nsIDeviceContext aContext,
nsIFrame aFrame,
PRUint8  aWidgetType,
nsMargin aResult 
) [pure virtual, inherited]

Implemented in nsNativeThemeMac, and nsNativeThemeWin.

Here is the caller graph for this function:

PRBool nsNativeTheme::IsBottomTab ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 124 of file nsNativeTheme.h.

                                       {
    nsAutoString classStr;
    if (GetAttr(aFrame, mClassAtom, classStr))
      return classStr.Find("tab-bottom") != kNotFound;
    return PR_FALSE;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsChecked ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 87 of file nsNativeTheme.h.

                                     {
    return GetCheckedOrSelected(aFrame, PR_FALSE);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsCheckedButton ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 106 of file nsNativeTheme.h.

                                           {
    return CheckBooleanAttr(aFrame, mCheckedAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsDefaultButton ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 82 of file nsNativeTheme.h.

                                           {
    return CheckBooleanAttr(aFrame, mDefaultAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsDisabled ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 77 of file nsNativeTheme.h.

                                      {
    return CheckBooleanAttr(aFrame, mDisabledAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsFocused ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 96 of file nsNativeTheme.h.

                                     {
    return CheckBooleanAttr(aFrame, mFocusedAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsIndeterminateProgress ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 132 of file nsNativeTheme.h.

                                                   {
    nsAutoString mode;
    if (GetAttr(aFrame, mModeAtom, mode))
      return mode.EqualsLiteral("undetermined");
    return PR_FALSE;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsReadOnly ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 144 of file nsNativeTheme.h.

                                      {
      return CheckBooleanAttr(aFrame, mReadOnlyAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsSelected ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 92 of file nsNativeTheme.h.

                                      {
    return GetCheckedOrSelected(aFrame, PR_TRUE);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsSelectedTab ( nsIFrame aFrame) [inline, protected, inherited]

Definition at line 101 of file nsNativeTheme.h.

                                         {
    return CheckBooleanAttr(aFrame, mSelectedAtom);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsNativeTheme::IsWidgetStyled ( nsPresContext aPresContext,
nsIFrame aFrame,
PRUint8  aWidgetType 
) [protected, inherited]

Definition at line 209 of file nsNativeTheme.cpp.

{
  // Check for specific widgets to see if HTML has overridden the style.
  if (aFrame && (aWidgetType == NS_THEME_BUTTON ||
                 aWidgetType == NS_THEME_TEXTFIELD ||
                 aWidgetType == NS_THEME_LISTBOX ||
                 aWidgetType == NS_THEME_DROPDOWN)) {

    if (aFrame->GetContent()->IsContentOfType(nsIContent::eHTML)) {
      nscolor defaultBGColor, defaultBorderColor;
      PRUint8 defaultBorderStyle;
      nsMargin defaultBorderSize;
      PRBool defaultBGTransparent = PR_FALSE;

      float p2t;
      p2t = aPresContext->PixelsToTwips();

      nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();

      switch (aWidgetType) {
      case NS_THEME_BUTTON:
        if (IsDisabled(aFrame)) {
          ConvertMarginToTwips(sButtonDisabledBorderSize, defaultBorderSize, p2t);
          defaultBorderStyle = sButtonInactiveBorderStyle;
          lookAndFeel->GetColor(sButtonDisabledBorderColorID,
                                defaultBorderColor);
          lookAndFeel->GetColor(sButtonDisabledBGColorID,
                                defaultBGColor);
        } else {
          PRInt32 contentState = GetContentState(aFrame, aWidgetType);
          ConvertMarginToTwips(sButtonBorderSize, defaultBorderSize, p2t);
          if (contentState & NS_EVENT_STATE_HOVER &&
              contentState & NS_EVENT_STATE_ACTIVE)
            defaultBorderStyle = sButtonActiveBorderStyle;
          else
            defaultBorderStyle = sButtonInactiveBorderStyle;
          lookAndFeel->GetColor(sButtonBorderColorID,
                                defaultBorderColor);
          lookAndFeel->GetColor(sButtonBGColorID,
                                defaultBGColor);
        }
        break;

      case NS_THEME_TEXTFIELD:
        defaultBorderStyle = sTextfieldBorderStyle;
        ConvertMarginToTwips(sTextfieldBorderSize, defaultBorderSize, p2t);
        lookAndFeel->GetColor(sTextfieldBorderColorID,
                              defaultBorderColor);
        if (!(defaultBGTransparent = sTextfieldBGTransparent)) {
          if (IsDisabled(aFrame))
            lookAndFeel->GetColor(sTextfieldDisabledBGColorID,
                                  defaultBGColor);
          else
            lookAndFeel->GetColor(sTextfieldBGColorID,
                                  defaultBGColor);
        }
        break;

      case NS_THEME_LISTBOX:
      case NS_THEME_DROPDOWN:
        defaultBorderStyle = sListboxBorderStyle;
        ConvertMarginToTwips(sListboxBorderSize, defaultBorderSize, p2t);
        lookAndFeel->GetColor(sListboxBorderColorID,
                              defaultBorderColor);
        if (!(defaultBGTransparent = sListboxBGTransparent)) {
          if (IsDisabled(aFrame))
            lookAndFeel->GetColor(sListboxDisabledBGColorID,
                                  defaultBGColor);
          else
            lookAndFeel->GetColor(sListboxBGColorID,
                                  defaultBGColor);
        }
        break;

      default:
        NS_ERROR("nsNativeTheme::IsWidgetStyled widget type not handled");
        return PR_FALSE;
      }

      // Check whether background differs from default
      const nsStyleBackground* ourBG = aFrame->GetStyleBackground();

      if (defaultBGTransparent) {
        if (!(ourBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT))
          return PR_TRUE;
      } else if (ourBG->mBackgroundColor != defaultBGColor ||
                 ourBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)
        return PR_TRUE;

      if (!(ourBG->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE))
        return PR_TRUE;

      // Check whether border style or color differs from default
      const nsStyleBorder* ourBorder = aFrame->GetStyleBorder();

      for (PRInt32 i = 0; i < 4; ++i) {
        if (ourBorder->GetBorderStyle(i) != defaultBorderStyle)
          return PR_TRUE;

        PRBool borderFG, borderClear;
        nscolor borderColor;
        ourBorder->GetBorderColor(i, borderColor, borderFG, borderClear);
        if (borderColor != defaultBorderColor || borderClear)
          return PR_TRUE;
      }

      // Check whether border size differs from default
      if (ourBorder->GetBorder() != defaultBorderSize)
        return PR_TRUE;
    }
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual nsNativeThemeGTK::NS_HIDDEN_ ( PRBool  ) [virtual]
virtual nsNativeThemeGTK::NS_HIDDEN_ ( PRBool  ) [virtual]
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Definition at line 119 of file nsNativeThemeGTK.cpp.

{
  nsIPresShell *shell = GetPresShell(aFrame);
  if (!shell)
    return;

  nsIViewManager* vm = shell->GetViewManager();
  if (!vm)
    return;
 
  vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsITheme.

Definition at line 718 of file nsNativeThemeGTK.cpp.

Here is the call graph for this function:

virtual PRBool nsITheme::ThemeSupportsWidget ( nsPresContext aPresContext,
nsIFrame aFrame,
PRUint8  aWidgetType 
) [pure virtual, inherited]

Implemented in nsNativeThemeWin, nsNativeThemeQt, and nsNativeThemeMac.

Here is the caller graph for this function:

virtual PRBool nsITheme::WidgetIsContainer ( PRUint8  aWidgetType) [pure virtual, inherited]

Implemented in nsNativeThemeWin, nsNativeThemeQt, and nsNativeThemeMac.

Here is the caller graph for this function:

NS_IMETHODIMP nsNativeThemeGTK::WidgetStateChanged ( nsIFrame aFrame,
PRUint8  aWidgetType,
nsIAtom aAttribute,
PRBool aShouldRepaint 
) [virtual]

Implements nsITheme.

Definition at line 675 of file nsNativeThemeGTK.cpp.

{
  // Some widget types just never change state.
  if (aWidgetType == NS_THEME_TOOLBOX ||
      aWidgetType == NS_THEME_TOOLBAR ||
      aWidgetType == NS_THEME_STATUSBAR ||
      aWidgetType == NS_THEME_STATUSBAR_PANEL ||
      aWidgetType == NS_THEME_STATUSBAR_RESIZER_PANEL ||
      aWidgetType == NS_THEME_PROGRESSBAR_CHUNK ||
      aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
      aWidgetType == NS_THEME_PROGRESSBAR ||
      aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
      aWidgetType == NS_THEME_MENUBAR ||
      aWidgetType == NS_THEME_MENUPOPUP ||
      aWidgetType == NS_THEME_TOOLTIP ||
      aWidgetType == NS_THEME_WINDOW ||
      aWidgetType == NS_THEME_DIALOG) {
    *aShouldRepaint = PR_FALSE;
    return NS_OK;
  }

  // XXXdwh Not sure what can really be done here.  Can at least guess for
  // specific widgets that they're highly unlikely to have certain states.
  // For example, a toolbar doesn't care about any states.
  if (!aAttribute) {
    // Hover/focus/active changed.  Always repaint.
    *aShouldRepaint = PR_TRUE;
  }
  else {
    // Check the attribute to see if it's relevant.  
    // disabled, checked, dlgtype, default, etc.
    *aShouldRepaint = PR_FALSE;
    if (aAttribute == mDisabledAtom || aAttribute == mCheckedAtom ||
        aAttribute == mSelectedAtom || aAttribute == mFocusedAtom ||
        aAttribute == mMenuActiveAtom)
      *aShouldRepaint = PR_TRUE;
  }

  return NS_OK;
}

Member Data Documentation

Definition at line 66 of file nsNativeThemeGTK.h.

Definition at line 85 of file nsNativeThemeGTK.h.

Definition at line 66 of file nsNativeThemeGTK.h.

Definition at line 71 of file nsNativeThemeGTK.h.

Definition at line 66 of file nsNativeThemeGTK.h.

Definition at line 85 of file nsNativeThemeGTK.h.

nsCOMPtr<nsIAtom> nsNativeTheme::mCheckedAtom [protected, inherited]

Definition at line 161 of file nsNativeTheme.h.

Definition at line 103 of file nsNativeThemeGTK.h.

Definition at line 160 of file nsNativeTheme.h.

Definition at line 107 of file nsNativeThemeGTK.h.

Definition at line 164 of file nsNativeTheme.h.

nsCOMPtr<nsIAtom> nsNativeTheme::mFocusedAtom [protected, inherited]

Definition at line 165 of file nsNativeTheme.h.

Definition at line 102 of file nsNativeThemeGTK.h.

Definition at line 101 of file nsNativeThemeGTK.h.

Definition at line 104 of file nsNativeThemeGTK.h.

Definition at line 105 of file nsNativeThemeGTK.h.

Definition at line 163 of file nsNativeTheme.h.

Definition at line 108 of file nsNativeThemeGTK.h.

Definition at line 162 of file nsNativeTheme.h.

Definition at line 166 of file nsNativeTheme.h.

Definition at line 100 of file nsNativeThemeGTK.h.

Definition at line 172 of file nsNativeTheme.h.

Definition at line 176 of file nsNativeTheme.h.

Definition at line 174 of file nsNativeTheme.h.

nsMargin nsNativeTheme::sButtonBorderSize [static, protected, inherited]

Definition at line 170 of file nsNativeTheme.h.

Definition at line 177 of file nsNativeTheme.h.

Definition at line 175 of file nsNativeTheme.h.

nsMargin nsNativeTheme::sButtonDisabledBorderSize [static, protected, inherited]

Definition at line 171 of file nsNativeTheme.h.

Definition at line 173 of file nsNativeTheme.h.

const char* nsNativeThemeGTK::sDisabledEngines[] [static, private]

Definition at line 109 of file nsNativeThemeGTK.h.

Definition at line 188 of file nsNativeTheme.h.

PRBool nsNativeTheme::sListboxBGTransparent = PR_FALSE [static, protected, inherited]

Definition at line 187 of file nsNativeTheme.h.

Definition at line 186 of file nsNativeTheme.h.

nsMargin nsNativeTheme::sListboxBorderSize [static, protected, inherited]

Definition at line 184 of file nsNativeTheme.h.

Definition at line 185 of file nsNativeTheme.h.

Definition at line 189 of file nsNativeTheme.h.

Definition at line 182 of file nsNativeTheme.h.

PRBool nsNativeTheme::sTextfieldBGTransparent = PR_FALSE [static, protected, inherited]

Definition at line 181 of file nsNativeTheme.h.

Definition at line 180 of file nsNativeTheme.h.

nsMargin nsNativeTheme::sTextfieldBorderSize [static, protected, inherited]

Definition at line 178 of file nsNativeTheme.h.

Definition at line 179 of file nsNativeTheme.h.

Definition at line 183 of file nsNativeTheme.h.


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