From 5f55e1cd63883c8d48a0e212e8910f6dfd536a50 Mon Sep 17 00:00:00 2001 From: Bill Spitzak Date: Thu, 7 Mar 2002 19:22:58 +0000 Subject: Back-ported cut & paste code from fltk2.0. This code splits the cut & paste into two buffers. The "SELECTION" is used for the currently highlighted text and for middle-mouse paste and (if possible) for handling drag & drop. The "CLIPBOARD" is for Ctrl+C and Ctrl+V style cut & paste. This matches how Motif, GTK, and KDE 3.0 work. But many older X applications (including KDE 2) can only see SELECTION, this results in cut & paste incompatability that is familiar to X users. However this now moves fltk over to the majority camp. On all systems this eliminates the annoying inability to select a region and replace it with Ctrl+V. On Mac and Win32 the SELECTION is local to the application, so middle-mouse paste only works between fields in the application. There may be tricks (special clipboard data types? use drag & drop?) to make it communicate, but unless there are standards it would be fltk-only. The file Fl_cutpaste.cxx has been deleted, so update the IDE files! The Win32 and Mac versions have NOT BEEN TESTED! I tried to be careful editing them but they may need some work. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1989 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl.cxx | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/Fl.cxx') diff --git a/src/Fl.cxx b/src/Fl.cxx index 1dff53f7f..7c34badea 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.21 2002/02/26 00:34:55 matthiaswm Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.22 2002/03/07 19:22:56 spitzak Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -485,7 +485,7 @@ void fl_fix_focus() { } #ifndef WIN32 -Fl_Widget *fl_selection_requestor; // from Fl_cutpaste.cxx +extern Fl_Widget *fl_selection_requestor; // from Fl_x.cxx #endif // This function is called by ~Fl_Widget() and by Fl_Widget::deactivate @@ -498,7 +498,6 @@ Fl_Widget *fl_selection_requestor; // from Fl_cutpaste.cxx void fl_throw_focus(Fl_Widget *o) { if (o->contains(Fl::pushed())) Fl::pushed_ = 0; - if (o->contains(Fl::selection_owner())) Fl::selection_owner_ = 0; #ifndef WIN32 if (o->contains(fl_selection_requestor)) fl_selection_requestor = 0; #endif @@ -761,7 +760,8 @@ Fl_Window::~Fl_Window() { // Fl_Window::show() or Fl_Window::hide() is called, or in response to // iconize/deiconize events from the system. -int Fl_Window::handle(int event) { +int Fl_Window::handle(int event) +{ if (parent()) switch (event) { case FL_SHOW: if (!shown()) show(); @@ -788,19 +788,21 @@ int Fl_Window::handle(int event) { } //////////////////////////////////////////////////////////////// -// ~Fl_Widget() calls this: this function must get rid of any -// global pointers to the widget. This is also called by hide() -// and deactivate(). +// Back compatability cut & paste functions for fltk 1.1 only: + +void Fl::selection_owner(Fl_Widget *owner) {selection_owner_ = owner;} + +void Fl::selection(Fl_Widget &owner, const char* text, int len) { + selection_owner_ = &owner; + Fl::copy(text, len, 0); +} -// call this to free a selection (or change the owner): -void Fl::selection_owner(Fl_Widget *owner) { - if (selection_owner_ && owner != selection_owner_) - selection_owner_->handle(FL_SELECTIONCLEAR); - if (focus_ && owner != focus_ && focus_ != selection_owner_) - focus_->handle(FL_SELECTIONCLEAR); // clear non-X-selection highlight - selection_owner_ = owner; +void Fl::paste(Fl_Widget &receiver) { + Fl::paste(receiver, 0); } +//////////////////////////////////////////////////////////////// + #include void Fl_Widget::redraw() {damage(FL_DAMAGE_ALL);} @@ -880,5 +882,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.21 2002/02/26 00:34:55 matthiaswm Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.22 2002/03/07 19:22:56 spitzak Exp $". // -- cgit v1.2.3