diff --git a/widget/public/nsILookAndFeel.h b/widget/public/nsILookAndFeel.h index bfceea32547..950e0eddb9c 100644 --- a/widget/public/nsILookAndFeel.h +++ b/widget/public/nsILookAndFeel.h @@ -48,11 +48,35 @@ public: eMetric_WindowBorderWidth, eMetric_WindowBorderHeight, eMetric_Widget3DBorder, - eMetric_TextFieldHeight + eMetric_TextFieldHeight, + eMetric_TextVerticalInsidePadding, // needed only because of GTK + eMetric_TextShouldUseVerticalInsidePadding, // needed only because of GTK + eMetric_TextHorizontalInsideMinimumPadding, + eMetric_TextShouldUseHorizontalInsideMinimumPadding, // needed only because of GTK + eMetric_ButtonHorizontalInsidePaddingNavQuirks, + eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks, + + eMetric_ListShouldUseHorizontalInsideMinimumPadding, // needed only because of GTK + eMetric_ListHorizontalInsideMinimumPadding, + + eMetric_ListShouldUseVerticalInsidePadding, // needed only because of GTK + eMetric_ListVerticalInsidePadding // needed only because of GTK } nsMetricID; + typedef enum { + eMetricFloat_TextFieldVerticalInsidePadding, + eMetricFloat_TextFieldHorizontalInsidePadding, + eMetricFloat_TextAreaVerticalInsidePadding, + eMetricFloat_TextAreaHorizontalInsidePadding, + eMetricFloat_ListVerticalInsidePadding, + eMetricFloat_ListHorizontalInsidePadding, + eMetricFloat_ButtonVerticalInsidePadding, + eMetricFloat_ButtonHorizontalInsidePadding + } nsMetricFloatID; + NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor) = 0; NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric) = 0; + NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric) = 0; }; #define nsLAF nsILookAndFeel diff --git a/widget/src/gtk/nsLookAndFeel.cpp b/widget/src/gtk/nsLookAndFeel.cpp index 74e7877702a..0f4de68467a 100644 --- a/widget/src/gtk/nsLookAndFeel.cpp +++ b/widget/src/gtk/nsLookAndFeel.cpp @@ -115,6 +115,36 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) // FIXME we need to allow the entry to size itself based on the font aMetric = 20; break; + case eMetric_ButtonHorizontalInsidePaddingNavQuirks: + aMetric = 20; + break; + case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks: + aMetric = 0; + break; + case eMetric_TextHorizontalInsideMinimumPadding: + aMetric = 6; + break; + case eMetric_TextVerticalInsidePadding: + aMetric = 10; + break; + case eMetric_TextShouldUseVerticalInsidePadding: + aMetric = 1; + break; + case eMetric_TextShouldUseHorizontalInsideMinimumPadding: + aMetric = 0; + break; + case eMetric_ListShouldUseHorizontalInsideMinimumPadding: + aMetric = 1; + break; + case eMetric_ListHorizontalInsideMinimumPadding: + aMetric = 7; + break; + case eMetric_ListShouldUseVerticalInsidePadding: + aMetric = 1; + break; + case eMetric_ListVerticalInsidePadding: + aMetric = 1; + break; default: aMetric = 0; res = NS_ERROR_FAILURE; @@ -125,4 +155,38 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) return res; } +NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric) +{ + nsresult res = NS_OK; + switch (aID) { + case eMetricFloat_TextFieldVerticalInsidePadding: + aMetric = 10.0f; + break; + case eMetricFloat_TextFieldHorizontalInsidePadding: + aMetric = 10000.0f; // large number on purpose so minimum padding is used + break; + case eMetricFloat_TextAreaVerticalInsidePadding: + aMetric = 10.0f; + break; + case eMetricFloat_TextAreaHorizontalInsidePadding: + aMetric = 10000.0f; // large number on purpose so minimum padding is used + break; + case eMetricFloat_ListVerticalInsidePadding: + aMetric = 1.0f; + break; + case eMetricFloat_ListHorizontalInsidePadding: + aMetric = 7.0f; + break; + case eMetricFloat_ButtonVerticalInsidePadding: + aMetric = 0.5f; + break; + case eMetricFloat_ButtonHorizontalInsidePadding: + aMetric = 0.5f; + break; + default: + aMetric = -1.0; + res = NS_ERROR_FAILURE; + } + return res; +} diff --git a/widget/src/gtk/nsLookAndFeel.h b/widget/src/gtk/nsLookAndFeel.h index 1276b2e1291..9164d5a43b2 100644 --- a/widget/src/gtk/nsLookAndFeel.h +++ b/widget/src/gtk/nsLookAndFeel.h @@ -29,6 +29,7 @@ public: NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor); NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric); + NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric); }; #endif diff --git a/widget/src/mac/nsLookAndFeel.cpp b/widget/src/mac/nsLookAndFeel.cpp index 6e97f2b182b..2218afd924d 100644 --- a/widget/src/mac/nsLookAndFeel.cpp +++ b/widget/src/mac/nsLookAndFeel.cpp @@ -105,6 +105,36 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) case eMetric_TextFieldHeight: aMetric = 16; break; + case eMetric_ButtonHorizontalInsidePaddingNavQuirks: + aMetric = 20; + break; + case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks: + aMetric = 0; + break; + 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; default: aMetric = 0; res = NS_ERROR_FAILURE; @@ -112,4 +142,38 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) 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.5f; + break; + case eMetricFloat_ButtonHorizontalInsidePadding: + aMetric = 0.5f; + break; + default: + aMetric = -1.0; + res = NS_ERROR_FAILURE; + } + return res; +} diff --git a/widget/src/mac/nsLookAndFeel.h b/widget/src/mac/nsLookAndFeel.h index 1276b2e1291..9164d5a43b2 100644 --- a/widget/src/mac/nsLookAndFeel.h +++ b/widget/src/mac/nsLookAndFeel.h @@ -29,6 +29,7 @@ public: NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor); NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric); + NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric); }; #endif diff --git a/widget/src/windows/nsLookAndFeel.cpp b/widget/src/windows/nsLookAndFeel.cpp index 52357d00f9e..a72925461f3 100644 --- a/widget/src/windows/nsLookAndFeel.cpp +++ b/widget/src/windows/nsLookAndFeel.cpp @@ -34,9 +34,9 @@ nsLookAndFeel::~nsLookAndFeel() NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { - nsresult res = NS_OK; - int idx; - switch (aID) { + nsresult res = NS_OK; + int idx; + switch (aID) { case eColor_WindowBackground: idx = COLOR_WINDOW; break; @@ -78,15 +78,15 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) break; } - aColor = ::GetSysColor(idx); + aColor = ::GetSysColor(idx); - return res; + return res; } NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { - nsresult res = NS_OK; - switch (aID) { + nsresult res = NS_OK; + switch (aID) { case eMetric_WindowTitleHeight: aMetric = ::GetSystemMetrics(SM_CYCAPTION); break; @@ -102,10 +102,75 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) case eMetric_TextFieldHeight: aMetric = 24; break; + case eMetric_ButtonHorizontalInsidePaddingNavQuirks: + aMetric = 10; + break; + case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks: + aMetric = 8; + break; + 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; default: aMetric = -1; res = NS_ERROR_FAILURE; } - return res; + 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; } diff --git a/widget/src/windows/nsLookAndFeel.h b/widget/src/windows/nsLookAndFeel.h index 1950ecb2a00..4f64a050fd6 100644 --- a/widget/src/windows/nsLookAndFeel.h +++ b/widget/src/windows/nsLookAndFeel.h @@ -30,6 +30,7 @@ public: NS_IMETHOD GetColor(const nsColorID aID, nscolor &aColor); NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric); + NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric); }; #endif