From 6308151359ba88ae05d8d61ad82adf6d51c19fc0 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 7 Dec 1999 11:59:07 +0000 Subject: [PATCH] Added wxUSE_SPINCTRL, Added various HAVE_XIM patches. Added forty's headers to list of installed files. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4853 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 3 +- distrib/msw/tmake/unx.t | 1 + include/wx/defs.h | 4 ++ include/wx/gtk/window.h | 6 ++ include/wx/gtk1/window.h | 6 ++ setup.h.in | 4 ++ src/gtk/window.cpp | 143 ++++++++++++++++++++++++++++++++++++--- src/gtk1/window.cpp | 143 ++++++++++++++++++++++++++++++++++++--- 8 files changed, 291 insertions(+), 19 deletions(-) diff --git a/Makefile.in b/Makefile.in index 5dbfdea918..378d521292 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# This file was automatically generated by tmake at 16:17, 1999/12/04 +# This file was automatically generated by tmake at 12:32, 1999/12/07 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -2437,6 +2437,7 @@ SAMPLES_DIST: mkdir $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/Makefile.in $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/makefile.unx $(DISTDIR)/samples/forty + cp $(SAMPDIR)/forty/*.h $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/*.cpp $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/*.xpm $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/*.xbm $(DISTDIR)/samples/forty diff --git a/distrib/msw/tmake/unx.t b/distrib/msw/tmake/unx.t index 0066a39bdc..115f4821a9 100644 --- a/distrib/msw/tmake/unx.t +++ b/distrib/msw/tmake/unx.t @@ -914,6 +914,7 @@ SAMPLES_DIST: mkdir $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/Makefile.in $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/makefile.unx $(DISTDIR)/samples/forty + cp $(SAMPDIR)/forty/*.h $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/*.cpp $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/*.xpm $(DISTDIR)/samples/forty cp $(SAMPDIR)/forty/*.xbm $(DISTDIR)/samples/forty diff --git a/include/wx/defs.h b/include/wx/defs.h index 2df82c842a..676b0ace7b 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1790,6 +1790,10 @@ typedef struct _GdkWindow GdkPixmap; typedef struct _GdkCursor GdkCursor; typedef struct _GdkRegion GdkRegion; typedef struct _GdkDragContext GdkDragContext; +#ifdef HAVE_XIM +typedef struct _GdkIC GdkIC; +typedef struct _GdkICAttr GdkICAttr; +#endif /* Stand-ins for GTK types */ typedef struct _GtkWidget GtkWidget; diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 9ec7f12639..90a6cdeda5 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -167,6 +167,12 @@ public: GtkWidget *m_widget; GtkWidget *m_wxwindow; +#if HAVE_XIM + /* XIM support for wxWindows */ + GdkIC *m_ic; + GdkICAttr *m_icattr; +#endif + /* scrolling stuff */ GtkAdjustment *m_hAdjust,*m_vAdjust; float m_oldHorizontalPos; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 9ec7f12639..90a6cdeda5 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -167,6 +167,12 @@ public: GtkWidget *m_widget; GtkWidget *m_wxwindow; +#if HAVE_XIM + /* XIM support for wxWindows */ + GdkIC *m_ic; + GdkICAttr *m_icattr; +#endif + /* scrolling stuff */ GtkAdjustment *m_hAdjust,*m_vAdjust; float m_oldHorizontalPos; diff --git a/setup.h.in b/setup.h.in index 94e16ee56e..be5879c04b 100644 --- a/setup.h.in +++ b/setup.h.in @@ -278,6 +278,10 @@ * Use this control */ #define wxUSE_SPINBTN 0 +/* + * Use this control + */ +#define wxUSE_SPINCTRL 0 /* * Use this control */ diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 2f617eaacd..756fc35801 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1621,7 +1621,7 @@ wxWindow *wxWindowBase::FindFocus() been realized, so we do this directly after realization */ static gint -gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) +gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1642,6 +1642,98 @@ gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) return FALSE; } +//----------------------------------------------------------------------------- +// "realize" from m_wxwindow +//----------------------------------------------------------------------------- + +/* Initialize XIM support */ + +static gint +gtk_wxwindow_realized_callback( GtkWidget *widget, wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + +#ifdef USE_XIM + if (win->m_ic) return FALSE; + if (!widget) return FALSE; + if (!gdk_im_ready()) return FALSE; + + win->m_icattr = gdk_ic_attr_new(); + if (!win->m_icattr) return FALSE; + + gint width, height; + GdkEventMask mask; + GdkColormap *colormap; + GdkICAttr *attr = win->m_icattr; + GdkICAttributesType attrmask = GDK_IC_ALL_REQ; + GdkIMStyle style; + GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE | + GDK_IM_PREEDIT_NOTHING | + GDK_IM_PREEDIT_POSITION | + GDK_IM_STATUS_NONE | + GDK_IM_STATUS_NOTHING; + + if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) + supported_style &= ~GDK_IM_PREEDIT_POSITION; + + attr->style = style = gdk_im_decide_style (supported_style); + attr->client_window = widget->window; + + if ((colormap = gtk_widget_get_colormap (widget)) != + gtk_widget_get_default_colormap ()) + { + attrmask |= GDK_IC_PREEDIT_COLORMAP; + attr->preedit_colormap = colormap; + } + + attrmask |= GDK_IC_PREEDIT_FOREGROUND; + attrmask |= GDK_IC_PREEDIT_BACKGROUND; + attr->preedit_foreground = widget->style->fg[GTK_STATE_NORMAL]; + attr->preedit_background = widget->style->base[GTK_STATE_NORMAL]; + + switch (style & GDK_IM_PREEDIT_MASK) + { + case GDK_IM_PREEDIT_POSITION: + if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) + { + g_warning ("over-the-spot style requires fontset"); + break; + } + + gdk_window_get_size (widget->window, &width, &height); + + attrmask |= GDK_IC_PREEDIT_POSITION_REQ; + attr->spot_location.x = 0; + attr->spot_location.y = height; + attr->preedit_area.x = 0; + attr->preedit_area.y = 0; + attr->preedit_area.width = width; + attr->preedit_area.height = height; + attr->preedit_fontset = widget->style->font; + + break; + } + + win->m_ic = gdk_ic_new (attr, attrmask); + + if (win->m_ic == NULL) + g_warning ("Can't create input context."); + else + { + mask = gdk_window_get_events (widget->window); + mask |= gdk_ic_get_events (win->m_ic); + gdk_window_set_events (widget->window, mask); + + if (GTK_WIDGET_HAS_FOCUS(widget)) + gdk_im_begin (win->m_ic, widget->window); + } + } +#endif + + return FALSE; +} + //----------------------------------------------------------------------------- // InsertChild for wxWindow. //----------------------------------------------------------------------------- @@ -1726,6 +1818,11 @@ void wxWindow::Init() m_acceptsFocus = FALSE; m_cursor = *wxSTANDARD_CURSOR; + +#ifdef HAVE_XIM + m_ic = (GdkIC*) NULL; + m_icattr = (GdkICAttr*) NULL; +#endif } wxWindow::wxWindow() @@ -1901,6 +1998,13 @@ wxWindow::~wxWindow() if (m_parent) m_parent->RemoveChild( this ); +#ifdef HAVE_XIM + if (m_ic) + gdk_ic_destroy (m_ic); + if (m_icattr) + gdk_ic_attr_destroy (m_icattr); +#endif + if (m_widgetStyle) { gtk_style_unref( m_widgetStyle ); @@ -1978,15 +2082,42 @@ void wxWindow::PostCreation() #endif } + if (m_wxwindow && m_needParent) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "focus_in_event", + GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); + + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "focus_out_event", + GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); + } + else + { + // For dialogs and frames, we are interested mainly in + // m_widget's focus. + + gtk_signal_connect( GTK_OBJECT(m_widget), "focus_in_event", + GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); + + gtk_signal_connect( GTK_OBJECT(m_widget), "focus_out_event", + GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); + } + GtkWidget *connect_widget = GetConnectWidget(); ConnectWidget( connect_widget ); - /* we cannot set colours, fonts and cursors before the widget has + /* We cannot set colours, fonts and cursors before the widget has been realized, so we do this directly after realization */ gtk_signal_connect( GTK_OBJECT(connect_widget), "realize", GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this ); - + + /* Initialize XIM support. */ + if (m_wxwindow) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", + GTK_SIGNAL_FUNC(gtk_wxwindow_realized_callback), (gpointer) this ); + } + m_hasVMT = TRUE; } @@ -2007,12 +2138,6 @@ void wxWindow::ConnectWidget( GtkWidget *widget ) gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", - GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", - GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 2f617eaacd..756fc35801 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1621,7 +1621,7 @@ wxWindow *wxWindowBase::FindFocus() been realized, so we do this directly after realization */ static gint -gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) +gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -1642,6 +1642,98 @@ gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) return FALSE; } +//----------------------------------------------------------------------------- +// "realize" from m_wxwindow +//----------------------------------------------------------------------------- + +/* Initialize XIM support */ + +static gint +gtk_wxwindow_realized_callback( GtkWidget *widget, wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + +#ifdef USE_XIM + if (win->m_ic) return FALSE; + if (!widget) return FALSE; + if (!gdk_im_ready()) return FALSE; + + win->m_icattr = gdk_ic_attr_new(); + if (!win->m_icattr) return FALSE; + + gint width, height; + GdkEventMask mask; + GdkColormap *colormap; + GdkICAttr *attr = win->m_icattr; + GdkICAttributesType attrmask = GDK_IC_ALL_REQ; + GdkIMStyle style; + GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE | + GDK_IM_PREEDIT_NOTHING | + GDK_IM_PREEDIT_POSITION | + GDK_IM_STATUS_NONE | + GDK_IM_STATUS_NOTHING; + + if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) + supported_style &= ~GDK_IM_PREEDIT_POSITION; + + attr->style = style = gdk_im_decide_style (supported_style); + attr->client_window = widget->window; + + if ((colormap = gtk_widget_get_colormap (widget)) != + gtk_widget_get_default_colormap ()) + { + attrmask |= GDK_IC_PREEDIT_COLORMAP; + attr->preedit_colormap = colormap; + } + + attrmask |= GDK_IC_PREEDIT_FOREGROUND; + attrmask |= GDK_IC_PREEDIT_BACKGROUND; + attr->preedit_foreground = widget->style->fg[GTK_STATE_NORMAL]; + attr->preedit_background = widget->style->base[GTK_STATE_NORMAL]; + + switch (style & GDK_IM_PREEDIT_MASK) + { + case GDK_IM_PREEDIT_POSITION: + if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) + { + g_warning ("over-the-spot style requires fontset"); + break; + } + + gdk_window_get_size (widget->window, &width, &height); + + attrmask |= GDK_IC_PREEDIT_POSITION_REQ; + attr->spot_location.x = 0; + attr->spot_location.y = height; + attr->preedit_area.x = 0; + attr->preedit_area.y = 0; + attr->preedit_area.width = width; + attr->preedit_area.height = height; + attr->preedit_fontset = widget->style->font; + + break; + } + + win->m_ic = gdk_ic_new (attr, attrmask); + + if (win->m_ic == NULL) + g_warning ("Can't create input context."); + else + { + mask = gdk_window_get_events (widget->window); + mask |= gdk_ic_get_events (win->m_ic); + gdk_window_set_events (widget->window, mask); + + if (GTK_WIDGET_HAS_FOCUS(widget)) + gdk_im_begin (win->m_ic, widget->window); + } + } +#endif + + return FALSE; +} + //----------------------------------------------------------------------------- // InsertChild for wxWindow. //----------------------------------------------------------------------------- @@ -1726,6 +1818,11 @@ void wxWindow::Init() m_acceptsFocus = FALSE; m_cursor = *wxSTANDARD_CURSOR; + +#ifdef HAVE_XIM + m_ic = (GdkIC*) NULL; + m_icattr = (GdkICAttr*) NULL; +#endif } wxWindow::wxWindow() @@ -1901,6 +1998,13 @@ wxWindow::~wxWindow() if (m_parent) m_parent->RemoveChild( this ); +#ifdef HAVE_XIM + if (m_ic) + gdk_ic_destroy (m_ic); + if (m_icattr) + gdk_ic_attr_destroy (m_icattr); +#endif + if (m_widgetStyle) { gtk_style_unref( m_widgetStyle ); @@ -1978,15 +2082,42 @@ void wxWindow::PostCreation() #endif } + if (m_wxwindow && m_needParent) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "focus_in_event", + GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); + + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "focus_out_event", + GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); + } + else + { + // For dialogs and frames, we are interested mainly in + // m_widget's focus. + + gtk_signal_connect( GTK_OBJECT(m_widget), "focus_in_event", + GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); + + gtk_signal_connect( GTK_OBJECT(m_widget), "focus_out_event", + GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); + } + GtkWidget *connect_widget = GetConnectWidget(); ConnectWidget( connect_widget ); - /* we cannot set colours, fonts and cursors before the widget has + /* We cannot set colours, fonts and cursors before the widget has been realized, so we do this directly after realization */ gtk_signal_connect( GTK_OBJECT(connect_widget), "realize", GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this ); - + + /* Initialize XIM support. */ + if (m_wxwindow) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", + GTK_SIGNAL_FUNC(gtk_wxwindow_realized_callback), (gpointer) this ); + } + m_hasVMT = TRUE; } @@ -2007,12 +2138,6 @@ void wxWindow::ConnectWidget( GtkWidget *widget ) gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event", - GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event", - GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); -- 2.45.2