generate EVT_CONTEXT_MENU under GTK
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -505,10 +505,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
|||||||
// This callback gets called in drawing-idle time under
|
// This callback gets called in drawing-idle time under
|
||||||
// GTK 2.0, so we don't need to defer anything to idle
|
// GTK 2.0, so we don't need to defer anything to idle
|
||||||
// time anymore.
|
// time anymore.
|
||||||
|
|
||||||
GtkPizza *pizza = GTK_PIZZA( widget );
|
GtkPizza *pizza = GTK_PIZZA( widget );
|
||||||
if (gdk_event->window != pizza->bin_window) return FALSE;
|
if (gdk_event->window != pizza->bin_window) return FALSE;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (win->GetName())
|
if (win->GetName())
|
||||||
{
|
{
|
||||||
@@ -525,15 +525,15 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
|||||||
win->GetUpdateRegion() = wxRegion( gdk_event->region );
|
win->GetUpdateRegion() = wxRegion( gdk_event->region );
|
||||||
|
|
||||||
win->GtkSendPaintEvents();
|
win->GtkSendPaintEvents();
|
||||||
|
|
||||||
|
|
||||||
// Let parent window draw window less widgets
|
// Let parent window draw window less widgets
|
||||||
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
|
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
|
||||||
#else
|
#else
|
||||||
// This gets called immediately after an expose event
|
// This gets called immediately after an expose event
|
||||||
// under GTK 1.2 so we collect the calls and wait for
|
// under GTK 1.2 so we collect the calls and wait for
|
||||||
// the idle handler to pick things up.
|
// the idle handler to pick things up.
|
||||||
|
|
||||||
win->GetUpdateRegion().Union( gdk_event->area.x,
|
win->GetUpdateRegion().Union( gdk_event->area.x,
|
||||||
gdk_event->area.y,
|
gdk_event->area.y,
|
||||||
gdk_event->area.width,
|
gdk_event->area.width,
|
||||||
@@ -1136,7 +1136,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
|
wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
|
||||||
|
|
||||||
event.m_keyCode = key_code;
|
event.m_keyCode = key_code;
|
||||||
|
|
||||||
// Implement OnCharHook by checking ancesteror top level windows
|
// Implement OnCharHook by checking ancesteror top level windows
|
||||||
wxWindow *parent = win;
|
wxWindow *parent = win;
|
||||||
while (parent && !parent->IsTopLevel())
|
while (parent && !parent->IsTopLevel())
|
||||||
@@ -1218,7 +1218,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1235,10 +1235,10 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (g_blockEventsOnDrag)
|
if (g_blockEventsOnDrag)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
bool ret = FALSE;
|
bool ret = FALSE;
|
||||||
bool dont_use_IM = FALSE;
|
bool dont_use_IM = FALSE;
|
||||||
|
|
||||||
wxKeyEvent event( wxEVT_KEY_DOWN );
|
wxKeyEvent event( wxEVT_KEY_DOWN );
|
||||||
long keycode = wxTranslateKeySymToWXKey( gdk_event->keyval, FALSE );
|
long keycode = wxTranslateKeySymToWXKey( gdk_event->keyval, FALSE );
|
||||||
if (keycode)
|
if (keycode)
|
||||||
@@ -1246,7 +1246,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
// We were able to decode the key press without
|
// We were able to decode the key press without
|
||||||
// any input method, so don't use it.
|
// any input method, so don't use it.
|
||||||
dont_use_IM = TRUE;
|
dont_use_IM = TRUE;
|
||||||
|
|
||||||
// now fill all the other fields
|
// now fill all the other fields
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
@@ -1266,11 +1266,11 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
event.m_x = x;
|
event.m_x = x;
|
||||||
event.m_y = y;
|
event.m_y = y;
|
||||||
event.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
|
|
||||||
// send key down event
|
// send key down event
|
||||||
ret = win->GetEventHandler()->ProcessEvent( event );
|
ret = win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
// Implement OnCharHook by checking ancesteror top level windows
|
// Implement OnCharHook by checking ancesteror top level windows
|
||||||
wxWindow *parent = win;
|
wxWindow *parent = win;
|
||||||
@@ -1288,7 +1288,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
ret = win->GetEventHandler()->ProcessEvent( event );
|
ret = win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// win is a control: tab can be propagated up
|
// win is a control: tab can be propagated up
|
||||||
if ( !ret &&
|
if ( !ret &&
|
||||||
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
|
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
|
||||||
@@ -1314,7 +1314,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
if ( btnCancel ) break;
|
if ( btnCancel ) break;
|
||||||
|
|
||||||
if ( winForCancel->IsTopLevel() ) break;
|
if ( winForCancel->IsTopLevel() ) break;
|
||||||
|
|
||||||
winForCancel = winForCancel->GetParent();
|
winForCancel = winForCancel->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1326,24 +1326,24 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dont_use_IM && win->m_imContext)
|
if (!dont_use_IM && win->m_imContext)
|
||||||
{
|
{
|
||||||
// In GTK 2.0, we need to hand over the key
|
// In GTK 2.0, we need to hand over the key
|
||||||
// event to an input method and the IM will
|
// event to an input method and the IM will
|
||||||
// emit a "commit" event containing the
|
// emit a "commit" event containing the
|
||||||
// actual utf8 character.
|
// actual utf8 character.
|
||||||
gtk_im_context_filter_keypress ( (GtkIMContext*) win->m_imContext, gdk_event );
|
gtk_im_context_filter_keypress ( (GtkIMContext*) win->m_imContext, gdk_event );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1351,13 +1351,13 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
const gchar *str,
|
const gchar *str,
|
||||||
wxWindow *window)
|
wxWindow *window)
|
||||||
{
|
{
|
||||||
bool ret = FALSE;
|
bool ret = FALSE;
|
||||||
|
|
||||||
wxKeyEvent event( wxEVT_KEY_DOWN );
|
wxKeyEvent event( wxEVT_KEY_DOWN );
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
event.m_uniChar = g_utf8_get_char( str );
|
event.m_uniChar = g_utf8_get_char( str );
|
||||||
|
|
||||||
// Backward compatible for ISO-8859
|
// Backward compatible for ISO-8859
|
||||||
if (event.m_uniChar < 256)
|
if (event.m_uniChar < 256)
|
||||||
event.m_keyCode = event.m_uniChar;
|
event.m_keyCode = event.m_uniChar;
|
||||||
@@ -1365,10 +1365,10 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
gunichar uniChar = g_utf8_get_char( str );
|
gunichar uniChar = g_utf8_get_char( str );
|
||||||
// We cannot handle Unicode in non-Unicode mode
|
// We cannot handle Unicode in non-Unicode mode
|
||||||
if (uniChar > 255) return;
|
if (uniChar > 255) return;
|
||||||
|
|
||||||
event.m_keyCode = uniChar;
|
event.m_keyCode = uniChar;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
// Implement OnCharHook by checking ancesteror top level windows
|
// Implement OnCharHook by checking ancesteror top level windows
|
||||||
@@ -1618,7 +1618,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEventType event_type = wxEVT_NULL;
|
wxEventType event_type = wxEVT_NULL;
|
||||||
|
|
||||||
if (gdk_event->button == 1)
|
if (gdk_event->button == 1)
|
||||||
@@ -1708,7 +1708,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
|
|||||||
// "button_release_event"
|
// "button_release_event"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win )
|
static gint gtk_window_button_release_callback( GtkWidget *widget,
|
||||||
|
GdkEventButton *gdk_event,
|
||||||
|
wxWindowGTK *win )
|
||||||
{
|
{
|
||||||
DEBUG_MAIN_THREAD
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
@@ -1721,21 +1723,25 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
|||||||
|
|
||||||
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
|
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
|
||||||
|
|
||||||
/*
|
|
||||||
printf( "OnButtonRelease from " );
|
|
||||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
|
||||||
printf( win->GetClassInfo()->GetClassName() );
|
|
||||||
printf( ".\n" );
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxEventType event_type = wxEVT_NULL;
|
wxEventType event_type = wxEVT_NULL;
|
||||||
|
|
||||||
switch (gdk_event->button)
|
switch (gdk_event->button)
|
||||||
{
|
{
|
||||||
case 1: event_type = wxEVT_LEFT_UP; break;
|
case 1:
|
||||||
case 2: event_type = wxEVT_MIDDLE_UP; break;
|
event_type = wxEVT_LEFT_UP;
|
||||||
case 3: event_type = wxEVT_RIGHT_UP; break;
|
break;
|
||||||
default: return FALSE;
|
|
||||||
|
case 2:
|
||||||
|
event_type = wxEVT_MIDDLE_UP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
event_type = wxEVT_RIGHT_UP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// unknwon button, don't process
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMouseEvent event( event_type );
|
wxMouseEvent event( event_type );
|
||||||
@@ -1746,6 +1752,20 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
|||||||
// same wxListBox hack as above
|
// same wxListBox hack as above
|
||||||
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
|
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
|
||||||
|
|
||||||
|
if ( event_type == wxEVT_RIGHT_UP )
|
||||||
|
{
|
||||||
|
// generate a "context menu" event: this is similar to wxEVT_RIGHT_UP
|
||||||
|
// except that:
|
||||||
|
//
|
||||||
|
// (a) it's a command event and so is propagated to the parent
|
||||||
|
// (b) under MSW it can be generated from kbd too
|
||||||
|
// (c) it uses screen coords (because of (a))
|
||||||
|
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
|
||||||
|
win->GetId(),
|
||||||
|
win->ClientToScreen(event.GetPosition()));
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent(evtCtx);
|
||||||
|
}
|
||||||
|
|
||||||
if ( !g_captureWindow )
|
if ( !g_captureWindow )
|
||||||
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
|
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
|
||||||
|
|
||||||
@@ -1894,7 +1914,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
|
|||||||
#endif // wxUSE_CARET
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
g_activeFrameLostFocus = FALSE;
|
g_activeFrameLostFocus = FALSE;
|
||||||
|
|
||||||
wxWindowGTK *active = wxGetTopLevelParent(win);
|
wxWindowGTK *active = wxGetTopLevelParent(win);
|
||||||
if ( active != g_activeFrame )
|
if ( active != g_activeFrame )
|
||||||
{
|
{
|
||||||
@@ -1911,7 +1931,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
|
|||||||
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
|
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
|
||||||
event.SetEventObject(g_activeFrame);
|
event.SetEventObject(g_activeFrame);
|
||||||
g_activeFrame->GetEventHandler()->ProcessEvent(event);
|
g_activeFrame->GetEventHandler()->ProcessEvent(event);
|
||||||
|
|
||||||
// Don't send focus events in addition to activate
|
// Don't send focus events in addition to activate
|
||||||
// if (win == g_activeFrame)
|
// if (win == g_activeFrame)
|
||||||
// return TRUE;
|
// return TRUE;
|
||||||
@@ -2277,7 +2297,7 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
|
|||||||
|
|
||||||
if (win->m_delayedForegroundColour)
|
if (win->m_delayedForegroundColour)
|
||||||
win->GtkSetForegroundColour( win->GetForegroundColour() );
|
win->GtkSetForegroundColour( win->GetForegroundColour() );
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
if (win->m_imContext)
|
if (win->m_imContext)
|
||||||
{
|
{
|
||||||
@@ -2548,7 +2568,7 @@ void wxWindowGTK::Init()
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
m_imContext = NULL;
|
m_imContext = NULL;
|
||||||
m_x11Context = NULL;
|
m_x11Context = NULL;
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_XIM
|
#ifdef HAVE_XIM
|
||||||
m_ic = (GdkIC*) NULL;
|
m_ic = (GdkIC*) NULL;
|
||||||
m_icattr = (GdkICAttr*) NULL;
|
m_icattr = (GdkICAttr*) NULL;
|
||||||
@@ -2586,11 +2606,11 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
|||||||
wxFAIL_MSG( wxT("wxWindowGTK creation failed") );
|
wxFAIL_MSG( wxT("wxWindowGTK creation failed") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_insertCallback = wxInsertChildInWindow;
|
m_insertCallback = wxInsertChildInWindow;
|
||||||
|
|
||||||
// always needed for background clearing
|
// always needed for background clearing
|
||||||
m_delayedBackgroundColour = TRUE;
|
m_delayedBackgroundColour = TRUE;
|
||||||
|
|
||||||
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
|
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
|
||||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||||
@@ -2677,10 +2697,10 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
// Create input method handler
|
// Create input method handler
|
||||||
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
||||||
|
|
||||||
// Cannot handle drawing preedited text yet
|
// Cannot handle drawing preedited text yet
|
||||||
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
||||||
|
|
||||||
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
|
||||||
@@ -2786,7 +2806,7 @@ bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const w
|
|||||||
void wxWindowGTK::PostCreation()
|
void wxWindowGTK::PostCreation()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
||||||
|
|
||||||
if (m_wxwindow)
|
if (m_wxwindow)
|
||||||
{
|
{
|
||||||
if (!m_noExpose)
|
if (!m_noExpose)
|
||||||
@@ -2814,10 +2834,10 @@ void wxWindowGTK::PostCreation()
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
// Create input method handler
|
// Create input method handler
|
||||||
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
||||||
|
|
||||||
// Cannot handle drawing preedited text yet
|
// Cannot handle drawing preedited text yet
|
||||||
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
||||||
|
|
||||||
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
|
||||||
@@ -2906,7 +2926,7 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
|
|||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
|
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
|
||||||
|
|
||||||
// This keeps crashing on me. RR.
|
// This keeps crashing on me. RR.
|
||||||
//
|
//
|
||||||
// gtk_signal_connect( GTK_OBJECT(widget), "destroy",
|
// gtk_signal_connect( GTK_OBJECT(widget), "destroy",
|
||||||
@@ -3065,7 +3085,7 @@ void wxWindowGTK::OnInternalIdle()
|
|||||||
}
|
}
|
||||||
g_activeFrameLostFocus = FALSE;
|
g_activeFrameLostFocus = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor cursor = m_cursor;
|
wxCursor cursor = m_cursor;
|
||||||
if (g_globalCursor.Ok()) cursor = g_globalCursor;
|
if (g_globalCursor.Ok()) cursor = g_globalCursor;
|
||||||
|
|
||||||
@@ -3413,26 +3433,26 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
if (theFont) fontToUse = *theFont;
|
if (theFont) fontToUse = *theFont;
|
||||||
|
|
||||||
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
|
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
|
||||||
|
|
||||||
if (string.IsEmpty())
|
if (string.IsEmpty())
|
||||||
{
|
{
|
||||||
if (x) (*x) = 0;
|
if (x) (*x) = 0;
|
||||||
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)
|
||||||
context = gtk_widget_get_pango_context( m_widget );
|
context = gtk_widget_get_pango_context( m_widget );
|
||||||
|
|
||||||
if (!context)
|
if (!context)
|
||||||
{
|
{
|
||||||
if (x) (*x) = 0;
|
if (x) (*x) = 0;
|
||||||
if (y) (*y) = 0;
|
if (y) (*y) = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
|
PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
|
||||||
PangoLayout *layout = pango_layout_new(context);
|
PangoLayout *layout = pango_layout_new(context);
|
||||||
pango_layout_set_font_description(layout, desc);
|
pango_layout_set_font_description(layout, desc);
|
||||||
@@ -3447,10 +3467,10 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
|
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
|
||||||
|
|
||||||
PangoRectangle rect;
|
PangoRectangle rect;
|
||||||
pango_layout_line_get_extents(line, NULL, &rect);
|
pango_layout_line_get_extents(line, NULL, &rect);
|
||||||
|
|
||||||
if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE);
|
if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE);
|
||||||
if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE);
|
if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE);
|
||||||
if (descent)
|
if (descent)
|
||||||
@@ -3459,7 +3479,7 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
(*descent) = 0;
|
(*descent) = 0;
|
||||||
}
|
}
|
||||||
if (externalLeading) (*externalLeading) = 0; // ??
|
if (externalLeading) (*externalLeading) = 0; // ??
|
||||||
|
|
||||||
g_object_unref( G_OBJECT( layout ) );
|
g_object_unref( G_OBJECT( layout ) );
|
||||||
#else
|
#else
|
||||||
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
|
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
|
||||||
@@ -3636,11 +3656,11 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
|
|||||||
{
|
{
|
||||||
if (!m_widget) return;
|
if (!m_widget) return;
|
||||||
if (!m_widget->window) return;
|
if (!m_widget->window) return;
|
||||||
|
|
||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
if (eraseBackground && m_wxwindow && m_wxwindow->window)
|
if (eraseBackground && m_wxwindow && m_wxwindow->window)
|
||||||
{
|
{
|
||||||
if (rect)
|
if (rect)
|
||||||
@@ -3726,7 +3746,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
{
|
{
|
||||||
if (!m_wxwindow)
|
if (!m_wxwindow)
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
m_clearRegion.Clear();
|
m_clearRegion.Clear();
|
||||||
#endif
|
#endif
|
||||||
m_updateRegion.Clear();
|
m_updateRegion.Clear();
|
||||||
@@ -3739,7 +3759,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
// widget to draw on
|
// widget to draw on
|
||||||
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
||||||
|
|
||||||
// later for GTK 2.0, too.
|
// later for GTK 2.0, too.
|
||||||
if (GetThemeEnabled())
|
if (GetThemeEnabled())
|
||||||
{
|
{
|
||||||
@@ -3749,7 +3769,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = (wxWindow*)this;
|
parent = (wxWindow*)this;
|
||||||
|
|
||||||
wxRegionIterator upd( m_updateRegion );
|
wxRegionIterator upd( m_updateRegion );
|
||||||
while (upd)
|
while (upd)
|
||||||
{
|
{
|
||||||
@@ -3758,7 +3778,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
rect.y = upd.GetY();
|
rect.y = upd.GetY();
|
||||||
rect.width = upd.GetWidth();
|
rect.width = upd.GetWidth();
|
||||||
rect.height = upd.GetHeight();
|
rect.height = upd.GetHeight();
|
||||||
|
|
||||||
gtk_paint_flat_box( parent->m_widget->style,
|
gtk_paint_flat_box( parent->m_widget->style,
|
||||||
pizza->bin_window,
|
pizza->bin_window,
|
||||||
GTK_STATE_NORMAL,
|
GTK_STATE_NORMAL,
|
||||||
@@ -3767,7 +3787,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
parent->m_widget,
|
parent->m_widget,
|
||||||
(char *)"base",
|
(char *)"base",
|
||||||
0, 0, -1, -1 );
|
0, 0, -1, -1 );
|
||||||
|
|
||||||
upd ++;
|
upd ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3838,7 +3858,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
{
|
{
|
||||||
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
|
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
|
||||||
children = children->next;
|
children = children->next;
|
||||||
|
|
||||||
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
|
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
|
||||||
GTK_WIDGET_DRAWABLE (child->widget))
|
GTK_WIDGET_DRAWABLE (child->widget))
|
||||||
{
|
{
|
||||||
@@ -3884,7 +3904,7 @@ void wxWindowGTK::Clear()
|
|||||||
m_clearRegion.Clear();
|
m_clearRegion.Clear();
|
||||||
wxSize size( GetClientSize() );
|
wxSize size( GetClientSize() );
|
||||||
m_clearRegion.Union( 0,0,size.x,size.y );
|
m_clearRegion.Union( 0,0,size.x,size.y );
|
||||||
|
|
||||||
// Better do this in idle?
|
// Better do this in idle?
|
||||||
GtkUpdate();
|
GtkUpdate();
|
||||||
}
|
}
|
||||||
@@ -3915,10 +3935,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
|
|||||||
window = GetConnectWidget()->window;
|
window = GetConnectWidget()->window;
|
||||||
|
|
||||||
wxASSERT( window );
|
wxASSERT( window );
|
||||||
|
|
||||||
// We need the pixel value e.g. for background clearing.
|
// We need the pixel value e.g. for background clearing.
|
||||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||||
|
|
||||||
if (m_wxwindow)
|
if (m_wxwindow)
|
||||||
{
|
{
|
||||||
// wxMSW doesn't clear the window here, either.
|
// wxMSW doesn't clear the window here, either.
|
||||||
@@ -4010,9 +4030,9 @@ PangoContext *wxWindowGTK::GtkGetPangoDefaultContext()
|
|||||||
|
|
||||||
PangoContext *wxWindowGTK::GtkGetPangoX11Context()
|
PangoContext *wxWindowGTK::GtkGetPangoX11Context()
|
||||||
{
|
{
|
||||||
if (!m_x11Context)
|
if (!m_x11Context)
|
||||||
m_x11Context = pango_x_get_context( gdk_display );
|
m_x11Context = pango_x_get_context( gdk_display );
|
||||||
|
|
||||||
return m_x11Context;
|
return m_x11Context;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -4514,7 +4534,7 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
|
|||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
||||||
|
|
||||||
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
|
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
|
||||||
|
|
||||||
// No scrolling requested.
|
// No scrolling requested.
|
||||||
if ((dx == 0) && (dy == 0)) return;
|
if ((dx == 0) && (dy == 0)) return;
|
||||||
|
|
||||||
|
@@ -505,10 +505,10 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
|||||||
// This callback gets called in drawing-idle time under
|
// This callback gets called in drawing-idle time under
|
||||||
// GTK 2.0, so we don't need to defer anything to idle
|
// GTK 2.0, so we don't need to defer anything to idle
|
||||||
// time anymore.
|
// time anymore.
|
||||||
|
|
||||||
GtkPizza *pizza = GTK_PIZZA( widget );
|
GtkPizza *pizza = GTK_PIZZA( widget );
|
||||||
if (gdk_event->window != pizza->bin_window) return FALSE;
|
if (gdk_event->window != pizza->bin_window) return FALSE;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (win->GetName())
|
if (win->GetName())
|
||||||
{
|
{
|
||||||
@@ -525,15 +525,15 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
|||||||
win->GetUpdateRegion() = wxRegion( gdk_event->region );
|
win->GetUpdateRegion() = wxRegion( gdk_event->region );
|
||||||
|
|
||||||
win->GtkSendPaintEvents();
|
win->GtkSendPaintEvents();
|
||||||
|
|
||||||
|
|
||||||
// Let parent window draw window less widgets
|
// Let parent window draw window less widgets
|
||||||
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
|
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
|
||||||
#else
|
#else
|
||||||
// This gets called immediately after an expose event
|
// This gets called immediately after an expose event
|
||||||
// under GTK 1.2 so we collect the calls and wait for
|
// under GTK 1.2 so we collect the calls and wait for
|
||||||
// the idle handler to pick things up.
|
// the idle handler to pick things up.
|
||||||
|
|
||||||
win->GetUpdateRegion().Union( gdk_event->area.x,
|
win->GetUpdateRegion().Union( gdk_event->area.x,
|
||||||
gdk_event->area.y,
|
gdk_event->area.y,
|
||||||
gdk_event->area.width,
|
gdk_event->area.width,
|
||||||
@@ -1136,7 +1136,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
|
wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
|
||||||
|
|
||||||
event.m_keyCode = key_code;
|
event.m_keyCode = key_code;
|
||||||
|
|
||||||
// Implement OnCharHook by checking ancesteror top level windows
|
// Implement OnCharHook by checking ancesteror top level windows
|
||||||
wxWindow *parent = win;
|
wxWindow *parent = win;
|
||||||
while (parent && !parent->IsTopLevel())
|
while (parent && !parent->IsTopLevel())
|
||||||
@@ -1218,7 +1218,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1235,10 +1235,10 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (g_blockEventsOnDrag)
|
if (g_blockEventsOnDrag)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
bool ret = FALSE;
|
bool ret = FALSE;
|
||||||
bool dont_use_IM = FALSE;
|
bool dont_use_IM = FALSE;
|
||||||
|
|
||||||
wxKeyEvent event( wxEVT_KEY_DOWN );
|
wxKeyEvent event( wxEVT_KEY_DOWN );
|
||||||
long keycode = wxTranslateKeySymToWXKey( gdk_event->keyval, FALSE );
|
long keycode = wxTranslateKeySymToWXKey( gdk_event->keyval, FALSE );
|
||||||
if (keycode)
|
if (keycode)
|
||||||
@@ -1246,7 +1246,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
// We were able to decode the key press without
|
// We were able to decode the key press without
|
||||||
// any input method, so don't use it.
|
// any input method, so don't use it.
|
||||||
dont_use_IM = TRUE;
|
dont_use_IM = TRUE;
|
||||||
|
|
||||||
// now fill all the other fields
|
// now fill all the other fields
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
@@ -1266,11 +1266,11 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
event.m_x = x;
|
event.m_x = x;
|
||||||
event.m_y = y;
|
event.m_y = y;
|
||||||
event.SetEventObject( win );
|
event.SetEventObject( win );
|
||||||
|
|
||||||
// send key down event
|
// send key down event
|
||||||
ret = win->GetEventHandler()->ProcessEvent( event );
|
ret = win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
// Implement OnCharHook by checking ancesteror top level windows
|
// Implement OnCharHook by checking ancesteror top level windows
|
||||||
wxWindow *parent = win;
|
wxWindow *parent = win;
|
||||||
@@ -1288,7 +1288,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
ret = win->GetEventHandler()->ProcessEvent( event );
|
ret = win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// win is a control: tab can be propagated up
|
// win is a control: tab can be propagated up
|
||||||
if ( !ret &&
|
if ( !ret &&
|
||||||
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
|
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
|
||||||
@@ -1314,7 +1314,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
if ( btnCancel ) break;
|
if ( btnCancel ) break;
|
||||||
|
|
||||||
if ( winForCancel->IsTopLevel() ) break;
|
if ( winForCancel->IsTopLevel() ) break;
|
||||||
|
|
||||||
winForCancel = winForCancel->GetParent();
|
winForCancel = winForCancel->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1326,24 +1326,24 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dont_use_IM && win->m_imContext)
|
if (!dont_use_IM && win->m_imContext)
|
||||||
{
|
{
|
||||||
// In GTK 2.0, we need to hand over the key
|
// In GTK 2.0, we need to hand over the key
|
||||||
// event to an input method and the IM will
|
// event to an input method and the IM will
|
||||||
// emit a "commit" event containing the
|
// emit a "commit" event containing the
|
||||||
// actual utf8 character.
|
// actual utf8 character.
|
||||||
gtk_im_context_filter_keypress ( (GtkIMContext*) win->m_imContext, gdk_event );
|
gtk_im_context_filter_keypress ( (GtkIMContext*) win->m_imContext, gdk_event );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1351,13 +1351,13 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
const gchar *str,
|
const gchar *str,
|
||||||
wxWindow *window)
|
wxWindow *window)
|
||||||
{
|
{
|
||||||
bool ret = FALSE;
|
bool ret = FALSE;
|
||||||
|
|
||||||
wxKeyEvent event( wxEVT_KEY_DOWN );
|
wxKeyEvent event( wxEVT_KEY_DOWN );
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
event.m_uniChar = g_utf8_get_char( str );
|
event.m_uniChar = g_utf8_get_char( str );
|
||||||
|
|
||||||
// Backward compatible for ISO-8859
|
// Backward compatible for ISO-8859
|
||||||
if (event.m_uniChar < 256)
|
if (event.m_uniChar < 256)
|
||||||
event.m_keyCode = event.m_uniChar;
|
event.m_keyCode = event.m_uniChar;
|
||||||
@@ -1365,10 +1365,10 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
gunichar uniChar = g_utf8_get_char( str );
|
gunichar uniChar = g_utf8_get_char( str );
|
||||||
// We cannot handle Unicode in non-Unicode mode
|
// We cannot handle Unicode in non-Unicode mode
|
||||||
if (uniChar > 255) return;
|
if (uniChar > 255) return;
|
||||||
|
|
||||||
event.m_keyCode = uniChar;
|
event.m_keyCode = uniChar;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
// Implement OnCharHook by checking ancesteror top level windows
|
// Implement OnCharHook by checking ancesteror top level windows
|
||||||
@@ -1618,7 +1618,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEventType event_type = wxEVT_NULL;
|
wxEventType event_type = wxEVT_NULL;
|
||||||
|
|
||||||
if (gdk_event->button == 1)
|
if (gdk_event->button == 1)
|
||||||
@@ -1708,7 +1708,9 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
|
|||||||
// "button_release_event"
|
// "button_release_event"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindowGTK *win )
|
static gint gtk_window_button_release_callback( GtkWidget *widget,
|
||||||
|
GdkEventButton *gdk_event,
|
||||||
|
wxWindowGTK *win )
|
||||||
{
|
{
|
||||||
DEBUG_MAIN_THREAD
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
@@ -1721,21 +1723,25 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
|||||||
|
|
||||||
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
|
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
|
||||||
|
|
||||||
/*
|
|
||||||
printf( "OnButtonRelease from " );
|
|
||||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
|
||||||
printf( win->GetClassInfo()->GetClassName() );
|
|
||||||
printf( ".\n" );
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxEventType event_type = wxEVT_NULL;
|
wxEventType event_type = wxEVT_NULL;
|
||||||
|
|
||||||
switch (gdk_event->button)
|
switch (gdk_event->button)
|
||||||
{
|
{
|
||||||
case 1: event_type = wxEVT_LEFT_UP; break;
|
case 1:
|
||||||
case 2: event_type = wxEVT_MIDDLE_UP; break;
|
event_type = wxEVT_LEFT_UP;
|
||||||
case 3: event_type = wxEVT_RIGHT_UP; break;
|
break;
|
||||||
default: return FALSE;
|
|
||||||
|
case 2:
|
||||||
|
event_type = wxEVT_MIDDLE_UP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
event_type = wxEVT_RIGHT_UP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// unknwon button, don't process
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMouseEvent event( event_type );
|
wxMouseEvent event( event_type );
|
||||||
@@ -1746,6 +1752,20 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
|||||||
// same wxListBox hack as above
|
// same wxListBox hack as above
|
||||||
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
|
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
|
||||||
|
|
||||||
|
if ( event_type == wxEVT_RIGHT_UP )
|
||||||
|
{
|
||||||
|
// generate a "context menu" event: this is similar to wxEVT_RIGHT_UP
|
||||||
|
// except that:
|
||||||
|
//
|
||||||
|
// (a) it's a command event and so is propagated to the parent
|
||||||
|
// (b) under MSW it can be generated from kbd too
|
||||||
|
// (c) it uses screen coords (because of (a))
|
||||||
|
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
|
||||||
|
win->GetId(),
|
||||||
|
win->ClientToScreen(event.GetPosition()));
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent(evtCtx);
|
||||||
|
}
|
||||||
|
|
||||||
if ( !g_captureWindow )
|
if ( !g_captureWindow )
|
||||||
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
|
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
|
||||||
|
|
||||||
@@ -1894,7 +1914,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
|
|||||||
#endif // wxUSE_CARET
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
g_activeFrameLostFocus = FALSE;
|
g_activeFrameLostFocus = FALSE;
|
||||||
|
|
||||||
wxWindowGTK *active = wxGetTopLevelParent(win);
|
wxWindowGTK *active = wxGetTopLevelParent(win);
|
||||||
if ( active != g_activeFrame )
|
if ( active != g_activeFrame )
|
||||||
{
|
{
|
||||||
@@ -1911,7 +1931,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
|
|||||||
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
|
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
|
||||||
event.SetEventObject(g_activeFrame);
|
event.SetEventObject(g_activeFrame);
|
||||||
g_activeFrame->GetEventHandler()->ProcessEvent(event);
|
g_activeFrame->GetEventHandler()->ProcessEvent(event);
|
||||||
|
|
||||||
// Don't send focus events in addition to activate
|
// Don't send focus events in addition to activate
|
||||||
// if (win == g_activeFrame)
|
// if (win == g_activeFrame)
|
||||||
// return TRUE;
|
// return TRUE;
|
||||||
@@ -2277,7 +2297,7 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
|
|||||||
|
|
||||||
if (win->m_delayedForegroundColour)
|
if (win->m_delayedForegroundColour)
|
||||||
win->GtkSetForegroundColour( win->GetForegroundColour() );
|
win->GtkSetForegroundColour( win->GetForegroundColour() );
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
if (win->m_imContext)
|
if (win->m_imContext)
|
||||||
{
|
{
|
||||||
@@ -2548,7 +2568,7 @@ void wxWindowGTK::Init()
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
m_imContext = NULL;
|
m_imContext = NULL;
|
||||||
m_x11Context = NULL;
|
m_x11Context = NULL;
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_XIM
|
#ifdef HAVE_XIM
|
||||||
m_ic = (GdkIC*) NULL;
|
m_ic = (GdkIC*) NULL;
|
||||||
m_icattr = (GdkICAttr*) NULL;
|
m_icattr = (GdkICAttr*) NULL;
|
||||||
@@ -2586,11 +2606,11 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
|||||||
wxFAIL_MSG( wxT("wxWindowGTK creation failed") );
|
wxFAIL_MSG( wxT("wxWindowGTK creation failed") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_insertCallback = wxInsertChildInWindow;
|
m_insertCallback = wxInsertChildInWindow;
|
||||||
|
|
||||||
// always needed for background clearing
|
// always needed for background clearing
|
||||||
m_delayedBackgroundColour = TRUE;
|
m_delayedBackgroundColour = TRUE;
|
||||||
|
|
||||||
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
|
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
|
||||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||||
@@ -2677,10 +2697,10 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
// Create input method handler
|
// Create input method handler
|
||||||
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
||||||
|
|
||||||
// Cannot handle drawing preedited text yet
|
// Cannot handle drawing preedited text yet
|
||||||
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
||||||
|
|
||||||
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
|
||||||
@@ -2786,7 +2806,7 @@ bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const w
|
|||||||
void wxWindowGTK::PostCreation()
|
void wxWindowGTK::PostCreation()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
||||||
|
|
||||||
if (m_wxwindow)
|
if (m_wxwindow)
|
||||||
{
|
{
|
||||||
if (!m_noExpose)
|
if (!m_noExpose)
|
||||||
@@ -2814,10 +2834,10 @@ void wxWindowGTK::PostCreation()
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
// Create input method handler
|
// Create input method handler
|
||||||
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new ();
|
||||||
|
|
||||||
// Cannot handle drawing preedited text yet
|
// Cannot handle drawing preedited text yet
|
||||||
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE );
|
||||||
|
|
||||||
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
|
||||||
@@ -2906,7 +2926,7 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
|
|||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
|
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
|
||||||
|
|
||||||
// This keeps crashing on me. RR.
|
// This keeps crashing on me. RR.
|
||||||
//
|
//
|
||||||
// gtk_signal_connect( GTK_OBJECT(widget), "destroy",
|
// gtk_signal_connect( GTK_OBJECT(widget), "destroy",
|
||||||
@@ -3065,7 +3085,7 @@ void wxWindowGTK::OnInternalIdle()
|
|||||||
}
|
}
|
||||||
g_activeFrameLostFocus = FALSE;
|
g_activeFrameLostFocus = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor cursor = m_cursor;
|
wxCursor cursor = m_cursor;
|
||||||
if (g_globalCursor.Ok()) cursor = g_globalCursor;
|
if (g_globalCursor.Ok()) cursor = g_globalCursor;
|
||||||
|
|
||||||
@@ -3413,26 +3433,26 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
if (theFont) fontToUse = *theFont;
|
if (theFont) fontToUse = *theFont;
|
||||||
|
|
||||||
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
|
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
|
||||||
|
|
||||||
if (string.IsEmpty())
|
if (string.IsEmpty())
|
||||||
{
|
{
|
||||||
if (x) (*x) = 0;
|
if (x) (*x) = 0;
|
||||||
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)
|
||||||
context = gtk_widget_get_pango_context( m_widget );
|
context = gtk_widget_get_pango_context( m_widget );
|
||||||
|
|
||||||
if (!context)
|
if (!context)
|
||||||
{
|
{
|
||||||
if (x) (*x) = 0;
|
if (x) (*x) = 0;
|
||||||
if (y) (*y) = 0;
|
if (y) (*y) = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
|
PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description;
|
||||||
PangoLayout *layout = pango_layout_new(context);
|
PangoLayout *layout = pango_layout_new(context);
|
||||||
pango_layout_set_font_description(layout, desc);
|
pango_layout_set_font_description(layout, desc);
|
||||||
@@ -3447,10 +3467,10 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
|
PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data;
|
||||||
|
|
||||||
PangoRectangle rect;
|
PangoRectangle rect;
|
||||||
pango_layout_line_get_extents(line, NULL, &rect);
|
pango_layout_line_get_extents(line, NULL, &rect);
|
||||||
|
|
||||||
if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE);
|
if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE);
|
||||||
if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE);
|
if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE);
|
||||||
if (descent)
|
if (descent)
|
||||||
@@ -3459,7 +3479,7 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
|
|||||||
(*descent) = 0;
|
(*descent) = 0;
|
||||||
}
|
}
|
||||||
if (externalLeading) (*externalLeading) = 0; // ??
|
if (externalLeading) (*externalLeading) = 0; // ??
|
||||||
|
|
||||||
g_object_unref( G_OBJECT( layout ) );
|
g_object_unref( G_OBJECT( layout ) );
|
||||||
#else
|
#else
|
||||||
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
|
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
|
||||||
@@ -3636,11 +3656,11 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
|
|||||||
{
|
{
|
||||||
if (!m_widget) return;
|
if (!m_widget) return;
|
||||||
if (!m_widget->window) return;
|
if (!m_widget->window) return;
|
||||||
|
|
||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
if (eraseBackground && m_wxwindow && m_wxwindow->window)
|
if (eraseBackground && m_wxwindow && m_wxwindow->window)
|
||||||
{
|
{
|
||||||
if (rect)
|
if (rect)
|
||||||
@@ -3726,7 +3746,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
{
|
{
|
||||||
if (!m_wxwindow)
|
if (!m_wxwindow)
|
||||||
{
|
{
|
||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
m_clearRegion.Clear();
|
m_clearRegion.Clear();
|
||||||
#endif
|
#endif
|
||||||
m_updateRegion.Clear();
|
m_updateRegion.Clear();
|
||||||
@@ -3739,7 +3759,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
#ifndef __WXGTK20__
|
#ifndef __WXGTK20__
|
||||||
// widget to draw on
|
// widget to draw on
|
||||||
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
|
||||||
|
|
||||||
// later for GTK 2.0, too.
|
// later for GTK 2.0, too.
|
||||||
if (GetThemeEnabled())
|
if (GetThemeEnabled())
|
||||||
{
|
{
|
||||||
@@ -3749,7 +3769,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = (wxWindow*)this;
|
parent = (wxWindow*)this;
|
||||||
|
|
||||||
wxRegionIterator upd( m_updateRegion );
|
wxRegionIterator upd( m_updateRegion );
|
||||||
while (upd)
|
while (upd)
|
||||||
{
|
{
|
||||||
@@ -3758,7 +3778,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
rect.y = upd.GetY();
|
rect.y = upd.GetY();
|
||||||
rect.width = upd.GetWidth();
|
rect.width = upd.GetWidth();
|
||||||
rect.height = upd.GetHeight();
|
rect.height = upd.GetHeight();
|
||||||
|
|
||||||
gtk_paint_flat_box( parent->m_widget->style,
|
gtk_paint_flat_box( parent->m_widget->style,
|
||||||
pizza->bin_window,
|
pizza->bin_window,
|
||||||
GTK_STATE_NORMAL,
|
GTK_STATE_NORMAL,
|
||||||
@@ -3767,7 +3787,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
parent->m_widget,
|
parent->m_widget,
|
||||||
(char *)"base",
|
(char *)"base",
|
||||||
0, 0, -1, -1 );
|
0, 0, -1, -1 );
|
||||||
|
|
||||||
upd ++;
|
upd ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3838,7 +3858,7 @@ void wxWindowGTK::GtkSendPaintEvents()
|
|||||||
{
|
{
|
||||||
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
|
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
|
||||||
children = children->next;
|
children = children->next;
|
||||||
|
|
||||||
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
|
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
|
||||||
GTK_WIDGET_DRAWABLE (child->widget))
|
GTK_WIDGET_DRAWABLE (child->widget))
|
||||||
{
|
{
|
||||||
@@ -3884,7 +3904,7 @@ void wxWindowGTK::Clear()
|
|||||||
m_clearRegion.Clear();
|
m_clearRegion.Clear();
|
||||||
wxSize size( GetClientSize() );
|
wxSize size( GetClientSize() );
|
||||||
m_clearRegion.Union( 0,0,size.x,size.y );
|
m_clearRegion.Union( 0,0,size.x,size.y );
|
||||||
|
|
||||||
// Better do this in idle?
|
// Better do this in idle?
|
||||||
GtkUpdate();
|
GtkUpdate();
|
||||||
}
|
}
|
||||||
@@ -3915,10 +3935,10 @@ void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour )
|
|||||||
window = GetConnectWidget()->window;
|
window = GetConnectWidget()->window;
|
||||||
|
|
||||||
wxASSERT( window );
|
wxASSERT( window );
|
||||||
|
|
||||||
// We need the pixel value e.g. for background clearing.
|
// We need the pixel value e.g. for background clearing.
|
||||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||||
|
|
||||||
if (m_wxwindow)
|
if (m_wxwindow)
|
||||||
{
|
{
|
||||||
// wxMSW doesn't clear the window here, either.
|
// wxMSW doesn't clear the window here, either.
|
||||||
@@ -4010,9 +4030,9 @@ PangoContext *wxWindowGTK::GtkGetPangoDefaultContext()
|
|||||||
|
|
||||||
PangoContext *wxWindowGTK::GtkGetPangoX11Context()
|
PangoContext *wxWindowGTK::GtkGetPangoX11Context()
|
||||||
{
|
{
|
||||||
if (!m_x11Context)
|
if (!m_x11Context)
|
||||||
m_x11Context = pango_x_get_context( gdk_display );
|
m_x11Context = pango_x_get_context( gdk_display );
|
||||||
|
|
||||||
return m_x11Context;
|
return m_x11Context;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -4514,7 +4534,7 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
|
|||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
|
||||||
|
|
||||||
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
|
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
|
||||||
|
|
||||||
// No scrolling requested.
|
// No scrolling requested.
|
||||||
if ((dx == 0) && (dy == 0)) return;
|
if ((dx == 0) && (dy == 0)) return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user