Lots of minor GTK2 updates.

Added wxFont SetNoAntiAliasing which cannot cause
    problems with existing apps since it doesn't
    changing the current style flags.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17636 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-10-28 00:21:00 +00:00
parent 87c6ba105c
commit d089223aa3
19 changed files with 221 additions and 76 deletions

View File

@@ -81,6 +81,9 @@ struct WXDLLEXPORT wxNativeFontInfo;
class WXDLLEXPORT wxFontBase : public wxGDIObject class WXDLLEXPORT wxFontBase : public wxGDIObject
{ {
public: public:
// default constructor
wxFontBase() { m_noAA = FALSE; }
// creator function // creator function
virtual ~wxFontBase(); virtual ~wxFontBase();
@@ -141,6 +144,10 @@ public:
wxString GetStyleString() const; wxString GetStyleString() const;
wxString GetWeightString() 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 // the default encoding is used for creating all fonts with default
// encoding parameter // encoding parameter
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
@@ -151,6 +158,9 @@ protected:
wxFontRefData *GetFontData() const wxFontRefData *GetFontData() const
{ return (wxFontRefData *)m_refData; } { return (wxFontRefData *)m_refData; }
// Don't use the native anti-aliasing
bool m_noAA;
private: private:
// the currently default encoding: by default, it's the default system // the currently default encoding: by default, it's the default system
// encoding, but may be changed by the application using // encoding, but may be changed by the application using

View File

@@ -118,6 +118,8 @@ public:
wxWindow *m_owner; wxWindow *m_owner;
wxRegion m_currentClippingRegion; wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion; wxRegion m_paintClippingRegion;
// PangoContext stuff for GTK 2.0
#ifdef __WXGTK20__ #ifdef __WXGTK20__
PangoContext *m_context; PangoContext *m_context;
PangoFontDescription *m_fontdesc; PangoFontDescription *m_fontdesc;

View File

@@ -157,6 +157,17 @@ public:
// and sets m_widgetStyle to this value. // and sets m_widgetStyle to this value.
GtkStyle *GetWidgetStyle(); 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 // Called by SetFont() and SetXXXColour etc
void SetWidgetStyle(); void SetWidgetStyle();

View File

@@ -118,6 +118,8 @@ public:
wxWindow *m_owner; wxWindow *m_owner;
wxRegion m_currentClippingRegion; wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion; wxRegion m_paintClippingRegion;
// PangoContext stuff for GTK 2.0
#ifdef __WXGTK20__ #ifdef __WXGTK20__
PangoContext *m_context; PangoContext *m_context;
PangoFontDescription *m_fontdesc; PangoFontDescription *m_fontdesc;

View File

@@ -157,6 +157,17 @@ public:
// and sets m_widgetStyle to this value. // and sets m_widgetStyle to this value.
GtkStyle *GetWidgetStyle(); 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 // Called by SetFont() and SetXXXColour etc
void SetWidgetStyle(); void SetWidgetStyle();

View File

@@ -87,6 +87,7 @@ struct wxCmdLineOption
wxT("Long option contains invalid characters") wxT("Long option contains invalid characters")
); );
kind = k; kind = k;
shortName = shrt; shortName = shrt;

View File

@@ -1074,7 +1074,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
} }
if ( firstWild.Left( 2 ) == wxT("*.") ) if ( firstWild.Left( 2 ) == wxT("*.") )
m_filterExtension = firstWild.Mid( 1 ); m_filterExtension = firstWild.Mid( 1 );
if ( m_filterExtension == ".*" ) if ( m_filterExtension == wxT(".*") )
m_filterExtension = wxEmptyString; m_filterExtension = wxEmptyString;
// layout // layout

View File

@@ -330,12 +330,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
wxASSERT_MSG( widget, wxT("DC needs a widget") ); wxASSERT_MSG( widget, wxT("DC needs a widget") );
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_context = gtk_widget_get_pango_context( widget ); m_context = window->GtkGetPangoDefaultContext();
// Always take Xft context to get matching fonts
// for display and printing.
// m_context = pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ()));
m_fontdesc = widget->style->font_desc; m_fontdesc = widget->style->font_desc;
#endif #endif
@@ -1415,18 +1410,22 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
if (!m_window) return; if (!m_window) return;
if (text.empty()) return;
#ifndef __WXGTK20__
GdkFont *font = m_font.GetInternalFont( m_scaleY ); GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_RET( font, wxT("invalid font") ); wxCHECK_RET( font, wxT("invalid font") );
#endif
#if defined(__WXGTK20__) #ifdef __WXGTK20__
wxCHECK_RET( m_context, wxT("no Pango context") ); wxCHECK_RET( m_context, wxT("no Pango context") );
#endif #endif
x = XLOG2DEV(x); x = XLOG2DEV(x);
y = YLOG2DEV(y); y = YLOG2DEV(y);
#if defined(__WXGTK20__) #ifdef __WXGTK20__
// TODO: the layout engine should be abstracted at a higher level! // TODO: the layout engine should be abstracted at a higher level!
PangoLayout *layout = pango_layout_new(m_context); PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc); pango_layout_set_font_description(layout, m_fontdesc);
@@ -1734,6 +1733,14 @@ void wxWindowDC::SetFont( const wxFont &font )
m_font = font; m_font = font;
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_fontdesc = m_font.GetNativeFontInfo()->description; 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 #endif
} }

View File

@@ -219,6 +219,7 @@ bool wxFrame::Create( wxWindow *parent,
bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
style, name); style, name);
m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
return rt; return rt;
} }

View File

@@ -385,7 +385,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title)
#endif #endif
// m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
// adding menu later on. // addings menu later on.
if (m_invokingWindow) if (m_invokingWindow)
{ {
wxMenubarSetInvokingWindow( menu, m_invokingWindow ); wxMenubarSetInvokingWindow( menu, m_invokingWindow );
@@ -773,12 +773,22 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{ {
if ( *pc == wxT('_') ) if ( *pc == wxT('_') )
{ {
// wxGTK escapes "xxx_xxx" to "xxx__xxx" // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx"
pc++; pc++;
label += *pc; label += *pc;
continue; 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('&') ) if ( *pc == wxT('&') )
{ {
// wxMSW escapes & // wxMSW escapes &
@@ -811,38 +821,45 @@ void wxMenuItem::SetText( const wxString& str )
else 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 ) ); gtk_label_set( label, wxGTK_CONV( m_text ) );
/* reparse key accel */ // reparse key accel
(void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
#endif
} }
} }
// it's valid for this function to be called even if m_menuItem == NULL // it's valid for this function to be called even if m_menuItem == NULL
void wxMenuItem::DoSetText( const wxString& str ) 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(); m_text.Empty();
const wxChar *pc = str; const wxChar *pc = str;
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ ) for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
{ {
#if GTK_CHECK_VERSION(1, 2, 0)
if (*pc == wxT('&')) if (*pc == wxT('&'))
{ {
m_text << wxT('_'); m_text << wxT('_');
} }
#if GTK_CHECK_VERSION(2, 0, 0)
else if ( *pc == wxT('_') ) // escape underscores 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 else if (*pc == wxT('/')) // we have to escape slashes
{ {
m_text << wxT("\\/"); m_text << wxT("\\/");
@@ -851,7 +868,11 @@ void wxMenuItem::DoSetText( const wxString& str )
{ {
m_text << wxT("\\\\"); 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 ... */ else if (*pc == wxT('/')) /* we have to filter out slashes ... */
{ {
m_text << wxT('\\'); /* ... and replace them with back slashes */ m_text << wxT('\\'); /* ... and replace them with back slashes */
@@ -1083,6 +1104,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
gtk_signal_connect( GTK_OBJECT(menuItem), "activate", gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer)this ); (gpointer)this );
gtk_menu_append( GTK_MENU(m_menu), menuItem ); gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem ); gtk_widget_show( menuItem );
@@ -1166,10 +1188,15 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
wxString path( mitem->GetFactoryPath() ); wxString path( mitem->GetFactoryPath() );
menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) ); 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() ) if ( !mitem->IsSeparator() )
{ {
wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
gtk_signal_connect( GTK_OBJECT(menuItem), "select", gtk_signal_connect( GTK_OBJECT(menuItem), "select",
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback), GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
(gpointer)this ); (gpointer)this );

View File

@@ -67,6 +67,10 @@
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#ifdef __WXGTK20__
#include <pango/pangox.h>
#endif
#ifdef __WXGTK20__ #ifdef __WXGTK20__
#define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d)) #define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
#else #else
@@ -2533,6 +2537,7 @@ void wxWindowGTK::Init()
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_imContext = NULL; m_imContext = NULL;
m_x11Context = NULL;
#else #else
#ifdef HAVE_XIM #ifdef HAVE_XIM
m_ic = (GdkIC*) NULL; m_ic = (GdkIC*) NULL;
@@ -2806,7 +2811,6 @@ void wxWindowGTK::PostCreation()
g_signal_connect (G_OBJECT (m_imContext), "commit", g_signal_connect (G_OBJECT (m_imContext), "commit",
G_CALLBACK (gtk_wxwindow_commit_cb), this); G_CALLBACK (gtk_wxwindow_commit_cb), this);
#endif #endif
} }
// these are called when the "sunken" or "raised" borders are drawn // 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; if (y) (*y) = 0;
return; return;
} }
#ifdef __WXGTK20__
#ifdef __WXGTK20__
PangoContext *context = NULL; PangoContext *context = NULL;
if (m_widget) if (m_widget)
gtk_widget_get_pango_context( m_widget ); context = gtk_widget_get_pango_context( m_widget );
if (!context) if (!context)
{ {
@@ -3983,6 +3987,21 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
return TRUE; 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() GtkStyle *wxWindowGTK::GetWidgetStyle()
{ {
if (m_widgetStyle) if (m_widgetStyle)

View File

@@ -330,12 +330,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
wxASSERT_MSG( widget, wxT("DC needs a widget") ); wxASSERT_MSG( widget, wxT("DC needs a widget") );
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_context = gtk_widget_get_pango_context( widget ); m_context = window->GtkGetPangoDefaultContext();
// Always take Xft context to get matching fonts
// for display and printing.
// m_context = pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ()));
m_fontdesc = widget->style->font_desc; m_fontdesc = widget->style->font_desc;
#endif #endif
@@ -1415,18 +1410,22 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
if (!m_window) return; if (!m_window) return;
if (text.empty()) return;
#ifndef __WXGTK20__
GdkFont *font = m_font.GetInternalFont( m_scaleY ); GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_RET( font, wxT("invalid font") ); wxCHECK_RET( font, wxT("invalid font") );
#endif
#if defined(__WXGTK20__) #ifdef __WXGTK20__
wxCHECK_RET( m_context, wxT("no Pango context") ); wxCHECK_RET( m_context, wxT("no Pango context") );
#endif #endif
x = XLOG2DEV(x); x = XLOG2DEV(x);
y = YLOG2DEV(y); y = YLOG2DEV(y);
#if defined(__WXGTK20__) #ifdef __WXGTK20__
// TODO: the layout engine should be abstracted at a higher level! // TODO: the layout engine should be abstracted at a higher level!
PangoLayout *layout = pango_layout_new(m_context); PangoLayout *layout = pango_layout_new(m_context);
pango_layout_set_font_description(layout, m_fontdesc); pango_layout_set_font_description(layout, m_fontdesc);
@@ -1734,6 +1733,14 @@ void wxWindowDC::SetFont( const wxFont &font )
m_font = font; m_font = font;
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_fontdesc = m_font.GetNativeFontInfo()->description; 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 #endif
} }

View File

@@ -219,6 +219,7 @@ bool wxFrame::Create( wxWindow *parent,
bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
style, name); style, name);
m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
return rt; return rt;
} }

View File

@@ -385,7 +385,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title)
#endif #endif
// m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
// adding menu later on. // addings menu later on.
if (m_invokingWindow) if (m_invokingWindow)
{ {
wxMenubarSetInvokingWindow( menu, m_invokingWindow ); wxMenubarSetInvokingWindow( menu, m_invokingWindow );
@@ -773,12 +773,22 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{ {
if ( *pc == wxT('_') ) if ( *pc == wxT('_') )
{ {
// wxGTK escapes "xxx_xxx" to "xxx__xxx" // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx"
pc++; pc++;
label += *pc; label += *pc;
continue; 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('&') ) if ( *pc == wxT('&') )
{ {
// wxMSW escapes & // wxMSW escapes &
@@ -811,38 +821,45 @@ void wxMenuItem::SetText( const wxString& str )
else 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 ) ); gtk_label_set( label, wxGTK_CONV( m_text ) );
/* reparse key accel */ // reparse key accel
(void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
#endif
} }
} }
// it's valid for this function to be called even if m_menuItem == NULL // it's valid for this function to be called even if m_menuItem == NULL
void wxMenuItem::DoSetText( const wxString& str ) 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(); m_text.Empty();
const wxChar *pc = str; const wxChar *pc = str;
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ ) for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
{ {
#if GTK_CHECK_VERSION(1, 2, 0)
if (*pc == wxT('&')) if (*pc == wxT('&'))
{ {
m_text << wxT('_'); m_text << wxT('_');
} }
#if GTK_CHECK_VERSION(2, 0, 0)
else if ( *pc == wxT('_') ) // escape underscores 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 else if (*pc == wxT('/')) // we have to escape slashes
{ {
m_text << wxT("\\/"); m_text << wxT("\\/");
@@ -851,7 +868,11 @@ void wxMenuItem::DoSetText( const wxString& str )
{ {
m_text << wxT("\\\\"); 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 ... */ else if (*pc == wxT('/')) /* we have to filter out slashes ... */
{ {
m_text << wxT('\\'); /* ... and replace them with back slashes */ m_text << wxT('\\'); /* ... and replace them with back slashes */
@@ -1083,6 +1104,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
gtk_signal_connect( GTK_OBJECT(menuItem), "activate", gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer)this ); (gpointer)this );
gtk_menu_append( GTK_MENU(m_menu), menuItem ); gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem ); gtk_widget_show( menuItem );
@@ -1166,10 +1188,15 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
wxString path( mitem->GetFactoryPath() ); wxString path( mitem->GetFactoryPath() );
menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) ); 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() ) if ( !mitem->IsSeparator() )
{ {
wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
gtk_signal_connect( GTK_OBJECT(menuItem), "select", gtk_signal_connect( GTK_OBJECT(menuItem), "select",
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback), GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
(gpointer)this ); (gpointer)this );

View File

@@ -67,6 +67,10 @@
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#ifdef __WXGTK20__
#include <pango/pangox.h>
#endif
#ifdef __WXGTK20__ #ifdef __WXGTK20__
#define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d)) #define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
#else #else
@@ -2533,6 +2537,7 @@ void wxWindowGTK::Init()
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_imContext = NULL; m_imContext = NULL;
m_x11Context = NULL;
#else #else
#ifdef HAVE_XIM #ifdef HAVE_XIM
m_ic = (GdkIC*) NULL; m_ic = (GdkIC*) NULL;
@@ -2806,7 +2811,6 @@ void wxWindowGTK::PostCreation()
g_signal_connect (G_OBJECT (m_imContext), "commit", g_signal_connect (G_OBJECT (m_imContext), "commit",
G_CALLBACK (gtk_wxwindow_commit_cb), this); G_CALLBACK (gtk_wxwindow_commit_cb), this);
#endif #endif
} }
// these are called when the "sunken" or "raised" borders are drawn // 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; if (y) (*y) = 0;
return; return;
} }
#ifdef __WXGTK20__
#ifdef __WXGTK20__
PangoContext *context = NULL; PangoContext *context = NULL;
if (m_widget) if (m_widget)
gtk_widget_get_pango_context( m_widget ); context = gtk_widget_get_pango_context( m_widget );
if (!context) if (!context)
{ {
@@ -3983,6 +3987,21 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour )
return TRUE; 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() GtkStyle *wxWindowGTK::GetWidgetStyle()
{ {
if (m_widgetStyle) if (m_widgetStyle)