add tab support and fix up drawing problems with port not being set. r=sdagley/sr=sfraser/a=asa. bug# 120171

This commit is contained in:
pinkerton%netscape.com 2005-08-20 07:12:09 +00:00
Родитель bccc526e51
Коммит 98f7fdedf2
2 изменённых файлов: 97 добавлений и 3 удалений

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

@ -55,6 +55,7 @@
#include "nsIPresContext.h" #include "nsIPresContext.h"
#include "nsILookAndFeel.h" #include "nsILookAndFeel.h"
#include "nsRegionPool.h" #include "nsRegionPool.h"
#include "nsGfxUtils.h"
// //
// Return true if we are on Mac OS X, caching the result after the first call // Return true if we are on Mac OS X, caching the result after the first call
@ -307,6 +308,9 @@ nsNativeThemeMac::GetScrollbarParentLocalRect ( nsIFrame* inButton, nsTransform2
scrollbar->GetRect(scrollbarRect); scrollbar->GetRect(scrollbarRect);
nsRect localScrollRect(-offset.x, -offset.y, scrollbarRect.width, scrollbarRect.height); nsRect localScrollRect(-offset.x, -offset.y, scrollbarRect.width, scrollbarRect.height);
//printf("offset is (%ld, %ld)\n", offset.x, offset.y);
//printf("pre-xform (%ld, %ld) w=%ld h=%ld\n", localScrollRect.x, localScrollRect.y, localScrollRect.width,
// localScrollRect.height);
// now that we have it in gecko coords, transform it to coords the OS can use // now that we have it in gecko coords, transform it to coords the OS can use
inMatrix->TransformCoord(&localScrollRect.x, &localScrollRect.y, inMatrix->TransformCoord(&localScrollRect.x, &localScrollRect.y,
&localScrollRect.width, &localScrollRect.height); &localScrollRect.width, &localScrollRect.height);
@ -396,6 +400,22 @@ nsNativeThemeMac::DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled )
#endif #endif
} }
void
nsNativeThemeMac::DrawListBox ( const Rect& inBoxRect, PRBool inIsDisabled )
{
#if TARGET_CARBON
Pattern whitePat;
::BackColor(whiteColor);
::BackPat(GetQDGlobalsWhite(&whitePat));
::EraseRect(&inBoxRect);
ThemeDrawState drawState = inIsDisabled ? kThemeStateActive : kThemeStateDisabled;
::DrawThemeListBoxFrame(&inBoxRect, drawState);
#endif
}
void void
nsNativeThemeMac::DrawProgress ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsIndeterminate, nsNativeThemeMac::DrawProgress ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsIndeterminate,
PRBool inIsHorizontal, PRInt32 inValue ) PRBool inIsHorizontal, PRInt32 inValue )
@ -413,7 +433,38 @@ nsNativeThemeMac::DrawProgress ( const Rect& inBoxRect, PRBool inIsDisabled, PRB
info.trackInfo.progress.phase = sPhase++; // animate for the next time we're called info.trackInfo.progress.phase = sPhase++; // animate for the next time we're called
::DrawThemeTrack(&info, nsnull, nsnull, 0L); ::DrawThemeTrack(&info, nsnull, nsnull, 0L);
}
void
nsNativeThemeMac::DrawTabPanel ( const Rect& inBoxRect, PRBool inIsDisabled )
{
ThemeDrawState drawState = inIsDisabled ? kThemeStateActive : kThemeStateDisabled;
::DrawThemeTabPane(&inBoxRect, kThemeStateActive);
}
void
nsNativeThemeMac::DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRInt32 inState )
{
ThemeTabStyle style = 0L;
if ( inIsFrontmost ) {
if ( inIsDisabled )
style = kThemeTabFrontInactive;
else
style = kThemeTabFront;
}
else {
if ( inIsDisabled )
style = kThemeTabNonFrontInactive;
else if ( (inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER) )
style = kThemeTabNonFrontPressed;
else
style = kThemeTabNonFront;
}
::DrawThemeTab(&inBoxRect, style, kThemeTabNorth, nsnull, 0L);
} }
@ -474,6 +525,8 @@ nsNativeThemeMac::DrawFullScrollbar ( const Rect& inSbarRect, PRInt32 inWidgetHi
#ifdef DEBUG_PINK #ifdef DEBUG_PINK
// some debug info for helping diagnose problems // some debug info for helping diagnose problems
printf("--- BEGIN scrollbar debug info\n"); printf("--- BEGIN scrollbar debug info\n");
printf("-- widget drawn is %ld\n", inWidgetHit);
printf("bounds (%ld, %ld), (%ld, %ld)\n",inSbarRect.left, inSbarRect.top, inSbarRect.right, inSbarRect.bottom );
if ( isHorizontal ) if ( isHorizontal )
printf("horizontal\n"); printf("horizontal\n");
else else
@ -491,6 +544,18 @@ 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)
{ {
// setup to draw into the correct port
nsDrawingSurface surf;
aContext->GetDrawingSurface(&surf);
nsDrawingSurfaceMac* macSurface = (nsDrawingSurfaceMac*)surf;
CGrafPtr port = nsnull;
NS_ASSERTION(macSurface,"no surface!!!\n");
if ( macSurface )
macSurface->GetGrafPtr(&port);
else
return NS_ERROR_FAILURE; // we won't get far w/out something to draw into
StPortSetter temp(port);
// save off the old clip rgn for later restoration. however, we're currently // save off the old clip rgn for later restoration. however, we're currently
// not using the cliprect because aqua likes to draw shadows and stuff outside // not using the cliprect because aqua likes to draw shadows and stuff outside
// the bounds we give it, and clipping to the exact rect looks horrible. // the bounds we give it, and clipping to the exact rect looks horrible.
@ -611,6 +676,17 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame*
break; break;
} }
case NS_THEME_LISTBOX:
DrawListBox(macRect, IsDisabled(aFrame));
break;
case NS_THEME_TAB:
DrawTab(macRect, IsDisabled(aFrame), IsSelected(aFrame), PR_TRUE, eventState);
break;
case NS_THEME_TAB_PANELS:
DrawTabPanel(macRect, IsDisabled(aFrame));
break;
} }
::SetClip(oldClip); ::SetClip(oldClip);
@ -632,9 +708,9 @@ nsNativeThemeMac::GetWidgetBorder(nsIDeviceContext* aContext,
{ {
aResult->SizeTo(0,0,0,0); aResult->SizeTo(0,0,0,0);
#if TARGET_CARBON
// XXX we should probably cache some of these metrics // XXX we should probably cache some of these metrics
#if TARGET_CARBON
switch ( aWidgetType ) { switch ( aWidgetType ) {
case NS_THEME_BUTTON: case NS_THEME_BUTTON:
@ -665,6 +741,14 @@ nsNativeThemeMac::GetWidgetBorder(nsIDeviceContext* aContext,
break; break;
} }
case NS_THEME_LISTBOX:
{
SInt32 frameOutset = 0;
::GetThemeMetric(kThemeMetricListBoxFrameOutset, &frameOutset);
aResult->SizeTo(frameOutset, frameOutset, frameOutset, frameOutset);
break;
}
} }
#endif #endif
@ -788,6 +872,7 @@ nsNativeThemeMac::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
case NS_THEME_TOOLTIP: case NS_THEME_TOOLTIP:
case NS_THEME_TAB_PANELS: case NS_THEME_TAB_PANELS:
case NS_THEME_TAB_PANEL: case NS_THEME_TAB_PANEL:
case NS_THEME_TEXTFIELD:
*aShouldRepaint = PR_FALSE; *aShouldRepaint = PR_FALSE;
return NS_OK; return NS_OK;
} }
@ -847,6 +932,13 @@ nsNativeThemeMac::ThemeSupportsWidget(nsIPresContext* aPresContext,
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL: case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
case NS_THEME_TREEVIEW_TWISTY: case NS_THEME_TREEVIEW_TWISTY:
case NS_THEME_LISTBOX:
case NS_THEME_TAB_PANELS:
case NS_THEME_TAB:
case NS_THEME_TAB_LEFT_EDGE:
case NS_THEME_TAB_RIGHT_EDGE:
case NS_THEME_SCROLLBAR: case NS_THEME_SCROLLBAR:
case NS_THEME_SCROLLBAR_BUTTON_UP: case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN: case NS_THEME_SCROLLBAR_BUTTON_DOWN:

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

@ -75,8 +75,6 @@ public:
protected: protected:
//nsresult GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType,
// PRInt32& aPart, PRInt32& aState);
nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID); nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont); nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);
@ -91,10 +89,14 @@ protected:
void DrawRadio ( const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState ) ; void DrawRadio ( const Rect& inBoxRect, PRBool inChecked, PRBool inDisabled, PRInt32 inState ) ;
void DrawToolbar ( const Rect& inBoxRect ) ; void DrawToolbar ( const Rect& inBoxRect ) ;
void DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled ) ; void DrawEditText ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
void DrawListBox ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
void DrawProgress ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsIndeterminate, void DrawProgress ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsIndeterminate,
PRBool inIsHorizontal, PRInt32 inValue ) ; PRBool inIsHorizontal, PRInt32 inValue ) ;
void DrawFullScrollbar ( const Rect& inScrollbarRect, PRInt32 inWidgetHit, PRInt32 inLineHeight, PRBool inIsDisabled, void DrawFullScrollbar ( const Rect& inScrollbarRect, PRInt32 inWidgetHit, PRInt32 inLineHeight, PRBool inIsDisabled,
PRInt32 inMax, PRInt32 inValue, PRInt32 inState ) ; PRInt32 inMax, PRInt32 inValue, PRInt32 inState ) ;
void DrawTab ( const Rect& inBoxRect, PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRInt32 inState ) ;
void DrawTabPanel ( const Rect& inBoxRect, PRBool inIsDisabled ) ;
// void DrawScrollArrows ( const Rect& inScrollbarRect, PRBool inIsDisabled, PRInt32 inWidget, PRInt32 inState ) ; // void DrawScrollArrows ( const Rect& inScrollbarRect, PRBool inIsDisabled, PRInt32 inWidget, PRInt32 inState ) ;
void DrawButton ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inIsDefault, void DrawButton ( ThemeButtonKind inKind, const Rect& inBoxRect, PRBool inIsDefault,