зеркало из https://github.com/mozilla/gecko-dev.git
Bug 970079 - Native theming for MacOS X help buttons, widget part. r=mstange, roc.
This commit is contained in:
Родитель
2f973a3734
Коммит
e25b790a1a
|
@ -256,6 +256,9 @@
|
|||
#define NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR 224
|
||||
#define NS_THEME_MOZ_MAC_FULLSCREEN_BUTTON 226
|
||||
|
||||
// Mac help button
|
||||
#define NS_THEME_MOZ_MAC_HELP_BUTTON 227
|
||||
|
||||
// Vista glass
|
||||
#define NS_THEME_WIN_BORDERLESS_GLASS 229
|
||||
#define NS_THEME_WIN_GLASS 230
|
||||
|
|
|
@ -703,6 +703,7 @@ CSS_KEY(-moz-window-button-maximize, _moz_window_button_maximize)
|
|||
CSS_KEY(-moz-window-button-restore, _moz_window_button_restore)
|
||||
CSS_KEY(-moz-window-button-box, _moz_window_button_box)
|
||||
CSS_KEY(-moz-window-button-box-maximized, _moz_window_button_box_maximized)
|
||||
CSS_KEY(-moz-mac-help-button, _moz_mac_help_button)
|
||||
CSS_KEY(-moz-mac-unified-toolbar, _moz_mac_unified_toolbar)
|
||||
CSS_KEY(-moz-win-exclude-glass, _moz_win_exclude_glass)
|
||||
CSS_KEY(alphabetic, alphabetic)
|
||||
|
|
|
@ -654,6 +654,7 @@ const KTableValue nsCSSProps::kAppearanceKTable[] = {
|
|||
eCSSKeyword__moz_win_borderless_glass, NS_THEME_WIN_BORDERLESS_GLASS,
|
||||
eCSSKeyword__moz_mac_unified_toolbar, NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR,
|
||||
eCSSKeyword__moz_mac_fullscreen_button, NS_THEME_MOZ_MAC_FULLSCREEN_BUTTON,
|
||||
eCSSKeyword__moz_mac_help_button, NS_THEME_MOZ_MAC_HELP_BUTTON,
|
||||
eCSSKeyword__moz_window_titlebar, NS_THEME_WINDOW_TITLEBAR,
|
||||
eCSSKeyword__moz_window_titlebar_maximized, NS_THEME_WINDOW_TITLEBAR_MAXIMIZED,
|
||||
eCSSKeyword__moz_window_frame_left, NS_THEME_WINDOW_FRAME_LEFT,
|
||||
|
|
|
@ -93,7 +93,8 @@ protected:
|
|||
void DrawSearchField(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||
nsIFrame* aFrame, nsEventStates inState);
|
||||
void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||
nsEventStates inState, nsIFrame* aFrame);
|
||||
nsEventStates inState, uint8_t aWidgetType,
|
||||
nsIFrame* aFrame);
|
||||
void DrawButton(CGContextRef context, ThemeButtonKind inKind,
|
||||
const HIRect& inBoxRect, bool inIsDefault,
|
||||
ThemeButtonValue inValue, ThemeButtonAdornment inAdornment,
|
||||
|
@ -125,6 +126,7 @@ protected:
|
|||
nsIFrame* GetParentScrollbarFrame(nsIFrame *aFrame);
|
||||
|
||||
private:
|
||||
NSButtonCell* mHelpButtonCell;
|
||||
NSButtonCell* mPushButtonCell;
|
||||
NSButtonCell* mRadioButtonCell;
|
||||
NSButtonCell* mCheckboxCell;
|
||||
|
|
|
@ -465,6 +465,11 @@ nsNativeThemeCocoa::nsNativeThemeCocoa()
|
|||
// before the main event-loop pool is in place
|
||||
nsAutoreleasePool pool;
|
||||
|
||||
mHelpButtonCell = [[NSButtonCell alloc] initTextCell:nil];
|
||||
[mHelpButtonCell setBezelStyle:NSHelpButtonBezelStyle];
|
||||
[mHelpButtonCell setButtonType:NSMomentaryPushInButton];
|
||||
[mHelpButtonCell setHighlightsBy:NSPushInCellMask];
|
||||
|
||||
mPushButtonCell = [[NSButtonCell alloc] initTextCell:nil];
|
||||
[mPushButtonCell setButtonType:NSMomentaryPushInButton];
|
||||
[mPushButtonCell setHighlightsBy:NSPushInCellMask];
|
||||
|
@ -509,6 +514,7 @@ nsNativeThemeCocoa::~nsNativeThemeCocoa()
|
|||
|
||||
[mMeterBarCell release];
|
||||
[mProgressBarCell release];
|
||||
[mHelpButtonCell release];
|
||||
[mPushButtonCell release];
|
||||
[mRadioButtonCell release];
|
||||
[mCheckboxCell release];
|
||||
|
@ -960,6 +966,8 @@ nsNativeThemeCocoa::DrawSearchField(CGContextRef cgContext, const HIRect& inBoxR
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
static const NSSize kHelpButtonSize = NSMakeSize(20, 20);
|
||||
|
||||
static const CellRenderSettings pushButtonSettings = {
|
||||
{
|
||||
NSMakeSize(0, 16), // mini
|
||||
|
@ -987,30 +995,38 @@ static const CellRenderSettings pushButtonSettings = {
|
|||
|
||||
void
|
||||
nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||
nsEventStates inState, nsIFrame* aFrame)
|
||||
nsEventStates inState, uint8_t aWidgetType,
|
||||
nsIFrame* aFrame)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
BOOL isActive = FrameIsInActiveWindow(aFrame);
|
||||
BOOL isDisabled = IsDisabled(aFrame, inState);
|
||||
|
||||
[mPushButtonCell setEnabled:!isDisabled];
|
||||
[mPushButtonCell setHighlighted:isActive &&
|
||||
inState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER)];
|
||||
[mPushButtonCell setShowsFirstResponder:inState.HasState(NS_EVENT_STATE_FOCUS) && !isDisabled && isActive];
|
||||
NSButtonCell* cell = (aWidgetType == NS_THEME_MOZ_MAC_HELP_BUTTON) ? mHelpButtonCell : mPushButtonCell;
|
||||
[cell setEnabled:!isDisabled];
|
||||
[cell setHighlighted:isActive &&
|
||||
inState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER)];
|
||||
[cell setShowsFirstResponder:inState.HasState(NS_EVENT_STATE_FOCUS) && !isDisabled && isActive];
|
||||
|
||||
// If the button is tall enough, draw the square button style so that buttons with
|
||||
// non-standard content look good. Otherwise draw normal rounded aqua buttons.
|
||||
if (inBoxRect.size.height > DO_SQUARE_BUTTON_HEIGHT) {
|
||||
[mPushButtonCell setBezelStyle:NSShadowlessSquareBezelStyle];
|
||||
DrawCellWithScaling(mPushButtonCell, cgContext, inBoxRect, NSRegularControlSize,
|
||||
NSZeroSize, NSMakeSize(14, 0), NULL,
|
||||
mCellDrawView, IsFrameRTL(aFrame));
|
||||
if (aWidgetType == NS_THEME_MOZ_MAC_HELP_BUTTON) {
|
||||
DrawCellWithScaling(cell, cgContext, inBoxRect, NSRegularControlSize,
|
||||
NSZeroSize, kHelpButtonSize, NULL, mCellDrawView,
|
||||
false); // Don't mirror icon in RTL.
|
||||
} else {
|
||||
[mPushButtonCell setBezelStyle:NSRoundedBezelStyle];
|
||||
|
||||
DrawCellWithSnapping(mPushButtonCell, cgContext, inBoxRect, pushButtonSettings,
|
||||
0.5f, mCellDrawView, IsFrameRTL(aFrame), 1.0f);
|
||||
// If the button is tall enough, draw the square button style so that
|
||||
// buttons with non-standard content look good. Otherwise draw normal
|
||||
// rounded aqua buttons.
|
||||
if (inBoxRect.size.height > DO_SQUARE_BUTTON_HEIGHT) {
|
||||
[cell setBezelStyle:NSShadowlessSquareBezelStyle];
|
||||
DrawCellWithScaling(cell, cgContext, inBoxRect, NSRegularControlSize,
|
||||
NSZeroSize, NSMakeSize(14, 0), NULL, mCellDrawView,
|
||||
IsFrameRTL(aFrame));
|
||||
} else {
|
||||
[cell setBezelStyle:NSRoundedBezelStyle];
|
||||
DrawCellWithSnapping(cell, cgContext, inBoxRect, pushButtonSettings, 0.5f,
|
||||
mCellDrawView, IsFrameRTL(aFrame), 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
#if DRAW_IN_FRAME_DEBUG
|
||||
|
@ -2240,10 +2256,14 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
|
|||
} else if (IsButtonTypeMenu(aFrame)) {
|
||||
DrawDropdown(cgContext, macRect, eventState, aWidgetType, aFrame);
|
||||
} else {
|
||||
DrawPushButton(cgContext, macRect, eventState, aFrame);
|
||||
DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame);
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_THEME_MOZ_MAC_HELP_BUTTON:
|
||||
DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame);
|
||||
break;
|
||||
|
||||
case NS_THEME_BUTTON_BEVEL:
|
||||
DrawButton(cgContext, kThemeMediumBevelButton, macRect,
|
||||
IsDefaultButton(aFrame), kThemeButtonOff, kThemeAdornmentNone,
|
||||
|
@ -2821,6 +2841,7 @@ nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFram
|
|||
int32_t p2a = aContext->AppUnitsPerDevPixel();
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_BUTTON:
|
||||
case NS_THEME_MOZ_MAC_HELP_BUTTON:
|
||||
case NS_THEME_TOOLBAR_BUTTON:
|
||||
case NS_THEME_NUMBER_INPUT:
|
||||
case NS_THEME_TEXTFIELD:
|
||||
|
@ -2882,6 +2903,13 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsRenderingContext* aContext,
|
|||
break;
|
||||
}
|
||||
|
||||
case NS_THEME_MOZ_MAC_HELP_BUTTON:
|
||||
{
|
||||
aResult->SizeTo(kHelpButtonSize.width, kHelpButtonSize.height);
|
||||
*aIsOverridable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
case NS_THEME_TOOLBAR_BUTTON:
|
||||
{
|
||||
aResult->SizeTo(0, toolbarButtonHeights[miniControlSize]);
|
||||
|
@ -3252,6 +3280,7 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a
|
|||
case NS_THEME_RADIO:
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
case NS_THEME_GROUPBOX:
|
||||
case NS_THEME_MOZ_MAC_HELP_BUTTON:
|
||||
case NS_THEME_BUTTON:
|
||||
case NS_THEME_BUTTON_BEVEL:
|
||||
case NS_THEME_TOOLBAR_BUTTON:
|
||||
|
@ -3345,6 +3374,7 @@ nsNativeThemeCocoa::WidgetIsContainer(uint8_t aWidgetType)
|
|||
case NS_THEME_PROGRESSBAR:
|
||||
case NS_THEME_METERBAR:
|
||||
case NS_THEME_RANGE:
|
||||
case NS_THEME_MOZ_MAC_HELP_BUTTON:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -3357,6 +3387,7 @@ nsNativeThemeCocoa::ThemeDrawsFocusForWidget(uint8_t aWidgetType)
|
|||
if (aWidgetType == NS_THEME_DROPDOWN ||
|
||||
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_BUTTON ||
|
||||
aWidgetType == NS_THEME_MOZ_MAC_HELP_BUTTON ||
|
||||
aWidgetType == NS_THEME_RADIO ||
|
||||
aWidgetType == NS_THEME_RANGE ||
|
||||
aWidgetType == NS_THEME_CHECKBOX)
|
||||
|
|
Загрузка…
Ссылка в новой задаче