|
|
|
|
@@ -18,204 +18,193 @@
|
|
|
|
|
|
|
|
|
|
#include "nsIFactory.h"
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
|
#include "nsIButton.h"
|
|
|
|
|
#include "nsITextWidget.h"
|
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
|
|
|
|
|
|
#include "nsToolkit.h"
|
|
|
|
|
#include "nsWindow.h"
|
|
|
|
|
#include "nsAppShell.h"
|
|
|
|
|
#include "nsButton.h"
|
|
|
|
|
#include "nsScrollbar.h"
|
|
|
|
|
#include "nsCheckButton.h"
|
|
|
|
|
#include "nsComboBox.h"
|
|
|
|
|
#include "nsRadioButton.h"
|
|
|
|
|
#include "nsTextWidget.h"
|
|
|
|
|
#include "nsTextAreaWidget.h"
|
|
|
|
|
#include "nsFileWidget.h"
|
|
|
|
|
#include "nsListBox.h"
|
|
|
|
|
#include "nsComboBox.h"
|
|
|
|
|
#include "nsLookAndFeel.h"
|
|
|
|
|
#include "nsRadioButton.h"
|
|
|
|
|
//#include "nsRadioGroup.h"
|
|
|
|
|
#include "nsScrollbar.h"
|
|
|
|
|
#include "nsTextAreaWidget.h"
|
|
|
|
|
#include "nsTextHelper.h"
|
|
|
|
|
#include "nsTextWidget.h"
|
|
|
|
|
#include "nsToolkit.h"
|
|
|
|
|
//#include "nsTabWidget.h"
|
|
|
|
|
//#include "nsTooltipWidget.h"
|
|
|
|
|
#include "nsWindow.h"
|
|
|
|
|
#include "nsDialog.h"
|
|
|
|
|
#include "nsLabel.h"
|
|
|
|
|
#include "nsMenuBar.h"
|
|
|
|
|
#include "nsMenu.h"
|
|
|
|
|
#include "nsMenuItem.h"
|
|
|
|
|
#include "nsPopUpMenu.h"
|
|
|
|
|
|
|
|
|
|
#include "nsImageButton.h"
|
|
|
|
|
#include "nsMenuButton.h"
|
|
|
|
|
#include "nsToolbar.h"
|
|
|
|
|
#include "nsToolbarManager.h"
|
|
|
|
|
#include "nsToolbarItemHolder.h"
|
|
|
|
|
#include "nsAppShell.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCChild, NS_CHILD_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCButton, NS_BUTTON_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID);
|
|
|
|
|
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);
|
|
|
|
|
static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID);
|
|
|
|
|
//static NS_DEFINE_IID(kCTabWidget, NS_TABWIDGET_CID);
|
|
|
|
|
//static NS_DEFINE_IID(kCTooltipWidget, NS_TOOLTIPWIDGET_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCToolkit, NS_TOOLKIT_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCLookAndFeel, NS_LOOKANDFEEL_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCHorzScrollbarCID, NS_HORZSCROLLBAR_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCVertScrollbarCID, NS_VERTSCROLLBAR_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCCheckButtonCID, NS_CHECKBUTTON_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCRadioButtonCID, NS_RADIOBUTTON_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCTextWidgetCID, NS_TEXTFIELD_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCTextAreaWidgetCID, NS_TEXTAREA_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCDialog, NS_DIALOG_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCLabel, NS_LABEL_CID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIWidget, NS_IWIDGET_IID);
|
|
|
|
|
static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID);
|
|
|
|
|
static NS_DEFINE_IID(kIButton, NS_IBUTTON_IID);
|
|
|
|
|
static NS_DEFINE_IID(kICheckButton, NS_ICHECKBUTTON_IID);
|
|
|
|
|
static NS_DEFINE_IID(kIScrollbar, NS_ISCROLLBAR_IID);
|
|
|
|
|
static NS_DEFINE_IID(kIFileWidget, NS_IFILEWIDGET_IID);
|
|
|
|
|
static NS_DEFINE_IID(kIListBox, NS_ILISTBOX_IID);
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kCMenuBar, NS_MENUBAR_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCMenu, NS_MENU_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCMenuItem, NS_MENUITEM_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCPopUpMenu, NS_POPUPMENU_CID);
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kCImageButton, NS_IMAGEBUTTON_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCToolBar, NS_TOOLBAR_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCToolBarManager, NS_TOOLBARMANAGER_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCToolBarItemHolder, NS_TOOLBARITEMHOLDER_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCPopUpMenu, NS_POPUPMENU_CID);
|
|
|
|
|
static NS_DEFINE_IID(kCMenuButton, NS_MENUBUTTON_CID);
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class nsWidgetFactory : public nsIFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// nsISupports methods
|
|
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
|
|
// nsIFactory methods
|
|
|
|
|
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
|
|
|
|
const nsIID &aIID,
|
|
|
|
|
void **aResult);
|
|
|
|
|
const nsIID &aIID,
|
|
|
|
|
void **aResult);
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD LockFactory(PRBool aLock);
|
|
|
|
|
|
|
|
|
|
nsWidgetFactory(const nsCID &aClass);
|
|
|
|
|
~nsWidgetFactory();
|
|
|
|
|
private:
|
|
|
|
|
nsCID mClassID;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
nsCID mClassID;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsWidgetFactory)
|
|
|
|
|
NS_IMPL_RELEASE(nsWidgetFactory)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
|
|
|
|
|
{
|
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
mClassID = aClass;
|
|
|
|
|
mClassID = aClass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsWidgetFactory::~nsWidgetFactory()
|
|
|
|
|
{
|
|
|
|
|
NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
|
|
|
|
|
void **aResult)
|
|
|
|
|
void **aInstancePtr)
|
|
|
|
|
{
|
|
|
|
|
if (aResult == NULL) {
|
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
}
|
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Always NULL result, in case of failure
|
|
|
|
|
*aResult = NULL;
|
|
|
|
|
if (aIID.Equals(kIFactoryIID)) {
|
|
|
|
|
*aInstancePtr = (void*)(nsWidgetFactory*)this;
|
|
|
|
|
AddRef();
|
|
|
|
|
return NS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
|
*aResult = (void *)(nsISupports*)this;
|
|
|
|
|
} else if (aIID.Equals(kIFactoryIID)) {
|
|
|
|
|
*aResult = (void *)(nsIFactory*)this;
|
|
|
|
|
}
|
|
|
|
|
if (aIID.Equals(kISupportsIID)) {
|
|
|
|
|
*aInstancePtr = (void*)(nsISupports*)(nsWidgetFactory*)this;
|
|
|
|
|
AddRef();
|
|
|
|
|
return NS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*aResult == NULL) {
|
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NS_ADDREF_THIS(); // Increase reference count for caller
|
|
|
|
|
return NS_OK;
|
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsWidgetFactory)
|
|
|
|
|
NS_IMPL_RELEASE(nsWidgetFactory)
|
|
|
|
|
|
|
|
|
|
nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
|
|
|
|
nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
|
|
|
|
const nsIID &aIID,
|
|
|
|
|
void **aResult)
|
|
|
|
|
{
|
|
|
|
|
if (aResult == NULL) {
|
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
}
|
|
|
|
|
*aResult = NULL;
|
|
|
|
|
if (nsnull != aOuter) {
|
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nsnull != aOuter)
|
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
|
|
*aResult = NULL;
|
|
|
|
|
|
|
|
|
|
nsISupports *inst = nsnull;
|
|
|
|
|
if (mClassID.Equals(kCWindow)) {
|
|
|
|
|
inst = (nsISupports*)new nsWindow();
|
|
|
|
|
if (aIID.Equals(kCWindow)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsWindow();
|
|
|
|
|
}
|
|
|
|
|
else if ( mClassID.Equals(kCCheckButtonCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsCheckButton();
|
|
|
|
|
}
|
|
|
|
|
else if ( mClassID.Equals(kCButtonCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsButton();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCVertScrollbarCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsScrollbar(PR_TRUE);
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCHorzScrollbarCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsScrollbar(PR_FALSE);
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCTextWidgetCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsTextWidget();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCTextAreaWidgetCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsTextAreaWidget();
|
|
|
|
|
}
|
|
|
|
|
else if ( mClassID.Equals(kCRadioButtonCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsRadioButton();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCListBoxCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsListBox();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCComboBoxCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsComboBox();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCFileWidgetCID)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsFileWidget();
|
|
|
|
|
}
|
|
|
|
|
else if (aIID.Equals(kIWidget)) {
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsWindow();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCChild)) {
|
|
|
|
|
inst = (nsISupports*)new ChildWindow();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCButton)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsButton();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCCheckButton)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsCheckButton();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCCombobox)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsComboBox();
|
|
|
|
|
}
|
|
|
|
|
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*)(nsIWidget *)new nsFileWidget();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCListbox)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsListBox();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCHorzScrollbar)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsScrollbar(PR_FALSE);
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCVertScrollbar)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsScrollbar(PR_TRUE);
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCTextArea)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsTextAreaWidget();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCTextField)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsTextWidget();
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
else if (mClassID.Equals(kCTabWidget)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsTabWidget();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCTooltipWidget)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsTooltipWidget();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
else if (mClassID.Equals(kCAppShell)) {
|
|
|
|
|
inst = (nsISupports*)new nsAppShell();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCToolkit)) {
|
|
|
|
|
inst = (nsISupports*)new nsToolkit();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCLookAndFeel)) {
|
|
|
|
|
inst = (nsISupports*)new nsLookAndFeel();
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new ChildWindow();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCDialog)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsDialog();
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsDialog();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCLabel)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsLabel();
|
|
|
|
|
inst = (nsISupports *)(nsIWidget *)new nsLabel();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCMenuBar)) {
|
|
|
|
|
inst = (nsISupports*)new nsMenuBar();
|
|
|
|
|
@@ -233,7 +222,7 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsMenuButton();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCToolBar)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsToolbar();
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsToolbar();
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCToolBarManager)) {
|
|
|
|
|
inst = (nsISupports*)(nsWindow*)new nsToolbarManager();
|
|
|
|
|
@@ -241,22 +230,44 @@ nsresult nsWidgetFactory::CreateInstance( nsISupports* aOuter,
|
|
|
|
|
else if (mClassID.Equals(kCToolBarItemHolder)) {
|
|
|
|
|
inst = (nsISupports*)(nsIToolbarItemHolder *) new nsToolbarItemHolder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (mClassID.Equals(kCPopUpMenu)) {
|
|
|
|
|
inst = (nsISupports*)new nsPopUpMenu();
|
|
|
|
|
}/* */
|
|
|
|
|
|
|
|
|
|
if (inst == NULL) {
|
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsresult res = inst->QueryInterface(aIID, aResult);
|
|
|
|
|
|
|
|
|
|
if (res != NS_OK) {
|
|
|
|
|
// We didn't get the right interface, so clean up
|
|
|
|
|
delete inst;
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCLookAndFeelCID)) {
|
|
|
|
|
nsLookAndFeel *laf = new nsLookAndFeel();
|
|
|
|
|
if (laf == NULL) {
|
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
nsresult res = laf->QueryInterface(aIID, aResult);
|
|
|
|
|
if (res != NS_OK) {
|
|
|
|
|
delete laf;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
else if (mClassID.Equals(kCAppShellCID)) {
|
|
|
|
|
nsAppShell *appInst = new nsAppShell();
|
|
|
|
|
if (appInst == NULL) {
|
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
nsresult res = appInst->QueryInterface(aIID, aResult);
|
|
|
|
|
if (res != NS_OK) {
|
|
|
|
|
delete appInst;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
if (inst == NULL) {
|
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsresult res = inst->QueryInterface(aIID, aResult);
|
|
|
|
|
|
|
|
|
|
if (res != NS_OK) {
|
|
|
|
|
delete inst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsresult nsWidgetFactory::LockFactory(PRBool aLock)
|