2001-11-06 02:41:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-09-28 20:14:13 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-07-29 18:55:25 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-07-29 18:55:25 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-07-29 18:55:25 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-01-21 21:56:09 +00:00
|
|
|
* Michael Lowe <michael.lowe@bigfoot.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-07-29 18:55:25 +00:00
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
2000-03-30 23:02:31 +00:00
|
|
|
#include "nsXPLookAndFeel.h"
|
1999-01-21 23:59:14 +00:00
|
|
|
#include <windows.h>
|
2001-05-25 14:48:31 +00:00
|
|
|
#include "nsWindow.h"
|
1998-07-29 18:55:25 +00:00
|
|
|
|
2001-11-06 02:41:04 +00:00
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
1998-09-14 20:40:49 +00:00
|
|
|
{
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-11-06 02:41:04 +00:00
|
|
|
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
|
1998-07-29 18:55:25 +00:00
|
|
|
{
|
1998-12-21 16:53:49 +00:00
|
|
|
nsresult res = NS_OK;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
int idx;
|
|
|
|
switch (aID) {
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_WindowBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_WindowForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_WidgetBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_WidgetForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_WidgetSelectBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_WidgetSelectForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_Widget3DHighlight:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_Widget3DShadow:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_TextBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_TextForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_TextSelectBackground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eColor_TextSelectForeground:
|
1998-07-29 18:55:25 +00:00
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
1999-09-10 18:30:55 +00:00
|
|
|
|
|
|
|
// New CSS 2 Color definitions
|
|
|
|
case eColor_activeborder:
|
|
|
|
idx = COLOR_ACTIVEBORDER;
|
|
|
|
break;
|
|
|
|
case eColor_activecaption:
|
|
|
|
idx = COLOR_ACTIVECAPTION;
|
|
|
|
break;
|
|
|
|
case eColor_appworkspace:
|
1999-10-24 03:03:38 +00:00
|
|
|
idx = COLOR_APPWORKSPACE;
|
1999-09-10 18:30:55 +00:00
|
|
|
break;
|
|
|
|
case eColor_background:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_BACKGROUND;
|
1999-09-10 18:30:55 +00:00
|
|
|
break;
|
|
|
|
case eColor_buttonface:
|
|
|
|
idx = COLOR_BTNFACE;
|
|
|
|
break;
|
|
|
|
case eColor_buttonhighlight:
|
|
|
|
idx = COLOR_BTNHIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_buttonshadow:
|
|
|
|
idx = COLOR_BTNSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_buttontext:
|
|
|
|
idx = COLOR_BTNTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_captiontext:
|
|
|
|
idx = COLOR_CAPTIONTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_graytext:
|
|
|
|
idx = COLOR_GRAYTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_highlight:
|
|
|
|
idx = COLOR_HIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_highlighttext:
|
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_inactiveborder:
|
|
|
|
idx = COLOR_INACTIVEBORDER;
|
|
|
|
break;
|
|
|
|
case eColor_inactivecaption:
|
|
|
|
idx = COLOR_INACTIVECAPTION;
|
|
|
|
break;
|
|
|
|
case eColor_inactivecaptiontext:
|
|
|
|
idx = COLOR_INACTIVECAPTIONTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_infobackground:
|
|
|
|
idx = COLOR_INFOBK;
|
|
|
|
break;
|
|
|
|
case eColor_infotext:
|
|
|
|
idx = COLOR_INFOTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_menu:
|
|
|
|
idx = COLOR_MENU;
|
|
|
|
break;
|
|
|
|
case eColor_menutext:
|
|
|
|
idx = COLOR_MENUTEXT;
|
|
|
|
break;
|
|
|
|
case eColor_scrollbar:
|
|
|
|
idx = COLOR_SCROLLBAR;
|
|
|
|
break;
|
|
|
|
case eColor_threeddarkshadow:
|
|
|
|
idx = COLOR_3DDKSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_threedface:
|
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
|
|
|
case eColor_threedhighlight:
|
|
|
|
idx = COLOR_3DHIGHLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_threedlightshadow:
|
|
|
|
idx = COLOR_3DLIGHT;
|
|
|
|
break;
|
|
|
|
case eColor_threedshadow:
|
|
|
|
idx = COLOR_3DSHADOW;
|
|
|
|
break;
|
|
|
|
case eColor_window:
|
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
case eColor_windowframe:
|
|
|
|
idx = COLOR_WINDOWFRAME;
|
|
|
|
break;
|
|
|
|
case eColor_windowtext:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2000-10-04 00:38:03 +00:00
|
|
|
case eColor__moz_field:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
case eColor__moz_fieldtext:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
|
|
|
case eColor__moz_dialog:
|
|
|
|
idx = COLOR_3DFACE;
|
|
|
|
break;
|
|
|
|
case eColor__moz_dialogtext:
|
|
|
|
idx = COLOR_WINDOWTEXT;
|
|
|
|
break;
|
2000-12-05 21:48:38 +00:00
|
|
|
case eColor__moz_dragtargetzone:
|
|
|
|
idx = COLOR_HIGHLIGHTTEXT;
|
2001-04-17 00:46:07 +00:00
|
|
|
break;
|
1998-07-29 18:55:25 +00:00
|
|
|
default:
|
2001-04-17 00:46:07 +00:00
|
|
|
idx = COLOR_WINDOW;
|
1998-07-29 18:55:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-25 14:48:31 +00:00
|
|
|
DWORD color = ::GetSysColor(idx);
|
|
|
|
aColor = COLOREF_2_NSRGB(color);
|
1998-07-29 18:55:25 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
return res;
|
1998-09-01 20:54:39 +00:00
|
|
|
}
|
2001-04-17 00:46:07 +00:00
|
|
|
|
1998-09-01 20:54:39 +00:00
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
1998-07-29 18:55:25 +00:00
|
|
|
{
|
2001-11-06 02:41:04 +00:00
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
switch (aID) {
|
1998-09-01 20:54:39 +00:00
|
|
|
case eMetric_WindowTitleHeight:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CYCAPTION);
|
|
|
|
break;
|
|
|
|
case eMetric_WindowBorderWidth:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CXFRAME);
|
1998-07-29 18:55:25 +00:00
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eMetric_WindowBorderHeight:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CYFRAME);
|
1998-07-29 18:55:25 +00:00
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eMetric_Widget3DBorder:
|
|
|
|
aMetric = ::GetSystemMetrics(SM_CXEDGE);
|
1998-07-29 18:55:25 +00:00
|
|
|
break;
|
1999-09-03 14:15:16 +00:00
|
|
|
case eMetric_TextFieldBorder:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
1998-09-01 20:54:39 +00:00
|
|
|
case eMetric_TextFieldHeight:
|
|
|
|
aMetric = 24;
|
1998-07-29 18:55:25 +00:00
|
|
|
break;
|
1998-12-21 16:53:49 +00:00
|
|
|
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
|
|
|
|
aMetric = 10;
|
|
|
|
break;
|
|
|
|
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
|
|
|
|
aMetric = 8;
|
|
|
|
break;
|
1999-02-11 00:51:36 +00:00
|
|
|
case eMetric_CheckboxSize:
|
|
|
|
aMetric = 12;
|
|
|
|
break;
|
|
|
|
case eMetric_RadioboxSize:
|
|
|
|
aMetric = 12;
|
|
|
|
break;
|
1998-12-21 16:53:49 +00:00
|
|
|
case eMetric_TextHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
|
|
|
case eMetric_TextVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_TextShouldUseVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_ListHorizontalInsideMinimumPadding:
|
|
|
|
aMetric = 3;
|
|
|
|
break;
|
|
|
|
case eMetric_ListShouldUseVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
|
|
|
case eMetric_ListVerticalInsidePadding:
|
|
|
|
aMetric = 0;
|
|
|
|
break;
|
1999-07-14 22:16:59 +00:00
|
|
|
case eMetric_CaretBlinkTime:
|
1999-11-11 00:08:49 +00:00
|
|
|
aMetric = (PRInt32)::GetCaretBlinkTime();
|
1999-07-14 22:16:59 +00:00
|
|
|
break;
|
2000-07-28 22:12:45 +00:00
|
|
|
case eMetric_SingleLineCaretWidth:
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
|
|
|
case eMetric_MultiLineCaretWidth:
|
|
|
|
aMetric = 2;
|
1999-07-14 22:16:59 +00:00
|
|
|
break;
|
2001-04-05 19:53:13 +00:00
|
|
|
case eMetric_ShowCaretDuringSelection:
|
2001-06-20 06:30:32 +00:00
|
|
|
aMetric = 0;
|
2000-12-28 03:27:23 +00:00
|
|
|
break;
|
2002-10-05 15:39:33 +00:00
|
|
|
case eMetric_SelectTextfieldsOnKeyFocus:
|
|
|
|
// Select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
2000-01-21 21:56:09 +00:00
|
|
|
case eMetric_SubmenuDelay:
|
|
|
|
{
|
|
|
|
static PRInt32 sSubmenuDelay = -1;
|
|
|
|
|
|
|
|
if (sSubmenuDelay == -1) {
|
|
|
|
HKEY key;
|
|
|
|
char value[100];
|
|
|
|
DWORD length, type;
|
|
|
|
LONG result;
|
|
|
|
|
2000-02-13 07:20:22 +00:00
|
|
|
sSubmenuDelay = 300;
|
2000-01-21 21:56:09 +00:00
|
|
|
|
|
|
|
result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
"Control Panel\\Desktop", 0, KEY_READ, &key);
|
|
|
|
|
|
|
|
if (result == ERROR_SUCCESS) {
|
|
|
|
length = sizeof(value);
|
|
|
|
|
|
|
|
result = ::RegQueryValueEx(key, "MenuShowDelay",
|
|
|
|
NULL, &type, (LPBYTE)&value, &length);
|
|
|
|
|
|
|
|
::RegCloseKey(key);
|
|
|
|
|
2000-02-15 11:51:12 +00:00
|
|
|
if (result == ERROR_SUCCESS) {
|
|
|
|
PRInt32 errorCode;
|
2000-04-26 01:13:55 +00:00
|
|
|
nsString str; str.AssignWithConversion(value);
|
2000-02-15 11:51:12 +00:00
|
|
|
PRInt32 submenuDelay = str.ToInteger(&errorCode);
|
|
|
|
if (errorCode == NS_OK) {
|
|
|
|
sSubmenuDelay = submenuDelay;
|
|
|
|
}
|
2000-01-21 21:56:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aMetric = sSubmenuDelay;
|
|
|
|
}
|
|
|
|
break;
|
2000-03-22 02:55:12 +00:00
|
|
|
case eMetric_MenusCanOverlapOSBar:
|
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
|
|
|
aMetric = 1;
|
|
|
|
break;
|
2000-11-16 22:25:45 +00:00
|
|
|
case eMetric_DragFullWindow:
|
|
|
|
{
|
|
|
|
static PRInt32 sDragFullWindow = -1;
|
|
|
|
if (sDragFullWindow == -1) {
|
|
|
|
HKEY key;
|
|
|
|
char value[100];
|
|
|
|
DWORD length, type;
|
|
|
|
LONG result;
|
|
|
|
|
|
|
|
|
|
|
|
result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
"Control Panel\\Desktop", 0, KEY_READ, &key);
|
|
|
|
|
|
|
|
if (result == ERROR_SUCCESS) {
|
|
|
|
length = sizeof(value);
|
|
|
|
|
|
|
|
result = ::RegQueryValueEx(key, "DragFullWindows",
|
|
|
|
NULL, &type, (LPBYTE)&value, &length);
|
|
|
|
|
|
|
|
::RegCloseKey(key);
|
|
|
|
|
|
|
|
if (result == ERROR_SUCCESS) {
|
|
|
|
PRInt32 errorCode;
|
|
|
|
nsString str; str.AssignWithConversion(value);
|
|
|
|
sDragFullWindow = str.ToInteger(&errorCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aMetric = sDragFullWindow ? 1 : 0;
|
|
|
|
}
|
|
|
|
break;
|
2000-03-22 02:55:12 +00:00
|
|
|
|
2000-11-30 01:51:14 +00:00
|
|
|
case eMetric_ScrollArrowStyle:
|
|
|
|
aMetric = eMetric_ScrollArrowStyleSingle;
|
|
|
|
break;
|
|
|
|
case eMetric_ScrollSliderStyle:
|
|
|
|
aMetric = eMetric_ScrollThumbStyleProportional;
|
|
|
|
break;
|
|
|
|
|
1998-07-29 18:55:25 +00:00
|
|
|
default:
|
2000-11-30 01:51:14 +00:00
|
|
|
aMetric = 0;
|
1998-09-01 20:54:39 +00:00
|
|
|
res = NS_ERROR_FAILURE;
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
1998-12-21 16:53:49 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
|
|
|
|
{
|
2001-11-06 02:41:04 +00:00
|
|
|
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
switch (aID) {
|
|
|
|
case eMetricFloat_TextFieldVerticalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextFieldHorizontalInsidePadding:
|
1999-09-30 11:48:52 +00:00
|
|
|
aMetric = 1.025f;
|
1998-12-21 16:53:49 +00:00
|
|
|
break;
|
|
|
|
case eMetricFloat_TextAreaVerticalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextAreaHorizontalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ListVerticalInsidePadding:
|
|
|
|
aMetric = 0.10f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ListHorizontalInsidePadding:
|
|
|
|
aMetric = 0.40f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ButtonVerticalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_ButtonHorizontalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aMetric = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
1999-01-19 17:36:19 +00:00
|
|
|
|
1999-10-19 11:34:00 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID,
|
|
|
|
const nsMetricNavFontID aFontID,
|
|
|
|
const PRInt32 aFontSize,
|
|
|
|
nsSize &aSize)
|
|
|
|
{
|
2001-11-06 02:41:04 +00:00
|
|
|
nsresult rv = nsXPLookAndFeel::GetNavSize(aWidgetID, aFontID, aFontSize,
|
|
|
|
aSize);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return rv;
|
2000-03-30 22:42:40 +00:00
|
|
|
|
1999-10-19 11:34:00 +00:00
|
|
|
aSize.width = 0;
|
|
|
|
aSize.height = 0;
|
|
|
|
|
|
|
|
if (aFontSize < 1 || aFontSize > 7) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 kTextFieldWidths[2][7] = {
|
|
|
|
{106,147,169,211,253,338,506}, // Courier
|
|
|
|
{152,214,237,281,366,495,732} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRInt32 kTextFieldHeights[2][7] = {
|
|
|
|
{18,21,24,27,33,45,63}, // Courier
|
|
|
|
{18,21,24,27,34,48,67} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRInt32 kTextAreaWidths[2][7] = {
|
|
|
|
{121,163,184,226,268,352,520}, // Courier
|
|
|
|
{163,226,247,289,373,499,730} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
PRInt32 kTextAreaHeights[2][7] = {
|
|
|
|
{40,44,48,52,60,76,100}, // Courier
|
|
|
|
{40,44,48,52,62,80,106} // sans-serif
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (aWidgetID) {
|
|
|
|
case eMetricSize_TextField:
|
|
|
|
aSize.width = kTextFieldWidths[aFontID][aFontSize-1];
|
|
|
|
aSize.height = kTextFieldHeights[aFontID][aFontSize-1];
|
|
|
|
break;
|
|
|
|
case eMetricSize_TextArea:
|
|
|
|
aSize.width = kTextAreaWidths[aFontID][aFontSize-1];
|
|
|
|
aSize.height = kTextAreaHeights[aFontID][aFontSize-1];
|
|
|
|
break;
|
|
|
|
} //switch
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|