michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: #ifndef nsButtonFrameRenderer_h___ michael@0: #define nsButtonFrameRenderer_h___ michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsMargin.h" michael@0: michael@0: class nsIFrame; michael@0: class nsFrame; michael@0: class nsDisplayList; michael@0: class nsDisplayListBuilder; michael@0: class nsPresContext; michael@0: class nsRenderingContext; michael@0: class nsRect; michael@0: class nsStyleContext; michael@0: michael@0: michael@0: #define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 0 michael@0: #define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1 michael@0: #define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX michael@0: michael@0: class nsButtonFrameRenderer { michael@0: public: michael@0: michael@0: nsButtonFrameRenderer(); michael@0: ~nsButtonFrameRenderer(); michael@0: michael@0: /** michael@0: * Create display list items for the button michael@0: */ michael@0: nsresult DisplayButton(nsDisplayListBuilder* aBuilder, michael@0: nsDisplayList* aBackground, nsDisplayList* aForeground); michael@0: michael@0: michael@0: void PaintOutlineAndFocusBorders(nsPresContext* aPresContext, michael@0: nsRenderingContext& aRenderingContext, michael@0: const nsRect& aDirtyRect, michael@0: const nsRect& aRect); michael@0: michael@0: void PaintBorderAndBackground(nsPresContext* aPresContext, michael@0: nsRenderingContext& aRenderingContext, michael@0: const nsRect& aDirtyRect, michael@0: const nsRect& aRect, michael@0: uint32_t aBGFlags); michael@0: michael@0: void SetFrame(nsFrame* aFrame, nsPresContext* aPresContext); michael@0: michael@0: void SetDisabled(bool aDisabled, bool notify); michael@0: michael@0: bool isActive(); michael@0: bool isDisabled(); michael@0: michael@0: void GetButtonOuterFocusRect(const nsRect& aRect, nsRect& aResult); michael@0: void GetButtonRect(const nsRect& aRect, nsRect& aResult); michael@0: void GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult); michael@0: nsMargin GetButtonOuterFocusBorderAndPadding(); michael@0: nsMargin GetButtonBorderAndPadding(); michael@0: nsMargin GetButtonInnerFocusMargin(); michael@0: nsMargin GetButtonInnerFocusBorderAndPadding(); michael@0: nsMargin GetAddedButtonBorderAndPadding(); michael@0: michael@0: nsStyleContext* GetStyleContext(int32_t aIndex) const; michael@0: void SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext); michael@0: void ReResolveStyles(nsPresContext* aPresContext); michael@0: michael@0: nsIFrame* GetFrame(); michael@0: michael@0: protected: michael@0: michael@0: private: michael@0: michael@0: // cached styles for focus and outline. michael@0: nsRefPtr mBorderStyle; michael@0: nsRefPtr mInnerFocusStyle; michael@0: nsRefPtr mOuterFocusStyle; michael@0: michael@0: nsFrame* mFrame; michael@0: }; michael@0: michael@0: michael@0: #endif michael@0: