// Name: src/gtk/window.cpp
// Purpose: wxWindowGTK implementation
// Author: Robert Roebling
-// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
KeySym keysym = gdk_event->keyval;
- wxLogTrace(TRACE_KEYS, wxT("Key %s event: keysym = %ld"),
+ wxLogTrace(TRACE_KEYS, wxT("Key %s event: keysym = %lu"),
event.GetEventType() == wxEVT_KEY_UP ? wxT("release")
: wxT("press"),
- keysym);
+ static_cast<unsigned long>(keysym));
long key_code = wxTranslateKeySymToWXKey(keysym, false /* !isChar */);
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{
- wxCommandEvent menu_event( wxEVT_COMMAND_MENU_SELECTED, command );
+ wxCommandEvent menu_event( wxEVT_MENU, command );
ret = ancestor->HandleWindowEvent( menu_event );
if ( !ret )
// if the accelerator wasn't handled as menu event, try
// it as button click (for compatibility with other
// platforms):
- wxCommandEvent button_event( wxEVT_COMMAND_BUTTON_CLICKED, command );
+ wxCommandEvent button_event( wxEVT_BUTTON, command );
ret = ancestor->HandleWindowEvent( button_event );
}
gtk_wxwindow_commit_cb (GtkIMContext * WXUNUSED(context),
const gchar *str,
wxWindow *window)
+{
+ // Ignore the return value here, it doesn't matter for the "commit" signal.
+ window->GTKDoInsertTextFromIM(str);
+}
+}
+
+bool wxWindowGTK::GTKDoInsertTextFromIM(const char* str)
{
wxKeyEvent event( wxEVT_CHAR );
// take modifiers, cursor position, timestamp etc. from the last
// key_press_event that was fed into Input Method:
- if (window->m_imKeyEvent)
+ if ( m_imKeyEvent )
{
- wxFillOtherKeyEventFields(event, window, window->m_imKeyEvent);
+ wxFillOtherKeyEventFields(event, this, m_imKeyEvent);
}
else
{
- event.SetEventObject( window );
+ event.SetEventObject(this);
}
const wxString data(wxGTK_CONV_BACK_SYS(str));
if( data.empty() )
- return;
+ return false;
+ bool processed = false;
for( wxString::const_iterator pstr = data.begin(); pstr != data.end(); ++pstr )
{
#if wxUSE_UNICODE
AdjustCharEventKeyCodes(event);
- window->HandleWindowEvent(event);
+ if ( HandleWindowEvent(event) )
+ processed = true;
}
+
+ return processed;
}
+
+bool wxWindowGTK::GTKOnInsertText(const char* text)
+{
+ if ( !m_imKeyEvent )
+ {
+ // We're not inside IM key handling at all.
+ return false;
+ }
+
+ return GTKDoInsertTextFromIM(text);
}
// FIXME: Get these values from GTK or GDK
event.m_linesPerAction = 3;
+ event.m_columnsPerAction = 3;
event.m_wheelDelta = 120;
// Determine the scroll direction.
if (w < 0) w = 0;
if (h < 0) h = 0;
}
+ GtkAllocation a;
+ gtk_widget_get_allocation(win->m_widget, &a);
+ // update position for widgets in native containers, such as wxToolBar
+ // (for widgets in a wxPizza, the values should already be the same)
+ win->m_x = a.x;
+ win->m_y = a.y;
win->m_useCachedClientSize = true;
if (win->m_clientWidth != w || win->m_clientHeight != h)
{
win->m_clientHeight = h;
// this callback can be connected to m_wxwindow,
// so always get size from m_widget->allocation
- GtkAllocation a;
- gtk_widget_get_allocation(win->m_widget, &a);
win->m_width = a.width;
win->m_height = a.height;
if (!win->m_nativeSizeEvent)
wxWindow *wxWindowBase::DoFindFocus()
{
+#if wxUSE_MENUS
// For compatibility with wxMSW, pretend that showing a popup menu doesn't
// change the focus and that it remains on the window showing it, even
// though the real focus does change in GTK.
extern wxMenu *wxCurrentPopupMenu;
if ( wxCurrentPopupMenu )
return wxCurrentPopupMenu->GetInvokingWindow();
+#endif // wxUSE_MENUS
wxWindowGTK *focus = gs_pendingFocus ? gs_pendingFocus : gs_currentFocus;
// the cast is necessary when we compile in wxUniversal mode
// destroy children before destroying this window itself
DestroyChildren();
- if (m_widget)
- Show( false );
-
// delete before the widgets to avoid a crash on solaris
if ( m_imContext )
{
void wxWindowGTK::SetCanFocus(bool canFocus)
{
+ wxCHECK_RET(m_widget, "invalid window");
+
gtk_widget_set_can_focus(m_widget, canFocus);
if ( m_wxwindow && (m_widget != m_wxwindow) )
gtk_get_current_event_time()
);
+ // it is possible for gtk_menu_popup() to fail
+ if (!gtk_widget_get_visible(GTK_WIDGET(menu->m_menu)))
+ {
+ menu->m_popupShown = false;
+ return false;
+ }
+
while (menu->m_popupShown)
{
gtk_main_iteration();