Back to index

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

#include <nsXPLookAndFeel.h>

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

List of all members.

Public Types

enum  nsColorID {
  eColor_WindowBackground, eColor_WindowForeground, eColor_WidgetBackground, eColor_WidgetForeground,
  eColor_WidgetSelectBackground, eColor_WidgetSelectForeground, eColor_Widget3DHighlight, eColor_Widget3DShadow,
  eColor_TextBackground, eColor_TextForeground, eColor_TextSelectBackground, eColor_TextSelectForeground,
  eColor_TextSelectBackgroundDisabled, eColor_TextSelectBackgroundAttention, eColor_activeborder, eColor_activecaption,
  eColor_appworkspace, eColor_background, eColor_buttonface, eColor_buttonhighlight,
  eColor_buttonshadow, eColor_buttontext, eColor_captiontext, eColor_graytext,
  eColor_highlight, eColor_highlighttext, eColor_inactiveborder, eColor_inactivecaption,
  eColor_inactivecaptiontext, eColor_infobackground, eColor_infotext, eColor_menu,
  eColor_menutext, eColor_scrollbar, eColor_threeddarkshadow, eColor_threedface,
  eColor_threedhighlight, eColor_threedlightshadow, eColor_threedshadow, eColor_window,
  eColor_windowframe, eColor_windowtext, eColor__moz_buttondefault, eColor__moz_field,
  eColor__moz_fieldtext, eColor__moz_dialog, eColor__moz_dialogtext, eColor__moz_dragtargetzone,
  eColor__moz_cellhighlight, eColor__moz_cellhighlighttext, eColor__moz_buttonhoverface, eColor__moz_buttonhovertext,
  eColor__moz_menuhover, eColor__moz_menuhovertext, eColor__moz_mac_focusring, eColor__moz_mac_menuselect,
  eColor__moz_mac_menushadow, eColor__moz_mac_menutextdisable, eColor__moz_mac_menutextselect, eColor__moz_mac_accentlightesthighlight,
  eColor__moz_mac_accentregularhighlight, eColor__moz_mac_accentface, eColor__moz_mac_accentlightshadow, eColor__moz_mac_accentregularshadow,
  eColor__moz_mac_accentdarkshadow, eColor__moz_mac_accentdarkestshadow, eColor__moz_mac_alternateprimaryhighlight, eColor__moz_mac_secondaryhighlight,
  eColor_LAST_COLOR
}
enum  nsMetricID {
  eMetric_WindowTitleHeight, eMetric_WindowBorderWidth, eMetric_WindowBorderHeight, eMetric_Widget3DBorder,
  eMetric_TextFieldBorder, eMetric_TextFieldHeight, eMetric_TextVerticalInsidePadding, eMetric_TextShouldUseVerticalInsidePadding,
  eMetric_TextHorizontalInsideMinimumPadding, eMetric_TextShouldUseHorizontalInsideMinimumPadding, eMetric_ButtonHorizontalInsidePaddingNavQuirks, eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks,
  eMetric_CheckboxSize, eMetric_RadioboxSize, eMetric_ListShouldUseHorizontalInsideMinimumPadding, eMetric_ListHorizontalInsideMinimumPadding,
  eMetric_ListShouldUseVerticalInsidePadding, eMetric_ListVerticalInsidePadding, eMetric_CaretBlinkTime, eMetric_CaretWidth,
  eMetric_ShowCaretDuringSelection, eMetric_SelectTextfieldsOnKeyFocus, eMetric_SubmenuDelay, eMetric_MenusCanOverlapOSBar,
  eMetric_SkipNavigatingDisabledMenuItem, eMetric_DragFullWindow, eMetric_DragThresholdX, eMetric_DragThresholdY,
  eMetric_UseAccessibilityTheme, eMetric_IsScreenReaderActive, eMetric_ScrollArrowStyle, eMetric_ScrollSliderStyle,
  eMetric_TreeOpenDelay, eMetric_TreeCloseDelay, eMetric_TreeLazyScrollDelay, eMetric_TreeScrollDelay,
  eMetric_TreeScrollLinesMax, eMetric_TabFocusModel, eMetric_AlertNotificationOrigin
}
enum  { eMetric_ScrollArrowStyleSingle, eMetric_ScrollArrowStyleBothAtBottom, eMetric_ScrollArrowStyleBothAtEachEnd, eMetric_ScrollArrowStyleBothAtTop }
enum  { eMetric_ScrollThumbStyleNormal, eMetric_ScrollThumbStyleProportional }
enum  nsMetricFloatID {
  eMetricFloat_TextFieldVerticalInsidePadding, eMetricFloat_TextFieldHorizontalInsidePadding, eMetricFloat_TextAreaVerticalInsidePadding, eMetricFloat_TextAreaHorizontalInsidePadding,
  eMetricFloat_ListVerticalInsidePadding, eMetricFloat_ListHorizontalInsidePadding, eMetricFloat_ButtonVerticalInsidePadding, eMetricFloat_ButtonHorizontalInsidePadding
}

Public Member Functions

 nsXPLookAndFeel ()
virtual ~nsXPLookAndFeel ()
NS_DECL_ISUPPORTS void Init ()
NS_IMETHOD GetColor (const nsColorID aID, nscolor &aColor)
NS_IMETHOD GetMetric (const nsMetricID aID, PRInt32 &aMetric)
NS_IMETHOD GetMetric (const nsMetricFloatID aID, float &aMetric)
NS_IMETHOD LookAndFeelChanged ()

Protected Member Functions

nsresult InitFromPref (nsLookAndFeelIntPref *aPref, nsIPref *aPrefService)
nsresult InitFromPref (nsLookAndFeelFloatPref *aPref, nsIPref *aPrefService)
nsresult InitColorFromPref (PRInt32 aIndex, nsIPref *aPrefService)
virtual nsresult NativeGetColor (const nsColorID aID, nscolor &aColor)=0

Static Protected Attributes

static PRBool sInitialized = PR_FALSE
static nsLookAndFeelIntPref sIntPrefs []
static nsLookAndFeelFloatPref sFloatPrefs []
static const char sColorPrefs [][36]
static PRInt32 sCachedColors [nsILookAndFeel::eColor_LAST_COLOR] = {0}
static PRInt32 sCachedColorBits [COLOR_CACHE_SIZE] = {0}

Friends

int colorPrefChanged (const char *aPref, void *aData)

Detailed Description

Definition at line 82 of file nsXPLookAndFeel.h.


Member Enumeration Documentation

anonymous enum [inherited]
Enumerator:
eMetric_ScrollArrowStyleSingle 
eMetric_ScrollArrowStyleBothAtBottom 
eMetric_ScrollArrowStyleBothAtEachEnd 
eMetric_ScrollArrowStyleBothAtTop 

Definition at line 212 of file nsILookAndFeel.h.

       {
    eMetric_ScrollArrowStyleSingle,                       // single arrow at each end
    eMetric_ScrollArrowStyleBothAtBottom,                 // both arrows at bottom/right, none at top/left
    eMetric_ScrollArrowStyleBothAtEachEnd,                // both arrows at both ends
    eMetric_ScrollArrowStyleBothAtTop                     // both arrows at top/left, none at bottom/right
  };
anonymous enum [inherited]
Enumerator:
eMetric_ScrollThumbStyleNormal 
eMetric_ScrollThumbStyleProportional 

Definition at line 218 of file nsILookAndFeel.h.

enum nsILookAndFeel::nsColorID [inherited]
Enumerator:
eColor_WindowBackground 
eColor_WindowForeground 
eColor_WidgetBackground 
eColor_WidgetForeground 
eColor_WidgetSelectBackground 
eColor_WidgetSelectForeground 
eColor_Widget3DHighlight 
eColor_Widget3DShadow 
eColor_TextBackground 
eColor_TextForeground 
eColor_TextSelectBackground 
eColor_TextSelectForeground 
eColor_TextSelectBackgroundDisabled 
eColor_TextSelectBackgroundAttention 
eColor_activeborder 
eColor_activecaption 
eColor_appworkspace 
eColor_background 
eColor_buttonface 
eColor_buttonhighlight 
eColor_buttonshadow 
eColor_buttontext 
eColor_captiontext 
eColor_graytext 
eColor_highlight 
eColor_highlighttext 
eColor_inactiveborder 
eColor_inactivecaption 
eColor_inactivecaptiontext 
eColor_infobackground 
eColor_infotext 
eColor_menu 
eColor_menutext 
eColor_scrollbar 
eColor_threeddarkshadow 
eColor_threedface 
eColor_threedhighlight 
eColor_threedlightshadow 
eColor_threedshadow 
eColor_window 
eColor_windowframe 
eColor_windowtext 
eColor__moz_buttondefault 
eColor__moz_field 
eColor__moz_fieldtext 
eColor__moz_dialog 
eColor__moz_dialogtext 
eColor__moz_dragtargetzone 
eColor__moz_cellhighlight 
eColor__moz_cellhighlighttext 
eColor__moz_buttonhoverface 
eColor__moz_buttonhovertext 
eColor__moz_menuhover 
eColor__moz_menuhovertext 
eColor__moz_mac_focusring 
eColor__moz_mac_menuselect 
eColor__moz_mac_menushadow 
eColor__moz_mac_menutextdisable 
eColor__moz_mac_menutextselect 
eColor__moz_mac_accentlightesthighlight 
eColor__moz_mac_accentregularhighlight 
eColor__moz_mac_accentface 
eColor__moz_mac_accentlightshadow 
eColor__moz_mac_accentregularshadow 
eColor__moz_mac_accentdarkshadow 
eColor__moz_mac_accentdarkestshadow 
eColor__moz_mac_alternateprimaryhighlight 
eColor__moz_mac_secondaryhighlight 
eColor_LAST_COLOR 

Definition at line 58 of file nsILookAndFeel.h.

               {

    // WARNING : NO NEGATIVE VALUE IN THIS ENUMERATION
    // see patch in bug 57757 for more information

    eColor_WindowBackground,
    eColor_WindowForeground,
    eColor_WidgetBackground,
    eColor_WidgetForeground,
    eColor_WidgetSelectBackground,
    eColor_WidgetSelectForeground,
    eColor_Widget3DHighlight,
    eColor_Widget3DShadow,
    eColor_TextBackground,
    eColor_TextForeground,
    eColor_TextSelectBackground,
    eColor_TextSelectForeground,
    eColor_TextSelectBackgroundDisabled,
    eColor_TextSelectBackgroundAttention,

    // New CSS 2 color definitions
    eColor_activeborder,
    eColor_activecaption,
    eColor_appworkspace,
    eColor_background,
    eColor_buttonface,
    eColor_buttonhighlight,
    eColor_buttonshadow,
    eColor_buttontext,
    eColor_captiontext,
    eColor_graytext,
    eColor_highlight,
    eColor_highlighttext,
    eColor_inactiveborder,
    eColor_inactivecaption,
    eColor_inactivecaptiontext,
    eColor_infobackground,
    eColor_infotext,
    eColor_menu,
    eColor_menutext,
    eColor_scrollbar,
    eColor_threeddarkshadow,
    eColor_threedface,
    eColor_threedhighlight,
    eColor_threedlightshadow,
    eColor_threedshadow,
    eColor_window,
    eColor_windowframe,
    eColor_windowtext,

    eColor__moz_buttondefault,
    // Colors which will hopefully become CSS3
    eColor__moz_field,
    eColor__moz_fieldtext,
    eColor__moz_dialog,
    eColor__moz_dialogtext,
    eColor__moz_dragtargetzone,                         //used to highlight valid regions to drop something onto

    eColor__moz_cellhighlight,                               //used to cell text background, selected but not focus
    eColor__moz_cellhighlighttext,                           //used to cell text, selected but not focus
    eColor__moz_buttonhoverface,                             //used to button text background, when mouse is over
    eColor__moz_buttonhovertext,                             //used to button text, when mouse is over
    eColor__moz_menuhover,                                   //used to menu item background, when mouse is over
    eColor__moz_menuhovertext,                               //used to menu item text, when mouse is over

    //colours needed by Mac Classic skin
    eColor__moz_mac_focusring,                          //ring around text fields and lists
    eColor__moz_mac_menuselect,                         //colour used when mouse is over a menu item
    eColor__moz_mac_menushadow,                         //colour used to do shadows on menu items
    eColor__moz_mac_menutextdisable,                    // color used to display text for disabled menu items
    eColor__moz_mac_menutextselect,                     //colour used to display text while mouse is over a menu item

       //all of the accent colours
       eColor__moz_mac_accentlightesthighlight,
    eColor__moz_mac_accentregularhighlight,
    eColor__moz_mac_accentface,
    eColor__moz_mac_accentlightshadow,
    eColor__moz_mac_accentregularshadow,
    eColor__moz_mac_accentdarkshadow,
    eColor__moz_mac_accentdarkestshadow,
    
    //new in 10.2
    eColor__moz_mac_alternateprimaryhighlight, //active list highlight
    eColor__moz_mac_secondaryhighlight,        //inactive light hightlight
  
    // keep this one last, please
    eColor_LAST_COLOR
  } nsColorID;
Enumerator:
eMetricFloat_TextFieldVerticalInsidePadding 
eMetricFloat_TextFieldHorizontalInsidePadding 
eMetricFloat_TextAreaVerticalInsidePadding 
eMetricFloat_TextAreaHorizontalInsidePadding 
eMetricFloat_ListVerticalInsidePadding 
eMetricFloat_ListHorizontalInsidePadding 
eMetricFloat_ButtonVerticalInsidePadding 
eMetricFloat_ButtonHorizontalInsidePadding 

Definition at line 225 of file nsILookAndFeel.h.

enum nsILookAndFeel::nsMetricID [inherited]
Enumerator:
eMetric_WindowTitleHeight 
eMetric_WindowBorderWidth 
eMetric_WindowBorderHeight 
eMetric_Widget3DBorder 
eMetric_TextFieldBorder 
eMetric_TextFieldHeight 
eMetric_TextVerticalInsidePadding 
eMetric_TextShouldUseVerticalInsidePadding 
eMetric_TextHorizontalInsideMinimumPadding 
eMetric_TextShouldUseHorizontalInsideMinimumPadding 
eMetric_ButtonHorizontalInsidePaddingNavQuirks 
eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks 
eMetric_CheckboxSize 
eMetric_RadioboxSize 
eMetric_ListShouldUseHorizontalInsideMinimumPadding 
eMetric_ListHorizontalInsideMinimumPadding 
eMetric_ListShouldUseVerticalInsidePadding 
eMetric_ListVerticalInsidePadding 
eMetric_CaretBlinkTime 
eMetric_CaretWidth 
eMetric_ShowCaretDuringSelection 
eMetric_SelectTextfieldsOnKeyFocus 
eMetric_SubmenuDelay 
eMetric_MenusCanOverlapOSBar 
eMetric_SkipNavigatingDisabledMenuItem 
eMetric_DragFullWindow 
eMetric_DragThresholdX 
eMetric_DragThresholdY 
eMetric_UseAccessibilityTheme 
eMetric_IsScreenReaderActive 
eMetric_ScrollArrowStyle 
eMetric_ScrollSliderStyle 
eMetric_TreeOpenDelay 
eMetric_TreeCloseDelay 
eMetric_TreeLazyScrollDelay 
eMetric_TreeScrollDelay 
eMetric_TreeScrollLinesMax 
eMetric_TabFocusModel 
eMetric_AlertNotificationOrigin 

Definition at line 149 of file nsILookAndFeel.h.

               {
    eMetric_WindowTitleHeight,
    eMetric_WindowBorderWidth,
    eMetric_WindowBorderHeight,
    eMetric_Widget3DBorder,
    eMetric_TextFieldBorder,                              // Native border size
    eMetric_TextFieldHeight,
    eMetric_TextVerticalInsidePadding,                    // needed only because of GTK
    eMetric_TextShouldUseVerticalInsidePadding,           // needed only because of GTK
    eMetric_TextHorizontalInsideMinimumPadding,  
    eMetric_TextShouldUseHorizontalInsideMinimumPadding,  // needed only because of GTK
    eMetric_ButtonHorizontalInsidePaddingNavQuirks,  
    eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks, 
    eMetric_CheckboxSize,
    eMetric_RadioboxSize,
    
    eMetric_ListShouldUseHorizontalInsideMinimumPadding,  // needed only because of GTK
    eMetric_ListHorizontalInsideMinimumPadding,         

    eMetric_ListShouldUseVerticalInsidePadding,           // needed only because of GTK
    eMetric_ListVerticalInsidePadding,                    // needed only because of GTK

    eMetric_CaretBlinkTime,                               // default, may be overriden by OS
    eMetric_CaretWidth,                                   // pixel width of caret
    eMetric_ShowCaretDuringSelection,                       // show the caret when text is selected?
    eMetric_SelectTextfieldsOnKeyFocus,                   // select textfields when focused via tab/accesskey?
    eMetric_SubmenuDelay,                                 // delay before submenus open
    eMetric_MenusCanOverlapOSBar,                         // can popups overlap menu/task bar?
    eMetric_SkipNavigatingDisabledMenuItem,               // skip navigating to disabled menu item?
    eMetric_DragFullWindow,                               // show window contents while dragging?
    eMetric_DragThresholdX,                               // begin a drag if the mouse is moved further than the threshold while the button is down
    eMetric_DragThresholdY,
    eMetric_UseAccessibilityTheme,                        // Accessibility theme being used?
    eMetric_IsScreenReaderActive,                         // Screen reader being used?

    eMetric_ScrollArrowStyle,                             // position of scroll arrows in a scrollbar
    eMetric_ScrollSliderStyle,                            // is scroll thumb proportional or fixed?

    eMetric_TreeOpenDelay,                                // delay for opening spring loaded folders
    eMetric_TreeCloseDelay,                               // delay for closing spring loaded folders
    eMetric_TreeLazyScrollDelay,                          // delay for triggering the tree scrolling
    eMetric_TreeScrollDelay,                              // delay for scrolling the tree
    eMetric_TreeScrollLinesMax,                           // the maximum number of lines to be scrolled at ones
    eMetric_TabFocusModel,                                // What type of tab-order to use

    /*
     * eMetric_AlertNotificationOrigin indicates from which corner of the
     * screen alerts slide in, and from which direction (horizontal/vertical).
     * 0, the default, represents bottom right, sliding vertically.
     * Use any bitwise combination of the following constants:
     * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
     *
     *       6       4
     *     +-----------+
     *    7|           |5
     *     |           |
     *    3|           |1
     *     +-----------+
     *       2       0
     */
    eMetric_AlertNotificationOrigin
  } nsMetricID;

Constructor & Destructor Documentation

Definition at line 210 of file nsXPLookAndFeel.cpp.

                                 : nsILookAndFeel()
{
}

Definition at line 377 of file nsXPLookAndFeel.cpp.

{
}

Member Function Documentation

NS_IMETHODIMP nsXPLookAndFeel::GetColor ( const nsColorID  aID,
nscolor aColor 
) [virtual]

Implements nsILookAndFeel.

Definition at line 387 of file nsXPLookAndFeel.cpp.

{
  if (!sInitialized)
    Init();

  // define DEBUG_SYSTEM_COLOR_USE if you want to debug system color
  // use in a skin that uses them.  When set, it will make all system
  // color pairs that are appropriate for foreground/background
  // pairing the same.  This means if the skin is using system colors
  // correctly you will not be able to see *any* text.
#undef DEBUG_SYSTEM_COLOR_USE

#ifdef DEBUG_SYSTEM_COLOR_USE
  {
    nsresult rv = NS_OK;
    switch (aID) {
        // css2  http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
      case eColor_activecaption:
          // active window caption background
      case eColor_captiontext:
          // text in active window caption
        aColor = NS_RGB(0xff, 0x00, 0x00);
        break;

      case eColor_highlight:
          // background of selected item
      case eColor_highlighttext:
          // text of selected item
        aColor = NS_RGB(0xff, 0xff, 0x00);
        break;

      case eColor_inactivecaption:
          // inactive window caption
      case eColor_inactivecaptiontext:
          // text in inactive window caption
        aColor = NS_RGB(0x66, 0x66, 0x00);
        break;

      case eColor_infobackground:
          // tooltip background color
      case eColor_infotext:
          // tooltip text color
        aColor = NS_RGB(0x00, 0xff, 0x00);
        break;

      case eColor_menu:
          // menu background
      case eColor_menutext:
          // menu text
        aColor = NS_RGB(0x00, 0xff, 0xff);
        break;

      case eColor_threedface:
      case eColor_buttonface:
          // 3-D face color
      case eColor_buttontext:
          // text on push buttons
        aColor = NS_RGB(0x00, 0x66, 0x66);
        break;

      case eColor_window:
      case eColor_windowtext:
        aColor = NS_RGB(0x00, 0x00, 0xff);
        break;

      // from the CSS3 working draft (not yet finalized)
      // http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color

      case eColor__moz_field:
      case eColor__moz_fieldtext:
        aColor = NS_RGB(0xff, 0x00, 0xff);
        break;

      case eColor__moz_dialog:
      case eColor__moz_dialogtext:
        aColor = NS_RGB(0x66, 0x00, 0x66);
        break;

      default:
        rv = NS_ERROR_NOT_AVAILABLE;
    }
    if (NS_SUCCEEDED(rv))
      return rv;
  }
#endif // DEBUG_SYSTEM_COLOR_USE

  if (IS_COLOR_CACHED(aID)) {
    aColor = sCachedColors[aID];
    return NS_OK;
  }

  // There are no system color settings for these, so set them manually
  if (aID == eColor_TextSelectBackgroundDisabled) {
    // This is used to gray out the selection when it's not focused
    // Used with nsISelectionController::SELECTION_DISABLED
    aColor = NS_RGB(0xb0, 0xb0, 0xb0);
    return NS_OK;
  }

  if (aID == eColor_TextSelectBackgroundAttention) {
    // This makes the selection stand out when typeaheadfind is on
    // Used with nsISelectionController::SELECTION_ATTENTION
    aColor = NS_RGB(0x38, 0xd8, 0x78);
    return NS_OK;
  }

  if (NS_SUCCEEDED(NativeGetColor(aID, aColor))) {
    CACHE_COLOR(aID, aColor);
    return NS_OK;
  }

  return NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsXPLookAndFeel::GetMetric ( const nsMetricID  aID,
PRInt32 aMetric 
) [virtual]

Implements nsILookAndFeel.

Reimplemented in nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, and nsLookAndFeel.

Definition at line 501 of file nsXPLookAndFeel.cpp.

{
  if (!sInitialized)
    Init();

  for (unsigned int i = 0; i < ((sizeof (sIntPrefs) / sizeof (*sIntPrefs))); ++i)
    if (sIntPrefs[i].isSet && (sIntPrefs[i].id == aID))
    {
      aMetric = sIntPrefs[i].intVar;
      return NS_OK;
    }

  return NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

NS_IMETHODIMP nsXPLookAndFeel::GetMetric ( const nsMetricFloatID  aID,
float &  aMetric 
) [virtual]

Implements nsILookAndFeel.

Reimplemented in nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, and nsLookAndFeel.

Definition at line 517 of file nsXPLookAndFeel.cpp.

{
  if (!sInitialized)
    Init();

  for (unsigned int i = 0; i < ((sizeof (sFloatPrefs) / sizeof (*sFloatPrefs))); ++i)
    if (sFloatPrefs[i].isSet && sFloatPrefs[i].id == aID)
    {
      aMetric = sFloatPrefs[i].floatVar;
      return NS_OK;
    }

  return NS_ERROR_NOT_AVAILABLE;
}

Here is the call graph for this function:

Definition at line 355 of file nsXPLookAndFeel.cpp.

{
  // Say we're already initialized, and take the chance that it might fail;
  // protects against some other process writing to our static variables.
  sInitialized = PR_TRUE;

  nsresult rv;
  nsCOMPtr<nsIPref> prefService(do_GetService(kPrefServiceCID, &rv));
  if (NS_FAILED(rv) || !prefService)
    return;

  unsigned int i;
  for (i = 0; i < ((sizeof (sIntPrefs) / sizeof (*sIntPrefs))); ++i)
    InitFromPref(&sIntPrefs[i], prefService);

  for (i = 0; i < ((sizeof (sFloatPrefs) / sizeof (*sFloatPrefs))); ++i)
    InitFromPref(&sFloatPrefs[i], prefService);

  for (i = 0; i < (sizeof(sColorPrefs) / sizeof (*sColorPrefs)); ++i)
    InitColorFromPref(i, prefService);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXPLookAndFeel::InitColorFromPref ( PRInt32  aIndex,
nsIPref aPrefService 
) [protected]

Definition at line 321 of file nsXPLookAndFeel.cpp.

{
  char *colorStr = 0;
  nsresult rv = aPrefService->CopyCharPref(sColorPrefs[i], &colorStr);
  if (NS_SUCCEEDED(rv) && colorStr[0])
  {
    nsAutoString colorNSStr; colorNSStr.AssignWithConversion(colorStr);
    nscolor thecolor;
    if (colorNSStr[0] == '#') {
      nsAutoString hexString;
      colorNSStr.Right(hexString, colorNSStr.Length() - 1);
      if (NS_SUCCEEDED(NS_HexToRGB(hexString, &thecolor))) {
        CACHE_COLOR(i, thecolor);
        PL_strfree(colorStr);
      }
    }
    else if (NS_SUCCEEDED(NS_ColorNameToRGB(colorNSStr, &thecolor)))
    {
      CACHE_COLOR(i, thecolor);
      PL_strfree(colorStr);
    }
  }

  aPrefService->RegisterCallback(sColorPrefs[i], colorPrefChanged, (void*)i);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXPLookAndFeel::InitFromPref ( nsLookAndFeelIntPref aPref,
nsIPref aPrefService 
) [protected]

Definition at line 293 of file nsXPLookAndFeel.cpp.

{
  PRInt32 intpref;
  nsresult rv = aPrefService->GetIntPref(aPref->name, &intpref);
  if (NS_SUCCEEDED(rv))
  {
    aPref->isSet = PR_TRUE;
    aPref->intVar = intpref;
  }
  aPrefService->RegisterCallback(aPref->name, intPrefChanged, aPref);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXPLookAndFeel::InitFromPref ( nsLookAndFeelFloatPref aPref,
nsIPref aPrefService 
) [protected]

Definition at line 307 of file nsXPLookAndFeel.cpp.

{
  PRInt32 intpref;
  nsresult rv = aPrefService->GetIntPref(aPref->name, &intpref);
  if (NS_SUCCEEDED(rv))
  {
    aPref->isSet = PR_TRUE;
    aPref->floatVar = (float)intpref / 100.;
  }
  aPrefService->RegisterCallback(aPref->name, floatPrefChanged, aPref);
  return rv;
}

Here is the call graph for this function:

Implements nsILookAndFeel.

Reimplemented in nsLookAndFeel.

Definition at line 533 of file nsXPLookAndFeel.cpp.

{
  // Wipe out our color cache.
  PRUint32 i;
  for (i = 0; i < nsILookAndFeel::eColor_LAST_COLOR; i++)
    sCachedColors[i] = 0;
  for (i = 0; i < COLOR_CACHE_SIZE; i++)
    sCachedColorBits[i] = 0;
  return NS_OK;
}
virtual nsresult nsXPLookAndFeel::NativeGetColor ( const nsColorID  aID,
nscolor aColor 
) [protected, pure virtual]

Implemented in nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, nsLookAndFeel, and nsLookAndFeel.

Here is the caller graph for this function:


Friends And Related Function Documentation

int colorPrefChanged ( const char *  aPref,
void aData 
) [friend]

Member Data Documentation

PRInt32 nsXPLookAndFeel::sCachedColorBits = {0} [static, protected]

Definition at line 125 of file nsXPLookAndFeel.h.

PRInt32 nsXPLookAndFeel::sCachedColors = {0} [static, protected]

Definition at line 124 of file nsXPLookAndFeel.h.

const char nsXPLookAndFeel::sColorPrefs [static, protected]

Definition at line 123 of file nsXPLookAndFeel.h.

Initial value:
{
  { "ui.textFieldVerticalInsidePadding",
    eMetricFloat_TextFieldVerticalInsidePadding, PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.textFieldHorizontalInsidePadding",
    eMetricFloat_TextFieldHorizontalInsidePadding, PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.textAreaVerticalInsidePadding", eMetricFloat_TextAreaVerticalInsidePadding,
    PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.textAreaHorizontalInsidePadding",
    eMetricFloat_TextAreaHorizontalInsidePadding, PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.listVerticalInsidePadding",
    eMetricFloat_ListVerticalInsidePadding, PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.listHorizontalInsidePadding",
    eMetricFloat_ListHorizontalInsidePadding, PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.buttonVerticalInsidePadding", eMetricFloat_ButtonVerticalInsidePadding,
    PR_FALSE, nsLookAndFeelTypeFloat, 0 },
  { "ui.buttonHorizontalInsidePadding", eMetricFloat_ButtonHorizontalInsidePadding,
    PR_FALSE, nsLookAndFeelTypeFloat, 0 },
}

Definition at line 119 of file nsXPLookAndFeel.h.

Definition at line 117 of file nsXPLookAndFeel.h.

Definition at line 118 of file nsXPLookAndFeel.h.


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