+
+ gtk_widget_show(m_widget);
+ }
+ else // hide
+ {
+ gtk_widget_hide(m_widget);
+ }
+
+ wxShowEvent eventShow(GetId(), show);
+ eventShow.SetEventObject(this);
+ HandleWindowEvent(eventShow);
+
+ return true;
+}
+
+void wxWindowGTK::DoEnable( bool enable )
+{
+ wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
+
+ gtk_widget_set_sensitive( m_widget, enable );
+ if (m_wxwindow && (m_wxwindow != m_widget))
+ gtk_widget_set_sensitive( m_wxwindow, enable );
+}
+
+int wxWindowGTK::GetCharHeight() const
+{
+ wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") );
+
+ wxFont font = GetFont();
+ wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") );
+
+ PangoContext* context = gtk_widget_get_pango_context(m_widget);
+
+ if (!context)
+ return 0;
+
+ PangoFontDescription *desc = font.GetNativeFontInfo()->description;
+ PangoLayout *layout = pango_layout_new(context);
+ pango_layout_set_font_description(layout, desc);
+ pango_layout_set_text(layout, "H", 1);
+ PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
+
+ PangoRectangle rect;
+ pango_layout_line_get_extents(line, NULL, &rect);
+
+ g_object_unref (layout);
+
+ return (int) PANGO_PIXELS(rect.height);
+}
+
+int wxWindowGTK::GetCharWidth() const
+{
+ wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") );
+
+ wxFont font = GetFont();
+ wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") );
+
+ PangoContext* context = gtk_widget_get_pango_context(m_widget);
+
+ if (!context)
+ return 0;
+
+ PangoFontDescription *desc = font.GetNativeFontInfo()->description;
+ PangoLayout *layout = pango_layout_new(context);
+ pango_layout_set_font_description(layout, desc);
+ pango_layout_set_text(layout, "g", 1);
+ PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
+
+ PangoRectangle rect;
+ pango_layout_line_get_extents(line, NULL, &rect);
+
+ g_object_unref (layout);
+
+ return (int) PANGO_PIXELS(rect.width);
+}
+
+void wxWindowGTK::DoGetTextExtent( const wxString& string,
+ int *x,
+ int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont ) const
+{
+ wxFont fontToUse = theFont ? *theFont : GetFont();
+
+ wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
+
+ if (string.empty())
+ {
+ if (x) (*x) = 0;
+ if (y) (*y) = 0;
+ return;
+ }
+
+ PangoContext *context = NULL;
+ if (m_widget)
+ context = gtk_widget_get_pango_context( m_widget );
+
+ if (!context)
+ {
+ if (x) (*x) = 0;
+ if (y) (*y) = 0;
+ return;
+ }
+
+ PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
+ PangoLayout *layout = pango_layout_new(context);
+ pango_layout_set_font_description(layout, desc);
+ {
+ const wxCharBuffer data = wxGTK_CONV( string );
+ if ( data )
+ pango_layout_set_text(layout, data, strlen(data));
+ }
+
+ PangoRectangle rect;
+ pango_layout_get_extents(layout, NULL, &rect);
+
+ if (x) (*x) = (wxCoord) PANGO_PIXELS(rect.width);
+ if (y) (*y) = (wxCoord) PANGO_PIXELS(rect.height);
+ if (descent)
+ {
+ PangoLayoutIter *iter = pango_layout_get_iter(layout);
+ int baseline = pango_layout_iter_get_baseline(iter);
+ pango_layout_iter_free(iter);
+ *descent = *y - PANGO_PIXELS(baseline);
+ }
+ if (externalLeading) (*externalLeading) = 0; // ??
+
+ g_object_unref (layout);
+}
+
+void wxWindowGTK::GTKDisableFocusOutEvent()
+{
+ g_signal_handlers_block_by_func( m_focusWidget,
+ (gpointer) gtk_window_focus_out_callback, this);
+}
+
+void wxWindowGTK::GTKEnableFocusOutEvent()
+{
+ g_signal_handlers_unblock_by_func( m_focusWidget,
+ (gpointer) gtk_window_focus_out_callback, this);
+}
+
+bool wxWindowGTK::GTKHandleFocusIn()
+{
+ // Disable default focus handling for custom windows since the default GTK+
+ // handler issues a repaint
+ const bool retval = m_wxwindow ? true : false;
+
+
+ // NB: if there's still unprocessed deferred focus-out event (see
+ // GTKHandleFocusOut() for explanation), we need to process it first so
+ // that the order of focus events -- focus-out first, then focus-in
+ // elsewhere -- is preserved
+ if ( gs_deferredFocusOut )
+ {
+ if ( GTKNeedsToFilterSameWindowFocus() &&
+ gs_deferredFocusOut == this )