Changed the way the button calculates it's size with respect to suggested size.

I factored out the part where border and padding is added in so it can be overridden.
This commit is contained in:
rods%netscape.com 1999-08-31 13:03:38 +00:00
Родитель c3ade2023a
Коммит 596cd15f00
4 изменённых файлов: 42 добавлений и 14 удалений

Просмотреть файл

@ -158,6 +158,20 @@ nsGfxButtonControlFrame::GetFrameName(nsString& aResult) const
NS_IMETHODIMP
nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aSuggestedReflowState)
{
if (kSuggestedNotSet == mSuggestedWidth) {
aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right;
}
if (kSuggestedNotSet == mSuggestedHeight) {
aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom;
}
return NS_OK;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -169,25 +183,22 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
}
if ((kSuggestedNotSet != mSuggestedWidth) ||
(kSuggestedNotSet != mSuggestedHeight))
{
(kSuggestedNotSet != mSuggestedHeight)) {
nsHTMLReflowState suggestedReflowState(aReflowState);
// Honor the suggested width and/or height.
if (kSuggestedNotSet != mSuggestedWidth) {
suggestedReflowState.mComputedWidth = mSuggestedWidth;
suggestedReflowState.mComputedWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
if (kSuggestedNotSet != mSuggestedHeight) {
suggestedReflowState.mComputedHeight = mSuggestedHeight;
suggestedReflowState.mComputedHeight -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus);
} else {
// Normal reflow.
} else { // Normal reflow.
return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
}

Просмотреть файл

@ -53,6 +53,9 @@ public:
nsString* aValues, nsString* aNames);
virtual void MouseClicked(nsIPresContext* aPresContext);
protected:
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aSuggestedReflowState);
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }

Просмотреть файл

@ -158,6 +158,20 @@ nsGfxButtonControlFrame::GetFrameName(nsString& aResult) const
NS_IMETHODIMP
nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aSuggestedReflowState)
{
if (kSuggestedNotSet == mSuggestedWidth) {
aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right;
}
if (kSuggestedNotSet == mSuggestedHeight) {
aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom;
}
return NS_OK;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -169,25 +183,22 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
}
if ((kSuggestedNotSet != mSuggestedWidth) ||
(kSuggestedNotSet != mSuggestedHeight))
{
(kSuggestedNotSet != mSuggestedHeight)) {
nsHTMLReflowState suggestedReflowState(aReflowState);
// Honor the suggested width and/or height.
if (kSuggestedNotSet != mSuggestedWidth) {
suggestedReflowState.mComputedWidth = mSuggestedWidth;
suggestedReflowState.mComputedWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
if (kSuggestedNotSet != mSuggestedHeight) {
suggestedReflowState.mComputedHeight = mSuggestedHeight;
suggestedReflowState.mComputedHeight -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus);
} else {
// Normal reflow.
} else { // Normal reflow.
return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
}

Просмотреть файл

@ -53,6 +53,9 @@ public:
nsString* aValues, nsString* aNames);
virtual void MouseClicked(nsIPresContext* aPresContext);
protected:
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aSuggestedReflowState);
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }