1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/src/nsITheme.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,174 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/* service providing platform-specific native rendering for widgets */ 1.11 + 1.12 +#ifndef nsITheme_h_ 1.13 +#define nsITheme_h_ 1.14 + 1.15 +#include "nsISupports.h" 1.16 +#include "nsCOMPtr.h" 1.17 +#include "nsColor.h" 1.18 + 1.19 +struct nsRect; 1.20 +struct nsIntRect; 1.21 +struct nsIntSize; 1.22 +class nsIntRegion; 1.23 +struct nsFont; 1.24 +struct nsIntMargin; 1.25 +class nsPresContext; 1.26 +class nsRenderingContext; 1.27 +class nsDeviceContext; 1.28 +class nsIFrame; 1.29 +class nsIContent; 1.30 +class nsIAtom; 1.31 +class nsIWidget; 1.32 + 1.33 +// IID for the nsITheme interface 1.34 +// {b0f3efe9-0bd4-4f6b-8daa-0ec7f6006822} 1.35 + #define NS_ITHEME_IID \ 1.36 +{ 0x4440b5c7, 0xd8bd, 0x4d9c, \ 1.37 + { 0x9c, 0x3e, 0xa5, 0xe6, 0x26, 0x81, 0x10, 0xa0 } } 1.38 +// {D930E29B-6909-44e5-AB4B-AF10D6923705} 1.39 +#define NS_THEMERENDERER_CID \ 1.40 +{ 0x9020805b, 0x14a3, 0x4125, \ 1.41 + { 0xa5, 0x63, 0x4a, 0x8c, 0x5d, 0xe0, 0xa9, 0xa3 } } 1.42 + 1.43 +/** 1.44 + * nsITheme is a service that provides platform-specific native 1.45 + * rendering for widgets. In other words, it provides the necessary 1.46 + * operations to draw a rendering object (an nsIFrame) as a native 1.47 + * widget. 1.48 + * 1.49 + * All the methods on nsITheme take a rendering context or device 1.50 + * context, a frame (the rendering object), and a widget type (one of 1.51 + * the constants in nsThemeConstants.h). 1.52 + */ 1.53 +class nsITheme: public nsISupports { 1.54 +public: 1.55 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID) 1.56 + 1.57 + /** 1.58 + * Draw the actual theme background. 1.59 + * @param aContext the context to draw into 1.60 + * @param aFrame the frame for the widget that we're drawing 1.61 + * @param aWidgetType the -moz-appearance value to draw 1.62 + * @param aRect the rectangle defining the area occupied by the widget 1.63 + * @param aDirtyRect the rectangle that needs to be drawn 1.64 + */ 1.65 + NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext, 1.66 + nsIFrame* aFrame, 1.67 + uint8_t aWidgetType, 1.68 + const nsRect& aRect, 1.69 + const nsRect& aDirtyRect) = 0; 1.70 + 1.71 + /** 1.72 + * Get the computed CSS border for the widget, in pixels. 1.73 + */ 1.74 + NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, 1.75 + nsIFrame* aFrame, 1.76 + uint8_t aWidgetType, 1.77 + nsIntMargin* aResult)=0; 1.78 + 1.79 + /** 1.80 + * This method can return false to indicate that the CSS padding 1.81 + * value should be used. Otherwise, it will fill in aResult with the 1.82 + * computed padding, in pixels, and return true. 1.83 + * 1.84 + * XXXldb This ought to be required to return true for non-containers 1.85 + * so that we don't let specified padding that has no effect change 1.86 + * the computed padding and potentially the size. 1.87 + */ 1.88 + virtual bool GetWidgetPadding(nsDeviceContext* aContext, 1.89 + nsIFrame* aFrame, 1.90 + uint8_t aWidgetType, 1.91 + nsIntMargin* aResult) = 0; 1.92 + 1.93 + /** 1.94 + * On entry, *aResult is positioned at 0,0 and sized to the new size 1.95 + * of aFrame (aFrame->GetSize() may be stale and should not be used). 1.96 + * This method can return false to indicate that no special 1.97 + * overflow area is required by the native widget. Otherwise it will 1.98 + * fill in aResult with the desired overflow area, in appunits, relative 1.99 + * to the frame origin, and return true. 1.100 + * 1.101 + * This overflow area is used to determine what area needs to be 1.102 + * repainted when the widget changes. However, it does not affect the 1.103 + * widget's size or what area is reachable by scrollbars. (In other 1.104 + * words, in layout terms, it affects visual overflow but not 1.105 + * scrollable overflow.) 1.106 + */ 1.107 + virtual bool GetWidgetOverflow(nsDeviceContext* aContext, 1.108 + nsIFrame* aFrame, 1.109 + uint8_t aWidgetType, 1.110 + /*INOUT*/ nsRect* aOverflowRect) 1.111 + { return false; } 1.112 + 1.113 + /** 1.114 + * Get the minimum border-box size of a widget, in *pixels* (in 1.115 + * |aResult|). If |aIsOverridable| is set to true, this size is a 1.116 + * minimum size; if false, this size is the only valid size for the 1.117 + * widget. 1.118 + */ 1.119 + NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, 1.120 + nsIFrame* aFrame, 1.121 + uint8_t aWidgetType, 1.122 + nsIntSize* aResult, 1.123 + bool* aIsOverridable)=0; 1.124 + 1.125 + 1.126 + enum Transparency { 1.127 + eOpaque = 0, 1.128 + eTransparent, 1.129 + eUnknownTransparency 1.130 + }; 1.131 + 1.132 + /** 1.133 + * Returns what we know about the transparency of the widget. 1.134 + */ 1.135 + virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) 1.136 + { return eUnknownTransparency; } 1.137 + 1.138 + NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, 1.139 + nsIAtom* aAttribute, bool* aShouldRepaint)=0; 1.140 + 1.141 + NS_IMETHOD ThemeChanged()=0; 1.142 + 1.143 + virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) 1.144 + { return false; } 1.145 + 1.146 + /** 1.147 + * Can the nsITheme implementation handle this widget? 1.148 + */ 1.149 + virtual bool ThemeSupportsWidget(nsPresContext* aPresContext, 1.150 + nsIFrame* aFrame, 1.151 + uint8_t aWidgetType)=0; 1.152 + 1.153 + virtual bool WidgetIsContainer(uint8_t aWidgetType)=0; 1.154 + 1.155 + /** 1.156 + * Does the nsITheme implementation draw its own focus ring for this widget? 1.157 + */ 1.158 + virtual bool ThemeDrawsFocusForWidget(uint8_t aWidgetType)=0; 1.159 + 1.160 + /** 1.161 + * Should we insert a dropmarker inside of combobox button? 1.162 + */ 1.163 + virtual bool ThemeNeedsComboboxDropmarker()=0; 1.164 + 1.165 + /** 1.166 + * Should we hide scrollbars? 1.167 + */ 1.168 + virtual bool ShouldHideScrollbars() 1.169 + { return false; } 1.170 +}; 1.171 + 1.172 +NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme, NS_ITHEME_IID) 1.173 + 1.174 +// Creator function 1.175 +extern nsresult NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult); 1.176 + 1.177 +#endif