2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define INCL_WIN
|
2012-02-20 15:19:48 -08:00
|
|
|
#define INCL_WINWINDOWMGR
|
|
|
|
#define INCL_WINSHELLDATA
|
|
|
|
#define INCL_DOSNLS
|
|
|
|
#define INCL_DOSERRORS
|
2007-03-22 10:30:00 -07:00
|
|
|
#include <os2.h>
|
2012-02-20 15:19:48 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsLookAndFeel.h"
|
|
|
|
#include "nsFont.h"
|
|
|
|
#include "nsSize.h"
|
2011-03-31 05:26:49 -07:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
|
2012-02-20 15:19:48 -08:00
|
|
|
static bool bIsDBCS;
|
|
|
|
static bool bIsDBCSSet = false;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
|
|
|
|
int idx;
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WindowForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONMIDDLE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetForeground:
|
2012-02-20 15:19:48 -08:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_HILITEBACKGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_WidgetSelectForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_HILITEFOREGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DHighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_Widget3DShadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONDARK;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectBackground:
|
|
|
|
case eColorID_IMESelectedRawTextBackground:
|
|
|
|
case eColorID_IMESelectedConvertedTextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_HILITEBACKGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_TextSelectForeground:
|
|
|
|
case eColorID_IMESelectedRawTextForeground:
|
|
|
|
case eColorID_IMESelectedConvertedTextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_HILITEFOREGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputBackground:
|
|
|
|
case eColorID_IMEConvertedTextBackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputForeground:
|
|
|
|
case eColorID_IMEConvertedTextForeground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMERawInputUnderline:
|
|
|
|
case eColorID_IMEConvertedTextUnderline:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_SAME_AS_FOREGROUND_COLOR;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_IMESelectedRawTextUnderline:
|
|
|
|
case eColorID_IMESelectedConvertedTextUnderline:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_TRANSPARENT;
|
|
|
|
return NS_OK;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_SpellCheckerUnderline:
|
2009-04-03 00:26:28 -07:00
|
|
|
aColor = NS_RGB(0xff, 0, 0);
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// New CSS 2 Color definitions
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activeborder:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_ACTIVEBORDER;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_activecaption:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_ACTIVETITLETEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_appworkspace:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_APPWORKSPACE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_background:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BACKGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonface:
|
|
|
|
case eColorID__moz_buttonhoverface:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONMIDDLE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttonshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONDARK;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_buttontext:
|
|
|
|
case eColorID__moz_buttonhovertext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_MENUTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_captiontext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_graytext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_MENUDISABLEDTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlight:
|
|
|
|
case eColorID__moz_html_cellhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_HILITEBACKGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_highlighttext:
|
|
|
|
case eColorID__moz_html_cellhighlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_HILITEFOREGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactiveborder:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_INACTIVEBORDER;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaption:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_INACTIVETITLE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_inactivecaptiontext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_INACTIVETITLETEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infobackground:
|
2007-03-22 10:30:00 -07:00
|
|
|
aColor = NS_RGB( 255, 255, 228);
|
|
|
|
return res;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_infotext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menu:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_MENU;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_menutext:
|
|
|
|
case eColorID__moz_menubartext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_MENUTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_scrollbar:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_SCROLLBAR;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threeddarkshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONDARK;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedface:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONMIDDLE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONLIGHT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedlightshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONMIDDLE;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_threedshadow:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONDARK;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_window:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOW;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_windowframe:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWFRAME;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID_windowtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_eventreerow:
|
|
|
|
case eColorID__moz_oddtreerow:
|
|
|
|
case eColorID__moz_field:
|
|
|
|
case eColorID__moz_combobox:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_ENTRYFIELD;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_fieldtext:
|
|
|
|
case eColorID__moz_comboboxtext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialog:
|
|
|
|
case eColorID__moz_cellhighlight:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_DIALOGBACKGROUND;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_dialogtext:
|
|
|
|
case eColorID__moz_cellhighlighttext:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_WINDOWTEXT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_buttondefault:
|
2007-03-22 10:30:00 -07:00
|
|
|
idx = SYSCLR_BUTTONDEFAULT;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhover:
|
2007-12-28 15:34:22 -08:00
|
|
|
if (WinQuerySysColor(HWND_DESKTOP, SYSCLR_MENUHILITEBGND, 0) ==
|
|
|
|
WinQuerySysColor(HWND_DESKTOP, SYSCLR_MENU, 0)) {
|
2007-12-14 12:30:02 -08:00
|
|
|
// if this happens, we would paint menu selections unreadable
|
|
|
|
// (we are most likely on Warp3), so let's fake a dark grey
|
|
|
|
// background for the selected menu item
|
|
|
|
aColor = NS_RGB( 132, 130, 132);
|
|
|
|
return res;
|
|
|
|
} else {
|
|
|
|
idx = SYSCLR_MENUHILITEBGND;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_menuhovertext:
|
|
|
|
case eColorID__moz_menubarhovertext:
|
2007-12-28 15:34:22 -08:00
|
|
|
if (WinQuerySysColor(HWND_DESKTOP, SYSCLR_MENUHILITEBGND, 0) ==
|
|
|
|
WinQuerySysColor(HWND_DESKTOP, SYSCLR_MENU, 0)) {
|
2007-12-14 12:30:02 -08:00
|
|
|
// white text to be readable on dark grey
|
|
|
|
aColor = NS_RGB( 255, 255, 255);
|
|
|
|
return res;
|
|
|
|
} else {
|
|
|
|
idx = SYSCLR_MENUHILITE;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eColorID__moz_nativehyperlinktext:
|
2008-08-21 15:09:28 -07:00
|
|
|
aColor = NS_RGB( 0, 0, 255);
|
|
|
|
return res;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
|
|
|
idx = SYSCLR_WINDOW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
long lColor = WinQuerySysColor( HWND_DESKTOP, idx, 0);
|
|
|
|
|
|
|
|
int iRed = (lColor & RGB_RED) >> 16;
|
|
|
|
int iGreen = (lColor & RGB_GREEN) >> 8;
|
|
|
|
int iBlue = (lColor & RGB_BLUE);
|
|
|
|
|
|
|
|
aColor = NS_RGB( iRed, iGreen, iBlue);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2012-02-20 15:19:48 -08:00
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetIntImpl(IntID aID, PRInt32 &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretBlinkTime:
|
|
|
|
aResult = WinQuerySysValue( HWND_DESKTOP, SV_CURSORRATE);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_CaretWidth:
|
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ShowCaretDuringSelection:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SelectTextfieldsOnKeyFocus:
|
2007-03-22 10:30:00 -07:00
|
|
|
// Do not select textfield content when focused by kbd
|
|
|
|
// used by nsEventStateManager::sTextfieldSelectModel
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SubmenuDelay:
|
|
|
|
aResult = 300;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-12-16 01:18:48 -08:00
|
|
|
case eIntID_TooltipDelay:
|
|
|
|
aResult = 500;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MenusCanOverlapOSBar:
|
2007-03-22 10:30:00 -07:00
|
|
|
// we want XUL popups to be able to overlap the task bar.
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollArrowStyle:
|
|
|
|
aResult = eScrollArrowStyle_Single;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_ScrollSliderStyle:
|
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeOpenDelay:
|
|
|
|
aResult = 1000;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeCloseDelay:
|
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeLazyScrollDelay:
|
|
|
|
aResult = 150;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeScrollDelay:
|
|
|
|
aResult = 100;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_TreeScrollLinesMax:
|
|
|
|
aResult = 3;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_DWMCompositor:
|
|
|
|
case eIntID_WindowsClassic:
|
|
|
|
case eIntID_WindowsDefaultTheme:
|
|
|
|
case eIntID_TouchEnabled:
|
|
|
|
case eIntID_WindowsThemeIdentifier:
|
|
|
|
aResult = 0;
|
2008-04-08 11:36:53 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_MacGraphiteTheme:
|
|
|
|
case eIntID_MacLionTheme:
|
|
|
|
case eIntID_MaemoClassic:
|
|
|
|
aResult = 0;
|
2008-09-17 09:23:58 -07:00
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_IMERawInputUnderlineStyle:
|
|
|
|
case eIntID_IMEConvertedTextUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
|
2007-08-16 13:35:18 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_IMESelectedRawTextUnderlineStyle:
|
|
|
|
case eIntID_IMESelectedConvertedTextUnderline:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE;
|
2007-08-16 13:35:18 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eIntID_SpellCheckerUnderlineStyle:
|
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
|
2009-04-03 00:26:28 -07:00
|
|
|
break;
|
2011-11-17 15:41:35 -08:00
|
|
|
case eIntID_ScrollbarButtonAutoRepeatBehavior:
|
|
|
|
aResult = 0;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult
|
|
|
|
nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-08 19:27:13 -07:00
|
|
|
nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
return res;
|
|
|
|
res = NS_OK;
|
|
|
|
|
|
|
|
switch (aID) {
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_IMEUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2011-09-08 19:27:13 -07:00
|
|
|
case eFloatID_SpellCheckerUnderlineRelativeSize:
|
|
|
|
aResult = 1.0f;
|
2009-04-03 00:26:28 -07:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
2011-09-08 19:27:13 -07:00
|
|
|
aResult = -1.0;
|
2007-03-22 10:30:00 -07:00
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2012-02-20 15:19:48 -08:00
|
|
|
|
|
|
|
/* Helper function to determine if we are running on DBCS */
|
|
|
|
static bool
|
|
|
|
IsDBCS()
|
|
|
|
{
|
|
|
|
if (!bIsDBCSSet) {
|
|
|
|
APIRET rc;
|
|
|
|
COUNTRYCODE ctrycodeInfo = {0};
|
|
|
|
CHAR achDBCSInfo[12] = {0}; // DBCS environmental vector
|
|
|
|
ctrycodeInfo.country = 0; // current country
|
|
|
|
ctrycodeInfo.codepage = 0; // current codepage
|
|
|
|
|
|
|
|
rc = DosQueryDBCSEnv(sizeof(achDBCSInfo), &ctrycodeInfo, achDBCSInfo);
|
|
|
|
if (rc == NO_ERROR) {
|
|
|
|
// DBCS countries will have at least one nonzero byte in the
|
|
|
|
// first four bytes of the DBCS environmental vector
|
|
|
|
bIsDBCS = (achDBCSInfo[0] != 0 || achDBCSInfo[1] != 0 ||
|
|
|
|
achDBCSInfo[2] != 0 || achDBCSInfo[3] != 0);
|
|
|
|
} else {
|
|
|
|
bIsDBCS = false;
|
|
|
|
}
|
|
|
|
bIsDBCSSet = true;
|
|
|
|
}
|
|
|
|
return bIsDBCS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to query font from INI file */
|
|
|
|
static void
|
|
|
|
QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength)
|
|
|
|
{
|
|
|
|
ULONG ulMaxNameL = ulLength;
|
|
|
|
|
|
|
|
// We must use PrfQueryProfileData here, because some users have
|
|
|
|
// binary font data in their INI files.
|
|
|
|
if (PrfQueryProfileData(HINI_USER,
|
|
|
|
(PCSZ)"PM_SystemFonts",
|
|
|
|
(PCSZ)fontType,
|
|
|
|
fontName, &ulMaxNameL)) {
|
|
|
|
// PrfQueryProfileData does not nul-terminate for us.
|
|
|
|
fontName[ulMaxNameL] = '\0';
|
|
|
|
} else {
|
|
|
|
// If there was no entry in the INI, default to something sensible.
|
|
|
|
// Make sure to use a DBCS-capable font in a DBCS-capable environment.
|
|
|
|
if (IsDBCS()) {
|
|
|
|
strcpy(fontName, "9.WarpSans Combined");
|
|
|
|
} else {
|
|
|
|
strcpy(fontName, "9.WarpSans");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Query the font used for various CSS properties (aID) from the system.
|
|
|
|
* For OS/2, only very few fonts are defined in the system, so most of the IDs
|
|
|
|
* resolve to the same system font.
|
|
|
|
* The font queried will give back a string like
|
|
|
|
* 9.WarpSans Bold
|
|
|
|
* 12.Times New Roman Bold Italic
|
|
|
|
* 10.Times New Roman.Strikeout.Underline
|
|
|
|
* 20.Bitstream Vera Sans Mono Obli
|
|
|
|
* (always restricted to 32 chars, at least before the second dot)
|
|
|
|
* We use the value before the dot as the font size (in pt, and convert it to
|
|
|
|
* px using the screen resolution) and then try to use the rest of the string
|
|
|
|
* to determine the font style from it.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
nsLookAndFeel::GetFont(FontID aID, nsString& aFontName,
|
|
|
|
gfxFontStyle& aFontStyle)
|
|
|
|
{
|
|
|
|
char szFontNameSize[MAXNAMEL];
|
|
|
|
|
|
|
|
switch (aID)
|
|
|
|
{
|
|
|
|
case eFont_Icon:
|
|
|
|
QueryFontFromINI("IconText", szFontNameSize, MAXNAMEL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Menu:
|
|
|
|
QueryFontFromINI("Menus", szFontNameSize, MAXNAMEL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eFont_Caption:
|
|
|
|
case eFont_MessageBox:
|
|
|
|
case eFont_SmallCaption:
|
|
|
|
case eFont_StatusBar:
|
|
|
|
case eFont_Tooltips:
|
|
|
|
case eFont_Widget:
|
|
|
|
|
|
|
|
case eFont_Window: // css3
|
|
|
|
case eFont_Document:
|
|
|
|
case eFont_Workspace:
|
|
|
|
case eFont_Desktop:
|
|
|
|
case eFont_Info:
|
|
|
|
case eFont_Dialog:
|
|
|
|
case eFont_Button:
|
|
|
|
case eFont_PullDownMenu:
|
|
|
|
case eFont_List:
|
|
|
|
case eFont_Field:
|
|
|
|
QueryFontFromINI("WindowText", szFontNameSize, MAXNAMEL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_WARNING("None of the listed font types, using WarpSans");
|
|
|
|
if (!IsDBCS()) {
|
|
|
|
strcpy(szFontNameSize, "9.WarpSans");
|
|
|
|
} else {
|
|
|
|
strcpy(szFontNameSize, "9.WarpSans Combined");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *szFacename = strchr(szFontNameSize, '.');
|
|
|
|
if (!szFacename || (*(szFacename++) == '\0'))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// local DPI for size will be taken into account below
|
|
|
|
aFontStyle.size = atof(szFontNameSize);
|
|
|
|
|
|
|
|
// determine DPI resolution of screen device to compare compute
|
|
|
|
// font size in pixels
|
|
|
|
HPS ps = WinGetScreenPS(HWND_DESKTOP);
|
|
|
|
HDC dc = GpiQueryDevice(ps);
|
|
|
|
// effective vertical resolution in DPI
|
|
|
|
LONG vertScreenRes = 120; // assume 120 dpi as default
|
|
|
|
DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &vertScreenRes);
|
|
|
|
WinReleasePS(ps);
|
|
|
|
|
|
|
|
// now scale to make pixels from points (1 pt = 1/72in)
|
|
|
|
aFontStyle.size *= vertScreenRes / 72.0;
|
|
|
|
|
|
|
|
NS_ConvertUTF8toUTF16 fontFace(szFacename);
|
|
|
|
int pos = 0;
|
|
|
|
|
|
|
|
// this is a system font in any case
|
|
|
|
aFontStyle.systemFont = true;
|
|
|
|
|
|
|
|
// bold fonts should have " Bold" in their names, at least we hope that they
|
|
|
|
// do, otherwise it's bad luck
|
|
|
|
NS_NAMED_LITERAL_CSTRING(spcBold, " Bold");
|
|
|
|
if ((pos = fontFace.Find(spcBold.get(), false, 0, -1)) > -1) {
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle.weight = NS_FONT_WEIGHT_BOLD;
|
2012-02-20 15:19:48 -08:00
|
|
|
// strip the attribute, now that we have set it in the gfxFontStyle
|
|
|
|
fontFace.Cut(pos, spcBold.Length());
|
|
|
|
} else {
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
|
2012-02-20 15:19:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Set aFontStyle.stretch correctly!
|
|
|
|
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
|
|
|
|
|
|
|
|
// similar hopes for italic and oblique fonts...
|
|
|
|
NS_NAMED_LITERAL_CSTRING(spcItalic, " Italic");
|
|
|
|
NS_NAMED_LITERAL_CSTRING(spcOblique, " Oblique");
|
|
|
|
NS_NAMED_LITERAL_CSTRING(spcObli, " Obli");
|
|
|
|
if ((pos = fontFace.Find(spcItalic.get(), false, 0, -1)) > -1) {
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle.style = NS_FONT_STYLE_ITALIC;
|
2012-02-20 15:19:48 -08:00
|
|
|
fontFace.Cut(pos, spcItalic.Length());
|
|
|
|
} else if ((pos = fontFace.Find(spcOblique.get(), false, 0, -1)) > -1) {
|
|
|
|
// oblique fonts are rare on OS/2 and not specially supported by
|
|
|
|
// the GPI system, but at least we are trying...
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle.style = NS_FONT_STYLE_OBLIQUE;
|
2012-02-20 15:19:48 -08:00
|
|
|
fontFace.Cut(pos, spcOblique.Length());
|
|
|
|
} else if ((pos = fontFace.Find(spcObli.get(), false, 0, -1)) > -1) {
|
|
|
|
// especially oblique often gets cut by the 32 char limit to "Obli",
|
|
|
|
// so search for that, too (anything shorter would be ambiguous)
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle.style = NS_FONT_STYLE_OBLIQUE;
|
2012-02-20 15:19:48 -08:00
|
|
|
// In this case, assume that this is the last property in the line
|
|
|
|
// and cut off everything else, too
|
|
|
|
// This is needed in case it was really Obliq or Obliqu...
|
|
|
|
fontFace.Cut(pos, fontFace.Length());
|
|
|
|
} else {
|
2012-03-15 02:04:46 -07:00
|
|
|
aFontStyle.style = NS_FONT_STYLE_NORMAL;
|
2012-02-20 15:19:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// just throw away any modifiers that are separated by dots (which are either
|
|
|
|
// .Strikeout, .Underline, or .Outline, none of which have a corresponding
|
|
|
|
// gfxFont property)
|
|
|
|
if ((pos = fontFace.Find(".", false, 0, -1)) > -1) {
|
|
|
|
fontFace.Cut(pos, fontFace.Length());
|
|
|
|
}
|
|
|
|
|
|
|
|
// seems like we need quotes around the font name
|
|
|
|
NS_NAMED_LITERAL_STRING(quote, "\"");
|
|
|
|
aFontName = quote + fontFace + quote;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|