I have removed nsRadioGroup and nsIRadioGroup and all references to it.
git-svn-id: svn://10.0.0.236/trunk@22928 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsIRadioGroup_h__
|
||||
#define nsIRadioGroup_h__
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IRADIOGROUP_IID \
|
||||
{ 0x961085f1, 0xbd28, 0x11d1, \
|
||||
{ 0x97, 0xef, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } }
|
||||
|
||||
|
||||
class nsIRadioGroup;
|
||||
class nsIRadioButton;
|
||||
class nsIEnumerator;
|
||||
|
||||
/**
|
||||
* Helper class for implementing a "group" of radio buttons
|
||||
*
|
||||
*/
|
||||
class nsIRadioGroup : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Adds a RadioButton to the group
|
||||
* @param aRadioBtn the radio button to be added
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Add(nsIRadioButton * aRadioBtn) = 0;
|
||||
|
||||
/**
|
||||
* Removes a RadioButton from the group
|
||||
* @param aRadioBtn the radio button to be removed
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Remove(nsIRadioButton * aRadioBtn) = 0;
|
||||
|
||||
/**
|
||||
* Sets the name of the RadioGroup
|
||||
* @param aName The new name of the radio group
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetName(const nsString &aName) = 0;
|
||||
|
||||
/**
|
||||
* Tells the RadioGroup that a child RadioButton has been clicked and it should set
|
||||
* the approproate state on the other buttons
|
||||
* @param aChild The RadioButton that was clicked
|
||||
* @result NS_Ok if no errors
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD Clicked(nsIRadioButton * aChild) = 0;
|
||||
|
||||
/**
|
||||
* Gets the enumeration of children
|
||||
* @return The enumeration of children (radio buttons) in the RadioGroup
|
||||
*
|
||||
*/
|
||||
virtual nsIEnumerator* GetChildren() = 0;
|
||||
};
|
||||
|
||||
#endif // nsIRadioGroup_h__
|
||||
|
||||
@@ -36,7 +36,6 @@ class nsIListBox;
|
||||
class nsIListWidget;
|
||||
class nsILookAndFeel;
|
||||
class nsIMouseListener;
|
||||
class nsIRadioGroup;
|
||||
class nsITabWidget;
|
||||
class nsIToolkit;
|
||||
class nsIWidget;
|
||||
|
||||
@@ -56,11 +56,6 @@
|
||||
{ 0x2d96b3d7, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d8-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_RADIOGROUP_CID \
|
||||
{ 0x2d96b3d8, 0xc051, 0x11d1, \
|
||||
{0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} }
|
||||
|
||||
/* 2d96b3d9-c051-11d1-a827-0040959a28c9 */
|
||||
#define NS_HORZSCROLLBAR_CID \
|
||||
{ 0x2d96b3d9, 0xc051, 0x11d1, \
|
||||
|
||||
@@ -168,9 +168,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
||||
else if (mClassID.Equals(kCRadioButton)) {
|
||||
inst = (nsISupports*)(nsWidget *)new nsRadioButton();
|
||||
}
|
||||
//else if (mClassID.Equals(kCRadioGroup)) {
|
||||
// inst = (nsISupports*)(nsObject*)new nsRadioGroup();
|
||||
//}
|
||||
else if (mClassID.Equals(kCFileOpen)) {
|
||||
inst = (nsISupports*)new nsFileWidget();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "nsIListWidget.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIMouseListener.h"
|
||||
#include "nsIRadioGroup.h"
|
||||
#include "nsITabWidget.h"
|
||||
#include "nsIToolkit.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "nsListBox.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "nsRadioButton.h"
|
||||
#include "nsRadioGroup.h"
|
||||
#include "nsScrollbar.h"
|
||||
#include "nsTextAreaWidget.h"
|
||||
#include "nsTextHelper.h"
|
||||
@@ -56,7 +55,6 @@ static NS_DEFINE_IID(kCCombobox, NS_COMBOBOX_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(kCRadioGroup, NS_RADIOGROUP_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);
|
||||
@@ -169,9 +167,6 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
||||
else if (mClassID.Equals(kCRadioButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsRadioButton();
|
||||
}
|
||||
//else if (mClassID.Equals(kCRadioGroup)) {
|
||||
// inst = (nsISupports*)(nsObject*)new nsRadioGroup();
|
||||
//}
|
||||
else if (mClassID.Equals(kCFileOpen)) {
|
||||
inst = (nsISupports*)new nsFileWidget();
|
||||
}
|
||||
|
||||
@@ -186,9 +186,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
||||
else if (mClassID.Equals(kCRadioButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsRadioButton();
|
||||
}
|
||||
//else if (mClassID.Equals(kCRadioGroup)) {
|
||||
// inst = (nsISupports*)(nsObject*)new nsRadioGroup();
|
||||
//}
|
||||
else if (mClassID.Equals(kCFileOpen)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsFileWidget();
|
||||
}
|
||||
|
||||
@@ -1,449 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsRadioGroup.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsStringUtil.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsRadioGroup, NS_IRADIOGROUP_IID)
|
||||
|
||||
class nsStringHashKey : public nsHashKey {
|
||||
public:
|
||||
nsStringHashKey(const nsString & aKey);
|
||||
~nsStringHashKey();
|
||||
|
||||
PRBool operator==(const nsStringHashKey& aOther) const;
|
||||
PRBool Equals(const nsHashKey* aOther) const;
|
||||
PRUint32 HashValue(void) const;
|
||||
nsHashKey* Clone(void) const;
|
||||
|
||||
private:
|
||||
nsStringHashKey();
|
||||
nsStringHashKey(const nsStringHashKey& aCopy);
|
||||
nsStringHashKey& operator=(const nsStringHashKey& aCopy);
|
||||
|
||||
protected:
|
||||
nsString mKey;
|
||||
PRUint32 mHashValid;
|
||||
PRUint32 mHashValue;
|
||||
|
||||
};
|
||||
|
||||
nsStringHashKey::nsStringHashKey(const nsString & aKey)
|
||||
{
|
||||
mKey.SetLength(0);
|
||||
mKey.Append(aKey);
|
||||
mHashValid = 0;
|
||||
}
|
||||
|
||||
nsStringHashKey::nsStringHashKey(const nsStringHashKey& aCopy)
|
||||
{
|
||||
mKey.SetLength(0);
|
||||
mKey.Append(aCopy.mKey);
|
||||
mHashValid = aCopy.mHashValid;
|
||||
mHashValue = aCopy.mHashValue;
|
||||
}
|
||||
|
||||
nsStringHashKey::~nsStringHashKey()
|
||||
{
|
||||
}
|
||||
|
||||
PRBool nsStringHashKey::operator==(const nsStringHashKey& aOther) const
|
||||
{
|
||||
return Equals(&aOther);
|
||||
}
|
||||
|
||||
PRBool nsStringHashKey::Equals(const nsHashKey* aOther) const
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
const nsStringHashKey* other = (nsStringHashKey*)aOther;
|
||||
|
||||
if (nsnull != other && other != this) {
|
||||
result = mKey.Equals(other->mKey);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nsHashKey* nsStringHashKey::Clone(void) const
|
||||
{
|
||||
return new nsStringHashKey(*this);
|
||||
}
|
||||
|
||||
PRUint32 nsStringHashKey::HashValue(void) const
|
||||
{
|
||||
if (0 == mHashValid) {
|
||||
((nsStringHashKey*)this)->mHashValue = 0;
|
||||
|
||||
NS_ALLOC_STR_BUF(val, mKey, 256)
|
||||
PRUint32 hash = 0;
|
||||
PRUint32 off = 0;
|
||||
PRUint32 len = mKey.Length();
|
||||
|
||||
if (len < 16) {
|
||||
for (PRUint32 i = len ; i > 0; i--) {
|
||||
hash = (hash * 37) + val[off++];
|
||||
}
|
||||
} else { // only sample some characters
|
||||
PRUint32 skip = len / 8;
|
||||
for (PRUint32 i = len ; i > 0; i -= skip, off += skip) {
|
||||
hash = (hash * 39) + val[off];
|
||||
}
|
||||
}
|
||||
NS_FREE_STR_BUF(val)
|
||||
((nsStringHashKey*)this)->mHashValue = hash;//^= (hash & 0x7FFFFFFF);
|
||||
((nsStringHashKey*)this)->mHashValid = 1;
|
||||
}
|
||||
return mHashValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsHashtable * nsRadioGroup::mRadioGroupHashtable = new nsHashtable(8);
|
||||
|
||||
PRBool HashtableEnum(nsHashKey *aKey, void *aData) {
|
||||
printf("HashtableEnum %s\n", aKey);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsRadioGroup constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioGroup::nsRadioGroup() : nsObject()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mChildren = NULL;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsRadioGroup destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioGroup::~nsRadioGroup()
|
||||
{
|
||||
if (mChildren) {
|
||||
mChildren = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsRadioGroup static methods
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioGroup * nsRadioGroup::getNamedRadioGroup(const nsString & aName) {
|
||||
nsStringHashKey key(aName);
|
||||
nsRadioGroup * group = (nsRadioGroup *)mRadioGroupHashtable->Get((nsHashKey *)&key);
|
||||
return group;
|
||||
}
|
||||
|
||||
NS_EXPORT nsIRadioGroup * NS_GetRadioGroup(const nsString &aName) {
|
||||
return nsRadioGroup::getNamedRadioGroup(aName);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gives a name to this group of radio buttons
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioGroup::SetName(const nsString &aName)
|
||||
{
|
||||
mName.SetLength(0);
|
||||
mName.Append(aName);
|
||||
nsStringHashKey* key = new nsStringHashKey(aName);
|
||||
if (key == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mRadioGroupHashtable->Put(key, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Adds a nsRadioButton to this group
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioGroup::Clicked(nsIRadioButton * aChild)
|
||||
{
|
||||
#if 0
|
||||
if (mChildren) {
|
||||
nsIEnumerator * enumerator = GetChildren();
|
||||
nsIRadioButton * child = (nsIRadioButton*)enumerator->Next();
|
||||
while (child) {
|
||||
child->SetStateNoNotify((PRBool)(child == aChild));
|
||||
NS_RELEASE(child);
|
||||
child = (nsIRadioButton*)enumerator->Next();
|
||||
}
|
||||
NS_RELEASE(enumerator);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Adds a nsRadioButton to this group
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioGroup::Add(nsIRadioButton * aChild)
|
||||
{
|
||||
if (!mChildren) {
|
||||
mChildren = new Enumerator();
|
||||
}
|
||||
|
||||
mChildren->Append(aChild);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Removes a nsRadioButton from this group
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsRadioGroup::Remove(nsIRadioButton * aChild)
|
||||
{
|
||||
if (mChildren) {
|
||||
mChildren->Remove(aChild);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get this window's list of children
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsIEnumerator* nsRadioGroup::GetChildren()
|
||||
{
|
||||
if (mChildren) {
|
||||
mChildren->Fist();
|
||||
NS_ADDREF(mChildren);
|
||||
return mChildren;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
#define INITIAL_SIZE 2
|
||||
|
||||
nsRadioGroup::Enumerator::Enumerator()
|
||||
{
|
||||
mRefCnt = 0;
|
||||
mArraySize = INITIAL_SIZE;
|
||||
mChildrens = (nsIRadioButton**)new DWORD[mArraySize];
|
||||
memset(mChildrens, 0, sizeof(DWORD) * mArraySize);
|
||||
mCurrentPosition = 0;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsRadioGroup::Enumerator::~Enumerator()
|
||||
{
|
||||
if (mChildrens) {
|
||||
for (int i = 0; mChildrens[i] && i < mArraySize; i++) {
|
||||
NS_RELEASE(mChildrens[i]);
|
||||
}
|
||||
|
||||
delete[] mChildrens;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// nsISupports methods
|
||||
//
|
||||
NS_IMPL_ADDREF(nsRadioGroup::Enumerator);
|
||||
NS_IMPL_RELEASE(nsRadioGroup::Enumerator);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIBidirectionalEnumerator::GetIID()) ||
|
||||
aIID.Equals(nsIEnumerator::GetIID()) ||
|
||||
aIID.Equals(nsISupports::GetIID())) {
|
||||
*aInstancePtr = (void*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get enumeration next element. Return null at the end
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::Next()
|
||||
{
|
||||
if (mCurrentPosition < (mArraySize -1) )
|
||||
mCurrentPosition ++;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::Prev()
|
||||
{
|
||||
if (mCurrentPosition > 0 )
|
||||
mCurrentPosition --;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::CurrentItem(nsISupports **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (mCurrentPosition >= 0 && mCurrentPosition < mArraySize && mChildrens[mCurrentPosition]) {
|
||||
NS_ADDREF(mChildrens[mCurrentPosition]);
|
||||
*aItem = mChildrens[mCurrentPosition];
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::First()
|
||||
{
|
||||
if (mArraySize && mChildrens[0]) {
|
||||
mCurrentPosition = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::Last()
|
||||
{
|
||||
if (mArraySize && mChildrens[0]) {
|
||||
mCurrentPosition = mArraySize -1;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRadioGroup::Enumerator::IsDone()
|
||||
{
|
||||
if ((mCurrentPosition == (mArraySize -1)) || mArraySize <= 0 ){ //empty lists always return done
|
||||
return NS_OK;
|
||||
}
|
||||
else{
|
||||
return NS_COMFALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Append an element
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioGroup::Enumerator::Append(nsIRadioButton* aRadioButton)
|
||||
{
|
||||
NS_PRECONDITION(aRadioButton, "Adding a null radio button to a radio group");
|
||||
if (aRadioButton) {
|
||||
int pos;
|
||||
for (pos = 0; pos < mArraySize && mChildrens[pos]; pos++);
|
||||
if (pos == mArraySize) {
|
||||
GrowArray();
|
||||
}
|
||||
mChildrens[pos] = aRadioButton;
|
||||
NS_ADDREF(aRadioButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Remove an element
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioGroup::Enumerator::Remove(nsIRadioButton* aRadioButton)
|
||||
{
|
||||
int pos;
|
||||
for(pos = 0; mChildrens[pos] && (mChildrens[pos] != aRadioButton); pos++);
|
||||
if (mChildrens[pos] == aRadioButton) {
|
||||
NS_RELEASE(aRadioButton);
|
||||
memcpy(mChildrens + pos, mChildrens + pos + 1, mArraySize - pos - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Grow the size of the children array
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsRadioGroup::Enumerator::GrowArray()
|
||||
{
|
||||
mArraySize <<= 1;
|
||||
nsIRadioButton **newArray = (nsIRadioButton**)new DWORD[mArraySize];
|
||||
memset(newArray, 0, sizeof(DWORD) * mArraySize);
|
||||
memcpy(newArray, mChildrens, (mArraySize>>1) * sizeof(DWORD));
|
||||
mChildrens = newArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsRadioGroup_h__
|
||||
#define nsRadioGroup_h__
|
||||
|
||||
#include "nsdefs.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsSwitchToUIThread.h"
|
||||
|
||||
#include "nsIRadioGroup.h"
|
||||
#include "nsRadioButton.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
/**
|
||||
* Native radio button manager
|
||||
*/
|
||||
|
||||
class nsRadioGroup : public nsObject,
|
||||
public nsIRadioGroup
|
||||
{
|
||||
|
||||
public:
|
||||
nsRadioGroup();
|
||||
virtual ~nsRadioGroup();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
// nsIRadioGroup Interface
|
||||
NS_IMETHOD Add(nsIRadioButton * aRadioBtn);
|
||||
NS_IMETHOD Remove(nsIRadioButton * aRadioBtn);
|
||||
NS_IMETHOD SetName(const nsString &aName);
|
||||
NS_IMETHOD Clicked(nsIRadioButton * aChild);
|
||||
virtual nsIEnumerator* GetChildren();
|
||||
|
||||
static nsRadioGroup * getNamedRadioGroup(const nsString & aName);
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
|
||||
static nsHashtable * mRadioGroupHashtable;
|
||||
//static PRBool HashtableEnum(nsHashKey *aKey, void *aData);
|
||||
|
||||
|
||||
// keep the list of children
|
||||
class Enumerator : public nsIBidirectionalEnumerator {
|
||||
nsIRadioButton **mChildrens;
|
||||
int mCurrentPosition;
|
||||
int mArraySize;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
Enumerator();
|
||||
virtual ~Enumerator();
|
||||
|
||||
NS_IMETHOD First();
|
||||
NS_IMETHOD Last();
|
||||
NS_IMETHOD Next();
|
||||
NS_IMETHOD Prev();
|
||||
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
||||
NS_IMETHOD IsDone();
|
||||
|
||||
void Append(nsIRadioButton* aWidget);
|
||||
void Remove(nsIRadioButton* aWidget);
|
||||
|
||||
private:
|
||||
void GrowArray();
|
||||
|
||||
} *mChildren;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsRadioGroup_h__
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "nsListBox.h"
|
||||
#include "nsLookAndFeel.h"
|
||||
#include "nsRadioButton.h"
|
||||
#include "nsRadioGroup.h"
|
||||
#include "nsScrollbar.h"
|
||||
#include "nsTextAreaWidget.h"
|
||||
#include "nsTextHelper.h"
|
||||
@@ -168,9 +167,6 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
||||
else if (mClassID.Equals(kCRadioButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsRadioButton();
|
||||
}
|
||||
//else if (mClassID.Equals(kCRadioGroup)) {
|
||||
// inst = (nsISupports*)(nsObject*)new nsRadioGroup();
|
||||
//}
|
||||
else if (mClassID.Equals(kCFileOpen)) {
|
||||
inst = (nsISupports*)new nsFileWidget();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIRadioButton.h"
|
||||
#include "nsIRadioGroup.h"
|
||||
#include "nsITextWidget.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
@@ -35,7 +34,6 @@ struct ScribbleApp {
|
||||
nsITextWidget *green;
|
||||
nsITextWidget *blue;
|
||||
|
||||
nsIRadioGroup *group;
|
||||
nsIRadioButton *scribble;
|
||||
nsIRadioButton *lines;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user