part of 93467 - remove old native radiobutton code. r=blizzard, sr=hyatt.

This commit is contained in:
bryner%netscape.com 2001-08-08 04:01:11 +00:00
Родитель c8d60373da
Коммит b459088f4a
29 изменённых файлов: 0 добавлений и 2415 удалений

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

@ -14,7 +14,6 @@ nsIListBox.h
nsIScrollbar.h
nsGUIEvent.h
nsEvent.h
nsIRadioButton.h
nsIMouseListener.h
nsIEventListener.h
nsIFileWidget.h

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

@ -50,7 +50,6 @@ EXPORTS = \
nsIScrollbar.h \
nsGUIEvent.h \
nsEvent.h \
nsIRadioButton.h \
nsIMouseListener.h \
nsIEventListener.h \
nsIMenuListener.h \

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

@ -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__

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

@ -47,7 +47,6 @@ CPPSRCS = \
nsLookAndFeel.cpp \
nsObject.cpp \
nsPopUpMenu.cpp \
nsRadioButton.cpp \
nsScrollbar.cpp \
nsSound.cpp \
nsTextAreaWidget.cpp \

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

@ -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<nscoord(scale*1.25);i++) {
aRenderingContext.DrawArc(rect, 0, 180);
aRenderingContext.DrawArc(rect, 180, 360);
rect.x++;
rect.y++;
rect.width -= 2;
rect.height -= 2;
}
if (fState) {
GetBounds(rect);
nscoord xHalf = rect.width / 4;
nscoord yHalf = rect.height / 4;
rect.x += xHalf;
rect.y += yHalf;
rect.width -= xHalf*2;
rect.height -= yHalf*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);
aRenderingContext.FillArc(rect, 0, 180);
aRenderingContext.FillArc(rect, 180, 360);
}
NS_RELEASE(context);
return NS_OK;
}
BView *nsRadioButton::CreateBeOSView()
{
return mRadioButton = new nsRadioButtonBeOS(this, BRect(0, 0, 0, 0), "", "", NULL);
}
//-------------------------------------------------------------------------
// Sub-class of BeOS RadioButton
//-------------------------------------------------------------------------
nsRadioButtonBeOS::nsRadioButtonBeOS( nsIWidget *aWidgetWindow, BRect aFrame,
const char *aName, const char *aLabel, BMessage *aMessage,
uint32 aResizingMode, uint32 aFlags )
: BRadioButton( aFrame, aName, aLabel, aMessage, aResizingMode, aFlags ),
nsIWidgetStore( aWidgetWindow )
{
}

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

@ -1,82 +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 "nsdefs.h"
#include "nsWindow.h"
#include "nsSwitchToUIThread.h"
#include "nsString.h"
#include "nsIRadioButton.h"
#include <RadioButton.h>
/**
* 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__

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

@ -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();
}

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

@ -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,

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

@ -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 <gtk/gtk.h>
#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);
}

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

@ -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__

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

@ -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 <ControlDefinitions.h>
#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;
}

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

@ -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__

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

@ -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();
}

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

@ -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,

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

@ -45,7 +45,6 @@ CPPSRCS = \
nsMenuBar.cpp \
nsMenuItem.cpp \
nsPopUpMenu.cpp \
nsRadioButton.cpp \
nsScrollbar.cpp \
nsTextAreaWidget.cpp \
nsTextHelper.cpp \

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

@ -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 <Xm/ToggleB.h>
#include <Xm/RowColumn.h>
#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;
}

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

@ -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__

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

@ -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();
}

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

@ -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)
{

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

@ -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 <Pt.h>
#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;
}

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

@ -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 <Pt.h>
/**
* 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__

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

@ -9,5 +9,4 @@ moc_nsCheckButton.cpp
moc_nsTextWidget.cpp
moc_nsTabWidget.cpp
moc_nsQEventHandler.cpp
moc_nsRadioButton.cpp
moc_nsWindow.cpp

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

@ -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;
}

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

@ -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 <qradiobutton.h>
//=============================================================================
//
// 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__

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

@ -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 <windows.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;
::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<nscoord(scale*1.25);i++) {
aRenderingContext.DrawArc(rect, 0, 180);
aRenderingContext.DrawArc(rect, 180, 360);
rect.x++;
rect.y++;
rect.width -= 2;
rect.height -= 2;
}
if (fState) {
GetBounds(rect);
nscoord xHalf = rect.width / 4;
nscoord yHalf = rect.height / 4;
rect.x += xHalf;
rect.y += yHalf;
rect.width -= xHalf*2;
rect.height -= yHalf*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);
aRenderingContext.FillArc(rect, 0, 180);
aRenderingContext.FillArc(rect, 180, 360);
}
NS_RELEASE(context);
return NS_OK;
}

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

@ -1,74 +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 "nsdefs.h"
#include "nsWindow.h"
#include "nsSwitchToUIThread.h"
#include "nsString.h"
#include "nsIRadioButton.h"
/**
* 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();
virtual PRBool OnResize(nsRect &aWindowRect);
protected:
PRBool fState;
virtual LPCTSTR WindowClass();
virtual DWORD WindowStyle();
virtual DWORD WindowExStyle();
};
#endif // nsRadioButton_h__

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

@ -51,7 +51,6 @@ CPPSRCS = \
nsMenuBar.cpp \
nsMenuItem.cpp \
nsPopUpMenu.cpp \
nsRadioButton.cpp \
nsScrollBar.cpp \
nsSound.cpp \
nsTextAreaWidget.cpp \

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

@ -1,74 +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"
NS_IMPL_ADDREF(nsRadioButton)
NS_IMPL_RELEASE(nsRadioButton)
nsRadioButton::nsRadioButton() : nsWidget(), nsIRadioButton()
{
NS_INIT_REFCNT();
}
nsRadioButton::~nsRadioButton()
{
}
nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
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);
NS_ADDREF_THIS();
result = NS_OK;
}
return result;
}
NS_METHOD nsRadioButton::SetState(const PRBool aState)
{
return NS_OK;
}
NS_METHOD nsRadioButton::GetState(PRBool& aState)
{
return NS_OK;
}
NS_METHOD nsRadioButton::SetLabel(const nsString& aText)
{
return NS_OK;
}
NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer)
{
return NS_OK;
}
NS_METHOD nsRadioButton::Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
return NS_OK;
}

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

@ -1,61 +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 Win32 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);
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
protected:
};
#endif // nsRadioButton_h__