michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsFormControlFrame_h___ michael@0: #define nsFormControlFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIFormControlFrame.h" michael@0: #include "nsLeafFrame.h" michael@0: michael@0: /** michael@0: * nsFormControlFrame is the base class for radio buttons and michael@0: * checkboxes. It also has two static methods (RegUnRegAccessKey and michael@0: * GetScreenHeight) that are used by other form controls. michael@0: */ michael@0: class nsFormControlFrame : public nsLeafFrame, michael@0: public nsIFormControlFrame michael@0: { michael@0: public: michael@0: /** michael@0: * Main constructor michael@0: * @param aContent the content representing this frame michael@0: * @param aParentFrame the parent frame michael@0: */ michael@0: nsFormControlFrame(nsStyleContext*); michael@0: michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsLeafFrame::IsFrameOfType(aFlags & michael@0: ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); michael@0: } michael@0: michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: /** michael@0: * Respond to a gui event michael@0: * @see nsIFrame::HandleEvent michael@0: */ michael@0: virtual nsresult HandleEvent(nsPresContext* aPresContext, michael@0: mozilla::WidgetGUIEvent* aEvent, michael@0: nsEventStatus* aEventStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual nscoord GetBaseline() const MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Respond to the request to resize and/or reflow michael@0: * @see nsIFrame::Reflow michael@0: */ michael@0: virtual nsresult Reflow(nsPresContext* aCX, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; michael@0: michael@0: // new behavior michael@0: michael@0: virtual void SetFocus(bool aOn = true, bool aRepaint = false) MOZ_OVERRIDE; michael@0: michael@0: // nsIFormControlFrame michael@0: virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE; michael@0: michael@0: // AccessKey Helper function michael@0: static nsresult RegUnRegAccessKey(nsIFrame * aFrame, bool aDoReg); michael@0: michael@0: /** michael@0: * Returns the usable screen rect in app units, eg the rect where we can michael@0: * draw dropdowns. michael@0: */ michael@0: static nsRect GetUsableScreenRect(nsPresContext* aPresContext); michael@0: michael@0: protected: michael@0: michael@0: virtual ~nsFormControlFrame(); michael@0: michael@0: virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE; michael@0: virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE; michael@0: michael@0: // michael@0: //------------------------------------------------------------------------------------- michael@0: // Utility methods for managing checkboxes and radiobuttons michael@0: //------------------------------------------------------------------------------------- michael@0: // michael@0: /** michael@0: * Get the state of the checked attribute. michael@0: * @param aState set to true if the checked attribute is set, michael@0: * false if the checked attribute has been removed michael@0: */ michael@0: michael@0: void GetCurrentCheckState(bool* aState); michael@0: }; michael@0: michael@0: #endif michael@0: