Bug 391984 - [10.5] Add roundness to context menus, r=josh sr=roc

This commit is contained in:
Markus Stange 2008-12-11 15:37:38 +01:00
parent 45b8f132d3
commit 975559338c
13 changed files with 62 additions and 17 deletions

View File

@ -57,14 +57,20 @@ class nsIContent;
class nsIAtom;
// IID for the nsITheme interface
// {df8baf21-5ea7-49eb-a2bc-f2fd4a9fd896}
// {f5eb2e02-ed3f-4340-82fc-22f55bb556f9}
#define NS_ITHEME_IID \
{ 0xdf8baf21, 0x5ea7, 0x49eb, { 0xa2, 0xbc, 0xf2, 0xfd, 0x4a, 0x9f, 0xd8, 0x96 } }
{ 0xf5eb2e02, 0xed3f, 0x4340, { 0x82, 0xfc, 0x22, 0xf5, 0x5b, 0xb5, 0x56, 0xf9 } }
// {D930E29B-6909-44e5-AB4B-AF10D6923705}
#define NS_THEMERENDERER_CID \
{ 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
enum nsTransparencyMode {
eTransparencyOpaque = 0, // Fully opaque
eTransparencyTransparent, // Parts of the window may be transparent
eTransparencyGlass // Transparent parts of the window have Vista AeroGlass effect applied
};
/**
* nsITheme is a service that provides platform-specific native
* rendering for widgets. In other words, it provides the necessary
@ -133,6 +139,8 @@ public:
nsSize* aResult,
PRBool* aIsOverridable)=0;
virtual nsTransparencyMode GetWidgetTransparency(PRUint8 aWidgetType)=0;
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
nsIAtom* aAttribute, PRBool* aShouldRepaint)=0;

View File

@ -2948,8 +2948,9 @@ nsLayoutUtils::GetFrameTransparency(nsIFrame* aFrame) {
if (HasNonZeroCorner(aFrame->GetStyleContext()->GetStyleBorder()->mBorderRadius))
return eTransparencyTransparent;
if (aFrame->IsThemed())
return eTransparencyOpaque;
nsTransparencyMode transparency;
if (aFrame->IsThemed(&transparency))
return transparency;
if (aFrame->GetStyleDisplay()->mAppearance == NS_THEME_WIN_GLASS)
return eTransparencyGlass;

View File

@ -842,15 +842,20 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists);
PRBool IsThemed() {
return IsThemed(GetStyleDisplay());
PRBool IsThemed(nsTransparencyMode* aTransparencyMode = nsnull) {
return IsThemed(GetStyleDisplay(), aTransparencyMode);
}
PRBool IsThemed(const nsStyleDisplay* aDisp) {
PRBool IsThemed(const nsStyleDisplay* aDisp,
nsTransparencyMode* aTransparencyMode = nsnull) {
if (!aDisp->mAppearance)
return PR_FALSE;
nsPresContext* pc = PresContext();
nsITheme *theme = pc->GetTheme();
return theme && theme->ThemeSupportsWidget(pc, this, aDisp->mAppearance);
if(!theme || !theme->ThemeSupportsWidget(pc, this, aDisp->mAppearance))
return PR_FALSE;
if (aTransparencyMode)
*aTransparencyMode = theme->GetWidgetTransparency(aDisp->mAppearance);
return PR_TRUE;
}
/**

View File

@ -46,6 +46,7 @@
#include "prthread.h"
#include "nsEvent.h"
#include "nsCOMPtr.h"
#include "nsITheme.h"
// forward declarations
class nsIAppShell;
@ -237,12 +238,6 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
eZPlacementTop // top of the window stack
};
enum nsTransparencyMode {
eTransparencyOpaque = 0, // Fully opaque
eTransparencyTransparent, // Parts of the window may be transparent
eTransparencyGlass // Transparent parts of the window have Vista AeroGlass effect applied
};
/**
* Basic struct for widget initialization data.
* @see Create member function of nsIWidget

View File

@ -2933,7 +2933,7 @@ NSEvent* gLastDragEvent = nil;
static const PRInt32 sShadowInvalidationInterval = 100;
- (void)maybeInvalidateShadow
{
if (!mIsTransparent || ![mWindow hasShadow])
if ([mWindow isOpaque] || ![mWindow hasShadow])
return;
PRIntervalTime now = PR_IntervalNow();

View File

@ -88,6 +88,7 @@ public:
PRBool WidgetIsContainer(PRUint8 aWidgetType);
PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
PRBool ThemeNeedsComboboxDropmarker();
virtual nsTransparencyMode GetWidgetTransparency(PRUint8 aWidgetType);
protected:

View File

@ -1439,8 +1439,10 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
version: 0,
menuType: IsDisabled(aFrame) ? kThemeMenuTypeInactive : kThemeMenuTypePopUp
};
HIThemeDrawMenuBackground(&macRect, &mdi, cgContext, HITHEME_ORIENTATION);
// The rounded corners draw outside the frame.
CGRect deflatedRect = CGRectMake(macRect.origin.x, macRect.origin.y + 4,
macRect.size.width, macRect.size.height - 8);
HIThemeDrawMenuBackground(&deflatedRect, &mdi, cgContext, HITHEME_ORIENTATION);
}
break;
@ -2288,3 +2290,12 @@ nsNativeThemeCocoa::ThemeNeedsComboboxDropmarker()
{
return PR_FALSE;
}
nsTransparencyMode
nsNativeThemeCocoa::GetWidgetTransparency(PRUint8 aWidgetType)
{
if (aWidgetType == NS_THEME_MENUPOPUP)
return eTransparencyTransparent;
return eTransparencyOpaque;
}

View File

@ -1314,3 +1314,9 @@ nsNativeThemeGTK::ThemeNeedsComboboxDropmarker()
{
return PR_FALSE;
}
nsTransparencyMode
nsNativeThemeGTK::GetWidgetTransparency(PRUint8 aWidgetType)
{
return eTransparencyOpaque;
}

View File

@ -92,6 +92,8 @@ public:
PRBool ThemeNeedsComboboxDropmarker();
virtual nsTransparencyMode GetWidgetTransparency(PRUint8 aWidgetType);
nsNativeThemeGTK();
virtual ~nsNativeThemeGTK();

View File

@ -563,6 +563,12 @@ nsNativeThemeQt::ThemeNeedsComboboxDropmarker()
return PR_TRUE;
}
nsTransparencyMode
nsNativeThemeQt::GetWidgetTransparency(PRUint8 aWidgetType)
{
return eTransparencyOpaque;
}
void
nsNativeThemeQt::InitButtonStyle(PRUint8 aWidgetType,
nsIFrame* aFrame,

View File

@ -99,6 +99,8 @@ public:
PRBool ThemeNeedsComboboxDropmarker();
virtual nsTransparencyMode GetWidgetTransparency(PRUint8 aWidgetType);
nsNativeThemeQt();
virtual ~nsNativeThemeQt();

View File

@ -1650,6 +1650,12 @@ nsNativeThemeWin::ThemeNeedsComboboxDropmarker()
return PR_TRUE;
}
nsTransparencyMode
nsNativeThemeWin::GetWidgetTransparency(PRUint8 aWidgetType)
{
return eTransparencyOpaque;
}
/* Windows 9x/NT/2000/Classic XP Theme Support */
PRBool

View File

@ -75,6 +75,8 @@ public:
nsSize* aResult,
PRBool* aIsOverridable);
virtual nsTransparencyMode GetWidgetTransparency(PRUint8 aWidgetType);
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
nsIAtom* aAttribute, PRBool* aShouldRepaint);