1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* service providing platform-specific native rendering for widgets */
12 #include "nsISupports.h"
22 class nsRenderingContext
;
23 class nsDeviceContext
;
29 // IID for the nsITheme interface
30 // {b0f3efe9-0bd4-4f6b-8daa-0ec7f6006822}
31 #define NS_ITHEME_IID \
32 { 0xb0f3efe9, 0x0bd4, 0x4f6b, { 0x8d, 0xaa, 0x0e, 0xc7, 0xf6, 0x00, 0x68, 0x22 } }
33 // {D930E29B-6909-44e5-AB4B-AF10D6923705}
34 #define NS_THEMERENDERER_CID \
35 { 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
37 enum nsTransparencyMode
{
38 eTransparencyOpaque
= 0, // Fully opaque
39 eTransparencyTransparent
, // Parts of the window may be transparent
40 eTransparencyGlass
, // Transparent parts of the window have Vista AeroGlass effect applied
41 eTransparencyBorderlessGlass
// As above, but without a border around the opaque areas when there would otherwise be one with eTransparencyGlass
45 * nsITheme is a service that provides platform-specific native
46 * rendering for widgets. In other words, it provides the necessary
47 * operations to draw a rendering object (an nsIFrame) as a native
50 * All the methods on nsITheme take a rendering context or device
51 * context, a frame (the rendering object), and a widget type (one of
52 * the constants in nsThemeConstants.h).
54 class nsITheme
: public nsISupports
{
56 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID
)
59 * Draw the actual theme background.
60 * @param aContext the context to draw into
61 * @param aFrame the frame for the widget that we're drawing
62 * @param aWidgetType the -moz-appearance value to draw
63 * @param aRect the rectangle defining the area occupied by the widget
64 * @param aDirtyRect the rectangle that needs to be drawn
66 NS_IMETHOD
DrawWidgetBackground(nsRenderingContext
* aContext
,
70 const nsRect
& aDirtyRect
) = 0;
73 * Get the computed CSS border for the widget, in pixels.
75 NS_IMETHOD
GetWidgetBorder(nsDeviceContext
* aContext
,
78 nsIntMargin
* aResult
)=0;
81 * This method can return false to indicate that the CSS padding
82 * value should be used. Otherwise, it will fill in aResult with the
83 * computed padding, in pixels, and return true.
85 * XXXldb This ought to be required to return true for non-containers
86 * so that we don't let specified padding that has no effect change
87 * the computed padding and potentially the size.
89 virtual bool GetWidgetPadding(nsDeviceContext
* aContext
,
92 nsIntMargin
* aResult
) = 0;
95 * On entry, *aResult is positioned at 0,0 and sized to the new size
96 * of aFrame (aFrame->GetSize() may be stale and should not be used).
97 * This method can return false to indicate that no special
98 * overflow area is required by the native widget. Otherwise it will
99 * fill in aResult with the desired overflow area, in appunits, relative
100 * to the frame origin, and return true.
102 * This overflow area is used to determine what area needs to be
103 * repainted when the widget changes. However, it does not affect the
104 * widget's size or what area is reachable by scrollbars. (In other
105 * words, in layout terms, it affects visual overflow but not
106 * scrollable overflow.)
108 virtual bool GetWidgetOverflow(nsDeviceContext
* aContext
,
111 /*INOUT*/ nsRect
* aOverflowRect
)
115 * Get the minimum border-box size of a widget, in *pixels* (in
116 * |aResult|). If |aIsOverridable| is set to true, this size is a
117 * minimum size; if false, this size is the only valid size for the
120 NS_IMETHOD
GetMinimumWidgetSize(nsRenderingContext
* aContext
,
124 bool* aIsOverridable
)=0;
134 * Returns what we know about the transparency of the widget.
136 virtual Transparency
GetWidgetTransparency(nsIFrame
* aFrame
, uint8_t aWidgetType
)
137 { return eUnknownTransparency
; }
139 NS_IMETHOD
WidgetStateChanged(nsIFrame
* aFrame
, uint8_t aWidgetType
,
140 nsIAtom
* aAttribute
, bool* aShouldRepaint
)=0;
142 NS_IMETHOD
ThemeChanged()=0;
145 * Can the nsITheme implementation handle this widget?
147 virtual bool ThemeSupportsWidget(nsPresContext
* aPresContext
,
149 uint8_t aWidgetType
)=0;
151 virtual bool WidgetIsContainer(uint8_t aWidgetType
)=0;
154 * Does the nsITheme implementation draw its own focus ring for this widget?
156 virtual bool ThemeDrawsFocusForWidget(uint8_t aWidgetType
)=0;
159 * Should we insert a dropmarker inside of combobox button?
161 virtual bool ThemeNeedsComboboxDropmarker()=0;
164 NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme
, NS_ITHEME_IID
)
167 extern nsresult
NS_NewNativeTheme(nsISupports
*aOuter
, REFNSIID aIID
, void **aResult
);