1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef MOZILLA_INTERNAL_API
10 #error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
23 // When modifying this list, also modify nsXPLookAndFeel::sColorPrefs
24 // in widget/xpwidgts/nsXPLookAndFeel.cpp.
27 // WARNING : NO NEGATIVE VALUE IN THIS ENUMERATION
28 // see patch in bug 57757 for more information
30 eColorID_WindowBackground
,
31 eColorID_WindowForeground
,
32 eColorID_WidgetBackground
,
33 eColorID_WidgetForeground
,
34 eColorID_WidgetSelectBackground
,
35 eColorID_WidgetSelectForeground
,
36 eColorID_Widget3DHighlight
,
37 eColorID_Widget3DShadow
,
38 eColorID_TextBackground
,
39 eColorID_TextForeground
,
40 eColorID_TextSelectBackground
,
41 eColorID_TextSelectForeground
,
42 eColorID_TextSelectBackgroundDisabled
,
43 eColorID_TextSelectBackgroundAttention
,
44 eColorID_TextHighlightBackground
,
45 eColorID_TextHighlightForeground
,
47 eColorID_IMERawInputBackground
,
48 eColorID_IMERawInputForeground
,
49 eColorID_IMERawInputUnderline
,
50 eColorID_IMESelectedRawTextBackground
,
51 eColorID_IMESelectedRawTextForeground
,
52 eColorID_IMESelectedRawTextUnderline
,
53 eColorID_IMEConvertedTextBackground
,
54 eColorID_IMEConvertedTextForeground
,
55 eColorID_IMEConvertedTextUnderline
,
56 eColorID_IMESelectedConvertedTextBackground
,
57 eColorID_IMESelectedConvertedTextForeground
,
58 eColorID_IMESelectedConvertedTextUnderline
,
60 eColorID_SpellCheckerUnderline
,
62 // New CSS 2 color definitions
63 eColorID_activeborder
,
64 eColorID_activecaption
,
65 eColorID_appworkspace
,
68 eColorID_buttonhighlight
,
69 eColorID_buttonshadow
,
74 eColorID_highlighttext
,
75 eColorID_inactiveborder
,
76 eColorID_inactivecaption
,
77 eColorID_inactivecaptiontext
,
78 eColorID_infobackground
,
83 eColorID_threeddarkshadow
,
85 eColorID_threedhighlight
,
86 eColorID_threedlightshadow
,
87 eColorID_threedshadow
,
92 eColorID__moz_buttondefault
,
93 // Colors which will hopefully become CSS3
95 eColorID__moz_fieldtext
,
97 eColorID__moz_dialogtext
,
98 // used to highlight valid regions to drop something onto
99 eColorID__moz_dragtargetzone
,
101 // used to cell text background, selected but not focus
102 eColorID__moz_cellhighlight
,
103 // used to cell text, selected but not focus
104 eColorID__moz_cellhighlighttext
,
105 // used to html select cell text background, selected but not focus
106 eColorID__moz_html_cellhighlight
,
107 // used to html select cell text, selected but not focus
108 eColorID__moz_html_cellhighlighttext
,
109 // used to button text background, when mouse is over
110 eColorID__moz_buttonhoverface
,
111 // used to button text, when mouse is over
112 eColorID__moz_buttonhovertext
,
113 // used to menu item background, when mouse is over
114 eColorID__moz_menuhover
,
115 // used to menu item text, when mouse is over
116 eColorID__moz_menuhovertext
,
117 // used to menu bar item text
118 eColorID__moz_menubartext
,
119 // used to menu bar item text, when mouse is over
120 eColorID__moz_menubarhovertext
,
121 // On platforms where these colors are the same as
122 // -moz-field, use -moz-fieldtext as foreground color
123 eColorID__moz_eventreerow
,
124 eColorID__moz_oddtreerow
,
126 // colors needed by the Mac OS X theme
128 // background color of chrome toolbars in active windows
129 eColorID__moz_mac_chrome_active
,
130 // background color of chrome toolbars in inactive windows
131 eColorID__moz_mac_chrome_inactive
,
132 //ring around text fields and lists
133 eColorID__moz_mac_focusring
,
134 //colour used when mouse is over a menu item
135 eColorID__moz_mac_menuselect
,
136 //colour used to do shadows on menu items
137 eColorID__moz_mac_menushadow
,
138 // color used to display text for disabled menu items
139 eColorID__moz_mac_menutextdisable
,
140 //colour used to display text while mouse is over a menu item
141 eColorID__moz_mac_menutextselect
,
142 // text color of disabled text on toolbars
143 eColorID__moz_mac_disabledtoolbartext
,
144 //inactive light hightlight
145 eColorID__moz_mac_secondaryhighlight
,
150 eColorID__moz_win_mediatext
,
151 // communications rebar text
152 eColorID__moz_win_communicationstext
,
154 // Hyperlink color extracted from the system, not affected by the
155 // browser.anchor_color user pref.
156 // There is no OS-specified safe background color for this text,
157 // but it is used regularly within Windows and the Gnome DE on Dialog and
159 eColorID__moz_nativehyperlinktext
,
162 eColorID__moz_comboboxtext
,
163 eColorID__moz_combobox
,
165 // keep this one last, please
169 // When modifying this list, also modify nsXPLookAndFeel::sIntPrefs
170 // in widget/xpwidgts/nsXPLookAndFeel.cpp.
172 // default, may be overriden by OS
173 eIntID_CaretBlinkTime
,
174 // pixel width of caret
176 // show the caret when text is selected?
177 eIntID_ShowCaretDuringSelection
,
178 // select textfields when focused via tab/accesskey?
179 eIntID_SelectTextfieldsOnKeyFocus
,
180 // delay before submenus open
182 // can popups overlap menu/task bar?
183 eIntID_MenusCanOverlapOSBar
,
184 // should overlay scrollbars be used?
185 eIntID_UseOverlayScrollbars
,
186 // allow H and V overlay scrollbars to overlap?
187 eIntID_AllowOverlayScrollbarsOverlap
,
188 // show/hide scrollbars based on activity
189 eIntID_ShowHideScrollbars
,
190 // skip navigating to disabled menu item?
191 eIntID_SkipNavigatingDisabledMenuItem
,
192 // begin a drag if the mouse is moved further than the threshold while the
194 eIntID_DragThresholdX
,
195 eIntID_DragThresholdY
,
196 // Accessibility theme being used?
197 eIntID_UseAccessibilityTheme
,
199 // position of scroll arrows in a scrollbar
200 eIntID_ScrollArrowStyle
,
201 // is scroll thumb proportional or fixed?
202 eIntID_ScrollSliderStyle
,
204 // each button can take one of four values:
205 eIntID_ScrollButtonLeftMouseButtonAction
,
206 // 0 - scrolls one line, 1 - scrolls one page
207 eIntID_ScrollButtonMiddleMouseButtonAction
,
208 // 2 - scrolls to end, 3 - button ignored
209 eIntID_ScrollButtonRightMouseButtonAction
,
211 // delay for opening spring loaded folders
212 eIntID_TreeOpenDelay
,
213 // delay for closing spring loaded folders
214 eIntID_TreeCloseDelay
,
215 // delay for triggering the tree scrolling
216 eIntID_TreeLazyScrollDelay
,
217 // delay for scrolling the tree
218 eIntID_TreeScrollDelay
,
219 // the maximum number of lines to be scrolled at ones
220 eIntID_TreeScrollLinesMax
,
221 // What type of tab-order to use
222 eIntID_TabFocusModel
,
223 // Should menu items blink when they're chosen?
224 eIntID_ChosenMenuItemsShouldBlink
,
227 * A Boolean value to determine whether the Windows default theme is
230 * The value of this metric is not used on other platforms. These platforms
231 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
233 eIntID_WindowsDefaultTheme
,
236 * A Boolean value to determine whether the DWM compositor is being used
238 * This metric is not used on non-Windows platforms. These platforms
239 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
241 eIntID_DWMCompositor
,
244 * A Boolean value to determine whether Windows is themed (Classic vs.
247 * This is Windows-specific and is not implemented on other platforms
248 * (will return the default of NS_ERROR_FAILURE).
250 eIntID_WindowsClassic
,
253 * A Boolean value to determine whether the current Windows desktop theme
254 * supports Aero Glass.
256 * This is Windows-specific and is not implemented on other platforms
257 * (will return the default of NS_ERROR_FAILURE).
262 * A Boolean value to determine whether the device is a touch enabled
263 * device. Currently this is only supported by the Windows 7 Touch API.
265 * Platforms that do not support this metric should return
266 * NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
271 * A Boolean value to determine whether the Mac graphite theme is
274 * The value of this metric is not used on other platforms. These platforms
275 * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
277 eIntID_MacGraphiteTheme
,
280 * A Boolean value to determine whether the Mac OS X Lion-specific theming
283 * The value of this metric is not used on non-Mac platforms. These
284 * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
290 * eIntID_AlertNotificationOrigin indicates from which corner of the
291 * screen alerts slide in, and from which direction (horizontal/vertical).
292 * 0, the default, represents bottom right, sliding vertically.
293 * Use any bitwise combination of the following constants:
294 * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
304 eIntID_AlertNotificationOrigin
,
307 * If true, clicking on a scrollbar (not as in dragging the thumb) defaults
308 * to scrolling the view corresponding to the clicked point. Otherwise, we
309 * only do so if the scrollbar is clicked using the middle mouse button or
310 * if shift is pressed when the scrollbar is clicked.
312 eIntID_ScrollToClick
,
315 * IME and spell checker underline styles, the values should be
316 * NS_DECORATION_LINE_STYLE_*. They are defined below.
318 eIntID_IMERawInputUnderlineStyle
,
319 eIntID_IMESelectedRawTextUnderlineStyle
,
320 eIntID_IMEConvertedTextUnderlineStyle
,
321 eIntID_IMESelectedConvertedTextUnderline
,
322 eIntID_SpellCheckerUnderlineStyle
,
325 * If this metric != 0, show icons in menus.
327 eIntID_ImagesInMenus
,
329 * If this metric != 0, show icons in buttons.
331 eIntID_ImagesInButtons
,
333 * If this metric != 0, support window dragging on the menubar.
337 * Return the appropriate WindowsThemeIdentifier for the current theme.
339 eIntID_WindowsThemeIdentifier
,
341 * Return an appropriate os version identifier.
343 eIntID_OperatingSystemVersionIdentifier
,
345 * 0: scrollbar button repeats to scroll only when cursor is on the button.
346 * 1: scrollbar button repeats to scroll even if cursor is outside of it.
348 eIntID_ScrollbarButtonAutoRepeatBehavior
,
350 * Delay before showing a tooltip.
354 * A Boolean value to determine whether Mac OS X Lion style swipe animations
357 eIntID_SwipeAnimationEnabled
,
360 * A boolean value indicating whether or not the device has a hardware
361 * home button. Used on gaia to determine whether a home button
364 eIntID_PhysicalHomeButton
,
367 * Controls whether overlay scrollbars display when the user moves
368 * the mouse in a scrollable frame.
370 eIntID_ScrollbarDisplayOnMouseMove
,
373 * Overlay scrollbar animation constants.
375 eIntID_ScrollbarFadeBeginDelay
,
376 eIntID_ScrollbarFadeDuration
380 * Windows themes we currently detect.
383 eWindowsTheme_Generic
= 0, // unrecognized theme
384 eWindowsTheme_Classic
,
386 eWindowsTheme_LunaBlue
,
387 eWindowsTheme_LunaOlive
,
388 eWindowsTheme_LunaSilver
,
389 eWindowsTheme_Royale
,
391 eWindowsTheme_AeroLite
395 * Operating system versions.
397 enum OperatingSystemVersion
{
398 eOperatingSystemVersion_WindowsXP
= 0,
399 eOperatingSystemVersion_WindowsVista
,
400 eOperatingSystemVersion_Windows7
,
401 eOperatingSystemVersion_Windows8
,
402 eOperatingSystemVersion_Unknown
406 eScrollArrow_None
= 0,
407 eScrollArrow_StartBackward
= 0x1000,
408 eScrollArrow_StartForward
= 0x0100,
409 eScrollArrow_EndBackward
= 0x0010,
410 eScrollArrow_EndForward
= 0x0001
414 // single arrow at each end
415 eScrollArrowStyle_Single
=
416 eScrollArrow_StartBackward
| eScrollArrow_EndForward
,
417 // both arrows at bottom/right, none at top/left
418 eScrollArrowStyle_BothAtBottom
=
419 eScrollArrow_EndBackward
| eScrollArrow_EndForward
,
420 // both arrows at both ends
421 eScrollArrowStyle_BothAtEachEnd
=
422 eScrollArrow_EndBackward
| eScrollArrow_EndForward
|
423 eScrollArrow_StartBackward
| eScrollArrow_StartForward
,
424 // both arrows at top/left, none at bottom/right
425 eScrollArrowStyle_BothAtTop
=
426 eScrollArrow_StartBackward
| eScrollArrow_StartForward
430 eScrollThumbStyle_Normal
,
431 eScrollThumbStyle_Proportional
434 // When modifying this list, also modify nsXPLookAndFeel::sFloatPrefs
435 // in widget/xpwidgts/nsXPLookAndFeel.cpp.
437 eFloatID_IMEUnderlineRelativeSize
,
438 eFloatID_SpellCheckerUnderlineRelativeSize
,
440 // The width/height ratio of the cursor. If used, the CaretWidth int metric
441 // should be added to the calculated caret width.
442 eFloatID_CaretAspectRatio
445 // These constants must be kept in 1:1 correspondence with the
446 // NS_STYLE_FONT_* system font constants.
448 eFont_Caption
= 1, // css2
455 eFont_Window
, // css3
466 eFont_Tooltips
, // moz
471 * GetColor() return a native color value (might be overwritten by prefs) for
472 * aID. Some platforms don't return an error even if the index doesn't
473 * match any system colors. And also some platforms may initialize the
474 * return value even when it returns an error. Therefore, if you want to
475 * use a color for the default value, you should use the other GetColor()
476 * which returns nscolor directly.
479 * eColorID_TextSelectForeground might return NS_DONT_CHANGE_COLOR.
480 * eColorID_IME* might return NS_TRANSPARENT, NS_SAME_AS_FOREGROUND_COLOR or
481 * NS_40PERCENT_FOREGROUND_COLOR.
482 * These values have particular meaning. Then, they are not an actual
485 static nsresult
GetColor(ColorID aID
, nscolor
* aResult
);
488 * GetInt() and GetFloat() return a int or float value for aID. The result
489 * might be distance, time, some flags or a int value which has particular
490 * meaning. See each document at definition of each ID for the detail.
491 * The result is always 0 when they return error. Therefore, if you want to
492 * use a value for the default value, you should use the other method which
493 * returns int or float directly.
495 static nsresult
GetInt(IntID aID
, int32_t* aResult
);
496 static nsresult
GetFloat(FloatID aID
, float* aResult
);
498 static nscolor
GetColor(ColorID aID
, nscolor aDefault
= NS_RGB(0, 0, 0))
500 nscolor result
= NS_RGB(0, 0, 0);
501 if (NS_FAILED(GetColor(aID
, &result
))) {
507 static int32_t GetInt(IntID aID
, int32_t aDefault
= 0)
510 if (NS_FAILED(GetInt(aID
, &result
))) {
516 static float GetFloat(FloatID aID
, float aDefault
= 0.0f
)
519 if (NS_FAILED(GetFloat(aID
, &result
))) {
526 * Retrieve the name and style of a system-theme font. Returns true
527 * if the system theme specifies this font, false if a default should
528 * be used. In the latter case neither aName nor aStyle is modified.
530 * @param aID Which system-theme font is wanted.
531 * @param aName The name of the font to use.
532 * @param aStyle Styling to apply to the font.
533 * @param aDevPixPerCSSPixel Ratio of device pixels to CSS pixels
535 static bool GetFont(FontID aID
, nsString
& aName
, gfxFontStyle
& aStyle
,
536 float aDevPixPerCSSPixel
);
539 * GetPasswordCharacter() returns a unicode character which should be used
540 * for a masked character in password editor. E.g., '*'.
542 static PRUnichar
GetPasswordCharacter();
545 * If the latest character in password field shouldn't be hidden by the
546 * result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
549 static bool GetEchoPassword();
552 * The millisecond to mask password value.
553 * This value is only valid when GetEchoPassword() returns true.
555 static uint32_t GetPasswordMaskDelay();
558 * When system look and feel is changed, Refresh() must be called. Then,
559 * cached data would be released.
561 static void Refresh();
564 } // namespace mozilla
566 // On the Mac, GetColor(eColorID_TextSelectForeground, color) returns this
567 // constant to specify that the foreground color should not be changed
568 // (ie. a colored text keeps its colors when selected).
569 // Of course if other plaforms work like the Mac, they can use it too.
570 #define NS_DONT_CHANGE_COLOR NS_RGB(0x01, 0x01, 0x01)
572 // ---------------------------------------------------------------------
573 // Special colors for eColorID_IME* and eColorID_SpellCheckerUnderline
574 // ---------------------------------------------------------------------
576 // For background color only.
577 #define NS_TRANSPARENT NS_RGBA(0x01, 0x00, 0x00, 0x00)
578 // For foreground color only.
579 #define NS_SAME_AS_FOREGROUND_COLOR NS_RGBA(0x02, 0x00, 0x00, 0x00)
580 #define NS_40PERCENT_FOREGROUND_COLOR NS_RGBA(0x03, 0x00, 0x00, 0x00)
582 #define NS_IS_SELECTION_SPECIAL_COLOR(c) ((c) == NS_TRANSPARENT || \
583 (c) == NS_SAME_AS_FOREGROUND_COLOR || \
584 (c) == NS_40PERCENT_FOREGROUND_COLOR)
586 // ------------------------------------------
587 // Bits for eIntID_AlertNotificationOrigin
588 // ------------------------------------------
590 #define NS_ALERT_HORIZONTAL 1
591 #define NS_ALERT_LEFT 2
592 #define NS_ALERT_TOP 4
594 #endif /* __LookAndFeel */