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/. */
6 #ifndef nsFormControlFrame_h___
7 #define nsFormControlFrame_h___
9 #include "mozilla/Attributes.h"
10 #include "nsIFormControlFrame.h"
11 #include "nsLeafFrame.h"
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.
18 class nsFormControlFrame
: public nsLeafFrame
,
19 public nsIFormControlFrame
24 * @param aContent the content representing this frame
25 * @param aParentFrame the parent frame
27 explicit nsFormControlFrame(nsStyleContext
*);
29 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
31 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
33 return nsLeafFrame::IsFrameOfType(aFlags
&
34 ~(nsIFrame::eReplaced
| nsIFrame::eReplacedContainsBlock
));
38 NS_DECL_FRAMEARENA_HELPERS
41 * Respond to a gui event
42 * @see nsIFrame::HandleEvent
44 virtual nsresult
HandleEvent(nsPresContext
* aPresContext
,
45 mozilla::WidgetGUIEvent
* aEvent
,
46 nsEventStatus
* aEventStatus
) MOZ_OVERRIDE
;
48 virtual nscoord
GetLogicalBaseline(mozilla::WritingMode aWritingMode
)
52 * Respond to the request to resize and/or reflow
53 * @see nsIFrame::Reflow
55 virtual void Reflow(nsPresContext
* aCX
,
56 nsHTMLReflowMetrics
& aDesiredSize
,
57 const nsHTMLReflowState
& aReflowState
,
58 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
60 virtual void DestroyFrom(nsIFrame
* aDestructRoot
) MOZ_OVERRIDE
;
64 virtual void SetFocus(bool aOn
= true, bool aRepaint
= false) MOZ_OVERRIDE
;
66 // nsIFormControlFrame
67 virtual nsresult
SetFormProperty(nsIAtom
* aName
, const nsAString
& aValue
) MOZ_OVERRIDE
;
69 // AccessKey Helper function
70 static nsresult
RegUnRegAccessKey(nsIFrame
* aFrame
, bool aDoReg
);
73 * Returns the usable screen rect in app units, eg the rect where we can
76 static nsRect
GetUsableScreenRect(nsPresContext
* aPresContext
);
80 virtual ~nsFormControlFrame();
82 virtual nscoord
GetIntrinsicISize() MOZ_OVERRIDE
;
83 virtual nscoord
GetIntrinsicBSize() MOZ_OVERRIDE
;
86 //-------------------------------------------------------------------------------------
87 // Utility methods for managing checkboxes and radiobuttons
88 //-------------------------------------------------------------------------------------
91 * Get the state of the checked attribute.
92 * @param aState set to true if the checked attribute is set,
93 * false if the checked attribute has been removed
96 void GetCurrentCheckState(bool* aState
);