michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* service providing platform-specific native rendering for widgets */ michael@0: michael@0: #ifndef nsITheme_h_ michael@0: #define nsITheme_h_ michael@0: michael@0: #include "nsISupports.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsColor.h" michael@0: michael@0: struct nsRect; michael@0: struct nsIntRect; michael@0: struct nsIntSize; michael@0: class nsIntRegion; michael@0: struct nsFont; michael@0: struct nsIntMargin; michael@0: class nsPresContext; michael@0: class nsRenderingContext; michael@0: class nsDeviceContext; michael@0: class nsIFrame; michael@0: class nsIContent; michael@0: class nsIAtom; michael@0: class nsIWidget; michael@0: michael@0: // IID for the nsITheme interface michael@0: // {b0f3efe9-0bd4-4f6b-8daa-0ec7f6006822} michael@0: #define NS_ITHEME_IID \ michael@0: { 0x4440b5c7, 0xd8bd, 0x4d9c, \ michael@0: { 0x9c, 0x3e, 0xa5, 0xe6, 0x26, 0x81, 0x10, 0xa0 } } michael@0: // {D930E29B-6909-44e5-AB4B-AF10D6923705} michael@0: #define NS_THEMERENDERER_CID \ michael@0: { 0x9020805b, 0x14a3, 0x4125, \ michael@0: { 0xa5, 0x63, 0x4a, 0x8c, 0x5d, 0xe0, 0xa9, 0xa3 } } michael@0: michael@0: /** michael@0: * nsITheme is a service that provides platform-specific native michael@0: * rendering for widgets. In other words, it provides the necessary michael@0: * operations to draw a rendering object (an nsIFrame) as a native michael@0: * widget. michael@0: * michael@0: * All the methods on nsITheme take a rendering context or device michael@0: * context, a frame (the rendering object), and a widget type (one of michael@0: * the constants in nsThemeConstants.h). michael@0: */ michael@0: class nsITheme: public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID) michael@0: michael@0: /** michael@0: * Draw the actual theme background. michael@0: * @param aContext the context to draw into michael@0: * @param aFrame the frame for the widget that we're drawing michael@0: * @param aWidgetType the -moz-appearance value to draw michael@0: * @param aRect the rectangle defining the area occupied by the widget michael@0: * @param aDirtyRect the rectangle that needs to be drawn michael@0: */ michael@0: NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext, michael@0: nsIFrame* aFrame, michael@0: uint8_t aWidgetType, michael@0: const nsRect& aRect, michael@0: const nsRect& aDirtyRect) = 0; michael@0: michael@0: /** michael@0: * Get the computed CSS border for the widget, in pixels. michael@0: */ michael@0: NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, michael@0: nsIFrame* aFrame, michael@0: uint8_t aWidgetType, michael@0: nsIntMargin* aResult)=0; michael@0: michael@0: /** michael@0: * This method can return false to indicate that the CSS padding michael@0: * value should be used. Otherwise, it will fill in aResult with the michael@0: * computed padding, in pixels, and return true. michael@0: * michael@0: * XXXldb This ought to be required to return true for non-containers michael@0: * so that we don't let specified padding that has no effect change michael@0: * the computed padding and potentially the size. michael@0: */ michael@0: virtual bool GetWidgetPadding(nsDeviceContext* aContext, michael@0: nsIFrame* aFrame, michael@0: uint8_t aWidgetType, michael@0: nsIntMargin* aResult) = 0; michael@0: michael@0: /** michael@0: * On entry, *aResult is positioned at 0,0 and sized to the new size michael@0: * of aFrame (aFrame->GetSize() may be stale and should not be used). michael@0: * This method can return false to indicate that no special michael@0: * overflow area is required by the native widget. Otherwise it will michael@0: * fill in aResult with the desired overflow area, in appunits, relative michael@0: * to the frame origin, and return true. michael@0: * michael@0: * This overflow area is used to determine what area needs to be michael@0: * repainted when the widget changes. However, it does not affect the michael@0: * widget's size or what area is reachable by scrollbars. (In other michael@0: * words, in layout terms, it affects visual overflow but not michael@0: * scrollable overflow.) michael@0: */ michael@0: virtual bool GetWidgetOverflow(nsDeviceContext* aContext, michael@0: nsIFrame* aFrame, michael@0: uint8_t aWidgetType, michael@0: /*INOUT*/ nsRect* aOverflowRect) michael@0: { return false; } michael@0: michael@0: /** michael@0: * Get the minimum border-box size of a widget, in *pixels* (in michael@0: * |aResult|). If |aIsOverridable| is set to true, this size is a michael@0: * minimum size; if false, this size is the only valid size for the michael@0: * widget. michael@0: */ michael@0: NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, michael@0: nsIFrame* aFrame, michael@0: uint8_t aWidgetType, michael@0: nsIntSize* aResult, michael@0: bool* aIsOverridable)=0; michael@0: michael@0: michael@0: enum Transparency { michael@0: eOpaque = 0, michael@0: eTransparent, michael@0: eUnknownTransparency michael@0: }; michael@0: michael@0: /** michael@0: * Returns what we know about the transparency of the widget. michael@0: */ michael@0: virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) michael@0: { return eUnknownTransparency; } michael@0: michael@0: NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, michael@0: nsIAtom* aAttribute, bool* aShouldRepaint)=0; michael@0: michael@0: NS_IMETHOD ThemeChanged()=0; michael@0: michael@0: virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) michael@0: { return false; } michael@0: michael@0: /** michael@0: * Can the nsITheme implementation handle this widget? michael@0: */ michael@0: virtual bool ThemeSupportsWidget(nsPresContext* aPresContext, michael@0: nsIFrame* aFrame, michael@0: uint8_t aWidgetType)=0; michael@0: michael@0: virtual bool WidgetIsContainer(uint8_t aWidgetType)=0; michael@0: michael@0: /** michael@0: * Does the nsITheme implementation draw its own focus ring for this widget? michael@0: */ michael@0: virtual bool ThemeDrawsFocusForWidget(uint8_t aWidgetType)=0; michael@0: michael@0: /** michael@0: * Should we insert a dropmarker inside of combobox button? michael@0: */ michael@0: virtual bool ThemeNeedsComboboxDropmarker()=0; michael@0: michael@0: /** michael@0: * Should we hide scrollbars? michael@0: */ michael@0: virtual bool ShouldHideScrollbars() michael@0: { return false; } michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme, NS_ITHEME_IID) michael@0: michael@0: // Creator function michael@0: extern nsresult NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult); michael@0: michael@0: #endif