diff --git a/widget/src/beos/nsButton.cpp b/widget/src/beos/nsButton.cpp deleted file mode 100644 index 22bca0e391e5..000000000000 --- a/widget/src/beos/nsButton.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsButton.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" - -#include "nsILookAndFeel.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" - -#include "nsIDeviceContext.h" -#include "nsIFontMetrics.h" - -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); - - -//------------------------------------------------------------------------- -// -// nsButton constructor -// -//------------------------------------------------------------------------- -nsButton::nsButton() : nsWindow() , nsIButton() -{ -} - -//------------------------------------------------------------------------- -// -// nsButton destructor -// -//------------------------------------------------------------------------- -nsButton::~nsButton() -{ -} - -/** - * Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID - * @modify gpk 8/4/98 - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID); - if (aIID.Equals(kIButton)) { - *aInstancePtr = (void*) ((nsIButton*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return nsWindow::QueryInterface(aIID,aInstancePtr); -} - - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsButton::SetLabel(const nsString& aText) -{ - mLabel = aText; - if(NULL == mView) { - return NS_ERROR_FAILURE; - } - if(mButton) - { - if(mButton->Looper()) - mButton->LockLooper(); - - mButton->SetLabel(NS_LossyConvertUCS2toASCII(aText).get()); - - if(mButton->Looper()) - mButton->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsButton::GetLabel(nsString& aBuffer) -{ - aBuffer = mLabel; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsButton::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsButton::OnPaint(nsRect &r) -{ - //printf("** nsButton::OnPaint **\n"); - return PR_FALSE; -} - -PRBool nsButton::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - -/** - * Renders the Button for Printing - * - **/ -NS_METHOD nsButton::Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - float appUnits; - float devUnits; - float scale; - nsIDeviceContext * context; - aRenderingContext.GetDeviceContext(context); - - context->GetCanonicalPixelScale(scale); - devUnits = context->AppUnitsToDevUnits(); - appUnits = context->DevUnitsToAppUnits(); - - nsRect rect; - GetBoundsAppUnits(rect, appUnits); - aRenderingContext.SetColor(NS_RGB(0,0,0)); - - nscolor bgColor = NS_RGB(255,255,255); - nscolor fgColor = NS_RGB(0,0,0); - nscolor hltColor = NS_RGB(240,240,240); - nscolor sdwColor = NS_RGB(128,128,128); - - { - nsCOMPtr lookAndFeel = do_GetService(kLookAndFeelCID); - if (lookAndFeel) { - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DHighlight, hltColor); - } - } - - aRenderingContext.SetColor(bgColor); - aRenderingContext.FillRect(rect); - - /*aRenderingContext.SetColor(bgColor); - for (int i=0;iGetMetricsFor(*mFont, metrics); - metrics->GetMaxAscent(textHeight); - - nscoord x = ((rect.width - textWidth) / 2) + rect.x; - nscoord y = ((rect.height - textHeight) / 2) + rect.y; - aRenderingContext.DrawString(mLabel, x, y); - - - NS_RELEASE(context); - return NS_OK; -} - -BView *nsButton::CreateBeOSView() -{ - return mButton = new nsButtonBeOS(this, BRect(0, 0, 0, 0), "", ""); -} - -//------------------------------------------------------------------------- -// Sub-class of BeOS Button -//------------------------------------------------------------------------- -nsButtonBeOS::nsButtonBeOS( nsIWidget *aWidgetWindow, BRect aFrame, - const char *aName, const char *aLabel, uint32 aResizingMode, uint32 aFlags ) - : BButton( aFrame, aName, aLabel, new BMessage('clik'), aResizingMode, aFlags ), - nsIWidgetStore( aWidgetWindow ) -{ -} - -void nsButtonBeOS::AttachedToWindow() -{ - SetTarget(this); -} - -void nsButtonBeOS::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case 'clik' : - { - nsWindow *w = (nsWindow *)GetMozillaWidget(); - nsToolkit *t; - if(w && (t = w->GetToolkit()) != 0) - { - uint32 args[5]; - args[0] = NS_MOUSE_LEFT_CLICK; - args[1] = (uint32)0; - args[2] = (uint32)0; - args[3] = 1; - args[4] = modifiers(); - MethodInfo *info = new MethodInfo(w, w, nsWindow::BTNCLICK, 5, args); - t->CallMethodAsync(info); - NS_RELEASE(t); - } - } - break; - - default : - BButton::MessageReceived(msg); - } -} - diff --git a/widget/src/beos/nsButton.h b/widget/src/beos/nsButton.h deleted file mode 100644 index 569a1bca40dd..000000000000 --- a/widget/src/beos/nsButton.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsButton_h__ -#define nsButton_h__ - -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" - -#include "nsIButton.h" - -#include - -/** - * Native Win32 button wrapper - */ - -class nsButton : public nsWindow, - public nsIButton -{ - -public: - nsButton(); - virtual ~nsButton(); - - //nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - - // nsIButton part - NS_IMETHOD SetLabel(const nsString& aText); - NS_IMETHOD GetLabel(nsString& aBuffer); - - // nsBaseWidget - NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnPaint(nsRect &r); - virtual PRBool OnResize(nsRect &aWindowRect); - -protected: - nsString mLabel; - virtual BView *CreateBeOSView(); - BButton *mButton; -}; - -// -// A BButton subclass -// -class nsButtonBeOS : public BButton, public nsIWidgetStore { - public: - nsButtonBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName, - const char *aLabel, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE ); - void AttachedToWindow(); - void MessageReceived(BMessage *msg); -}; - -#endif // nsButton_h__ diff --git a/widget/src/beos/nsCheckButton.cpp b/widget/src/beos/nsCheckButton.cpp deleted file mode 100644 index 6f6daaaba3e5..000000000000 --- a/widget/src/beos/nsCheckButton.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsCheckButton.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" - -#include "nsILookAndFeel.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" - -#include "nsIDeviceContext.h" - -//------------------------------------------------------------------------- -// -// nsCheckButton constructor -// -//------------------------------------------------------------------------- -nsCheckButton::nsCheckButton() : nsWindow() , nsICheckButton(), - mState(PR_FALSE) -{ -} - - -//------------------------------------------------------------------------- -// -// nsCheckButton destructor -// -//------------------------------------------------------------------------- -nsCheckButton::~nsCheckButton() -{ -} - - -/** - * Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID - * @modify gpk 8/4/98 - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); - if (aIID.Equals(kICheckButtonIID)) { - *aInstancePtr = (void*) ((nsICheckButton*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - return nsWindow::QueryInterface(aIID,aInstancePtr); -} - - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::SetState(const PRBool aState) -{ - mState = aState; - if(mCheckBox && mCheckBox->LockLooper()) - { - mCheckBox->SetValue(aState ? 1 : 0); - mCheckBox->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::GetState(PRBool& aState) -{ - aState = mState; - if(mCheckBox && mCheckBox->LockLooper()) - { - aState = mCheckBox->Value() ? PR_TRUE : PR_FALSE; - mCheckBox->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::SetLabel(const nsString& aText) -{ - if(mCheckBox && mCheckBox->LockLooper()) - { - mCheckBox->SetLabel( - NS_LossyConvertUCS2toASCII(Substring(aText,0,255)).get()); - mCheckBox->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer) -{ - if(mCheckBox && mCheckBox->LockLooper()) - { - aBuffer.SetLength(0); - aBuffer.AppendWithConversion(mCheckBox->Label()); - mCheckBox->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsCheckButton::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsCheckButton::OnPaint(nsRect &r) -{ - return PR_FALSE; -} - -PRBool nsCheckButton::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - - -/** - * Renders the CheckButton for Printing - * - **/ -NS_METHOD nsCheckButton::Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - nsRect rect; - float appUnits; - float scale; - nsIDeviceContext * context; - aRenderingContext.GetDeviceContext(context); - - context->GetCanonicalPixelScale(scale); - appUnits = context->DevUnitsToAppUnits(); - - GetBoundsAppUnits(rect, appUnits); - - nscoord one = nscoord(PRFloat64(rect.height) * 1.0/20.0); - nscoord three = nscoord(PRFloat64(rect.width) * 3.0/20.0); - nscoord five = nscoord(PRFloat64(rect.width) * 5.0/20.0); - nscoord six = nscoord(PRFloat64(rect.height) * 5.0/20.0); - nscoord eight = nscoord(PRFloat64(rect.height) * 7.0/20.0); - nscoord nine = nscoord(PRFloat64(rect.width) * 9.0/20.0); - nscoord ten = nscoord(PRFloat64(rect.height) * 9.0/20.0); - - rect.x += three; - rect.y += nscoord(PRFloat64(rect.height) * 3.5 /20.0); - rect.width = nscoord(PRFloat64(rect.width) * 12.0/20.0); - rect.height = nscoord(PRFloat64(rect.height) * 12.0/20.0); - - aRenderingContext.SetColor(NS_RGB(0,0,0)); - - nscoord onePixel = nscoord((appUnits+0.6F)); - DrawScaledRect(aRenderingContext, rect, scale, appUnits); - nscoord x = rect.x; - nscoord y = rect.y; - - if (mState) { - nscoord inc = nscoord(PRFloat64(rect.height) * 0.75/20.0); - nscoord yy = 0; - for (nscoord i=0;i<4;i++) { - DrawScaledLine(aRenderingContext, x+three, y+eight+yy, x+five, y+ten+yy, scale, appUnits, PR_FALSE); // top - DrawScaledLine(aRenderingContext, x+five, y+ten+yy, x+nine, y+six+yy, scale, appUnits, PR_FALSE); // top - //aRenderingContext.DrawLine(x+three, y+eight+yy, x+five, y+ten+yy); - //aRenderingContext.DrawLine(x+five, y+ten+yy, x+nine, y+six+yy); - yy += nscoord(scale); - } - } - - NS_RELEASE(context); - return NS_OK; -} - -BView *nsCheckButton::CreateBeOSView() -{ - return mCheckBox = new nsCheckBoxBeOS(this, BRect(0, 0, 0, 0), "", "", NULL); -} - -//------------------------------------------------------------------------- -// Sub-class of BeOS CheckBox -//------------------------------------------------------------------------- -nsCheckBoxBeOS::nsCheckBoxBeOS( nsIWidget *aWidgetWindow, BRect aFrame, - const char *aName, const char *aLabel, BMessage *aMessage, - uint32 aResizingMode, uint32 aFlags ) - : BCheckBox( aFrame, aName, aLabel, aMessage, aResizingMode, aFlags ), - nsIWidgetStore( aWidgetWindow ) -{ -} diff --git a/widget/src/beos/nsCheckButton.h b/widget/src/beos/nsCheckButton.h deleted file mode 100644 index 0a533d56b877..000000000000 --- a/widget/src/beos/nsCheckButton.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsCheckButton_h__ -#define nsCheckButton_h__ - -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" - -#include "nsICheckButton.h" - -#include - -/** - * Native Win32 Checkbox wrapper - */ - -class nsCheckButton : public nsWindow, - public nsICheckButton -{ - -public: - nsCheckButton(); - virtual ~nsCheckButton(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - - // nsICheckButton part - NS_IMETHOD SetLabel(const nsString &aText); - NS_IMETHOD GetLabel(nsString &aBuffer); - NS_IMETHOD SetState(const PRBool aState); - NS_IMETHOD GetState(PRBool& aState); - - NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnPaint(nsRect &r); - virtual PRBool OnResize(nsRect &aWindowRect); - - -protected: - PRBool mState; - virtual BView *CreateBeOSView(); - BCheckBox *mCheckBox; -}; - -// -// A BCheckBox subclass -// -class nsCheckBoxBeOS : public BCheckBox, public nsIWidgetStore { - public: - nsCheckBoxBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName, - const char *aLabel, BMessage *aMessage, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE ); -}; - -#endif // nsCheckButton_h__ diff --git a/widget/src/beos/nsLabel.cpp b/widget/src/beos/nsLabel.cpp deleted file mode 100644 index f31b3481a07c..000000000000 --- a/widget/src/beos/nsLabel.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsLabel.h" -#include "nsILabel.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsIFontMetrics.h" -#include "nsIDeviceContext.h" - -//------------------------------------------------------------------------- -// -// nsLabel constructor -// -//------------------------------------------------------------------------- -nsLabel::nsLabel() : nsWindow(), nsILabel() -{ - mAlignment = eAlign_Left; -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::PreCreateWidget(nsWidgetInitData *aInitData) -{ - if (nsnull != aInitData) { - nsLabelInitData* data = (nsLabelInitData *) aInitData; - mAlignment = data->mAlignment; - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsLabel destructor -// -//------------------------------------------------------------------------- -nsLabel::~nsLabel() -{ -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsLabel::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kILabelIID)) { - *aInstancePtr = (void*) ((nsILabel*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::SetAlignment(nsLabelAlignment aAlignment) -{ - mAlignment = aAlignment; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::SetLabel(const nsString& aText) -{ - if(mStringView && mStringView->LockLooper()) - { - mStringView->SetText( - NS_LossyConvertUCS2toASCII(Substring(aText,0,255)).get()); - mStringView->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsLabel::GetLabel(nsString& aBuffer) -{ - if(mStringView && mStringView->LockLooper()) - { - aBuffer.SetLength(0); - aBuffer.AppendWithConversion(mStringView->Text()); - mStringView->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsLabel::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsLabel::OnPaint(nsRect &r) -{ - //printf("** nsLabel::OnPaint **\n"); - return PR_FALSE; -} - -PRBool nsLabel::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - - -//------------------------------------------------------------------------- -// -// get position/dimensions -// -//------------------------------------------------------------------------- - -NS_METHOD nsLabel::GetBounds(nsRect &aRect) -{ - return nsWindow::GetBounds(aRect); -} - -//------------------------------------------------------------------------- -NS_METHOD nsLabel::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) -{ - if (nsnull == mContext) { - return NS_ERROR_FAILURE; - } - //nsIFontMetrics * fm = GetFont();; - // mDeviceContext->GetMetricsFor(mFont, &fm); - - nsIFontMetrics* metrics; - mContext->GetMetricsFor(*mFont, metrics); - - nsString text; - GetLabel(text); - - nsIRenderingContext *cx; - mContext->CreateRenderingContext(this, cx); - cx->SetFont(metrics); - nscoord string_height, string_width; - metrics->GetHeight(string_height); - cx->GetWidth(text, string_width); - NS_RELEASE(cx); - NS_RELEASE(metrics); - - if (mPreferredWidth != 0) { - aWidth = mPreferredWidth; - } else { - aWidth = string_width+8; - } - - if (mPreferredHeight != 0) { - aHeight = mPreferredHeight; - } else { - aHeight = string_height+8; - } - - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsLabel::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) -{ - mPreferredWidth = aWidth; - mPreferredHeight = aHeight; - return NS_OK; -} - -BView *nsLabel::CreateBeOSView() -{ - return mStringView = new nsStringViewBeOS(this, BRect(0, 0, 0, 0), "", ""); -} - -//------------------------------------------------------------------------- -// Sub-class of BeOS StringView -//------------------------------------------------------------------------- -nsStringViewBeOS::nsStringViewBeOS( nsIWidget *aWidgetWindow, BRect aFrame, - const char *aName, const char *text, uint32 aResizingMode, uint32 aFlags ) - : BStringView( aFrame, aName, text, aResizingMode, aFlags ), - nsIWidgetStore( aWidgetWindow ) -{ -} diff --git a/widget/src/beos/nsLabel.h b/widget/src/beos/nsLabel.h deleted file mode 100644 index ec1785925213..000000000000 --- a/widget/src/beos/nsLabel.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsLabel_h__ -#define nsLabel_h__ - -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" - -#include "nsILabel.h" - -#include - -/** - * Native Win32 Label wrapper - */ - -class nsLabel : public nsWindow, - public nsILabel -{ - -public: - nsLabel(); - virtual ~nsLabel(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - - // nsILabel part - NS_IMETHOD SetLabel(const nsString &aText); - NS_IMETHOD GetLabel(nsString &aBuffer); - NS_IMETHOD SetAlignment(nsLabelAlignment aAlignment); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnPaint(nsRect &r); - virtual PRBool OnResize(nsRect &aWindowRect); - - NS_IMETHOD GetBounds(nsRect &aRect); - NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData); - - NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight); - NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight); - -protected: - nsLabelAlignment mAlignment; - BStringView *mStringView; - BView *CreateBeOSView(); -}; - -// -// A BStringView subclass -// -class nsStringViewBeOS : public BStringView, public nsIWidgetStore { - public: - nsStringViewBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName, - const char *text, uint32 aResizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 aFlags = B_WILL_DRAW | B_NAVIGABLE ); -}; - -#endif // nsLabel_h__ diff --git a/widget/src/beos/nsObject.cpp b/widget/src/beos/nsObject.cpp deleted file mode 100644 index c022b0d6eea0..000000000000 --- a/widget/src/beos/nsObject.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -#include "nsObject.h" - - -CList nsObject::s_liveChain; -PRMonitor *nsObject::s_liveChainMutex = PR_NewMonitor(); - -#ifdef _DEBUG -int32 nsObject::s_nObjects = 0; -#endif - -/** - * constructor - */ -nsObject::nsObject() -{ - // - // Add the new object the chain of allocated nsObjects - // - PR_EnterMonitor(s_liveChainMutex); - s_liveChain.Append(m_link); - PR_ExitMonitor(s_liveChainMutex); -#ifdef _DEBUG - s_nObjects++; -#endif -} - - -/** - * destructor - */ -nsObject::~nsObject() -{ -#ifdef _DEBUG - s_nObjects--; -#endif - // - // Remove from the chain of allocated nsObjects - // - PR_EnterMonitor(s_liveChainMutex); - m_link.Remove(); - PR_ExitMonitor(s_liveChainMutex); -} - - -/** - * static utility. Delete all live objects - */ - -void nsObject::DeleteAllObjects(void) -{ - PR_EnterMonitor(s_liveChainMutex); - - while (!s_liveChain.IsEmpty()) { - nsObject *pnsObject; - - pnsObject = (nsObject*)OBJECT_PTR_FROM_CLIST(nsObject, s_liveChain.next); - - // Remove the event from the chain... - pnsObject->m_link.Remove(); - delete pnsObject; - } - - PR_ExitMonitor(s_liveChainMutex); -} - diff --git a/widget/src/beos/nsObject.h b/widget/src/beos/nsObject.h deleted file mode 100644 index 17697e649806..000000000000 --- a/widget/src/beos/nsObject.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsObject_h__ -#define nsObject_h__ - -#include "nsdefs.h" -#include "nsCList.h" -#include "nsISupports.h" -#include "prmon.h" - -/** - * nsObject is the base class for all native widgets - */ - -class nsObject -{ - -public: - nsObject(); - virtual ~nsObject(); - -protected: - // - // Data members: - // - CList m_link; - -public: - - // - // The following data members are used to maintain a chain of all - // allocated nsObject instances. This chain is traversed at - // shutdown to clean up any dangling instances... - // - static CList s_liveChain; - static PRMonitor *s_liveChainMutex; - -#ifdef _DEBUG - static int32 s_nObjects; -#endif - - static void DeleteAllObjects(void); - -}; - - -#endif // nsObject_h__ diff --git a/widget/src/beos/nsTextHelper.cpp b/widget/src/beos/nsTextHelper.cpp deleted file mode 100644 index 185fedea51aa..000000000000 --- a/widget/src/beos/nsTextHelper.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsTextHelper.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsReadableUtils.h" -#include - -NS_METHOD nsTextHelper::PreCreateWidget(nsWidgetInitData *aInitData) -{ - if (nsnull != aInitData) { - nsTextWidgetInitData* data = (nsTextWidgetInitData *) aInitData; - mIsPassword = data->mIsPassword; - mIsReadOnly = data->mIsReadOnly; - } - return NS_OK; -} - -NS_METHOD nsTextHelper::SetMaxTextLength(PRUint32 aChars) -{ - if(mTextView && mTextView->LockLooper()) - { - mTextView->SetMaxBytes(aChars); - mTextView->UnlockLooper(); - } - return NS_OK; -} - -NS_METHOD nsTextHelper::GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize) -{ - if(mTextView && mTextView->LockLooper()) - { - aTextBuffer.SetLength(0); - aTextBuffer.AppendWithConversion(mTextView->Text()); - aActualSize = strlen(mTextView->Text()); - mTextView->UnlockLooper(); - } - return NS_OK; -} - -NS_METHOD nsTextHelper::SetText(const nsString &aText, PRUint32& aActualSize) -{ - mText = aText; - - const char *text; - text = ToNewCString(aText); - if(mTextView && mTextView->LockLooper()) - { - mTextView->SetText(text); - mTextView->UnlockLooper(); - } - delete [] text; - - aActualSize = aText.Length(); - return NS_OK; -} - -NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) -{ - const char *text; - text = ToNewCString(aText); - if(mTextView) - { - if(mTextView->LockLooper()) - { - mTextView->Insert(aStartPos, text, aActualSize); - mTextView->UnlockLooper(); - } - else - mTextView->Insert(aStartPos, text, aActualSize); - } - delete [] text; - mText.Insert(ToNewUnicode(aText), aStartPos, aText.Length()); - return NS_OK; -} - -NS_METHOD nsTextHelper::RemoveText() -{ - if(mTextView && mTextView->LockLooper()) - { - mTextView->Delete(0, mTextView->TextLength() - 1); - mTextView->UnlockLooper(); - } - return NS_OK; -} - -NS_METHOD nsTextHelper::SetPassword(PRBool aIsPassword) -{ - mIsPassword = aIsPassword; -if(mIsPassword) printf("nsTextHelper::SetPassword not implemented\n"); - return NS_OK; -} - -NS_METHOD nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldFlag) -{ - aOldFlag = mIsReadOnly; - mIsReadOnly = aReadOnlyFlag; - - // Update the widget - if(mTextView && mTextView->LockLooper()) - { - mTextView->MakeEditable(false); - mTextView->UnlockLooper(); - } - - return NS_OK; -} - -NS_METHOD nsTextHelper::SelectAll() -{ - if(mTextView && mTextView->LockLooper()) - { - mTextView->SelectAll(); - mTextView->UnlockLooper(); - } - return NS_OK; -} - -NS_METHOD nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel) -{ - if(mTextView && mTextView->LockLooper()) - { - mTextView->Select(aStartSel, aEndSel); - mTextView->UnlockLooper(); - } - return NS_OK; -} - - -NS_METHOD nsTextHelper::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel) -{ - if(mTextView && mTextView->LockLooper()) - { - mTextView->GetSelection((int32 *)aStartSel, (int32 *)aEndSel); - mTextView->UnlockLooper(); - } - return NS_OK; -} - -NS_METHOD nsTextHelper::SetCaretPosition(PRUint32 aPosition) -{ - SetSelection(aPosition, aPosition); - return NS_OK; -} - -NS_METHOD nsTextHelper::GetCaretPosition(PRUint32& aPos) -{ - PRUint32 start; - PRUint32 end; - GetSelection(&start, &end); - if (start == end) { - aPos = start; - } - else { - aPos = PRUint32(-1);/* XXX is this right??? scary cast! */ - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsTextHelper constructor -// -//------------------------------------------------------------------------- - -nsTextHelper::nsTextHelper() : nsWindow(), nsITextWidget() -{ - mIsReadOnly = PR_FALSE; - mIsPassword = PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// nsTextHelper destructor -// -//------------------------------------------------------------------------- -nsTextHelper::~nsTextHelper() -{ -} - -//------------------------------------------------------------------------- -// -// Clear window before paint -// -//------------------------------------------------------------------------- - -PRBool nsTextHelper::AutoErase() -{ - return(PR_TRUE); -} - - -TextFrameBeOS::TextFrameBeOS(BTextView *child, BRect frame, const char *name, uint32 resizingmode, uint32 flags) - : BView(frame, name, resizingmode, flags | B_FRAME_EVENTS), tv(child) -{ - SetViewColor(0, 0, 0); - AddChild(tv); -} - -void TextFrameBeOS::FrameResized(float width, float height) -{ - tv->MoveTo(1, 1); - tv->ResizeTo(width - 2, height - 2); - BRect r = Bounds(); - r.InsetBy(1, 1); - tv->SetTextRect(r); - BView::FrameResized(width, height); -} diff --git a/widget/src/beos/nsTextHelper.h b/widget/src/beos/nsTextHelper.h deleted file mode 100644 index 5b350bb80a36..000000000000 --- a/widget/src/beos/nsTextHelper.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsTextHelper_h__ -#define nsTextHelper_h__ - -#include "nsdefs.h" -#include "nsITextWidget.h" -#include "nsWindow.h" - -class BTextView; - -/** - * Base class for nsTextAreaWidget (obsolete) and nsTextWidget - */ - -class nsTextHelper : public nsWindow, - public nsITextWidget -{ - -public: - nsTextHelper(); - virtual ~nsTextHelper(); - - NS_IMETHOD SelectAll(); - NS_IMETHOD SetMaxTextLength(PRUint32 aChars); - NS_IMETHOD GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize); - NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize); - NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize); - NS_IMETHOD RemoveText(); - NS_IMETHOD SetPassword(PRBool aIsPassword); - NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag); - NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel); - NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel); - NS_IMETHOD SetCaretPosition(PRUint32 aPosition); - NS_IMETHOD GetCaretPosition(PRUint32& aPosition); - - NS_IMETHOD PreCreateWidget(nsWidgetInitData *aInitData); - - virtual PRBool AutoErase(); - -protected: - nsString mText; - PRBool mIsPassword; - PRBool mIsReadOnly; - BTextView *mTextView; -}; - -class TextFrameBeOS : public BView -{ - BTextView *tv; -public: - TextFrameBeOS(BTextView *child, BRect frame, const char *name, uint32 resizingmode, uint32 flags); - void FrameResized(float width, float height); -}; - -#endif // nsTextHelper_h__ diff --git a/widget/src/beos/nsTextWidget.cpp b/widget/src/beos/nsTextWidget.cpp deleted file mode 100644 index 7882641d853d..000000000000 --- a/widget/src/beos/nsTextWidget.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsTextWidget.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" - -#include "nsILookAndFeel.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" - -#include "nsIDeviceContext.h" -#include "nsIFontMetrics.h" - -#include - -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); - - -//------------------------------------------------------------------------- -// -// nsTextWidget constructor -// -//------------------------------------------------------------------------- -nsTextWidget::nsTextWidget() : nsTextHelper() -{ - mBackground = NS_RGB(124, 124, 124); -} - -//------------------------------------------------------------------------- -// -// nsTextWidget destructor -// -//------------------------------------------------------------------------- -nsTextWidget::~nsTextWidget() -{ -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsTextWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsTextWidgetIID)) { - *aInstancePtr = (void*) ((nsITextWidget*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - - return result; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsTextWidget::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsTextWidget::OnPaint(nsRect &r) -{ - return PR_FALSE; -} - - -PRBool nsTextWidget::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// get position/dimensions -// -//------------------------------------------------------------------------- - -NS_METHOD nsTextWidget::GetBounds(nsRect &aRect) -{ -#if 0 - nsWindow::GetNonClientBounds(aRect); -#endif -printf("nsTextWidget::GetBounds not wrong\n"); // the following is just a placeholder - nsWindow::GetClientBounds(aRect); - return NS_OK; -} - -/** - * Renders the TextWidget for Printing - * - **/ -NS_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - nsRect rect; - float appUnits; - float scale; - nsIDeviceContext * context; - aRenderingContext.GetDeviceContext(context); - - context->GetCanonicalPixelScale(scale); - appUnits = context->DevUnitsToAppUnits(); - - GetBoundsAppUnits(rect, appUnits); - - aRenderingContext.SetColor(NS_RGB(0,0,0)); - - nscolor bgColor = NS_RGB(255,255,255); - nscolor fgColor = NS_RGB(0,0,0); - nscolor hltColor = NS_RGB(240,240,240); - nscolor sdwColor = NS_RGB(128,128,128); - nscolor txtBGColor = NS_RGB(255,255,255); - nscolor txtFGColor = NS_RGB(0,0,0); - { - nsCOMPtr lookAndFeel = do_GetService(kLookAndFeelCID); - if (lookAndFeel) { - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DHighlight, hltColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextBackground, txtBGColor); - lookAndFeel->GetColor(nsILookAndFeel::eColor_TextForeground, txtFGColor); - } - } - - aRenderingContext.SetColor(txtBGColor); - aRenderingContext.FillRect(rect); - - // Paint Black border - //nsBaseWidget::Paint(aRenderingContext, aDirtyRect); - - nscoord onePixel = nscoord(scale); - nscoord twoPixels = nscoord(scale*2); - - rect.x += onePixel; - rect.y += onePixel; - rect.width -= twoPixels+onePixel; - rect.height -= twoPixels+onePixel; - - nscoord right = rect.x+rect.width; - nscoord bottom = rect.y+rect.height; - - - // Draw Left & Top - aRenderingContext.SetColor(NS_RGB(128,128,128)); - DrawScaledLine(aRenderingContext, rect.x, rect.y, right, rect.y, scale, appUnits, PR_TRUE); // top - DrawScaledLine(aRenderingContext, rect.x, rect.y, rect.x, bottom, scale, appUnits, PR_FALSE); // left - - //DrawScaledLine(aRenderingContext, rect.x+onePixel, rect.y+onePixel, right-onePixel, rect.y+onePixel, scale, appUnits, PR_TRUE); // top + 1 - //DrawScaledLine(aRenderingContext, rect.x+onePixel, rect.y+onePixel, rect.x+onePixel, bottom-onePixel, scale, appUnits, PR_FALSE); // left + 1 - - // Draw Right & Bottom - aRenderingContext.SetColor(NS_RGB(192,192,192)); - DrawScaledLine(aRenderingContext, right, rect.y+onePixel, right, bottom, scale, appUnits, PR_FALSE); // right - DrawScaledLine(aRenderingContext, rect.x+onePixel, bottom, right, bottom, scale, appUnits, PR_TRUE); // bottom - - //DrawScaledLine(aRenderingContext, right-onePixel, rect.y+twoPixels, right-onePixel, bottom, scale, appUnits, PR_FALSE); // right + 1 - //DrawScaledLine(aRenderingContext, rect.x+twoPixels, bottom-onePixel, right, bottom-onePixel, scale, appUnits, PR_TRUE); // bottom + 1 - - - aRenderingContext.SetFont(*mFont); - - nscoord textWidth; - nscoord textHeight; - aRenderingContext.GetWidth(mText, textWidth); - - nsIFontMetrics* metrics; - context->GetMetricsFor(*mFont, metrics); - metrics->GetMaxAscent(textHeight); - - nscoord x = (twoPixels * 2) + rect.x; - nscoord y = ((rect.height - textHeight) / 2) + rect.y; - aRenderingContext.SetColor(txtFGColor); - if (!mIsPassword) { - aRenderingContext.DrawString(mText, x, y); - } else { - nsString astricks; - PRInt32 i; - for (i=0;iWindow()->CurrentMessage(); - if (msg) { - msg->FindInt32("key", &keycode); - } - - if(w && (t = w->GetToolkit()) != 0) - { - uint32 bytebuf = 0; - uint8 *byteptr = (uint8 *)&bytebuf; - for(int32 i = 0; i < numBytes; i++) - byteptr[i] = bytes[i]; - - uint32 args[5]; - args[0] = NS_KEY_DOWN; - args[1] = bytebuf; - args[2] = numBytes; - args[3] = modifiers(); - args[4] = keycode; - - MethodInfo *info = new MethodInfo(w, w, nsWindow::ONKEY, 5, args); - t->CallMethodAsync(info); - NS_RELEASE(t); - } -} - -void nsTextViewBeOS::KeyUp(const char *bytes, int32 numBytes) -{ - // call back if not enter/return - if(numBytes != 1 || (bytes[0] != 10 && bytes[0] != 13)) - BTextView::KeyUp(bytes, numBytes); - - nsWindow *w = (nsWindow *)GetMozillaWidget(); - nsToolkit *t; - int32 keycode = 0; - - BMessage *msg = this->Window()->CurrentMessage(); - if (msg) { - msg->FindInt32("key", &keycode); - } - - if(w && (t = w->GetToolkit()) != 0) - { - uint32 bytebuf = 0; - uint8 *byteptr = (uint8 *)&bytebuf; - for(int32 i = 0; i < numBytes; i++) - byteptr[i] = bytes[i]; - - uint32 args[5]; - args[0] = NS_KEY_UP; - args[1] = (int32)bytebuf; - args[2] = numBytes; - args[3] = modifiers(); - args[4] = keycode; - - MethodInfo *info = new MethodInfo(w, w, nsWindow::ONKEY, 5, args); - t->CallMethodAsync(info); - NS_RELEASE(t); - } -} diff --git a/widget/src/beos/nsTextWidget.h b/widget/src/beos/nsTextWidget.h deleted file mode 100644 index 72510cc2ac01..000000000000 --- a/widget/src/beos/nsTextWidget.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsTextWidget_h__ -#define nsTextWidget_h__ - -#include "nsdefs.h" -#include "nsWindow.h" -#include "nsSwitchToUIThread.h" -#include "nsTextHelper.h" - -#include "nsITextWidget.h" - -#include - -/** - * Native WIN32 single line edit control wrapper. - */ - -class nsTextWidget : public nsTextHelper -{ - -public: - nsTextWidget(); - virtual ~nsTextWidget(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - - virtual PRBool OnPaint(nsRect &r); - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnResize(nsRect &aWindowRect); - NS_IMETHOD GetBounds(nsRect &aRect); - - NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect); -protected: - BView *CreateBeOSView(); -}; - -// -// A BTextView subclass -// -class nsTextViewBeOS : public BTextView, public nsIWidgetStore -{ - public: - nsTextViewBeOS( nsIWidget *aWidgetWindow, BRect aFrame, const char *aName, - BRect aTextRect, uint32 aResizingMode, uint32 aFlags ); - void KeyDown(const char *bytes, int32 numbytes); - void KeyUp(const char *bytes, int32 numbytes); -}; - -#endif // nsTextWidget_h__