|
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 |
|
6 #ifndef nsButtonFrameRenderer_h___ |
|
7 #define nsButtonFrameRenderer_h___ |
|
8 |
|
9 #include "nsAutoPtr.h" |
|
10 #include "nsMargin.h" |
|
11 |
|
12 class nsIFrame; |
|
13 class nsFrame; |
|
14 class nsDisplayList; |
|
15 class nsDisplayListBuilder; |
|
16 class nsPresContext; |
|
17 class nsRenderingContext; |
|
18 class nsRect; |
|
19 class nsStyleContext; |
|
20 |
|
21 |
|
22 #define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 0 |
|
23 #define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1 |
|
24 #define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX |
|
25 |
|
26 class nsButtonFrameRenderer { |
|
27 public: |
|
28 |
|
29 nsButtonFrameRenderer(); |
|
30 ~nsButtonFrameRenderer(); |
|
31 |
|
32 /** |
|
33 * Create display list items for the button |
|
34 */ |
|
35 nsresult DisplayButton(nsDisplayListBuilder* aBuilder, |
|
36 nsDisplayList* aBackground, nsDisplayList* aForeground); |
|
37 |
|
38 |
|
39 void PaintOutlineAndFocusBorders(nsPresContext* aPresContext, |
|
40 nsRenderingContext& aRenderingContext, |
|
41 const nsRect& aDirtyRect, |
|
42 const nsRect& aRect); |
|
43 |
|
44 void PaintBorderAndBackground(nsPresContext* aPresContext, |
|
45 nsRenderingContext& aRenderingContext, |
|
46 const nsRect& aDirtyRect, |
|
47 const nsRect& aRect, |
|
48 uint32_t aBGFlags); |
|
49 |
|
50 void SetFrame(nsFrame* aFrame, nsPresContext* aPresContext); |
|
51 |
|
52 void SetDisabled(bool aDisabled, bool notify); |
|
53 |
|
54 bool isActive(); |
|
55 bool isDisabled(); |
|
56 |
|
57 void GetButtonOuterFocusRect(const nsRect& aRect, nsRect& aResult); |
|
58 void GetButtonRect(const nsRect& aRect, nsRect& aResult); |
|
59 void GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult); |
|
60 nsMargin GetButtonOuterFocusBorderAndPadding(); |
|
61 nsMargin GetButtonBorderAndPadding(); |
|
62 nsMargin GetButtonInnerFocusMargin(); |
|
63 nsMargin GetButtonInnerFocusBorderAndPadding(); |
|
64 nsMargin GetAddedButtonBorderAndPadding(); |
|
65 |
|
66 nsStyleContext* GetStyleContext(int32_t aIndex) const; |
|
67 void SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext); |
|
68 void ReResolveStyles(nsPresContext* aPresContext); |
|
69 |
|
70 nsIFrame* GetFrame(); |
|
71 |
|
72 protected: |
|
73 |
|
74 private: |
|
75 |
|
76 // cached styles for focus and outline. |
|
77 nsRefPtr<nsStyleContext> mBorderStyle; |
|
78 nsRefPtr<nsStyleContext> mInnerFocusStyle; |
|
79 nsRefPtr<nsStyleContext> mOuterFocusStyle; |
|
80 |
|
81 nsFrame* mFrame; |
|
82 }; |
|
83 |
|
84 |
|
85 #endif |
|
86 |