Bug 118025 - nsITheme menupopup/menuitem implementations (Mac). r=pinkerton sr=smfr (for gfx) r=kmgerich (for pinstripe)

This commit is contained in:
mozilla.mano%sent.com 2005-08-20 07:14:24 +00:00
Родитель 54839a85aa
Коммит 5ce31b67c6
2 изменённых файлов: 44 добавлений и 5 удалений

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsIAtom.h"
#include "nsIEventStateManager.h" #include "nsIEventStateManager.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
#include "nsPresContext.h" #include "nsPresContext.h"
@ -100,6 +101,8 @@ nsNativeThemeMac::nsNativeThemeMac()
sListboxBGTransparent = PR_TRUE; sListboxBGTransparent = PR_TRUE;
sTextfieldDisabledBGColorID = nsILookAndFeel::eColor__moz_field; sTextfieldDisabledBGColorID = nsILookAndFeel::eColor__moz_field;
} }
mMenuActiveAtom = do_GetAtom("_moz-menuactive");
} }
nsNativeThemeMac::~nsNativeThemeMac() nsNativeThemeMac::~nsNativeThemeMac()
@ -284,6 +287,31 @@ nsNativeThemeMac::DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool i
::DrawThemeTab(&inBoxRect, style, direction, nsnull, 0L); ::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 NS_IMETHODIMP
nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame* aFrame, nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame* aFrame,
PRUint8 aWidgetType, const nsRect& aRect, const nsRect& aClipRect) PRUint8 aWidgetType, const nsRect& aRect, const nsRect& aClipRect)
@ -332,7 +360,13 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame*
case NS_THEME_MENUPOPUP: case NS_THEME_MENUPOPUP:
::SetThemeBackground(kThemeBrushDialogBackgroundActive, 24, true); ::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); ::SetThemeBackground(kThemeBrushWhite, 24, true);
break; break;
@ -724,7 +758,7 @@ nsNativeThemeMac::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
// disabled, checked, dlgtype, default, etc. // disabled, checked, dlgtype, default, etc.
*aShouldRepaint = PR_FALSE; *aShouldRepaint = PR_FALSE;
if (aAttribute == mDisabledAtom || aAttribute == mCheckedAtom || if (aAttribute == mDisabledAtom || aAttribute == mCheckedAtom ||
aAttribute == mSelectedAtom) aAttribute == mSelectedAtom || aAttribute == mMenuActiveAtom)
*aShouldRepaint = PR_TRUE; *aShouldRepaint = PR_TRUE;
} }
@ -758,7 +792,8 @@ nsNativeThemeMac::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFr
switch ( aWidgetType ) { switch ( aWidgetType ) {
case NS_THEME_DIALOG: case NS_THEME_DIALOG:
case NS_THEME_WINDOW: 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_TOOLTIP:
case NS_THEME_CHECKBOX: case NS_THEME_CHECKBOX:

Просмотреть файл

@ -114,8 +114,12 @@ protected:
PRBool inDisabled, ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, PRInt32 inState ) ; PRBool inDisabled, ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, PRInt32 inState ) ;
void DrawCheckboxRadio ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inChecked, void DrawCheckboxRadio ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inChecked,
PRBool inDisabled, PRInt32 inState ) ; PRBool inDisabled, PRInt32 inState ) ;
void DrawMenu ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
void DrawMenuItem ( const Rect& inBoxRect, ThemeMenuItemType itemType, PRBool inIsDisabled,
PRBool inHover) ;
private: private:
ThemeEraseUPP mEraseProc; ThemeEraseUPP mEraseProc;
nsCOMPtr<nsIAtom> mMenuActiveAtom;
}; };