Fixed Linux support for viewing the current text as a label

in the plugin drawing rectangle.  This is part of a fix for
bug #25068. a=ekrock
This commit is contained in:
rusty.lynch%intel.com 2000-06-05 20:35:32 +00:00
Родитель 1f983fa5c8
Коммит 9a68f0d240
2 изменённых файлов: 142 добавлений и 16 удалений

Просмотреть файл

@ -60,9 +60,6 @@
* UNIX includes
*----------------------------------------------------------------------------*/
#ifdef XP_UNIX
//#include <X11/Xlib.h>
//#include <X11/Intrinsic.h>
//#include <X11/StringDefs.h>
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
@ -70,6 +67,12 @@
#include <gtkmozbox.h>
#endif /* XP_UNIX */
#ifdef XP_UNIX
gboolean draw (GtkWidget *widget, GdkEventExpose *event, gpointer data);
#endif
/*******************************************************************************
* SECTION 2 - Instance Structs
@ -105,6 +108,7 @@ typedef struct _PlatformInstance
Window window;
GtkWidget *moz_box;
GdkSuperWin *superwin;
GtkWidget *label;
Display * display;
uint32 x, y;
uint32 width, height;
@ -311,6 +315,10 @@ public:
void SetMode(nsPluginMode mode) { fMode = mode; }
#ifdef XP_UNIX
NS_IMETHOD Repaint(void);
#endif
#if defined(XP_PC) && !defined(XP_OS2)
static LRESULT CALLBACK
PluginWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
@ -713,6 +721,13 @@ SimplePluginInstance::SimplePluginInstance(void)
static const char text[] = "Hello World!";
fText = (char*) nsMemory::Clone(text, sizeof(text));
#ifdef XP_UNIX
fPlatform.moz_box = nsnull;
fPlatform.superwin = nsnull;
fPlatform.label = nsnull;
#endif
}
SimplePluginInstance::~SimplePluginInstance(void)
@ -918,6 +933,11 @@ NS_IMETHODIMP SimplePluginInstance::SetText(const char * aText)
}
#endif
#ifdef XP_UNIX
// force a redraw
Repaint();
#endif
}
return NS_OK;
@ -1161,18 +1181,33 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window)
#ifdef NS_DEBUG
printf("SimplePluginInstance::PlatformSetWindow\n");
#endif
if (window == NULL || window->window == NULL)
return NS_ERROR_NULL_POINTER;
if ( fPlatform.superwin == (GdkSuperWin *)window->window )
return NS_OK;
fPlatform.superwin = (GdkSuperWin *)window->window;
// a little cleanup
if (fPlatform.label)
gtk_widget_destroy(fPlatform.label);
if (fPlatform.moz_box)
gtk_widget_destroy(fPlatform.moz_box);
// create a containing mozbox and a label to put in it
fPlatform.moz_box = gtk_mozbox_new(fPlatform.superwin->bin_window);
fPlatform.label = gtk_label_new(fText);
gtk_container_add(GTK_CONTAINER(fPlatform.moz_box), fPlatform.label);
GtkWidget *button;
// grow the label to fit the entire mozbox
gtk_widget_set_usize(fPlatform.label, window->width, window->height);
button = gtk_button_new_with_label("Hello World");
gtk_container_add(GTK_CONTAINER(fPlatform.moz_box), button);
// connect to expose events
gtk_signal_connect (GTK_OBJECT(fPlatform.label), "expose_event",
GTK_SIGNAL_FUNC(draw), this);
gtk_widget_show(button);
gtk_widget_show(fPlatform.label);
gtk_widget_show(fPlatform.moz_box);
return NS_OK;
@ -1191,6 +1226,34 @@ SimplePluginInstance::PlatformHandleEvent(nsPluginEvent* event)
return 0;
}
NS_IMETHODIMP
SimplePluginInstance::Repaint(void)
{
#ifdef DEBUG
printf("SimplePluginInstance::Repaint()\n");
#endif
if ( !fPlatform.moz_box || !fPlatform.label )
return NS_ERROR_FAILURE;
// Set the label text
gtk_label_set_text(GTK_LABEL(fPlatform.label), fText);
// show the new label
gtk_widget_show(fPlatform.label);
gtk_widget_show(fPlatform.moz_box);
return NS_OK;
}
gboolean draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
SimplePluginInstance * pthis = (SimplePluginInstance *)data;
pthis->Repaint();
return TRUE;
}
/*------------------------------------------------------------------------------
* Windows Implementations
*----------------------------------------------------------------------------*/

Просмотреть файл

@ -60,9 +60,6 @@
* UNIX includes
*----------------------------------------------------------------------------*/
#ifdef XP_UNIX
//#include <X11/Xlib.h>
//#include <X11/Intrinsic.h>
//#include <X11/StringDefs.h>
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
#include <gtk/gtk.h>
@ -70,6 +67,12 @@
#include <gtkmozbox.h>
#endif /* XP_UNIX */
#ifdef XP_UNIX
gboolean draw (GtkWidget *widget, GdkEventExpose *event, gpointer data);
#endif
/*******************************************************************************
* SECTION 2 - Instance Structs
@ -105,6 +108,7 @@ typedef struct _PlatformInstance
Window window;
GtkWidget *moz_box;
GdkSuperWin *superwin;
GtkWidget *label;
Display * display;
uint32 x, y;
uint32 width, height;
@ -311,6 +315,10 @@ public:
void SetMode(nsPluginMode mode) { fMode = mode; }
#ifdef XP_UNIX
NS_IMETHOD Repaint(void);
#endif
#if defined(XP_PC) && !defined(XP_OS2)
static LRESULT CALLBACK
PluginWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
@ -713,6 +721,13 @@ SimplePluginInstance::SimplePluginInstance(void)
static const char text[] = "Hello World!";
fText = (char*) nsMemory::Clone(text, sizeof(text));
#ifdef XP_UNIX
fPlatform.moz_box = nsnull;
fPlatform.superwin = nsnull;
fPlatform.label = nsnull;
#endif
}
SimplePluginInstance::~SimplePluginInstance(void)
@ -918,6 +933,11 @@ NS_IMETHODIMP SimplePluginInstance::SetText(const char * aText)
}
#endif
#ifdef XP_UNIX
// force a redraw
Repaint();
#endif
}
return NS_OK;
@ -1161,18 +1181,33 @@ SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window)
#ifdef NS_DEBUG
printf("SimplePluginInstance::PlatformSetWindow\n");
#endif
if (window == NULL || window->window == NULL)
return NS_ERROR_NULL_POINTER;
if ( fPlatform.superwin == (GdkSuperWin *)window->window )
return NS_OK;
fPlatform.superwin = (GdkSuperWin *)window->window;
// a little cleanup
if (fPlatform.label)
gtk_widget_destroy(fPlatform.label);
if (fPlatform.moz_box)
gtk_widget_destroy(fPlatform.moz_box);
// create a containing mozbox and a label to put in it
fPlatform.moz_box = gtk_mozbox_new(fPlatform.superwin->bin_window);
fPlatform.label = gtk_label_new(fText);
gtk_container_add(GTK_CONTAINER(fPlatform.moz_box), fPlatform.label);
GtkWidget *button;
// grow the label to fit the entire mozbox
gtk_widget_set_usize(fPlatform.label, window->width, window->height);
button = gtk_button_new_with_label("Hello World");
gtk_container_add(GTK_CONTAINER(fPlatform.moz_box), button);
// connect to expose events
gtk_signal_connect (GTK_OBJECT(fPlatform.label), "expose_event",
GTK_SIGNAL_FUNC(draw), this);
gtk_widget_show(button);
gtk_widget_show(fPlatform.label);
gtk_widget_show(fPlatform.moz_box);
return NS_OK;
@ -1191,6 +1226,34 @@ SimplePluginInstance::PlatformHandleEvent(nsPluginEvent* event)
return 0;
}
NS_IMETHODIMP
SimplePluginInstance::Repaint(void)
{
#ifdef DEBUG
printf("SimplePluginInstance::Repaint()\n");
#endif
if ( !fPlatform.moz_box || !fPlatform.label )
return NS_ERROR_FAILURE;
// Set the label text
gtk_label_set_text(GTK_LABEL(fPlatform.label), fText);
// show the new label
gtk_widget_show(fPlatform.label);
gtk_widget_show(fPlatform.moz_box);
return NS_OK;
}
gboolean draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
SimplePluginInstance * pthis = (SimplePluginInstance *)data;
pthis->Repaint();
return TRUE;
}
/*------------------------------------------------------------------------------
* Windows Implementations
*----------------------------------------------------------------------------*/