From b459088f4aa46fc5a1dabbb2e966382fc59f73a1 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Wed, 8 Aug 2001 04:01:11 +0000 Subject: [PATCH] part of 93467 - remove old native radiobutton code. r=blizzard, sr=hyatt. --- widget/public/MANIFEST | 1 - widget/public/Makefile.in | 1 - widget/public/nsIRadioButton.h | 80 ------- widget/src/beos/Makefile.in | 1 - widget/src/beos/nsRadioButton.cpp | 248 ---------------------- widget/src/beos/nsRadioButton.h | 82 -------- widget/src/beos/nsWidgetFactory.cpp | 5 - widget/src/build/nsWidgetSupport.cpp | 26 --- widget/src/gtk/nsRadioButton.cpp | 242 --------------------- widget/src/gtk/nsRadioButton.h | 75 ------- widget/src/mac/nsRadioButton.cpp | 99 --------- widget/src/mac/nsRadioButton.h | 49 ----- widget/src/mac/nsWidgetFactory.cpp | 10 - widget/src/mac/nsWidgetSupport.cpp | 26 --- widget/src/motif/Makefile.in | 1 - widget/src/motif/nsRadioButton.cpp | 290 -------------------------- widget/src/motif/nsRadioButton.h | 88 -------- widget/src/motif/nsWidgetFactory.cpp | 5 - widget/src/motif/nsXtEventHandler.cpp | 24 --- widget/src/photon/nsRadioButton.cpp | 277 ------------------------ widget/src/photon/nsRadioButton.h | 69 ------ widget/src/qt/.cvsignore | 1 - widget/src/qt/nsRadioButton.cpp | 161 -------------- widget/src/qt/nsRadioButton.h | 88 -------- widget/src/windows/nsRadioButton.cpp | 256 ----------------------- widget/src/windows/nsRadioButton.h | 74 ------- widget/src/xlib/Makefile.in | 1 - widget/src/xlib/nsRadioButton.cpp | 74 ------- widget/src/xlib/nsRadioButton.h | 61 ------ 29 files changed, 2415 deletions(-) delete mode 100644 widget/public/nsIRadioButton.h delete mode 100644 widget/src/beos/nsRadioButton.cpp delete mode 100644 widget/src/beos/nsRadioButton.h delete mode 100644 widget/src/gtk/nsRadioButton.cpp delete mode 100644 widget/src/gtk/nsRadioButton.h delete mode 100644 widget/src/mac/nsRadioButton.cpp delete mode 100644 widget/src/mac/nsRadioButton.h delete mode 100644 widget/src/motif/nsRadioButton.cpp delete mode 100644 widget/src/motif/nsRadioButton.h delete mode 100644 widget/src/photon/nsRadioButton.cpp delete mode 100644 widget/src/photon/nsRadioButton.h delete mode 100644 widget/src/qt/nsRadioButton.cpp delete mode 100644 widget/src/qt/nsRadioButton.h delete mode 100644 widget/src/windows/nsRadioButton.cpp delete mode 100644 widget/src/windows/nsRadioButton.h delete mode 100644 widget/src/xlib/nsRadioButton.cpp delete mode 100644 widget/src/xlib/nsRadioButton.h diff --git a/widget/public/MANIFEST b/widget/public/MANIFEST index ed7824df4e6d..1682136aa43b 100644 --- a/widget/public/MANIFEST +++ b/widget/public/MANIFEST @@ -14,7 +14,6 @@ nsIListBox.h nsIScrollbar.h nsGUIEvent.h nsEvent.h -nsIRadioButton.h nsIMouseListener.h nsIEventListener.h nsIFileWidget.h diff --git a/widget/public/Makefile.in b/widget/public/Makefile.in index b9cfa2269ab9..5a7c59e23e72 100644 --- a/widget/public/Makefile.in +++ b/widget/public/Makefile.in @@ -50,7 +50,6 @@ EXPORTS = \ nsIScrollbar.h \ nsGUIEvent.h \ nsEvent.h \ - nsIRadioButton.h \ nsIMouseListener.h \ nsIEventListener.h \ nsIMenuListener.h \ diff --git a/widget/public/nsIRadioButton.h b/widget/public/nsIRadioButton.h deleted file mode 100644 index 4f639474beed..000000000000 --- a/widget/public/nsIRadioButton.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape 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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIRadioButton_h__ -#define nsIRadioButton_h__ - -#include "nsIButton.h" - -#define NS_IRADIOBUTTON_IID \ -{ 0x18032ad4, 0xb265, 0x11d2, \ -{ 0xaa, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } - -/** - * RadioButton widget. Can show itself in a checked or unchecked state. - * The RadioButton widget automatically shows itself checked or unchecked when clicked on. - */ - -class nsIRadioButton : public nsISupports { - -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRADIOBUTTON_IID) - - /** - * Set the button label - * - * @param aText button label - * @result set to NS_OK if method successful - */ - - NS_IMETHOD SetLabel(const nsString &aText) = 0; - - /** - * Get the button label - * - * @param aBuffer contains label upon return - * @result set to NS_OK if method successful - */ - - NS_IMETHOD GetLabel(nsString &aBuffer) = 0; - - /** - * Set the check state. - * @param aState PR_TRUE show as checked. PR_FALSE show unchecked. - * @result set to NS_OK if method successful - */ - - NS_IMETHOD SetState(const PRBool aState) = 0; - - /** - * Get the check state. - * @param aState PR_TRUE if checked. PR_FALSE if unchecked. - * @result set to NS_OK if method successful - */ - - NS_IMETHOD GetState(PRBool& aState) = 0; - -}; - -#endif // nsIRadioButton_h__ - - diff --git a/widget/src/beos/Makefile.in b/widget/src/beos/Makefile.in index 305977089b64..093937f290e2 100644 --- a/widget/src/beos/Makefile.in +++ b/widget/src/beos/Makefile.in @@ -47,7 +47,6 @@ CPPSRCS = \ nsLookAndFeel.cpp \ nsObject.cpp \ nsPopUpMenu.cpp \ - nsRadioButton.cpp \ nsScrollbar.cpp \ nsSound.cpp \ nsTextAreaWidget.cpp \ diff --git a/widget/src/beos/nsRadioButton.cpp b/widget/src/beos/nsRadioButton.cpp deleted file mode 100644 index c4ff8c82c518..000000000000 --- a/widget/src/beos/nsRadioButton.cpp +++ /dev/null @@ -1,248 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsRadioButton.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsStringUtil.h" - -#include "nsILookAndFeel.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" - -#include "nsIDeviceContext.h" - -NS_IMPL_ADDREF(nsRadioButton) -NS_IMPL_RELEASE(nsRadioButton) - -//------------------------------------------------------------------------- -// -// nsRadioButton constructor -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsWindow(), nsIRadioButton() -{ - NS_INIT_REFCNT(); -} - - -//------------------------------------------------------------------------- -// -// nsRadioButton destructor -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kIRadioButtonIID)) { - *aInstancePtr = (void*) ((nsIRadioButton*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - return result; - } - -//------------------------------------------------------------------------- -// -// Sets the state of the nsRadioButton -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(const PRBool aState) -{ - fState = aState; - if(mRadioButton && mRadioButton->LockLooper()) - { - mRadioButton->SetValue(aState ? 1 : 0); - mRadioButton->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool& aState) -{ - aState = fState; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - char label[256]; - aText.ToCString(label, 256); - label[255] = '\0'; - if(mRadioButton && mRadioButton->LockLooper()) - { - mRadioButton->SetLabel(label); - mRadioButton->UnlockLooper(); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - if(mRadioButton && mRadioButton->LockLooper()) - { - aBuffer.SetLength(0); - aBuffer.AppendWithConversion(mRadioButton->Label()); - mRadioButton->UnlockLooper(); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsRadioButton::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsRadioButton::OnPaint(nsRect &r) -{ - return PR_FALSE; -} - -PRBool nsRadioButton::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - - -/** - * Renders the RadioButton for Printing - * - **/ -NS_METHOD nsRadioButton::Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - float appUnits; - float scale; - nsIDeviceContext * context; - aRenderingContext.GetDeviceContext(context); - - context->GetCanonicalPixelScale(scale); - context->GetDevUnitsToAppUnits(appUnits); - nsRect rect; - GetBounds(rect); - - rect.x++; - rect.y++; - rect.width -= 2; - rect.height -= 2; - aRenderingContext.SetColor(NS_RGB(0,0,0)); - - nscoord one = nscoord(PRFloat64(rect.width) * 1.0/12.0); - - rect.x = nscoord((PRFloat64)rect.x * appUnits); - rect.y = nscoord((PRFloat64)rect.y * appUnits); - rect.width = nscoord((PRFloat64)rect.width * appUnits); - rect.height = nscoord((PRFloat64)rect.height * appUnits); - rect.x += one; - rect.width = nscoord(PRFloat64(rect.width) * 11.0/12.0); - rect.height = nscoord(PRFloat64(rect.height) * 11.0/12.0); - - for (nscoord i=0;i - -/** - * Native Win32 Radio button wrapper - */ - -class nsRadioButton : public nsWindow, - public nsIRadioButton -{ - -public: - nsRadioButton(); - virtual ~nsRadioButton(); - - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIRadioButton 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 fState; - virtual BView *CreateBeOSView(); - BRadioButton *mRadioButton; -}; - -// -// A BRadioButton subclass -// -class nsRadioButtonBeOS : public BRadioButton, public nsIWidgetStore { - public: - nsRadioButtonBeOS( 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 // nsRadioButton_h__ diff --git a/widget/src/beos/nsWidgetFactory.cpp b/widget/src/beos/nsWidgetFactory.cpp index fff53321d591..38ffe7a5011c 100644 --- a/widget/src/beos/nsWidgetFactory.cpp +++ b/widget/src/beos/nsWidgetFactory.cpp @@ -35,7 +35,6 @@ #include "nsCheckButton.h" #include "nsTextWidget.h" #include "nsTextAreaWidget.h" -#include "nsRadioButton.h" #include "nsFilePicker.h" #include "nsFileWidget.h" #include "nsListBox.h" @@ -62,7 +61,6 @@ static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID); static NS_DEFINE_IID(kCFileOpen, NS_FILEWIDGET_CID); static NS_DEFINE_IID(kCFilePicker, NS_FILEPICKER_CID); static NS_DEFINE_IID(kCListbox, NS_LISTBOX_CID); -static NS_DEFINE_IID(kCRadioButton, NS_RADIOBUTTON_CID); static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); static NS_DEFINE_IID(kCTextArea, NS_TEXTAREA_CID); @@ -176,9 +174,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCCheckButton)) { inst = (nsISupports*)(nsWindow *)new nsCheckButton(); } - else if (mClassID.Equals(kCRadioButton)) { - inst = (nsISupports*)(nsWindow *)new nsRadioButton(); - } else if (mClassID.Equals(kCFileOpen)) { inst = (nsISupports*)new nsFileWidget(); } diff --git a/widget/src/build/nsWidgetSupport.cpp b/widget/src/build/nsWidgetSupport.cpp index c40b0cdca1a8..4772ce284b2f 100644 --- a/widget/src/build/nsWidgetSupport.cpp +++ b/widget/src/build/nsWidgetSupport.cpp @@ -37,7 +37,6 @@ #include "nsIWidget.h" #include "nsICheckButton.h" #include "nsIScrollbar.h" -#include "nsIRadioButton.h" #include "nsITextWidget.h" @@ -105,31 +104,6 @@ NS_CreateCheckButton(nsISupports* aParent, -NS_WIDGET nsresult -NS_CreateRadioButton( nsISupports* aParent, - nsIRadioButton* aRadioButton, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont* aFont) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) - aParent->QueryInterface(kIWidgetIID,(void**)&parent); - - nsIWidget* widget; - if (NS_OK == aRadioButton->QueryInterface(kIWidgetIID,(void**)&widget)) { - widget->Create(parent, aRect, aHandleEventFunction, NULL); - widget->Show(PR_TRUE); - if (aFont != nsnull) - widget->SetFont(*aFont); - NS_IF_RELEASE(widget); - } - if (aParent != nsnull) - NS_IF_RELEASE(parent); - return NS_OK; -} - - NS_WIDGET nsresult NS_CreateLabel( nsISupports* aParent, nsILabel* aLabel, diff --git a/widget/src/gtk/nsRadioButton.cpp b/widget/src/gtk/nsRadioButton.cpp deleted file mode 100644 index 57d14d6dcf2d..000000000000 --- a/widget/src/gtk/nsRadioButton.cpp +++ /dev/null @@ -1,242 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include - -#include "nsRadioButton.h" -#include "nsString.h" - -#include "nsGtkEventHandler.h" - -NS_IMPL_ADDREF_INHERITED(nsRadioButton, nsWidget) -NS_IMPL_RELEASE_INHERITED(nsRadioButton, nsWidget) - -//------------------------------------------------------------------------- -// -// nsRadioButton constructor -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton() -{ - NS_INIT_REFCNT(); - mLabel = nsnull; - mRadioButton = nsnull; -} - - -//------------------------------------------------------------------------- -// -// nsRadioButton destructor -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ -#if 0 - if (mLabel) - gtk_widget_destroy(mLabel); -#endif -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWidget::QueryInterface(aIID, aInstancePtr); - - if (result == NS_NOINTERFACE && aIID.Equals(NS_GET_IID(nsIRadioButton))) { - *aInstancePtr = (void*) ((nsIRadioButton*)this); - AddRef(); - result = NS_OK; - } - return result; -} - - -//------------------------------------------------------------------------- -// -// Create the native RadioButton widget -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::CreateNative(GtkObject *parentWindow) -{ - mWidget = gtk_event_box_new(); - mRadioButton = gtk_radio_button_new(nsnull); - - gtk_container_add(GTK_CONTAINER(mWidget), mRadioButton); - - gtk_widget_show(mRadioButton); - - gtk_widget_set_name(mWidget, "nsRadioButton"); - - gtk_radio_button_set_group(GTK_RADIO_BUTTON(mRadioButton), nsnull); - - gtk_signal_connect(GTK_OBJECT(mRadioButton), - "destroy", - GTK_SIGNAL_FUNC(DestroySignal), - this); - - return NS_OK; -} - -void -nsRadioButton::OnDestroySignal(GtkWidget* aGtkWidget) -{ - if (aGtkWidget == mLabel) { - mLabel = nsnull; - } - else if (aGtkWidget == mRadioButton) { - mRadioButton = nsnull; - } - else { - nsWidget::OnDestroySignal(aGtkWidget); - } -} - -void nsRadioButton::InitCallbacks(char * aName) -{ - InstallButtonPressSignal(mRadioButton); - InstallButtonReleaseSignal(mRadioButton); - - InstallEnterNotifySignal(mWidget); - InstallLeaveNotifySignal(mWidget); - - // These are needed so that the events will go to us and not our parent. - AddToEventMask(mWidget, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_EXPOSURE_MASK | - GDK_FOCUS_CHANGE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK); -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(const PRBool aState) -{ - if (mWidget) { - GtkToggleButton * item = GTK_TOGGLE_BUTTON(mRadioButton); - item->active = (gboolean) aState; - gtk_widget_queue_draw(GTK_WIDGET(item)); - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button state -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool& aState) -{ - if (mWidget) { - aState = (PRBool) GTK_TOGGLE_BUTTON(mRadioButton)->active; - } - else { - aState = PR_TRUE; - } - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - if (mWidget) { - NS_ALLOC_STR_BUF(label, aText, 256); -#ifdef DEBUG - g_print("nsRadioButton::SetLabel(%s)\n",label); -#endif - if (mLabel) { - gtk_label_set(GTK_LABEL(mLabel), label); - } else { - mLabel = gtk_label_new(label); - gtk_misc_set_alignment (GTK_MISC (mLabel), 0.0, 0.5); - gtk_container_add(GTK_CONTAINER(mRadioButton), mLabel); - gtk_widget_show(mLabel); /* XXX */ - gtk_signal_connect(GTK_OBJECT(mLabel), - "destroy", - GTK_SIGNAL_FUNC(DestroySignal), - this); - } - NS_FREE_STR_BUF(label); - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - aBuffer.Truncate(); - if (mWidget) { - if (mLabel) { - char* text; - gtk_label_get(GTK_LABEL(mLabel), &text); - aBuffer.AppendWithConversion(text); - } - } - return NS_OK; -} - -////////////////////////////////////////////////////////////////////// -// SetBackgroundColor for RadioButton -/*virtual*/ -void nsRadioButton::SetBackgroundColorNative(GdkColor *aColorNor, - GdkColor *aColorBri, - GdkColor *aColorDark) -{ - // use same style copy as SetFont - GtkStyle *style = gtk_style_copy(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0))->style); - - style->bg[GTK_STATE_NORMAL]=*aColorNor; - - // Mouse over button - style->bg[GTK_STATE_PRELIGHT]=*aColorBri; - - // Button is down - style->bg[GTK_STATE_ACTIVE]=*aColorDark; - - // other states too? (GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, - // GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE) - gtk_widget_set_style(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0)), style); - // set style for eventbox too - gtk_widget_set_style(mWidget, style); - - gtk_style_unref(style); -} - diff --git a/widget/src/gtk/nsRadioButton.h b/widget/src/gtk/nsRadioButton.h deleted file mode 100644 index 881e7a799fc9..000000000000 --- a/widget/src/gtk/nsRadioButton.h +++ /dev/null @@ -1,75 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsRadioButton_h__ -#define nsRadioButton_h__ - -#include "nsWidget.h" -#include "nsIRadioButton.h" - -/** - * Native GTK+ Radiobutton wrapper - */ -class nsRadioButton : public nsWidget, - public nsIRadioButton -{ - -public: - nsRadioButton(); - virtual ~nsRadioButton(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsIRadioButton part - NS_IMETHOD SetLabel(const nsString& aText); - NS_IMETHOD GetLabel(nsString& aBuffer); - NS_IMETHOD SetState(const PRBool aState); - NS_IMETHOD GetState(PRBool& aState); - - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; } - virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; } - virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; } - - // These are needed to Override the auto check behavior - void Armed(); - void DisArmed(); - -protected: - NS_IMETHOD CreateNative(GtkObject *parentWindow); - virtual void InitCallbacks(char * aName = nsnull); - virtual void OnDestroySignal(GtkWidget* aGtkWidget); - - // Sets background for checkbutton - virtual void SetBackgroundColorNative(GdkColor *aColorNor, - GdkColor *aColorBri, - GdkColor *aColorDark); - - GtkWidget *mLabel; - GtkWidget *mRadioButton; - -}; - -#endif // nsRadioButton_h__ diff --git a/widget/src/mac/nsRadioButton.cpp b/widget/src/mac/nsRadioButton.cpp deleted file mode 100644 index 5aa5a104e238..000000000000 --- a/widget/src/mac/nsRadioButton.cpp +++ /dev/null @@ -1,99 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsRadioButton.h" -#if TARGET_CARBON -#include -#endif - -NS_IMPL_ADDREF(nsRadioButton); -NS_IMPL_RELEASE(nsRadioButton); - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsMacControl(), nsIRadioButton() -{ - NS_INIT_REFCNT(); - gInstanceClassName = "nsRadioButton"; - SetControlType(radioButProc); -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_INTERFACE_MAP_BEGIN(nsRadioButton) - NS_INTERFACE_MAP_ENTRY(nsIRadioButton) -NS_INTERFACE_MAP_END_INHERITING(nsWindow) - -#pragma mark - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(PRBool aState) -{ - mValue = (aState ? 1 : 0); - Invalidate(PR_TRUE); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool& aState) -{ - aState = (mValue != 0); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - mLabel = aText; - Invalidate(PR_TRUE); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - aBuffer = mLabel; - return NS_OK; -} diff --git a/widget/src/mac/nsRadioButton.h b/widget/src/mac/nsRadioButton.h deleted file mode 100644 index 86808f9b7882..000000000000 --- a/widget/src/mac/nsRadioButton.h +++ /dev/null @@ -1,49 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsRadioButton_h__ -#define nsRadioButton_h__ - -#include "nsMacControl.h" -#include "nsIRadioButton.h" - - -class nsRadioButton : public nsMacControl, public nsIRadioButton -{ - -public: - nsRadioButton(); - virtual ~nsRadioButton(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsIRadioButton part - NS_IMETHOD SetLabel(const nsString& aText); - NS_IMETHOD GetLabel(nsString& aBuffer); - NS_IMETHOD SetState(const PRBool aState); - NS_IMETHOD GetState(PRBool& aState); -}; - -#endif // nsRadioButton_h__ diff --git a/widget/src/mac/nsWidgetFactory.cpp b/widget/src/mac/nsWidgetFactory.cpp index 3d7ddfde6e48..e7b2195868be 100644 --- a/widget/src/mac/nsWidgetFactory.cpp +++ b/widget/src/mac/nsWidgetFactory.cpp @@ -64,8 +64,6 @@ #if USE_NATIVE_VERSION # include "nsTextAreaWidget.h" # include "nsListBox.h" -# include "nsComboBox.h" -# include "nsRadioButton.h" # include "nsCheckButton.h" #endif @@ -91,9 +89,7 @@ static NS_DEFINE_CID(kCButton, NS_BUTTON_CID); static NS_DEFINE_CID(kCCheckButton, NS_CHECKBUTTON_CID); static NS_DEFINE_CID(kCFilePicker, NS_FILEPICKER_CID); static NS_DEFINE_CID(kCFileOpen, NS_FILEWIDGET_CID); -static NS_DEFINE_CID(kCCombobox, NS_COMBOBOX_CID); static NS_DEFINE_CID(kCListbox, NS_LISTBOX_CID); -static NS_DEFINE_CID(kCRadioButton, NS_RADIOBUTTON_CID); static NS_DEFINE_CID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_CID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); static NS_DEFINE_CID(kCTextArea, NS_TEXTAREA_CID); @@ -214,12 +210,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCCheckButton)) { inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsCheckButton(); } - else if (mClassID.Equals(kCCombobox)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsComboBox(); - } - else if (mClassID.Equals(kCRadioButton)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsRadioButton(); - } else if (mClassID.Equals(kCListbox)) { inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsListBox(); } diff --git a/widget/src/mac/nsWidgetSupport.cpp b/widget/src/mac/nsWidgetSupport.cpp index b4b59a9ad68c..9491c0c12f43 100644 --- a/widget/src/mac/nsWidgetSupport.cpp +++ b/widget/src/mac/nsWidgetSupport.cpp @@ -37,7 +37,6 @@ #include "nsIWidget.h" #include "nsICheckButton.h" #include "nsIScrollbar.h" -#include "nsIRadioButton.h" #include "nsITextWidget.h" @@ -95,31 +94,6 @@ NS_CreateCheckButton(nsISupports* aParent, -NS_WIDGET nsresult -NS_CreateRadioButton( nsISupports* aParent, - nsIRadioButton* aRadioButton, - const nsRect& aRect, - EVENT_CALLBACK aHandleEventFunction, - const nsFont* aFont) -{ - nsIWidget* parent = nsnull; - if (aParent != nsnull) - aParent->QueryInterface(NS_GET_IID(nsIWidget),(void**)&parent); - - nsIWidget* widget; - if (NS_OK == aRadioButton->QueryInterface(NS_GET_IID(nsIWidget),(void**)&widget)) { - widget->Create(parent, aRect, aHandleEventFunction, NULL); - widget->Show(PR_TRUE); - if (aFont != nsnull) - widget->SetFont(*aFont); - NS_IF_RELEASE(widget); - } - if (aParent != nsnull) - NS_IF_RELEASE(parent); - return NS_OK; -} - - NS_WIDGET nsresult NS_CreateLabel( nsISupports* aParent, nsILabel* aLabel, diff --git a/widget/src/motif/Makefile.in b/widget/src/motif/Makefile.in index d3a199fbba8f..73e12a1c482b 100644 --- a/widget/src/motif/Makefile.in +++ b/widget/src/motif/Makefile.in @@ -45,7 +45,6 @@ CPPSRCS = \ nsMenuBar.cpp \ nsMenuItem.cpp \ nsPopUpMenu.cpp \ - nsRadioButton.cpp \ nsScrollbar.cpp \ nsTextAreaWidget.cpp \ nsTextHelper.cpp \ diff --git a/widget/src/motif/nsRadioButton.cpp b/widget/src/motif/nsRadioButton.cpp deleted file mode 100644 index c3bb2363ad01..000000000000 --- a/widget/src/motif/nsRadioButton.cpp +++ /dev/null @@ -1,290 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include -#include - -#include "nsRadioButton.h" -#include "nsString.h" - -#include "nsXtEventHandler.h" - -NS_IMPL_ADDREF(nsRadioButton) -NS_IMPL_RELEASE(nsRadioButton) - -//------------------------------------------------------------------------- -// -// nsRadioButton constructor -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsWindow(), nsIRadioButton() -{ - NS_INIT_REFCNT(); -} - - -//------------------------------------------------------------------------- -// -// nsRadioButton destructor -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kIRadioButtonIID)) { - *aInstancePtr = (void*) ((nsIRadioButton*)this); - AddRef(); - result = NS_OK; - } - return result; -} - - -//------------------------------------------------------------------------- -// -// nsRadioButton Creator -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - aParent->AddChild(this); - Widget parentWidget = nsnull; - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else { - parentWidget = (Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL); - } - - InitToolkit(aToolkit, aParent); - InitDeviceContext(aContext, parentWidget); - - mWidget = ::XmCreateRadioBox(parentWidget, "radio", nsnull, 0); - XtVaSetValues(mWidget, XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNx, aRect.x, - XmNy, aRect.y, - XmNrecomputeSize, False, - XmNresizeHeight, False, - XmNresizeWidth, False, - XmNradioAlwaysOne, False, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNadjustMargin, False, - XmNspacing, 0, - XmNisAligned, False, - XmNentryBorder, 0, - XmNorientation, XmVERTICAL, - XmNborderWidth, 0, - 0); - - mRadioBtn = ::XmCreateToggleButton(mWidget, "", nsnull, 0); - - XtVaSetValues(mRadioBtn, - XmNwidth, aRect.width, - XmNheight, aRect.height, - XmNx, 0, - XmNy, 0, - XmNrecomputeSize, False, - XmNresizeHeight, False, - XmNresizeWidth, False, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - XmNadjustMargin, False, - XmNspacing, 0, - XmNisAligned, False, - XmNentryBorder, 0, - XmNborderWidth, 0, - 0); - - XtManageChild(mRadioBtn); - - // save the event callback function - mEventCallback = aHandleEventFunction; - - InitCallbacks(); - - XtAddCallback(mRadioBtn, - XmNarmCallback, - nsXtWidget_RadioButton_ArmCallback, - this); - - XtAddCallback(mRadioBtn, - XmNdisarmCallback, - nsXtWidget_RadioButton_DisArmCallback, - this); - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsRadioButton Creator -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NS_ERROR_FAILURE; -} - -//------------------------------------------------------------------------- -// -// Armed -// -//------------------------------------------------------------------------- -void nsRadioButton::Armed() -{ - mIsArmed = PR_TRUE; - mValueWasSet = PR_FALSE; - mInitialState = XmToggleButtonGetState(mRadioBtn); -} - -//------------------------------------------------------------------------- -// -// DisArmed -// -//------------------------------------------------------------------------- -void nsRadioButton::DisArmed() -{ - if (mValueWasSet) { - XmToggleButtonSetState(mRadioBtn, mNewValue, TRUE); - } else { - XmToggleButtonSetState(mRadioBtn, mInitialState, TRUE); - } - mIsArmed = PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(const PRBool aState) -{ - if (mIsArmed) { - mNewValue = aState; - mValueWasSet = PR_TRUE; - } - XmToggleButtonSetState(mRadioBtn, aState, TRUE); - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool& aState) -{ - int state = XmToggleButtonGetState(mRadioBtn); - if (mIsArmed) { - if (mValueWasSet) { - return mNewValue; - } else { - return state; - } - } else { - return state; - } -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - NS_ALLOC_STR_BUF(label, aText, 256); - XmString str; - str = XmStringCreate(label, XmFONTLIST_DEFAULT_TAG); - XtVaSetValues(mRadioBtn, XmNlabelString, str, nsnull); - NS_FREE_STR_BUF(label); - XmStringFree(str); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - XmString str; - XtVaGetValues(mRadioBtn, XmNlabelString, &str, nsnull); - char * text; - if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &text)) { - aBuffer.SetLength(0); - aBuffer.Append(text); - XtFree(text); - } - XmStringFree(str); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsRadioButton::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsRadioButton::OnPaint(nsPaintEvent &aEvent) -{ - return PR_FALSE; -} - -PRBool nsRadioButton::OnResize(nsSizeEvent &aEvent) -{ - return PR_FALSE; -} - diff --git a/widget/src/motif/nsRadioButton.h b/widget/src/motif/nsRadioButton.h deleted file mode 100644 index 909a8f949b9a..000000000000 --- a/widget/src/motif/nsRadioButton.h +++ /dev/null @@ -1,88 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsRadioButton_h__ -#define nsRadioButton_h__ - -#include "nsWindow.h" -#include "nsIRadioButton.h" - -/** - * Native Motif Radiobutton wrapper - */ -class nsRadioButton : public nsWindow, - public nsIRadioButton -{ - -public: - nsRadioButton(); - virtual ~nsRadioButton(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsIRadioButton 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 Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - // nsIRadioButton part - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnPaint(nsPaintEvent &aEvent); - virtual PRBool OnResize(nsSizeEvent &aEvent); - - - // These are needed to Override the auto check behavior - void Armed(); - void DisArmed(); - -private: - - Widget mRadioBtn; - Boolean mInitialState; - Boolean mNewValue; - Boolean mValueWasSet; - Boolean mIsArmed; - -}; - -#endif // nsRadioButton_h__ diff --git a/widget/src/motif/nsWidgetFactory.cpp b/widget/src/motif/nsWidgetFactory.cpp index 8a54570ff733..f6043670d64d 100644 --- a/widget/src/motif/nsWidgetFactory.cpp +++ b/widget/src/motif/nsWidgetFactory.cpp @@ -33,7 +33,6 @@ #include "nsButton.h" #include "nsScrollbar.h" #include "nsCheckButton.h" -#include "nsRadioButton.h" #include "nsTextWidget.h" #include "nsTextAreaWidget.h" #include "nsFileWidget.h" @@ -63,7 +62,6 @@ static NS_DEFINE_IID(kCButton, NS_BUTTON_CID); static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID); static NS_DEFINE_IID(kCFileOpen, NS_FILEWIDGET_CID); static NS_DEFINE_IID(kCListbox, NS_LISTBOX_CID); -static NS_DEFINE_IID(kCRadioButton, NS_RADIOBUTTON_CID); static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); static NS_DEFINE_IID(kCTextArea, NS_TEXTAREA_CID); @@ -178,9 +176,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCCheckButton)) { inst = (nsISupports*)(nsIWidget *)new nsCheckButton(); } - else if (mClassID.Equals(kCRadioButton)) { - inst = (nsISupports*)(nsIWidget *)new nsRadioButton(); - } else if (mClassID.Equals(kCFileOpen)) { inst = (nsISupports*)(nsIWidget *)new nsFileWidget(); } diff --git a/widget/src/motif/nsXtEventHandler.cpp b/widget/src/motif/nsXtEventHandler.cpp index 130825f0a696..2841f4c3d321 100644 --- a/widget/src/motif/nsXtEventHandler.cpp +++ b/widget/src/motif/nsXtEventHandler.cpp @@ -28,7 +28,6 @@ #include "nsWindow.h" #include "nsTextWidget.h" #include "nsCheckButton.h" -#include "nsRadioButton.h" #include "nsFileWidget.h" #include "nsGUIEvent.h" #include "nsIMenuItem.h" @@ -321,29 +320,6 @@ void nsXtWidget_Toggle_DisArmCallback(Widget w, XtPointer p, XtPointer call_data checkBtn->DisArmed(); } -//============================================================== -void nsXtWidget_RadioButton_ArmCallback(Widget w, XtPointer p, XtPointer call_data) -{ - nsRadioButton * radioBtn = (nsRadioButton *) p ; - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data; - radioBtn->Armed(); - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN); - radioBtn->DispatchMouseEvent(mevent); -} - -//============================================================== -void nsXtWidget_RadioButton_DisArmCallback(Widget w, XtPointer p, XtPointer call_data) -{ - nsRadioButton * radioBtn = (nsRadioButton *) p ; - XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data; - radioBtn->DisArmed(); - nsMouseEvent mevent; - nsXtWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP); - radioBtn->DispatchMouseEvent(mevent); -} - - //============================================================== void nsXtWidget_Scrollbar_Callback(Widget w, XtPointer p, XtPointer call_data) { diff --git a/widget/src/photon/nsRadioButton.cpp b/widget/src/photon/nsRadioButton.cpp deleted file mode 100644 index 664929d5bdc3..000000000000 --- a/widget/src/photon/nsRadioButton.cpp +++ /dev/null @@ -1,277 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsRadioButton.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsStringUtil.h" -#include - -#include "nsILookAndFeel.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" - -#include "nsIDeviceContext.h" -#include "nsIFontMetrics.h" - -#include "nsPhWidgetLog.h" - -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); -static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); - - -NS_IMPL_ADDREF(nsRadioButton) -NS_IMPL_RELEASE(nsRadioButton) - -//------------------------------------------------------------------------- -// -// nsRadioButton constructor -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton() -{ - NS_INIT_REFCNT(); -} - -//------------------------------------------------------------------------- -// -// nsRadioButton destructor -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton::~nsRadioButton - Not Implemented!\n")); -} - -nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton:QueryInterface, mWidget=%p\n", mWidget)); - - if (NULL == aInstancePtr) - { - return NS_ERROR_NULL_POINTER; - } - - static NS_DEFINE_IID(kIRadioButton, NS_IRADIOBUTTON_IID); - if (aIID.Equals(kIRadioButton)) { - *aInstancePtr = (void*) ((nsIRadioButton*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return nsWidget::QueryInterface(aIID,aInstancePtr); -} - -//------------------------------------------------------------------------- -// -// Set the RadioButton State -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(const PRBool aState) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsRadioButton:SetState, mWidget=%p new state is <%d>\n", mWidget, aState)); - nsresult res = NS_ERROR_FAILURE; - - mState = aState; - if (mWidget) - { - PtArg_t arg; - - if (mState) - PtSetArg( &arg, Pt_ARG_FLAGS, Pt_SET, Pt_SET ); - else - PtSetArg( &arg, Pt_ARG_FLAGS, 0, Pt_SET ); - - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - res = NS_OK; - } - - return res; -} - -//------------------------------------------------------------------------- -// -// Get the RadioButton State -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool & aState) -{ -// PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsRadioButton:GetState, mWidget=%p\n", mWidget)); - nsresult res = NS_ERROR_FAILURE; - - if (mWidget) - { - PtArg_t arg; - long *flags; - - PtSetArg( &arg, Pt_ARG_FLAGS, &flags, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - if( *flags & Pt_SET ) - mState = PR_TRUE; - else - mState = PR_FALSE; - - res = NS_OK; - } - } - - aState = mState; - - return res; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - nsresult res = NS_ERROR_FAILURE; - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsRadioButton:SetLabel, mWidget=%p\n", mWidget)); - if( mWidget ) - { - PtArg_t arg; - - NS_ALLOC_STR_BUF(label, aText, aText.Length()); - - PtSetArg( &arg, Pt_ARG_TEXT_STRING, label, 0 ); - if( PtSetResources( mWidget, 1, &arg ) == 0 ) - res = NS_OK; - - NS_FREE_STR_BUF(label); - } - - return res; -} - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - nsresult res = NS_ERROR_FAILURE; - - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton::GetLabel\n")); - - aBuffer.SetLength(0); - - if( mWidget ) - { - PtArg_t arg; - char *label; - - PtSetArg( &arg, Pt_ARG_TEXT_STRING, &label, 0 ); - if( PtGetResources( mWidget, 1, &arg ) == 0 ) - { - aBuffer.Append( label ); - res = NS_OK; - } - } - - return res; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsRadioButton::OnMove(PRInt32, PRInt32) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton::OnMove - Not Implemented\n")); - return PR_FALSE; -} - -PRBool nsRadioButton::OnPaint() -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton::OnPaint - Not Implemented\n")); - return PR_FALSE; -} - -PRBool nsRadioButton::OnResize(nsRect &aWindowRect) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton::OnResize - Not Implemented\n")); - return PR_FALSE; -} - - -/** - * Renders the RadioButton for Printing - * - **/ -NS_METHOD nsRadioButton::Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsRadioButton::Paint - Not Implemented\n")); - return NS_OK; -} - - -NS_METHOD nsRadioButton::CreateNative( PtWidget_t* aParent ) -{ - nsresult res = NS_ERROR_FAILURE; - PtArg_t arg[15]; - PhPoint_t pos; - PhDim_t dim; - - PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsRadioButton::CreateNative\n")); - - pos.x = mBounds.x; - pos.y = mBounds.y; - dim.w = mBounds.width; - dim.h = mBounds.height; - - PtSetArg( &arg[0], Pt_ARG_POS, &pos, 0 ); - PtSetArg( &arg[1], Pt_ARG_DIM, &dim, 0 ); - PtSetArg( &arg[2], Pt_ARG_BORDER_WIDTH, 0, 0 ); - PtSetArg( &arg[3], Pt_ARG_INDICATOR_TYPE, Pt_RADIO, 0 ); - PtSetArg( &arg[4], Pt_ARG_INDICATOR_COLOR, Pg_BLACK, 0 ); - PtSetArg( &arg[5], Pt_ARG_SPACING, 0, 0 ); - PtSetArg( &arg[6], Pt_ARG_MARGIN_TOP, 0, 0 ); - PtSetArg( &arg[7], Pt_ARG_MARGIN_LEFT, 0, 0 ); - PtSetArg( &arg[8], Pt_ARG_MARGIN_BOTTOM, 0, 0 ); - PtSetArg( &arg[9], Pt_ARG_MARGIN_RIGHT, 0, 0 ); - PtSetArg( &arg[10], Pt_ARG_MARGIN_WIDTH, 0, 0 ); - PtSetArg( &arg[11], Pt_ARG_MARGIN_HEIGHT, 0, 0 ); - PtSetArg( &arg[12], Pt_ARG_VERTICAL_ALIGNMENT, Pt_TOP, 0 ); -// PtSetArg( &arg[13], Pt_ARG_TEXT_FONT, "helv08", 0 ); - - mWidget = PtCreateWidget( PtToggleButton, aParent, 13, arg ); - if( mWidget ) - { - PtAddEventHandler( mWidget, - Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY, - RawEventHandler, this ); - - res = NS_OK; - } - - return res; -} - diff --git a/widget/src/photon/nsRadioButton.h b/widget/src/photon/nsRadioButton.h deleted file mode 100644 index ad77eb353928..000000000000 --- a/widget/src/photon/nsRadioButton.h +++ /dev/null @@ -1,69 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsRadioButton_h__ -#define nsRadioButton_h__ - -#include "nsWidget.h" -#include "nsIRadioButton.h" -#include - -/** - * Native Photon Radio Button wrapper - */ - -class nsRadioButton : public nsWidget, public nsIRadioButton -{ - -public: - nsRadioButton(); - virtual ~nsRadioButton(); - - //nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - // nsIRadioButton part - NS_IMETHOD SetLabel(const nsString& aText); - NS_IMETHOD GetLabel(nsString& aBuffer); - NS_IMETHOD SetState(const PRBool aState); - NS_IMETHOD GetState(PRBool & aState); - - // nsBaseWidget - NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - virtual PRBool OnPaint(); - virtual PRBool OnResize(nsRect &aWindowRect); - -protected: - - NS_IMETHOD CreateNative( PtWidget_t* aParent ); - static int handle_activate_event (PtWidget_t *aWidget, void *aData, PtCallbackInfo_t *aCbinfo ); - - PRBool mState; - -}; - -#endif // nsRadioButton_h__ diff --git a/widget/src/qt/.cvsignore b/widget/src/qt/.cvsignore index d17129b1cb52..e82313c73c89 100644 --- a/widget/src/qt/.cvsignore +++ b/widget/src/qt/.cvsignore @@ -9,5 +9,4 @@ moc_nsCheckButton.cpp moc_nsTextWidget.cpp moc_nsTabWidget.cpp moc_nsQEventHandler.cpp -moc_nsRadioButton.cpp moc_nsWindow.cpp diff --git a/widget/src/qt/nsRadioButton.cpp b/widget/src/qt/nsRadioButton.cpp deleted file mode 100644 index 96d4f6097907..000000000000 --- a/widget/src/qt/nsRadioButton.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape 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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsRadioButton.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsString.h" -#include "nsStringUtil.h" - -//============================================================================= -// -// nsQRadioButton class -// -//============================================================================= -nsQRadioButton::nsQRadioButton(nsWidget * widget, - QWidget * parent, - const char * name) - : QRadioButton(parent, name), nsQBaseWidget(widget) -{ -} - -nsQRadioButton::~nsQRadioButton() -{ -} - -NS_IMPL_ADDREF(nsRadioButton) -NS_IMPL_RELEASE(nsRadioButton) - -//------------------------------------------------------------------------- -// -// nsRadioButton constructor -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton() -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsRadioButton::nsRadioButton()\n")); -} - - -//------------------------------------------------------------------------- -// -// nsRadioButton destructor -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsRadioButton::~nsRadioButton()\n")); - if (mWidget) - { - delete ((nsQRadioButton *) mWidget); - mWidget = nsnull; - } -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsRadioButton::QueryInterface()\n")); - nsresult result = nsWidget::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kIRadioButtonIID)) - { - *aInstancePtr = (void*) ((nsIRadioButton*)this); - AddRef(); - result = NS_OK; - } - return result; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(const PRBool aState) -{ - PRBool newState; - GetState(newState); - - PR_LOG(QtWidgetsLM, - PR_LOG_DEBUG, - ("nsRadioButton::SetState() %p:%d\n", mWidget, aState)); - ((QRadioButton *)mWidget)->setChecked(aState); - - GetState(newState); - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get this button state -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool& aState) -{ - aState = ((QRadioButton *)mWidget)->isChecked(); - PR_LOG(QtWidgetsLM, - PR_LOG_DEBUG, - ("nsRadioButton::GetState() %p:%d\n", mWidget, aState)); - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsRadioButton::SetLabel()\n")); - NS_ALLOC_STR_BUF(label, aText, 256); - - ((QRadioButton *)mWidget)->setText(label); - - NS_FREE_STR_BUF(label); - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsRadioButton::GetLabel()\n")); - QString string = ((QRadioButton *)mWidget)->text(); - aBuffer.SetLength(0); - aBuffer.AppendWithConversion((const char *) string); - - return NS_OK; -} diff --git a/widget/src/qt/nsRadioButton.h b/widget/src/qt/nsRadioButton.h deleted file mode 100644 index c382675a0721..000000000000 --- a/widget/src/qt/nsRadioButton.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape 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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsRadioButton_h__ -#define nsRadioButton_h__ - -#include "nsWidget.h" -#include "nsIRadioButton.h" -#include - -//============================================================================= -// -// nsQRadioButton class -// -//============================================================================= -class nsQRadioButton : public QRadioButton, public nsQBaseWidget -{ - Q_OBJECT -public: - nsQRadioButton(nsWidget * widget, - QWidget * parent = 0, - const char * name = 0); - ~nsQRadioButton(); - -protected: -#if 0 - bool eventFilter(QObject * object, QEvent * event); - virtual void mousePressedEvent(QMouseEvent * event); - virtual void mouseReleasedEvent(QMouseEvent * event); -#endif -}; - -/** - * Native QT Radiobutton wrapper - */ -class nsRadioButton : public nsWidget, - public nsIRadioButton -{ - -public: - nsRadioButton(); - virtual ~nsRadioButton(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - // nsIRadioButton part - NS_IMETHOD SetLabel(const nsString& aText); - NS_IMETHOD GetLabel(nsString& aBuffer); - NS_IMETHOD SetState(const PRBool aState); - NS_IMETHOD GetState(PRBool& aState); - - virtual PRBool OnMove(PRInt32 aX, PRInt32 aY) { return PR_FALSE; } - virtual PRBool OnPaint(nsPaintEvent &aEvent) { return PR_FALSE; } - virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; } - - // These are needed to Override the auto check behavior - void Armed(); - void DisArmed(); - -protected: - -protected: - QWidget *mLabel; -}; - -#endif // nsRadioButton_h__ diff --git a/widget/src/windows/nsRadioButton.cpp b/widget/src/windows/nsRadioButton.cpp deleted file mode 100644 index ce067355de2b..000000000000 --- a/widget/src/windows/nsRadioButton.cpp +++ /dev/null @@ -1,256 +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.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/NPL/ - * - * 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 Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsRadioButton.h" -#include "nsToolkit.h" -#include "nsColor.h" -#include "nsGUIEvent.h" -#include "nsStringUtil.h" -#include - -#include "nsILookAndFeel.h" -#include "nsWidgetsCID.h" -#include "nsIComponentManager.h" - -#include "nsIDeviceContext.h" - -NS_IMPL_ADDREF(nsRadioButton) -NS_IMPL_RELEASE(nsRadioButton) - -//------------------------------------------------------------------------- -// -// nsRadioButton constructor -// -//------------------------------------------------------------------------- -nsRadioButton::nsRadioButton() : nsWindow(), nsIRadioButton() -{ - NS_INIT_REFCNT(); -} - - -//------------------------------------------------------------------------- -// -// nsRadioButton destructor -// -//------------------------------------------------------------------------- -nsRadioButton::~nsRadioButton() -{ -} - - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = nsWindow::QueryInterface(aIID, aInstancePtr); - - static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kIRadioButtonIID)) { - *aInstancePtr = (void*) ((nsIRadioButton*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - return result; - } - -//------------------------------------------------------------------------- -// -// Sets the state of the nsRadioButton -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetState(const PRBool aState) -{ - fState = aState; - ::SendMessage(GetWindowHandle(), BM_SETCHECK, (WPARAM)(fState), 0L); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetState(PRBool& aState) -{ - aState = fState; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::SetLabel(const nsString& aText) -{ - char label[256]; - aText.ToCString(label, 256); - label[255] = '\0'; - VERIFY(::SetWindowText(mWnd, label)); - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get this button label -// -//------------------------------------------------------------------------- -NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer) -{ - int actualSize = ::GetWindowTextLength(mWnd)+1; - NS_ALLOC_CHAR_BUF(label, 256, actualSize); - ::GetWindowText(mWnd, label, actualSize); - aBuffer.SetLength(0); - aBuffer.Append(label); - NS_FREE_CHAR_BUF(label); - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// move, paint, resizes message - ignore -// -//------------------------------------------------------------------------- -PRBool nsRadioButton::OnMove(PRInt32, PRInt32) -{ - return PR_FALSE; -} - -PRBool nsRadioButton::OnPaint() -{ - return PR_FALSE; -} - -PRBool nsRadioButton::OnResize(nsRect &aWindowRect) -{ - return PR_FALSE; -} - -//------------------------------------------------------------------------- -// -// return the window class name and initialize the class if needed -// -//------------------------------------------------------------------------- -LPCTSTR nsRadioButton::WindowClass() -{ - return "BUTTON"; -} - - -//------------------------------------------------------------------------- -// -// return window styles -// -//------------------------------------------------------------------------- -DWORD nsRadioButton::WindowStyle() -{ - return BS_RADIOBUTTON | WS_CHILD | WS_CLIPSIBLINGS; -} - - -//------------------------------------------------------------------------- -// -// return window extended styles -// -//------------------------------------------------------------------------- -DWORD nsRadioButton::WindowExStyle() -{ - return 0; -} - -/** - * Renders the RadioButton for Printing - * - **/ -NS_METHOD nsRadioButton::Paint(nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect) -{ - float appUnits; - float scale; - nsIDeviceContext * context; - aRenderingContext.GetDeviceContext(context); - - context->GetCanonicalPixelScale(scale); - context->GetDevUnitsToAppUnits(appUnits); - nsRect rect; - GetBounds(rect); - - rect.x++; - rect.y++; - rect.width -= 2; - rect.height -= 2; - aRenderingContext.SetColor(NS_RGB(0,0,0)); - - nscoord one = nscoord(PRFloat64(rect.width) * 1.0/12.0); - - rect.x = nscoord((PRFloat64)rect.x * appUnits); - rect.y = nscoord((PRFloat64)rect.y * appUnits); - rect.width = nscoord((PRFloat64)rect.width * appUnits); - rect.height = nscoord((PRFloat64)rect.height * appUnits); - rect.x += one; - rect.width = nscoord(PRFloat64(rect.width) * 11.0/12.0); - rect.height = nscoord(PRFloat64(rect.height) * 11.0/12.0); - - for (nscoord i=0;i