First Checked In.
git-svn-id: svn://10.0.0.236/trunk@42405 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
233
mozilla/layout/forms/nsGfxButtonControlFrame.cpp
Normal file
233
mozilla/layout/forms/nsGfxButtonControlFrame.cpp
Normal file
@@ -0,0 +1,233 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGfxButtonControlFrame.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIButton.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
|
||||
nsresult
|
||||
NS_NewGfxButtonControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsGfxButtonControlFrame* it = new nsGfxButtonControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsGfxButtonControlFrame::nsGfxButtonControlFrame()
|
||||
{
|
||||
mRenderer.SetNameSpace(kNameSpaceID_None);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = Inherited::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
mRenderer.SetFrame(this,aPresContext);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ReResolveStyleContext
|
||||
//
|
||||
// When the style context changes, make sure that all of our styles are still up to date.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList, PRInt32* aLocalChange)
|
||||
{
|
||||
// this re-resolves |mStyleContext|, so it may change
|
||||
nsresult rv = Inherited::ReResolveStyleContext(aPresContext, aParentContext,
|
||||
aParentChange, aChangeList, aLocalChange);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_COMFALSE != rv) { // frame style changed
|
||||
if (aLocalChange) {
|
||||
aParentChange = *aLocalChange; // tell children about or change
|
||||
}
|
||||
}
|
||||
mRenderer.ReResolveStyles(*aPresContext, aParentChange, aChangeList, aLocalChange);
|
||||
|
||||
return rv;
|
||||
|
||||
} // ReResolveStyleContext
|
||||
|
||||
|
||||
|
||||
|
||||
NS_METHOD
|
||||
nsGfxButtonControlFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->mVisible)
|
||||
return NS_OK;
|
||||
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, rect);
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
nsString label;
|
||||
nsresult result = GetValue(&label);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != result) {
|
||||
GetDefaultLabel(label);
|
||||
}
|
||||
|
||||
nsRect content;
|
||||
mRenderer.GetButtonContentRect(rect,content);
|
||||
|
||||
// paint the title
|
||||
const nsStyleFont* fontStyle = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
const nsStyleColor* colorStyle = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
|
||||
aRenderingContext.SetFont(fontStyle->mFont);
|
||||
|
||||
PRBool clipState;
|
||||
aRenderingContext.PushState();
|
||||
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipState);
|
||||
// if disabled paint
|
||||
if (PR_TRUE == mRenderer.isDisabled())
|
||||
{
|
||||
float p2t;
|
||||
aPresContext.GetScaledPixelsToTwips(&p2t);
|
||||
nscoord pixel = NSIntPixelsToTwips(1, p2t);
|
||||
|
||||
aRenderingContext.SetColor(NS_RGB(255,255,255));
|
||||
aRenderingContext.DrawString(label, content.x + pixel, content.y+ pixel);
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(colorStyle->mColor);
|
||||
aRenderingContext.DrawString(label, content.x, content.y);
|
||||
aRenderingContext.PopState(clipState);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
if (nsHTMLAtoms::value == aAttribute) {
|
||||
// redraw button with the changed value
|
||||
Invalidate(mRect, PR_FALSE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
|
||||
// add ourself as an nsIFormControlFrame
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
|
||||
if ((NS_FORMSIZE_NOTSET != mSuggestedWidth) && (
|
||||
NS_FORMSIZE_NOTSET != mSuggestedHeight))
|
||||
{
|
||||
aDesiredSize.width = mSuggestedWidth;
|
||||
aDesiredSize.height = mSuggestedHeight;
|
||||
aDesiredSize.ascent = mSuggestedHeight;
|
||||
aDesiredSize.descent = 0;
|
||||
if (aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = mSuggestedWidth;
|
||||
aDesiredSize.maxElementSize->height = mSuggestedWidth;
|
||||
}
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsSize ignore;
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, ignore);
|
||||
|
||||
// if our size is intrinsic. Then we need to return the size we really need
|
||||
// so include our inner borders we use for focus.
|
||||
nsMargin added = mRenderer.GetAddedButtonBorderAndPadding();
|
||||
if (aReflowState.mComputedWidth == NS_INTRINSICSIZE)
|
||||
aDesiredSize.width += added.left + added.right;
|
||||
|
||||
if (aReflowState.mComputedHeight == NS_INTRINSICSIZE)
|
||||
aDesiredSize.height += added.top + added.bottom;
|
||||
|
||||
nsMargin bp(0,0,0,0);
|
||||
AddBordersAndPadding(&aPresContext, aReflowState, aDesiredSize, bp);
|
||||
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.AddBorderPaddingToMaxElementSize(bp);
|
||||
aDesiredSize.maxElementSize->width += added.left + added.right;
|
||||
aDesiredSize.maxElementSize->height += added.top + added.bottom;
|
||||
|
||||
}
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
// if disabled do nothing
|
||||
if (mRenderer.isDisabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return Inherited::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
72
mozilla/layout/forms/nsGfxButtonControlFrame.h
Normal file
72
mozilla/layout/forms/nsGfxButtonControlFrame.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGfxButtonControlFrame_h___
|
||||
#define nsGfxButtonControlFrame_h___
|
||||
|
||||
#include "nsNativeFormControlFrame.h"
|
||||
#include "nsButtonControlFrame.h"
|
||||
#include "nsButtonFrameRenderer.h"
|
||||
|
||||
class nsGfxButtonControlFrame : public nsButtonControlFrame {
|
||||
private:
|
||||
typedef nsButtonControlFrame Inherited;
|
||||
|
||||
public:
|
||||
|
||||
nsGfxButtonControlFrame();
|
||||
|
||||
NS_IMETHOD Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* asPrevInFlow);
|
||||
|
||||
NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList,
|
||||
PRInt32* aLocalChange) ;
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
protected:
|
||||
//GFX-rendered state variables
|
||||
nsButtonFrameRenderer mRenderer;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
151
mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp
Normal file
151
mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGfxCheckboxControlFrame.h"
|
||||
#include "nsICheckButton.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewGfxCheckboxControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsGfxCheckboxControlFrame* it = new nsGfxCheckboxControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame()
|
||||
{
|
||||
// Initialize GFX-rendered state
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
mChecked = PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxCheckboxControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
{
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
Inherited::MouseClicked(aPresContext);
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
aRenderingContext.PushState();
|
||||
|
||||
float p2t;
|
||||
aPresContext.GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
|
||||
// Get current checked state through content model.
|
||||
// XXX: This is very inefficient, but it is necessary in the case of printing.
|
||||
// During printing the Paint is called but the actual state of the checkbox
|
||||
// is in a frame in presentation shell 0.
|
||||
/*XXXnsresult result = */GetCurrentCheckState(&checked);
|
||||
if (PR_TRUE == checked) {
|
||||
// Draw check mark
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
aRenderingContext.SetColor(color->mColor);
|
||||
nsFormControlHelper::PaintCheckMark(aRenderingContext,
|
||||
p2t, mRect.width, mRect.height);
|
||||
|
||||
}
|
||||
PRBool clip;
|
||||
aRenderingContext.PopState(clip);
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD
|
||||
nsGfxCheckboxControlFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->mVisible)
|
||||
return NS_OK;
|
||||
|
||||
// Paint the background
|
||||
Inherited::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
// Paint the checkmark
|
||||
PaintCheckBox(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsGfxCheckboxControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (nsEventStatus_eConsumeNoDefault == aEventStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Handle GFX rendered widget Mouse Down event
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
mMouseDownOnCheckbox = PR_TRUE;
|
||||
//XXX: TODO render gray rectangle on mouse down
|
||||
break;
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
//XXX: TO DO clear gray rectangle on mouse up
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return(Inherited::HandleEvent(aPresContext, aEvent, aEventStatus));
|
||||
}
|
||||
|
||||
|
||||
PRBool nsGfxCheckboxControlFrame::GetCheckboxState()
|
||||
{
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
void nsGfxCheckboxControlFrame::SetCheckboxState(PRBool aValue)
|
||||
{
|
||||
mChecked = aValue;
|
||||
nsFormControlHelper::ForceDrawFrame(this);
|
||||
}
|
||||
|
||||
66
mozilla/layout/forms/nsGfxCheckboxControlFrame.h
Normal file
66
mozilla/layout/forms/nsGfxCheckboxControlFrame.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsGfxCheckboxControlFrame_h___
|
||||
#define nsGfxCheckboxControlFrame_h___
|
||||
|
||||
#include "nsCheckboxControlFrame.h"
|
||||
|
||||
|
||||
class nsGfxCheckboxControlFrame : public nsCheckboxControlFrame {
|
||||
private:
|
||||
typedef nsCheckboxControlFrame Inherited;
|
||||
|
||||
public:
|
||||
nsGfxCheckboxControlFrame();
|
||||
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
||||
return MakeFrameName("CheckboxControl", aResult);
|
||||
}
|
||||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
//
|
||||
// Methods used to GFX-render the checkbox
|
||||
//
|
||||
|
||||
virtual void PaintCheckBox(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
//End of GFX-rendering methods
|
||||
|
||||
protected:
|
||||
virtual PRBool GetCheckboxState();
|
||||
virtual void SetCheckboxState(PRBool aValue);
|
||||
|
||||
//GFX-rendered state variables
|
||||
PRBool mMouseDownOnCheckbox;
|
||||
PRBool mChecked;
|
||||
};
|
||||
|
||||
#endif
|
||||
168
mozilla/layout/forms/nsGfxRadioControlFrame.cpp
Normal file
168
mozilla/layout/forms/nsGfxRadioControlFrame.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGfxRadioControlFrame.h"
|
||||
#include "nsIRadioButton.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCSSRendering.h"
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewGfxRadioControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsGfxRadioControlFrame* it = new nsGfxRadioControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGfxRadioControlFrame::nsGfxRadioControlFrame()
|
||||
{
|
||||
// Initialize GFX-rendered state
|
||||
mChecked = PR_FALSE;
|
||||
mRadioButtonFaceStyle = nsnull;
|
||||
}
|
||||
|
||||
nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
|
||||
{
|
||||
NS_IF_RELEASE(mRadioButtonFaceStyle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList,
|
||||
PRInt32* aLocalChange)
|
||||
{
|
||||
// this re-resolves |mStyleContext|, so it may change
|
||||
nsresult rv = Inherited::ReResolveStyleContext(aPresContext, aParentContext, aParentChange,
|
||||
aChangeList, aLocalChange);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_COMFALSE != rv) { // frame style changed
|
||||
if (aLocalChange) {
|
||||
aParentChange = *aLocalChange; // tell children about or change
|
||||
}
|
||||
}
|
||||
|
||||
// see if the outline has changed.
|
||||
nsCOMPtr<nsIStyleContext> oldRadioButtonFaceStyle = mRadioButtonFaceStyle;
|
||||
aPresContext->ProbePseudoStyleContextFor(mContent, nsHTMLAtoms::radioPseudo, mStyleContext,
|
||||
PR_FALSE,
|
||||
&mRadioButtonFaceStyle);
|
||||
|
||||
if ((mRadioButtonFaceStyle && oldRadioButtonFaceStyle.get()) && (mRadioButtonFaceStyle != oldRadioButtonFaceStyle.get())) {
|
||||
Inherited::CaptureStyleChangeFor(this, oldRadioButtonFaceStyle, mRadioButtonFaceStyle,
|
||||
aParentChange, aChangeList, aLocalChange);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext)
|
||||
{
|
||||
mRadioButtonFaceStyle = aRadioButtonFaceStyleContext;
|
||||
NS_ADDREF(mRadioButtonFaceStyle);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
|
||||
PRBool checked = PR_TRUE;
|
||||
GetCurrentCheckState(&checked); // Get check state from the content model
|
||||
if (PR_TRUE == checked) {
|
||||
// Paint the button for the radio button using CSS background rendering code
|
||||
if (nsnull != mRadioButtonFaceStyle) {
|
||||
const nsStyleColor* myColor = (const nsStyleColor*)
|
||||
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Color);
|
||||
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
|
||||
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Spacing);
|
||||
const nsStylePosition* myPosition = (const nsStylePosition*)
|
||||
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Position);
|
||||
|
||||
nscoord width = myPosition->mWidth.GetCoordValue();
|
||||
nscoord height = myPosition->mHeight.GetCoordValue();
|
||||
// Position the button centered within the radio control's rectangle.
|
||||
nscoord x = (mRect.width - width) / 2;
|
||||
nscoord y = (mRect.height - height) / 2;
|
||||
nsRect rect(x, y, width, height);
|
||||
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, rect, *mySpacing, mRadioButtonFaceStyle, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsGfxRadioControlFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->mVisible)
|
||||
return NS_OK;
|
||||
|
||||
// Paint the background
|
||||
Inherited::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
PaintRadioButton(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsGfxRadioControlFrame::GetRadioState()
|
||||
{
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
void nsGfxRadioControlFrame::SetRadioState(PRBool aValue)
|
||||
{
|
||||
mChecked = aValue;
|
||||
nsFormControlHelper::ForceDrawFrame(this);
|
||||
}
|
||||
79
mozilla/layout/forms/nsGfxRadioControlFrame.h
Normal file
79
mozilla/layout/forms/nsGfxRadioControlFrame.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGfxRadioControlFrame_h___
|
||||
#define nsGfxRadioControlFrame_h___
|
||||
|
||||
#include "nsRadioControlFrame.h"
|
||||
|
||||
// nsGfxRadioControlFrame
|
||||
|
||||
class nsGfxRadioControlFrame : public nsRadioControlFrame
|
||||
{
|
||||
private:
|
||||
typedef nsRadioControlFrame Inherited;
|
||||
|
||||
public:
|
||||
nsGfxRadioControlFrame();
|
||||
~nsGfxRadioControlFrame();
|
||||
|
||||
//nsIRadioControlFrame methods
|
||||
NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext);
|
||||
|
||||
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList,
|
||||
PRInt32* aLocalChange);
|
||||
|
||||
//
|
||||
// XXX: The following paint methods are TEMPORARY. It is being used to get printing working
|
||||
// under windows. Later it may be used to GFX-render the controls to the display.
|
||||
// Expect this code to repackaged and moved to a new location in the future.
|
||||
//
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
virtual void PaintRadioButton(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
///XXX: End o the temporary methods
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRBool GetRadioState();
|
||||
virtual void SetRadioState(PRBool aValue);
|
||||
|
||||
//GFX-rendered state variables
|
||||
PRBool mChecked;
|
||||
nsIStyleContext* mRadioButtonFaceStyle;
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
76
mozilla/layout/html/forms/src/nsCheckboxControlFrame.h
Normal file
76
mozilla/layout/html/forms/src/nsCheckboxControlFrame.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsCheckboxControlFrame_h___
|
||||
#define nsCheckboxControlFrame_h___
|
||||
|
||||
#include "nsNativeFormControlFrame.h"
|
||||
|
||||
|
||||
class nsCheckboxControlFrame : public nsNativeFormControlFrame {
|
||||
private:
|
||||
typedef nsNativeFormControlFrame Inherited;
|
||||
|
||||
public:
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext,
|
||||
nscoord& aWidth,
|
||||
nscoord& aHeight);
|
||||
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
||||
return MakeFrameName("CheckboxControl", aResult);
|
||||
}
|
||||
|
||||
virtual const nsIID& GetCID();
|
||||
|
||||
virtual const nsIID& GetIID();
|
||||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
virtual void Reset();
|
||||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
|
||||
|
||||
// Utility methods for implementing SetProperty/GetProperty
|
||||
void SetCheckboxControlFrameState(const nsString& aValue);
|
||||
void GetCheckboxControlFrameState(nsString& aValue);
|
||||
|
||||
// nsFormControlFrame overrides
|
||||
nsresult RequiresWidget(PRBool &aHasWidget);
|
||||
|
||||
//
|
||||
// Methods used to GFX-render the checkbox
|
||||
//
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
//End of GFX-rendering methods
|
||||
|
||||
protected:
|
||||
virtual PRBool GetCheckboxState() = 0;
|
||||
virtual void SetCheckboxState(PRBool aValue) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
233
mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp
Normal file
233
mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp
Normal file
@@ -0,0 +1,233 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGfxButtonControlFrame.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIButton.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
|
||||
nsresult
|
||||
NS_NewGfxButtonControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsGfxButtonControlFrame* it = new nsGfxButtonControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsGfxButtonControlFrame::nsGfxButtonControlFrame()
|
||||
{
|
||||
mRenderer.SetNameSpace(kNameSpaceID_None);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = Inherited::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
mRenderer.SetFrame(this,aPresContext);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ReResolveStyleContext
|
||||
//
|
||||
// When the style context changes, make sure that all of our styles are still up to date.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList, PRInt32* aLocalChange)
|
||||
{
|
||||
// this re-resolves |mStyleContext|, so it may change
|
||||
nsresult rv = Inherited::ReResolveStyleContext(aPresContext, aParentContext,
|
||||
aParentChange, aChangeList, aLocalChange);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_COMFALSE != rv) { // frame style changed
|
||||
if (aLocalChange) {
|
||||
aParentChange = *aLocalChange; // tell children about or change
|
||||
}
|
||||
}
|
||||
mRenderer.ReResolveStyles(*aPresContext, aParentChange, aChangeList, aLocalChange);
|
||||
|
||||
return rv;
|
||||
|
||||
} // ReResolveStyleContext
|
||||
|
||||
|
||||
|
||||
|
||||
NS_METHOD
|
||||
nsGfxButtonControlFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->mVisible)
|
||||
return NS_OK;
|
||||
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, rect);
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
nsString label;
|
||||
nsresult result = GetValue(&label);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != result) {
|
||||
GetDefaultLabel(label);
|
||||
}
|
||||
|
||||
nsRect content;
|
||||
mRenderer.GetButtonContentRect(rect,content);
|
||||
|
||||
// paint the title
|
||||
const nsStyleFont* fontStyle = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
const nsStyleColor* colorStyle = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
|
||||
aRenderingContext.SetFont(fontStyle->mFont);
|
||||
|
||||
PRBool clipState;
|
||||
aRenderingContext.PushState();
|
||||
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipState);
|
||||
// if disabled paint
|
||||
if (PR_TRUE == mRenderer.isDisabled())
|
||||
{
|
||||
float p2t;
|
||||
aPresContext.GetScaledPixelsToTwips(&p2t);
|
||||
nscoord pixel = NSIntPixelsToTwips(1, p2t);
|
||||
|
||||
aRenderingContext.SetColor(NS_RGB(255,255,255));
|
||||
aRenderingContext.DrawString(label, content.x + pixel, content.y+ pixel);
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(colorStyle->mColor);
|
||||
aRenderingContext.DrawString(label, content.x, content.y);
|
||||
aRenderingContext.PopState(clipState);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
if (nsHTMLAtoms::value == aAttribute) {
|
||||
// redraw button with the changed value
|
||||
Invalidate(mRect, PR_FALSE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
|
||||
// add ourself as an nsIFormControlFrame
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
|
||||
if ((NS_FORMSIZE_NOTSET != mSuggestedWidth) && (
|
||||
NS_FORMSIZE_NOTSET != mSuggestedHeight))
|
||||
{
|
||||
aDesiredSize.width = mSuggestedWidth;
|
||||
aDesiredSize.height = mSuggestedHeight;
|
||||
aDesiredSize.ascent = mSuggestedHeight;
|
||||
aDesiredSize.descent = 0;
|
||||
if (aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = mSuggestedWidth;
|
||||
aDesiredSize.maxElementSize->height = mSuggestedWidth;
|
||||
}
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
||||
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsSize ignore;
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, ignore);
|
||||
|
||||
// if our size is intrinsic. Then we need to return the size we really need
|
||||
// so include our inner borders we use for focus.
|
||||
nsMargin added = mRenderer.GetAddedButtonBorderAndPadding();
|
||||
if (aReflowState.mComputedWidth == NS_INTRINSICSIZE)
|
||||
aDesiredSize.width += added.left + added.right;
|
||||
|
||||
if (aReflowState.mComputedHeight == NS_INTRINSICSIZE)
|
||||
aDesiredSize.height += added.top + added.bottom;
|
||||
|
||||
nsMargin bp(0,0,0,0);
|
||||
AddBordersAndPadding(&aPresContext, aReflowState, aDesiredSize, bp);
|
||||
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.AddBorderPaddingToMaxElementSize(bp);
|
||||
aDesiredSize.maxElementSize->width += added.left + added.right;
|
||||
aDesiredSize.maxElementSize->height += added.top + added.bottom;
|
||||
|
||||
}
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
// if disabled do nothing
|
||||
if (mRenderer.isDisabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return Inherited::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
72
mozilla/layout/html/forms/src/nsGfxButtonControlFrame.h
Normal file
72
mozilla/layout/html/forms/src/nsGfxButtonControlFrame.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGfxButtonControlFrame_h___
|
||||
#define nsGfxButtonControlFrame_h___
|
||||
|
||||
#include "nsNativeFormControlFrame.h"
|
||||
#include "nsButtonControlFrame.h"
|
||||
#include "nsButtonFrameRenderer.h"
|
||||
|
||||
class nsGfxButtonControlFrame : public nsButtonControlFrame {
|
||||
private:
|
||||
typedef nsButtonControlFrame Inherited;
|
||||
|
||||
public:
|
||||
|
||||
nsGfxButtonControlFrame();
|
||||
|
||||
NS_IMETHOD Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* asPrevInFlow);
|
||||
|
||||
NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList,
|
||||
PRInt32* aLocalChange) ;
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
protected:
|
||||
//GFX-rendered state variables
|
||||
nsButtonFrameRenderer mRenderer;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
151
mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp
Normal file
151
mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGfxCheckboxControlFrame.h"
|
||||
#include "nsICheckButton.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewGfxCheckboxControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsGfxCheckboxControlFrame* it = new nsGfxCheckboxControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame()
|
||||
{
|
||||
// Initialize GFX-rendered state
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
mChecked = PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxCheckboxControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
{
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
Inherited::MouseClicked(aPresContext);
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
aRenderingContext.PushState();
|
||||
|
||||
float p2t;
|
||||
aPresContext.GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
|
||||
// Get current checked state through content model.
|
||||
// XXX: This is very inefficient, but it is necessary in the case of printing.
|
||||
// During printing the Paint is called but the actual state of the checkbox
|
||||
// is in a frame in presentation shell 0.
|
||||
/*XXXnsresult result = */GetCurrentCheckState(&checked);
|
||||
if (PR_TRUE == checked) {
|
||||
// Draw check mark
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
aRenderingContext.SetColor(color->mColor);
|
||||
nsFormControlHelper::PaintCheckMark(aRenderingContext,
|
||||
p2t, mRect.width, mRect.height);
|
||||
|
||||
}
|
||||
PRBool clip;
|
||||
aRenderingContext.PopState(clip);
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD
|
||||
nsGfxCheckboxControlFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->mVisible)
|
||||
return NS_OK;
|
||||
|
||||
// Paint the background
|
||||
Inherited::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
// Paint the checkmark
|
||||
PaintCheckBox(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsGfxCheckboxControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (nsEventStatus_eConsumeNoDefault == aEventStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Handle GFX rendered widget Mouse Down event
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
mMouseDownOnCheckbox = PR_TRUE;
|
||||
//XXX: TODO render gray rectangle on mouse down
|
||||
break;
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
//XXX: TO DO clear gray rectangle on mouse up
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return(Inherited::HandleEvent(aPresContext, aEvent, aEventStatus));
|
||||
}
|
||||
|
||||
|
||||
PRBool nsGfxCheckboxControlFrame::GetCheckboxState()
|
||||
{
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
void nsGfxCheckboxControlFrame::SetCheckboxState(PRBool aValue)
|
||||
{
|
||||
mChecked = aValue;
|
||||
nsFormControlHelper::ForceDrawFrame(this);
|
||||
}
|
||||
|
||||
66
mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h
Normal file
66
mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsGfxCheckboxControlFrame_h___
|
||||
#define nsGfxCheckboxControlFrame_h___
|
||||
|
||||
#include "nsCheckboxControlFrame.h"
|
||||
|
||||
|
||||
class nsGfxCheckboxControlFrame : public nsCheckboxControlFrame {
|
||||
private:
|
||||
typedef nsCheckboxControlFrame Inherited;
|
||||
|
||||
public:
|
||||
nsGfxCheckboxControlFrame();
|
||||
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
||||
return MakeFrameName("CheckboxControl", aResult);
|
||||
}
|
||||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
//
|
||||
// Methods used to GFX-render the checkbox
|
||||
//
|
||||
|
||||
virtual void PaintCheckBox(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
//End of GFX-rendering methods
|
||||
|
||||
protected:
|
||||
virtual PRBool GetCheckboxState();
|
||||
virtual void SetCheckboxState(PRBool aValue);
|
||||
|
||||
//GFX-rendered state variables
|
||||
PRBool mMouseDownOnCheckbox;
|
||||
PRBool mChecked;
|
||||
};
|
||||
|
||||
#endif
|
||||
168
mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp
Normal file
168
mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsGfxRadioControlFrame.h"
|
||||
#include "nsIRadioButton.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCSSRendering.h"
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewGfxRadioControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsGfxRadioControlFrame* it = new nsGfxRadioControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGfxRadioControlFrame::nsGfxRadioControlFrame()
|
||||
{
|
||||
// Initialize GFX-rendered state
|
||||
mChecked = PR_FALSE;
|
||||
mRadioButtonFaceStyle = nsnull;
|
||||
}
|
||||
|
||||
nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
|
||||
{
|
||||
NS_IF_RELEASE(mRadioButtonFaceStyle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList,
|
||||
PRInt32* aLocalChange)
|
||||
{
|
||||
// this re-resolves |mStyleContext|, so it may change
|
||||
nsresult rv = Inherited::ReResolveStyleContext(aPresContext, aParentContext, aParentChange,
|
||||
aChangeList, aLocalChange);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_COMFALSE != rv) { // frame style changed
|
||||
if (aLocalChange) {
|
||||
aParentChange = *aLocalChange; // tell children about or change
|
||||
}
|
||||
}
|
||||
|
||||
// see if the outline has changed.
|
||||
nsCOMPtr<nsIStyleContext> oldRadioButtonFaceStyle = mRadioButtonFaceStyle;
|
||||
aPresContext->ProbePseudoStyleContextFor(mContent, nsHTMLAtoms::radioPseudo, mStyleContext,
|
||||
PR_FALSE,
|
||||
&mRadioButtonFaceStyle);
|
||||
|
||||
if ((mRadioButtonFaceStyle && oldRadioButtonFaceStyle.get()) && (mRadioButtonFaceStyle != oldRadioButtonFaceStyle.get())) {
|
||||
Inherited::CaptureStyleChangeFor(this, oldRadioButtonFaceStyle, mRadioButtonFaceStyle,
|
||||
aParentChange, aChangeList, aLocalChange);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext)
|
||||
{
|
||||
mRadioButtonFaceStyle = aRadioButtonFaceStyleContext;
|
||||
NS_ADDREF(mRadioButtonFaceStyle);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
|
||||
PRBool checked = PR_TRUE;
|
||||
GetCurrentCheckState(&checked); // Get check state from the content model
|
||||
if (PR_TRUE == checked) {
|
||||
// Paint the button for the radio button using CSS background rendering code
|
||||
if (nsnull != mRadioButtonFaceStyle) {
|
||||
const nsStyleColor* myColor = (const nsStyleColor*)
|
||||
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Color);
|
||||
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
|
||||
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Spacing);
|
||||
const nsStylePosition* myPosition = (const nsStylePosition*)
|
||||
mRadioButtonFaceStyle->GetStyleData(eStyleStruct_Position);
|
||||
|
||||
nscoord width = myPosition->mWidth.GetCoordValue();
|
||||
nscoord height = myPosition->mHeight.GetCoordValue();
|
||||
// Position the button centered within the radio control's rectangle.
|
||||
nscoord x = (mRect.width - width) / 2;
|
||||
nscoord y = (mRect.height - height) / 2;
|
||||
nsRect rect(x, y, width, height);
|
||||
|
||||
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
||||
aDirtyRect, rect, *mySpacing, mRadioButtonFaceStyle, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsGfxRadioControlFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||
if (!disp->mVisible)
|
||||
return NS_OK;
|
||||
|
||||
// Paint the background
|
||||
Inherited::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
PaintRadioButton(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsGfxRadioControlFrame::GetRadioState()
|
||||
{
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
void nsGfxRadioControlFrame::SetRadioState(PRBool aValue)
|
||||
{
|
||||
mChecked = aValue;
|
||||
nsFormControlHelper::ForceDrawFrame(this);
|
||||
}
|
||||
79
mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h
Normal file
79
mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGfxRadioControlFrame_h___
|
||||
#define nsGfxRadioControlFrame_h___
|
||||
|
||||
#include "nsRadioControlFrame.h"
|
||||
|
||||
// nsGfxRadioControlFrame
|
||||
|
||||
class nsGfxRadioControlFrame : public nsRadioControlFrame
|
||||
{
|
||||
private:
|
||||
typedef nsRadioControlFrame Inherited;
|
||||
|
||||
public:
|
||||
nsGfxRadioControlFrame();
|
||||
~nsGfxRadioControlFrame();
|
||||
|
||||
//nsIRadioControlFrame methods
|
||||
NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext);
|
||||
|
||||
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aParentContext,
|
||||
PRInt32 aParentChange,
|
||||
nsStyleChangeList* aChangeList,
|
||||
PRInt32* aLocalChange);
|
||||
|
||||
//
|
||||
// XXX: The following paint methods are TEMPORARY. It is being used to get printing working
|
||||
// under windows. Later it may be used to GFX-render the controls to the display.
|
||||
// Expect this code to repackaged and moved to a new location in the future.
|
||||
//
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
virtual void PaintRadioButton(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
///XXX: End o the temporary methods
|
||||
|
||||
protected:
|
||||
|
||||
virtual PRBool GetRadioState();
|
||||
virtual void SetRadioState(PRBool aValue);
|
||||
|
||||
//GFX-rendered state variables
|
||||
PRBool mChecked;
|
||||
nsIStyleContext* mRadioButtonFaceStyle;
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
97
mozilla/layout/html/forms/src/nsNativeButtonControlFrame.cpp
Normal file
97
mozilla/layout/html/forms/src/nsNativeButtonControlFrame.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsNativeButtonControlFrame.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIButton.h"
|
||||
|
||||
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
|
||||
nsresult
|
||||
NS_NewNativeButtonControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsNativeButtonControlFrame* it = new nsNativeButtonControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (mWidget) {
|
||||
if (nsHTMLAtoms::value == aAttribute) {
|
||||
nsIButton* button = nsnull;
|
||||
result = mWidget->QueryInterface(kIButtonIID, (void**)&button);
|
||||
if ((NS_SUCCEEDED(result)) && (nsnull != button)) {
|
||||
nsString value;
|
||||
/*XXXnsresult result = */GetValue(&value);
|
||||
button->SetLabel(value);
|
||||
NS_RELEASE(button);
|
||||
nsFormFrame::StyleChangeReflow(aPresContext, this);
|
||||
}
|
||||
} else if (nsHTMLAtoms::size == aAttribute) {
|
||||
nsFormFrame::StyleChangeReflow(aPresContext, this);
|
||||
}
|
||||
// Allow the base class to handle common attributes supported
|
||||
// by all form elements...
|
||||
else {
|
||||
result = Inherited::AttributeChanged(aPresContext, aChild, aAttribute, aHint);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsNativeButtonControlFrame::PostCreateWidget(nsIPresContext* aPresContext, nscoord& aWidth, nscoord& aHeight)
|
||||
{
|
||||
nsIButton* button = nsnull;
|
||||
if (mWidget && (NS_OK == mWidget->QueryInterface(kIButtonIID,(void**)&button))) {
|
||||
nsFont font(aPresContext->GetDefaultFixedFontDeprecated());
|
||||
GetFont(aPresContext, font);
|
||||
mWidget->SetFont(font);
|
||||
SetColors(*aPresContext);
|
||||
|
||||
nsAutoString value;
|
||||
nsresult result = GetValue(&value);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != result) {
|
||||
GetDefaultLabel(value);
|
||||
}
|
||||
button->SetLabel(value);
|
||||
NS_RELEASE(button);
|
||||
|
||||
mWidget->Enable(!nsFormFrame::GetDisabled(this));
|
||||
}
|
||||
}
|
||||
|
||||
44
mozilla/layout/html/forms/src/nsNativeButtonControlFrame.h
Normal file
44
mozilla/layout/html/forms/src/nsNativeButtonControlFrame.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsNativeButtonControlFrame_h___
|
||||
#define nsNativeButtonControlFrame_h___
|
||||
|
||||
#include "nsNativeFormControlFrame.h"
|
||||
#include "nsButtonControlFrame.h"
|
||||
#include "nsButtonFrameRenderer.h"
|
||||
|
||||
class nsNativeButtonControlFrame : public nsButtonControlFrame {
|
||||
private:
|
||||
typedef nsButtonControlFrame Inherited;
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext,
|
||||
nscoord& aWidth,
|
||||
nscoord& aHeight);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
157
mozilla/layout/html/forms/src/nsNativeCheckboxControlFram.cpp
Normal file
157
mozilla/layout/html/forms/src/nsNativeCheckboxControlFram.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsNativeCheckboxControlFram.h"
|
||||
#include "nsICheckButton.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
||||
#define NS_DEFAULT_CHECKBOX_SIZE 12
|
||||
|
||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewNativeCheckboxControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsNativeCheckboxControlFrame* it = new nsNativeCheckboxControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nscoord
|
||||
nsNativeCheckboxControlFrame::GetCheckboxSize(float aPixToTwip) const
|
||||
{
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
PRInt32 checkboxSize = 0;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_CheckboxSize, checkboxSize);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
if (checkboxSize == 0)
|
||||
checkboxSize = NS_DEFAULT_CHECKBOX_SIZE;
|
||||
return NSIntPixelsToTwips(checkboxSize, aPixToTwip);
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeCheckboxControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
aDesiredWidgetSize.width = GetCheckboxSize(p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.height = aDesiredWidgetSize.height;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsNativeCheckboxControlFrame::PostCreateWidget(nsIPresContext* aPresContext, nscoord& aWidth, nscoord& aHeight)
|
||||
{
|
||||
Inherited::PostCreateWidget(aPresContext, aWidth, aHeight);
|
||||
|
||||
if (mWidget != nsnull) {
|
||||
SetColors(*aPresContext);
|
||||
mWidget->Enable(!nsFormFrame::GetDisabled(this));
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeCheckboxControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (mWidget) {
|
||||
if (nsHTMLAtoms::checked == aAttribute) {
|
||||
nsICheckButton* button = nsnull;
|
||||
result = mWidget->QueryInterface(GetIID(), (void**)&button);
|
||||
if ((NS_SUCCEEDED(result)) && (nsnull != button)) {
|
||||
PRBool checkedAttr;
|
||||
GetCurrentCheckState(&checkedAttr);
|
||||
PRBool checkedPrevState;
|
||||
button->GetState(checkedPrevState);
|
||||
if (checkedAttr != checkedPrevState) {
|
||||
button->SetState(checkedAttr);
|
||||
}
|
||||
NS_RELEASE(button);
|
||||
}
|
||||
}
|
||||
// Allow the base class to handle common attributes supported
|
||||
// by all form elements...
|
||||
else {
|
||||
result = Inherited::AttributeChanged(aPresContext, aChild, aAttribute, aHint);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PRBool nsNativeCheckboxControlFrame::GetCheckboxState()
|
||||
{
|
||||
PRBool state = PR_FALSE;
|
||||
|
||||
nsICheckButton* checkBox = nsnull;
|
||||
if (nsnull != mWidget) {
|
||||
// native-widget
|
||||
if (NS_SUCCEEDED(mWidget->QueryInterface(kICheckButtonIID,(void**)&checkBox))) {
|
||||
checkBox->GetState(state);
|
||||
NS_RELEASE(checkBox);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
void nsNativeCheckboxControlFrame::SetCheckboxState(PRBool aValue)
|
||||
{
|
||||
if (nsnull != mWidget) {
|
||||
nsICheckButton* checkBox = nsnull;
|
||||
if (NS_OK == mWidget->QueryInterface(kICheckButtonIID,(void**)&checkBox)) {
|
||||
checkBox->SetState(aValue);
|
||||
NS_RELEASE(checkBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
mozilla/layout/html/forms/src/nsNativeCheckboxControlFram.h
Normal file
49
mozilla/layout/html/forms/src/nsNativeCheckboxControlFram.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsNativeCheckboxControlFrame_h___
|
||||
#define nsNativeCheckboxControlFrame_h___
|
||||
|
||||
#include "nsCheckboxControlFrame.h"
|
||||
|
||||
|
||||
class nsNativeCheckboxControlFrame : public nsCheckboxControlFrame {
|
||||
private:
|
||||
typedef nsCheckboxControlFrame Inherited;
|
||||
|
||||
public:
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext,
|
||||
nscoord& aWidth,
|
||||
nscoord& aHeight);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
|
||||
protected:
|
||||
virtual PRBool GetCheckboxState();
|
||||
virtual void SetCheckboxState(PRBool aValue);
|
||||
|
||||
virtual nscoord GetCheckboxSize(float aPixToTwip) const;
|
||||
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
330
mozilla/layout/html/forms/src/nsNativeFormControlFrame.cpp
Normal file
330
mozilla/layout/html/forms/src/nsNativeFormControlFrame.cpp
Normal file
@@ -0,0 +1,330 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsViewsCID.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsNativeFormControlFrame.h"
|
||||
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
|
||||
|
||||
nsNativeFormControlFrame::nsNativeFormControlFrame()
|
||||
: Inherited()
|
||||
{
|
||||
mLastMouseState = eMouseNone;
|
||||
mWidget = nsnull;
|
||||
}
|
||||
|
||||
nsNativeFormControlFrame::~nsNativeFormControlFrame()
|
||||
{
|
||||
NS_IF_RELEASE(mWidget);
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD
|
||||
nsNativeFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (mDidInit) {
|
||||
return Inherited::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||
}
|
||||
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDeviceContext> dx;
|
||||
aPresContext.GetDeviceContext(getter_AddRefs(dx));
|
||||
PRBool requiresWidget = PR_TRUE;
|
||||
|
||||
// Checkto see if the device context supports widgets at all
|
||||
if (dx) {
|
||||
dx->SupportsNativeWidgets(requiresWidget);
|
||||
}
|
||||
|
||||
nsWidgetRendering mode;
|
||||
aPresContext.GetWidgetRenderingMode(&mode);
|
||||
if ((eWidgetRendering_Gfx == mode) || (eWidgetRendering_PartialGfx == mode)) {
|
||||
// Check with the frame to see if requires a widget to render
|
||||
if (PR_TRUE == requiresWidget) {
|
||||
RequiresWidget(requiresWidget);
|
||||
}
|
||||
}
|
||||
|
||||
if (! requiresWidget) {
|
||||
return Inherited::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||
}
|
||||
|
||||
// add ourself as an nsIFormControlFrame
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
|
||||
GetDesiredSize(&aPresContext, aReflowState, aDesiredSize, mWidgetSize);
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext.GetShell(getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIViewManager> viewMan;
|
||||
presShell->GetViewManager(getter_AddRefs(viewMan));
|
||||
nsRect boundBox(0, 0, aDesiredSize.width, aDesiredSize.height);
|
||||
|
||||
// absolutely positioned controls already have a view but not a widget
|
||||
nsIView* view = nsnull;
|
||||
GetView(&view);
|
||||
if (nsnull == view) {
|
||||
result = nsComponentManager::CreateInstance(kViewCID, nsnull, kIViewIID, (void **)&view);
|
||||
if (!NS_SUCCEEDED(result)) {
|
||||
NS_ASSERTION(0, "Could not create view for form control");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIFrame* parWithView;
|
||||
nsIView *parView;
|
||||
|
||||
GetParentWithView(&parWithView);
|
||||
parWithView->GetView(&parView);
|
||||
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "view initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
const nsIID& id = GetCID();
|
||||
|
||||
if ((NS_FORM_INPUT_HIDDEN != type) && (PR_TRUE == requiresWidget)) {
|
||||
// Do the following only if a widget is created
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
|
||||
// set our widget
|
||||
result = GetWidget(view, &mWidget);
|
||||
if ((PR_FALSE == NS_SUCCEEDED(result)) || (nsnull == mWidget)) { // keep the ref on mWidget
|
||||
NS_ASSERTION(0, "could not get widget");
|
||||
}
|
||||
}
|
||||
|
||||
PostCreateWidget(&aPresContext, aDesiredSize.width, aDesiredSize.height);
|
||||
mDidInit = PR_TRUE;
|
||||
|
||||
if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) {
|
||||
viewMan->ResizeView(view, aDesiredSize.width, aDesiredSize.height);
|
||||
}
|
||||
}
|
||||
|
||||
aDesiredSize.ascent = aDesiredSize.height;
|
||||
aDesiredSize.descent = 0;
|
||||
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
//XXX aDesiredSize.AddBorderPaddingToMaxElementSize(borderPadding);
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeFormControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
if (mWidget) {
|
||||
if (nsHTMLAtoms::disabled == aAttribute) {
|
||||
mWidget->Enable(!nsFormFrame::GetDisabled(this));
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsNativeFormControlFrame::SetColors(nsIPresContext& aPresContext)
|
||||
{
|
||||
if (mWidget) {
|
||||
nsCompatibility mode;
|
||||
aPresContext.GetCompatibilityMode(&mode);
|
||||
const nsStyleColor* color =
|
||||
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
if (nsnull != color) {
|
||||
if (!(NS_STYLE_BG_COLOR_TRANSPARENT & color->mBackgroundFlags)) {
|
||||
mWidget->SetBackgroundColor(color->mBackgroundColor);
|
||||
#ifdef bug_1021_closed
|
||||
} else if (eCompatibility_NavQuirks == mode) {
|
||||
#else
|
||||
} else {
|
||||
#endif
|
||||
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
mWidget->SetForegroundColor(color->mColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// native widgets don't need to repaint
|
||||
void
|
||||
nsNativeFormControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
||||
{
|
||||
if (mWidget) {
|
||||
if (aOn) {
|
||||
mWidget->SetFocus();
|
||||
}
|
||||
else {
|
||||
//Unsetting of focus on native widget is accomplised
|
||||
//by pushing focus up to its parent
|
||||
nsIWidget *parentWidget = mWidget->GetParent();
|
||||
if (parentWidget) {
|
||||
parentWidget->SetFocus();
|
||||
NS_RELEASE(parentWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNativeFormControlFrame::GetWidget(nsIWidget** aWidget)
|
||||
{
|
||||
if (mWidget) {
|
||||
NS_ADDREF(mWidget);
|
||||
*aWidget = mWidget;
|
||||
mWidget->Enable(!nsFormFrame::GetDisabled(this));
|
||||
return NS_OK;
|
||||
} else {
|
||||
*aWidget = nsnull;
|
||||
return NS_FORM_NOTOK;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNativeFormControlFrame::GetWidget(nsIView* aView, nsIWidget** aWidget)
|
||||
{
|
||||
nsIWidget* widget;
|
||||
aView->GetWidget(widget);
|
||||
nsresult result;
|
||||
|
||||
if (nsnull == widget) {
|
||||
*aWidget = nsnull;
|
||||
result = NS_ERROR_FAILURE;
|
||||
|
||||
} else {
|
||||
result = widget->QueryInterface(kIWidgetIID, (void**)aWidget); // keep the ref
|
||||
if (NS_FAILED(result)) {
|
||||
NS_ASSERTION(0, "The widget interface is invalid"); // need to print out more details of the widget
|
||||
}
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsNativeFormControlFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (nsnull == mWidget) {
|
||||
return Inherited::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault == aEventStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// make sure that the widget in the event is this input
|
||||
// XXX if there is no view, it could be an image button. Unfortunately,
|
||||
// every image button will get every event.
|
||||
nsIView* view;
|
||||
GetView(&view);
|
||||
if (view) {
|
||||
if (mWidget != aEvent->widget) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// if not native then use the NS_MOUSE_LEFT_CLICK to see if pressed
|
||||
// unfortunately native widgets don't seem to handle this right.
|
||||
// so use the old code for native stuff. -EDV
|
||||
|
||||
//printf(" %d %d %d %d (%d,%d) \n", this, aEvent->widget, aEvent->widgetSupports,
|
||||
// aEvent->message, aEvent->point.x, aEvent->point.y);
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_ENTER:
|
||||
mLastMouseState = eMouseEnter;
|
||||
break;
|
||||
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
if (NS_FORM_INPUT_IMAGE == type) {
|
||||
mLastMouseState = eMouseDown;
|
||||
} else {
|
||||
mLastMouseState = (eMouseEnter == mLastMouseState) ? eMouseDown : eMouseNone;
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
if (eMouseDown == mLastMouseState) {
|
||||
MouseClicked(&aPresContext);
|
||||
}
|
||||
mLastMouseState = eMouseEnter;
|
||||
break;
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
mLastMouseState = eMouseNone;
|
||||
break;
|
||||
|
||||
case NS_CONTROL_CHANGE:
|
||||
ControlChanged(&aPresContext);
|
||||
break;
|
||||
|
||||
case NS_KEY_DOWN:
|
||||
return Inherited::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
88
mozilla/layout/html/forms/src/nsNativeFormControlFrame.h
Normal file
88
mozilla/layout/html/forms/src/nsNativeFormControlFrame.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsNativeFormControlFrame_h___
|
||||
#define nsNativeFormControlFrame_h___
|
||||
|
||||
#include "nsFormControlFrame.h"
|
||||
|
||||
|
||||
/**
|
||||
* nsFormControlFrame is the base class for frames of form controls. It
|
||||
* provides a uniform way of creating widgets, resizing, and painting.
|
||||
* @see nsLeafFrame and its base classes for more info
|
||||
*/
|
||||
class nsNativeFormControlFrame : public nsFormControlFrame
|
||||
{
|
||||
private:
|
||||
typedef nsFormControlFrame Inherited;
|
||||
|
||||
public:
|
||||
nsNativeFormControlFrame();
|
||||
|
||||
|
||||
/**
|
||||
* Respond to the request to resize and/or reflow
|
||||
* @see nsIFrame::Reflow
|
||||
*/
|
||||
NS_IMETHOD Reflow(nsIPresContext& aCX,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
/**
|
||||
* Respond to a gui event
|
||||
* @see nsIFrame::HandleEvent
|
||||
*/
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
/**
|
||||
* Get the widget associated with this frame
|
||||
* @param aView the view associated with the frame. It is a convience parm.
|
||||
* @param aWidget the address of address of where the widget will be placed.
|
||||
* This method doses an AddRef on the widget.
|
||||
*/
|
||||
nsresult GetWidget(nsIView* aView, nsIWidget** aWidget);
|
||||
nsresult GetWidget(nsIWidget** aWidget);
|
||||
|
||||
PRBool HasNativeWidget() { return (nsnull != mWidget);}
|
||||
|
||||
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
|
||||
void SetColors(nsIPresContext& aPresContext);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~nsNativeFormControlFrame();
|
||||
|
||||
nsMouseState mLastMouseState;
|
||||
nsIWidget* mWidget;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
175
mozilla/layout/html/forms/src/nsNativeRadioControlFrame.cpp
Normal file
175
mozilla/layout/html/forms/src/nsNativeRadioControlFrame.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsNativeRadioControlFrame.h"
|
||||
#include "nsIRadioButton.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsFormFrame.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsStyleUtil.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIRadioIID, NS_IRADIOBUTTON_IID);
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
||||
|
||||
#define NS_DEFAULT_RADIOBOX_SIZE 12
|
||||
|
||||
nsresult
|
||||
NS_NewNativeRadioControlFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsNativeRadioControlFrame* it = new nsNativeRadioControlFrame;
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
nscoord
|
||||
nsNativeRadioControlFrame::GetRadioboxSize(float aPixToTwip) const
|
||||
{
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
PRInt32 radioboxSize = 0;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_RadioboxSize, radioboxSize);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
if (radioboxSize == 0)
|
||||
radioboxSize = NS_DEFAULT_RADIOBOX_SIZE;
|
||||
return NSIntPixelsToTwips(radioboxSize, aPixToTwip);
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeRadioControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
|
||||
nsWidgetRendering mode;
|
||||
aPresContext->GetWidgetRenderingMode(&mode);
|
||||
if ((eWidgetRendering_Gfx == mode) || (eWidgetRendering_PartialGfx == mode)) {
|
||||
Inherited::GetDesiredSize(aPresContext,aReflowState,aDesiredLayoutSize,
|
||||
aDesiredWidgetSize);
|
||||
} else {
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
aDesiredWidgetSize.width = GetRadioboxSize(p2t);
|
||||
aDesiredWidgetSize.height = aDesiredWidgetSize.width;
|
||||
|
||||
aDesiredLayoutSize.width = aDesiredWidgetSize.width;
|
||||
aDesiredLayoutSize.height = aDesiredWidgetSize.height;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeRadioControlFrame::PostCreateWidget(nsIPresContext* aPresContext, nscoord& aWidth, nscoord& aHeight)
|
||||
{
|
||||
Inherited::PostCreateWidget(aPresContext, aWidth, aHeight);
|
||||
|
||||
if (mWidget != nsnull) {
|
||||
const nsStyleColor* color =
|
||||
nsStyleUtil::FindNonTransparentBackground(mStyleContext);
|
||||
|
||||
if (nsnull != color) {
|
||||
mWidget->SetBackgroundColor(color->mBackgroundColor);
|
||||
} else {
|
||||
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
mWidget->Enable(!nsFormFrame::GetDisabled(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeRadioControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (mWidget) {
|
||||
if (nsHTMLAtoms::checked == aAttribute) {
|
||||
nsIRadioButton* button = nsnull;
|
||||
result = mWidget->QueryInterface(kIRadioIID, (void**)&button);
|
||||
if ((NS_SUCCEEDED(result)) && (nsnull != button)) {
|
||||
PRBool checkedAttr = PR_TRUE;
|
||||
GetCurrentCheckState(&checkedAttr);
|
||||
PRBool checkedPrevState = PR_TRUE;
|
||||
button->GetState(checkedPrevState);
|
||||
if (checkedAttr != checkedPrevState) {
|
||||
button->SetState(checkedAttr);
|
||||
mFormFrame->OnRadioChecked(*this, checkedAttr);
|
||||
}
|
||||
NS_RELEASE(button);
|
||||
}
|
||||
}
|
||||
// Allow the base class to handle common attributes supported
|
||||
// by all form elements...
|
||||
else {
|
||||
result = Inherited::AttributeChanged(aPresContext, aChild, aAttribute, aHint);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PRBool nsNativeRadioControlFrame::GetRadioState()
|
||||
{
|
||||
PRBool state = PR_FALSE;
|
||||
|
||||
if (nsnull != mWidget) {
|
||||
nsIRadioButton* radio = nsnull;
|
||||
if (NS_SUCCEEDED(mWidget->QueryInterface(kIRadioIID,(void**)&radio))) {
|
||||
radio->GetState(state);
|
||||
NS_RELEASE(radio);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
void nsNativeRadioControlFrame::SetRadioState(PRBool aValue)
|
||||
{
|
||||
if (nsnull != mWidget) {
|
||||
nsIRadioButton* radio = nsnull;
|
||||
if (NS_OK == mWidget->QueryInterface(kIRadioIID,(void**)&radio)) {
|
||||
radio->SetState(aValue);
|
||||
NS_RELEASE(radio);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
mozilla/layout/html/forms/src/nsNativeRadioControlFrame.h
Normal file
66
mozilla/layout/html/forms/src/nsNativeRadioControlFrame.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsNativeRadioControlFrame_h___
|
||||
#define nsNativeRadioControlFrame_h___
|
||||
|
||||
#include "nsIRadioControlFrame.h"
|
||||
#include "nsRadioControlFrame.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
class nsIAtom;
|
||||
|
||||
// nsNativeRadioControlFrame
|
||||
|
||||
class nsNativeRadioControlFrame : public nsRadioControlFrame
|
||||
{
|
||||
private:
|
||||
typedef nsRadioControlFrame Inherited;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext,
|
||||
nscoord& aWidth,
|
||||
nscoord& aHeight);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint);
|
||||
|
||||
|
||||
protected:
|
||||
virtual PRBool GetRadioState();
|
||||
virtual void SetRadioState(PRBool aValue);
|
||||
|
||||
virtual nscoord GetRadioboxSize(float aPixToTwip) const;
|
||||
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize);
|
||||
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1421
mozilla/layout/html/forms/src/nsNativeSelectControlFrame.cpp
Normal file
1421
mozilla/layout/html/forms/src/nsNativeSelectControlFrame.cpp
Normal file
File diff suppressed because it is too large
Load Diff
71
mozilla/layout/html/forms/src/nsRadioControlGroup.cpp
Normal file
71
mozilla/layout/html/forms/src/nsRadioControlGroup.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsRadioControlGroup.h"
|
||||
|
||||
nsRadioControlGroup::nsRadioControlGroup(nsString& aName)
|
||||
:mName(aName), mCheckedRadio(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsRadioControlGroup::~nsRadioControlGroup()
|
||||
{
|
||||
mCheckedRadio = nsnull;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsRadioControlGroup::GetRadioCount() const
|
||||
{
|
||||
return mRadios.Count();
|
||||
}
|
||||
|
||||
nsRadioControlFrame*
|
||||
nsRadioControlGroup::GetRadioAt(PRInt32 aIndex) const
|
||||
{
|
||||
return (nsRadioControlFrame*) mRadios.ElementAt(aIndex);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsRadioControlGroup::AddRadio(nsRadioControlFrame* aRadio)
|
||||
{
|
||||
return mRadios.AppendElement(aRadio);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsRadioControlGroup::RemoveRadio(nsRadioControlFrame* aRadio)
|
||||
{
|
||||
return mRadios.RemoveElement(aRadio);
|
||||
}
|
||||
|
||||
nsRadioControlFrame*
|
||||
nsRadioControlGroup::GetCheckedRadio()
|
||||
{
|
||||
return mCheckedRadio;
|
||||
}
|
||||
|
||||
void
|
||||
nsRadioControlGroup::SetCheckedRadio(nsRadioControlFrame* aRadio)
|
||||
{
|
||||
mCheckedRadio = aRadio;
|
||||
}
|
||||
|
||||
void
|
||||
nsRadioControlGroup::GetName(nsString& aNameResult) const
|
||||
{
|
||||
aNameResult = mName;
|
||||
}
|
||||
47
mozilla/layout/html/forms/src/nsRadioControlGroup.h
Normal file
47
mozilla/layout/html/forms/src/nsRadioControlGroup.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsRadioControlGroup_h___
|
||||
#define nsRadioControlGroup_h___
|
||||
|
||||
#include "nsRadioControlFrame.h"
|
||||
|
||||
|
||||
class nsRadioControlGroup
|
||||
{
|
||||
public:
|
||||
nsRadioControlGroup(nsString& aName);
|
||||
virtual ~nsRadioControlGroup();
|
||||
|
||||
PRBool AddRadio(nsRadioControlFrame* aRadio);
|
||||
PRInt32 GetRadioCount() const;
|
||||
nsRadioControlFrame* GetRadioAt(PRInt32 aIndex) const;
|
||||
PRBool RemoveRadio(nsRadioControlFrame* aRadio);
|
||||
|
||||
nsRadioControlFrame* GetCheckedRadio();
|
||||
void SetCheckedRadio(nsRadioControlFrame* aRadio);
|
||||
void GetName(nsString& aNameResult) const;
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsVoidArray mRadios;
|
||||
nsRadioControlFrame* mCheckedRadio;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user