widget/LookAndFeel.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/LookAndFeel.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,615 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef __LookAndFeel
    1.10 +#define __LookAndFeel
    1.11 +
    1.12 +#ifndef MOZILLA_INTERNAL_API
    1.13 +#error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
    1.14 +#endif
    1.15 +
    1.16 +#include "nsDebug.h"
    1.17 +#include "nsColor.h"
    1.18 +
    1.19 +struct gfxFontStyle;
    1.20 +
    1.21 +namespace mozilla {
    1.22 +
    1.23 +class LookAndFeel
    1.24 +{
    1.25 +public:
    1.26 +  // When modifying this list, also modify nsXPLookAndFeel::sColorPrefs
    1.27 +  // in widget/xpwidgts/nsXPLookAndFeel.cpp.
    1.28 +  enum ColorID {
    1.29 +
    1.30 +    // WARNING : NO NEGATIVE VALUE IN THIS ENUMERATION
    1.31 +    // see patch in bug 57757 for more information
    1.32 +
    1.33 +    eColorID_WindowBackground,
    1.34 +    eColorID_WindowForeground,
    1.35 +    eColorID_WidgetBackground,
    1.36 +    eColorID_WidgetForeground,
    1.37 +    eColorID_WidgetSelectBackground,
    1.38 +    eColorID_WidgetSelectForeground,
    1.39 +    eColorID_Widget3DHighlight,
    1.40 +    eColorID_Widget3DShadow,
    1.41 +    eColorID_TextBackground,
    1.42 +    eColorID_TextForeground,
    1.43 +    eColorID_TextSelectBackground,
    1.44 +    eColorID_TextSelectForeground,
    1.45 +    eColorID_TextSelectBackgroundDisabled,
    1.46 +    eColorID_TextSelectBackgroundAttention,
    1.47 +    eColorID_TextHighlightBackground,
    1.48 +    eColorID_TextHighlightForeground,
    1.49 +
    1.50 +    eColorID_IMERawInputBackground,
    1.51 +    eColorID_IMERawInputForeground,
    1.52 +    eColorID_IMERawInputUnderline,
    1.53 +    eColorID_IMESelectedRawTextBackground,
    1.54 +    eColorID_IMESelectedRawTextForeground,
    1.55 +    eColorID_IMESelectedRawTextUnderline,
    1.56 +    eColorID_IMEConvertedTextBackground,
    1.57 +    eColorID_IMEConvertedTextForeground,
    1.58 +    eColorID_IMEConvertedTextUnderline,
    1.59 +    eColorID_IMESelectedConvertedTextBackground,
    1.60 +    eColorID_IMESelectedConvertedTextForeground,
    1.61 +    eColorID_IMESelectedConvertedTextUnderline,
    1.62 +
    1.63 +    eColorID_SpellCheckerUnderline,
    1.64 +
    1.65 +    // New CSS 2 color definitions
    1.66 +    eColorID_activeborder,
    1.67 +    eColorID_activecaption,
    1.68 +    eColorID_appworkspace,
    1.69 +    eColorID_background,
    1.70 +    eColorID_buttonface,
    1.71 +    eColorID_buttonhighlight,
    1.72 +    eColorID_buttonshadow,
    1.73 +    eColorID_buttontext,
    1.74 +    eColorID_captiontext,
    1.75 +    eColorID_graytext,
    1.76 +    eColorID_highlight,
    1.77 +    eColorID_highlighttext,
    1.78 +    eColorID_inactiveborder,
    1.79 +    eColorID_inactivecaption,
    1.80 +    eColorID_inactivecaptiontext,
    1.81 +    eColorID_infobackground,
    1.82 +    eColorID_infotext,
    1.83 +    eColorID_menu,
    1.84 +    eColorID_menutext,
    1.85 +    eColorID_scrollbar,
    1.86 +    eColorID_threeddarkshadow,
    1.87 +    eColorID_threedface,
    1.88 +    eColorID_threedhighlight,
    1.89 +    eColorID_threedlightshadow,
    1.90 +    eColorID_threedshadow,
    1.91 +    eColorID_window,
    1.92 +    eColorID_windowframe,
    1.93 +    eColorID_windowtext,
    1.94 +
    1.95 +    eColorID__moz_buttondefault,
    1.96 +    // Colors which will hopefully become CSS3
    1.97 +    eColorID__moz_field,
    1.98 +    eColorID__moz_fieldtext,
    1.99 +    eColorID__moz_dialog,
   1.100 +    eColorID__moz_dialogtext,
   1.101 +    // used to highlight valid regions to drop something onto
   1.102 +    eColorID__moz_dragtargetzone,
   1.103 +
   1.104 +    // used to cell text background, selected but not focus
   1.105 +    eColorID__moz_cellhighlight,
   1.106 +    // used to cell text, selected but not focus
   1.107 +    eColorID__moz_cellhighlighttext,
   1.108 +    // used to html select cell text background, selected but not focus
   1.109 +    eColorID__moz_html_cellhighlight,
   1.110 +    // used to html select cell text, selected but not focus
   1.111 +    eColorID__moz_html_cellhighlighttext,
   1.112 +    // used to button text background, when mouse is over
   1.113 +    eColorID__moz_buttonhoverface,
   1.114 +    // used to button text, when mouse is over
   1.115 +    eColorID__moz_buttonhovertext,
   1.116 +    // used to menu item background, when mouse is over
   1.117 +    eColorID__moz_menuhover,
   1.118 +    // used to menu item text, when mouse is over
   1.119 +    eColorID__moz_menuhovertext,
   1.120 +    // used to menu bar item text
   1.121 +    eColorID__moz_menubartext,
   1.122 +    // used to menu bar item text, when mouse is over
   1.123 +    eColorID__moz_menubarhovertext,
   1.124 +    // On platforms where these colors are the same as
   1.125 +    // -moz-field, use -moz-fieldtext as foreground color
   1.126 +    eColorID__moz_eventreerow,
   1.127 +    eColorID__moz_oddtreerow,
   1.128 +
   1.129 +    // colors needed by the Mac OS X theme
   1.130 +
   1.131 +    // background color of chrome toolbars in active windows
   1.132 +    eColorID__moz_mac_chrome_active,
   1.133 +    // background color of chrome toolbars in inactive windows
   1.134 +    eColorID__moz_mac_chrome_inactive,
   1.135 +    //ring around text fields and lists
   1.136 +    eColorID__moz_mac_focusring,
   1.137 +    //colour used when mouse is over a menu item
   1.138 +    eColorID__moz_mac_menuselect,
   1.139 +    //colour used to do shadows on menu items
   1.140 +    eColorID__moz_mac_menushadow,
   1.141 +    // color used to display text for disabled menu items
   1.142 +    eColorID__moz_mac_menutextdisable,
   1.143 +    //colour used to display text while mouse is over a menu item
   1.144 +    eColorID__moz_mac_menutextselect,
   1.145 +    // text color of disabled text on toolbars
   1.146 +    eColorID__moz_mac_disabledtoolbartext,
   1.147 +    //inactive light hightlight
   1.148 +    eColorID__moz_mac_secondaryhighlight,
   1.149 +
   1.150 +    // vista rebars
   1.151 +
   1.152 +    // media rebar text
   1.153 +    eColorID__moz_win_mediatext,
   1.154 +    // communications rebar text
   1.155 +    eColorID__moz_win_communicationstext,
   1.156 +
   1.157 +    // Hyperlink color extracted from the system, not affected by the
   1.158 +    // browser.anchor_color user pref.
   1.159 +    // There is no OS-specified safe background color for this text, 
   1.160 +    // but it is used regularly within Windows and the Gnome DE on Dialog and
   1.161 +    // Window colors.
   1.162 +    eColorID__moz_nativehyperlinktext,
   1.163 +
   1.164 +    // Combo box widgets
   1.165 +    eColorID__moz_comboboxtext,
   1.166 +    eColorID__moz_combobox,
   1.167 +
   1.168 +    // keep this one last, please
   1.169 +    eColorID_LAST_COLOR
   1.170 +  };
   1.171 +
   1.172 +  // When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
   1.173 +  // in widget/xpwidgts/nsXPLookAndFeel.cpp.
   1.174 +  enum IntID {
   1.175 +    // default, may be overriden by OS
   1.176 +    eIntID_CaretBlinkTime,
   1.177 +    // pixel width of caret
   1.178 +    eIntID_CaretWidth,
   1.179 +    // show the caret when text is selected?
   1.180 +    eIntID_ShowCaretDuringSelection,
   1.181 +    // select textfields when focused via tab/accesskey?
   1.182 +    eIntID_SelectTextfieldsOnKeyFocus,
   1.183 +    // delay before submenus open
   1.184 +    eIntID_SubmenuDelay,
   1.185 +    // can popups overlap menu/task bar?
   1.186 +    eIntID_MenusCanOverlapOSBar,
   1.187 +    // should overlay scrollbars be used?
   1.188 +    eIntID_UseOverlayScrollbars,
   1.189 +    // allow H and V overlay scrollbars to overlap?
   1.190 +    eIntID_AllowOverlayScrollbarsOverlap,
   1.191 +    // show/hide scrollbars based on activity
   1.192 +    eIntID_ShowHideScrollbars,
   1.193 +    // skip navigating to disabled menu item?
   1.194 +    eIntID_SkipNavigatingDisabledMenuItem,
   1.195 +    // begin a drag if the mouse is moved further than the threshold while the
   1.196 +    // button is down
   1.197 +    eIntID_DragThresholdX,
   1.198 +    eIntID_DragThresholdY,
   1.199 +    // Accessibility theme being used?
   1.200 +    eIntID_UseAccessibilityTheme,
   1.201 +
   1.202 +    // position of scroll arrows in a scrollbar
   1.203 +    eIntID_ScrollArrowStyle,
   1.204 +    // is scroll thumb proportional or fixed?
   1.205 +    eIntID_ScrollSliderStyle,
   1.206 +
   1.207 +    // each button can take one of four values:
   1.208 +    eIntID_ScrollButtonLeftMouseButtonAction,
   1.209 +    // 0 - scrolls one  line, 1 - scrolls one page
   1.210 +    eIntID_ScrollButtonMiddleMouseButtonAction,
   1.211 +    // 2 - scrolls to end, 3 - button ignored
   1.212 +    eIntID_ScrollButtonRightMouseButtonAction,
   1.213 +
   1.214 +    // delay for opening spring loaded folders
   1.215 +    eIntID_TreeOpenDelay,
   1.216 +    // delay for closing spring loaded folders
   1.217 +    eIntID_TreeCloseDelay,
   1.218 +    // delay for triggering the tree scrolling
   1.219 +    eIntID_TreeLazyScrollDelay,
   1.220 +    // delay for scrolling the tree
   1.221 +    eIntID_TreeScrollDelay,
   1.222 +    // the maximum number of lines to be scrolled at ones
   1.223 +    eIntID_TreeScrollLinesMax,
   1.224 +    // What type of tab-order to use
   1.225 +    eIntID_TabFocusModel,
   1.226 +    // Should menu items blink when they're chosen?
   1.227 +    eIntID_ChosenMenuItemsShouldBlink,
   1.228 +
   1.229 +    /*
   1.230 +     * A Boolean value to determine whether the Windows default theme is
   1.231 +     * being used.
   1.232 +     *
   1.233 +     * The value of this metric is not used on other platforms. These platforms
   1.234 +     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
   1.235 +     */
   1.236 +    eIntID_WindowsDefaultTheme,
   1.237 +
   1.238 +    /*
   1.239 +     * A Boolean value to determine whether the DWM compositor is being used
   1.240 +     *
   1.241 +     * This metric is not used on non-Windows platforms. These platforms
   1.242 +     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
   1.243 +     */
   1.244 +    eIntID_DWMCompositor,
   1.245 +
   1.246 +    /*
   1.247 +     * A Boolean value to determine whether Windows is themed (Classic vs.
   1.248 +     * uxtheme)
   1.249 +     *
   1.250 +     * This is Windows-specific and is not implemented on other platforms
   1.251 +     * (will return the default of NS_ERROR_FAILURE).
   1.252 +     */
   1.253 +    eIntID_WindowsClassic,
   1.254 +
   1.255 +    /*
   1.256 +     * A Boolean value to determine whether the current Windows desktop theme
   1.257 +     * supports Aero Glass.
   1.258 +     *
   1.259 +     * This is Windows-specific and is not implemented on other platforms
   1.260 +     * (will return the default of NS_ERROR_FAILURE).
   1.261 +     */
   1.262 +    eIntID_WindowsGlass,
   1.263 +
   1.264 +    /*
   1.265 +     * A Boolean value to determine whether the device is a touch enabled
   1.266 +     * device. Currently this is only supported by the Windows 7 Touch API.
   1.267 +     *
   1.268 +     * Platforms that do not support this metric should return
   1.269 +     * NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
   1.270 +     */
   1.271 +    eIntID_TouchEnabled,
   1.272 +
   1.273 +    /*
   1.274 +     * A Boolean value to determine whether the Mac graphite theme is
   1.275 +     * being used.
   1.276 +     *
   1.277 +     * The value of this metric is not used on other platforms. These platforms
   1.278 +     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
   1.279 +     */
   1.280 +    eIntID_MacGraphiteTheme,
   1.281 +
   1.282 +    /*
   1.283 +     * A Boolean value to determine whether the Mac OS X Lion-specific theming
   1.284 +     * should be used.
   1.285 +     *
   1.286 +     * The value of this metric is not used on non-Mac platforms. These
   1.287 +     * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
   1.288 +     * metric.
   1.289 +     */
   1.290 +    eIntID_MacLionTheme,
   1.291 +
   1.292 +    /*
   1.293 +     * eIntID_AlertNotificationOrigin indicates from which corner of the
   1.294 +     * screen alerts slide in, and from which direction (horizontal/vertical).
   1.295 +     * 0, the default, represents bottom right, sliding vertically.
   1.296 +     * Use any bitwise combination of the following constants:
   1.297 +     * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
   1.298 +     *
   1.299 +     *       6       4
   1.300 +     *     +-----------+
   1.301 +     *    7|           |5
   1.302 +     *     |           |
   1.303 +     *    3|           |1
   1.304 +     *     +-----------+
   1.305 +     *       2       0
   1.306 +     */
   1.307 +    eIntID_AlertNotificationOrigin,
   1.308 +
   1.309 +    /**
   1.310 +     * If true, clicking on a scrollbar (not as in dragging the thumb) defaults
   1.311 +     * to scrolling the view corresponding to the clicked point. Otherwise, we
   1.312 +     * only do so if the scrollbar is clicked using the middle mouse button or
   1.313 +     * if shift is pressed when the scrollbar is clicked.
   1.314 +     */
   1.315 +    eIntID_ScrollToClick,
   1.316 +
   1.317 +    /**
   1.318 +     * IME and spell checker underline styles, the values should be
   1.319 +     * NS_DECORATION_LINE_STYLE_*.  They are defined below.
   1.320 +     */
   1.321 +    eIntID_IMERawInputUnderlineStyle,
   1.322 +    eIntID_IMESelectedRawTextUnderlineStyle,
   1.323 +    eIntID_IMEConvertedTextUnderlineStyle,
   1.324 +    eIntID_IMESelectedConvertedTextUnderline,
   1.325 +    eIntID_SpellCheckerUnderlineStyle,
   1.326 +
   1.327 +    /**
   1.328 +     * If this metric != 0, show icons in menus.
   1.329 +     */
   1.330 +    eIntID_ImagesInMenus,
   1.331 +    /**
   1.332 +     * If this metric != 0, show icons in buttons.
   1.333 +     */
   1.334 +    eIntID_ImagesInButtons,
   1.335 +    /**
   1.336 +     * If this metric != 0, support window dragging on the menubar.
   1.337 +     */
   1.338 +    eIntID_MenuBarDrag,
   1.339 +    /**
   1.340 +     * Return the appropriate WindowsThemeIdentifier for the current theme.
   1.341 +     */
   1.342 +    eIntID_WindowsThemeIdentifier,
   1.343 +    /**
   1.344 +     * Return an appropriate os version identifier.
   1.345 +     */
   1.346 +    eIntID_OperatingSystemVersionIdentifier,
   1.347 +    /**
   1.348 +     * 0: scrollbar button repeats to scroll only when cursor is on the button.
   1.349 +     * 1: scrollbar button repeats to scroll even if cursor is outside of it.
   1.350 +     */
   1.351 +    eIntID_ScrollbarButtonAutoRepeatBehavior,
   1.352 +    /**
   1.353 +     * Delay before showing a tooltip.
   1.354 +     */
   1.355 +    eIntID_TooltipDelay,
   1.356 +    /*
   1.357 +     * A Boolean value to determine whether Mac OS X Lion style swipe animations
   1.358 +     * should be used.
   1.359 +     */
   1.360 +    eIntID_SwipeAnimationEnabled,
   1.361 +
   1.362 +    /*
   1.363 +     * A Boolean value to determine whether we have a color picker available
   1.364 +     * for <input type="color"> to hook into.
   1.365 +     *
   1.366 +     * This lets us selectively enable the style for <input type="color">
   1.367 +     * based on whether it's functional or not.
   1.368 +     */
   1.369 +    eIntID_ColorPickerAvailable,
   1.370 +
   1.371 +    /*
   1.372 +     * A boolean value indicating whether or not the device has a hardware
   1.373 +     * home button. Used on gaia to determine whether a home button
   1.374 +     * is shown.
   1.375 +     */
   1.376 +     eIntID_PhysicalHomeButton,
   1.377 + 
   1.378 +     /*
   1.379 +      * Controls whether overlay scrollbars display when the user moves
   1.380 +      * the mouse in a scrollable frame.
   1.381 +      */
   1.382 +     eIntID_ScrollbarDisplayOnMouseMove,
   1.383 + 
   1.384 +     /*
   1.385 +      * Overlay scrollbar animation constants.
   1.386 +      */
   1.387 +     eIntID_ScrollbarFadeBeginDelay,
   1.388 +     eIntID_ScrollbarFadeDuration
   1.389 +  };
   1.390 +
   1.391 +  /**
   1.392 +   * Windows themes we currently detect.
   1.393 +   */
   1.394 +  enum WindowsTheme {
   1.395 +    eWindowsTheme_Generic = 0, // unrecognized theme
   1.396 +    eWindowsTheme_Classic,
   1.397 +    eWindowsTheme_Aero,
   1.398 +    eWindowsTheme_LunaBlue,
   1.399 +    eWindowsTheme_LunaOlive,
   1.400 +    eWindowsTheme_LunaSilver,
   1.401 +    eWindowsTheme_Royale,
   1.402 +    eWindowsTheme_Zune,
   1.403 +    eWindowsTheme_AeroLite
   1.404 +  };
   1.405 +
   1.406 +  /**
   1.407 +   * Operating system versions.
   1.408 +   */
   1.409 +  enum OperatingSystemVersion {
   1.410 +    eOperatingSystemVersion_WindowsXP = 0,
   1.411 +    eOperatingSystemVersion_WindowsVista,
   1.412 +    eOperatingSystemVersion_Windows7,
   1.413 +    eOperatingSystemVersion_Windows8,
   1.414 +    eOperatingSystemVersion_Unknown
   1.415 +  };
   1.416 +
   1.417 +  enum {
   1.418 +    eScrollArrow_None = 0,
   1.419 +    eScrollArrow_StartBackward = 0x1000,
   1.420 +    eScrollArrow_StartForward = 0x0100,
   1.421 +    eScrollArrow_EndBackward = 0x0010,
   1.422 +    eScrollArrow_EndForward = 0x0001
   1.423 +  };
   1.424 +
   1.425 +  enum {
   1.426 +    // single arrow at each end
   1.427 +    eScrollArrowStyle_Single =
   1.428 +      eScrollArrow_StartBackward | eScrollArrow_EndForward, 
   1.429 +    // both arrows at bottom/right, none at top/left
   1.430 +    eScrollArrowStyle_BothAtBottom =
   1.431 +      eScrollArrow_EndBackward | eScrollArrow_EndForward,
   1.432 +    // both arrows at both ends
   1.433 +    eScrollArrowStyle_BothAtEachEnd =
   1.434 +      eScrollArrow_EndBackward | eScrollArrow_EndForward |
   1.435 +      eScrollArrow_StartBackward | eScrollArrow_StartForward,
   1.436 +    // both arrows at top/left, none at bottom/right
   1.437 +    eScrollArrowStyle_BothAtTop =
   1.438 +      eScrollArrow_StartBackward | eScrollArrow_StartForward
   1.439 +  };
   1.440 +
   1.441 +  enum {
   1.442 +    eScrollThumbStyle_Normal,
   1.443 +    eScrollThumbStyle_Proportional
   1.444 +  };
   1.445 +
   1.446 +  // When modifying this list, also modify nsXPLookAndFeel::sFloatPrefs
   1.447 +  // in widget/xpwidgts/nsXPLookAndFeel.cpp.
   1.448 +  enum FloatID {
   1.449 +    eFloatID_IMEUnderlineRelativeSize,
   1.450 +    eFloatID_SpellCheckerUnderlineRelativeSize,
   1.451 +
   1.452 +    // The width/height ratio of the cursor. If used, the CaretWidth int metric
   1.453 +    // should be added to the calculated caret width.
   1.454 +    eFloatID_CaretAspectRatio
   1.455 +  };
   1.456 +
   1.457 +  // These constants must be kept in 1:1 correspondence with the
   1.458 +  // NS_STYLE_FONT_* system font constants.
   1.459 +  enum FontID {
   1.460 +    eFont_Caption = 1,     // css2
   1.461 +    eFont_Icon,
   1.462 +    eFont_Menu,
   1.463 +    eFont_MessageBox,
   1.464 +    eFont_SmallCaption,
   1.465 +    eFont_StatusBar,
   1.466 +
   1.467 +    eFont_Window,          // css3
   1.468 +    eFont_Document,
   1.469 +    eFont_Workspace,
   1.470 +    eFont_Desktop,
   1.471 +    eFont_Info,
   1.472 +    eFont_Dialog,
   1.473 +    eFont_Button,
   1.474 +    eFont_PullDownMenu,
   1.475 +    eFont_List,
   1.476 +    eFont_Field,
   1.477 +
   1.478 +    eFont_Tooltips,        // moz
   1.479 +    eFont_Widget
   1.480 +  };
   1.481 +
   1.482 +  /**
   1.483 +   * GetColor() return a native color value (might be overwritten by prefs) for
   1.484 +   * aID.  Some platforms don't return an error even if the index doesn't
   1.485 +   * match any system colors.  And also some platforms may initialize the
   1.486 +   * return value even when it returns an error.  Therefore, if you want to
   1.487 +   * use a color for the default value, you should use the other GetColor()
   1.488 +   * which returns nscolor directly.
   1.489 +   *
   1.490 +   * NOTE:
   1.491 +   *   eColorID_TextSelectForeground might return NS_DONT_CHANGE_COLOR.
   1.492 +   *   eColorID_IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
   1.493 +   *   NS_40PERCENT_FOREGROUND_COLOR.
   1.494 +   *   These values have particular meaning.  Then, they are not an actual
   1.495 +   *   color value.
   1.496 +   */
   1.497 +  static nsresult GetColor(ColorID aID, nscolor* aResult);
   1.498 +
   1.499 +  /**
   1.500 +   * This variant of GetColor() take an extra Boolean parameter that allows
   1.501 +   * the caller to ask that hard-coded color values be substituted for
   1.502 +   * native colors (used when it is desireable to hide system colors to
   1.503 +   * avoid system fingerprinting).
   1.504 +   */
   1.505 +  static nsresult GetColor(ColorID aID, bool aUseStandinsForNativeColors,
   1.506 +                           nscolor* aResult);
   1.507 +
   1.508 +  static nsresult GetColorForNativeAppearance(uint8_t aWidgetType,
   1.509 +                                          bool aIsDisabled, nscolor* aResult);
   1.510 +
   1.511 +  /**
   1.512 +   * GetInt() and GetFloat() return a int or float value for aID.  The result
   1.513 +   * might be distance, time, some flags or a int value which has particular
   1.514 +   * meaning.  See each document at definition of each ID for the detail.
   1.515 +   * The result is always 0 when they return error.  Therefore, if you want to
   1.516 +   * use a value for the default value, you should use the other method which
   1.517 +   * returns int or float directly.
   1.518 +   */
   1.519 +  static nsresult GetInt(IntID aID, int32_t* aResult);
   1.520 +  static nsresult GetFloat(FloatID aID, float* aResult);
   1.521 +
   1.522 +  static nscolor GetColor(ColorID aID, nscolor aDefault = NS_RGB(0, 0, 0))
   1.523 +  {
   1.524 +    nscolor result = NS_RGB(0, 0, 0);
   1.525 +    if (NS_FAILED(GetColor(aID, &result))) {
   1.526 +      return aDefault;
   1.527 +    }
   1.528 +    return result;
   1.529 +  }
   1.530 +
   1.531 +  static int32_t GetInt(IntID aID, int32_t aDefault = 0)
   1.532 +  {
   1.533 +    int32_t result;
   1.534 +    if (NS_FAILED(GetInt(aID, &result))) {
   1.535 +      return aDefault;
   1.536 +    }
   1.537 +    return result;
   1.538 +  }
   1.539 +
   1.540 +  static float GetFloat(FloatID aID, float aDefault = 0.0f)
   1.541 +  {
   1.542 +    float result;
   1.543 +    if (NS_FAILED(GetFloat(aID, &result))) {
   1.544 +      return aDefault;
   1.545 +    }
   1.546 +    return result;
   1.547 +  }
   1.548 +
   1.549 +  /**
   1.550 +   * Retrieve the name and style of a system-theme font.  Returns true
   1.551 +   * if the system theme specifies this font, false if a default should
   1.552 +   * be used.  In the latter case neither aName nor aStyle is modified.
   1.553 +   *
   1.554 +   * @param aID    Which system-theme font is wanted.
   1.555 +   * @param aName  The name of the font to use.
   1.556 +   * @param aStyle Styling to apply to the font.
   1.557 +   * @param aDevPixPerCSSPixel  Ratio of device pixels to CSS pixels
   1.558 +   */
   1.559 +  static bool GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle,
   1.560 +                      float aDevPixPerCSSPixel);
   1.561 +
   1.562 +  /**
   1.563 +   * GetPasswordCharacter() returns a unicode character which should be used
   1.564 +   * for a masked character in password editor.  E.g., '*'.
   1.565 +   */
   1.566 +  static char16_t GetPasswordCharacter();
   1.567 +
   1.568 +  /**
   1.569 +   * If the latest character in password field shouldn't be hidden by the
   1.570 +   * result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
   1.571 +   * Otherwise, FALSE.
   1.572 +   */
   1.573 +  static bool GetEchoPassword();
   1.574 +
   1.575 +  /**
   1.576 +   * The millisecond to mask password value.
   1.577 +   * This value is only valid when GetEchoPassword() returns true.
   1.578 +   */
   1.579 +  static uint32_t GetPasswordMaskDelay();
   1.580 +
   1.581 +  /**
   1.582 +   * When system look and feel is changed, Refresh() must be called.  Then,
   1.583 +   * cached data would be released.
   1.584 +   */
   1.585 +  static void Refresh();
   1.586 +};
   1.587 +
   1.588 +} // namespace mozilla
   1.589 +
   1.590 +// On the Mac, GetColor(eColorID_TextSelectForeground, color) returns this
   1.591 +// constant to specify that the foreground color should not be changed
   1.592 +// (ie. a colored text keeps its colors  when selected).
   1.593 +// Of course if other plaforms work like the Mac, they can use it too.
   1.594 +#define NS_DONT_CHANGE_COLOR 	NS_RGB(0x01, 0x01, 0x01)
   1.595 +
   1.596 +// ---------------------------------------------------------------------
   1.597 +//  Special colors for eColorID_IME* and eColorID_SpellCheckerUnderline
   1.598 +// ---------------------------------------------------------------------
   1.599 +
   1.600 +// For background color only.
   1.601 +#define NS_TRANSPARENT                NS_RGBA(0x01, 0x00, 0x00, 0x00)
   1.602 +// For foreground color only.
   1.603 +#define NS_SAME_AS_FOREGROUND_COLOR   NS_RGBA(0x02, 0x00, 0x00, 0x00)
   1.604 +#define NS_40PERCENT_FOREGROUND_COLOR NS_RGBA(0x03, 0x00, 0x00, 0x00)
   1.605 +
   1.606 +#define NS_IS_SELECTION_SPECIAL_COLOR(c) ((c) == NS_TRANSPARENT || \
   1.607 +                                          (c) == NS_SAME_AS_FOREGROUND_COLOR || \
   1.608 +                                          (c) == NS_40PERCENT_FOREGROUND_COLOR)
   1.609 +
   1.610 +// ------------------------------------------
   1.611 +//  Bits for eIntID_AlertNotificationOrigin
   1.612 +// ------------------------------------------
   1.613 +
   1.614 +#define NS_ALERT_HORIZONTAL 1
   1.615 +#define NS_ALERT_LEFT       2
   1.616 +#define NS_ALERT_TOP        4
   1.617 +
   1.618 +#endif /* __LookAndFeel */

mercurial