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