]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented clipboard events support for wxGTK
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 16 May 2006 23:16:36 +0000 (23:16 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 16 May 2006 23:16:36 +0000 (23:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39168 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/textctrl.cpp

index c3b61e8e3e6dada6d27b50fe8e30232b1628a77b..a19bf3377921c58bb3b09fe25fc1d7b76ad77135 100644 (file)
@@ -462,6 +462,48 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win )
 }
 }
 
+//-----------------------------------------------------------------------------
+//  clipboard events: "copy-clipboard", "cut-clipboard", "paste-clipboard"
+//-----------------------------------------------------------------------------
+
+// common part of the event handlers below
+static void
+handle_text_clipboard_callback( GtkWidget *widget, wxTextCtrl *win,
+                                                               wxEventType eventType, const gchar * signal_name)
+{
+    wxClipboardTextEvent event( eventType, win->GetId() );
+    event.SetEventObject( win );
+    if ( win->GetEventHandler()->ProcessEvent( event ) )
+    {
+        // don't let the default processing to take place if we did something
+        // ourselves in the event handler
+       g_signal_stop_emission_by_name (widget, signal_name);
+    }
+}
+
+extern "C" {
+static void
+gtk_copy_clipboard_callback( GtkWidget *widget, wxTextCtrl *win )
+{
+       handle_text_clipboard_callback(
+               widget, win, wxEVT_COMMAND_TEXT_COPY, "copy-clipboard" );
+}
+
+static void
+gtk_cut_clipboard_callback( GtkWidget *widget, wxTextCtrl *win )
+{
+       handle_text_clipboard_callback(
+               widget, win, wxEVT_COMMAND_TEXT_CUT, "cut-clipboard" );
+}
+
+static void
+gtk_paste_clipboard_callback( GtkWidget *widget, wxTextCtrl *win )
+{
+       handle_text_clipboard_callback(
+               widget, win, wxEVT_COMMAND_TEXT_PASTE, "paste-clipboard" );
+}
+}
+
 //-----------------------------------------------------------------------------
 // "expose_event" from scrolled window and textview
 //-----------------------------------------------------------------------------
@@ -716,6 +758,13 @@ bool wxTextCtrl::Create( wxWindow *parent,
                           G_CALLBACK (gtk_text_changed_callback), this);
     }
 
+    g_signal_connect (m_text, "copy-clipboard",
+                      G_CALLBACK (gtk_copy_clipboard_callback), this);
+    g_signal_connect (m_text, "cut-clipboard",
+                      G_CALLBACK (gtk_cut_clipboard_callback), this);
+    g_signal_connect (m_text, "paste-clipboard",
+                      G_CALLBACK (gtk_paste_clipboard_callback), this);
+
     m_cursor = wxCursor( wxCURSOR_IBEAM );
 
     wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont());