mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 11:58:55 +00:00
added gtk/nsWidgetFactory.cpp so that we are not dependant on the one in
Build. Changed build/Makefile.in so that we do not compile nsMotifWidgetFactory.cpp if we are using GTK as we have one in the GTK dir now. Add nsWidgetFactory.cpp to gtk/Makefile.in Cleanup of nsWindow.cpp: removed lots of unused code and general cleanups and fixes. Don't create a toplevel window in nsAppShell.cpp as it isn't really needed.
This commit is contained in:
parent
f615b3d60d
commit
839f153d84
@ -45,7 +45,14 @@ INCLUDES+= -I$(srcdir)/../xpwidgets -I$(srcdir)/../motif -I$(srcdir)/.
|
||||
CFLAGS += $(TOOLKIT_CFLAGS)
|
||||
|
||||
# nsMotifWidgetFactory actually has no Motif/Xt/Xlib code in it -- surprise!
|
||||
|
||||
ifneq (,$(filter gtk, $(MOZ_TOOLKIT)))
|
||||
CPPSRCS=dlldeps.cpp nsWidgetSupport.cpp
|
||||
else
|
||||
ifneq (,$(filter motif, $(MOZ_TOOLKIT)))
|
||||
CPPSRCS=dlldeps.cpp nsWidgetSupport.cpp nsMotifWidgetFactory.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
LD = $(CCC)
|
||||
|
@ -58,7 +58,8 @@ CPPSRCS= \
|
||||
nsGtkEventHandler.cpp \
|
||||
nsRadioButton.cpp \
|
||||
nsPopUpMenu.cpp \
|
||||
nsWindow.cpp
|
||||
nsWindow.cpp \
|
||||
nsWidgetFactory.cpp
|
||||
|
||||
CSRCS = gtklayout.c \
|
||||
$(NULL)
|
||||
|
@ -49,10 +49,10 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv)
|
||||
gtk_init (argc, &argv);
|
||||
|
||||
gdk_rgb_init ();
|
||||
|
||||
mTopLevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
/* we should probibly set even handlers here */
|
||||
|
||||
|
||||
// Windows and Mac don't create anything here, so why should we?
|
||||
// mTopLevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
/* we should probibly set even handlers here */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ NS_METHOD nsAppShell::Run()
|
||||
|
||||
NS_METHOD nsAppShell::Exit()
|
||||
{
|
||||
gtk_widget_destroy (mTopLevel);
|
||||
// gtk_widget_destroy (mTopLevel);
|
||||
gtk_main_quit ();
|
||||
|
||||
return NS_OK;
|
||||
@ -112,7 +112,7 @@ nsAppShell::~nsAppShell()
|
||||
void* nsAppShell::GetNativeData(PRUint32 aDataType)
|
||||
{
|
||||
if (aDataType == NS_NATIVE_SHELL) {
|
||||
return mTopLevel;
|
||||
// return mTopLevel;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
284
widget/src/gtk/nsWidgetFactory.cpp
Normal file
284
widget/src/gtk/nsWidgetFactory.cpp
Normal file
@ -0,0 +1,284 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.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 "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
#include "nsButton.h"
|
||||
#include "nsCheckButton.h"
|
||||
#include "nsComboBox.h"
|
||||
#include "nsFileWidget.h"
|
||||
#include "nsListBox.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(kCDialog, NS_DIALOG_CID);
|
||||
static NS_DEFINE_IID(kCLabel, NS_LABEL_CID);
|
||||
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(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);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsWidgetFactory(const nsCID &aClass);
|
||||
~nsWidgetFactory();
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsWidgetFactory)
|
||||
NS_IMPL_RELEASE(nsWidgetFactory)
|
||||
|
||||
|
||||
nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
nsWidgetFactory::~nsWidgetFactory()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
|
||||
}
|
||||
|
||||
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = (void *)(nsISupports*)this;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = (void *)(nsIFactory*)this;
|
||||
}
|
||||
|
||||
if (*aResult == NULL) {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_ADDREF_THIS(); // Increase reference count for caller
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kCWindow)) {
|
||||
inst = (nsISupports*)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();
|
||||
}
|
||||
else if (mClassID.Equals(kCDialog)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsDialog();
|
||||
}
|
||||
else if (mClassID.Equals(kCLabel)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsLabel();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenuBar)) {
|
||||
inst = (nsISupports*)new nsMenuBar();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenu)) {
|
||||
inst = (nsISupports*)new nsMenu();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenuItem)) {
|
||||
inst = (nsISupports*)new nsMenuItem();
|
||||
}
|
||||
else if (mClassID.Equals(kCImageButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsImageButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCMenuButton)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsMenuButton();
|
||||
}
|
||||
else if (mClassID.Equals(kCToolBar)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsToolbar();
|
||||
}
|
||||
else if (mClassID.Equals(kCToolBarManager)) {
|
||||
inst = (nsISupports*)(nsWindow*)new nsToolbarManager();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsWidgetFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// return the proper factory to the caller
|
||||
extern "C" NS_WIDGET nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
|
||||
{
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aFactory = new nsWidgetFactory(aClass);
|
||||
|
||||
if (nsnull == aFactory) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ nsWindow::nsWindow():
|
||||
mFontMetrics(nsnull),
|
||||
mContext(nsnull),
|
||||
mWidget(nsnull),
|
||||
mGC(nsnull),
|
||||
mEventCallback(nsnull),
|
||||
mIgnoreResize(PR_FALSE)
|
||||
{
|
||||
@ -73,7 +74,6 @@ nsWindow::nsWindow():
|
||||
mBounds.width = 0;
|
||||
mBounds.height = 0;
|
||||
mResized = PR_FALSE;
|
||||
mGC = nsnull ;
|
||||
mShown = PR_FALSE;
|
||||
mVisible = PR_FALSE;
|
||||
mDisplayed = PR_FALSE;
|
||||
@ -183,37 +183,6 @@ void nsWindow::InitToolkit(nsIToolkit *aToolkit,
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::InitDeviceContext(nsIDeviceContext *aContext,
|
||||
GtkWidget *aParentWidget)
|
||||
{
|
||||
// keep a reference to the toolkit object
|
||||
if (aContext) {
|
||||
mContext = aContext;
|
||||
mContext->AddRef();
|
||||
}
|
||||
else {
|
||||
nsresult res;
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
//res = !NS_OK;
|
||||
res = nsRepository::CreateInstance(kDeviceContextCID,
|
||||
nsnull,
|
||||
kDeviceContextIID,
|
||||
(void **)&mContext);
|
||||
if (NS_OK == res) {
|
||||
mContext->Init(aParentWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsWindow::CreateGC()
|
||||
{
|
||||
if (nsnull == mGC) {
|
||||
@ -231,191 +200,57 @@ void nsWindow::CreateGC()
|
||||
}
|
||||
}
|
||||
|
||||
void nsWindow::CreateMainWindow(nsNativeWidget aNativeParent,
|
||||
nsIWidget *aWidgetParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData,
|
||||
nsNativeWidget aNativeParent)
|
||||
{
|
||||
GtkWidget *mainWindow = 0, *frame = 0;
|
||||
GtkWidget *mainWindow = 0, *parentWidget = 0;
|
||||
mBounds = aRect;
|
||||
mAppShell = aAppShell;
|
||||
|
||||
InitToolkit(aToolkit, aWidgetParent);
|
||||
InitToolkit(aToolkit, aParent);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
InitDeviceContext(aContext,
|
||||
(GtkWidget*) aAppShell->GetNativeData(NS_NATIVE_SHELL));
|
||||
|
||||
GtkWidget *frameParent = 0;
|
||||
if (aParent) {
|
||||
parentWidget = GTK_WIDGET(aParent->GetNativeData(NS_NATIVE_WIDGET));
|
||||
} else if (aAppShell) {
|
||||
parentWidget = GTK_WIDGET(aAppShell->GetNativeData(NS_NATIVE_SHELL));
|
||||
}
|
||||
|
||||
// XXX: This is a kludge, need to be able to create multiple top
|
||||
// level windows instead.
|
||||
if (gFirstTopLevelWindow == 0) {
|
||||
mainWindow = aAppShell->GetNativeData(NS_NATIVE_SHELL);
|
||||
//gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
/* mainWindow = ::XtVaCreateManagedWidget("mainWindow",
|
||||
xmMainWindowWidgetClass,
|
||||
(Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL),
|
||||
nsnull);
|
||||
*/
|
||||
mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gFirstTopLevelWindow = mainWindow;
|
||||
} else {
|
||||
mainWindow = gtk_window_new(GTK_WINDOW_POPUP);
|
||||
}
|
||||
/*
|
||||
else {
|
||||
Widget shell = ::XtVaCreatePopupShell(" ",
|
||||
xmDialogShellWidgetClass,
|
||||
(Widget) aAppShell->GetNativeData(NS_NATIVE_SHELL), 0);
|
||||
|
||||
XtVaSetValues(shell, XmNwidth,
|
||||
aRect.width, XmNheight,
|
||||
aRect.height, nsnull);
|
||||
gtk_widget_set_usize(mainWindow, aRect.width, aRect.height);
|
||||
|
||||
mainWindow = ::XtVaCreateManagedWidget("mainWindow",
|
||||
xmMainWindowWidgetClass,
|
||||
shell,
|
||||
nsnull);
|
||||
|
||||
XtVaSetValues(mainWindow, XmNallowShellResize, 1,
|
||||
XmNwidth, aRect.width, XmNheight, aRect.height, nsnull);
|
||||
}
|
||||
*/
|
||||
|
||||
// Initially used xmDrawingAreaWidgetClass instead of
|
||||
// newManageClass. Drawing area will spontaneously resize
|
||||
// to fit it's contents.
|
||||
/*
|
||||
frame = ::XtVaCreateManagedWidget("drawingArea",
|
||||
newManageClass,
|
||||
mainWindow,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNrecomputeSize, False,
|
||||
XmNuserData, this,
|
||||
nsnull);
|
||||
*/
|
||||
mWidget = gtk_vbox_new(0, FALSE);
|
||||
// mWidget = gtk_layout_new(FALSE,FALSE);
|
||||
mWidget = gtk_label_new("foobar!");
|
||||
gtk_container_add(GTK_CONTAINER(mainWindow), mWidget);
|
||||
|
||||
GtkAdjustment *hadj = (GtkAdjustment*)gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
GtkAdjustment *vadj = (GtkAdjustment*)gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
frame = gtk_layout_new(hadj,vadj);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(mWidget), frame, FALSE, FALSE, 0);
|
||||
|
||||
if (mainWindow) {
|
||||
// gtk_container_add(GTK_CONTAINER(mainWindow), frame);
|
||||
// XmMainWindowSetAreas(mainWindow, nsnull, nsnull, nsnull, nsnull, frame);
|
||||
if (aParent) {
|
||||
aParent->AddChild(this);
|
||||
}
|
||||
|
||||
if (aWidgetParent) {
|
||||
aWidgetParent->AddChild(this);
|
||||
}
|
||||
|
||||
InitCallbacks();
|
||||
CreateGC();
|
||||
}
|
||||
|
||||
|
||||
void nsWindow::CreateChildWindow(nsNativeWidget aNativeParent,
|
||||
nsIWidget *aWidgetParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
mBounds = aRect;
|
||||
mAppShell = aAppShell;
|
||||
|
||||
InitToolkit(aToolkit, aWidgetParent);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
InitDeviceContext(aContext, (GtkWidget*)aNativeParent);
|
||||
|
||||
// Initially used xmDrawingAreaWidgetClass instead of
|
||||
// newManageClass. Drawing area will spontaneously resize
|
||||
// to fit it's contents.
|
||||
#if 0
|
||||
mWidget = ::XtVaCreateManagedWidget("drawingArea",
|
||||
newManageClass,
|
||||
(Widget)aNativeParent,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNrecomputeSize, False,
|
||||
XmNuserData, this,
|
||||
nsnull);
|
||||
GtkAdjustment *hadj = (GtkAdjustment*)gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
GtkAdjustment *vadj = (GtkAdjustment*)gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||
mWidget = gtk_layout_new(hadj,vadj);
|
||||
if (aWidgetParent) {
|
||||
aWidgetParent->AddChild(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Force cursor to default setting
|
||||
mCursor = eCursor_select;
|
||||
SetCursor(eCursor_standard);
|
||||
|
||||
InitCallbacks();
|
||||
CreateGC();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Create a window.
|
||||
//
|
||||
// Note: aNativeParent is always non-null if aWidgetParent is non-null.
|
||||
// aNativeaParent is set regardless if the parent for the Create() was an
|
||||
// nsIWidget or a Native widget.
|
||||
// aNativeParent is equal to aWidgetParent->GetNativeData(NS_NATIVE_WIDGET)
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void nsWindow::CreateWindow(nsNativeWidget aNativeParent,
|
||||
nsIWidget *aWidgetParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
// keep a reference to the device context
|
||||
if (aContext) {
|
||||
mContext = aContext;
|
||||
NS_ADDREF(mContext);
|
||||
}
|
||||
else {
|
||||
nsresult res;
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
res = nsRepository::CreateInstance(kDeviceContextCID, nsnull, kDeviceContextIID, (void **)&mContext);
|
||||
|
||||
if (NS_OK == res)
|
||||
mContext->Init(nsnull);
|
||||
}
|
||||
|
||||
if (nsnull==aNativeParent)
|
||||
CreateMainWindow(aNativeParent, aWidgetParent, aRect,
|
||||
aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData);
|
||||
else
|
||||
CreateChildWindow(aNativeParent, aWidgetParent, aRect,
|
||||
aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -524,12 +359,9 @@ NS_METHOD nsWindow::Create(nsIWidget *aParent,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
if (aParent)
|
||||
aParent->AddChild(this);
|
||||
CreateWindow((nsNativeWidget)((aParent) ? aParent->GetNativeData(NS_NATIVE_WIDGET) : 0),
|
||||
aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit,
|
||||
aInitData);
|
||||
return NS_OK;
|
||||
return(StandardWindowCreate(aParent, aRect, aHandleEventFunction,
|
||||
aContext, aAppShell, aToolkit, aInitData,
|
||||
nsnull));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -545,8 +377,9 @@ NS_METHOD nsWindow::Create(nsNativeWidget aParent,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
CreateWindow(aParent, 0, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData);
|
||||
return NS_OK;
|
||||
return(StandardWindowCreate(nsnull, aRect, aHandleEventFunction,
|
||||
aContext, aAppShell, aToolkit, aInitData,
|
||||
aParent));
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,31 +160,16 @@ protected:
|
||||
|
||||
|
||||
void CreateGC();
|
||||
void CreateWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
|
||||
|
||||
nsresult StandardWindowCreate(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
|
||||
void CreateMainWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
|
||||
void CreateChildWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
|
||||
|
||||
nsWidgetInitData *aInitData,
|
||||
nsNativeWidget aNativeParent = nsnull);
|
||||
|
||||
void InitToolkit(nsIToolkit *aToolkit, nsIWidget * aWidgetParent);
|
||||
void InitDeviceContext(nsIDeviceContext *aContext, GtkWidget *aWidgetParent);
|
||||
|
||||
@ -221,12 +206,11 @@ protected:
|
||||
int mResized;
|
||||
PRBool mLowerLeft;
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
GtkWidget *mWidget;
|
||||
GtkWidget *mVBox;
|
||||
GdkGC *mGC;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user