From 53129acd64c7123703e4c95895c5468719692c8c Mon Sep 17 00:00:00 2001 From: "pavlov%pavlov.net" Date: Mon, 9 Nov 1998 05:45:57 +0000 Subject: [PATCH] Impliment Resize for nsWidget (and nsWindow (it calls nsWidget::Resize/Move) Add patch for gtklayout from Owen Taylor that makes sure the widgets added are shown and realized. We now get a window popped up that shows the spinner, toolbar, menu, etc etc etc. its getting close! --- widget/src/gtk/gtklayout.c | 15 +++++++++++---- widget/src/gtk/nsAppShell.cpp | 1 + widget/src/gtk/nsWidget.cpp | 21 +++++++++++---------- widget/src/gtk/nsWindow.cpp | 14 +++++++++----- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/widget/src/gtk/gtklayout.c b/widget/src/gtk/gtklayout.c index 391326f4dd1f..492ea492396b 100644 --- a/widget/src/gtk/gtklayout.c +++ b/widget/src/gtk/gtklayout.c @@ -162,10 +162,17 @@ gtk_layout_put (GtkLayout *layout, gtk_widget_size_request (child->widget, &child->requisition); - if (GTK_WIDGET_REALIZED (layout) && - !GTK_WIDGET_REALIZED (child_widget)) - gtk_layout_realize_child (layout, child); - + if (GTK_WIDGET_VISIBLE (layout)) + { + if (GTK_WIDGET_REALIZED (layout) && + !GTK_WIDGET_REALIZED (child_widget)) + gtk_widget_realize (child_widget); + + if (GTK_WIDGET_MAPPED (layout) && + !GTK_WIDGET_MAPPED (child_widget)) + gtk_widget_map (child_widget); + } + gtk_layout_position_child (layout, child, TRUE); } diff --git a/widget/src/gtk/nsAppShell.cpp b/widget/src/gtk/nsAppShell.cpp index 7ae5d413abbb..e9f14cdae1b7 100644 --- a/widget/src/gtk/nsAppShell.cpp +++ b/widget/src/gtk/nsAppShell.cpp @@ -48,6 +48,7 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv) gtk_init (argc, &argv); + gtk_rc_init(); // 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 */ diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index bbcafc90ab90..0b88916f961b 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -187,27 +187,28 @@ NS_METHOD nsWidget::IsVisible(PRBool &aState) NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY) { - NS_NOTYETIMPLEMENTED("nsWidget::Move"); -#if 0 + fprintf(stderr,"nsWidget::Move called (%d,%d)\n", aX, aY); mBounds.x = aX; mBounds.y = aY; - // TODO - // gtk_layout_move(GTK_LAYOUT(layout), mWidget, aX, aY); - XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY), nsnull); -#endif - return NS_OK; + gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY); + //XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY), nsnull); + return NS_OK; } NS_METHOD nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) { - NS_NOTYETIMPLEMENTED("nsWidget::Resize"); - return NS_OK; + fprintf(stderr,"nsWidget::Resize called w,h(%d,%d)\n", aWidth, aHeight); + mBounds.width = aWidth; + mBounds.height = aHeight; + gtk_widget_set_usize(mWidget,aWidth, aHeight); + return NS_OK; } NS_METHOD nsWidget::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) { - NS_NOTYETIMPLEMENTED("nsWidget::Resize"); + Resize(aWidth, aHeight, aRepaint); + Move(aX, aY); return NS_OK; } diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 04b9baedddf0..563b4cb9f612 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -37,9 +37,10 @@ #include "stdio.h" #define DBG 0 - +#if 0 +#define DEBUG_shaver 1 #define DEBUG_pavlov 1 - +#endif static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); extern GtkWidget *gAppContext; @@ -209,7 +210,7 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, gtk_box_pack_end(GTK_BOX(mVBox), mWidget, TRUE, TRUE, 0); } else { #ifdef DEBUG_shaver - fprintf(stderr, "StandardCreateWindow: creating GtkLayout subarea\n"); + fprintf(stderr, "StandardCreateWindow: creating GtkLayout subarea (%d,%d)\n", aRect.x, aRect.y); #endif mainWindow = mWidget; gtk_layout_put(GTK_LAYOUT(parentWidget), mWidget, aRect.x, aRect.y); @@ -413,8 +414,9 @@ NS_METHOD nsWindow::Show(PRBool bState) //------------------------------------------------------------------------- NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) { - NS_NOTYETIMPLEMENTED("nsWindow::Resize"); + nsWidget::Resize(aWidth, aHeight,aRepaint); #if 0 + NS_NOTYETIMPLEMENTED("nsWindow::Resize"); if (DBG) printf("$$$$$$$$$ %s::Resize %d %d Repaint: %s\n", gInstanceClassName, aWidth, aHeight, (aRepaint?"true":"false")); mBounds.width = aWidth; @@ -434,8 +436,10 @@ NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) //------------------------------------------------------------------------- NS_METHOD nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) { - NS_NOTYETIMPLEMENTED("nsWindow::Resize"); + nsWindow::Resize(aWidth, aHeight,aRepaint); + nsWidget::Move(aX,aY); #if 0 + NS_NOTYETIMPLEMENTED("nsWindow::Resize"); mBounds.x = aX; mBounds.y = aY; mBounds.width = aWidth;