1998-07-29 18:55:25 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsLookAndFeel.h"
|
1999-01-21 23:59:14 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include "nsFont.h"
|
1998-07-29 18:55:25 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsLookAndFeel, NS_ILOOKANDFEEL_IID)
|
1998-09-14 20:40:49 +00:00
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
nsLookAndFeel::nsLookAndFeel() : nsILookAndFeel()
|
1998-09-14 20:40:49 +00:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
1998-07-29 18:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLookAndFeel::~nsLookAndFeel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-09-01 20:54:39 +00:00
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetColor(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;
|
|
|
|
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;
|
|
|
|
default:
|
|
|
|
idx = COLOR_WINDOW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-12-21 16:53:49 +00:00
|
|
|
aColor = ::GetSysColor(idx);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
1998-07-29 18:55:25 +00:00
|
|
|
{
|
1998-12-21 16:53:49 +00:00
|
|
|
nsresult res = NS_OK;
|
|
|
|
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;
|
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;
|
1998-07-29 18:55:25 +00:00
|
|
|
default:
|
1998-09-01 20:54:39 +00:00
|
|
|
aMetric = -1;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
switch (aID) {
|
|
|
|
case eMetricFloat_TextFieldVerticalInsidePadding:
|
|
|
|
aMetric = 0.25f;
|
|
|
|
break;
|
|
|
|
case eMetricFloat_TextFieldHorizontalInsidePadding:
|
|
|
|
aMetric = 0.95f;
|
|
|
|
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
|
|
|
|