From ebc2d06273034b82b1205dc3cc7df3ce0b06066e Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Tue, 8 Jun 1999 21:23:36 +0000 Subject: [PATCH] File Removed. git-svn-id: svn://10.0.0.236/trunk@34269 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/public/nsIImageButton.h | 240 ---- .../widget/public/nsIImageButtonListener.h | 48 - mozilla/widget/public/nsIMenuButton.h | 263 ----- .../widget/src/xpwidgets/nsImageButton.cpp | 1025 ----------------- mozilla/widget/src/xpwidgets/nsImageButton.h | 217 ---- mozilla/widget/src/xpwidgets/nsMenuButton.cpp | 495 -------- mozilla/widget/src/xpwidgets/nsMenuButton.h | 123 -- 7 files changed, 2411 deletions(-) delete mode 100644 mozilla/widget/public/nsIImageButton.h delete mode 100644 mozilla/widget/public/nsIImageButtonListener.h delete mode 100644 mozilla/widget/public/nsIMenuButton.h delete mode 100644 mozilla/widget/src/xpwidgets/nsImageButton.cpp delete mode 100644 mozilla/widget/src/xpwidgets/nsImageButton.h delete mode 100644 mozilla/widget/src/xpwidgets/nsMenuButton.cpp delete mode 100644 mozilla/widget/src/xpwidgets/nsMenuButton.h diff --git a/mozilla/widget/public/nsIImageButton.h b/mozilla/widget/public/nsIImageButton.h deleted file mode 100644 index a646e3fad84..00000000000 --- a/mozilla/widget/public/nsIImageButton.h +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- 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 nsIImageButton_h___ -#define nsIImageButton_h___ - -#include "nsISupports.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsColor.h" - -class nsIImageButtonListener; - -//f58c2550-4a7c-11d2-bee2-00805f8a8dbd -#define NS_IIMAGEBUTTON_IID \ - { 0xf58c2550, 0x4a7c, 0x11d2, \ - {0xbe, 0xe2, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } - - - typedef enum { - eButtonVerticalAligment_Top, - eButtonVerticalAligment_Center, - eButtonVerticalAligment_Bottom - } nsButtonVerticalAligment; - - typedef enum { - eButtonHorizontalAligment_Left, - eButtonHorizontalAligment_Middle, - eButtonHorizontalAligment_Right - } nsButtonHorizontalAligment; - -//--------------------------------------------------------------------------- -class nsIImageButton : public nsISupports -{ - -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEBUTTON_IID) - - /** - * Sets the label on the Image Button - * - */ - NS_IMETHOD SetLabel(const nsString& aString) = 0; - - /** - * Gets the label on the Image Button - * - */ - NS_IMETHOD GetLabel(nsString& aString) = 0; - - /** - * Gets the command for the Image Button - * - */ - NS_IMETHOD GetCommand(PRInt32 &aCommand) = 0; - - /** - * Sets the command for the Image Button - * - */ - NS_IMETHOD SetCommand(PRInt32 aCommand) = 0; - - /** - * Sets the description that is available when the mouse enters the control - * - */ - NS_IMETHOD SetRollOverDesc(const nsString& aString) = 0; - - /** - * Gets the description that is available when the mouse enters the control - * - */ - NS_IMETHOD GetRollOverDesc(nsString& aString) = 0; - - /** - * Sets the border highlight color - * - */ - NS_IMETHOD SetHighlightColor(const nscolor &aColor) = 0; - - /** - * Gets the border highlight color - * - */ - NS_IMETHOD GetHighlightColor(nscolor &aColor) = 0; - - /** - * Gets the Shadow highlight color - * - */ - NS_IMETHOD GetShadowColor(nscolor &aColor) = 0; - - /** - * Sets the Shadow highlight color - * - */ - NS_IMETHOD SetShadowColor(const nscolor &aColor) = 0; - - /** - * Sets the Dimensions of the Image in the button - * (The dimensions should come from the image) - * - */ - NS_IMETHOD SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight) = 0; - - /** - * Gets the Dimensions of the Image in the button - * - */ - NS_IMETHOD GetImageDimensions(PRInt32 & aWidth, PRInt32 & aHeight) = 0; - - /** - * Sets the URLs for the Buttons images - * - */ - NS_IMETHOD SetImageURLs(const nsString& aUpURL, - const nsString& aPressedURL, - const nsString& aDisabledURL, - const nsString& aRollOverURL) = 0; - NS_IMETHOD SetImageUpURL(const nsString& aUpURL) = 0; - NS_IMETHOD SetImagePressedURL(const nsString& aPressedURL) = 0; - NS_IMETHOD SetImageDisabledURL(const nsString& aDisabledURL) = 0; - NS_IMETHOD SetImageRollOverURL(const nsString& aRollOverURL) = 0; - - /** - * Sets the width of the border - * - */ - NS_IMETHOD SetBorderWidth(PRInt32 aWidth) = 0; - - /** - * Sets the width of the space between the border and the text or image - * - */ - NS_IMETHOD SetBorderOffset(PRInt32 aWidth) = 0; - - /** - * Sets whether the Border show be shown - * - */ - NS_IMETHOD SetShowBorder(PRBool aState) = 0; - - /** - * Sets whether the Border show be shown - * - */ - NS_IMETHOD SetShowButtonBorder(PRBool aState) = 0; - - /** - * Sets whether the text should be shown - * - */ - NS_IMETHOD SetShowText(PRBool aState) = 0; - - /** - * Sets whether the image should be shown - * - */ - NS_IMETHOD SetShowImage(PRBool aState) = 0; - - /** - * Sets the image's vertical alignment - * - */ - NS_IMETHOD SetImageVerticalAlignment(nsButtonVerticalAligment aAlign) = 0; - - /** - * Sets the image's horizontal alignment - * - */ - NS_IMETHOD SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign) = 0; - - /** - * Sets the text's vertical alignment - * - */ - NS_IMETHOD SetTextVerticalAlignment(nsButtonVerticalAligment aAlign) = 0; - - /** - * Sets the text's horizontal alignment - * - */ - NS_IMETHOD SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign) = 0; - - /** - * Show border at all times - * - */ - NS_IMETHOD SetAlwaysShowBorder(PRBool aState) = 0; - - /** - * Show border at all times - * - */ - NS_IMETHOD SwapHighlightShadowColors() = 0; - - /** - * Add Image Button Listener - * - */ - NS_IMETHOD AddListener(nsIImageButtonListener * aListener) = 0; - - /** - * Removes Image Button Listener - * - */ - NS_IMETHOD RemoveListener(nsIImageButtonListener * aListener) = 0; - - /** - * HandleGUI Events - * - */ - NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) = 0; - - /** - * Handle OnPaint - * - */ - NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) = 0; - -}; - -#endif /* nsIImageButton_h___ */ - diff --git a/mozilla/widget/public/nsIImageButtonListener.h b/mozilla/widget/public/nsIImageButtonListener.h deleted file mode 100644 index 2c31cad914f..00000000000 --- a/mozilla/widget/public/nsIImageButtonListener.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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 nsIImageButtonListener_h___ -#define nsIImageButtonListener_h___ - -#include "nsISupports.h" -#include "nsGUIEvent.h" - -class nsIImageButton; - -// {D3C3B8B2-55B5-11d2-9A2A-000000000000} -#define NS_IIMAGEBUTTONLISTENER_IID \ -{ 0xd3c3b8b2, 0x55b5, 0x11d2, \ - { 0x9a, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } - -class nsIImageButtonListener : public nsISupports -{ - -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEBUTTONLISTENER_IID) - - /** - * Notifies - * - */ - NS_IMETHOD NotifyImageButtonEvent(nsIImageButton * aImgBtn, nsGUIEvent* anEvent) = 0; - - -}; - -#endif /* nsIImageButtonListener_h___ */ - diff --git a/mozilla/widget/public/nsIMenuButton.h b/mozilla/widget/public/nsIMenuButton.h deleted file mode 100644 index 63690d14969..00000000000 --- a/mozilla/widget/public/nsIMenuButton.h +++ /dev/null @@ -1,263 +0,0 @@ -/* -*- 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 nsIMenuButton_h___ -#define nsIMenuButton_h___ - -#include "nsISupports.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsColor.h" -#include "nsIImageButton.h" - -#define NS_IMENUBUTTON_IID \ -{ 0x67b8e261, 0x53c3, 0x11d2, \ - { 0x8d, 0xc4, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } - -/* - typedef enum { - eButtonVerticalAligment_Top, - eButtonVerticalAligment_Center, - eButtonVerticalAligment_Bottom - } nsButtonVerticalAligment; - - typedef enum { - eButtonHorizontalAligment_Left, - eButtonHorizontalAligment_Middle, - eButtonHorizontalAligment_Right - } nsButtonHorizontalAligment; -*/ -//--------------------------------------------------------------------------- -class nsIMenuButton : public nsISupports -{ - -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENUBUTTON_IID) - - /** - * Sets the label on the Menu Button - * - */ - NS_IMETHOD SetLabel(const nsString& aString) = 0; - - /** - * Gets the label on the Menu Button - * - */ - NS_IMETHOD GetLabel(nsString& aString) = 0; - - /** - * Sets the description that is available when the mouse enters the control - * - */ - NS_IMETHOD SetRollOverDesc(const nsString& aString) = 0; - - /** - * Gets the description that is available when the mouse enters the control - * - */ - NS_IMETHOD GetRollOverDesc(nsString& aString) = 0; - - /** - * Gets the command for the Menu Button - * - */ - NS_IMETHOD GetCommand(PRInt32 &aCommand) = 0; - - /** - * Sets the command for the Menu Button - * - */ - NS_IMETHOD SetCommand(PRInt32 aCommand) = 0; - - /** - * Sets the border highlight color - * - */ - NS_IMETHOD SetHighlightColor(const nscolor &aColor) = 0; - - /** - * Gets the border highlight color - * - */ - NS_IMETHOD GetHighlightColor(nscolor &aColor) = 0; - - /** - * Gets the Shadow highlight color - * - */ - NS_IMETHOD GetShadowColor(nscolor &aColor) = 0; - - /** - * Sets the Shadow highlight color - * - */ - NS_IMETHOD SetShadowColor(const nscolor &aColor) = 0; - - /** - * Sets the Dimensions of the Image in the button - * (The dimensions should come from the image) - * - */ - NS_IMETHOD SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight) = 0; - - /** - * Sets the URLs for the Buttons images - * - */ - NS_IMETHOD SetImageURLs(const nsString& aUpURL, - const nsString& aPressedURL, - const nsString& aDisabledURL, - const nsString& aRollOverURL) = 0; - NS_IMETHOD SetImageUpURL(const nsString& aUpURL) = 0; - NS_IMETHOD SetImagePressedURL(const nsString& aPressedURL) = 0; - NS_IMETHOD SetImageDisabledURL(const nsString& aDisabledURL) = 0; - NS_IMETHOD SetImageRollOverURL(const nsString& aRollOverURL) = 0; - - /** - * Sets the width of the border - * - */ - NS_IMETHOD SetBorderWidth(PRInt32 aWidth) = 0; - - /** - * Sets the width of the space between the border and the text or image - * - */ - NS_IMETHOD SetBorderOffset(PRInt32 aWidth) = 0; - - /** - * Sets whether the Border show be shown - * - */ - NS_IMETHOD SetShowBorder(PRBool aState) = 0; - - /** - * Sets whether the Border show be shown - * - */ - NS_IMETHOD SetShowButtonBorder(PRBool aState) = 0; - - /** - * Sets whether the text should be shown - * - */ - NS_IMETHOD SetShowText(PRBool aState) = 0; - - /** - * Sets whether the image should be shown - * - */ - NS_IMETHOD SetShowImage(PRBool aState) = 0; - - /** - * Sets the image's vertical alignment - * - */ - NS_IMETHOD SetImageVerticalAlignment(nsButtonVerticalAligment aAlign) = 0; - - /** - * Sets the image's horizontal alignment - * - */ - NS_IMETHOD SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign) = 0; - - /** - * Sets the text's vertical alignment - * - */ - NS_IMETHOD SetTextVerticalAlignment(nsButtonVerticalAligment aAlign) = 0; - - /** - * Sets the text's horizontal alignment - * - */ - NS_IMETHOD SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign) = 0; - - /** - * Show border at all times - * - */ - NS_IMETHOD SetAlwaysShowBorder(PRBool aState) = 0; - - /** - * Show border at all times - * - */ - NS_IMETHOD SwapHighlightShadowColors() = 0; - - /** - * HandleGUI Events - * - */ - NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) = 0; - - /** - * Handle OnPaint - * - */ - NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) = 0; - - /** - * Gets the PopUp on the Image Button - * - */ - NS_IMETHOD GetPopUpMenu(nsIPopUpMenu *& aPopUpMenu) = 0; - - /** - * Appends a MenuItem to the PopUp - * - */ - NS_IMETHOD AddMenuItem(const nsString& aMenuLabel, PRInt32 aCommand) = 0; - - /** - * Inserts a MenuItem into the PopUp - * - */ - NS_IMETHOD InsertMenuItem(const nsString& aMenuLabel, PRInt32 aCommand, PRInt32 aPos) = 0; - - /** - * Removes a MenuItem from the PopUp at a specified location - * - */ - NS_IMETHOD RemovesMenuItem(PRInt32 aPos) = 0; - - /** - * Removes all the MenuItems from the PopUp - * - */ - NS_IMETHOD RemoveAllMenuItems(PRInt32 aPos) = 0; - - /** - * Add Menu Button Listener - * - */ - NS_IMETHOD AddListener(nsIImageButtonListener * aListener) = 0; - - /** - * Removes Menu Button Listener - * - */ - NS_IMETHOD RemoveListener(nsIImageButtonListener * aListener) = 0; - - -}; - -#endif /* nsIMenuButton_h___ */ - diff --git a/mozilla/widget/src/xpwidgets/nsImageButton.cpp b/mozilla/widget/src/xpwidgets/nsImageButton.cpp deleted file mode 100644 index 0ee86398b95..00000000000 --- a/mozilla/widget/src/xpwidgets/nsImageButton.cpp +++ /dev/null @@ -1,1025 +0,0 @@ -/* -*- 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 "nsImageButton.h" -#include "nsWidgetsCID.h" -#include "nspr.h" -#include "nsIButton.h" -#include "nsIFontMetrics.h" -#include "nsIDeviceContext.h" -#include "nsWidgetsCID.h" - -#include "nsIAppShell.h" -#include "nsIWidget.h" -#include "nsITextWidget.h" -#include "nsIButton.h" -#include "nsIImageGroup.h" -#include "nsITimer.h" -#include "nsIThrobber.h" - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kCImageButtonCID, NS_IMAGEBUTTON_CID); -static NS_DEFINE_IID(kCIImageButtonIID, NS_IIMAGEBUTTON_IID); -//static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID); -//static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); -static NS_DEFINE_IID(kIImageObserverIID, NS_IIMAGEREQUESTOBSERVER_IID); - -#define DEFAULT_WIDTH 50 -#define DEFAULT_HEIGHT 50 - -NS_IMPL_ADDREF(nsImageButton) -NS_IMPL_RELEASE(nsImageButton) - -//typedef enum {eAlignJustText, eAlignJustImage, eAlignBoth} eWhichAlignment; -const PRInt32 kAlignJustText = 0; -const PRInt32 kAlignJustImage = 1; -const PRInt32 kAlignBoth = 2; - - -//--------------------------------------------------------------- -static nsEventStatus PR_CALLBACK -HandleImageButtonEvent(nsGUIEvent *aEvent) -{ - nsEventStatus result = nsEventStatus_eIgnore; - nsIImageButton * button; - if (NS_OK == aEvent->widget->QueryInterface(kCIImageButtonIID,(void**)&button)) { - result = button->HandleEvent(aEvent); - NS_RELEASE(button); - } - return result; -} - - -//------------------------------------------------------------ -nsImageButton::nsImageButton() : ChildWindow(), nsIImageButton(), -#ifdef XP_MAC //temporary: we should use CSS for platform-specific rendering - mFont("geneva", - NS_FONT_STYLE_NORMAL, - NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, - 0, - 9) -#else - mFont("Sans", - NS_FONT_STYLE_NORMAL, - NS_FONT_VARIANT_NORMAL, - NS_FONT_WEIGHT_NORMAL, - 0, - 13) -#endif -{ - NS_INIT_REFCNT(); - - mUpImageRequest = nsnull; - mPressedImageRequest = nsnull; - mDisabledImageRequest = nsnull; - mRollOverImageRequest = nsnull; - - mState = eButtonState_up; - - // From Canvas - mBackgroundColor = NS_RGB(192,192,192); - mForegroundColor = NS_RGB(0,0,0); - - mHighlightColor = NS_RGB(255,255,255); - mShadowColor = NS_RGB(128,128,128); - mShowButtonBorder = PR_FALSE; - - // XXX: We should probably auto-generate unique names here - mLabel = "Default Label"; - - mImageGroup = nsnull; - mImageRequest = nsnull; - mImageWidth = 32; - mImageHeight = 32; - - mShowBorder = PR_TRUE; - - mTextVAlignment = eButtonVerticalAligment_Bottom; - mTextHAlignment = eButtonHorizontalAligment_Middle; - - mImageVAlignment = eButtonVerticalAligment_Top; - mImageHAlignment = eButtonHorizontalAligment_Middle; - - mShowImage = PR_TRUE; - mShowText = PR_TRUE; - mAlwaysShowBorder = PR_FALSE; - mBorderWidth = 1; - mBorderOffset = 2; - mTextGap = 2; - mCommand = 0; - - mLabel.SetLength(0); - mLabel.Append("Default"); - - mNumListeners = 0; -} - -//------------------------------------------------------------ -nsImageButton::~nsImageButton() -{ - // XXX will be switching to a nsDeque - PRInt32 i; - for (i=0;iGetImage(); - - if (nsnull != img) { - aRenderingContext.DrawImage(img, aRect.x, aRect.y); - } - - NS_IF_RELEASE(img); - - return nsEventStatus_eIgnore; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::PaintForeground(nsIRenderingContext& aRenderingContext, - const nsRect & aDirtyRect, - const nsRect & aEntireRect, - const nsString & aLabel, - const nsRect & aRect) -{ - if (!mShowText) { - return nsEventStatus_eConsumeNoDefault; - } - - //if (mShowText == eShowText_none) - // return nsEventStatus_eConsumeNoDefault; - - // XXX: We really need to query system-wide colors via gfx system manager here? - // On windows, the calls are: - // - // GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_GRAYTEXT), GetSysColor(COLOR_GRAYTEXT) - - // Draw text based on justifications - - if ((mState & eButtonState_rollover)) - aRenderingContext.SetColor(NS_RGB(0,0,255)); - - else if (mState & eButtonState_disabled) - aRenderingContext.SetColor(NS_RGB(255, 255, 255)); - - else - aRenderingContext.SetColor(GetForegroundColor()); - - if (mState & eButtonState_disabled) { - aRenderingContext.DrawString(aLabel, aLabel.Length(), aRect.x+1, aRect.y+1); - aRenderingContext.SetColor(NS_RGB(128, 128, 128)); - } - aRenderingContext.DrawString(aLabel, aLabel.Length(), aRect.x, aRect.y); - - - return nsEventStatus_eConsumeNoDefault; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::OnMouseMove(nsGUIEvent *aEvent) -{ - return nsEventStatus_eIgnore; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::OnMouseEnter(nsGUIEvent *aEvent) -{ - SetCursor(eCursor_standard); - - mState |= eButtonState_rollover; - - Invalidate(PR_FALSE); - return nsEventStatus_eIgnore; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::OnMouseExit(nsGUIEvent *aEvent) -{ - mState &= ~eButtonState_rollover; - mState &= ~eButtonState_pressed; - Invalidate(PR_FALSE); - return nsEventStatus_eIgnore;//(nsWindow::OnMouseExit(aEvent)); -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::OnLeftButtonDown(nsGUIEvent *aEvent) -{ - mState |= eButtonState_pressed; - Invalidate(PR_FALSE); - return nsEventStatus_eIgnore; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::OnLeftButtonUp(nsGUIEvent *aEvent) -{ - mState &= ~eButtonState_pressed; - Invalidate(PR_FALSE); - return nsEventStatus_eIgnore; -} - -//----------------------------------------------------------------------------- -nsresult nsImageButton::CreateImageGroup() -{ - nsresult res = NS_OK; - - if (mImageGroup != nsnull) - return NS_OK; - - res = NS_NewImageGroup(&mImageGroup); - - if (NS_OK == res) - { - - nsIDeviceContext * deviceCtx = GetDeviceContext(); - - mImageGroup->Init(deviceCtx, nsnull); - - NS_RELEASE(deviceCtx); - } - - return res; -} - - -//----------------------------------------------------------------------------- -nsIImageRequest * nsImageButton::RequestImage(nsString aUrl) -{ - if (aUrl.Length() == 0) { - return nsnull; - } - char * url = aUrl.ToNewCString(); - - nsIImageRequest * request ; - - nscolor bgcolor = GetBackgroundColor(); - - nsRect rect; - GetBounds(rect); - - request = mImageGroup->GetImage(url, - (nsIImageRequestObserver *)this, - &bgcolor, - mImageWidth, - mImageHeight, - 0);//nsImageLoadFlags_kSticky); - - //request->GetNaturalDimensions(&mImageWidth, &mImageHeight); - - delete[] url; - - return request; -} - -//----------------------------------------------------------------------------- -nsresult nsImageButton::PushState(nsIRenderingContext& aRenderingContext) -{ - aRenderingContext.PushState(); - - aRenderingContext.SetFont(mFont); - - return NS_OK; -} - -//----------------------------------------------------------------------------- -PRBool nsImageButton::PopState(nsIRenderingContext& aRenderingContext) -{ - PRBool clipState; - aRenderingContext.PopState(clipState); - return clipState; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::GetLabel(nsString & aString) -{ - aString = mLabel; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::SetLabel(const nsString& aString) -{ - mLabel = aString; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::GetRollOverDesc(nsString & aString) -{ - aString = mRollOverDesc; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::SetRollOverDesc(const nsString& aString) -{ - mRollOverDesc = aString; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::GetCommand(PRInt32 & aCommand) -{ - aCommand = mCommand; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::SetCommand(PRInt32 aCommand) -{ - mCommand = aCommand; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::GetHighlightColor(nscolor &aColor) -{ - aColor = mHighlightColor; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::SetHighlightColor(const nscolor &aColor) -{ - mHighlightColor = aColor; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::GetShadowColor(nscolor &aColor) -{ - aColor = mShadowColor; - return NS_OK; -} - -//----------------------------------------------------------------------------- -NS_METHOD nsImageButton::SetShadowColor(const nscolor &aColor) -{ - mShadowColor = aColor; - return NS_OK; -} - - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::PaintBorder(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - const nsRect& aEntireRect) -{ - nsRect rect(aEntireRect); - if ((mState == eButtonState_up || (mState & eButtonState_disabled)) && !mAlwaysShowBorder) { - return nsEventStatus_eConsumeNoDefault; - } - - rect.x = 0; - rect.y = 0; - rect.width--; - rect.height--; - - if (mShowButtonBorder) { - aRenderingContext.SetColor(NS_RGB(0,0,0)); - aRenderingContext.DrawRect(0,0, rect.width, rect.height); - rect.x++; - rect.y++; - rect.width -= 2; - rect.height -= 2; - } - - if (mState & eButtonState_pressed) { - aRenderingContext.SetColor(mHighlightColor); - } else { - aRenderingContext.SetColor(mShadowColor); - } - aRenderingContext.DrawLine(rect.x, rect.height, rect.width, rect.height); - aRenderingContext.DrawLine(rect.width, rect.y, rect.width, rect.height); - - if (mState & eButtonState_pressed) { - aRenderingContext.SetColor(mShadowColor); - } else { - aRenderingContext.SetColor(mHighlightColor); - } - - aRenderingContext.DrawLine(rect.x,rect.y, rect.width,rect.y); - aRenderingContext.DrawLine(rect.x,rect.y, rect.x, rect.height); - - - return nsEventStatus_eConsumeNoDefault; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsImageButton::HandleEvent(nsGUIEvent *aEvent) -{ - - if (aEvent->message == NS_PAINT || aEvent->message == NS_SIZE) - { - switch(aEvent->message) - { - case NS_PAINT: - { - - nsEventStatus es ; - nsRect rect; - nsDrawingSurface ds = nsnull; - nsIRenderingContext * ctx = ((nsPaintEvent*)aEvent)->renderingContext; - - /*nsRect widgetRect; - GetBounds(widgetRect); - widgetRect.x = 0; - widgetRect.y = 0; - ctx->SetClipRect(widgetRect, nsClipCombine_kReplace); - */ - rect.x = ((nsPaintEvent *)aEvent)->rect->x; - rect.y = ((nsPaintEvent *)aEvent)->rect->y; - rect.width = ((nsPaintEvent *)aEvent)->rect->width; - rect.height = ((nsPaintEvent *)aEvent)->rect->height; - aEvent->widget->GetBounds(rect); - rect.x = 0; - rect.y = 0; - ctx->CreateDrawingSurface(&rect, 0, ds); - if (ds == nsnull) { - return nsEventStatus_eConsumeNoDefault; - } - ctx->SelectOffScreenDrawingSurface(ds); - - es = OnPaint((*((nsPaintEvent*)aEvent)->renderingContext),(*((nsPaintEvent*)aEvent)->rect)); - - ctx->CopyOffScreenBits(ds, 0, 0, rect, NS_COPYBITS_USE_SOURCE_CLIP_REGION); - ctx->DestroyDrawingSurface(ds); - - return es; - } - break; - - /*case NS_SIZE: { - nscoord x = ((nsSizeEvent*)aEvent)->windowSize->x; - nscoord y = ((nsSizeEvent*)aEvent)->windowSize->y; - nscoord w = ((nsSizeEvent*)aEvent)->windowSize->width; - nscoord h = ((nsSizeEvent*)aEvent)->windowSize->height; - - OnResize(x,y,w,h); - } - break;*/ - - } - //PRInt32 i = 0; - //for (i=0;iNotifyImageButtonEvent(aEvent); - //} - return nsEventStatus_eIgnore; - } - - if (aEvent->message == NS_DESTROY) - return nsEventStatus_eIgnore; - - /* - * XXX: Make this a HandleInputEvent... - */ - - switch(aEvent->message) { - - case NS_MOUSE_LEFT_BUTTON_DOWN: - OnLeftButtonDown(aEvent); - break; - - case NS_MOUSE_LEFT_BUTTON_UP: - OnLeftButtonUp(aEvent); - break; - - case NS_MOUSE_RIGHT_BUTTON_DOWN: - OnLeftButtonDown(aEvent); - break; - - case NS_MOUSE_RIGHT_BUTTON_UP: - OnLeftButtonUp(aEvent); - break; - - case NS_MOUSE_MOVE: - OnMouseMove(aEvent); - break; - - case NS_MOUSE_ENTER: - OnMouseEnter(aEvent); - break; - - case NS_MOUSE_EXIT: - OnMouseExit(aEvent); - break; - - case NS_KEY_UP: - //OnKeyUp(aEvent); - break; - - case NS_KEY_DOWN: - //OnKeyDown(aEvent); - break; - - } // switch - - - PRInt32 i = 0; - for (i=0;iNotifyImageButtonEvent(this, aEvent); - } - return nsEventStatus_eIgnore; - -} - -//---------------------------------------------------------------- -void nsImageButton::Notify(nsIImageRequest *aImageRequest, - nsIImage *aImage, - nsImageNotification aNotificationType, - PRInt32 aParam1, PRInt32 aParam2, - void *aParam3) -{ - if (aNotificationType == nsImageNotification_kImageComplete) { - PRUint32 w,h; - aImageRequest->GetNaturalDimensions(&w, &h); - if (w > 0 && h > 0) { - aImageRequest->GetNaturalDimensions(&mImageWidth, &mImageHeight); - } - - Invalidate(PR_FALSE); - } - return ; -} - -//---------------------------------------------------------------- -void nsImageButton::NotifyError(nsIImageRequest *aImageRequest, - nsImageError aErrorType) -{ - return ; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight) -{ - mImageWidth = aWidth; - mImageHeight = aHeight; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::GetImageDimensions(PRInt32 & aWidth, PRInt32 & aHeight) -{ - aWidth = mImageWidth ; - aHeight = mImageHeight ; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageURLs(const nsString& aUpURL, - const nsString& aPressedURL, - const nsString& aDisabledURL, - const nsString& aRollOverURL) -{ - CreateImageGroup(); - - mUpImageRequest = RequestImage(aUpURL); - mPressedImageRequest = RequestImage(aPressedURL); - mDisabledImageRequest = RequestImage(aDisabledURL); - mRollOverImageRequest = RequestImage(aRollOverURL); - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageUpURL(const nsString& aUpURL) -{ - CreateImageGroup(); - mUpImageRequest = RequestImage(aUpURL); - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImagePressedURL(const nsString& aPressedURL) -{ - CreateImageGroup(); - mPressedImageRequest = RequestImage(aPressedURL); - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageDisabledURL(const nsString& aDisabledURL) -{ - CreateImageGroup(); - mDisabledImageRequest = RequestImage(aDisabledURL); - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageRollOverURL(const nsString& aRollOverURL) -{ - CreateImageGroup(); - mRollOverImageRequest = RequestImage(aRollOverURL); - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetShowBorder(PRBool aState) -{ - mShowBorder = aState; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetAlwaysShowBorder(PRBool aState) -{ - mAlwaysShowBorder = aState; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SwapHighlightShadowColors() -{ - nscolor highColor; - nscolor shadeColor; - - GetHighlightColor(highColor); - GetShadowColor(shadeColor); - - SetHighlightColor(shadeColor); - SetShadowColor(highColor); - - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetShowButtonBorder(PRBool aState) -{ - mShowButtonBorder = aState; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetBorderWidth(PRInt32 aWidth) -{ - mBorderWidth = aWidth; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetBorderOffset(PRInt32 aOffset) -{ - mBorderOffset = aOffset; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetShowText(PRBool aState) -{ - mShowText = aState; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetShowImage(PRBool aState) -{ - mShowImage = aState; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageVerticalAlignment(nsButtonVerticalAligment aAlign) -{ - mImageVAlignment = aAlign; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign) -{ - mImageHAlignment = aAlign; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetTextVerticalAlignment(nsButtonVerticalAligment aAlign) -{ - mTextVAlignment = aAlign; - return NS_OK; -} - -//---------------------------------------------------------------- -NS_METHOD nsImageButton::SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign) -{ - mTextHAlignment = aAlign; - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsImageButton::AddListener(nsIImageButtonListener * aListener) -{ - // XXX will be switching to a nsDeque - mListeners[mNumListeners++] = aListener; - NS_ADDREF(aListener); - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsImageButton::RemoveListener(nsIImageButtonListener * aListener) -{ - // XXX will be switching to a nsDeque - PRInt32 i; - for (i=0;iCreateRenderingContext(this, cx)) { - return; - } - nsIFontMetrics* metrics; - if (NS_OK != mContext->GetMetricsFor(mFont, metrics)) { - NS_RELEASE(cx); - return; - } - cx->SetFont(metrics); - metrics->GetHeight(string_height); - cx->GetWidth(aText, string_width); - NS_RELEASE(metrics); - NS_RELEASE(cx); - - aTxtRect.SetRect(offset,offset, string_width, string_height); // Align left - if (!mShowImage || anImage == nsnull) { - aWhichAlignment = kAlignJustText; - // Align horizontally - if (mTextHAlignment == eButtonHorizontalAligment_Right) { - aTxtRect.x = aRect.width - aTxtRect.width - offset; - } if (mTextHAlignment == eButtonHorizontalAligment_Middle) { - aTxtRect.x = (aRect.width - aTxtRect.width) / 2; - } - // Align vertically - if (mTextVAlignment == eButtonVerticalAligment_Bottom) { - aTxtRect.y = aRect.height - aTxtRect.height - offset; - } if (mTextVAlignment == eButtonVerticalAligment_Center) { - aTxtRect.y = (aRect.height - aTxtRect.height) / 2; - } - aMaxWidth = string_width; - aMaxHeight = string_height; - } - } - - // Set up initial image size - if (mShowImage && anImage != nsnull) { - aImgRect.SetRect(offset, offset, mImageWidth, mImageHeight); // Align left - if (!mShowText || aText.Length() == 0) { - aWhichAlignment = kAlignJustImage; - // Align horizontally - if (mImageHAlignment == eButtonHorizontalAligment_Right) { - aImgRect.x = aRect.width - aImgRect.width - offset; - } if (mImageHAlignment == eButtonHorizontalAligment_Middle) { - aImgRect.x = (aRect.width - aImgRect.width) / 2; - } - - // Align vertically - if (mImageVAlignment == eButtonVerticalAligment_Bottom) { - aImgRect.y = aRect.height - aImgRect.height - offset; - } if (mImageVAlignment == eButtonVerticalAligment_Center) { - aImgRect.y = (aRect.height - aImgRect.height) / 2; - } - aMaxWidth = mImageWidth; - aMaxHeight = mImageHeight; - } - } - - aWhichAlignment = kAlignBoth; - - // Now align and layout both text and image - // Text align is relative to the image, so it forces the image to an alignment - if (mTextHAlignment == eButtonHorizontalAligment_Right) { - aImgRect.x = offset; - aTxtRect.x = aImgRect.x + aImgRect.width + mTextGap; - aMaxWidth = aTxtRect.x + aTxtRect.width - offset; - } else if (mTextHAlignment == eButtonHorizontalAligment_Middle) { - aImgRect.x = (aRect.width - aImgRect.width) / 2; - aTxtRect.x = (aRect.width - aTxtRect.width) / 2; - aMaxWidth = (aTxtRect.width > aImgRect.width? aTxtRect.width : aImgRect.width); - } else { // Text is on the Left - aTxtRect.x = offset; - aImgRect.x = aTxtRect.x + aTxtRect.width + mTextGap; - aMaxWidth = aImgRect.x + aImgRect.width - offset; - } - - // vertical - if (mTextVAlignment == eButtonVerticalAligment_Bottom) { - aImgRect.y = offset; - aTxtRect.y = aImgRect.y + aImgRect.height;// + mTextGap; - aMaxHeight = aTxtRect.y + aTxtRect.height; - } else if (mTextVAlignment == eButtonVerticalAligment_Center) { - aImgRect.y = (aRect.height - aImgRect.height) / 2; - aTxtRect.y = (aRect.height - aTxtRect.height) / 2; - aMaxHeight = (aTxtRect.height > aImgRect.height? aTxtRect.height : aImgRect.height); - } else { // Text is on the Left - aTxtRect.y = offset; - aImgRect.y = aTxtRect.y + aTxtRect.height;// + mTextGap; - aMaxHeight = aImgRect.y + aImgRect.height - offset; - } - -} - diff --git a/mozilla/widget/src/xpwidgets/nsImageButton.h b/mozilla/widget/src/xpwidgets/nsImageButton.h deleted file mode 100644 index 45275cd0804..00000000000 --- a/mozilla/widget/src/xpwidgets/nsImageButton.h +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- 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 nsImageButton_h___ -#define nsImageButton_h___ - -#include "nsIImageButton.h" -#include "nsIImageRequest.h" -#include "nsIImageGroup.h" -#include "nsIRenderingContext.h" -#include "nsWindow.h" -#include "nsColor.h" -#include "nsFont.h" -#include "nsIImageObserver.h" -#include "nsIImageButtonListener.h" - -#define eButtonState_up 1 -#define eButtonState_rollover 2 -#define eButtonState_pressed 4 -#define eButtonState_disabled 8 - -//-------------------------------------------------------------- -class nsImageButton : public ChildWindow, - public nsIImageButton, - public nsIImageRequestObserver - - -{ -public: - nsImageButton(); - virtual ~nsImageButton(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - NS_IMETHOD SetBounds(const nsRect& aBounds); - - NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect); - - NS_IMETHOD_(nsEventStatus) PaintBackground(nsIRenderingContext& aRenderingContext, - const nsRect & aDirtyRect, - const nsRect & aEntireRect, - nsIImageRequest * anImage, - const nsRect & aRect); - - NS_IMETHOD_(nsEventStatus) PaintForeground(nsIRenderingContext& aRenderingContext, - const nsRect & aDirtyRect, - const nsRect & aEntireRect, - const nsString & aLabel, - const nsRect & aRect); - - NS_IMETHOD_(nsEventStatus) PaintBorder(nsIRenderingContext& aRenderingContext, - const nsRect & aDirtyRect, - const nsRect & aEntireRect); - - - NS_IMETHOD_(nsEventStatus) OnMouseEnter(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnMouseExit(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnMouseMove(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnLeftButtonUp(nsGUIEvent *aEvent); - - NS_IMETHOD CreateImageGroup(); - NS_IMETHOD_(nsIImageRequest *) RequestImage(nsString aUrl); - - /** - * Save canvas graphical state - * @param aRenderingContext, rendering context to save state to - * @result nsresult, NS_OK if successful - */ - NS_IMETHOD PushState(nsIRenderingContext& aRenderingContext); - - /** - * Get and and set RenderingContext to this graphical state - * @param aRenderingContext, rendering context to get previously saved state from - * @return if PR_TRUE, indicates that the clipping region after - * popping state is empty, else PR_FALSE - */ - NS_IMETHOD_(PRBool) PopState(nsIRenderingContext& aRenderingContext); - - NS_IMETHOD GetLabel(nsString&); - NS_IMETHOD SetLabel(const nsString& aString); - NS_IMETHOD GetRollOverDesc(nsString& aString); - NS_IMETHOD SetRollOverDesc(const nsString& aString); - - NS_IMETHOD GetCommand(PRInt32 & aCommand); - NS_IMETHOD SetCommand(PRInt32 aCommand); - - NS_IMETHOD GetHighlightColor(nscolor &aColor); - NS_IMETHOD SetHighlightColor(const nscolor &aColor); - - NS_IMETHOD GetShadowColor(nscolor &aColor); - NS_IMETHOD SetShadowColor(const nscolor &aColor); - - NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent); - - NS_IMETHOD SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight); - NS_IMETHOD GetImageDimensions(PRInt32 & aWidth, PRInt32 & aHeight); - NS_IMETHOD SetImageURLs(const nsString& aUpURL, - const nsString& aPressedURL, - const nsString& aDisabledURL, - const nsString& aRollOverURL); - NS_IMETHOD SetImageUpURL(const nsString& aUpURL); - NS_IMETHOD SetImagePressedURL(const nsString& aPressedURL); - NS_IMETHOD SetImageDisabledURL(const nsString& aDisabledURL); - NS_IMETHOD SetImageRollOverURL(const nsString& aRollOverURL); - - NS_IMETHOD SetShowBorder(PRBool aState); - NS_IMETHOD SetShowButtonBorder(PRBool aState); - NS_IMETHOD SetBorderWidth(PRInt32 aWidth); - NS_IMETHOD SetBorderOffset(PRInt32 aWidth); - NS_IMETHOD SetShowText(PRBool aState); - NS_IMETHOD SetShowImage(PRBool aState); - NS_IMETHOD SetAlwaysShowBorder(PRBool aState); - NS_IMETHOD SwapHighlightShadowColors(); - - // Alignment Methods - NS_IMETHOD SetImageVerticalAlignment(nsButtonVerticalAligment aAlign); - NS_IMETHOD SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign); - NS_IMETHOD SetTextVerticalAlignment(nsButtonVerticalAligment aAlign); - NS_IMETHOD SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign); - - NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight); - NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight); - - NS_IMETHOD AddListener(nsIImageButtonListener * aListener); - NS_IMETHOD RemoveListener(nsIImageButtonListener * aListener); - - // nsIImageRequestObserver - virtual void Notify(nsIImageRequest *aImageRequest, - nsIImage *aImage, - nsImageNotification aNotificationType, - PRInt32 aParam1, PRInt32 aParam2, - void *aParam3); - - virtual void NotifyError(nsIImageRequest *aImageRequest, - nsImageError aErrorType); - // nsWindow - NS_IMETHOD Enable(PRBool aState); - -protected: - nsIImageRequest * GetImageForPainting(); - - void PerformAlignment(const nsRect & aRect, - const nsIImageRequest * anImage, nsRect & aImgRect, - const nsString & aText, nsRect & aTxtRect, - PRInt32 &aWhichAlignment, PRInt32 &aMaxWidth, PRInt32 &aMaxHeight); - - nsIImageRequest* mUpImageRequest; - nsIImageRequest* mPressedImageRequest; - nsIImageRequest* mDisabledImageRequest; - nsIImageRequest* mRollOverImageRequest; - - PRUint32 mState; - - nsIImageRequest* mImageRequest; - nsIImageGroup* mImageGroup; - nsIRenderingContext *mRenderingContext; - - nsButtonVerticalAligment mTextVAlignment; - nsButtonHorizontalAligment mTextHAlignment; - - nsButtonVerticalAligment mImageVAlignment; - nsButtonHorizontalAligment mImageHAlignment; - - PRBool mShowImage; - PRBool mShowText; - - nscolor mBackgroundColor; - nscolor mForegroundColor; - nscolor mHighlightColor; - nscolor mShadowColor; - nsFont mFont; - nsString mLabel; - nsString mRollOverDesc; - PRInt32 mCommand; - - PRInt32 mTextGap; - PRUint32 mImageWidth; - PRUint32 mImageHeight; - PRBool mShowBorder; // If true border show on mouse over - PRBool mShowButtonBorder; // controls just the black rect around the button - PRBool mAlwaysShowBorder; // controls whether up/dwn border is always drawn - PRInt32 mBorderWidth; - PRInt32 mBorderOffset; - - // Temporary - // XXX will be switching to a nsDeque - nsIImageButtonListener * mListeners[32]; - PRInt32 mNumListeners; - -}; - -#endif /* nsImageButton_h___ */ diff --git a/mozilla/widget/src/xpwidgets/nsMenuButton.cpp b/mozilla/widget/src/xpwidgets/nsMenuButton.cpp deleted file mode 100644 index d7921d2cede..00000000000 --- a/mozilla/widget/src/xpwidgets/nsMenuButton.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/* -*- 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 "nsMenuButton.h" -#include "nsWidgetsCID.h" -#include "nspr.h" -#include "nsIFontMetrics.h" -#include "nsIDeviceContext.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" -#include "nsIWidget.h" - -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); -static NS_DEFINE_IID(kCMenuButtonCID, NS_MENUBUTTON_CID); -static NS_DEFINE_IID(kCIMenuButtonIID, NS_IMENUBUTTON_IID); -static NS_DEFINE_IID(kIPopUpMenuIID, NS_IPOPUPMENU_IID); -static NS_DEFINE_IID(kPopUpMenuCID, NS_POPUPMENU_CID); -static NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID); -static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID); - -NS_IMPL_ADDREF(nsMenuButton) -NS_IMPL_RELEASE(nsMenuButton) - - -//------------------------------------------------------------ -nsMenuButton::nsMenuButton() : nsIMenuButton(), nsImageButton() -{ - NS_INIT_REFCNT(); - - mPopUpMenu = nsnull; - mMenuIsPoppedUp = PR_FALSE; -} - -//------------------------------------------------------------ -nsMenuButton::~nsMenuButton() -{ - NS_IF_RELEASE(mPopUpMenu); -} - -//------------------------------------------------------------ -nsresult nsMenuButton::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - static NS_DEFINE_IID(kClassIID, kCMenuButtonCID); - - if (aIID.Equals(kCIMenuButtonIID)) { - *aInstancePtr = (void*) (nsIMenuButton *)this; - AddRef(); - return NS_OK; - } - if (aIID.Equals(kClassIID)) { - *aInstancePtr = (void*) (nsMenuButton *)this; - AddRef(); - return NS_OK; - } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*) (this); - AddRef(); - return NS_OK; - } - return (nsImageButton::QueryInterface(aIID, aInstancePtr)); -} - -//------------------------------------------------------------ -void nsMenuButton::CreatePopUpMenu() -{ - if (nsnull != mPopUpMenu) { - return; - } - - // Create and place back button - nsresult rv = nsComponentManager::CreateInstance(kPopUpMenuCID, nsnull, kIPopUpMenuIID, - (void**)&mPopUpMenu); - if (NS_OK == rv) { - nsIWidget * menuParentWidget; - if (NS_OK != this->QueryInterface(kIWidgetIID,(void**)&menuParentWidget)) { - return; - } - - nsIWidget * popupWidget; - nsRect rect; - if (NS_OK == mPopUpMenu->QueryInterface(kIWidgetIID,(void**)&popupWidget)) { - popupWidget->Create(menuParentWidget, rect, nsnull, nsnull); - NS_RELEASE(popupWidget); - } - NS_RELEASE(menuParentWidget); - } - - - return; -} - -//------------------------------------------------------------ -NS_METHOD nsMenuButton::GetPopUpMenu(nsIPopUpMenu *& aPopUpMenu) -{ - CreatePopUpMenu(); - - NS_ADDREF(mPopUpMenu); - aPopUpMenu = mPopUpMenu; - return NS_OK; -} - -//------------------------------------------------------------ -NS_METHOD nsMenuButton::AddMenuItem(const nsString& aMenuLabel, PRInt32 aCommand) -{ - CreatePopUpMenu(); - - nsIMenuItem * menuItem = nsnull; - nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, kIMenuItemIID, (void**)&menuItem); - menuItem->Create(mPopUpMenu, aMenuLabel, aCommand); - if (NS_OK == rv) { - mPopUpMenu->AddItem(menuItem); - NS_RELEASE(menuItem); - } - return NS_OK; -} - -//------------------------------------------------------------ -NS_METHOD nsMenuButton::InsertMenuItem(const nsString& aMenuLabel, PRInt32 aCommand, PRInt32 aPos) -{ - CreatePopUpMenu(); - return NS_OK; -} - -//------------------------------------------------------------ -NS_METHOD nsMenuButton::RemovesMenuItem(PRInt32 aPos) -{ - CreatePopUpMenu(); - return NS_OK; -} - -//------------------------------------------------------------ -NS_METHOD nsMenuButton::RemoveAllMenuItems(PRInt32 aPos) -{ - CreatePopUpMenu(); - return NS_OK; -} - - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::OnLeftButtonDown(nsGUIEvent *aEvent) -{ - mState |= eButtonState_pressed; - Invalidate(PR_TRUE); - - nsRect rect; - GetBounds(rect); - - if (mPopUpMenu) { - mMenuIsPoppedUp = PR_TRUE; - mPopUpMenu->ShowMenu(0, rect.height); - mMenuIsPoppedUp = PR_FALSE; - } - return nsEventStatus_eIgnore; -} - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::PaintBorder(nsIRenderingContext & aRenderingContext, - const nsRect & aDirtyRect, - const nsRect & aEntireRect) -{ - nsRect rect(aEntireRect); - if ((mState == eButtonState_up || (mState & eButtonState_disabled)) && !mAlwaysShowBorder && !mMenuIsPoppedUp) { - return nsEventStatus_eConsumeNoDefault; - } - - rect.x = 0; - rect.y = 0; - rect.width--; - rect.height--; - - if (mShowButtonBorder) { - aRenderingContext.SetColor(NS_RGB(0,0,0)); - aRenderingContext.DrawRect(0,0, rect.width, rect.height); - rect.x++; - rect.y++; - rect.width -= 2; - rect.height -= 2; - } - - if ((mState & eButtonState_pressed) || mMenuIsPoppedUp) { - aRenderingContext.SetColor(mHighlightColor); - } else { - aRenderingContext.SetColor(mShadowColor); - } - aRenderingContext.DrawLine(rect.x, rect.height, rect.width, rect.height); - aRenderingContext.DrawLine(rect.width, rect.y, rect.width, rect.height); - - if ((mState & eButtonState_pressed) || mMenuIsPoppedUp) { - aRenderingContext.SetColor(mShadowColor); - } else { - aRenderingContext.SetColor(mHighlightColor); - } - - aRenderingContext.DrawLine(rect.x,rect.y, rect.width,rect.y); - aRenderingContext.DrawLine(rect.x,rect.y, rect.x, rect.height); - - - return nsEventStatus_eConsumeNoDefault; -} - - - -//------------------------------------------------------------ -nsresult nsMenuButton::SetBounds(const nsRect &aBounds) -{ - return nsImageButton::SetBounds(aBounds); -} - -//------------------------------------------------------------ -nsEventStatus nsMenuButton::OnPaint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - // draw the button, as normal - nsEventStatus rv = nsImageButton::OnPaint(aRenderingContext, aDirtyRect); - - // draw the triangle in the top right corner to indicate this is a dropdown, - // but only if the dirty rect contains that area - if ( aDirtyRect.YMost() > mBounds.YMost() - 11 ) { - aRenderingContext.PushState(); - nscolor triangleColor = 0; - if ( mState & eButtonState_disabled ) - triangleColor = nscolor(NS_RGB(0xaa,0xaa,0xaa)); //*** this should go to l&f object - aRenderingContext.SetColor(triangleColor); - - // it would be great if I could just use a polygon here, but this - // way guarantees it will be a nice triangle shape on all gfx platforms - int lineWidth = 10; - int hStart = mBounds.width - 14; - for (int i = 5; lineWidth >= 0; ++i, lineWidth -= 2, hStart += 1) - { - int hEnd = hStart + lineWidth; - aRenderingContext.DrawLine(hStart, i, hEnd, i); - } - - PRBool ignored; - aRenderingContext.PopState(ignored); - } - return rv; -} - - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::OnMouseMove(nsGUIEvent *aEvent) -{ - return nsImageButton::OnMouseMove(aEvent); -} - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::OnMouseEnter(nsGUIEvent *aEvent) -{ - return nsImageButton::OnMouseEnter(aEvent); -} - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::OnMouseExit(nsGUIEvent *aEvent) -{ - return nsImageButton::OnMouseExit(aEvent); -} - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::OnLeftButtonUp(nsGUIEvent *aEvent) -{ - return nsImageButton::OnLeftButtonUp(aEvent); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::GetLabel(nsString & aString) -{ - return nsImageButton::GetLabel(aString); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::SetLabel(const nsString& aString) -{ - return nsImageButton::SetLabel(aString); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::GetRollOverDesc(nsString & aString) -{ - return nsImageButton::GetRollOverDesc(aString); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::SetRollOverDesc(const nsString& aString) -{ - return nsImageButton::SetRollOverDesc(aString); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::GetCommand(PRInt32 & aCommand) -{ - return nsImageButton::GetCommand(aCommand); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::SetCommand(PRInt32 aCommand) -{ - return nsImageButton::SetCommand(aCommand); -} - - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::GetHighlightColor(nscolor &aColor) -{ - return nsImageButton::GetHighlightColor(aColor); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::SetHighlightColor(const nscolor &aColor) -{ - return nsImageButton::SetHighlightColor(aColor); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::GetShadowColor(nscolor &aColor) -{ - return nsImageButton::GetShadowColor(aColor); -} - -//----------------------------------------------------------------------------- -NS_METHOD nsMenuButton::SetShadowColor(const nscolor &aColor) -{ - return nsImageButton::SetShadowColor(aColor); -} - -//----------------------------------------------------------------------------- -nsEventStatus nsMenuButton::HandleEvent(nsGUIEvent *aEvent) -{ - return nsImageButton::HandleEvent(aEvent); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight) -{ - return nsImageButton::SetImageDimensions(aWidth, aHeight); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageURLs(const nsString& aUpURL, - const nsString& aPressedURL, - const nsString& aDisabledURL, - const nsString& aRollOverURL) -{ - return nsImageButton::SetImageURLs(aUpURL, aPressedURL, aDisabledURL, aRollOverURL); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageUpURL(const nsString& aUpURL) -{ - return nsImageButton::SetImageUpURL(aUpURL); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImagePressedURL(const nsString& aPressedURL) -{ - return nsImageButton::SetImagePressedURL(aPressedURL); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageDisabledURL(const nsString& aDisabledURL) -{ - return nsImageButton::SetImageDisabledURL(aDisabledURL); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageRollOverURL(const nsString& aRollOverURL) -{ - return nsImageButton::SetImageRollOverURL(aRollOverURL); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetShowBorder(PRBool aState) -{ - return nsImageButton::SetShowBorder(aState); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetAlwaysShowBorder(PRBool aState) -{ - return nsImageButton::SetAlwaysShowBorder(aState); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SwapHighlightShadowColors() -{ - return nsImageButton::SwapHighlightShadowColors(); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetShowButtonBorder(PRBool aState) -{ - return nsImageButton::SetShowButtonBorder(aState); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetBorderWidth(PRInt32 aWidth) -{ - return nsImageButton::SetBorderWidth(aWidth); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetBorderOffset(PRInt32 aOffset) -{ - return nsImageButton::SetBorderOffset(aOffset); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetShowText(PRBool aState) -{ - return nsImageButton::SetShowText(aState); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetShowImage(PRBool aState) -{ - return nsImageButton::SetShowImage(aState); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageVerticalAlignment(nsButtonVerticalAligment aAlign) -{ - return nsImageButton::SetImageVerticalAlignment(aAlign); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign) -{ - return nsImageButton::SetImageHorizontalAlignment(aAlign); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetTextVerticalAlignment(nsButtonVerticalAligment aAlign) -{ - return nsImageButton::SetTextVerticalAlignment(aAlign); -} - -//---------------------------------------------------------------- -NS_METHOD nsMenuButton::SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign) -{ - return nsImageButton::SetTextHorizontalAlignment(aAlign); -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuButton::AddListener(nsIImageButtonListener * aListener) -{ - return nsImageButton::AddListener(aListener); -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuButton::RemoveListener(nsIImageButtonListener * aListener) -{ - return nsImageButton::RemoveListener(aListener); -} - - -//------------------------------------------------------------------------- -NS_METHOD nsMenuButton::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) -{ - return nsImageButton::GetPreferredSize(aWidth, aHeight); -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuButton::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) -{ - return nsImageButton::SetPreferredSize(aWidth, aHeight); -} - -//------------------------------------------------------------------------- -NS_METHOD nsMenuButton::Enable(PRBool aState) -{ - return nsImageButton::Enable(aState); -} - - diff --git a/mozilla/widget/src/xpwidgets/nsMenuButton.h b/mozilla/widget/src/xpwidgets/nsMenuButton.h deleted file mode 100644 index 8f17ff0a7f7..00000000000 --- a/mozilla/widget/src/xpwidgets/nsMenuButton.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- 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 nsMenuButton_h___ -#define nsMenuButton_h___ - -#include "nsIPopUpMenu.h" -#include "nsIMenuButton.h" - -#include "nsImageButton.h" - -#include "nsIRenderingContext.h" -#include "nsColor.h" -#include "nsFont.h" -#include "nsGUIEvent.h" -#include "nsIImageButtonListener.h" - - -//-------------------------------------------------------------- -class nsMenuButton : public nsIMenuButton, - public nsImageButton -{ -public: - nsMenuButton(); - virtual ~nsMenuButton(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD GetPopUpMenu(nsIPopUpMenu *& aPopUpMenu); - NS_IMETHOD AddMenuItem(const nsString& aMenuLabel, PRInt32 aCommand); - NS_IMETHOD InsertMenuItem(const nsString& aMenuLabel, PRInt32 aCommand, PRInt32 aPos); - NS_IMETHOD RemovesMenuItem(PRInt32 aPos); - NS_IMETHOD RemoveAllMenuItems(PRInt32 aPos); - - NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) PaintBorder(nsIRenderingContext& aRenderingContext, - const nsRect & aDirtyRect, - const nsRect & aEntireRect); - - NS_IMETHOD SetBounds(const nsRect& aBounds); - - NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect); - - NS_IMETHOD_(nsEventStatus) OnMouseEnter(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnMouseExit(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnMouseMove(nsGUIEvent *aEvent); - NS_IMETHOD_(nsEventStatus) OnLeftButtonUp(nsGUIEvent *aEvent); - - NS_IMETHOD GetLabel(nsString&); - NS_IMETHOD SetLabel(const nsString& aString); - NS_IMETHOD GetRollOverDesc(nsString& aString); - NS_IMETHOD SetRollOverDesc(const nsString& aString); - NS_IMETHOD GetCommand(PRInt32 & aCommand); - NS_IMETHOD SetCommand(PRInt32 aCommand); - - NS_IMETHOD GetHighlightColor(nscolor &aColor); - NS_IMETHOD SetHighlightColor(const nscolor &aColor); - - NS_IMETHOD GetShadowColor(nscolor &aColor); - NS_IMETHOD SetShadowColor(const nscolor &aColor); - - NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent); - - NS_IMETHOD SetImageDimensions(const PRInt32 & aWidth, const PRInt32 & aHeight); - NS_IMETHOD SetImageURLs(const nsString& aUpURL, - const nsString& aPressedURL, - const nsString& aDisabledURL, - const nsString& aRollOverURL); - NS_IMETHOD SetImageUpURL(const nsString& aUpURL); - NS_IMETHOD SetImagePressedURL(const nsString& aPressedURL); - NS_IMETHOD SetImageDisabledURL(const nsString& aDisabledURL); - NS_IMETHOD SetImageRollOverURL(const nsString& aRollOverURL); - - NS_IMETHOD SetShowBorder(PRBool aState); - NS_IMETHOD SetShowButtonBorder(PRBool aState); - NS_IMETHOD SetBorderWidth(PRInt32 aWidth); - NS_IMETHOD SetBorderOffset(PRInt32 aWidth); - NS_IMETHOD SetShowText(PRBool aState); - NS_IMETHOD SetShowImage(PRBool aState); - NS_IMETHOD SetAlwaysShowBorder(PRBool aState); - NS_IMETHOD SwapHighlightShadowColors(); - - // Alignment Methods - NS_IMETHOD SetImageVerticalAlignment(nsButtonVerticalAligment aAlign); - NS_IMETHOD SetImageHorizontalAlignment(nsButtonHorizontalAligment aAlign); - NS_IMETHOD SetTextVerticalAlignment(nsButtonVerticalAligment aAlign); - NS_IMETHOD SetTextHorizontalAlignment(nsButtonHorizontalAligment aAlign); - - NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight); - NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight); - - NS_IMETHOD AddListener(nsIImageButtonListener * aListener); - NS_IMETHOD RemoveListener(nsIImageButtonListener * aListener); - - - // nsWindow - NS_IMETHOD Enable(PRBool aState); - -protected: - void CreatePopUpMenu(); - - nsIPopUpMenu * mPopUpMenu; - PRBool mMenuIsPoppedUp; - -}; - -#endif /* nsMenuButton_h___ */