diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 50a1f8472d0..56838951386 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -237,32 +237,6 @@ nsComboboxControlFrame::GetWindowTemp(nsIView *aView) return nsnull; } -/** - * - */ -static void ForceDrawFrame(nsIFrame * aFrame)//, PRBool) -{ - if (aFrame == nsnull) { - return; - } - nsRect rect; - nsIView * view; - nsPoint pnt; - aFrame->GetOffsetFromView(pnt, view); - aFrame->GetRect(rect); - rect.x = pnt.x; - rect.y = pnt.y; - if (view != nsnull) { - nsIViewManager * viewMgr; - view->GetViewManager(viewMgr); - if (viewMgr != nsnull) { - viewMgr->UpdateView(view, rect, 0); - NS_RELEASE(viewMgr); - } - } - -} - //-------------------------------------------------------------- void nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) @@ -270,7 +244,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) //mContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "SELECTED", PR_TRUE); mGotFocus = aOn; if (aRepaint) { - ForceDrawFrame(this); + nsFormControlHelper::ForceDrawFrame(this); } } @@ -296,7 +270,7 @@ void nsComboboxControlFrame::MouseClicked(nsIPresContext* aPresContext) } mListFrame->ReResolveStyleContext(aPresContext, mCurrentStyleContext); - ForceDrawFrame(mListFrame); + nsFormControlHelper::ForceDrawFrame(mListFrame); } } @@ -764,14 +738,14 @@ NS_IMETHODIMP nsComboboxControlFrame::HandleEvent(nsIPresContext& aPresContext, if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { mArrowStyle = mBtnOutStyleContext; - ForceDrawFrame(this); + nsFormControlHelper::ForceDrawFrame(this); //MouseClicked(&aPresContext); } else if (aEvent->message == NS_MOUSE_MOVE) { } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { mArrowStyle = mBtnPressedStyleContext; - ForceDrawFrame(this); + nsFormControlHelper::ForceDrawFrame(this); MouseClicked(&aPresContext); } } diff --git a/mozilla/layout/forms/nsFormControlFrame.h b/mozilla/layout/forms/nsFormControlFrame.h index 9ac833ff8d1..0aec41e8f96 100644 --- a/mozilla/layout/forms/nsFormControlFrame.h +++ b/mozilla/layout/forms/nsFormControlFrame.h @@ -268,201 +268,6 @@ protected: nsresult SetDefaultCheckState(PRBool aState); - - //nscoord GetStyleDim(nsIPresContext& aPresContext, nscoord aMaxDim, - // nscoord aMaxWidth, const nsStyleCoord& aCoord); - -#if 0 - -// -//------------------------------------------------------------------------------------- -// Utility methods for rendering Form Elements using GFX -//------------------------------------------------------------------------------------- -// -// XXX: The following location for the paint code is TEMPORARY. -// It is being used to get printing working -// under windows. Later it will be used to GFX-render the controls to the display. -// Expect this code to repackaged and moved to a new location in the future. - - /** - * Enumeration of possible mouse states used to detect mouse clicks - */ - enum nsArrowDirection { - eArrowDirection_Left, - eArrowDirection_Right, - eArrowDirection_Up, - eArrowDirection_Down - }; - - /** - * Scale, translate and convert an arrow of poitns from nscoord's to nsPoints's. - * - * @param aNumberOfPoints number of (x,y) pairs - * @param aPoints arrow of points to convert - * @param aScaleFactor scale factor to apply to each points translation. - * @param aX x coordinate to add to each point after scaling - * @param aY y coordinate to add to each point after scaling - * @param aCenterX x coordinate of the center point in the original array of points. - * @param aCenterY y coordiante of the center point in the original array of points. - */ - - static void SetupPoints(PRUint32 aNumberOfPoints, nscoord* aPoints, - nsPoint* aPolygon, nscoord aScaleFactor, nscoord aX, nscoord aY, - nscoord aCenterX, nscoord aCenterY); - - /** - * Paint a fat line. The line is drawn as a polygon with a specified width. - * - * @param aRenderingContext the rendering context - * @param aSX starting x in pixels - * @param aSY starting y in pixels - * @param aEX ending x in pixels - * @param aEY ending y in pixels - * @param aHorz PR_TRUE if aWidth is added to x coordinates to form polygon. If - * PR_FALSE then aWidth as added to the y coordinates. - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintLine(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY, - PRBool aHorz, nscoord aWidth, nscoord aOnePixel); - - /** - * Draw an arrow glyph. - * - * @param aRenderingContext the rendering context - * @param aSX upper left x coordinate pixels - * @param aSY upper left y coordinate pixels - * @param aType @see nsArrowDirection enumeration - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintArrowGlyph(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nsArrowDirection aArrowDirection, - nscoord aOnePixel); - - /** - * Draw an arrow - * - * @param aArrowDirection @see nsArrowDirection enumeration - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aOnePixel number of TWIPS in a single pixel - * @param aColor color of the arrow glph - * @param aSpacing spacing for the arrow background - * @param aForFrame frame which the arrow will be rendered into. - * @param aFrameRect rectangle for the frame specified by aForFrame - */ - - static void PaintArrow(nsArrowDirection aArrowDirection, - nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - nscoord aOnePixel, - nsIStyleContext* aArrowStyle, - const nsStyleSpacing& aSpacing, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a scrollbar - * - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aRect width and height of the scrollbar - * @param aHorizontal if TRUE scrollbar is drawn horizontally, vertical if FALSE - * @param aOnePixel number TWIPS per pixel - * @param aScrollbarStyleContext style context for the scrollbar - * @param aScrollbarArrowStyleContext style context for the scrollbar arrow - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aFrameRect the rectangle for the frame passed as aForFrame - */ - - static void PaintScrollbar(nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - PRBool aHorizontal, - nscoord aOnePixel, - nsIStyleContext* aScrollbarStyleContext, - nsIStyleContext* aScrollbarArrowStyleContext, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a fixed size checkmark - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - */ - - static void PaintFixedSizeCheckMark(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips); - - /** - * Paint a fixed size checkmark border - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - * @param aBackgroundColor color for background of checkbox - */ - - static void PaintFixedSizeCheckMarkBorder(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips, const nsStyleColor& aBackgroundColor); - - /** - * Paint a rectangular button. Includes background, string, and focus indicator - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aWidth width the checkmark border in TWIPS - * @param aHeight height of the checkmark border in TWIPS - * @param aShift if PR_TRUE offset button as if it were pressed - * @param aShowFocus if PR_TRUE draw focus rectangle over button - * @param aStyleContext style context used for drawing button background - * @param aLabel label for button - * @param aForFrame the frame that the scrollbar will be rendered in to - */ - - static void PaintRectangularButton(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, PRUint32 aWidth, - PRUint32 aHeight, PRBool aShift, PRBool aShowFocus, - nsIStyleContext* aStyleContext, nsString& aLabel, - nsFormControlFrame* aForFrame); - /** - * Paint a focus indicator. - * - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aInside border inside - * @param aOutside border outside - */ - - static void PaintFocus(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsRect& aInside, nsRect& aOutside); - - /** - * Paint a circular border - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aStyleContext style context specifying colors and spacing - * @param aInset if PR_TRUE draw inset, otherwise draw outset - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aWidth width of the border in TWIPS - * @param aHeight height ofthe border in TWIPS - */ - - static void PaintCircularBorder(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsIStyleContext* aStyleContext, PRBool aInset, - nsIFrame* aForFrame, PRUint32 aWidth, PRUint32 aHeight); - -#endif nsMouseState mLastMouseState; nsIWidget* mWidget; nsSize mWidgetSize; diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 77a52c2e2ec..d4d1d5dd6ff 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -82,6 +82,28 @@ nsFormControlHelper::~nsFormControlHelper() { } +void nsFormControlHelper::ForceDrawFrame(nsIFrame * aFrame) +{ + if (aFrame == nsnull) { + return; + } + nsRect rect; + nsIView * view; + nsPoint pnt; + aFrame->GetOffsetFromView(pnt, view); + aFrame->GetRect(rect); + rect.x = pnt.x; + rect.y = pnt.y; + if (view != nsnull) { + nsIViewManager * viewMgr; + view->GetViewManager(viewMgr); + if (viewMgr != nsnull) { + viewMgr->UpdateView(view, rect, 0); + NS_RELEASE(viewMgr); + } + } +} + /*nscoord nsFormControlHelper::GetScrollbarWidth(float aPixToTwip) diff --git a/mozilla/layout/forms/nsFormControlHelper.h b/mozilla/layout/forms/nsFormControlHelper.h index 6533d51e1ba..b6378a08441 100644 --- a/mozilla/layout/forms/nsFormControlHelper.h +++ b/mozilla/layout/forms/nsFormControlHelper.h @@ -104,18 +104,12 @@ public: nsIStyleContext * aStyleContext, nsFont& aFont); + static void ForceDrawFrame(nsIFrame * aFrame); + // XXX similar functionality needs to be added to widget library and these // need to change to use it. static nscoord GetScrollbarWidth(float aPixToTwip); - /*virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; - virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; - virtual nscoord GetVerticalInsidePadding(float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; - */ + static nsCompatibility GetRepChars(nsIPresContext& aPresContext, char& char1, char& char2); // @@ -151,10 +145,6 @@ public: nsresult GetDefaultCheckState(PRBool* aState); - //nscoord GetStyleDim(nsIPresContext& aPresContext, nscoord aMaxDim, - // nscoord aMaxWidth, const nsStyleCoord& aCoord); - - // //------------------------------------------------------------------------------------- // Utility methods for rendering Form Elements using GFX @@ -343,203 +333,7 @@ public: const nsRect& aDirtyRect, nsIStyleContext* aStyleContext, PRBool aInset, nsIFrame* aForFrame, PRUint32 aWidth, PRUint32 aHeight); -#if 0 - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** -// -//------------------------------------------------------------------------------------- -// Utility methods for rendering Form Elements using GFX -//------------------------------------------------------------------------------------- -// -// XXX: The following location for the paint code is TEMPORARY. -// It is being used to get printing working -// under windows. Later it will be used to GFX-render the controls to the display. -// Expect this code to repackaged and moved to a new location in the future. - /** - * Enumeration of possible mouse states used to detect mouse clicks - */ - enum nsArrowDirection { - eArrowDirection_Left, - eArrowDirection_Right, - eArrowDirection_Up, - eArrowDirection_Down - }; - - /** - * Scale, translate and convert an arrow of poitns from nscoord's to nsPoints's. - * - * @param aNumberOfPoints number of (x,y) pairs - * @param aPoints arrow of points to convert - * @param aScaleFactor scale factor to apply to each points translation. - * @param aX x coordinate to add to each point after scaling - * @param aY y coordinate to add to each point after scaling - * @param aCenterX x coordinate of the center point in the original array of points. - * @param aCenterY y coordiante of the center point in the original array of points. - */ - - static void SetupPoints(PRUint32 aNumberOfPoints, nscoord* aPoints, - nsPoint* aPolygon, nscoord aScaleFactor, nscoord aX, nscoord aY, - nscoord aCenterX, nscoord aCenterY); - - /** - * Paint a fat line. The line is drawn as a polygon with a specified width. - * - * @param aRenderingContext the rendering context - * @param aSX starting x in pixels - * @param aSY starting y in pixels - * @param aEX ending x in pixels - * @param aEY ending y in pixels - * @param aHorz PR_TRUE if aWidth is added to x coordinates to form polygon. If - * PR_FALSE then aWidth as added to the y coordinates. - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintLine(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY, - PRBool aHorz, nscoord aWidth, nscoord aOnePixel); - - /** - * Draw an arrow glyph. - * - * @param aRenderingContext the rendering context - * @param aSX upper left x coordinate pixels - * @param aSY upper left y coordinate pixels - * @param aType @see nsArrowDirection enumeration - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintArrowGlyph(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nsArrowDirection aArrowDirection, - nscoord aOnePixel); - - /** - * Draw an arrow - * - * @param aArrowDirection @see nsArrowDirection enumeration - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aOnePixel number of TWIPS in a single pixel - * @param aColor color of the arrow glph - * @param aSpacing spacing for the arrow background - * @param aForFrame frame which the arrow will be rendered into. - * @param aFrameRect rectangle for the frame specified by aForFrame - */ - - static void PaintArrow(nsArrowDirection aArrowDirection, - nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - nscoord aOnePixel, - const nsStyleColor& aColor, - const nsStyleSpacing& aSpacing, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a scrollbar - * - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aRect width and height of the scrollbar - * @param aHorizontal if TRUE scrollbar is drawn horizontally, vertical if FALSE - * @param aOnePixel number TWIPS per pixel - * @param aScrollbarStyleContext style context for the scrollbar - * @param aScrollbarArrowStyleContext style context for the scrollbar arrow - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aFrameRect the rectangle for the frame passed as aForFrame - */ - - static void PaintScrollbar(nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - PRBool aHorizontal, - nscoord aOnePixel, - nsIStyleContext* aScrollbarStyleContext, - nsIStyleContext* aScrollbarArrowStyleContext, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a fixed size checkmark - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - */ - - static void PaintFixedSizeCheckMark(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips); - - /** - * Paint a fixed size checkmark border - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - */ - - static void PaintFixedSizeCheckMarkBorder(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips); - - /** - * Paint a rectangular button. Includes background, string, and focus indicator - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aWidth width the checkmark border in TWIPS - * @param aHeight height of the checkmark border in TWIPS - * @param aShift if PR_TRUE offset button as if it were pressed - * @param aShowFocus if PR_TRUE draw focus rectangle over button - * @param aStyleContext style context used for drawing button background - * @param aLabel label for button - * @param aForFrame the frame that the scrollbar will be rendered in to - */ - - static void PaintRectangularButton(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, PRUint32 aWidth, - PRUint32 aHeight, PRBool aShift, PRBool aShowFocus, - nsIStyleContext* aStyleContext, nsString& aLabel, - nsIFrame* aForFrame); - /** - * Paint a focus indicator. - * - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aInside border inside - * @param aOutside border outside - */ - - static void PaintFocus(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsRect& aInside, nsRect& aOutside); - - /** - * Paint a circular border - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aStyleContext style context specifying colors and spacing - * @param aInset if PR_TRUE draw inset, otherwise draw outset - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aWidth width of the border in TWIPS - * @param aHeight height ofthe border in TWIPS - */ - - static void PaintCircularBorder(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsIStyleContext* aStyleContext, PRBool aInset, - nsIFrame* aForFrame, PRUint32 aWidth, PRUint32 aHeight); - -#endif protected: nsFormControlHelper(); diff --git a/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp index 92831fc5071..3dbe318bee2 100644 --- a/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsCheckboxControlFrame.cpp @@ -87,8 +87,6 @@ public: // Methods used to GFX-render the checkbox // - void ForceRepaint(); - virtual void PaintCheckBox(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); @@ -165,18 +163,6 @@ nsCheckboxControlFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredLayoutSize.descent = 0; } -void -nsCheckboxControlFrame::ForceRepaint() -{ - //XXX: Hack. This hack is used to reforce a repaint - //by changing an attribute on the check box. - //We need a clean, legal way to force repaint's for - //GFX rendered controls. - PRBool state = PR_FALSE; - GetDefaultCheckState(&state); - SetDefaultCheckState(state); -} - void nsCheckboxControlFrame::PostCreateWidget(nsIPresContext* aPresContext, nscoord& aWidth, nscoord& aHeight) @@ -236,7 +222,6 @@ nsCheckboxControlFrame::MouseClicked(nsIPresContext* aPresContext) GetCurrentCheckState(&oldState); PRBool newState = oldState ? PR_FALSE : PR_TRUE; SetCurrentCheckState(newState); - ForceRepaint(); } PRInt32 @@ -372,13 +357,13 @@ NS_METHOD nsCheckboxControlFrame::HandleEvent(nsIPresContext& aPresContext, switch (aEvent->message) { case NS_MOUSE_LEFT_BUTTON_DOWN: mMouseDownOnCheckbox = PR_TRUE; - //XXX: TODO render gray rectangle on mouse down ForceRepaint(); + //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 ForceRepaint(); + //XXX: TO DO clear gray rectangle on mouse up break; } @@ -432,6 +417,8 @@ void nsCheckboxControlFrame::SetCheckboxControlFrameState(const nsString& aValue mChecked = PR_TRUE; else mChecked = PR_FALSE; + + nsFormControlHelper::ForceDrawFrame(this); } } diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 50a1f8472d0..56838951386 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -237,32 +237,6 @@ nsComboboxControlFrame::GetWindowTemp(nsIView *aView) return nsnull; } -/** - * - */ -static void ForceDrawFrame(nsIFrame * aFrame)//, PRBool) -{ - if (aFrame == nsnull) { - return; - } - nsRect rect; - nsIView * view; - nsPoint pnt; - aFrame->GetOffsetFromView(pnt, view); - aFrame->GetRect(rect); - rect.x = pnt.x; - rect.y = pnt.y; - if (view != nsnull) { - nsIViewManager * viewMgr; - view->GetViewManager(viewMgr); - if (viewMgr != nsnull) { - viewMgr->UpdateView(view, rect, 0); - NS_RELEASE(viewMgr); - } - } - -} - //-------------------------------------------------------------- void nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) @@ -270,7 +244,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) //mContent->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "SELECTED", PR_TRUE); mGotFocus = aOn; if (aRepaint) { - ForceDrawFrame(this); + nsFormControlHelper::ForceDrawFrame(this); } } @@ -296,7 +270,7 @@ void nsComboboxControlFrame::MouseClicked(nsIPresContext* aPresContext) } mListFrame->ReResolveStyleContext(aPresContext, mCurrentStyleContext); - ForceDrawFrame(mListFrame); + nsFormControlHelper::ForceDrawFrame(mListFrame); } } @@ -764,14 +738,14 @@ NS_IMETHODIMP nsComboboxControlFrame::HandleEvent(nsIPresContext& aPresContext, if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) { mArrowStyle = mBtnOutStyleContext; - ForceDrawFrame(this); + nsFormControlHelper::ForceDrawFrame(this); //MouseClicked(&aPresContext); } else if (aEvent->message == NS_MOUSE_MOVE) { } else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) { mArrowStyle = mBtnPressedStyleContext; - ForceDrawFrame(this); + nsFormControlHelper::ForceDrawFrame(this); MouseClicked(&aPresContext); } } diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.h b/mozilla/layout/html/forms/src/nsFormControlFrame.h index 9ac833ff8d1..0aec41e8f96 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.h +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.h @@ -268,201 +268,6 @@ protected: nsresult SetDefaultCheckState(PRBool aState); - - //nscoord GetStyleDim(nsIPresContext& aPresContext, nscoord aMaxDim, - // nscoord aMaxWidth, const nsStyleCoord& aCoord); - -#if 0 - -// -//------------------------------------------------------------------------------------- -// Utility methods for rendering Form Elements using GFX -//------------------------------------------------------------------------------------- -// -// XXX: The following location for the paint code is TEMPORARY. -// It is being used to get printing working -// under windows. Later it will be used to GFX-render the controls to the display. -// Expect this code to repackaged and moved to a new location in the future. - - /** - * Enumeration of possible mouse states used to detect mouse clicks - */ - enum nsArrowDirection { - eArrowDirection_Left, - eArrowDirection_Right, - eArrowDirection_Up, - eArrowDirection_Down - }; - - /** - * Scale, translate and convert an arrow of poitns from nscoord's to nsPoints's. - * - * @param aNumberOfPoints number of (x,y) pairs - * @param aPoints arrow of points to convert - * @param aScaleFactor scale factor to apply to each points translation. - * @param aX x coordinate to add to each point after scaling - * @param aY y coordinate to add to each point after scaling - * @param aCenterX x coordinate of the center point in the original array of points. - * @param aCenterY y coordiante of the center point in the original array of points. - */ - - static void SetupPoints(PRUint32 aNumberOfPoints, nscoord* aPoints, - nsPoint* aPolygon, nscoord aScaleFactor, nscoord aX, nscoord aY, - nscoord aCenterX, nscoord aCenterY); - - /** - * Paint a fat line. The line is drawn as a polygon with a specified width. - * - * @param aRenderingContext the rendering context - * @param aSX starting x in pixels - * @param aSY starting y in pixels - * @param aEX ending x in pixels - * @param aEY ending y in pixels - * @param aHorz PR_TRUE if aWidth is added to x coordinates to form polygon. If - * PR_FALSE then aWidth as added to the y coordinates. - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintLine(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY, - PRBool aHorz, nscoord aWidth, nscoord aOnePixel); - - /** - * Draw an arrow glyph. - * - * @param aRenderingContext the rendering context - * @param aSX upper left x coordinate pixels - * @param aSY upper left y coordinate pixels - * @param aType @see nsArrowDirection enumeration - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintArrowGlyph(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nsArrowDirection aArrowDirection, - nscoord aOnePixel); - - /** - * Draw an arrow - * - * @param aArrowDirection @see nsArrowDirection enumeration - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aOnePixel number of TWIPS in a single pixel - * @param aColor color of the arrow glph - * @param aSpacing spacing for the arrow background - * @param aForFrame frame which the arrow will be rendered into. - * @param aFrameRect rectangle for the frame specified by aForFrame - */ - - static void PaintArrow(nsArrowDirection aArrowDirection, - nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - nscoord aOnePixel, - nsIStyleContext* aArrowStyle, - const nsStyleSpacing& aSpacing, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a scrollbar - * - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aRect width and height of the scrollbar - * @param aHorizontal if TRUE scrollbar is drawn horizontally, vertical if FALSE - * @param aOnePixel number TWIPS per pixel - * @param aScrollbarStyleContext style context for the scrollbar - * @param aScrollbarArrowStyleContext style context for the scrollbar arrow - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aFrameRect the rectangle for the frame passed as aForFrame - */ - - static void PaintScrollbar(nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - PRBool aHorizontal, - nscoord aOnePixel, - nsIStyleContext* aScrollbarStyleContext, - nsIStyleContext* aScrollbarArrowStyleContext, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a fixed size checkmark - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - */ - - static void PaintFixedSizeCheckMark(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips); - - /** - * Paint a fixed size checkmark border - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - * @param aBackgroundColor color for background of checkbox - */ - - static void PaintFixedSizeCheckMarkBorder(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips, const nsStyleColor& aBackgroundColor); - - /** - * Paint a rectangular button. Includes background, string, and focus indicator - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aWidth width the checkmark border in TWIPS - * @param aHeight height of the checkmark border in TWIPS - * @param aShift if PR_TRUE offset button as if it were pressed - * @param aShowFocus if PR_TRUE draw focus rectangle over button - * @param aStyleContext style context used for drawing button background - * @param aLabel label for button - * @param aForFrame the frame that the scrollbar will be rendered in to - */ - - static void PaintRectangularButton(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, PRUint32 aWidth, - PRUint32 aHeight, PRBool aShift, PRBool aShowFocus, - nsIStyleContext* aStyleContext, nsString& aLabel, - nsFormControlFrame* aForFrame); - /** - * Paint a focus indicator. - * - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aInside border inside - * @param aOutside border outside - */ - - static void PaintFocus(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsRect& aInside, nsRect& aOutside); - - /** - * Paint a circular border - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aStyleContext style context specifying colors and spacing - * @param aInset if PR_TRUE draw inset, otherwise draw outset - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aWidth width of the border in TWIPS - * @param aHeight height ofthe border in TWIPS - */ - - static void PaintCircularBorder(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsIStyleContext* aStyleContext, PRBool aInset, - nsIFrame* aForFrame, PRUint32 aWidth, PRUint32 aHeight); - -#endif nsMouseState mLastMouseState; nsIWidget* mWidget; nsSize mWidgetSize; diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index 77a52c2e2ec..d4d1d5dd6ff 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -82,6 +82,28 @@ nsFormControlHelper::~nsFormControlHelper() { } +void nsFormControlHelper::ForceDrawFrame(nsIFrame * aFrame) +{ + if (aFrame == nsnull) { + return; + } + nsRect rect; + nsIView * view; + nsPoint pnt; + aFrame->GetOffsetFromView(pnt, view); + aFrame->GetRect(rect); + rect.x = pnt.x; + rect.y = pnt.y; + if (view != nsnull) { + nsIViewManager * viewMgr; + view->GetViewManager(viewMgr); + if (viewMgr != nsnull) { + viewMgr->UpdateView(view, rect, 0); + NS_RELEASE(viewMgr); + } + } +} + /*nscoord nsFormControlHelper::GetScrollbarWidth(float aPixToTwip) diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.h b/mozilla/layout/html/forms/src/nsFormControlHelper.h index 6533d51e1ba..b6378a08441 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.h +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.h @@ -104,18 +104,12 @@ public: nsIStyleContext * aStyleContext, nsFont& aFont); + static void ForceDrawFrame(nsIFrame * aFrame); + // XXX similar functionality needs to be added to widget library and these // need to change to use it. static nscoord GetScrollbarWidth(float aPixToTwip); - /*virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; - virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; - virtual nscoord GetVerticalInsidePadding(float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; - */ + static nsCompatibility GetRepChars(nsIPresContext& aPresContext, char& char1, char& char2); // @@ -151,10 +145,6 @@ public: nsresult GetDefaultCheckState(PRBool* aState); - //nscoord GetStyleDim(nsIPresContext& aPresContext, nscoord aMaxDim, - // nscoord aMaxWidth, const nsStyleCoord& aCoord); - - // //------------------------------------------------------------------------------------- // Utility methods for rendering Form Elements using GFX @@ -343,203 +333,7 @@ public: const nsRect& aDirtyRect, nsIStyleContext* aStyleContext, PRBool aInset, nsIFrame* aForFrame, PRUint32 aWidth, PRUint32 aHeight); -#if 0 - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** - //****************************************************************** -// -//------------------------------------------------------------------------------------- -// Utility methods for rendering Form Elements using GFX -//------------------------------------------------------------------------------------- -// -// XXX: The following location for the paint code is TEMPORARY. -// It is being used to get printing working -// under windows. Later it will be used to GFX-render the controls to the display. -// Expect this code to repackaged and moved to a new location in the future. - /** - * Enumeration of possible mouse states used to detect mouse clicks - */ - enum nsArrowDirection { - eArrowDirection_Left, - eArrowDirection_Right, - eArrowDirection_Up, - eArrowDirection_Down - }; - - /** - * Scale, translate and convert an arrow of poitns from nscoord's to nsPoints's. - * - * @param aNumberOfPoints number of (x,y) pairs - * @param aPoints arrow of points to convert - * @param aScaleFactor scale factor to apply to each points translation. - * @param aX x coordinate to add to each point after scaling - * @param aY y coordinate to add to each point after scaling - * @param aCenterX x coordinate of the center point in the original array of points. - * @param aCenterY y coordiante of the center point in the original array of points. - */ - - static void SetupPoints(PRUint32 aNumberOfPoints, nscoord* aPoints, - nsPoint* aPolygon, nscoord aScaleFactor, nscoord aX, nscoord aY, - nscoord aCenterX, nscoord aCenterY); - - /** - * Paint a fat line. The line is drawn as a polygon with a specified width. - * - * @param aRenderingContext the rendering context - * @param aSX starting x in pixels - * @param aSY starting y in pixels - * @param aEX ending x in pixels - * @param aEY ending y in pixels - * @param aHorz PR_TRUE if aWidth is added to x coordinates to form polygon. If - * PR_FALSE then aWidth as added to the y coordinates. - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintLine(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY, - PRBool aHorz, nscoord aWidth, nscoord aOnePixel); - - /** - * Draw an arrow glyph. - * - * @param aRenderingContext the rendering context - * @param aSX upper left x coordinate pixels - * @param aSY upper left y coordinate pixels - * @param aType @see nsArrowDirection enumeration - * @param aOnePixel number of twips in a single pixel. - */ - - static void PaintArrowGlyph(nsIRenderingContext& aRenderingContext, - nscoord aSX, nscoord aSY, nsArrowDirection aArrowDirection, - nscoord aOnePixel); - - /** - * Draw an arrow - * - * @param aArrowDirection @see nsArrowDirection enumeration - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aOnePixel number of TWIPS in a single pixel - * @param aColor color of the arrow glph - * @param aSpacing spacing for the arrow background - * @param aForFrame frame which the arrow will be rendered into. - * @param aFrameRect rectangle for the frame specified by aForFrame - */ - - static void PaintArrow(nsArrowDirection aArrowDirection, - nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - nscoord aOnePixel, - const nsStyleColor& aColor, - const nsStyleSpacing& aSpacing, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a scrollbar - * - * @param aRenderingContext the rendering context - * @param aPresContext the presentation context - * @param aDirtyRect rectangle requiring update - * @param aRect width and height of the scrollbar - * @param aHorizontal if TRUE scrollbar is drawn horizontally, vertical if FALSE - * @param aOnePixel number TWIPS per pixel - * @param aScrollbarStyleContext style context for the scrollbar - * @param aScrollbarArrowStyleContext style context for the scrollbar arrow - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aFrameRect the rectangle for the frame passed as aForFrame - */ - - static void PaintScrollbar(nsIRenderingContext& aRenderingContext, - nsIPresContext& aPresContext, - const nsRect& aDirtyRect, - nsRect& aRect, - PRBool aHorizontal, - nscoord aOnePixel, - nsIStyleContext* aScrollbarStyleContext, - nsIStyleContext* aScrollbarArrowStyleContext, - nsIFrame* aForFrame, - nsRect& aFrameRect); - /** - * Paint a fixed size checkmark - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - */ - - static void PaintFixedSizeCheckMark(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips); - - /** - * Paint a fixed size checkmark border - * - * @param aRenderingContext the rendering context - * @param aPixelsToTwips scale factor for convering pixels to twips. - */ - - static void PaintFixedSizeCheckMarkBorder(nsIRenderingContext& aRenderingContext, - float aPixelsToTwips); - - /** - * Paint a rectangular button. Includes background, string, and focus indicator - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aWidth width the checkmark border in TWIPS - * @param aHeight height of the checkmark border in TWIPS - * @param aShift if PR_TRUE offset button as if it were pressed - * @param aShowFocus if PR_TRUE draw focus rectangle over button - * @param aStyleContext style context used for drawing button background - * @param aLabel label for button - * @param aForFrame the frame that the scrollbar will be rendered in to - */ - - static void PaintRectangularButton(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, PRUint32 aWidth, - PRUint32 aHeight, PRBool aShift, PRBool aShowFocus, - nsIStyleContext* aStyleContext, nsString& aLabel, - nsIFrame* aForFrame); - /** - * Paint a focus indicator. - * - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aInside border inside - * @param aOutside border outside - */ - - static void PaintFocus(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsRect& aInside, nsRect& aOutside); - - /** - * Paint a circular border - * - * @param aPresContext the presentation context - * @param aRenderingContext the rendering context - * @param aDirtyRect rectangle requiring update - * @param aStyleContext style context specifying colors and spacing - * @param aInset if PR_TRUE draw inset, otherwise draw outset - * @param aForFrame the frame that the scrollbar will be rendered in to - * @param aWidth width of the border in TWIPS - * @param aHeight height ofthe border in TWIPS - */ - - static void PaintCircularBorder(nsIPresContext& aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, nsIStyleContext* aStyleContext, PRBool aInset, - nsIFrame* aForFrame, PRUint32 aWidth, PRUint32 aHeight); - -#endif protected: nsFormControlHelper(); diff --git a/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp b/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp index cd4765e1bc7..18ffec80c8d 100644 --- a/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsRadioControlFrame.cpp @@ -158,7 +158,7 @@ void nsRadioControlFrame::MouseClicked(nsIPresContext* aPresContext) { SetProperty(nsHTMLAtoms::checked, "1"); - + if (mFormFrame) { // The form frame will determine which radio button needs // to be turned off and will call SetChecked on the @@ -194,7 +194,8 @@ nsRadioControlFrame::SetChecked(PRBool aValue, PRBool aSetInitialValue) if (PR_TRUE == aValue) SetProperty(nsHTMLAtoms::checked, "1"); else - SetProperty(nsHTMLAtoms::checked, "0"); + SetProperty(nsHTMLAtoms::checked, "0"); + } @@ -398,6 +399,8 @@ void nsRadioControlFrame::SetRadioControlFrameState(const nsString& aValue) mChecked = PR_TRUE; else mChecked = PR_FALSE; + + nsFormControlHelper::ForceDrawFrame(this); } }