1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/forms/nsButtonFrameRenderer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsButtonFrameRenderer_h___ 1.10 +#define nsButtonFrameRenderer_h___ 1.11 + 1.12 +#include "nsAutoPtr.h" 1.13 +#include "nsMargin.h" 1.14 + 1.15 +class nsIFrame; 1.16 +class nsFrame; 1.17 +class nsDisplayList; 1.18 +class nsDisplayListBuilder; 1.19 +class nsPresContext; 1.20 +class nsRenderingContext; 1.21 +class nsRect; 1.22 +class nsStyleContext; 1.23 + 1.24 + 1.25 +#define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 0 1.26 +#define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1 1.27 +#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1.28 + 1.29 +class nsButtonFrameRenderer { 1.30 +public: 1.31 + 1.32 + nsButtonFrameRenderer(); 1.33 + ~nsButtonFrameRenderer(); 1.34 + 1.35 + /** 1.36 + * Create display list items for the button 1.37 + */ 1.38 + nsresult DisplayButton(nsDisplayListBuilder* aBuilder, 1.39 + nsDisplayList* aBackground, nsDisplayList* aForeground); 1.40 + 1.41 + 1.42 + void PaintOutlineAndFocusBorders(nsPresContext* aPresContext, 1.43 + nsRenderingContext& aRenderingContext, 1.44 + const nsRect& aDirtyRect, 1.45 + const nsRect& aRect); 1.46 + 1.47 + void PaintBorderAndBackground(nsPresContext* aPresContext, 1.48 + nsRenderingContext& aRenderingContext, 1.49 + const nsRect& aDirtyRect, 1.50 + const nsRect& aRect, 1.51 + uint32_t aBGFlags); 1.52 + 1.53 + void SetFrame(nsFrame* aFrame, nsPresContext* aPresContext); 1.54 + 1.55 + void SetDisabled(bool aDisabled, bool notify); 1.56 + 1.57 + bool isActive(); 1.58 + bool isDisabled(); 1.59 + 1.60 + void GetButtonOuterFocusRect(const nsRect& aRect, nsRect& aResult); 1.61 + void GetButtonRect(const nsRect& aRect, nsRect& aResult); 1.62 + void GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult); 1.63 + nsMargin GetButtonOuterFocusBorderAndPadding(); 1.64 + nsMargin GetButtonBorderAndPadding(); 1.65 + nsMargin GetButtonInnerFocusMargin(); 1.66 + nsMargin GetButtonInnerFocusBorderAndPadding(); 1.67 + nsMargin GetAddedButtonBorderAndPadding(); 1.68 + 1.69 + nsStyleContext* GetStyleContext(int32_t aIndex) const; 1.70 + void SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext); 1.71 + void ReResolveStyles(nsPresContext* aPresContext); 1.72 + 1.73 + nsIFrame* GetFrame(); 1.74 + 1.75 +protected: 1.76 + 1.77 +private: 1.78 + 1.79 + // cached styles for focus and outline. 1.80 + nsRefPtr<nsStyleContext> mBorderStyle; 1.81 + nsRefPtr<nsStyleContext> mInnerFocusStyle; 1.82 + nsRefPtr<nsStyleContext> mOuterFocusStyle; 1.83 + 1.84 + nsFrame* mFrame; 1.85 +}; 1.86 + 1.87 + 1.88 +#endif 1.89 +