Back out a5a5d2c176f7 (bug 882865) because of Android test failures on a CLOSED TREE
[gecko.git] / gfx / src / nsITheme.h
blob618f2f0442710a19d5495c5c4f32d48adfd5bb94
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 */
9 #ifndef nsITheme_h_
10 #define nsITheme_h_
12 #include "nsISupports.h"
13 #include "nsCOMPtr.h"
14 #include "nsColor.h"
16 struct nsRect;
17 struct nsIntRect;
18 struct nsIntSize;
19 struct nsFont;
20 struct nsIntMargin;
21 class nsPresContext;
22 class nsRenderingContext;
23 class nsDeviceContext;
24 class nsIFrame;
25 class nsIContent;
26 class nsIAtom;
27 class nsIWidget;
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
44 /**
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
48 * widget.
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 {
55 public:
56 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID)
58 /**
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,
67 nsIFrame* aFrame,
68 uint8_t aWidgetType,
69 const nsRect& aRect,
70 const nsRect& aDirtyRect) = 0;
72 /**
73 * Get the computed CSS border for the widget, in pixels.
75 NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext,
76 nsIFrame* aFrame,
77 uint8_t aWidgetType,
78 nsIntMargin* aResult)=0;
80 /**
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,
90 nsIFrame* aFrame,
91 uint8_t aWidgetType,
92 nsIntMargin* aResult) = 0;
94 /**
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,
109 nsIFrame* aFrame,
110 uint8_t aWidgetType,
111 /*INOUT*/ nsRect* aOverflowRect)
112 { return false; }
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
118 * widget.
120 NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext,
121 nsIFrame* aFrame,
122 uint8_t aWidgetType,
123 nsIntSize* aResult,
124 bool* aIsOverridable)=0;
127 enum Transparency {
128 eOpaque = 0,
129 eTransparent,
130 eUnknownTransparency
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,
148 nsIFrame* aFrame,
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)
166 // Creator function
167 extern nsresult NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);
169 #endif