|
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 nsFormControlFrame_h___ |
|
7 #define nsFormControlFrame_h___ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsIFormControlFrame.h" |
|
11 #include "nsLeafFrame.h" |
|
12 |
|
13 /** |
|
14 * nsFormControlFrame is the base class for radio buttons and |
|
15 * checkboxes. It also has two static methods (RegUnRegAccessKey and |
|
16 * GetScreenHeight) that are used by other form controls. |
|
17 */ |
|
18 class nsFormControlFrame : public nsLeafFrame, |
|
19 public nsIFormControlFrame |
|
20 { |
|
21 public: |
|
22 /** |
|
23 * Main constructor |
|
24 * @param aContent the content representing this frame |
|
25 * @param aParentFrame the parent frame |
|
26 */ |
|
27 nsFormControlFrame(nsStyleContext*); |
|
28 |
|
29 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
30 |
|
31 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
|
32 { |
|
33 return nsLeafFrame::IsFrameOfType(aFlags & |
|
34 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); |
|
35 } |
|
36 |
|
37 NS_DECL_QUERYFRAME |
|
38 NS_DECL_FRAMEARENA_HELPERS |
|
39 |
|
40 /** |
|
41 * Respond to a gui event |
|
42 * @see nsIFrame::HandleEvent |
|
43 */ |
|
44 virtual nsresult HandleEvent(nsPresContext* aPresContext, |
|
45 mozilla::WidgetGUIEvent* aEvent, |
|
46 nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
|
47 |
|
48 virtual nscoord GetBaseline() const MOZ_OVERRIDE; |
|
49 |
|
50 /** |
|
51 * Respond to the request to resize and/or reflow |
|
52 * @see nsIFrame::Reflow |
|
53 */ |
|
54 virtual nsresult Reflow(nsPresContext* aCX, |
|
55 nsHTMLReflowMetrics& aDesiredSize, |
|
56 const nsHTMLReflowState& aReflowState, |
|
57 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
58 |
|
59 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
|
60 |
|
61 // new behavior |
|
62 |
|
63 virtual void SetFocus(bool aOn = true, bool aRepaint = false) MOZ_OVERRIDE; |
|
64 |
|
65 // nsIFormControlFrame |
|
66 virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE; |
|
67 |
|
68 // AccessKey Helper function |
|
69 static nsresult RegUnRegAccessKey(nsIFrame * aFrame, bool aDoReg); |
|
70 |
|
71 /** |
|
72 * Returns the usable screen rect in app units, eg the rect where we can |
|
73 * draw dropdowns. |
|
74 */ |
|
75 static nsRect GetUsableScreenRect(nsPresContext* aPresContext); |
|
76 |
|
77 protected: |
|
78 |
|
79 virtual ~nsFormControlFrame(); |
|
80 |
|
81 virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE; |
|
82 virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE; |
|
83 |
|
84 // |
|
85 //------------------------------------------------------------------------------------- |
|
86 // Utility methods for managing checkboxes and radiobuttons |
|
87 //------------------------------------------------------------------------------------- |
|
88 // |
|
89 /** |
|
90 * Get the state of the checked attribute. |
|
91 * @param aState set to true if the checked attribute is set, |
|
92 * false if the checked attribute has been removed |
|
93 */ |
|
94 |
|
95 void GetCurrentCheckState(bool* aState); |
|
96 }; |
|
97 |
|
98 #endif |
|
99 |