зеркало из https://github.com/mozilla/pjs.git
Synch with new widget interfaces
This commit is contained in:
Родитель
e33899dd67
Коммит
03b192b61c
|
@ -29,54 +29,40 @@
|
|||
#include <quickdraw.h>
|
||||
|
||||
|
||||
#define DBG 0
|
||||
NS_IMPL_ADDREF(nsButton)
|
||||
NS_IMPL_RELEASE(nsButton)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsButton constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsButton::nsButton(nsISupports *aOuter) : nsWindow(aOuter)
|
||||
nsButton::nsButton()
|
||||
{
|
||||
strcpy(gInstanceClassName, "nsButton");
|
||||
mWidgetArmed = PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert an nsPoint into mac local coordinated.
|
||||
* The tree hierarchy is navigated upwards, changing
|
||||
* the x,y offset by the parent's coordinates
|
||||
*
|
||||
*/
|
||||
void nsButton::LocalToWindowCoordinate(nsPoint& aPoint)
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
nsIWidget* parent = GetParent();
|
||||
nsRect bounds;
|
||||
|
||||
while (parent)
|
||||
{
|
||||
parent->GetBounds(bounds);
|
||||
aPoint.x += bounds.x;
|
||||
aPoint.y += bounds.y;
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
}
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an nsRect's local coordinates to global coordinates
|
||||
*/
|
||||
void nsButton::LocalToWindowCoordinate(nsRect& aRect)
|
||||
{
|
||||
nsIWidget* parent = GetParent();
|
||||
nsRect bounds;
|
||||
|
||||
while (parent)
|
||||
{
|
||||
parent->GetBounds(bounds);
|
||||
aRect.x += bounds.x;
|
||||
aRect.y += bounds.y;
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID);
|
||||
if (aIID.Equals(kIButton)) {
|
||||
*aInstancePtr = (void*) ((nsIButton*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,8 +76,6 @@ void nsButton::Create(nsIWidget *aParent,
|
|||
{
|
||||
mParent = aParent;
|
||||
aParent->AddChild(this);
|
||||
|
||||
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);
|
||||
|
||||
WindowPtr window = nsnull;
|
||||
|
||||
|
@ -111,16 +95,6 @@ void nsButton::Create(nsIWidget *aParent,
|
|||
{
|
||||
InitToolkit(aToolkit, aParent);
|
||||
// InitDeviceContext(aContext, parentWidget);
|
||||
|
||||
if (DBG) fprintf(stderr, "Parent 0x%x\n", window);
|
||||
|
||||
// NOTE: CREATE MACINTOSH CONTROL HERE
|
||||
Str255 title = "";
|
||||
Boolean visible = PR_TRUE;
|
||||
PRInt16 initialValue = 0;
|
||||
PRInt16 minValue = 0;
|
||||
PRInt16 maxValue = 1;
|
||||
PRInt16 ctrlType = pushButProc;
|
||||
|
||||
// Set the bounds to the local rect
|
||||
SetBounds(aRect);
|
||||
|
@ -136,9 +110,6 @@ void nsButton::Create(nsIWidget *aParent,
|
|||
mWindowRegion = NewRgn();
|
||||
SetRectRgn(mWindowRegion,aRect.x,aRect.y,aRect.x+aRect.width,aRect.y+aRect.height);
|
||||
|
||||
|
||||
//if (DBG) fprintf(stderr, "Button 0x%x this 0x%x\n", mControl, this);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
|
@ -170,67 +141,7 @@ nsButton::~nsButton()
|
|||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsButton::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
||||
|
||||
if (aIID.Equals(kIButtonIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Convert a nsString to a PascalStr255
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsButton::StringToStr255(const nsString& aText, Str255& aStr255)
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
aText.ToCString(buffer,255);
|
||||
|
||||
PRInt32 len = strlen(buffer);
|
||||
memcpy(&aStr255[1],buffer,len);
|
||||
aStr255[0] = len;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
|
||||
NS_ASSERTION(mControl != nsnull,"Control must not be null");
|
||||
//if (mControl != nsnull)
|
||||
//{
|
||||
StringToStr255(aText,mLabel);
|
||||
//SetControlTitle(mControl,s);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -249,19 +160,6 @@ PRBool nsButton::OnResize(nsSizeEvent &aEvent)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
#define GET_OUTER() ((nsButton*) ((char*)this - nsButton::GetOuterOffset()))
|
||||
|
||||
void nsButton::AggButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
GET_OUTER()->GetLabel(aBuffer);
|
||||
}
|
||||
|
||||
void nsButton::AggButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
GET_OUTER()->SetLabel(aText);
|
||||
}
|
||||
|
||||
/*
|
||||
* @update gpk 08/27/98
|
||||
* @param aX -- x offset in widget local coordinates
|
||||
|
@ -346,9 +244,12 @@ RgnHandle thergn;
|
|||
::EraseRoundRect(¯ect,10,10);
|
||||
::PenSize(1,1);
|
||||
::FrameRoundRect(¯ect,10,10);
|
||||
|
||||
Str255 label;
|
||||
StringToStr255(mLabel, label);
|
||||
|
||||
|
||||
width = ::StringWidth(mLabel);
|
||||
width = ::StringWidth(label);
|
||||
x = (macrect.left+macrect.right)/2 - (width/2);
|
||||
|
||||
::TextFont(0);
|
||||
|
@ -359,7 +260,7 @@ RgnHandle thergn;
|
|||
//height = 6;
|
||||
y = (macrect.top+macrect.bottom)/2 + 6;
|
||||
::MoveTo(x,y);
|
||||
::DrawString(mLabel);
|
||||
::DrawString(label);
|
||||
|
||||
if(mMouseDownInButton && aMouseInside)
|
||||
::InvertRoundRect(¯ect,10,10);
|
||||
|
@ -369,9 +270,33 @@ RgnHandle thergn;
|
|||
::SetPort(theport);
|
||||
}
|
||||
|
||||
/** nsIButton Implementation **/
|
||||
|
||||
/**
|
||||
* Set the label for this object to be equal to aText
|
||||
*
|
||||
* @param Set the label to aText
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_METHOD nsButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
mLabel = aText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a buffer to be equal to this objects label
|
||||
*
|
||||
* @param Put the contents of the label into aBuffer
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_METHOD nsButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
aBuffer = mLabel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
BASE_IWIDGET_IMPL(nsButton, AggButton);
|
||||
|
||||
|
||||
|
|
|
@ -24,17 +24,20 @@
|
|||
#include "nsIButton.h"
|
||||
|
||||
/**
|
||||
* Native Motif button wrapper
|
||||
* Native Mac button wrapper
|
||||
*/
|
||||
|
||||
class nsButton : public nsWindow
|
||||
|
||||
class nsButton : public nsWindow, public nsIButton
|
||||
{
|
||||
|
||||
public:
|
||||
nsButton(nsISupports *aOuter);
|
||||
nsButton();
|
||||
virtual ~nsButton();
|
||||
|
||||
NS_IMETHOD QueryObject(const nsIID& aIID, void** aInstancePtr);
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef();
|
||||
NS_IMETHOD_(nsrefcnt) Release();
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
|
@ -51,19 +54,14 @@ public:
|
|||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
|
||||
// nsIButton part
|
||||
virtual void SetLabel(const nsString& aText);
|
||||
virtual void GetLabel(nsString& aBuffer);
|
||||
NS_IMETHOD SetLabel(const nsString& aText);
|
||||
NS_IMETHOD GetLabel(nsString& aBuffer);
|
||||
|
||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
||||
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
|
||||
|
||||
// Mac specific methods
|
||||
void LocalToWindowCoordinate(nsPoint& aPoint);
|
||||
void LocalToWindowCoordinate(nsRect& aRect);
|
||||
//ControlHandle GetControl() { return mControl; }
|
||||
|
||||
|
||||
|
||||
// Overriden from nsWindow
|
||||
virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
|
||||
|
@ -71,34 +69,9 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void StringToStr255(const nsString& aText, Str255& aStr255);
|
||||
void DrawWidget(PRBool aMouseInside);
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsButton,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIButton interface to nsButton w/o using multiple
|
||||
// inheritance.
|
||||
class AggButton : public nsIButton {
|
||||
public:
|
||||
AggButton();
|
||||
virtual ~AggButton();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
// nsIButton
|
||||
virtual void SetLabel(const nsString &aText);
|
||||
virtual void GetLabel(nsString &aBuffer);
|
||||
|
||||
};
|
||||
AggButton mAggWidget;
|
||||
friend class AggButton;
|
||||
|
||||
Str255 mLabel;
|
||||
|
||||
nsString mLabel;
|
||||
PRBool mMouseDownInButton;
|
||||
PRBool mWidgetArmed;
|
||||
|
||||
|
|
|
@ -22,19 +22,21 @@
|
|||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsCheckButton)
|
||||
NS_IMPL_RELEASE(nsCheckButton)
|
||||
|
||||
#define DBG 0
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsCheckButton constructor
|
||||
// nsButton constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsCheckButton::nsCheckButton(nsISupports *aOuter) : nsWindow(aOuter)
|
||||
nsCheckButton::nsCheckButton() : nsWindow(), nsICheckButton()
|
||||
{
|
||||
strcpy(gInstanceClassName, "nsCheckButton");
|
||||
mButtonSet = PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert an nsPoint into mac local coordinated.
|
||||
* The tree hierarchy is navigated upwards, changing
|
||||
|
@ -150,21 +152,25 @@ nsCheckButton::~nsCheckButton()
|
|||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsCheckButton::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
|
||||
if (aIID.Equals(kICheckButtonIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsCheckButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
||||
if (aIID.Equals(kICheckButtonIID)) {
|
||||
*aInstancePtr = (void*) ((nsICheckButton*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -184,27 +190,6 @@ void nsCheckButton::StringToStr255(const nsString& aText, Str255& aStr255)
|
|||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsCheckButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
mLabel = aText;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsCheckButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
aBuffer = mLabel;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -224,17 +209,6 @@ PRBool nsCheckButton::OnResize(nsSizeEvent &aEvent)
|
|||
}
|
||||
|
||||
|
||||
#define GET_OUTER() ((nsCheckButton*) ((char*)this - nsCheckButton::GetOuterOffset()))
|
||||
|
||||
void nsCheckButton::AggCheckButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
GET_OUTER()->GetLabel(aBuffer);
|
||||
}
|
||||
|
||||
void nsCheckButton::AggCheckButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
GET_OUTER()->SetLabel(aText);
|
||||
}
|
||||
|
||||
/*
|
||||
* @update gpk 08/27/98
|
||||
|
@ -353,51 +327,62 @@ Str255 tempstring;
|
|||
::SetPort(theport);
|
||||
}
|
||||
|
||||
/** nsICheckButton Implementation **/
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsCheckButton::SetState(PRBool aState)
|
||||
/**
|
||||
* Set the check state.
|
||||
* @param aState PR_TRUE show as checked. PR_FALSE show unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_METHOD nsCheckButton::SetState(PRBool aState)
|
||||
{
|
||||
int state = aState;
|
||||
|
||||
mButtonSet = aState;
|
||||
DrawWidget(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
//if (mIsArmed) {
|
||||
//mNewValue = aState;
|
||||
//mValueWasSet = PR_TRUE;
|
||||
//}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsCheckButton::GetState()
|
||||
/**
|
||||
* Get the check state.
|
||||
* @param aState PR_TRUE if checked. PR_FALSE if unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
NS_METHOD nsCheckButton::GetState(PRBool& aState)
|
||||
{
|
||||
|
||||
return(mButtonSet);
|
||||
aState = mButtonSet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define GET_OUTER() \
|
||||
((nsCheckButton*) ((char*)this - nsCheckButton::GetOuterOffset()))
|
||||
|
||||
PRBool nsCheckButton::AggCheckButton::GetState()
|
||||
/**
|
||||
* Set the label for this object to be equal to aText
|
||||
*
|
||||
* @param Set the label to aText
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_METHOD nsCheckButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
return GET_OUTER()->GetState();
|
||||
mLabel = aText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsCheckButton::AggCheckButton::SetState(PRBool aState)
|
||||
/**
|
||||
* Set a buffer to be equal to this objects label
|
||||
*
|
||||
* @param Put the contents of the label into aBuffer
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_METHOD nsCheckButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
GET_OUTER()->SetState(aState);
|
||||
aBuffer = mLabel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
BASE_IWIDGET_IMPL(nsCheckButton, AggCheckButton);
|
||||
|
||||
|
|
|
@ -24,17 +24,21 @@
|
|||
|
||||
|
||||
/**
|
||||
* Native Macintosh button wrapper
|
||||
* Native Macintosh check button wrapper
|
||||
*/
|
||||
|
||||
class nsCheckButton : public nsWindow
|
||||
class nsCheckButton : public nsWindow,
|
||||
public nsICheckButton
|
||||
{
|
||||
|
||||
public:
|
||||
nsCheckButton(nsISupports *aOuter);
|
||||
virtual ~nsCheckButton();
|
||||
nsCheckButton();
|
||||
virtual ~nsCheckButton();
|
||||
|
||||
NS_IMETHOD QueryObject(const nsIID& aIID, void** aInstancePtr);
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef();
|
||||
NS_IMETHOD_(nsrefcnt) Release();
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
|
@ -53,54 +57,28 @@ public:
|
|||
|
||||
|
||||
// nsIRadioButton part
|
||||
virtual void SetLabel(const nsString& aText);
|
||||
virtual void GetLabel(nsString& aBuffer);
|
||||
NS_IMETHOD SetLabel(const nsString& aText);
|
||||
NS_IMETHOD GetLabel(nsString& aBuffer);
|
||||
NS_IMETHOD SetState(const PRBool aState);
|
||||
NS_IMETHOD GetState(PRBool& aState);
|
||||
|
||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
||||
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
|
||||
|
||||
virtual void SetState(PRBool aState);
|
||||
virtual PRBool GetState();
|
||||
|
||||
// Overriden from nsWindow
|
||||
virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
|
||||
|
||||
// Mac specific methods
|
||||
void LocalToWindowCoordinate(nsPoint& aPoint);
|
||||
void LocalToWindowCoordinate(nsRect& aRect);
|
||||
|
||||
// Overriden from nsWindow
|
||||
virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void StringToStr255(const nsString& aText, Str255& aStr255);
|
||||
void DrawWidget(PRBool aMouseInside);
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsCheckButton,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIRadioButton interface to nsCheckButton w/o using multiple
|
||||
// inheritance.
|
||||
class AggCheckButton : public nsICheckButton {
|
||||
public:
|
||||
AggCheckButton();
|
||||
virtual ~AggCheckButton();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
// nsICheckButton
|
||||
virtual void SetLabel(const nsString &aText);
|
||||
virtual void GetLabel(nsString &aBuffer);
|
||||
virtual void SetState(PRBool aState);
|
||||
virtual PRBool GetState();
|
||||
|
||||
};
|
||||
|
||||
AggCheckButton mAggWidget;
|
||||
friend class AggCheckButton;
|
||||
|
||||
nsString mLabel;
|
||||
PRBool mMouseDownInButton;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
// nsComboBox constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsComboBox::nsComboBox(nsISupports *aOuter) : nsWindow(aOuter)
|
||||
nsComboBox::nsComboBox() : nsWindow(), nsIComboBox()
|
||||
{
|
||||
mMultiSelect = PR_FALSE;
|
||||
mBackground = NS_RGB(124, 124, 124);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* Native Motif Listbox wrapper
|
||||
*/
|
||||
|
||||
class nsComboBox : public nsWindow
|
||||
class nsComboBox : public nsWindow, public nsIComboBox
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -80,41 +80,6 @@ protected:
|
|||
int mMaxNumItems;
|
||||
int mNumItems;
|
||||
|
||||
private:
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsComboBox,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIComboBox interface to nsComboBox w/o using multiple
|
||||
// inheritance.
|
||||
class AggComboBox : public nsIComboBox {
|
||||
public:
|
||||
AggComboBox();
|
||||
virtual ~AggComboBox();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
// nsIComboBox
|
||||
void SetMultipleSelection(PRBool aMultipleSelections);
|
||||
void AddItemAt(nsString &aItem, PRInt32 aPosition);
|
||||
PRInt32 FindItem(nsString &aItem, PRInt32 aStartPos);
|
||||
PRInt32 GetItemCount();
|
||||
PRBool RemoveItemAt(PRInt32 aPosition);
|
||||
PRBool GetItemAt(nsString& anItem, PRInt32 aPosition);
|
||||
void GetSelectedItem(nsString& aItem);
|
||||
PRInt32 GetSelectedIndex();
|
||||
PRInt32 GetSelectedCount();
|
||||
void GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize);
|
||||
void SelectItem(PRInt32 aPosition);
|
||||
void Deselect() ;
|
||||
|
||||
};
|
||||
AggComboBox mAggWidget;
|
||||
friend class AggComboBox;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -17,22 +17,23 @@
|
|||
*/
|
||||
|
||||
#include "nsFileWidget.h"
|
||||
#include <Xm/FileSB.h>
|
||||
#include "nsXtEventHandler.h"
|
||||
#include "nsStringUtil.h"
|
||||
#include <StandardFile.h>
|
||||
|
||||
#define DBG 0
|
||||
extern XtAppContext gAppContext;
|
||||
|
||||
NS_IMPL_ADDREF(nsFileWidget)
|
||||
NS_IMPL_RELEASE(nsFileWidget)
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsFileWidget constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsFileWidget::nsFileWidget(nsISupports *aOuter) : nsWindow(aOuter),
|
||||
mIOwnEventLoop(PR_FALSE)
|
||||
nsFileWidget::nsFileWidget()
|
||||
{
|
||||
//mWnd = NULL;
|
||||
mIOwnEventLoop = PR_FALSE;
|
||||
mNumberOfFilters = 0;
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,7 @@ void nsFileWidget::Create(nsIWidget *aParent,
|
|||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
nsString title("Load");
|
||||
nsString title("Open");
|
||||
Create(aParent, title, eMode_load, aContext, aAppShell, aToolkit, aInitData);
|
||||
}
|
||||
|
||||
|
@ -58,42 +59,48 @@ void nsFileWidget:: Create(nsIWidget *aParent,
|
|||
nsIToolkit *aToolkit,
|
||||
void *aInitData)
|
||||
{
|
||||
//mWnd = (aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0;
|
||||
mTitle.SetLength(0);
|
||||
mTitle.Append(aTitle);
|
||||
mTitle = aTitle;
|
||||
mMode = aMode;
|
||||
|
||||
Widget parentWidget = nsnull;
|
||||
WindowPtr window = nsnull;
|
||||
|
||||
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);
|
||||
|
||||
if (aParent) {
|
||||
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
} else {
|
||||
parentWidget = (Widget) aInitData ;
|
||||
window = (WindowPtr) aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
} else if (aAppShell) {
|
||||
window = (WindowPtr) aAppShell->GetNativeData(NS_NATIVE_SHELL);
|
||||
}
|
||||
|
||||
InitToolkit(aToolkit, aParent);
|
||||
InitDeviceContext(aContext, parentWidget);
|
||||
InitDeviceContext(aContext, (nsNativeWidget)mWindowPtr);
|
||||
|
||||
if (DBG) fprintf(stderr, "Parent 0x%x\n", parentWidget);
|
||||
|
||||
mWidget = XmCreateFileSelectionDialog(parentWidget, "filesb", NULL, 0);
|
||||
|
||||
NS_ALLOC_STR_BUF(title, aTitle, 256);
|
||||
XmString str;
|
||||
str = XmStringCreate(title, XmFONTLIST_DEFAULT_TAG);
|
||||
XtVaSetValues(mWidget, XmNdialogTitle, str, nsnull);
|
||||
NS_FREE_STR_BUF(title);
|
||||
XmStringFree(str);
|
||||
|
||||
|
||||
XtAddCallback(mWidget, XmNcancelCallback, nsXtWidget_FSBCancel_Callback, this);
|
||||
XtAddCallback(mWidget, XmNokCallback, nsXtWidget_FSBOk_Callback, this);
|
||||
|
||||
//XtManageChild(mWidget);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
if (aIID.Equals(kIFileWidgetIID)) {
|
||||
*aInstancePtr = (void*) ((nsIFileWidget*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void nsFileWidget::Create(nsNativeWidget aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
|
@ -104,23 +111,6 @@ void nsFileWidget::Create(nsNativeWidget aParent,
|
|||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsFileWidget::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kIFileWidgetIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -129,7 +119,6 @@ nsresult nsFileWidget::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
|||
//-------------------------------------------------------------------------
|
||||
void nsFileWidget::OnOk()
|
||||
{
|
||||
XtUnmanageChild(mWidget);
|
||||
mWasCancelled = PR_FALSE;
|
||||
mIOwnEventLoop = PR_FALSE;
|
||||
}
|
||||
|
@ -141,7 +130,6 @@ void nsFileWidget::OnOk()
|
|||
//-------------------------------------------------------------------------
|
||||
void nsFileWidget::OnCancel()
|
||||
{
|
||||
XtUnmanageChild(mWidget);
|
||||
mWasCancelled = PR_TRUE;
|
||||
mIOwnEventLoop = PR_FALSE;
|
||||
}
|
||||
|
@ -152,79 +140,37 @@ void nsFileWidget::OnCancel()
|
|||
// Show - Display the file dialog
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsFileWidget::Show(PRBool bState)
|
||||
PRBool nsFileWidget::Show()
|
||||
{
|
||||
nsresult result = nsEventStatus_eIgnore;
|
||||
XtManageChild(mWidget);
|
||||
|
||||
// XXX Kludge: gAppContext is a global set in nsAppShell
|
||||
XEvent event;
|
||||
mIOwnEventLoop = PR_TRUE;
|
||||
while (mIOwnEventLoop) {
|
||||
XtAppNextEvent(gAppContext, &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
|
||||
if (!mWasCancelled) {
|
||||
XmString str;
|
||||
char * fileBuf;
|
||||
XtVaGetValues(mWidget, XmNdirSpec, &str, nsnull);
|
||||
if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &fileBuf)) {
|
||||
// Set user-selected location of file or directory
|
||||
mFile.SetLength(0);
|
||||
mFile.Append(fileBuf);
|
||||
XmStringFree(str);
|
||||
XtFree(fileBuf);
|
||||
}
|
||||
}
|
||||
|
||||
/*char fileBuffer[MAX_PATH];
|
||||
fileBuffer[0] = '\0';
|
||||
OPENFILENAME ofn;
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
|
||||
nsString filterList;
|
||||
GetFilterListArray(filterList);
|
||||
char *filterBuffer = filterList.ToNewCString();
|
||||
char *title = mTitle.ToNewCString();
|
||||
ofn.lpstrTitle = title;
|
||||
ofn.lpstrFilter = filterBuffer;
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.hwndOwner = mWnd;
|
||||
ofn.lpstrFile = fileBuffer;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_SHAREAWARE | OFN_NOCHANGEDIR | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
||||
|
||||
BOOL result;
|
||||
|
||||
// Save current directory, so we can reset if it changes.
|
||||
char* currentDirectory = new char[MAX_PATH+1];
|
||||
VERIFY(::GetCurrentDirectory(MAX_PATH, currentDirectory) > 0);
|
||||
Str255 title;
|
||||
Str255 defaultName;
|
||||
StringToStr255(mTitle,title);
|
||||
StringToStr255(mDefault,defaultName);
|
||||
|
||||
StandardFileReply reply;
|
||||
|
||||
if (mMode == eMode_load) {
|
||||
result = GetOpenFileName(&ofn);
|
||||
PRInt32 numTypes = -1; // DO NO FILTERING FOR NOW! -1 on the Mac means no filtering is done
|
||||
SFTypeList typeList;
|
||||
StandardGetFile (nsnull, numTypes, typeList, &reply );
|
||||
}
|
||||
else if (mMode == eMode_save) {
|
||||
result = GetSaveFileName(&ofn);
|
||||
StandardPutFile (title, defaultName, &reply );
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0, "Only load and save are supported modes");
|
||||
}
|
||||
|
||||
VERIFY(::SetCurrentDirectory(currentDirectory));
|
||||
|
||||
// Clean up filter buffers
|
||||
delete filterBuffer;
|
||||
delete title;
|
||||
|
||||
// Set user-selected location of file or directory
|
||||
mFile.SetLength(0);
|
||||
if (result==PR_TRUE) {
|
||||
mFile.Append(fileBuffer);
|
||||
}
|
||||
*/
|
||||
Str255ToString(reply.sfFile.name,mFile);
|
||||
|
||||
return reply.sfGood;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -295,60 +241,3 @@ nsFileWidget::~nsFileWidget()
|
|||
{
|
||||
}
|
||||
|
||||
#define GET_OUTER() ((nsFileWidget*) ((char*)this - nsFileWidget::GetOuterOffset()))
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
BASE_IWIDGET_IMPL_NO_SHOW(nsFileWidget, AggFileWidget);
|
||||
|
||||
void nsFileWidget::AggFileWidget::Create( nsIWidget *aParent,
|
||||
nsString& aTitle,
|
||||
nsMode aMode,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
void *aInitData)
|
||||
{
|
||||
GET_OUTER()->Create(aParent, aTitle, aMode, aContext, aAppShell, aToolkit, aInitData);
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::OnOk()
|
||||
{
|
||||
GET_OUTER()->OnOk();
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::OnCancel()
|
||||
{
|
||||
GET_OUTER()->OnCancel();
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::Show(PRBool bState)
|
||||
{
|
||||
GET_OUTER()->Show(bState);
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::GetFile(nsString& aFile)
|
||||
{
|
||||
GET_OUTER()->GetFile(aFile);
|
||||
}
|
||||
|
||||
void nsFileWidget::AggFileWidget::SetDefaultString(nsString& aFile)
|
||||
{
|
||||
GET_OUTER()->SetDefaultString(aFile);
|
||||
}
|
||||
|
||||
|
||||
void nsFileWidget::AggFileWidget::SetFilterList(PRUint32 aNumberOfFilters,
|
||||
const nsString aTitles[],
|
||||
const nsString aFilters[])
|
||||
{
|
||||
GET_OUTER()->SetFilterList(aNumberOfFilters, aTitles, aFilters);
|
||||
}
|
||||
|
||||
PRBool nsFileWidget::AggFileWidget::Show()
|
||||
{
|
||||
GET_OUTER()->Show(PR_TRUE);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,15 +25,17 @@
|
|||
#include "nsWindow.h"
|
||||
|
||||
/**
|
||||
* Native Motif FileSelector wrapper
|
||||
* Native Mac FileSelector wrapper
|
||||
*/
|
||||
|
||||
class nsFileWidget : public nsWindow
|
||||
class nsFileWidget : public nsWindow, public nsIFileWidget
|
||||
{
|
||||
public:
|
||||
nsFileWidget(nsISupports *aOuter);
|
||||
nsFileWidget();
|
||||
virtual ~nsFileWidget();
|
||||
NS_IMETHOD QueryObject(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
|
@ -62,7 +64,7 @@ class nsFileWidget : public nsWindow
|
|||
void *aInitData = nsnull);
|
||||
|
||||
// nsIFileWidget part
|
||||
virtual void Show(PRBool bState);
|
||||
virtual PRBool Show();
|
||||
virtual void GetFile(nsString& aFile);
|
||||
virtual void SetDefaultString(nsString& aString);
|
||||
virtual void SetFilterList(PRUint32 aNumberOfFilters,
|
||||
|
@ -85,47 +87,7 @@ class nsFileWidget : public nsWindow
|
|||
nsString mDefault;
|
||||
|
||||
void GetFilterListArray(nsString& aFilterList);
|
||||
|
||||
private:
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsFileWidget,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIFileWidget interface to nsFileWidget w/o using multiple
|
||||
// inheritance.
|
||||
class AggFileWidget : public nsIFileWidget {
|
||||
public:
|
||||
AggFileWidget();
|
||||
virtual ~AggFileWidget();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
// nsIFileWidget
|
||||
virtual void Create( nsIWidget *aParent,
|
||||
nsString& aTitle,
|
||||
nsMode aMode,
|
||||
nsIDeviceContext *aContext = nsnull,
|
||||
nsIAppShell *aAppShell = nsnull,
|
||||
nsIToolkit *aToolkit = nsnull,
|
||||
void *aInitData = nsnull);
|
||||
|
||||
virtual void GetFile(nsString& aFile);
|
||||
virtual void SetDefaultString(nsString& aString);
|
||||
virtual void SetFilterList(PRUint32 aNumberOfFilters,
|
||||
const nsString aTitles[],
|
||||
const nsString aFilters[]);
|
||||
|
||||
virtual PRBool Show();
|
||||
virtual void OnOk();
|
||||
virtual void OnCancel();
|
||||
};
|
||||
AggFileWidget mAggWidget;
|
||||
friend class AggFileWidget;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // nsFileWidget_h__
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "nsString.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsRadioButton)
|
||||
NS_IMPL_RELEASE(nsRadioButton)
|
||||
|
||||
#define DBG 0
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -29,7 +31,7 @@
|
|||
// nsRadioButton constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioButton::nsRadioButton(nsISupports *aOuter) : nsWindow(aOuter)
|
||||
nsRadioButton::nsRadioButton() : nsWindow(), nsIRadioButton()
|
||||
{
|
||||
strcpy(gInstanceClassName, "nsRadioButton");
|
||||
mButtonSet = PR_FALSE;
|
||||
|
@ -164,60 +166,26 @@ nsRadioButton::~nsRadioButton()
|
|||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsRadioButton::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
||||
/**
|
||||
* Implement the standard QueryInterface for NS_IWIDGET_IID and NS_ISUPPORTS_IID
|
||||
* @param aIID The name of the class implementing the method
|
||||
* @param _classiiddef The name of the #define symbol that defines the IID
|
||||
* for the class (e.g. NS_ISUPPORTS_IID)
|
||||
*/
|
||||
nsresult nsRadioButton::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIRadioButtonIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
}
|
||||
static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID);
|
||||
if (aIID.Equals(kIRadioButtonIID)) {
|
||||
*aInstancePtr = (void*) ((nsIRadioButton*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Convert a nsString to a PascalStr255
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioButton::StringToStr255(const nsString& aText, Str255& aStr255)
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
aText.ToCString(buffer,255);
|
||||
|
||||
PRInt32 len = strlen(buffer);
|
||||
memcpy(&aStr255[1],buffer,len);
|
||||
aStr255[0] = len;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
mLabel = aText;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
aBuffer = mLabel;
|
||||
return nsWindow::QueryInterface(aIID,aInstancePtr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -238,17 +206,6 @@ PRBool nsRadioButton::OnResize(nsSizeEvent &aEvent)
|
|||
}
|
||||
|
||||
|
||||
#define GET_OUTER() ((nsRadioButton*) ((char*)this - nsRadioButton::GetOuterOffset()))
|
||||
|
||||
void nsRadioButton::AggRadioButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
GET_OUTER()->GetLabel(aBuffer);
|
||||
}
|
||||
|
||||
void nsRadioButton::AggRadioButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
GET_OUTER()->SetLabel(aText);
|
||||
}
|
||||
|
||||
/*
|
||||
* @update gpk 08/27/98
|
||||
|
@ -365,67 +322,63 @@ Str255 tempstring;
|
|||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioButton::SetState(PRBool aState)
|
||||
|
||||
/** nsIRadioButton Implementation **/
|
||||
|
||||
/**
|
||||
* Set the check state.
|
||||
* @param aState PR_TRUE show as checked. PR_FALSE show unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
|
||||
NS_METHOD nsRadioButton::SetState(PRBool aState)
|
||||
{
|
||||
int state = aState;
|
||||
|
||||
mButtonSet = aState;
|
||||
DrawWidget(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
//if (mIsArmed) {
|
||||
//mNewValue = aState;
|
||||
//mValueWasSet = PR_TRUE;
|
||||
//}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set this button label
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsRadioButton::GetState()
|
||||
{
|
||||
|
||||
return(mButtonSet);
|
||||
|
||||
/*
|
||||
if (mIsArmed) {
|
||||
if (mValueWasSet) {
|
||||
return mNewValue;
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
/**
|
||||
* Get the check state.
|
||||
* @param aState PR_TRUE if checked. PR_FALSE if unchecked.
|
||||
* @result set to NS_OK if method successful
|
||||
*/
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define GET_OUTER() \
|
||||
((nsRadioButton*) ((char*)this - nsRadioButton::GetOuterOffset()))
|
||||
|
||||
PRBool nsRadioButton::AggRadioButton::GetState()
|
||||
NS_METHOD nsRadioButton::GetState(PRBool& aState)
|
||||
{
|
||||
return GET_OUTER()->GetState();
|
||||
aState = mButtonSet;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsRadioButton::AggRadioButton::SetState(PRBool aState)
|
||||
|
||||
|
||||
/**
|
||||
* Set the label for this object to be equal to aText
|
||||
*
|
||||
* @param Set the label to aText
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_METHOD nsRadioButton::SetLabel(const nsString& aText)
|
||||
{
|
||||
GET_OUTER()->SetState(aState);
|
||||
mLabel = aText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
BASE_IWIDGET_IMPL(nsRadioButton, AggRadioButton);
|
||||
|
||||
/**
|
||||
* Set a buffer to be equal to this objects label
|
||||
*
|
||||
* @param Put the contents of the label into aBuffer
|
||||
* @result NS_Ok if no errors
|
||||
*/
|
||||
NS_METHOD nsRadioButton::GetLabel(nsString& aBuffer)
|
||||
{
|
||||
aBuffer = mLabel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
* Native Macintosh button wrapper
|
||||
*/
|
||||
|
||||
class nsRadioButton : public nsWindow
|
||||
class nsRadioButton : public nsWindow, public nsIRadioButton
|
||||
{
|
||||
|
||||
public:
|
||||
nsRadioButton(nsISupports *aOuter);
|
||||
nsRadioButton();
|
||||
virtual ~nsRadioButton();
|
||||
|
||||
NS_IMETHOD QueryObject(const nsIID& aIID, void** aInstancePtr);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
|
@ -51,15 +51,15 @@ public:
|
|||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
|
||||
// nsIButton part
|
||||
virtual void SetLabel(const nsString& aText);
|
||||
virtual void GetLabel(nsString& aBuffer);
|
||||
// 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 OnPaint(nsPaintEvent & aEvent);
|
||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
||||
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
|
||||
|
||||
virtual void SetState(PRBool aState);
|
||||
virtual PRBool GetState();
|
||||
|
||||
// Mac specific methods
|
||||
void LocalToWindowCoordinate(nsPoint& aPoint);
|
||||
|
@ -70,36 +70,8 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
|
||||
void StringToStr255(const nsString& aText, Str255& aStr255);
|
||||
void DrawWidget(PRBool aMouseInside);
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsRadioButton,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIButton interface to nsRadioButton w/o using multiple
|
||||
// inheritance.
|
||||
class AggRadioButton : public nsIRadioButton {
|
||||
public:
|
||||
AggRadioButton();
|
||||
virtual ~AggRadioButton();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
// nsIRadioButton
|
||||
virtual void SetLabel(const nsString &aText);
|
||||
virtual void GetLabel(nsString &aBuffer);
|
||||
virtual void SetState(PRBool aState);
|
||||
virtual PRBool GetState();
|
||||
|
||||
};
|
||||
|
||||
AggRadioButton mAggWidget;
|
||||
friend class AggRadioButton;
|
||||
|
||||
nsString mLabel;
|
||||
PRBool mMouseDownInButton;
|
||||
|
|
|
@ -30,21 +30,24 @@ class nsTextHelper : public nsITextWidget
|
|||
{
|
||||
|
||||
public:
|
||||
nsTextHelper(nsISupports *aOuter);
|
||||
nsTextHelper();
|
||||
virtual ~nsTextHelper();
|
||||
|
||||
virtual void SelectAll();
|
||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||
virtual PRUint32 SetText(const nsString &aText);
|
||||
virtual PRUint32 InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos);
|
||||
virtual void RemoveText();
|
||||
virtual void SetPassword(PRBool aIsPassword);
|
||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
||||
virtual PRUint32 GetCaretPosition();
|
||||
NS_IMETHOD SelectAll();
|
||||
NS_IMETHOD SetMaxTextLength(PRUint32 aChars);
|
||||
NS_IMETHOD GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize);
|
||||
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize);
|
||||
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize);
|
||||
NS_IMETHOD RemoveText();
|
||||
NS_IMETHOD SetPassword(PRBool aIsPassword);
|
||||
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag);
|
||||
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
NS_IMETHOD SetCaretPosition(PRUint32 aPosition);
|
||||
NS_IMETHOD GetCaretPosition(PRUint32& aPosition);
|
||||
|
||||
|
||||
|
||||
virtual PRBool AutoErase();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -22,16 +22,20 @@
|
|||
#include "nsGUIEvent.h"
|
||||
#include "nsString.h"
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsTextWidget)
|
||||
NS_IMPL_RELEASE(nsTextWidget)
|
||||
|
||||
#define DBG 0
|
||||
|
||||
|
||||
//=================================================================
|
||||
// ----------------------------------------------------------------
|
||||
/* Constructor
|
||||
* @update dc 09/10/98
|
||||
* @param aOuter -- nsISupports object
|
||||
* @return NONE
|
||||
*/
|
||||
nsTextWidget::nsTextWidget(nsISupports *aOuter): nsWindow(aOuter)
|
||||
nsTextWidget::nsTextWidget(): nsWindow()
|
||||
{
|
||||
mIsPasswordCallBacksInstalled = PR_FALSE;
|
||||
mMakeReadOnly=PR_FALSE;
|
||||
|
@ -40,7 +44,7 @@ nsTextWidget::nsTextWidget(nsISupports *aOuter): nsWindow(aOuter)
|
|||
//mBackground = NS_RGB(124, 124, 124);
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// ----------------------------------------------------------------
|
||||
/* Destructor
|
||||
* @update dc 09/10/98
|
||||
* @param NONE
|
||||
|
@ -52,7 +56,7 @@ nsTextWidget::~nsTextWidget()
|
|||
WEDispose(mTE_Data);
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// ----------------------------------------------------------------
|
||||
/* Function to create the TextWidget and all its neccisary data
|
||||
* @update dc 09/10/98
|
||||
* @param aParent --
|
||||
|
@ -123,7 +127,7 @@ GrafPtr curport;
|
|||
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// ----------------------------------------------------------------
|
||||
/* Function to create the TextWidget and all its neccisary data
|
||||
* @update dc 09/10/98
|
||||
* @param aParent --
|
||||
|
@ -151,16 +155,16 @@ void nsTextWidget::Create(nsNativeWidget aParent,
|
|||
// Query interface implementation
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsTextWidget::QueryObject(REFNSIID aIID, void** aInstancePtr)
|
||||
nsresult nsTextWidget::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
|
||||
if (aIID.Equals(kITextWidgetIID)) {
|
||||
AddRef();
|
||||
*aInstancePtr = (void**) &mAggWidget;
|
||||
*aInstancePtr = (void**)(nsITextWidget*)this;
|
||||
return NS_OK;
|
||||
}
|
||||
return nsWindow::QueryObject(aIID, aInstancePtr);
|
||||
return nsWindow::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -260,11 +264,11 @@ PRBool nsTextWidget::OnResize(nsSizeEvent &aEvent)
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::SetPassword(PRBool aIsPassword)
|
||||
NS_METHOD nsTextWidget::SetPassword(PRBool aIsPassword)
|
||||
{
|
||||
if ( aIsPassword) {
|
||||
mMakePassword = PR_TRUE;
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIsPassword)
|
||||
|
@ -282,26 +286,25 @@ void nsTextWidget::SetPassword(PRBool aIsPassword)
|
|||
}
|
||||
}
|
||||
//mHelper->SetPassword(aIsPassword);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool nsTextWidget::SetReadOnly(PRBool aReadOnlyFlag)
|
||||
NS_METHOD nsTextWidget::SetReadOnly(PRBool aReadOnlyFlag, PRBool& aOldFlag)
|
||||
{
|
||||
if ( aReadOnlyFlag)
|
||||
{
|
||||
mMakeReadOnly = PR_TRUE;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
aOldFlag = mMakeReadOnly;
|
||||
mMakeReadOnly = aReadOnlyFlag;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::SetMaxTextLength(PRUint32 aChars)
|
||||
NS_METHOD nsTextWidget::SetMaxTextLength(PRUint32 aChars)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize)
|
||||
NS_METHOD nsTextWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aSize)
|
||||
{
|
||||
Handle thetext;
|
||||
PRInt32 len,i;
|
||||
|
@ -319,11 +322,12 @@ char *str;
|
|||
aTextBuffer.SetLength(0);
|
||||
aTextBuffer.Append(str);
|
||||
delete str;
|
||||
return aTextBuffer.Length();
|
||||
aSize = aTextBuffer.Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::SetText(const nsString& aText)
|
||||
PRUint32 nsTextWidget::SetText(const nsString& aText, PRUint32& aSize)
|
||||
{
|
||||
char buffer[256];
|
||||
PRInt32 len;
|
||||
|
@ -334,11 +338,12 @@ PRInt32 len;
|
|||
|
||||
WEInsert(buffer,len,0,0,mTE_Data);
|
||||
|
||||
return len;
|
||||
aSize = len;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos)
|
||||
PRUint32 nsTextWidget::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aSize)
|
||||
{
|
||||
char buffer[256];
|
||||
PRInt32 len;
|
||||
|
@ -347,46 +352,53 @@ PRInt32 len;
|
|||
len = strlen(buffer);
|
||||
|
||||
WEInsert(buffer,len,0,0,mTE_Data);
|
||||
return(len);
|
||||
aSize = len;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::RemoveText()
|
||||
NS_METHOD nsTextWidget::RemoveText()
|
||||
{
|
||||
WESetSelection(0, 32000,mTE_Data);
|
||||
WEDelete(mTE_Data);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::SelectAll()
|
||||
NS_METHOD nsTextWidget::SelectAll()
|
||||
{
|
||||
WESetSelection(0, 32000,mTE_Data);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
||||
NS_METHOD nsTextWidget::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
||||
{
|
||||
WESetSelection(aStartSel, aEndSel,mTE_Data);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
|
||||
NS_METHOD nsTextWidget::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
|
||||
{
|
||||
WEGetSelection((long*)aStartSel,(long*)aEndSel,mTE_Data);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::SetCaretPosition(PRUint32 aPosition)
|
||||
NS_METHOD nsTextWidget::SetCaretPosition(PRUint32 aPosition)
|
||||
{
|
||||
//mHelper->SetCaretPosition(aPosition);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::GetCaretPosition()
|
||||
NS_METHOD nsTextWidget::GetCaretPosition(PRUint32& aPos)
|
||||
{
|
||||
//return mHelper->GetCaretPosition();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
@ -397,90 +409,4 @@ PRBool nsTextWidget::AutoErase()
|
|||
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
#define GET_OUTER() ((nsTextWidget*) ((char*)this - nsTextWidget::GetOuterOffset()))
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::SetMaxTextLength(PRUint32 aChars)
|
||||
{
|
||||
GET_OUTER()->SetMaxTextLength(aChars);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::AggTextWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize) {
|
||||
return GET_OUTER()->GetText(aTextBuffer, aBufferSize);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::AggTextWidget::SetText(const nsString& aText)
|
||||
{
|
||||
return GET_OUTER()->SetText(aText);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::AggTextWidget::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos)
|
||||
{
|
||||
return GET_OUTER()->InsertText(aText, aStartPos, aEndPos);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::RemoveText()
|
||||
{
|
||||
GET_OUTER()->RemoveText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::SetPassword(PRBool aIsPassword)
|
||||
{
|
||||
GET_OUTER()->SetPassword(aIsPassword);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool nsTextWidget::AggTextWidget::SetReadOnly(PRBool aReadOnlyFlag)
|
||||
{
|
||||
return GET_OUTER()->SetReadOnly(aReadOnlyFlag);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::SelectAll()
|
||||
{
|
||||
GET_OUTER()->SelectAll();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
||||
{
|
||||
GET_OUTER()->SetSelection(aStartSel, aEndSel);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
|
||||
{
|
||||
GET_OUTER()->GetSelection(aStartSel, aEndSel);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void nsTextWidget::AggTextWidget::SetCaretPosition(PRUint32 aPosition)
|
||||
{
|
||||
GET_OUTER()->SetCaretPosition(aPosition);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRUint32 nsTextWidget::AggTextWidget::GetCaretPosition()
|
||||
{
|
||||
return GET_OUTER()->GetCaretPosition();
|
||||
}
|
||||
|
||||
PRBool nsTextWidget::AggTextWidget::AutoErase()
|
||||
{
|
||||
return GET_OUTER()->AutoErase();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
BASE_IWIDGET_IMPL(nsTextWidget, AggTextWidget);
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ typedef struct _PasswordData {
|
|||
* Native Mac single line edit control wrapper.
|
||||
*/
|
||||
|
||||
class nsTextWidget : public nsWindow
|
||||
class nsTextWidget : public nsWindow, public nsITextWidget
|
||||
{
|
||||
|
||||
public:
|
||||
nsTextWidget(nsISupports *aOuter);
|
||||
nsTextWidget();
|
||||
virtual ~nsTextWidget();
|
||||
|
||||
NS_IMETHOD QueryObject(REFNSIID aIID, void** aInstancePtr);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void Create(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
|
@ -57,23 +57,25 @@ public:
|
|||
nsIToolkit *aToolkit = nsnull,
|
||||
nsWidgetInitData *aInitData = nsnull);
|
||||
|
||||
// nsITextWidget interface
|
||||
NS_IMETHOD SelectAll();
|
||||
NS_IMETHOD SetMaxTextLength(PRUint32 aChars);
|
||||
NS_IMETHOD GetText(nsString& aTextBuffer, PRUint32 aBufferSize, PRUint32& aActualSize);
|
||||
NS_IMETHOD SetText(const nsString &aText, PRUint32& aActualSize);
|
||||
NS_IMETHOD InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize);
|
||||
NS_IMETHOD RemoveText();
|
||||
NS_IMETHOD SetPassword(PRBool aIsPassword);
|
||||
NS_IMETHOD SetReadOnly(PRBool aNewReadOnlyFlag, PRBool& aOldReadOnlyFlag);
|
||||
NS_IMETHOD SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
NS_IMETHOD SetCaretPosition(PRUint32 aPosition);
|
||||
NS_IMETHOD GetCaretPosition(PRUint32& aPosition);
|
||||
|
||||
|
||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
||||
|
||||
// nsTextHelper Interface
|
||||
virtual void SelectAll();
|
||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||
virtual PRUint32 SetText(const nsString& aText);
|
||||
virtual PRUint32 InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos);
|
||||
virtual void RemoveText();
|
||||
virtual void SetPassword(PRBool aIsPassword);
|
||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
||||
virtual PRUint32 GetCaretPosition();
|
||||
virtual PRBool AutoErase();
|
||||
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
|
||||
|
||||
|
@ -86,42 +88,6 @@ private:
|
|||
PRBool mMakeReadOnly;
|
||||
PRBool mMakePassword;
|
||||
WEReference mTE_Data;
|
||||
|
||||
|
||||
// this should not be public
|
||||
static PRInt32 GetOuterOffset() {
|
||||
return offsetof(nsTextWidget,mAggWidget);
|
||||
}
|
||||
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIText interface to nsText w/o using multiple
|
||||
// inheritance.
|
||||
class AggTextWidget : public nsITextWidget {
|
||||
public:
|
||||
AggTextWidget();
|
||||
virtual ~AggTextWidget();
|
||||
|
||||
AGGREGATE_METHOD_DEF
|
||||
|
||||
virtual void SelectAll();
|
||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||
virtual PRUint32 SetText(const nsString& aText);
|
||||
virtual PRUint32 InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos);
|
||||
virtual void RemoveText();
|
||||
virtual void SetPassword(PRBool aIsPassword);
|
||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
||||
virtual PRUint32 GetCaretPosition();
|
||||
virtual PRBool AutoErase();
|
||||
|
||||
};
|
||||
AggTextWidget mAggWidget;
|
||||
friend class AggTextWidget;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsTextWidget_h__
|
||||
|
|
|
@ -141,11 +141,11 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
nsWindow *inst = nsnull;
|
||||
if (aIID.Equals(kCWindow))
|
||||
{
|
||||
inst = new nsWindow(aOuter);
|
||||
inst = new nsWindow();
|
||||
}
|
||||
else if (aIID.Equals(kIWidget))
|
||||
{
|
||||
inst = new nsWindow(aOuter);
|
||||
inst = new nsWindow();
|
||||
}
|
||||
else if (mClassID.Equals(kCAppShellCID))
|
||||
{
|
||||
|
@ -162,51 +162,51 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
return res;
|
||||
}
|
||||
else if ( mClassID.Equals(kCButtonCID)) {
|
||||
inst = new nsButton(aOuter);
|
||||
inst = new nsButton();
|
||||
}
|
||||
else if (aIID.Equals(kIWidget)) {
|
||||
inst = new nsWindow(aOuter);
|
||||
inst = new nsWindow();
|
||||
}
|
||||
else if (mClassID.Equals(kCChild)) {
|
||||
inst = new ChildWindow(aOuter);
|
||||
inst = new ChildWindow();
|
||||
}
|
||||
else if ( mClassID.Equals(kCRadioButtonCID )) {
|
||||
inst = new nsRadioButton(aOuter);
|
||||
inst = new nsRadioButton();
|
||||
}
|
||||
else if ( mClassID.Equals(kCCheckButtonCID)) {
|
||||
inst = new nsCheckButton(aOuter);
|
||||
inst = new nsCheckButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCTextWidgetCID)) {
|
||||
inst = new nsTextWidget(aOuter);
|
||||
inst = new nsTextWidget();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef NOTNOW
|
||||
else if (mClassID.Equals(kCVertScrollbarCID)) {
|
||||
inst = new nsScrollbar(aOuter, PR_TRUE);
|
||||
inst = new nsScrollbar(, PR_TRUE);
|
||||
}
|
||||
else if (mClassID.Equals(kCHorzScrollbarCID)) {
|
||||
inst = new nsScrollbar(aOuter, PR_FALSE);
|
||||
inst = new nsScrollbar(, PR_FALSE);
|
||||
}
|
||||
else if (aIID.Equals(kIScrollbar)) {
|
||||
inst = nsnull;
|
||||
fprintf(stderr, "------ NOT CreatingkIScrollbar Scrollbar\n");
|
||||
}
|
||||
else if (mClassID.Equals(kCTextAreaWidgetCID)) {
|
||||
inst = new nsTextAreaWidget(aOuter);
|
||||
inst = new nsTextAreaWidget();
|
||||
}
|
||||
else if (mClassID.Equals(kCListBoxCID)) {
|
||||
inst = new nsListBox(aOuter);
|
||||
inst = new nsListBox();
|
||||
}
|
||||
else if (mClassID.Equals(kCComboBoxCID)) {
|
||||
inst = new nsComboBox(aOuter);
|
||||
inst = new nsComboBox();
|
||||
}
|
||||
else if (mClassID.Equals(kCFileWidgetCID)) {
|
||||
inst = new nsFileWidget(aOuter);
|
||||
inst = new nsFileWidget();
|
||||
}
|
||||
else if (mClassID.Equals(kCLookAndFeelCID)) {
|
||||
nsLookAndFeel *laf = new nsLookAndFeel(aOuter);
|
||||
nsLookAndFeel *laf = new nsLookAndFeel();
|
||||
if (laf == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult res = inst->QueryObject(aIID, aResult);
|
||||
nsresult res = inst->QueryInterface(aIID, aResult);
|
||||
|
||||
if (res != NS_OK) {
|
||||
delete inst;
|
||||
|
|
Загрузка…
Ссылка в новой задаче