DnD feedback
keyx down and key up. listbox bug added bitmap to wxBitmapDataObject constructor corrected spelling of "Suiss bank account" git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
dc63c944b3
commit
b666df2c10
@ -38,7 +38,7 @@ enum wxDragResult
|
||||
Default/wxGTK-specific constructor. If you use the default constructor you must
|
||||
call \helpref{wxDropSource::SetData}{wxdropsourcesetdata} later.
|
||||
|
||||
{\it win} is only used by wxGTK. TODO: in what circumstances?
|
||||
{\it win} is required by wxGTK and therefore should always be set.
|
||||
|
||||
\func{}{wxDropSource}{\param{wxDataObject }{\&data}, \param{wxWindow }{*win = NULL}}
|
||||
|
||||
@ -64,7 +64,8 @@ Sets the data \helpref{data object}{wxdataobject} associated with the drop sourc
|
||||
|
||||
Do it (call this in response to a mouse button press, for example).
|
||||
|
||||
If {\bf bAllowMove} is FALSE, data can only be copied.
|
||||
If {\bf bAllowMove} is FALSE, data can only be copied. Under GTK, data
|
||||
is always copied.
|
||||
|
||||
\membersection{wxDropSource::GiveFeedback}\label{wxdropsourcegivefeedback}
|
||||
|
||||
@ -76,9 +77,9 @@ slow.
|
||||
|
||||
\wxheading{Parameters}
|
||||
|
||||
\docparam{effect}{The effect to implement. One of wxDragCopy, wxDragMove.}
|
||||
\docparam{effect}{The effect to implement. One of wxDragCopy, wxDragMove. MSW only. }
|
||||
|
||||
\docparam{bScrolling}{TRUE if the window is scrolling.}
|
||||
\docparam{bScrolling}{TRUE if the window is scrolling. MSW only. }
|
||||
|
||||
\wxheading{Return value}
|
||||
|
||||
|
@ -115,6 +115,8 @@ public:
|
||||
|
||||
wxBitmapDataObject(void) {}
|
||||
|
||||
wxBitmapDataObject( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
|
||||
|
||||
virtual wxDataFormat GetFormat() const
|
||||
{ return wxDF_BITMAP; }
|
||||
|
||||
|
@ -272,6 +272,7 @@ public:
|
||||
virtual wxString GetLabel() const;
|
||||
|
||||
void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
|
||||
void OnKeyDown( wxKeyEvent &event );
|
||||
|
||||
virtual bool IsShown() const;
|
||||
|
||||
|
@ -115,6 +115,8 @@ public:
|
||||
|
||||
wxBitmapDataObject(void) {}
|
||||
|
||||
wxBitmapDataObject( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
|
||||
|
||||
virtual wxDataFormat GetFormat() const
|
||||
{ return wxDF_BITMAP; }
|
||||
|
||||
|
@ -272,6 +272,7 @@ public:
|
||||
virtual wxString GetLabel() const;
|
||||
|
||||
void OnSysColourChanged( wxSysColourChangedEvent &WXUNUSED(event) ) {};
|
||||
void OnKeyDown( wxKeyEvent &event );
|
||||
|
||||
virtual bool IsShown() const;
|
||||
|
||||
|
@ -79,4 +79,4 @@ Q. Where to send comments,
|
||||
A. To Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>,
|
||||
wxWindows list <wxwin-developers@wx.dent.med.uni-muenchen.de>,
|
||||
/dev/null (platform-dependent),
|
||||
wxWindows dev team Suiss banc account.
|
||||
wxWindows dev team Swiss banc account.
|
||||
|
@ -472,6 +472,36 @@ static char * page_xpm[] = {
|
||||
" ......................... "};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// globals
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxDropSource *gs_currentDropSource = (wxDropSource*) NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "drop_enter_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_target_enter_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventDropEnter *WXUNUSED(event),
|
||||
wxDropTarget *target )
|
||||
{
|
||||
if (target)
|
||||
target->OnEnter();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "drop_leave_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_target_leave_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventDropLeave *WXUNUSED(event),
|
||||
wxDropTarget *target )
|
||||
{
|
||||
if (target)
|
||||
target->OnLeave();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "drop_data_available_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -563,6 +593,12 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
|
||||
GTK_SIGNAL_FUNC(gtk_target_callback), (gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(widget), "drop_enter_event",
|
||||
GTK_SIGNAL_FUNC(gtk_target_enter_callback), (gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(widget), "drop_leave_event",
|
||||
GTK_SIGNAL_FUNC(gtk_target_leave_callback), (gpointer) this );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -673,7 +709,7 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
||||
|
||||
static void
|
||||
shape_motion (GtkWidget *widget,
|
||||
GdkEventMotion */*event*/);
|
||||
GdkEventMotion * /*event*/);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// drag request
|
||||
@ -773,7 +809,7 @@ void wxDropSource::SetData( wxDataObject &data )
|
||||
|
||||
wxDropSource::~wxDropSource(void)
|
||||
{
|
||||
// if (m_data) delete m_data;
|
||||
// if (m_data) delete m_data;
|
||||
|
||||
g_blockEventsOnDrag = FALSE;
|
||||
}
|
||||
@ -870,8 +906,12 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
wxGetMousePosition( &x, &y );
|
||||
|
||||
gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
|
||||
|
||||
|
||||
gs_currentDropSource = this;
|
||||
|
||||
while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
|
||||
|
||||
gs_currentDropSource = (wxDropSource*) NULL;
|
||||
|
||||
UnregisterWindow();
|
||||
|
||||
@ -969,7 +1009,7 @@ shape_released (GtkWidget *widget)
|
||||
|
||||
static void
|
||||
shape_motion (GtkWidget *widget,
|
||||
GdkEventMotion */*event*/)
|
||||
GdkEventMotion * /*event*/ )
|
||||
{
|
||||
gint xp, yp;
|
||||
CursorOffset * p;
|
||||
@ -981,8 +1021,11 @@ shape_motion (GtkWidget *widget,
|
||||
* Can't use event->x / event->y here
|
||||
* because I need absolute coordinates.
|
||||
*/
|
||||
|
||||
gdk_window_get_pointer (root_win, &xp, &yp, &mask);
|
||||
gtk_widget_set_uposition (widget, xp - p->x, yp - p->y);
|
||||
|
||||
if (gs_currentDropSource) gs_currentDropSource->GiveFeedback( wxDragCopy, FALSE );
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -244,10 +244,13 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
(GtkSignalFunc)gtk_listbox_button_press_callback,
|
||||
(gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
if (m_hasCheckBoxes)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
"key_press_event",
|
||||
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
||||
(gpointer)this );
|
||||
}
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
@ -308,10 +311,13 @@ void wxListBox::AppendCommon( const wxString &item )
|
||||
(GtkSignalFunc)gtk_listbox_button_press_callback,
|
||||
(gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
if (m_hasCheckBoxes)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
"key_press_event",
|
||||
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
||||
(gpointer)this );
|
||||
(gpointer)this );
|
||||
}
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
|
@ -317,7 +317,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
||||
|
||||
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);
|
||||
@ -384,6 +384,122 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
||||
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"
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1137,6 +1253,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
|
||||
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()
|
||||
@ -1517,6 +1634,9 @@ void wxWindow::ConnectWidget( GtkWidget *widget )
|
||||
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 );
|
||||
|
||||
@ -2023,6 +2143,16 @@ void wxWindow::MakeModal( bool modal )
|
||||
}
|
||||
}
|
||||
|
||||
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" );
|
||||
|
@ -472,6 +472,36 @@ static char * page_xpm[] = {
|
||||
" ......................... "};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// globals
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxDropSource *gs_currentDropSource = (wxDropSource*) NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "drop_enter_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_target_enter_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventDropEnter *WXUNUSED(event),
|
||||
wxDropTarget *target )
|
||||
{
|
||||
if (target)
|
||||
target->OnEnter();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "drop_leave_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void gtk_target_leave_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventDropLeave *WXUNUSED(event),
|
||||
wxDropTarget *target )
|
||||
{
|
||||
if (target)
|
||||
target->OnLeave();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "drop_data_available_event"
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -563,6 +593,12 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
|
||||
GTK_SIGNAL_FUNC(gtk_target_callback), (gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(widget), "drop_enter_event",
|
||||
GTK_SIGNAL_FUNC(gtk_target_enter_callback), (gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(widget), "drop_leave_event",
|
||||
GTK_SIGNAL_FUNC(gtk_target_leave_callback), (gpointer) this );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -673,7 +709,7 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
||||
|
||||
static void
|
||||
shape_motion (GtkWidget *widget,
|
||||
GdkEventMotion */*event*/);
|
||||
GdkEventMotion * /*event*/);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// drag request
|
||||
@ -773,7 +809,7 @@ void wxDropSource::SetData( wxDataObject &data )
|
||||
|
||||
wxDropSource::~wxDropSource(void)
|
||||
{
|
||||
// if (m_data) delete m_data;
|
||||
// if (m_data) delete m_data;
|
||||
|
||||
g_blockEventsOnDrag = FALSE;
|
||||
}
|
||||
@ -870,8 +906,12 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
wxGetMousePosition( &x, &y );
|
||||
|
||||
gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
|
||||
|
||||
|
||||
gs_currentDropSource = this;
|
||||
|
||||
while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
|
||||
|
||||
gs_currentDropSource = (wxDropSource*) NULL;
|
||||
|
||||
UnregisterWindow();
|
||||
|
||||
@ -969,7 +1009,7 @@ shape_released (GtkWidget *widget)
|
||||
|
||||
static void
|
||||
shape_motion (GtkWidget *widget,
|
||||
GdkEventMotion */*event*/)
|
||||
GdkEventMotion * /*event*/ )
|
||||
{
|
||||
gint xp, yp;
|
||||
CursorOffset * p;
|
||||
@ -981,8 +1021,11 @@ shape_motion (GtkWidget *widget,
|
||||
* Can't use event->x / event->y here
|
||||
* because I need absolute coordinates.
|
||||
*/
|
||||
|
||||
gdk_window_get_pointer (root_win, &xp, &yp, &mask);
|
||||
gtk_widget_set_uposition (widget, xp - p->x, yp - p->y);
|
||||
|
||||
if (gs_currentDropSource) gs_currentDropSource->GiveFeedback( wxDragCopy, FALSE );
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -244,10 +244,13 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
(GtkSignalFunc)gtk_listbox_button_press_callback,
|
||||
(gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
if (m_hasCheckBoxes)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
"key_press_event",
|
||||
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
||||
(gpointer)this );
|
||||
}
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
@ -308,10 +311,13 @@ void wxListBox::AppendCommon( const wxString &item )
|
||||
(GtkSignalFunc)gtk_listbox_button_press_callback,
|
||||
(gpointer) this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
if (m_hasCheckBoxes)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(list_item),
|
||||
"key_press_event",
|
||||
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
||||
(gpointer)this );
|
||||
(gpointer)this );
|
||||
}
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
|
@ -317,7 +317,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
||||
|
||||
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);
|
||||
@ -384,6 +384,122 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
||||
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"
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1137,6 +1253,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
|
||||
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()
|
||||
@ -1517,6 +1634,9 @@ void wxWindow::ConnectWidget( GtkWidget *widget )
|
||||
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 );
|
||||
|
||||
@ -2023,6 +2143,16 @@ void wxWindow::MakeModal( bool modal )
|
||||
}
|
||||
}
|
||||
|
||||
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" );
|
||||
|
Loading…
Reference in New Issue
Block a user