1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
23
* Sergei Dolgov <sergei_d@fi.tartu.ee>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#include "nsLookAndFeel.h"
43
#include <InterfaceDefs.h>
46
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
50
nsLookAndFeel::~nsLookAndFeel()
54
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
59
* There used to be an entirely separate list of these colors in
60
* nsDeviceContextBeOS::GetSystemAttribute. The colors given there
61
* were a bit different from these. If these are inaccurate, it might
62
* be worth looking at cvs history for the ones there to see if they
67
case eColor_WindowBackground:
68
aColor = NS_RGB(0xff, 0xff, 0xff);
70
case eColor_WindowForeground:
71
aColor = NS_RGB(0x00, 0x00, 0x00);
73
case eColor_WidgetBackground:
74
aColor = NS_RGB(0xdd, 0xdd, 0xdd);
76
case eColor_WidgetForeground:
77
aColor = NS_RGB(0x00, 0x00, 0x00);
79
case eColor_WidgetSelectBackground:
81
color = ui_color(B_MENU_SELECTION_BACKGROUND_COLOR);
82
aColor = NS_RGB(color.red, color.green, color.blue);
85
case eColor_WidgetSelectForeground:
86
aColor = NS_RGB(0x00, 0x00, 0x80);
88
case eColor_Widget3DHighlight:
89
aColor = NS_RGB(0xa0, 0xa0, 0xa0);
91
case eColor_Widget3DShadow:
92
aColor = NS_RGB(0x40, 0x40, 0x40);
94
case eColor_TextBackground:
95
aColor = NS_RGB(0xff, 0xff, 0xff);
97
case eColor_TextForeground:
98
aColor = NS_RGB(0x00, 0x00, 0x00);
100
case eColor_TextSelectBackground:
102
// looks good in Mozilla, though, never noticed this color in BeOS menu
103
color = ui_color(B_MENU_SELECTION_BACKGROUND_COLOR);
104
aColor = NS_RGB(color.red, color.green, color.blue);
107
case eColor_TextSelectForeground:
109
color = ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR);
110
aColor = NS_RGB(color.red, color.green, color.blue);
113
// two following colors get initialisation in XPLookAndFeel.
114
//eColor_TextSelectBackgroundDisabled,
115
//eColor_TextSelectBackgroundAttention,
118
case eColor_activeborder:
119
aColor = NS_RGB(0x88, 0x88, 0x88);
122
case eColor_activecaption:
124
color = ui_color(B_WINDOW_TAB_COLOR);
125
aColor = NS_RGB(color.red, color.green, color.blue);
129
case eColor_appworkspace:
130
aColor = NS_RGB(0xd8, 0xd8, 0xd8);
132
//incidentally, this is supposed to be the colour of the desktop, though how anyone
133
//is supposed to guess that from the name?
134
case eColor_background:
136
color = ui_color(B_DESKTOP_COLOR);
137
aColor = NS_RGB(color.red, color.green, color.blue);
140
case eColor_buttonface:
141
aColor = NS_RGB(0xdd, 0xdd, 0xdd);
143
//should be lighter of 2 possible highlight colours available
144
case eColor_buttonhighlight:
145
aColor = NS_RGB(0xff, 0xff, 0xff);
147
//darker of 2 possible shadow colours available
148
case eColor_buttonshadow:
149
aColor = NS_RGB(0x77, 0x77, 0x77);
151
case eColor_buttontext:
152
aColor = NS_RGB(0x00, 0x00, 0x00);
154
case eColor_captiontext:
155
aColor = NS_RGB(0x00, 0x00, 0x00);
157
case eColor_graytext:
158
aColor = NS_RGB(0x77, 0x77, 0x77);
160
case eColor_highlight:
162
// B_MENU_SELECTION_BACKGROUND_COLOR is used for text selection
163
// this blue colors seems more suitable
164
color = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
165
aColor = NS_RGB(color.red, color.green, color.blue);
168
case eColor_highlighttext:
170
color = ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR);
171
aColor = NS_RGB(color.red, color.green, color.blue);
174
case eColor_inactiveborder:
175
aColor = NS_RGB(0x55, 0x55, 0x55);
177
case eColor_inactivecaption:
178
aColor = NS_RGB(0xdd, 0xdd, 0xdd);
180
case eColor_inactivecaptiontext:
181
aColor = NS_RGB(0x77, 0x77, 0x77);
183
case eColor_infobackground:
185
aColor = NS_RGB(0xff, 0xff, 0xd0);
187
case eColor_infotext:
188
aColor = NS_RGB(0x00, 0x00, 0x00);
192
color = ui_color(B_MENU_BACKGROUND_COLOR);
193
aColor = NS_RGB(color.red, color.green, color.blue);
196
case eColor_menutext:
198
color = ui_color(B_MENU_ITEM_TEXT_COLOR);
199
aColor = NS_RGB(color.red, color.green, color.blue);
202
case eColor_scrollbar:
203
aColor = NS_RGB(0xaa, 0xaa, 0xaa);
205
case eColor_threeddarkshadow:
206
aColor = NS_RGB(0x77, 0x77, 0x77);
208
case eColor_threedface:
209
aColor = NS_RGB(0xdd, 0xdd, 0xdd);
211
case eColor_threedhighlight:
212
aColor = NS_RGB(0xff, 0xff, 0xff);
214
case eColor_threedlightshadow:
215
aColor = NS_RGB(0xdd, 0xdd, 0xdd);
217
case eColor_threedshadow:
218
aColor = NS_RGB(0x99, 0x99, 0x99);
221
aColor = NS_RGB(0xff, 0xff, 0xff);
223
case eColor_windowframe:
224
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
226
case eColor_windowtext:
227
aColor = NS_RGB(0x00, 0x00, 0x00);
230
case eColor__moz_field:
231
// normal widget background
232
aColor = NS_RGB(0xff, 0xff, 0xff);
234
case eColor__moz_fieldtext:
235
aColor = NS_RGB(0x00, 0x00, 0x00);
237
case eColor__moz_dialog:
238
//all bars including MenuBar
239
aColor = NS_RGB(0xdd, 0xdd, 0xdd);
241
case eColor__moz_dialogtext:
242
aColor = NS_RGB(0x00, 0x00, 0x00);
244
case eColor__moz_dragtargetzone:
245
aColor = NS_RGB(0x63, 0x63, 0xCE);
247
case eColor__moz_buttondefault:
248
aColor = NS_RGB(0x77, 0x77, 0x77);
250
case eColor_LAST_COLOR:
252
aColor = NS_RGB(0xff, 0xff, 0xff);
253
res = NS_ERROR_FAILURE;
260
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
262
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
263
if (NS_SUCCEEDED(res))
268
* There used to be an entirely separate list of these metrics in
269
* nsDeviceContextBeOS::GetSystemAttribute. The metrics given there
270
* were a bit different from these. If these are inaccurate, it might
271
* be worth looking at cvs history for the ones there to see if they
277
case eMetric_WindowTitleHeight:
278
// 2*horizontal scrollbar height
281
case eMetric_WindowBorderWidth:
284
case eMetric_WindowBorderHeight:
287
case eMetric_Widget3DBorder:
290
case eMetric_TextFieldBorder:
293
case eMetric_TextFieldHeight:
296
case eMetric_TextVerticalInsidePadding:
299
case eMetric_TextShouldUseVerticalInsidePadding:
302
case eMetric_TextHorizontalInsideMinimumPadding:
305
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
308
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
311
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
314
case eMetric_CheckboxSize:
317
case eMetric_RadioboxSize:
321
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
324
case eMetric_ListHorizontalInsideMinimumPadding:
328
case eMetric_ListShouldUseVerticalInsidePadding:
331
case eMetric_ListVerticalInsidePadding:
335
case eMetric_CaretBlinkTime:
338
case eMetric_SingleLineCaretWidth:
341
case eMetric_MultiLineCaretWidth:
344
case eMetric_ShowCaretDuringSelection:
347
case eMetric_SelectTextfieldsOnKeyFocus:
348
// Do not select textfield content when focused by kbd
349
// used by nsEventStateManager::sTextfieldSelectModel
352
case eMetric_SubmenuDelay:
355
case eMetric_MenusCanOverlapOSBar: // can popups overlap menu/task bar?
358
case eMetric_DragFullWindow:
361
case eMetric_ScrollArrowStyle:
363
aMetric = eMetric_ScrollArrowStyleBothAtEachEnd; // BeOS default
365
scroll_bar_info info;
366
if(B_OK == get_scroll_bar_info(&info) && !info.double_arrows)
368
aMetric = eMetric_ScrollArrowStyleSingle;
372
case eMetric_ScrollSliderStyle:
374
aMetric = eMetric_ScrollThumbStyleProportional; // BeOS default
376
scroll_bar_info info;
377
if(B_OK == get_scroll_bar_info(&info) && !info.proportional)
379
aMetric = eMetric_ScrollThumbStyleNormal;
383
case eMetric_TreeOpenDelay:
386
case eMetric_TreeCloseDelay:
389
case eMetric_TreeLazyScrollDelay:
392
case eMetric_TreeScrollDelay:
395
case eMetric_TreeScrollLinesMax:
400
res = NS_ERROR_FAILURE;
405
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
407
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
408
if (NS_SUCCEEDED(res))
413
case eMetricFloat_TextFieldVerticalInsidePadding:
416
case eMetricFloat_TextFieldHorizontalInsidePadding:
419
case eMetricFloat_TextAreaVerticalInsidePadding:
422
case eMetricFloat_TextAreaHorizontalInsidePadding:
425
case eMetricFloat_ListVerticalInsidePadding:
428
case eMetricFloat_ListHorizontalInsidePadding:
431
case eMetricFloat_ButtonVerticalInsidePadding:
434
case eMetricFloat_ButtonHorizontalInsidePadding:
439
res = NS_ERROR_FAILURE;