nsButtonFrameRenderer.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsButtonFrameRenderer_h___
  6. #define nsButtonFrameRenderer_h___
  7. #include "imgIContainer.h"
  8. #include "nsMargin.h"
  9. class nsIFrame;
  10. class nsFrame;
  11. class nsDisplayList;
  12. class nsDisplayListBuilder;
  13. class nsPresContext;
  14. class nsRenderingContext;
  15. struct nsRect;
  16. class nsStyleContext;
  17. #define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 0
  18. #define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1
  19. #define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX
  20. class nsButtonFrameRenderer {
  21. typedef mozilla::image::DrawResult DrawResult;
  22. public:
  23. nsButtonFrameRenderer();
  24. ~nsButtonFrameRenderer();
  25. /**
  26. * Create display list items for the button
  27. */
  28. nsresult DisplayButton(nsDisplayListBuilder* aBuilder,
  29. nsDisplayList* aBackground, nsDisplayList* aForeground);
  30. DrawResult PaintOutlineAndFocusBorders(nsDisplayListBuilder* aBuilder,
  31. nsPresContext* aPresContext,
  32. nsRenderingContext& aRenderingContext,
  33. const nsRect& aDirtyRect,
  34. const nsRect& aRect);
  35. DrawResult PaintBorder(nsDisplayListBuilder* aBuilder,
  36. nsPresContext* aPresContext,
  37. nsRenderingContext& aRenderingContext,
  38. const nsRect& aDirtyRect,
  39. const nsRect& aRect);
  40. void SetFrame(nsFrame* aFrame, nsPresContext* aPresContext);
  41. void SetDisabled(bool aDisabled, bool notify);
  42. bool isActive();
  43. bool isDisabled();
  44. void GetButtonOuterFocusRect(const nsRect& aRect, nsRect& aResult);
  45. void GetButtonRect(const nsRect& aRect, nsRect& aResult);
  46. void GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult);
  47. nsMargin GetButtonOuterFocusBorderAndPadding();
  48. nsMargin GetButtonBorderAndPadding();
  49. nsMargin GetButtonInnerFocusMargin();
  50. nsMargin GetButtonInnerFocusBorderAndPadding();
  51. nsMargin GetAddedButtonBorderAndPadding();
  52. nsStyleContext* GetStyleContext(int32_t aIndex) const;
  53. void SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext);
  54. void ReResolveStyles(nsPresContext* aPresContext);
  55. nsIFrame* GetFrame();
  56. protected:
  57. private:
  58. // cached styles for focus and outline.
  59. RefPtr<nsStyleContext> mInnerFocusStyle;
  60. RefPtr<nsStyleContext> mOuterFocusStyle;
  61. nsFrame* mFrame;
  62. };
  63. #endif