зеркало из https://github.com/mozilla/gecko-dev.git
make widgets appear inactive when they are backgrounded. patch by Markus Stange. b=54488 r=josh sr=roc a=schrep
This commit is contained in:
Родитель
b63056a1c2
Коммит
a1ccc68144
|
@ -2495,6 +2495,9 @@ NSEvent* gLastDragEvent = nil;
|
||||||
nsGUIEvent focusGuiEvent(PR_TRUE, eventType, mGeckoChild);
|
nsGUIEvent focusGuiEvent(PR_TRUE, eventType, mGeckoChild);
|
||||||
focusGuiEvent.time = PR_IntervalNow();
|
focusGuiEvent.time = PR_IntervalNow();
|
||||||
mGeckoChild->DispatchEvent(&focusGuiEvent, status);
|
mGeckoChild->DispatchEvent(&focusGuiEvent, status);
|
||||||
|
|
||||||
|
// invalidate so that things with a different appearance in background windows will redraw
|
||||||
|
mGeckoChild->Invalidate(PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,37 +95,38 @@ protected:
|
||||||
nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);
|
nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);
|
||||||
|
|
||||||
// HITheme drawing routines
|
// HITheme drawing routines
|
||||||
void DrawFrame (CGContextRef context, HIThemeFrameKind inKind,
|
void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
|
||||||
const HIRect& inBoxRect, PRBool inIsDisabled,
|
const HIRect& inBoxRect, PRBool inIsDisabled,
|
||||||
PRInt32 inState);
|
PRInt32 inState);
|
||||||
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
|
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
|
||||||
PRBool inIsIndeterminate, PRBool inIsHorizontal,
|
PRBool inIsIndeterminate, PRBool inIsHorizontal,
|
||||||
PRInt32 inValue);
|
PRInt32 inValue, nsIFrame* aFrame);
|
||||||
void DrawTab (CGContextRef context, const HIRect& inBoxRect,
|
void DrawTab(CGContextRef context, const HIRect& inBoxRect,
|
||||||
PRBool inIsDisabled, PRBool inIsFrontmost,
|
PRBool inIsDisabled, PRBool inIsFrontmost,
|
||||||
PRBool inIsHorizontal, PRBool inTabBottom,
|
PRBool inIsHorizontal, PRBool inTabBottom,
|
||||||
PRInt32 inState);
|
PRInt32 inState, nsIFrame* aFrame);
|
||||||
void DrawTabPanel (CGContextRef context, const HIRect& inBoxRect);
|
void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame);
|
||||||
void DrawScale (CGContextRef context, const HIRect& inBoxRect,
|
void DrawScale(CGContextRef context, const HIRect& inBoxRect,
|
||||||
PRBool inIsDisabled, PRInt32 inState,
|
PRBool inIsDisabled, PRInt32 inState,
|
||||||
PRBool inDirection, PRBool inIsReverse,
|
PRBool inDirection, PRBool inIsReverse,
|
||||||
PRInt32 inCurrentValue,
|
PRInt32 inCurrentValue,
|
||||||
PRInt32 inMinValue, PRInt32 inMaxValue);
|
PRInt32 inMinValue, PRInt32 inMaxValue, nsIFrame* aFrame);
|
||||||
void DrawRadioButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inSelected,
|
void DrawRadioButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inSelected,
|
||||||
PRBool inDisabled, PRInt32 inState);
|
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame);
|
||||||
void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inIsDefault,
|
void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inIsDefault,
|
||||||
PRBool inDisabled, PRInt32 inState);
|
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame);
|
||||||
void DrawButton (CGContextRef context, ThemeButtonKind inKind,
|
void DrawButton(CGContextRef context, ThemeButtonKind inKind,
|
||||||
const HIRect& inBoxRect, PRBool inIsDefault,
|
const HIRect& inBoxRect, PRBool inIsDefault,
|
||||||
PRBool inDisabled, ThemeButtonValue inValue,
|
PRBool inDisabled, ThemeButtonValue inValue,
|
||||||
ThemeButtonAdornment inAdornment, PRInt32 inState);
|
ThemeButtonAdornment inAdornment, PRInt32 inState,
|
||||||
void DrawSpinButtons (CGContextRef context, ThemeButtonKind inKind,
|
nsIFrame* aFrame);
|
||||||
const HIRect& inBoxRect,
|
void DrawSpinButtons(CGContextRef context, ThemeButtonKind inKind,
|
||||||
PRBool inDisabled, ThemeDrawState inDrawState,
|
const HIRect& inBoxRect, PRBool inDisabled,
|
||||||
ThemeButtonAdornment inAdornment, PRInt32 inState);
|
ThemeDrawState inDrawState, ThemeButtonAdornment inAdornment,
|
||||||
|
PRInt32 inState, nsIFrame* aFrame);
|
||||||
void DrawCheckbox(CGContextRef context, ThemeButtonKind inKind,
|
void DrawCheckbox(CGContextRef context, ThemeButtonKind inKind,
|
||||||
const HIRect& inBoxRect, PRBool inChecked,
|
const HIRect& inBoxRect, PRBool inChecked,
|
||||||
PRBool inDisabled, PRInt32 inState);
|
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame);
|
||||||
// Scrollbars
|
// Scrollbars
|
||||||
void DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRect, nsIFrame *aFrame);
|
void DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRect, nsIFrame *aFrame);
|
||||||
void GetScrollbarPressStates (nsIFrame *aFrame, PRInt32 aButtonStates[]);
|
void GetScrollbarPressStates (nsIFrame *aFrame, PRInt32 aButtonStates[]);
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include "nsILookAndFeel.h"
|
#include "nsILookAndFeel.h"
|
||||||
#include "nsWidgetAtoms.h"
|
#include "nsWidgetAtoms.h"
|
||||||
#include "nsToolkit.h"
|
#include "nsToolkit.h"
|
||||||
|
#include "nsIWidget.h"
|
||||||
|
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
#include "gfxQuartzSurface.h"
|
#include "gfxQuartzSurface.h"
|
||||||
|
@ -146,26 +147,54 @@ nsNativeThemeCocoa::~nsNativeThemeCocoa()
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL frameIsInActiveWindow(nsIFrame* aFrame)
|
||||||
|
{
|
||||||
|
// default return value should be YES here, so things are painted as active by default
|
||||||
|
if (!aFrame)
|
||||||
|
return YES;
|
||||||
|
|
||||||
|
nsIWidget* widget = aFrame->GetWindow();
|
||||||
|
if (!widget)
|
||||||
|
return YES;
|
||||||
|
|
||||||
|
// get the top-level widget
|
||||||
|
nsIWidget* topLevelWidget;
|
||||||
|
while (widget) {
|
||||||
|
topLevelWidget = widget;
|
||||||
|
widget = widget->GetParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
NSWindow* nativeWindow = (NSWindow*)topLevelWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||||
|
if (!nativeWindow)
|
||||||
|
return YES;
|
||||||
|
|
||||||
|
nsWindowType windowType;
|
||||||
|
topLevelWidget->GetWindowType(windowType);
|
||||||
|
return [nativeWindow isKeyWindow] || (windowType == eWindowType_popup);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNativeThemeCocoa::DrawCheckbox(CGContextRef cgContext, ThemeButtonKind inKind,
|
nsNativeThemeCocoa::DrawCheckbox(CGContextRef cgContext, ThemeButtonKind inKind,
|
||||||
const HIRect& inBoxRect, PRBool inChecked,
|
const HIRect& inBoxRect, PRBool inChecked,
|
||||||
PRBool inDisabled, PRInt32 inState)
|
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
HIThemeButtonDrawInfo bdi;
|
HIThemeButtonDrawInfo bdi;
|
||||||
bdi.version = 0;
|
bdi.version = 0;
|
||||||
bdi.kind = inKind;
|
bdi.kind = inKind;
|
||||||
|
|
||||||
|
BOOL isInActiveWindow = frameIsInActiveWindow(aFrame);
|
||||||
|
|
||||||
if (inDisabled)
|
if (inDisabled)
|
||||||
bdi.state = kThemeStateUnavailable;
|
bdi.state = kThemeStateUnavailable;
|
||||||
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
|
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
|
||||||
bdi.state = kThemeStatePressed;
|
bdi.state = kThemeStatePressed;
|
||||||
else
|
else
|
||||||
bdi.state = kThemeStateActive;
|
bdi.state = isInActiveWindow ? kThemeStateActive : kThemeStateInactive;
|
||||||
|
|
||||||
bdi.value = inChecked ? kThemeButtonOn : kThemeButtonOff;
|
bdi.value = inChecked ? kThemeButtonOn : kThemeButtonOff;
|
||||||
bdi.adornment = (inState & NS_EVENT_STATE_FOCUS) ? kThemeAdornmentFocus : kThemeAdornmentNone;
|
bdi.adornment = (inState & NS_EVENT_STATE_FOCUS && isInActiveWindow) ? kThemeAdornmentFocus : kThemeAdornmentNone;
|
||||||
|
|
||||||
HIRect drawFrame = inBoxRect;
|
HIRect drawFrame = inBoxRect;
|
||||||
|
|
||||||
|
@ -317,7 +346,7 @@ nsNativeThemeCocoa::DrawCellWithScaling(NSCell *cell,
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are the sizes that Gecko needs to request to draw if it wants
|
// These are the sizes that Gecko needs to request to draw if it wants
|
||||||
// to get a standard-sized Aqua radio button drawn. Note that the rects
|
// to get a standard-sized Aqua radio button drawn. Note that the rects
|
||||||
// that draw these are actually a little bigger.
|
// that draw these are actually a little bigger.
|
||||||
|
@ -345,13 +374,13 @@ static const float radioButtonMargins[2][3][4] =
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNativeThemeCocoa::DrawRadioButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inSelected,
|
nsNativeThemeCocoa::DrawRadioButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inSelected,
|
||||||
PRBool inDisabled, PRInt32 inState)
|
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
NSRect drawRect = NSMakeRect(inBoxRect.origin.x, inBoxRect.origin.y, inBoxRect.size.width, inBoxRect.size.height);
|
NSRect drawRect = NSMakeRect(inBoxRect.origin.x, inBoxRect.origin.y, inBoxRect.size.width, inBoxRect.size.height);
|
||||||
|
|
||||||
[mRadioButtonCell setEnabled:!inDisabled];
|
[mRadioButtonCell setEnabled:(!inDisabled && frameIsInActiveWindow(aFrame))];
|
||||||
[mRadioButtonCell setShowsFirstResponder:(inState & NS_EVENT_STATE_FOCUS)];
|
[mRadioButtonCell setShowsFirstResponder:(inState & NS_EVENT_STATE_FOCUS)];
|
||||||
[mRadioButtonCell setState:(inSelected ? NSOnState : NSOffState)];
|
[mRadioButtonCell setState:(inSelected ? NSOnState : NSOffState)];
|
||||||
[mRadioButtonCell setHighlighted:((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))];
|
[mRadioButtonCell setHighlighted:((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))];
|
||||||
|
@ -403,15 +432,20 @@ static const float pushButtonMargins[2][3][4] =
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inIsDefault,
|
nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect, PRBool inIsDefault,
|
||||||
PRBool inDisabled, PRInt32 inState)
|
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
NSRect drawRect = NSMakeRect(inBoxRect.origin.x, inBoxRect.origin.y, inBoxRect.size.width, inBoxRect.size.height);
|
NSRect drawRect = NSMakeRect(inBoxRect.origin.x, inBoxRect.origin.y, inBoxRect.size.width, inBoxRect.size.height);
|
||||||
|
|
||||||
|
BOOL isInActiveWindow = frameIsInActiveWindow(aFrame);
|
||||||
|
|
||||||
[mPushButtonCell setEnabled:!inDisabled];
|
[mPushButtonCell setEnabled:!inDisabled];
|
||||||
[mPushButtonCell setHighlighted:((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER) || (inIsDefault && !inDisabled))];
|
[mPushButtonCell setHighlighted:(((inState & NS_EVENT_STATE_ACTIVE) &&
|
||||||
[mPushButtonCell setShowsFirstResponder:(inState & NS_EVENT_STATE_FOCUS)];
|
(inState & NS_EVENT_STATE_HOVER) ||
|
||||||
|
(inIsDefault && !inDisabled)) &&
|
||||||
|
isInActiveWindow)];
|
||||||
|
[mPushButtonCell setShowsFirstResponder:(inState & NS_EVENT_STATE_FOCUS) && !inDisabled && isInActiveWindow];
|
||||||
|
|
||||||
CGAffineTransform savedCTM = CGContextGetCTM(cgContext);
|
CGAffineTransform savedCTM = CGContextGetCTM(cgContext);
|
||||||
|
|
||||||
|
@ -475,7 +509,7 @@ void
|
||||||
nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
|
nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
|
||||||
const HIRect& inBoxRect, PRBool inIsDefault, PRBool inDisabled,
|
const HIRect& inBoxRect, PRBool inIsDefault, PRBool inDisabled,
|
||||||
ThemeButtonValue inValue, ThemeButtonAdornment inAdornment,
|
ThemeButtonValue inValue, ThemeButtonAdornment inAdornment,
|
||||||
PRInt32 inState)
|
PRInt32 inState, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
|
@ -485,12 +519,18 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
|
||||||
bdi.value = inValue;
|
bdi.value = inValue;
|
||||||
bdi.adornment = inAdornment;
|
bdi.adornment = inAdornment;
|
||||||
|
|
||||||
if (inDisabled)
|
if (inDisabled) {
|
||||||
bdi.state = kThemeStateUnavailable;
|
bdi.state = kThemeStateUnavailable;
|
||||||
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
|
}
|
||||||
|
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER)) {
|
||||||
bdi.state = kThemeStatePressed;
|
bdi.state = kThemeStatePressed;
|
||||||
else
|
}
|
||||||
bdi.state = (inKind == kThemeArrowButton) ? kThemeStateUnavailable : kThemeStateActive;
|
else {
|
||||||
|
if (inKind == kThemeArrowButton)
|
||||||
|
bdi.state = kThemeStateUnavailable; // these are always drawn as unavailable
|
||||||
|
else
|
||||||
|
bdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
|
||||||
|
}
|
||||||
|
|
||||||
if (inState & NS_EVENT_STATE_FOCUS)
|
if (inState & NS_EVENT_STATE_FOCUS)
|
||||||
bdi.adornment |= kThemeAdornmentFocus;
|
bdi.adornment |= kThemeAdornmentFocus;
|
||||||
|
@ -602,7 +642,7 @@ nsNativeThemeCocoa::DrawSpinButtons(CGContextRef cgContext, ThemeButtonKind inKi
|
||||||
const HIRect& inBoxRect, PRBool inDisabled,
|
const HIRect& inBoxRect, PRBool inDisabled,
|
||||||
ThemeDrawState inDrawState,
|
ThemeDrawState inDrawState,
|
||||||
ThemeButtonAdornment inAdornment,
|
ThemeButtonAdornment inAdornment,
|
||||||
PRInt32 inState)
|
PRInt32 inState, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
|
@ -615,6 +655,8 @@ nsNativeThemeCocoa::DrawSpinButtons(CGContextRef cgContext, ThemeButtonKind inKi
|
||||||
|
|
||||||
if (inDisabled)
|
if (inDisabled)
|
||||||
bdi.state = kThemeStateUnavailable;
|
bdi.state = kThemeStateUnavailable;
|
||||||
|
else
|
||||||
|
bdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
|
||||||
|
|
||||||
HIThemeDrawButton(&inBoxRect, &bdi, cgContext, HITHEME_ORIENTATION, NULL);
|
HIThemeDrawButton(&inBoxRect, &bdi, cgContext, HITHEME_ORIENTATION, NULL);
|
||||||
|
|
||||||
|
@ -624,14 +666,19 @@ nsNativeThemeCocoa::DrawSpinButtons(CGContextRef cgContext, ThemeButtonKind inKi
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNativeThemeCocoa::DrawFrame(CGContextRef cgContext, HIThemeFrameKind inKind,
|
nsNativeThemeCocoa::DrawFrame(CGContextRef cgContext, HIThemeFrameKind inKind,
|
||||||
const HIRect& inBoxRect, PRBool inIsDisabled, PRInt32 inState)
|
const HIRect& inBoxRect, PRBool inIsDisabled,
|
||||||
|
PRInt32 inState)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
HIThemeFrameDrawInfo fdi;
|
HIThemeFrameDrawInfo fdi;
|
||||||
fdi.version = 0;
|
fdi.version = 0;
|
||||||
fdi.kind = inKind;
|
fdi.kind = inKind;
|
||||||
|
|
||||||
|
// We don't ever set an inactive state for this because it doesn't
|
||||||
|
// look right(see other apps).
|
||||||
fdi.state = inIsDisabled ? kThemeStateUnavailable : kThemeStateActive;
|
fdi.state = inIsDisabled ? kThemeStateUnavailable : kThemeStateActive;
|
||||||
|
|
||||||
// for some reason focus rings on listboxes draw incorrectly
|
// for some reason focus rings on listboxes draw incorrectly
|
||||||
if (inKind == kHIThemeFrameListBox)
|
if (inKind == kHIThemeFrameListBox)
|
||||||
fdi.isFocused = 0;
|
fdi.isFocused = 0;
|
||||||
|
@ -671,9 +718,9 @@ nsNativeThemeCocoa::DrawFrame(CGContextRef cgContext, HIThemeFrameKind inKind,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext,
|
nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||||
const HIRect& inBoxRect, PRBool inIsIndeterminate,
|
PRBool inIsIndeterminate, PRBool inIsHorizontal,
|
||||||
PRBool inIsHorizontal, PRInt32 inValue)
|
PRInt32 inValue, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
|
@ -689,7 +736,7 @@ nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext,
|
||||||
tdi.max = 100;
|
tdi.max = 100;
|
||||||
tdi.value = inValue;
|
tdi.value = inValue;
|
||||||
tdi.attributes = inIsHorizontal ? kThemeTrackHorizontal : 0;
|
tdi.attributes = inIsHorizontal ? kThemeTrackHorizontal : 0;
|
||||||
tdi.enableState = kThemeTrackActive;
|
tdi.enableState = frameIsInActiveWindow(aFrame) ? kThemeTrackActive : kThemeTrackInactive;
|
||||||
tdi.trackInfo.progress.phase = PR_IntervalToMilliseconds(PR_IntervalNow()) /
|
tdi.trackInfo.progress.phase = PR_IntervalToMilliseconds(PR_IntervalNow()) /
|
||||||
milliSecondsPerStep % 16;
|
milliSecondsPerStep % 16;
|
||||||
|
|
||||||
|
@ -700,14 +747,15 @@ nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNativeThemeCocoa::DrawTabPanel(CGContextRef cgContext, const HIRect& inBoxRect)
|
nsNativeThemeCocoa::DrawTabPanel(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||||
|
nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
HIThemeTabPaneDrawInfo tpdi;
|
HIThemeTabPaneDrawInfo tpdi;
|
||||||
|
|
||||||
tpdi.version = 0;
|
tpdi.version = 0;
|
||||||
tpdi.state = kThemeStateActive;
|
tpdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
|
||||||
tpdi.direction = kThemeTabNorth;
|
tpdi.direction = kThemeTabNorth;
|
||||||
tpdi.size = kHIThemeTabSizeNormal;
|
tpdi.size = kHIThemeTabSizeNormal;
|
||||||
|
|
||||||
|
@ -721,8 +769,8 @@ void
|
||||||
nsNativeThemeCocoa::DrawScale(CGContextRef cgContext, const HIRect& inBoxRect,
|
nsNativeThemeCocoa::DrawScale(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||||
PRBool inIsDisabled, PRInt32 inState,
|
PRBool inIsDisabled, PRInt32 inState,
|
||||||
PRBool inIsVertical, PRBool inIsReverse,
|
PRBool inIsVertical, PRBool inIsReverse,
|
||||||
PRInt32 inCurrentValue,
|
PRInt32 inCurrentValue, PRInt32 inMinValue,
|
||||||
PRInt32 inMinValue, PRInt32 inMaxValue)
|
PRInt32 inMaxValue, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
|
@ -741,7 +789,10 @@ nsNativeThemeCocoa::DrawScale(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||||
tdi.attributes |= kThemeTrackRightToLeft;
|
tdi.attributes |= kThemeTrackRightToLeft;
|
||||||
if (inState & NS_EVENT_STATE_FOCUS)
|
if (inState & NS_EVENT_STATE_FOCUS)
|
||||||
tdi.attributes |= kThemeTrackHasFocus;
|
tdi.attributes |= kThemeTrackHasFocus;
|
||||||
tdi.enableState = inIsDisabled ? kThemeTrackDisabled : kThemeTrackActive;
|
if (inIsDisabled)
|
||||||
|
tdi.enableState = kThemeTrackDisabled;
|
||||||
|
else
|
||||||
|
tdi.enableState = frameIsInActiveWindow(aFrame) ? kThemeTrackActive : kThemeTrackInactive;
|
||||||
tdi.trackInfo.slider.thumbDir = kThemeThumbPlain;
|
tdi.trackInfo.slider.thumbDir = kThemeThumbPlain;
|
||||||
tdi.trackInfo.slider.pressState = 0;
|
tdi.trackInfo.slider.pressState = 0;
|
||||||
|
|
||||||
|
@ -755,7 +806,7 @@ void
|
||||||
nsNativeThemeCocoa::DrawTab(CGContextRef cgContext, const HIRect& inBoxRect,
|
nsNativeThemeCocoa::DrawTab(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||||
PRBool inIsDisabled, PRBool inIsFrontmost,
|
PRBool inIsDisabled, PRBool inIsFrontmost,
|
||||||
PRBool inIsHorizontal, PRBool inTabBottom,
|
PRBool inIsHorizontal, PRBool inTabBottom,
|
||||||
PRInt32 inState)
|
PRInt32 inState, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
|
@ -767,14 +818,14 @@ nsNativeThemeCocoa::DrawTab(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||||
if (inIsDisabled)
|
if (inIsDisabled)
|
||||||
tdi.style = kThemeTabFrontUnavailable;
|
tdi.style = kThemeTabFrontUnavailable;
|
||||||
else
|
else
|
||||||
tdi.style = kThemeTabFront;
|
tdi.style = frameIsInActiveWindow(aFrame) ? kThemeTabFront : kThemeTabFrontInactive;
|
||||||
} else {
|
} else {
|
||||||
if (inIsDisabled)
|
if (inIsDisabled)
|
||||||
tdi.style = kThemeTabNonFrontUnavailable;
|
tdi.style = kThemeTabNonFrontUnavailable;
|
||||||
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
|
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
|
||||||
tdi.style = kThemeTabNonFrontPressed;
|
tdi.style = kThemeTabNonFrontPressed;
|
||||||
else
|
else
|
||||||
tdi.style = kThemeTabNonFront;
|
tdi.style = frameIsInActiveWindow(aFrame) ? kThemeTabNonFront : kThemeTabNonFrontInactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't yet support vertical tabs
|
// don't yet support vertical tabs
|
||||||
|
@ -862,6 +913,13 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo(HIThemeTrackDrawInfo& aTdi, nsIFrame *a
|
||||||
|
|
||||||
aTdi.trackInfo.scrollbar.viewsize = (SInt32)thumbSize;
|
aTdi.trackInfo.scrollbar.viewsize = (SInt32)thumbSize;
|
||||||
|
|
||||||
|
// This should be done early on so things like "kThemeTrackNothingToScroll" can
|
||||||
|
// override the active enable state.
|
||||||
|
if (frameIsInActiveWindow(aFrame))
|
||||||
|
aTdi.enableState = kThemeTrackActive;
|
||||||
|
else
|
||||||
|
aTdi.enableState = kThemeTrackInactive;
|
||||||
|
|
||||||
/* Only display features if we have enough room for them.
|
/* Only display features if we have enough room for them.
|
||||||
* Gecko still maintains the scrollbar info; this is just a visual issue (bug 380185).
|
* Gecko still maintains the scrollbar info; this is just a visual issue (bug 380185).
|
||||||
*/
|
*/
|
||||||
|
@ -1099,26 +1157,26 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_CHECKBOX:
|
case NS_THEME_CHECKBOX:
|
||||||
DrawCheckbox(cgContext, kThemeCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState);
|
DrawCheckbox(cgContext, kThemeCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_CHECKBOX_SMALL:
|
case NS_THEME_CHECKBOX_SMALL:
|
||||||
DrawCheckbox(cgContext, kThemeSmallCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState);
|
DrawCheckbox(cgContext, kThemeSmallCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_RADIO:
|
case NS_THEME_RADIO:
|
||||||
case NS_THEME_RADIO_SMALL:
|
case NS_THEME_RADIO_SMALL:
|
||||||
DrawRadioButton(cgContext, macRect, IsSelected(aFrame), IsDisabled(aFrame), eventState);
|
DrawRadioButton(cgContext, macRect, IsSelected(aFrame), IsDisabled(aFrame), eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_BUTTON:
|
case NS_THEME_BUTTON:
|
||||||
DrawPushButton(cgContext, macRect, IsDefaultButton(aFrame), IsDisabled(aFrame), eventState);
|
DrawPushButton(cgContext, macRect, IsDefaultButton(aFrame), IsDisabled(aFrame), eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_BUTTON_BEVEL:
|
case NS_THEME_BUTTON_BEVEL:
|
||||||
DrawButton(cgContext, kThemeMediumBevelButton, macRect,
|
DrawButton(cgContext, kThemeMediumBevelButton, macRect,
|
||||||
IsDefaultButton(aFrame), IsDisabled(aFrame),
|
IsDefaultButton(aFrame), IsDisabled(aFrame),
|
||||||
kThemeButtonOff, kThemeAdornmentNone, eventState);
|
kThemeButtonOff, kThemeAdornmentNone, eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_SPINNER: {
|
case NS_THEME_SPINNER: {
|
||||||
|
@ -1134,14 +1192,14 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawSpinButtons(cgContext, kThemeIncDecButton, macRect, IsDisabled(aFrame),
|
DrawSpinButtons(cgContext, kThemeIncDecButton, macRect, IsDisabled(aFrame),
|
||||||
state, kThemeAdornmentNone, eventState);
|
state, kThemeAdornmentNone, eventState, aFrame);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_TOOLBAR_BUTTON:
|
case NS_THEME_TOOLBAR_BUTTON:
|
||||||
DrawButton(cgContext, kThemePushButton, macRect,
|
DrawButton(cgContext, kThemePushButton, macRect,
|
||||||
IsDefaultButton(aFrame), IsDisabled(aFrame),
|
IsDefaultButton(aFrame), IsDisabled(aFrame),
|
||||||
kThemeButtonOn, kThemeAdornmentNone, eventState);
|
kThemeButtonOn, kThemeAdornmentNone, eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_TOOLBAR_SEPARATOR: {
|
case NS_THEME_TOOLBAR_SEPARATOR: {
|
||||||
|
@ -1161,13 +1219,13 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
case NS_THEME_DROPDOWN:
|
case NS_THEME_DROPDOWN:
|
||||||
DrawButton(cgContext, kThemePopupButton, macRect,
|
DrawButton(cgContext, kThemePopupButton, macRect,
|
||||||
IsDefaultButton(aFrame), IsDisabled(aFrame),
|
IsDefaultButton(aFrame), IsDisabled(aFrame),
|
||||||
kThemeButtonOn, kThemeAdornmentNone, eventState);
|
kThemeButtonOn, kThemeAdornmentNone, eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_DROPDOWN_BUTTON:
|
case NS_THEME_DROPDOWN_BUTTON:
|
||||||
DrawButton (cgContext, kThemeArrowButton, macRect, PR_FALSE,
|
DrawButton(cgContext, kThemeArrowButton, macRect, PR_FALSE,
|
||||||
IsDisabled(aFrame), kThemeButtonOn,
|
IsDisabled(aFrame), kThemeButtonOn,
|
||||||
kThemeAdornmentArrowDownArrow, eventState);
|
kThemeAdornmentArrowDownArrow, eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_GROUPBOX: {
|
case NS_THEME_GROUPBOX: {
|
||||||
|
@ -1195,12 +1253,12 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
|
|
||||||
case NS_THEME_PROGRESSBAR:
|
case NS_THEME_PROGRESSBAR:
|
||||||
DrawProgress(cgContext, macRect, IsIndeterminateProgress(aFrame),
|
DrawProgress(cgContext, macRect, IsIndeterminateProgress(aFrame),
|
||||||
PR_TRUE, GetProgressValue(aFrame));
|
PR_TRUE, GetProgressValue(aFrame), aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_PROGRESSBAR_VERTICAL:
|
case NS_THEME_PROGRESSBAR_VERTICAL:
|
||||||
DrawProgress(cgContext, macRect, IsIndeterminateProgress(aFrame),
|
DrawProgress(cgContext, macRect, IsIndeterminateProgress(aFrame),
|
||||||
PR_FALSE, GetProgressValue(aFrame));
|
PR_FALSE, GetProgressValue(aFrame), aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_PROGRESSBAR_CHUNK:
|
case NS_THEME_PROGRESSBAR_CHUNK:
|
||||||
|
@ -1210,12 +1268,12 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
|
|
||||||
case NS_THEME_TREEVIEW_TWISTY:
|
case NS_THEME_TREEVIEW_TWISTY:
|
||||||
DrawButton(cgContext, kThemeDisclosureButton, macRect, PR_FALSE, IsDisabled(aFrame),
|
DrawButton(cgContext, kThemeDisclosureButton, macRect, PR_FALSE, IsDisabled(aFrame),
|
||||||
kThemeDisclosureRight, kThemeAdornmentNone, eventState);
|
kThemeDisclosureRight, kThemeAdornmentNone, eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_TREEVIEW_TWISTY_OPEN:
|
case NS_THEME_TREEVIEW_TWISTY_OPEN:
|
||||||
DrawButton(cgContext, kThemeDisclosureButton, macRect, PR_FALSE, IsDisabled(aFrame),
|
DrawButton(cgContext, kThemeDisclosureButton, macRect, PR_FALSE, IsDisabled(aFrame),
|
||||||
kThemeDisclosureDown, kThemeAdornmentNone, eventState);
|
kThemeDisclosureDown, kThemeAdornmentNone, eventState, aFrame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_TREEVIEW_HEADER_CELL: {
|
case NS_THEME_TREEVIEW_HEADER_CELL: {
|
||||||
|
@ -1223,7 +1281,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
DrawButton(cgContext, kThemeListHeaderButton, macRect, PR_FALSE, IsDisabled(aFrame),
|
DrawButton(cgContext, kThemeListHeaderButton, macRect, PR_FALSE, IsDisabled(aFrame),
|
||||||
sortDirection == eTreeSortDirection_Natural ? kThemeButtonOff : kThemeButtonOn,
|
sortDirection == eTreeSortDirection_Natural ? kThemeButtonOff : kThemeButtonOn,
|
||||||
sortDirection == eTreeSortDirection_Descending ?
|
sortDirection == eTreeSortDirection_Descending ?
|
||||||
kThemeAdornmentHeaderButtonSortUp : kThemeAdornmentNone, eventState);
|
kThemeAdornmentHeaderButtonSortUp : kThemeAdornmentNone, eventState, aFrame);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1256,7 +1314,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
NS_LITERAL_STRING("reverse"), eCaseMatters);
|
NS_LITERAL_STRING("reverse"), eCaseMatters);
|
||||||
DrawScale(cgContext, macRect, IsDisabled(aFrame), eventState,
|
DrawScale(cgContext, macRect, IsDisabled(aFrame), eventState,
|
||||||
(aWidgetType == NS_THEME_SCALE_VERTICAL), reverse,
|
(aWidgetType == NS_THEME_SCALE_VERTICAL), reverse,
|
||||||
curpos, minpos, maxpos);
|
curpos, minpos, maxpos, aFrame);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1337,20 +1395,20 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
|
||||||
// HIThemeSetFill is not available on 10.3
|
// HIThemeSetFill is not available on 10.3
|
||||||
CGContextSetRGBFillColor(cgContext, 1.0, 1.0, 1.0, 1.0);
|
CGContextSetRGBFillColor(cgContext, 1.0, 1.0, 1.0, 1.0);
|
||||||
CGContextFillRect(cgContext, macRect);
|
CGContextFillRect(cgContext, macRect);
|
||||||
DrawFrame(cgContext, kHIThemeFrameListBox,
|
DrawFrame(cgContext, kHIThemeFrameListBox, macRect,
|
||||||
macRect, (IsDisabled(aFrame) || IsReadOnly(aFrame)), eventState);
|
(IsDisabled(aFrame) || IsReadOnly(aFrame)), eventState);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_TAB: {
|
case NS_THEME_TAB: {
|
||||||
DrawTab(cgContext, macRect,
|
DrawTab(cgContext, macRect,
|
||||||
IsDisabled(aFrame), IsSelectedTab(aFrame),
|
IsDisabled(aFrame), IsSelectedTab(aFrame),
|
||||||
PR_TRUE, IsBottomTab(aFrame),
|
PR_TRUE, IsBottomTab(aFrame),
|
||||||
eventState);
|
eventState, aFrame);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_THEME_TAB_PANELS:
|
case NS_THEME_TAB_PANELS:
|
||||||
DrawTabPanel(cgContext, macRect);
|
DrawTabPanel(cgContext, macRect, aFrame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче