Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / gfx / public / nsITheme.h
blobcf3ca7448712ad37e18fab18d5401a0eb4c5d890
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 nsSize;
50 struct nsFont;
51 struct nsMargin;
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 // {df8baf21-5ea7-49eb-a2bc-f2fd4a9fd896}
61 #define NS_ITHEME_IID \
62 { 0xdf8baf21, 0x5ea7, 0x49eb, { 0xa2, 0xbc, 0xf2, 0xfd, 0x4a, 0x9f, 0xd8, 0x96 } }
64 // {D930E29B-6909-44e5-AB4B-AF10D6923705}
65 #define NS_THEMERENDERER_CID \
66 { 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
68 /**
69 * nsITheme is a service that provides platform-specific native
70 * rendering for widgets. In other words, it provides the necessary
71 * operations to draw a rendering object (an nsIFrame) as a native
72 * widget.
74 * All the methods on nsITheme take a rendering context or device
75 * context, a frame (the rendering object), and a widget type (one of
76 * the constants in nsThemeConstants.h).
78 class nsITheme: public nsISupports {
79 public:
80 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID)
82 NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
83 nsIFrame* aFrame,
84 PRUint8 aWidgetType,
85 const nsRect& aRect,
86 const nsRect& aDirtyRect)=0;
88 /**
89 * Get the computed CSS border for the widget, in pixels.
91 NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
92 nsIFrame* aFrame,
93 PRUint8 aWidgetType,
94 nsMargin* aResult)=0;
96 /**
97 * This method can return PR_FALSE to indicate that the CSS padding
98 * value should be used. Otherwise, it will fill in aResult with the
99 * computed padding, in pixels, and return PR_TRUE.
101 * XXXldb This ought to be required to return true for non-containers
102 * so that we don't let specified padding that has no effect change
103 * the computed padding and potentially the size.
105 virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
106 nsIFrame* aFrame,
107 PRUint8 aWidgetType,
108 nsMargin* aResult) = 0;
111 * On entry, *aResult is positioned at 0,0 and sized to the new size
112 * of aFrame (aFrame->GetSize() may be stale and should not be used).
113 * This method can return PR_FALSE to indicate that no special
114 * overflow area is required by the native widget. Otherwise it will
115 * fill in aResult with the desired overflow area, in appunits, relative
116 * to the frame origin, and return PR_TRUE.
118 virtual PRBool GetWidgetOverflow(nsIDeviceContext* aContext,
119 nsIFrame* aFrame,
120 PRUint8 aWidgetType,
121 /*INOUT*/ nsRect* aOverflowRect)
122 { return PR_FALSE; }
125 * Get the minimum border-box size of a widget, in *pixels* (in
126 * |aResult|). If |aIsOverridable| is set to true, this size is a
127 * minimum size; if false, this size is the only valid size for the
128 * widget.
130 NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext,
131 nsIFrame* aFrame,
132 PRUint8 aWidgetType,
133 nsSize* aResult,
134 PRBool* aIsOverridable)=0;
136 NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
137 nsIAtom* aAttribute, PRBool* aShouldRepaint)=0;
139 NS_IMETHOD ThemeChanged()=0;
142 * Can the nsITheme implementation handle this widget?
144 virtual PRBool ThemeSupportsWidget(nsPresContext* aPresContext,
145 nsIFrame* aFrame,
146 PRUint8 aWidgetType)=0;
148 virtual PRBool WidgetIsContainer(PRUint8 aWidgetType)=0;
151 * Does the nsITheme implementation draw its own focus ring for this widget?
153 virtual PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext,
154 nsIFrame* aFrame,
155 PRUint8 aWidgetType)=0;
158 * Should we insert a dropmarker inside of combobox button?
160 virtual PRBool ThemeNeedsComboboxDropmarker()=0;
163 NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme, NS_ITHEME_IID)
165 // Creator function
166 extern NS_METHOD NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);
168 #endif