#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
-#include "wx/dcclient.h"
+#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
+#endif
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
#include "wx/settings.h"
#include "wx/log.h"
-#include "gdk/gdkprivate.h"
-#include "gdk/gdkkeysyms.h"
#include <math.h>
+#include "gdk/gdk.h"
+#include "gtk/gtk.h"
+#include "gdk/gdkprivate.h"
+#include "gdk/gdkkeysyms.h"
+#include "wx/gtk/win_gtk.h"
+
//-----------------------------------------------------------------------------
// documentation on internals
//-----------------------------------------------------------------------------
if (!key_code) return FALSE;
- wxKeyEvent event( wxEVT_CHAR );
+ wxKeyEvent event( wxEVT_KEY_DOWN );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
return ret;
}
+//-----------------------------------------------------------------------------
+// "key_release_event" from any window
+//-----------------------------------------------------------------------------
+
+static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
+{
+ if (!win->HasVMT()) return FALSE;
+ if (g_blockEventsOnDrag) return FALSE;
+
+/*
+ printf( "OnKeyRelease from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ long key_code = 0;
+ switch (gdk_event->keyval)
+ {
+ case GDK_BackSpace: key_code = WXK_BACK; break;
+ case GDK_Tab: key_code = WXK_TAB; break;
+ case GDK_Linefeed: key_code = WXK_RETURN; break;
+ case GDK_Clear: key_code = WXK_CLEAR; break;
+ case GDK_Return: key_code = WXK_RETURN; break;
+ case GDK_Pause: key_code = WXK_PAUSE; break;
+ case GDK_Scroll_Lock: key_code = WXK_SCROLL; break;
+ case GDK_Escape: key_code = WXK_ESCAPE; break;
+ case GDK_Delete: key_code = WXK_DELETE; break;
+ case GDK_Home: key_code = WXK_HOME; break;
+ case GDK_Left: key_code = WXK_LEFT; break;
+ case GDK_Up: key_code = WXK_UP; break;
+ case GDK_Right: key_code = WXK_RIGHT; break;
+ case GDK_Down: key_code = WXK_DOWN; break;
+ case GDK_Prior: key_code = WXK_PRIOR; break;
+// case GDK_Page_Up: key_code = WXK_PAGEUP; break;
+ case GDK_Next: key_code = WXK_NEXT; break;
+// case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
+ case GDK_End: key_code = WXK_END; break;
+ case GDK_Begin: key_code = WXK_HOME; break;
+ case GDK_Select: key_code = WXK_SELECT; break;
+ case GDK_Print: key_code = WXK_PRINT; break;
+ case GDK_Execute: key_code = WXK_EXECUTE; break;
+ case GDK_Insert: key_code = WXK_INSERT; break;
+ case GDK_Num_Lock: key_code = WXK_NUMLOCK; break;
+ case GDK_KP_Tab: key_code = WXK_TAB; break;
+ case GDK_KP_Enter: key_code = WXK_RETURN; break;
+ case GDK_KP_Home: key_code = WXK_HOME; break;
+ case GDK_KP_Left: key_code = WXK_LEFT; break;
+ case GDK_KP_Up: key_code = WXK_UP; break;
+ case GDK_KP_Right: key_code = WXK_RIGHT; break;
+ case GDK_KP_Down: key_code = WXK_DOWN; break;
+ case GDK_KP_Prior: key_code = WXK_PRIOR; break;
+// case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
+ case GDK_KP_Next: key_code = WXK_NEXT; break;
+// case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
+ case GDK_KP_End: key_code = WXK_END; break;
+ case GDK_KP_Begin: key_code = WXK_HOME; break;
+ case GDK_KP_Insert: key_code = WXK_INSERT; break;
+ case GDK_KP_Delete: key_code = WXK_DELETE; break;
+ case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break;
+ case GDK_KP_Add: key_code = WXK_ADD; break;
+ case GDK_KP_Separator: key_code = WXK_SEPARATOR; break;
+ case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break;
+ case GDK_KP_Decimal: key_code = WXK_DECIMAL; break;
+ case GDK_KP_Divide: key_code = WXK_DIVIDE; break;
+ case GDK_KP_0: key_code = WXK_NUMPAD0; break;
+ case GDK_KP_1: key_code = WXK_NUMPAD1; break;
+ case GDK_KP_2: key_code = WXK_NUMPAD2; break;
+ case GDK_KP_3: key_code = WXK_NUMPAD3; break;
+ case GDK_KP_4: key_code = WXK_NUMPAD4; break;
+ case GDK_KP_5: key_code = WXK_NUMPAD5; break;
+ case GDK_KP_6: key_code = WXK_NUMPAD6; break;
+ case GDK_KP_7: key_code = WXK_NUMPAD7; break;
+ case GDK_KP_8: key_code = WXK_NUMPAD7; break;
+ case GDK_KP_9: key_code = WXK_NUMPAD9; break;
+ case GDK_F1: key_code = WXK_F1; break;
+ case GDK_F2: key_code = WXK_F2; break;
+ case GDK_F3: key_code = WXK_F3; break;
+ case GDK_F4: key_code = WXK_F4; break;
+ case GDK_F5: key_code = WXK_F5; break;
+ case GDK_F6: key_code = WXK_F6; break;
+ case GDK_F7: key_code = WXK_F7; break;
+ case GDK_F8: key_code = WXK_F8; break;
+ case GDK_F9: key_code = WXK_F9; break;
+ case GDK_F10: key_code = WXK_F10; break;
+ case GDK_F11: key_code = WXK_F11; break;
+ case GDK_F12: key_code = WXK_F12; break;
+ default:
+ {
+ if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
+ key_code = gdk_event->keyval;
+ }
+ }
+
+ if (!key_code) return FALSE;
+
+ wxKeyEvent event( wxEVT_KEY_UP );
+ event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
+ event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
+ event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
+ event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
+ event.m_keyCode = key_code;
+ event.m_x = 0;
+ event.m_y = 0;
+ event.SetEventObject( win );
+
+ bool ret = win->GetEventHandler()->ProcessEvent( event );
+
+ if (ret)
+ {
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
+ }
+
+ return ret;
+}
+
//-----------------------------------------------------------------------------
// "button_press_event"
//-----------------------------------------------------------------------------
node = node->Next();
}
}
+
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
event.SetEventObject( win );
}
}
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
+ if (gdk_event->is_hint)
+ {
+ int x = 0;
+ int y = 0;
+ GdkModifierType state;
+ gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
+ gdk_event->x = x;
+ gdk_event->y = y;
+ gdk_event->state = state;
+ }
+
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
-*/
+*/
wxMouseEvent event( wxEVT_MOTION );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
}
}
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
event.m_x = (long)x;
event.m_y = (long)y;
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
if (win->GetEventHandler()->ProcessEvent( event ))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
event.m_x = (long)x;
event.m_y = (long)y;
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
if (win->GetEventHandler()->ProcessEvent( event ))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
child->m_width,
child->m_height );
+
+ if (wxIS_KIND_OF(parent,wxFrame))
+ {
+ parent->m_sizeSet = FALSE;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// global functions
+//-----------------------------------------------------------------------------
+
+wxWindow* wxGetActiveWindow()
+{
+ return g_focusWindow;
}
//-----------------------------------------------------------------------------
EVT_SIZE(wxWindow::OnSize)
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
- EVT_IDLE(wxWindow::OnIdle)
+ EVT_KEY_DOWN(wxWindow::OnKeyDown)
END_EVENT_TABLE()
wxWindow::wxWindow()
m_isShown = FALSE;
m_isEnabled = TRUE;
+#if wxUSE_DRAG_AND_DROP
m_dropTarget = (wxDropTarget*) NULL;
+#endif
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
{
m_hasVMT = FALSE;
+#if wxUSE_DRAG_AND_DROP
if (m_dropTarget) delete m_dropTarget;
+#endif
if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE );
m_isShown = FALSE;
m_isEnabled = TRUE;
+#if wxUSE_DRAG_AND_DROP
m_dropTarget = (wxDropTarget *) NULL;
+#endif
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL;
gtk_signal_connect( GTK_OBJECT(widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this );
+ gtk_signal_connect( GTK_OBJECT(widget), "key_release_event",
+ GTK_SIGNAL_FUNC(gtk_window_key_release_callback), (gpointer)this );
+
gtk_signal_connect( GTK_OBJECT(widget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
- if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
- if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+ if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
wxPoint pt( m_parent->GetClientAreaOrigin() );
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
m_resizing = FALSE;
}
+void wxWindow::OnInternalIdle()
+{
+ UpdateWindowUI();
+}
+
void wxWindow::SetSize( int width, int height )
{
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
}
}
+void wxWindow::OnKeyDown( wxKeyEvent &event )
+{
+ event.SetEventType( wxEVT_CHAR );
+
+ if (!GetEventHandler()->ProcessEvent( event ))
+ {
+ event.Skip();
+ }
+}
+
void wxWindow::SetFocus()
{
wxCHECK_RET( (m_widget != NULL), "invalid window" );
}
}
-bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
+static gint gs_pop_x = 0;
+static gint gs_pop_y = 0;
+
+static void pop_pos_callback( GtkMenu *menu, gint *x, gint *y, wxWindow *win )
+{
+ win->ClientToScreen( &gs_pop_x, &gs_pop_y );
+ *x = gs_pop_x;
+ *y = gs_pop_y;
+}
+
+bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
{
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" );
SetInvokingWindow( menu, this );
+
+ gs_pop_x = x;
+ gs_pop_y = y;
+
gtk_menu_popup(
GTK_MENU(menu->m_menu),
- (GtkWidget *)NULL, // parent menu shell
- (GtkWidget *)NULL, // parent menu item
- (GtkMenuPositionFunc)NULL,
- NULL, // client data
- 0, // button used to activate it
- 0//gs_timeLastClick // the time of activation
+ (GtkWidget *) NULL, // parent menu shell
+ (GtkWidget *) NULL, // parent menu item
+ (GtkMenuPositionFunc) pop_pos_callback,
+ (gpointer) this, // client data
+ 0, // button used to activate it
+ 0 //gs_timeLastClick // the time of activation
);
return TRUE;
}
+#if wxUSE_DRAG_AND_DROP
+
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
wxCHECK_RET( m_widget != NULL, "invalid window" );
return m_dropTarget;
}
+#endif
+
GtkWidget* wxWindow::GetConnectWidget()
{
GtkWidget *connect_widget = m_widget;
GetPosition(x, y);
}
-void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) )
-{
- UpdateWindowUI();
-}