From a7ec022a73563fa07fdaea79a73e157894a71b3d Mon Sep 17 00:00:00 2001 From: "mozilla.mano%sent.com" Date: Mon, 28 Feb 2005 15:09:58 +0000 Subject: [PATCH] Bug 118025 - nsITheme menupopup/menuitem implementations (Mac). r=pinkerton sr=smfr (for gfx) r=kmgerich (for pinstripe) git-svn-id: svn://10.0.0.236/trunk@169985 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/mac/nsNativeThemeMac.cpp | 45 ++++++++++++++++--- mozilla/gfx/src/mac/nsNativeThemeMac.h | 4 ++ .../toolkit/themes/pinstripe/global/menu.css | 12 ++--- .../toolkit/themes/pinstripe/global/popup.css | 5 +-- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/mozilla/gfx/src/mac/nsNativeThemeMac.cpp b/mozilla/gfx/src/mac/nsNativeThemeMac.cpp index fe4db2dbd6d..65f40400103 100644 --- a/mozilla/gfx/src/mac/nsNativeThemeMac.cpp +++ b/mozilla/gfx/src/mac/nsNativeThemeMac.cpp @@ -48,6 +48,7 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIFrame.h" +#include "nsIAtom.h" #include "nsIEventStateManager.h" #include "nsINameSpaceManager.h" #include "nsPresContext.h" @@ -100,6 +101,8 @@ nsNativeThemeMac::nsNativeThemeMac() sListboxBGTransparent = PR_TRUE; sTextfieldDisabledBGColorID = nsILookAndFeel::eColor__moz_field; } + + mMenuActiveAtom = do_GetAtom("_moz-menuactive"); } nsNativeThemeMac::~nsNativeThemeMac() @@ -284,6 +287,31 @@ nsNativeThemeMac::DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool i ::DrawThemeTab(&inBoxRect, style, direction, nsnull, 0L); } +void +nsNativeThemeMac::DrawMenu ( const Rect& inBoxRect, PRBool inIsDisabled ) +{ + ::EraseRect(&inBoxRect); + ThemeMenuType menuType = inIsDisabled ? kThemeMenuTypeInactive : kThemeMenuTypePopUp; + ::DrawThemeMenuBackground(&inBoxRect, menuType); +} + +void +nsNativeThemeMac::DrawMenuItem ( const Rect& inBoxRect, ThemeMenuItemType itemType, PRBool inIsDisabled, + PRBool inHover) +{ + ThemeMenuState menuItemState; + if (inIsDisabled) + menuItemState = kThemeMenuDisabled; + else if (inHover) + menuItemState = kThemeMenuSelected; + else + menuItemState = kThemeMenuActive; + + // XXXmano: pass the right menu rect! + ::DrawThemeMenuItem(&inBoxRect, &inBoxRect, inBoxRect.top, + inBoxRect.bottom, menuItemState, itemType, NULL, 0); +} + NS_IMETHODIMP nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame* aFrame, PRUint8 aWidgetType, const nsRect& aRect, const nsRect& aClipRect) @@ -329,10 +357,16 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame* ::EraseRect(&macRect); ::SetThemeBackground(kThemeBrushWhite, 24, true); break; - + case NS_THEME_MENUPOPUP: ::SetThemeBackground(kThemeBrushDialogBackgroundActive, 24, true); - ::EraseRect(&macRect); + DrawMenu(macRect, IsDisabled(aFrame)); + ::SetThemeBackground(kThemeBrushWhite, 24, true); + break; + + case NS_THEME_MENUITEM: + ::SetThemeBackground(kThemeBrushDialogBackgroundActive, 24, true); + DrawMenuItem(macRect, kThemeMenuItemPlain, IsDisabled(aFrame), CheckBooleanAttr(aFrame, mMenuActiveAtom)); ::SetThemeBackground(kThemeBrushWhite, 24, true); break; @@ -724,7 +758,7 @@ nsNativeThemeMac::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, // disabled, checked, dlgtype, default, etc. *aShouldRepaint = PR_FALSE; if (aAttribute == mDisabledAtom || aAttribute == mCheckedAtom || - aAttribute == mSelectedAtom) + aAttribute == mSelectedAtom || aAttribute == mMenuActiveAtom) *aShouldRepaint = PR_TRUE; } @@ -758,7 +792,8 @@ nsNativeThemeMac::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFr switch ( aWidgetType ) { case NS_THEME_DIALOG: case NS_THEME_WINDOW: - // case NS_THEME_MENUPOPUP: // no support for painting menu backgrounds + case NS_THEME_MENUPOPUP: + case NS_THEME_MENUITEM: case NS_THEME_TOOLTIP: case NS_THEME_CHECKBOX: @@ -808,7 +843,7 @@ nsNativeThemeMac::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFr case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL: retVal = PR_TRUE; break; - + case NS_THEME_LISTBOX: case NS_THEME_DROPDOWN: case NS_THEME_DROPDOWN_BUTTON: diff --git a/mozilla/gfx/src/mac/nsNativeThemeMac.h b/mozilla/gfx/src/mac/nsNativeThemeMac.h index db718ebd82d..3f7d6e469cf 100644 --- a/mozilla/gfx/src/mac/nsNativeThemeMac.h +++ b/mozilla/gfx/src/mac/nsNativeThemeMac.h @@ -114,8 +114,12 @@ protected: PRBool inDisabled, ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, PRInt32 inState ) ; void DrawCheckboxRadio ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState ) ; + void DrawMenu ( const Rect& inBoxRect, PRBool inIsDisabled ) ; + void DrawMenuItem ( const Rect& inBoxRect, ThemeMenuItemType itemType, PRBool inIsDisabled, + PRBool inHover) ; private: ThemeEraseUPP mEraseProc; + nsCOMPtr mMenuActiveAtom; }; diff --git a/mozilla/toolkit/themes/pinstripe/global/menu.css b/mozilla/toolkit/themes/pinstripe/global/menu.css index e930fa70e4a..d9736bd4879 100644 --- a/mozilla/toolkit/themes/pinstripe/global/menu.css +++ b/mozilla/toolkit/themes/pinstripe/global/menu.css @@ -47,20 +47,16 @@ menu, menuitem { - -moz-appearance: none !important; + -moz-appearance: menuitem !important; -moz-box-align: center; - color: #000000; + color: MenuText; font: menu; - list-style-image: none; - -moz-image-region: auto; } menu[disabled="true"], menuitem[disabled="true"], menu[_moz-menuactive="true"][disabled="true"], menuitem[_moz-menuactive="true"][disabled="true"] { color: GrayText; - background-color: transparent !important; - /* background-image: none !important; */ } /* ..... internal content .... */ @@ -134,9 +130,7 @@ menupopup > menu[_moz-menuactive="true"], menupopup > menuitem[_moz-menuactive="true"], popup > menu[_moz-menuactive="true"], popup > menuitem[_moz-menuactive="true"] { - /* background: url("chrome://global/skin/icons/menuselected.png") #FFFFFF repeat !important; */ - background-color: #3063b0; - color: #FFF; + color: -moz-mac-menutextselect; } /* ::::: menu/menuitems in menulist popups ::::: */ diff --git a/mozilla/toolkit/themes/pinstripe/global/popup.css b/mozilla/toolkit/themes/pinstripe/global/popup.css index a4e32a6a456..de6eea9f05b 100644 --- a/mozilla/toolkit/themes/pinstripe/global/popup.css +++ b/mozilla/toolkit/themes/pinstripe/global/popup.css @@ -47,10 +47,7 @@ menupopup, popup { - min-width: 1px; - color: #000000; - border-top: 1px solid #C3C3C3; - background: url("chrome://global/skin/icons/popup-overlay.png") repeat !important; + -moz-appearance: menupopup;; } /* ::::: popup internal box ::::: */