Automated checkin: version bump remove "pre" from version number for firefox 3.7a1...
[mozilla-central.git] / gfx / public / nsITheme.h
blob94f108bb8449ea6a67801c0e7c0367069d9ad63b
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
14 * License.
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.
23 * Contributor(s):
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 */
41 #ifndef nsITheme_h_
42 #define nsITheme_h_
44 #include "nsISupports.h"
45 #include "nsCOMPtr.h"
46 #include "nsColor.h"
48 struct nsRect;
49 struct nsIntSize;
50 struct nsFont;
51 struct nsIntMargin;
52 class nsPresContext;
53 class nsIRenderingContext;
54 class nsIDeviceContext;
55 class nsIFrame;
56 class nsIContent;
57 class nsIAtom;
59 // IID for the nsITheme interface
60 // {887e8902-db6b-41b4-8481-a80f49c5a93a}
61 #define NS_ITHEME_IID \
62 { 0x887e8902, 0xdb6b, 0x41b4, { 0x84, 0x81, 0xa8, 0x0f, 0x49, 0xc5, 0xa9, 0x3a } }
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
74 /**
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
78 * widget.
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 {
85 public:
86 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID)
88 NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
89 nsIFrame* aFrame,
90 PRUint8 aWidgetType,
91 const nsRect& aRect,
92 const nsRect& aDirtyRect)=0;
94 /**
95 * Get the computed CSS border for the widget, in pixels.
97 NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
98 nsIFrame* aFrame,
99 PRUint8 aWidgetType,
100 nsIntMargin* 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,
112 nsIFrame* aFrame,
113 PRUint8 aWidgetType,
114 nsIntMargin* 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,
125 nsIFrame* aFrame,
126 PRUint8 aWidgetType,
127 /*INOUT*/ nsRect* aOverflowRect)
128 { return PR_FALSE; }
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
134 * widget.
136 NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext,
137 nsIFrame* aFrame,
138 PRUint8 aWidgetType,
139 nsIntSize* aResult,
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,
153 nsIFrame* aFrame,
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,
162 nsIFrame* aFrame,
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)
173 // Creator function
174 extern NS_METHOD NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);
176 #endif