1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is the Mozilla browser.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /* service providing platform-specific native rendering for widgets */
44 #include "nsISupports.h"
53 class nsIRenderingContext
;
54 class nsIDeviceContext
;
59 // IID for the nsITheme interface
60 // {f5eb2e02-ed3f-4340-82fc-22f55bb556f9}
61 #define NS_ITHEME_IID \
62 { 0xf5eb2e02, 0xed3f, 0x4340, { 0x82, 0xfc, 0x22, 0xf5, 0x5b, 0xb5, 0x56, 0xf9 } }
64 // {D930E29B-6909-44e5-AB4B-AF10D6923705}
65 #define NS_THEMERENDERER_CID \
66 { 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
68 enum nsTransparencyMode
{
69 eTransparencyOpaque
= 0, // Fully opaque
70 eTransparencyTransparent
, // Parts of the window may be transparent
71 eTransparencyGlass
// Transparent parts of the window have Vista AeroGlass effect applied
75 * nsITheme is a service that provides platform-specific native
76 * rendering for widgets. In other words, it provides the necessary
77 * operations to draw a rendering object (an nsIFrame) as a native
80 * All the methods on nsITheme take a rendering context or device
81 * context, a frame (the rendering object), and a widget type (one of
82 * the constants in nsThemeConstants.h).
84 class nsITheme
: public nsISupports
{
86 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID
)
88 NS_IMETHOD
DrawWidgetBackground(nsIRenderingContext
* aContext
,
92 const nsRect
& aDirtyRect
)=0;
95 * Get the computed CSS border for the widget, in pixels.
97 NS_IMETHOD
GetWidgetBorder(nsIDeviceContext
* aContext
,
100 nsMargin
* aResult
)=0;
103 * This method can return PR_FALSE to indicate that the CSS padding
104 * value should be used. Otherwise, it will fill in aResult with the
105 * computed padding, in pixels, and return PR_TRUE.
107 * XXXldb This ought to be required to return true for non-containers
108 * so that we don't let specified padding that has no effect change
109 * the computed padding and potentially the size.
111 virtual PRBool
GetWidgetPadding(nsIDeviceContext
* aContext
,
114 nsMargin
* aResult
) = 0;
117 * On entry, *aResult is positioned at 0,0 and sized to the new size
118 * of aFrame (aFrame->GetSize() may be stale and should not be used).
119 * This method can return PR_FALSE to indicate that no special
120 * overflow area is required by the native widget. Otherwise it will
121 * fill in aResult with the desired overflow area, in appunits, relative
122 * to the frame origin, and return PR_TRUE.
124 virtual PRBool
GetWidgetOverflow(nsIDeviceContext
* aContext
,
127 /*INOUT*/ nsRect
* aOverflowRect
)
131 * Get the minimum border-box size of a widget, in *pixels* (in
132 * |aResult|). If |aIsOverridable| is set to true, this size is a
133 * minimum size; if false, this size is the only valid size for the
136 NS_IMETHOD
GetMinimumWidgetSize(nsIRenderingContext
* aContext
,
140 PRBool
* aIsOverridable
)=0;
142 virtual nsTransparencyMode
GetWidgetTransparency(PRUint8 aWidgetType
)=0;
144 NS_IMETHOD
WidgetStateChanged(nsIFrame
* aFrame
, PRUint8 aWidgetType
,
145 nsIAtom
* aAttribute
, PRBool
* aShouldRepaint
)=0;
147 NS_IMETHOD
ThemeChanged()=0;
150 * Can the nsITheme implementation handle this widget?
152 virtual PRBool
ThemeSupportsWidget(nsPresContext
* aPresContext
,
154 PRUint8 aWidgetType
)=0;
156 virtual PRBool
WidgetIsContainer(PRUint8 aWidgetType
)=0;
159 * Does the nsITheme implementation draw its own focus ring for this widget?
161 virtual PRBool
ThemeDrawsFocusForWidget(nsPresContext
* aPresContext
,
163 PRUint8 aWidgetType
)=0;
166 * Should we insert a dropmarker inside of combobox button?
168 virtual PRBool
ThemeNeedsComboboxDropmarker()=0;
171 NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme
, NS_ITHEME_IID
)
174 extern NS_METHOD
NS_NewNativeTheme(nsISupports
*aOuter
, REFNSIID aIID
, void **aResult
);