Fixed toolbars so the border can be painted in 3 modes. All, partial or none.

This commit is contained in:
rods%netscape.com 1998-11-03 14:52:27 +00:00
Родитель 162d1913f1
Коммит b33ee2bfb8
3 изменённых файлов: 64 добавлений и 22 удалений

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

@ -33,6 +33,15 @@ class nsIToolbarItem;
{ 0xdeb24690, 0x35f8, 0x11d2, \
{0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} }
enum nsToolbarBorderType {
///no border
eToolbarBorderType_none,
///draws partial border
eToolbarBorderType_partial,
///draws border on all sides
eToolbarBorderType_full,
};
class nsIToolbar : public nsISupports
{
@ -129,7 +138,7 @@ public:
* Tells the toolbar to draw the border on all 4 sides, instead of just top and bottom
*
*/
NS_IMETHOD SetDrawFullBorder(PRBool aDoDrawFullBorder) = 0;
NS_IMETHOD SetBorderType(nsToolbarBorderType aBorderType) = 0;
/**
* Tells the toolbar to wrap

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

@ -96,9 +96,9 @@ nsToolbar::nsToolbar() : ChildWindow(), nsIToolbar()
mHGap = 0;
mVGap = 0;
mBorderType = eToolbarBorderType_partial;
mLastItemIsRightJustified = PR_FALSE;
mNextLastItemIsStretchy = PR_FALSE;
mDoDrawFullBorder = PR_FALSE;
mWrapItems = PR_FALSE;
mDoHorizontalLayout = PR_TRUE;
@ -277,12 +277,40 @@ NS_METHOD nsToolbar::SetHorizontalLayout(PRBool aDoHorizontalLayout)
return NS_OK;
}
//--------------------------------------------------------------------
void nsToolbar::GetMargins(PRInt32 &aX, PRInt32 &aY)
{
switch (mBorderType) {
case eToolbarBorderType_none:
aX = 0;
aY = 0;
break;
case eToolbarBorderType_partial:
aX = 0;
aY = mMargin;
break;
case eToolbarBorderType_full:
aX = mMargin;
aY = mMargin;
break;
default:
aX = 0;
aY = 0;
} // switch
}
//--------------------------------------------------------------------
void nsToolbar::DoVerticalLayout(const nsRect& aTBRect)
{
PRInt32 i;
PRInt32 x = mDoDrawFullBorder ? mMargin : 0;
PRInt32 y = mMargin;
PRInt32 x;
PRInt32 y;
GetMargins(x, y);
PRInt32 maxWidth = 0;
@ -395,8 +423,10 @@ void nsToolbar::DoVerticalLayout(const nsRect& aTBRect)
void nsToolbar::DoHorizontalLayout(const nsRect& aTBRect)
{
PRInt32 i;
PRInt32 x = mDoDrawFullBorder ? mMargin : 0;
PRInt32 y = mMargin;
PRInt32 x;
PRInt32 y;
GetMargins(x, y);
PRInt32 maxHeight = 0;
@ -619,9 +649,9 @@ NS_METHOD nsToolbar::SetMargin(PRInt32 aMargin)
}
//--------------------------------------------------------------------
NS_METHOD nsToolbar::SetDrawFullBorder(PRBool aDoDrawFullBorder)
NS_METHOD nsToolbar::SetBorderType(nsToolbarBorderType aBorderType)
{
mDoDrawFullBorder = aDoDrawFullBorder;
mBorderType = aBorderType;
return NS_OK;
}
@ -745,19 +775,21 @@ nsEventStatus nsToolbar::HandleEvent(nsGUIEvent *aEvent)
drawCtx->FillRect(r);
r.width--;
nsRect rect(r);
// draw top & left
drawCtx->SetColor(NS_RGB(255,255,255));
drawCtx->DrawLine(0,0,rect.width,0);
if (mDoDrawFullBorder) {
drawCtx->DrawLine(0,0,0,rect.height);
}
if (mBorderType != eToolbarBorderType_none) {
nsRect rect(r);
// draw top & left
drawCtx->SetColor(NS_RGB(255,255,255));
drawCtx->DrawLine(0,0,rect.width,0);
if (mBorderType == eToolbarBorderType_full) {
drawCtx->DrawLine(0,0,0,rect.height);
}
// draw bottom & right
drawCtx->SetColor(NS_RGB(128,128,128));
drawCtx->DrawLine(0,rect.height-1,rect.width,rect.height-1);
if (mDoDrawFullBorder) {
drawCtx->DrawLine(rect.width,0,rect.width,rect.height);
// draw bottom & right
drawCtx->SetColor(NS_RGB(128,128,128));
drawCtx->DrawLine(0,rect.height-1,rect.width,rect.height-1);
if (mBorderType == eToolbarBorderType_full) {
drawCtx->DrawLine(rect.width,0,rect.width,rect.height);
}
}
}

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

@ -57,7 +57,7 @@ public:
NS_IMETHOD SetToolbarManager(nsIToolbarManager * aToolbarManager);
NS_IMETHOD GetToolbarManager(nsIToolbarManager *& aToolbarManager);
NS_IMETHOD SetDrawFullBorder(PRBool aDoDrawFullBorder);
NS_IMETHOD SetBorderType(nsToolbarBorderType aBorderType);
virtual nsEventStatus HandleEvent(nsGUIEvent *aEvent);
@ -100,6 +100,7 @@ public:
PRInt32& aWidth, PRInt32& aHeight);
protected:
void GetMargins(PRInt32 &aX, PRInt32 &aY);
void DoHorizontalLayout(const nsRect& aTBRect);
void DoVerticalLayout(const nsRect& aTBRect);
void AddTab(const nsString& aUpURL,
@ -120,7 +121,7 @@ protected:
PRInt32 mHGap;
PRInt32 mVGap;
PRBool mDoDrawFullBorder;
PRBool mBorderType;
PRBool mWrapItems;
PRBool mDoHorizontalLayout;