1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/cocoa/nsNativeThemeCocoa.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,146 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsNativeThemeCocoa_h_ 1.10 +#define nsNativeThemeCocoa_h_ 1.11 + 1.12 +#import <Carbon/Carbon.h> 1.13 +#import <Cocoa/Cocoa.h> 1.14 + 1.15 +#include "nsITheme.h" 1.16 +#include "nsCOMPtr.h" 1.17 +#include "nsIAtom.h" 1.18 +#include "nsNativeTheme.h" 1.19 + 1.20 +@class CellDrawView; 1.21 +@class NSProgressBarCell; 1.22 +@class ContextAwareSearchFieldCell; 1.23 +class nsDeviceContext; 1.24 +struct SegmentedControlRenderSettings; 1.25 + 1.26 +namespace mozilla { 1.27 +class EventStates; 1.28 +} // namespace mozilla 1.29 + 1.30 +class nsNativeThemeCocoa : private nsNativeTheme, 1.31 + public nsITheme 1.32 +{ 1.33 +public: 1.34 + nsNativeThemeCocoa(); 1.35 + virtual ~nsNativeThemeCocoa(); 1.36 + 1.37 + NS_DECL_ISUPPORTS_INHERITED 1.38 + 1.39 + // The nsITheme interface. 1.40 + NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext, 1.41 + nsIFrame* aFrame, 1.42 + uint8_t aWidgetType, 1.43 + const nsRect& aRect, 1.44 + const nsRect& aDirtyRect); 1.45 + NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, 1.46 + nsIFrame* aFrame, 1.47 + uint8_t aWidgetType, 1.48 + nsIntMargin* aResult); 1.49 + 1.50 + virtual bool GetWidgetPadding(nsDeviceContext* aContext, 1.51 + nsIFrame* aFrame, 1.52 + uint8_t aWidgetType, 1.53 + nsIntMargin* aResult); 1.54 + 1.55 + virtual bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, 1.56 + uint8_t aWidgetType, nsRect* aOverflowRect); 1.57 + 1.58 + NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame, 1.59 + uint8_t aWidgetType, 1.60 + nsIntSize* aResult, bool* aIsOverridable); 1.61 + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, 1.62 + nsIAtom* aAttribute, bool* aShouldRepaint); 1.63 + NS_IMETHOD ThemeChanged(); 1.64 + bool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType); 1.65 + bool WidgetIsContainer(uint8_t aWidgetType); 1.66 + bool ThemeDrawsFocusForWidget(uint8_t aWidgetType) MOZ_OVERRIDE; 1.67 + bool ThemeNeedsComboboxDropmarker(); 1.68 + virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) MOZ_OVERRIDE; 1.69 + virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType); 1.70 + 1.71 + void DrawProgress(CGContextRef context, const HIRect& inBoxRect, 1.72 + bool inIsIndeterminate, bool inIsHorizontal, 1.73 + double inValue, double inMaxValue, nsIFrame* aFrame); 1.74 + 1.75 +protected: 1.76 + 1.77 + nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame); 1.78 + nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter); 1.79 + CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft, 1.80 + nsIFrame* aCurrent, nsIFrame* aRight); 1.81 + 1.82 + // HITheme drawing routines 1.83 + void DrawFrame(CGContextRef context, HIThemeFrameKind inKind, 1.84 + const HIRect& inBoxRect, bool inReadOnly, 1.85 + mozilla::EventStates inState); 1.86 + void DrawMeter(CGContextRef context, const HIRect& inBoxRect, 1.87 + nsIFrame* aFrame); 1.88 + void DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect, 1.89 + mozilla::EventStates inState, nsIFrame* aFrame, 1.90 + const SegmentedControlRenderSettings& aSettings); 1.91 + void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame); 1.92 + void DrawScale(CGContextRef context, const HIRect& inBoxRect, 1.93 + mozilla::EventStates inState, bool inDirection, 1.94 + bool inIsReverse, int32_t inCurrentValue, int32_t inMinValue, 1.95 + int32_t inMaxValue, nsIFrame* aFrame); 1.96 + void DrawCheckboxOrRadio(CGContextRef cgContext, bool inCheckbox, 1.97 + const HIRect& inBoxRect, bool inSelected, 1.98 + mozilla::EventStates inState, nsIFrame* aFrame); 1.99 + void DrawSearchField(CGContextRef cgContext, const HIRect& inBoxRect, 1.100 + nsIFrame* aFrame, mozilla::EventStates inState); 1.101 + void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect, 1.102 + mozilla::EventStates inState, uint8_t aWidgetType, 1.103 + nsIFrame* aFrame); 1.104 + void DrawButton(CGContextRef context, ThemeButtonKind inKind, 1.105 + const HIRect& inBoxRect, bool inIsDefault, 1.106 + ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, 1.107 + mozilla::EventStates inState, nsIFrame* aFrame); 1.108 + void DrawDropdown(CGContextRef context, const HIRect& inBoxRect, 1.109 + mozilla::EventStates inState, uint8_t aWidgetType, 1.110 + nsIFrame* aFrame); 1.111 + void DrawSpinButtons(CGContextRef context, ThemeButtonKind inKind, 1.112 + const HIRect& inBoxRect, ThemeDrawState inDrawState, 1.113 + ThemeButtonAdornment inAdornment, 1.114 + mozilla::EventStates inState, nsIFrame* aFrame); 1.115 + void DrawSpinButton(CGContextRef context, ThemeButtonKind inKind, 1.116 + const HIRect& inBoxRect, ThemeDrawState inDrawState, 1.117 + ThemeButtonAdornment inAdornment, 1.118 + mozilla::EventStates inState, 1.119 + nsIFrame* aFrame, uint8_t aWidgetType); 1.120 + void DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inBoxRect, 1.121 + NSWindow* aWindow); 1.122 + void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect, 1.123 + nsIFrame *aFrame); 1.124 + void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect, 1.125 + CGFloat aUnifiedHeight, BOOL aIsMain); 1.126 + void DrawResizer(CGContextRef cgContext, const HIRect& aRect, nsIFrame *aFrame); 1.127 + 1.128 + // Scrollbars 1.129 + void DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRect, nsIFrame *aFrame); 1.130 + void GetScrollbarPressStates(nsIFrame *aFrame, 1.131 + mozilla::EventStates aButtonStates[]); 1.132 + void GetScrollbarDrawInfo (HIThemeTrackDrawInfo& aTdi, nsIFrame *aFrame, 1.133 + const CGSize& aSize, bool aShouldGetButtonStates); 1.134 + nsIFrame* GetParentScrollbarFrame(nsIFrame *aFrame); 1.135 + 1.136 +private: 1.137 + NSButtonCell* mHelpButtonCell; 1.138 + NSButtonCell* mPushButtonCell; 1.139 + NSButtonCell* mRadioButtonCell; 1.140 + NSButtonCell* mCheckboxCell; 1.141 + ContextAwareSearchFieldCell* mSearchFieldCell; 1.142 + NSPopUpButtonCell* mDropdownCell; 1.143 + NSComboBoxCell* mComboBoxCell; 1.144 + NSProgressBarCell* mProgressBarCell; 1.145 + NSLevelIndicatorCell* mMeterBarCell; 1.146 + CellDrawView* mCellDrawView; 1.147 +}; 1.148 + 1.149 +#endif // nsNativeThemeCocoa_h_