diff --git a/include/wx/font.h b/include/wx/font.h index c627010124..5628bdffd9 100644 --- a/include/wx/font.h +++ b/include/wx/font.h @@ -81,6 +81,9 @@ struct WXDLLEXPORT wxNativeFontInfo; class WXDLLEXPORT wxFontBase : public wxGDIObject { public: + // default constructor + wxFontBase() { m_noAA = FALSE; } + // creator function virtual ~wxFontBase(); @@ -141,6 +144,10 @@ public: wxString GetStyleString() const; wxString GetWeightString() const; + // Unofficial API, don't use + void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; } + bool GetNoAntiAliasing() { return m_noAA; } + // the default encoding is used for creating all fonts with default // encoding parameter static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } @@ -150,7 +157,10 @@ protected: // get the internal data wxFontRefData *GetFontData() const { return (wxFontRefData *)m_refData; } - + + // Don't use the native anti-aliasing + bool m_noAA; + private: // the currently default encoding: by default, it's the default system // encoding, but may be changed by the application using diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index 802e60b693..a9cb16b074 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -118,6 +118,8 @@ public: wxWindow *m_owner; wxRegion m_currentClippingRegion; wxRegion m_paintClippingRegion; + + // PangoContext stuff for GTK 2.0 #ifdef __WXGTK20__ PangoContext *m_context; PangoFontDescription *m_fontdesc; diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index a64652f93f..13adf9b21f 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -157,6 +157,17 @@ public: // and sets m_widgetStyle to this value. GtkStyle *GetWidgetStyle(); +#ifdef __WXGTK20__ + // Returns the default context which usually is anti-aliased + PangoContext *GtkGetPangoDefaultContext(); + + // Returns the X11 context which renders on the X11 client + // side (which can be remote) and which usually is not + // anti-aliased and is thus faster + PangoContext *GtkGetPangoX11Context(); + PangoContext *m_x11Context; +#endif + // Called by SetFont() and SetXXXColour etc void SetWidgetStyle(); diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h index 802e60b693..a9cb16b074 100644 --- a/include/wx/gtk1/dcclient.h +++ b/include/wx/gtk1/dcclient.h @@ -118,6 +118,8 @@ public: wxWindow *m_owner; wxRegion m_currentClippingRegion; wxRegion m_paintClippingRegion; + + // PangoContext stuff for GTK 2.0 #ifdef __WXGTK20__ PangoContext *m_context; PangoFontDescription *m_fontdesc; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index a64652f93f..13adf9b21f 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -157,6 +157,17 @@ public: // and sets m_widgetStyle to this value. GtkStyle *GetWidgetStyle(); +#ifdef __WXGTK20__ + // Returns the default context which usually is anti-aliased + PangoContext *GtkGetPangoDefaultContext(); + + // Returns the X11 context which renders on the X11 client + // side (which can be remote) and which usually is not + // anti-aliased and is thus faster + PangoContext *GtkGetPangoX11Context(); + PangoContext *m_x11Context; +#endif + // Called by SetFont() and SetXXXColour etc void SetWidgetStyle(); diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index 9697a6d3ac..8441af3fd5 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -86,6 +86,7 @@ struct wxCmdLineOption GetLongOptionName(lng).Len() == lng.Len(), wxT("Long option contains invalid characters") ); + kind = k; diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 4938730bd8..2adc607c33 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -1074,7 +1074,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, } if ( firstWild.Left( 2 ) == wxT("*.") ) m_filterExtension = firstWild.Mid( 1 ); - if ( m_filterExtension == ".*" ) + if ( m_filterExtension == wxT(".*") ) m_filterExtension = wxEmptyString; // layout diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 6e9e380ebd..3d2ad4d292 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -330,12 +330,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) wxASSERT_MSG( widget, wxT("DC needs a widget") ); #ifdef __WXGTK20__ - m_context = gtk_widget_get_pango_context( widget ); - - // Always take Xft context to get matching fonts - // for display and printing. - // m_context = pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ())); - + m_context = window->GtkGetPangoDefaultContext(); m_fontdesc = widget->style->font_desc; #endif @@ -1414,19 +1409,23 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCHECK_RET( Ok(), wxT("invalid window dc") ); if (!m_window) return; + + if (text.empty()) return; +#ifndef __WXGTK20__ GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_RET( font, wxT("invalid font") ); +#endif -#if defined(__WXGTK20__) +#ifdef __WXGTK20__ wxCHECK_RET( m_context, wxT("no Pango context") ); #endif x = XLOG2DEV(x); y = YLOG2DEV(y); -#if defined(__WXGTK20__) +#ifdef __WXGTK20__ // TODO: the layout engine should be abstracted at a higher level! PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); @@ -1734,6 +1733,14 @@ void wxWindowDC::SetFont( const wxFont &font ) m_font = font; #ifdef __WXGTK20__ m_fontdesc = m_font.GetNativeFontInfo()->description; + + if (m_owner) + { + if (m_font.GetNoAntiAliasing()) + m_context = m_owner->GtkGetPangoX11Context(); + else + m_context = m_owner->GtkGetPangoDefaultContext(); + } #endif } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 641fe09094..7e1ed2b2ba 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -164,7 +164,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) child->m_y, child->m_width, child->m_height ); - + #if wxUSE_TOOLBAR_NATIVE // We connect to these events for recalculating the client area // space when the toolbar is floating @@ -192,7 +192,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) child->m_width, child->m_height ); } - + // Resize on OnInternalIdle parent->GtkUpdateSize(); } @@ -219,6 +219,7 @@ bool wxFrame::Create( wxWindow *parent, bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, style, name); m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; + return rt; } @@ -576,7 +577,7 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); } - + m_frameMenuBar->Show( TRUE ); UpdateMenuBarSize(); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index ba4b2a14da..5178cf554b 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -385,7 +385,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) #endif // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables - // adding menu later on. + // addings menu later on. if (m_invokingWindow) { wxMenubarSetInvokingWindow( menu, m_invokingWindow ); @@ -396,9 +396,9 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) // see (and refactor :) similar code in Remove // below. - wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame ); + wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame ); - if( frame ) + if( frame ) frame->UpdateMenuBarSize(); } @@ -773,12 +773,22 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) { if ( *pc == wxT('_') ) { - // wxGTK escapes "xxx_xxx" to "xxx__xxx" + // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx" pc++; label += *pc; continue; } +#if GTK_CHECK_VERSION(2, 0, 0) + if ( *pc == wxT('\\') ) + { + // GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx" + pc++; + label += *pc; + continue; + } +#endif + if ( *pc == wxT('&') ) { // wxMSW escapes & @@ -807,42 +817,49 @@ void wxMenuItem::SetText( const wxString& str ) { GtkLabel *label; if (m_labelWidget) - label = (GtkLabel*) m_labelWidget; + label = (GtkLabel*) m_labelWidget; else - label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); + label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); - /* set new text */ +#if GTK_CHECK_VERSION(2, 0, 0) + // We have to imitate item_factory_unescape_label here + wxString tmp; + for (size_t n = 0; n < m_text.Len(); n++) + { + if (m_text[n] != wxT('\\')) + tmp += m_text[n]; + } + + gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(tmp) ); +#else + // set new text gtk_label_set( label, wxGTK_CONV( m_text ) ); - /* reparse key accel */ - (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( m_text ) ); + // reparse key accel + (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); +#endif } } // it's valid for this function to be called even if m_menuItem == NULL void wxMenuItem::DoSetText( const wxString& str ) { - /* '\t' is the deliminator indicating a hot key */ + // '\t' is the deliminator indicating a hot key m_text.Empty(); const wxChar *pc = str; for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ ) { -#if GTK_CHECK_VERSION(1, 2, 0) if (*pc == wxT('&')) { m_text << wxT('_'); } + +#if GTK_CHECK_VERSION(2, 0, 0) else if ( *pc == wxT('_') ) // escape underscores { - m_text << wxT("__"); + // m_text << wxT("__"); doesn't work } -#else // GTK+ < 1.2.0 - if (*pc == wxT('&')) - { - } -#endif -#if GTK_CHECK_VERSION(2, 0, 0) else if (*pc == wxT('/')) // we have to escape slashes { m_text << wxT("\\/"); @@ -851,7 +868,11 @@ void wxMenuItem::DoSetText( const wxString& str ) { m_text << wxT("\\\\"); } -#elif GTK_CHECK_VERSION(1, 2, 0) +#elif + else if ( *pc == wxT('_') ) // escape underscores + { + m_text << wxT("__"); + } else if (*pc == wxT('/')) /* we have to filter out slashes ... */ { m_text << wxT('\\'); /* ... and replace them with back slashes */ @@ -1065,7 +1086,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) ); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem); if (accel_key != GDK_VoidSymbol) - { + { gtk_widget_add_accelerator (menuItem, "activate_item", gtk_menu_ensure_uline_accel_group (GTK_MENU (m_menu)), @@ -1083,6 +1104,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) gtk_signal_connect( GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), (gpointer)this ); + gtk_menu_append( GTK_MENU(m_menu), menuItem ); gtk_widget_show( menuItem ); @@ -1166,10 +1188,15 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) wxString path( mitem->GetFactoryPath() ); menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) ); + + if (!menuItem) + wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() ); } if ( !mitem->IsSeparator() ) { + wxASSERT_MSG( menuItem, wxT("invalid menuitem") ); + gtk_signal_connect( GTK_OBJECT(menuItem), "select", GTK_SIGNAL_FUNC(gtk_menu_hilight_callback), (gpointer)this ); diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index bba5d91e63..6b9a2bf9dd 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -313,7 +313,7 @@ bool wxScrolledWindow::Create(wxWindow *parent, PostCreation(); Show( TRUE ); - + return TRUE; } diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index 704086c960..d05f2cddfb 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -475,7 +475,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) return FALSE; } - + gtk_signal_connect( GTK_OBJECT(tool->m_item), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback), diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 30c495822b..199fef91a8 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -67,6 +67,10 @@ #include "wx/gtk/win_gtk.h" +#ifdef __WXGTK20__ +#include +#endif + #ifdef __WXGTK20__ #define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d)) #else @@ -2533,6 +2537,7 @@ void wxWindowGTK::Init() #ifdef __WXGTK20__ m_imContext = NULL; + m_x11Context = NULL; #else #ifdef HAVE_XIM m_ic = (GdkIC*) NULL; @@ -2571,7 +2576,7 @@ bool wxWindowGTK::Create( wxWindow *parent, wxFAIL_MSG( wxT("wxWindowGTK creation failed") ); return FALSE; } - + m_insertCallback = wxInsertChildInWindow; // always needed for background clearing @@ -2806,7 +2811,6 @@ void wxWindowGTK::PostCreation() g_signal_connect (G_OBJECT (m_imContext), "commit", G_CALLBACK (gtk_wxwindow_commit_cb), this); #endif - } // these are called when the "sunken" or "raised" borders are drawn @@ -3401,11 +3405,11 @@ void wxWindowGTK::GetTextExtent( const wxString& string, if (y) (*y) = 0; return; } + #ifdef __WXGTK20__ - PangoContext *context = NULL; if (m_widget) - gtk_widget_get_pango_context( m_widget ); + context = gtk_widget_get_pango_context( m_widget ); if (!context) { @@ -3983,6 +3987,21 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) return TRUE; } +#ifdef __WXGTK20__ +PangoContext *wxWindowGTK::GtkGetPangoDefaultContext() +{ + return gtk_widget_get_pango_context( m_widget ); +} + +PangoContext *wxWindowGTK::GtkGetPangoX11Context() +{ + if (!m_x11Context) + m_x11Context = pango_x_get_context( gdk_display ); + + return m_x11Context; +} +#endif + GtkStyle *wxWindowGTK::GetWidgetStyle() { if (m_widgetStyle) diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 6e9e380ebd..3d2ad4d292 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -330,12 +330,7 @@ wxWindowDC::wxWindowDC( wxWindow *window ) wxASSERT_MSG( widget, wxT("DC needs a widget") ); #ifdef __WXGTK20__ - m_context = gtk_widget_get_pango_context( widget ); - - // Always take Xft context to get matching fonts - // for display and printing. - // m_context = pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ())); - + m_context = window->GtkGetPangoDefaultContext(); m_fontdesc = widget->style->font_desc; #endif @@ -1414,19 +1409,23 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCHECK_RET( Ok(), wxT("invalid window dc") ); if (!m_window) return; + + if (text.empty()) return; +#ifndef __WXGTK20__ GdkFont *font = m_font.GetInternalFont( m_scaleY ); wxCHECK_RET( font, wxT("invalid font") ); +#endif -#if defined(__WXGTK20__) +#ifdef __WXGTK20__ wxCHECK_RET( m_context, wxT("no Pango context") ); #endif x = XLOG2DEV(x); y = YLOG2DEV(y); -#if defined(__WXGTK20__) +#ifdef __WXGTK20__ // TODO: the layout engine should be abstracted at a higher level! PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); @@ -1734,6 +1733,14 @@ void wxWindowDC::SetFont( const wxFont &font ) m_font = font; #ifdef __WXGTK20__ m_fontdesc = m_font.GetNativeFontInfo()->description; + + if (m_owner) + { + if (m_font.GetNoAntiAliasing()) + m_context = m_owner->GtkGetPangoX11Context(); + else + m_context = m_owner->GtkGetPangoDefaultContext(); + } #endif } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 641fe09094..7e1ed2b2ba 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -164,7 +164,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) child->m_y, child->m_width, child->m_height ); - + #if wxUSE_TOOLBAR_NATIVE // We connect to these events for recalculating the client area // space when the toolbar is floating @@ -192,7 +192,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) child->m_width, child->m_height ); } - + // Resize on OnInternalIdle parent->GtkUpdateSize(); } @@ -219,6 +219,7 @@ bool wxFrame::Create( wxWindow *parent, bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, style, name); m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; + return rt; } @@ -576,7 +577,7 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); } - + m_frameMenuBar->Show( TRUE ); UpdateMenuBarSize(); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index ba4b2a14da..5178cf554b 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -385,7 +385,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) #endif // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables - // adding menu later on. + // addings menu later on. if (m_invokingWindow) { wxMenubarSetInvokingWindow( menu, m_invokingWindow ); @@ -396,9 +396,9 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) // see (and refactor :) similar code in Remove // below. - wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame ); + wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame ); - if( frame ) + if( frame ) frame->UpdateMenuBarSize(); } @@ -773,12 +773,22 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) { if ( *pc == wxT('_') ) { - // wxGTK escapes "xxx_xxx" to "xxx__xxx" + // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx" pc++; label += *pc; continue; } +#if GTK_CHECK_VERSION(2, 0, 0) + if ( *pc == wxT('\\') ) + { + // GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx" + pc++; + label += *pc; + continue; + } +#endif + if ( *pc == wxT('&') ) { // wxMSW escapes & @@ -807,42 +817,49 @@ void wxMenuItem::SetText( const wxString& str ) { GtkLabel *label; if (m_labelWidget) - label = (GtkLabel*) m_labelWidget; + label = (GtkLabel*) m_labelWidget; else - label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); + label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); - /* set new text */ +#if GTK_CHECK_VERSION(2, 0, 0) + // We have to imitate item_factory_unescape_label here + wxString tmp; + for (size_t n = 0; n < m_text.Len(); n++) + { + if (m_text[n] != wxT('\\')) + tmp += m_text[n]; + } + + gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(tmp) ); +#else + // set new text gtk_label_set( label, wxGTK_CONV( m_text ) ); - /* reparse key accel */ - (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( m_text ) ); + // reparse key accel + (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); +#endif } } // it's valid for this function to be called even if m_menuItem == NULL void wxMenuItem::DoSetText( const wxString& str ) { - /* '\t' is the deliminator indicating a hot key */ + // '\t' is the deliminator indicating a hot key m_text.Empty(); const wxChar *pc = str; for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ ) { -#if GTK_CHECK_VERSION(1, 2, 0) if (*pc == wxT('&')) { m_text << wxT('_'); } + +#if GTK_CHECK_VERSION(2, 0, 0) else if ( *pc == wxT('_') ) // escape underscores { - m_text << wxT("__"); + // m_text << wxT("__"); doesn't work } -#else // GTK+ < 1.2.0 - if (*pc == wxT('&')) - { - } -#endif -#if GTK_CHECK_VERSION(2, 0, 0) else if (*pc == wxT('/')) // we have to escape slashes { m_text << wxT("\\/"); @@ -851,7 +868,11 @@ void wxMenuItem::DoSetText( const wxString& str ) { m_text << wxT("\\\\"); } -#elif GTK_CHECK_VERSION(1, 2, 0) +#elif + else if ( *pc == wxT('_') ) // escape underscores + { + m_text << wxT("__"); + } else if (*pc == wxT('/')) /* we have to filter out slashes ... */ { m_text << wxT('\\'); /* ... and replace them with back slashes */ @@ -1065,7 +1086,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) ); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem); if (accel_key != GDK_VoidSymbol) - { + { gtk_widget_add_accelerator (menuItem, "activate_item", gtk_menu_ensure_uline_accel_group (GTK_MENU (m_menu)), @@ -1083,6 +1104,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) gtk_signal_connect( GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), (gpointer)this ); + gtk_menu_append( GTK_MENU(m_menu), menuItem ); gtk_widget_show( menuItem ); @@ -1166,10 +1188,15 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) wxString path( mitem->GetFactoryPath() ); menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) ); + + if (!menuItem) + wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() ); } if ( !mitem->IsSeparator() ) { + wxASSERT_MSG( menuItem, wxT("invalid menuitem") ); + gtk_signal_connect( GTK_OBJECT(menuItem), "select", GTK_SIGNAL_FUNC(gtk_menu_hilight_callback), (gpointer)this ); diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index bba5d91e63..6b9a2bf9dd 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -313,7 +313,7 @@ bool wxScrolledWindow::Create(wxWindow *parent, PostCreation(); Show( TRUE ); - + return TRUE; } diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index 704086c960..d05f2cddfb 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -475,7 +475,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) return FALSE; } - + gtk_signal_connect( GTK_OBJECT(tool->m_item), "enter_notify_event", GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback), diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 30c495822b..199fef91a8 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -67,6 +67,10 @@ #include "wx/gtk/win_gtk.h" +#ifdef __WXGTK20__ +#include +#endif + #ifdef __WXGTK20__ #define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d)) #else @@ -2533,6 +2537,7 @@ void wxWindowGTK::Init() #ifdef __WXGTK20__ m_imContext = NULL; + m_x11Context = NULL; #else #ifdef HAVE_XIM m_ic = (GdkIC*) NULL; @@ -2571,7 +2576,7 @@ bool wxWindowGTK::Create( wxWindow *parent, wxFAIL_MSG( wxT("wxWindowGTK creation failed") ); return FALSE; } - + m_insertCallback = wxInsertChildInWindow; // always needed for background clearing @@ -2806,7 +2811,6 @@ void wxWindowGTK::PostCreation() g_signal_connect (G_OBJECT (m_imContext), "commit", G_CALLBACK (gtk_wxwindow_commit_cb), this); #endif - } // these are called when the "sunken" or "raised" borders are drawn @@ -3401,11 +3405,11 @@ void wxWindowGTK::GetTextExtent( const wxString& string, if (y) (*y) = 0; return; } + #ifdef __WXGTK20__ - PangoContext *context = NULL; if (m_widget) - gtk_widget_get_pango_context( m_widget ); + context = gtk_widget_get_pango_context( m_widget ); if (!context) { @@ -3983,6 +3987,21 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) return TRUE; } +#ifdef __WXGTK20__ +PangoContext *wxWindowGTK::GtkGetPangoDefaultContext() +{ + return gtk_widget_get_pango_context( m_widget ); +} + +PangoContext *wxWindowGTK::GtkGetPangoX11Context() +{ + if (!m_x11Context) + m_x11Context = pango_x_get_context( gdk_display ); + + return m_x11Context; +} +#endif + GtkStyle *wxWindowGTK::GetWidgetStyle() { if (m_widgetStyle)