From a0898cd636c81f7f135d101d52d2f3e2151a9d1f Mon Sep 17 00:00:00 2001 From: "akkana%netscape.com" Date: Mon, 3 Apr 2000 22:46:52 +0000 Subject: [PATCH] Add the XPLookAndFeel calls to the front ends which didn't already have them. There's no Tinderbox for these platforms; if this causes any problems or bustage, please contact me and feel free to back out or fix the offending files. --- widget/src/beos/nsLookAndFeel.cpp | 33 +++++++++++++++++++++++++++++ widget/src/beos/nsLookAndFeel.h | 4 ++++ widget/src/motif/nsLookAndFeel.cpp | 33 +++++++++++++++++++++++++++++ widget/src/motif/nsLookAndFeel.h | 4 ++++ widget/src/os2/nsLookAndFeel.cpp | 31 +++++++++++++++++++++++++++ widget/src/os2/nsLookAndFeel.h | 4 ++++ widget/src/photon/nsLookAndFeel.cpp | 32 ++++++++++++++++++++++++++++ widget/src/photon/nsLookAndFeel.h | 4 ++++ widget/src/qt/nsLookAndFeel.cpp | 33 +++++++++++++++++++++++++++++ widget/src/qt/nsLookAndFeel.h | 4 ++++ widget/src/xlib/nsLookAndFeel.cpp | 33 +++++++++++++++++++++++++++++ widget/src/xlib/nsLookAndFeel.h | 4 ++++ 12 files changed, 219 insertions(+) diff --git a/widget/src/beos/nsLookAndFeel.cpp b/widget/src/beos/nsLookAndFeel.cpp index 670a960532f0..eb7594a14413 100644 --- a/widget/src/beos/nsLookAndFeel.cpp +++ b/widget/src/beos/nsLookAndFeel.cpp @@ -22,6 +22,8 @@ #include "nsLookAndFeel.h" #include "nsFont.h" + +#include "nsXPLookAndFeel.h" //static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); //NS_IMPL_ISUPPORTS(nsLookAndFeel, NS_ILOOKANDFEEL_IID) @@ -41,6 +43,14 @@ nsLookAndFeel::~nsLookAndFeel() NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetColor(aID, aColor); + if (NS_SUCCEEDED(res)) + return res; + } + int idx; switch (aID) { case eColor_WindowBackground: @@ -91,6 +101,14 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetric_WindowTitleHeight: aMetric = 0; @@ -162,6 +180,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric) { nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetricFloat_TextFieldVerticalInsidePadding: aMetric = 0.25f; @@ -200,6 +226,13 @@ NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, const PRInt32 aFontSize, nsSize &aSize) { + if (mXPLookAndFeel) + { + nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); + if (NS_SUCCEEDED(rv)) + return rv; + } + aSize.width = 0; aSize.height = 0; return NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/beos/nsLookAndFeel.h b/widget/src/beos/nsLookAndFeel.h index 4dc70a484920..497b0e24e248 100644 --- a/widget/src/beos/nsLookAndFeel.h +++ b/widget/src/beos/nsLookAndFeel.h @@ -24,6 +24,7 @@ #define __nsLookAndFeel #include "nsObject.h" #include "nsILookAndFeel.h" +#include "nsCOMPtr.h" class nsLookAndFeel: public nsILookAndFeel { public: @@ -46,6 +47,9 @@ public: const PRInt32 aFontSize, nsSize &aSize); #endif + +protected: + nsCOMPtr mXPLookAndFeel; }; #endif diff --git a/widget/src/motif/nsLookAndFeel.cpp b/widget/src/motif/nsLookAndFeel.cpp index 7429fb0054e9..2eb7ffbd5393 100644 --- a/widget/src/motif/nsLookAndFeel.cpp +++ b/widget/src/motif/nsLookAndFeel.cpp @@ -21,6 +21,8 @@ */ #include "nsLookAndFeel.h" + +#include "nsXPLookAndFeel.h" static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); @@ -43,6 +45,14 @@ nsLookAndFeel::~nsLookAndFeel() NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetColor(aID, aColor); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eColor_WindowBackground: aColor = NS_RGB(0xff,0xff,0xff); @@ -92,6 +102,14 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetric_WindowTitleHeight: aMetric = 0; @@ -132,6 +150,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) NS_METHOD nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric) { + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + // FIXME: Need to implement. --ZuperDee return NS_OK; } @@ -142,6 +168,13 @@ NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, const PRInt32 aFontSize, nsSize &aSize) { + if (mXPLookAndFeel) + { + nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); + if (NS_SUCCEEDED(rv)) + return rv; + } + aSize.width = 0; aSize.height = 0; return NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/motif/nsLookAndFeel.h b/widget/src/motif/nsLookAndFeel.h index 9a2417311bf5..99e60743afbf 100644 --- a/widget/src/motif/nsLookAndFeel.h +++ b/widget/src/motif/nsLookAndFeel.h @@ -23,6 +23,7 @@ #ifndef __nsLookAndFeel #define __nsLookAndFeel #include "nsILookAndFeel.h" +#include "nsCOMPtr.h" class nsLookAndFeel: public nsILookAndFeel { NS_DECL_ISUPPORTS @@ -45,6 +46,9 @@ public: const PRInt32 aFontSize, nsSize &aSize); #endif + +protected: + nsCOMPtr mXPLookAndFeel; }; #endif diff --git a/widget/src/os2/nsLookAndFeel.cpp b/widget/src/os2/nsLookAndFeel.cpp index 1e85721f5831..ce54cef0960b 100644 --- a/widget/src/os2/nsLookAndFeel.cpp +++ b/widget/src/os2/nsLookAndFeel.cpp @@ -23,6 +23,8 @@ #include "nsColor.h" #include "nsWidgetDefs.h" +#include "nsXPLookAndFeel.h" + #include // XPCom scaffolding @@ -36,6 +38,13 @@ nsLookAndFeel::nsLookAndFeel() // Colours NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetColor(aID, aColor); + if (NS_SUCCEEDED(res)) + return res; + } + int idx = 0; switch (aID) { @@ -70,6 +79,13 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) // metrics NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + long svalue = 0; aMetric = 0; ULONG ulPels = 0; @@ -169,6 +185,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric( const nsMetricFloatID aID, float &aMetric) { nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch( aID) { case eMetricFloat_TextFieldVerticalInsidePadding: @@ -209,6 +233,13 @@ NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, const PRInt32 aFontSize, nsSize &aSize) { + if (mXPLookAndFeel) + { + nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); + if (NS_SUCCEEDED(rv)) + return rv; + } + aSize.width = 0; aSize.height = 0; return NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/os2/nsLookAndFeel.h b/widget/src/os2/nsLookAndFeel.h index 16a275307eae..804d85224e39 100644 --- a/widget/src/os2/nsLookAndFeel.h +++ b/widget/src/os2/nsLookAndFeel.h @@ -23,6 +23,7 @@ #define _nsLookAndFeel_h #include "nsILookAndFeel.h" +#include "nsCOMPtr.h" class nsLookAndFeel: public nsILookAndFeel { @@ -45,6 +46,9 @@ class nsLookAndFeel: public nsILookAndFeel const PRInt32 aFontSize, nsSize &aSize); #endif + +protected: + nsCOMPtr mXPLookAndFeel; }; #endif diff --git a/widget/src/photon/nsLookAndFeel.cpp b/widget/src/photon/nsLookAndFeel.cpp index 2ad7ade489f7..b9f9c22ea4f1 100644 --- a/widget/src/photon/nsLookAndFeel.cpp +++ b/widget/src/photon/nsLookAndFeel.cpp @@ -24,12 +24,16 @@ #include #include "nsFont.h" #include "nsPhWidgetLog.h" + +#include "nsXPLookAndFeel.h" NS_IMPL_ISUPPORTS1(nsLookAndFeel, nsILookAndFeel) nsLookAndFeel::nsLookAndFeel() : nsILookAndFeel() { NS_INIT_REFCNT(); + + (void)NS_NewXPLookAndFeel(getter_AddRefs(mXPLookAndFeel)); } nsLookAndFeel::~nsLookAndFeel() @@ -42,6 +46,13 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { nsresult res = NS_OK; + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetColor(aID, aColor); + if (NS_SUCCEEDED(res)) + return res; + } + PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsLookAndFeel::GetColor this=<%p> mRefCnt=<%d>\n", this, mRefCnt)); switch( aID ) @@ -107,6 +118,13 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { nsresult res = NS_OK; + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric\n")); switch( aID ) @@ -185,6 +203,13 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetri { nsresult res = NS_OK; + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric with float aID=<%d>\n", aID)); switch( aID ) @@ -228,6 +253,13 @@ NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, const PRInt32 aFontSize, nsSize &aSize) { + if (mXPLookAndFeel) + { + nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); + if (NS_SUCCEEDED(rv)) + return rv; + } + aSize.width = 0; aSize.height = 0; return NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/photon/nsLookAndFeel.h b/widget/src/photon/nsLookAndFeel.h index 1f8c32e13af5..24119022103d 100644 --- a/widget/src/photon/nsLookAndFeel.h +++ b/widget/src/photon/nsLookAndFeel.h @@ -23,6 +23,7 @@ #ifndef __nsLookAndFeel #define __nsLookAndFeel #include "nsILookAndFeel.h" +#include "nsCOMPtr.h" class nsLookAndFeel: public nsILookAndFeel { NS_DECL_ISUPPORTS @@ -45,6 +46,9 @@ public: const PRInt32 aFontSize, nsSize &aSize); #endif + +protected: + nsCOMPtr mXPLookAndFeel; }; #endif diff --git a/widget/src/qt/nsLookAndFeel.cpp b/widget/src/qt/nsLookAndFeel.cpp index ce582cce5cf4..2c064592c6d2 100644 --- a/widget/src/qt/nsLookAndFeel.cpp +++ b/widget/src/qt/nsLookAndFeel.cpp @@ -26,6 +26,8 @@ #include #include "nsWidget.h" +#include "nsXPLookAndFeel.h" + static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); #define GDK_COLOR_TO_NS_RGB(c) \ @@ -53,6 +55,14 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetColor()\n")); nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetColor(aID, aColor); + if (NS_SUCCEEDED(res)) + return res; + } + QPalette palette = qApp->palette(); QColorGroup normalGroup = palette.normal(); QColorGroup activeGroup = palette.active(); @@ -108,6 +118,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n")); nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetric_WindowTitleHeight: @@ -188,6 +206,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, { PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n")); nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetricFloat_TextFieldVerticalInsidePadding: @@ -227,6 +253,13 @@ NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, const PRInt32 aFontSize, nsSize &aSize) { + if (mXPLookAndFeel) + { + nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); + if (NS_SUCCEEDED(rv)) + return rv; + } + aSize.width = 0; aSize.height = 0; return NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/qt/nsLookAndFeel.h b/widget/src/qt/nsLookAndFeel.h index d5006914338d..b0808352ed5a 100644 --- a/widget/src/qt/nsLookAndFeel.h +++ b/widget/src/qt/nsLookAndFeel.h @@ -23,6 +23,7 @@ #ifndef __nsLookAndFeel #define __nsLookAndFeel #include "nsILookAndFeel.h" +#include "nsCOMPtr.h" class nsLookAndFeel: public nsILookAndFeel { @@ -46,6 +47,9 @@ public: const PRInt32 aFontSize, nsSize &aSize); #endif + +protected: + nsCOMPtr mXPLookAndFeel; }; #endif diff --git a/widget/src/xlib/nsLookAndFeel.cpp b/widget/src/xlib/nsLookAndFeel.cpp index 3ca5382e9795..2bd29a8ca23d 100644 --- a/widget/src/xlib/nsLookAndFeel.cpp +++ b/widget/src/xlib/nsLookAndFeel.cpp @@ -23,6 +23,8 @@ #include "nsLookAndFeel.h" #include "nsWidget.h" +#include "nsXPLookAndFeel.h" + static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); NS_IMPL_ISUPPORTS(nsLookAndFeel, kILookAndFeelIID) @@ -42,6 +44,14 @@ nsLookAndFeel::~nsLookAndFeel() NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetColor()\n")); + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetColor(aID, aColor); + if (NS_SUCCEEDED(res)) + return res; + } + return NS_OK; } @@ -50,6 +60,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n")); // XXX These are not complete! nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetric_WindowTitleHeight: aMetric = 20; @@ -124,6 +142,14 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetri // XXX this is not complete nsresult res = NS_OK; + + if (mXPLookAndFeel) + { + res = mXPLookAndFeel->GetMetric(aID, aMetric); + if (NS_SUCCEEDED(res)) + return res; + } + switch (aID) { case eMetricFloat_TextFieldVerticalInsidePadding: aMetric = 0.25f; @@ -162,6 +188,13 @@ NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID, const PRInt32 aFontSize, nsSize &aSize) { + if (mXPLookAndFeel) + { + nsresult rv = mXPLookAndFeel->GetNavSize(aWidgetID, aFontID, aFontSize, aSize); + if (NS_SUCCEEDED(rv)) + return rv; + } + aSize.width = 0; aSize.height = 0; return NS_ERROR_NOT_IMPLEMENTED; diff --git a/widget/src/xlib/nsLookAndFeel.h b/widget/src/xlib/nsLookAndFeel.h index 361f67b01ed8..25828eafa7ce 100644 --- a/widget/src/xlib/nsLookAndFeel.h +++ b/widget/src/xlib/nsLookAndFeel.h @@ -24,6 +24,7 @@ #define __nsLookAndFeel #include "nsILookAndFeel.h" +#include "nsCOMPtr.h" class nsLookAndFeel: public nsILookAndFeel { public: @@ -46,6 +47,9 @@ public: const PRInt32 aFontSize, nsSize &aSize); #endif + +protected: + nsCOMPtr mXPLookAndFeel; }; #endif