Inherit nsDialog from nsWindow instead of nsWidget. s/Motif/GTK+/ in *.h for

some comments
This commit is contained in:
pavlov%pavlov.net 1999-01-17 01:36:13 +00:00
parent d596158079
commit a3f65b8ce0
22 changed files with 59 additions and 64 deletions

View File

@ -114,7 +114,6 @@ NS_METHOD nsAppShell::Run()
NS_METHOD nsAppShell::Exit()
{
// gtk_widget_destroy (mTopLevel);
gtk_main_quit ();
gtk_exit(0);

View File

@ -23,7 +23,7 @@
#include <gtk/gtk.h>
/**
* Native GTK Application shell wrapper
* Native GTK+ Application shell wrapper
*/
class nsAppShell : public nsIAppShell

View File

@ -23,7 +23,7 @@
#include "nsIButton.h"
/**
* Native Motif button wrapper
* Native GTK+ button wrapper
*/
class nsButton : public nsWidget,
public nsIButton

View File

@ -23,7 +23,7 @@
#include "nsICheckButton.h"
/**
* Native Motif Checkbox wrapper
* Native GTK+ Checkbox wrapper
*/
class nsCheckButton : public nsWidget,

View File

@ -23,7 +23,7 @@
#include "nsIComboBox.h"
/**
* Native Motif Listbox wrapper
* Native GTK+ Listbox wrapper
*/
class nsComboBox : public nsWidget,

View File

@ -34,28 +34,11 @@ NS_IMPL_RELEASE(nsDialog)
// nsDialog constructor
//
//-------------------------------------------------------------------------
nsDialog::nsDialog() : nsWidget(), nsIDialog()
nsDialog::nsDialog() : nsWindow(), nsIDialog()
{
NS_INIT_REFCNT();
}
//-------------------------------------------------------------------------
//
// Create the native GtkDialog widget
//
//-------------------------------------------------------------------------
NS_METHOD nsDialog::CreateNative(GtkWidget *parentWindow)
{
mShell = gtk_dialog_new();
gtk_widget_set_name(mShell, "nsDialog");
gtk_widget_show(mShell);
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(mShell)->vbox), mWidget);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// nsDialog destructor
@ -65,6 +48,26 @@ nsDialog::~nsDialog()
{
}
//-------------------------------------------------------------------------
//
// Create the native GtkDialog widget
//
//-------------------------------------------------------------------------
NS_METHOD nsDialog::CreateNative(GtkWidget *parentWindow)
{
mShell = gtk_window_new(GTK_WINDOW_DIALOG);
gtk_window_set_default_size(GTK_WINDOW(mShell),
mBounds.width,
mBounds.height);
gtk_widget_set_name(mShell, "nsDialog");
gtk_widget_show(mShell);
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
gtk_container_add(GTK_CONTAINER(mShell), mWidget);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Query interface implementation

View File

@ -19,13 +19,13 @@
#ifndef nsDialog_h__
#define nsDialog_h__
#include "nsWidget.h"
#include "nsWindow.h"
#include "nsIDialog.h"
/**
* Native Motif Dialog wrapper
* Native GTK+ Dialog wrapper
*/
class nsDialog : public nsWidget,
class nsDialog : public nsWindow,
public nsIDialog
{
@ -48,12 +48,7 @@ public:
//virtual void PreCreateWidget(nsWidgetInitData *aInitData);
protected:
NS_IMETHOD nsDialog::CreateNative(GtkWidget *parentWindow);
private:
GtkWidget *mShell;
};
#endif // nsDialog_h__

View File

@ -25,7 +25,7 @@
#include "nsWidget.h"
/**
* Native Motif FileSelector wrapper
* Native GTK+ FileSelector wrapper
*/
class nsFileWidget : public nsWidget, public nsIFileWidget

View File

@ -24,7 +24,7 @@
#include "nsILabel.h"
/**
* Native Motif Label wrapper
* Native GTK+ Label wrapper
*/
class nsLabel : public nsWidget,
public nsILabel

View File

@ -23,7 +23,7 @@
#include "nsIListBox.h"
/**
* Native Motif Listbox wrapper
* Native GTK+ Listbox wrapper
*/
class nsListBox : public nsWidget,

View File

@ -24,7 +24,7 @@
class nsIMenuBar;
/**
* Native Motif Menu wrapper
* Native GTK+ Menu wrapper
*/
class nsMenu : public nsIMenu

View File

@ -24,7 +24,7 @@
class nsIWidget;
/**
* Native Motif MenuBar wrapper
* Native GTK+ MenuBar wrapper
*/
class nsMenuBar : public nsIMenuBar

View File

@ -27,7 +27,7 @@ class nsIPopUpMenu;
class nsIWidget;
/**
* Native Motif MenuItem wrapper
* Native GTK+ MenuItem wrapper
*/
class nsMenuItem : public nsIMenuItem

View File

@ -26,7 +26,7 @@
class nsIWidget;
/**
* Native Motif PopUp wrapper
* Native GTK+ PopUp wrapper
*/
class nsPopUpMenu : public nsIPopUpMenu

View File

@ -23,7 +23,7 @@
#include "nsIRadioButton.h"
/**
* Native Motif Radiobutton wrapper
* Native GTK+ Radiobutton wrapper
*/
class nsRadioButton : public nsWidget,
public nsIRadioButton

View File

@ -23,7 +23,7 @@
#include "nsIScrollbar.h"
/**
* Native GTK scrollbar wrapper.
* Native GTK+ scrollbar wrapper.
*/
class nsScrollbar : public nsWidget,

View File

@ -24,7 +24,7 @@
#include "nsITextAreaWidget.h"
/**
* Native Motif multi-line edit control wrapper.
* Native GTK+ multi-line edit control wrapper.
*/
class nsTextAreaWidget : public nsTextHelper

View File

@ -25,7 +25,7 @@
#include "nsITextWidget.h"
/**
* Native Motif single line edit control wrapper.
* Native GTK+ single line edit control wrapper.
*/
class nsTextWidget : public nsTextHelper

View File

@ -100,6 +100,10 @@ NS_IMETHODIMP nsWidget::Destroy(void)
if (PR_FALSE == mOnDestroyCalled)
OnDestroy();
}
if (mGC) {
::gdk_gc_destroy(mGC);
mGC = nsnull;
}
return NS_OK;
}

View File

@ -32,7 +32,7 @@
#include <gtk/gtk.h>
/**
* Base of all GTK native widgets.
* Base of all GTK+ native widgets.
*/
class nsWidget : public nsBaseWidget

View File

@ -50,6 +50,7 @@ nsWindow::nsWindow()
NS_INIT_REFCNT();
strcpy(gInstanceClassName, "nsWindow");
mFontMetrics = nsnull;
mShell = nsnull;
mVBox = nsnull;
mResized = PR_FALSE;
mVisible = PR_FALSE;
@ -66,15 +67,11 @@ nsWindow::nsWindow()
//-------------------------------------------------------------------------
nsWindow::~nsWindow()
{
if (mWidget)
if (mShell)
{
if (GTK_IS_WIDGET(mWidget))
gtk_widget_destroy(mWidget);
mWidget = nsnull;
}
if (mGC) {
gdk_gc_destroy(mGC);
mGC = nsnull;
if (GTK_IS_WIDGET(mShell))
gtk_widget_destroy(mShell);
mShell = nsnull;
}
}
@ -145,8 +142,6 @@ NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData)
//-------------------------------------------------------------------------
NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
{
GtkWidget *mainWindow;
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
GTK_WIDGET_SET_FLAGS(mWidget, GTK_CAN_FOCUS);
@ -163,17 +158,17 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
if (!parentWidget) {
// mainWindow = gtk_window_new(mBorderStyle);
mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(mainWindow),
// mainWindow = gtk_window_new(mBorderStyle);
mShell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(mShell),
mBounds.width,
mBounds.height);
gtk_widget_show (mainWindow);
gtk_widget_show (mShell);
// VBox for the menu, etc.
mVBox = gtk_vbox_new(PR_FALSE, 0);
gtk_widget_show (mVBox);
gtk_container_add(GTK_CONTAINER(mainWindow), mVBox);
gtk_container_add(GTK_CONTAINER(mShell), mVBox);
gtk_box_pack_start(GTK_BOX(mVBox), mWidget, PR_TRUE, PR_TRUE, 0);
}
@ -290,8 +285,10 @@ NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
NS_METHOD nsWindow::SetTitle(const nsString& aTitle)
{
if (!mShell)
return NS_ERROR_FAILURE;
char * titleStr = aTitle.ToNewCString();
gtk_window_set_title(GTK_WINDOW(mVBox->parent), titleStr);
gtk_window_set_title(GTK_WINDOW(mShell), titleStr);
delete[] titleStr;
return NS_OK;
}

View File

@ -33,7 +33,7 @@ class nsFont;
/**
* Native GTK+ window wrapper.
* Native GTK++ window wrapper.
*/
class nsWindow : public nsWidget
@ -80,8 +80,6 @@ protected:
virtual void InitCallbacks(char * aName = nsnull);
NS_IMETHOD CreateNative(GtkWidget *parentWidget);
public:
protected:
nsIFontMetrics *mFontMetrics;
PRBool mVisible;
PRBool mDisplayed;
@ -96,9 +94,8 @@ protected:
int mResized;
PRBool mLowerLeft;
GtkWidget *mShell; /* used for toplevel windows */
GtkWidget *mVBox;
private:
};
//