Rewrite Fl_dnd.cxx under the driver model.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11455 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-03-28 17:36:07 +00:00
parent 4fbbab8b41
commit aacb5277e7
13 changed files with 30 additions and 25 deletions

View File

@ -90,6 +90,9 @@ public:
virtual int compose(int &del) {del = 0; return 0;}
// default implementation may be enough
virtual void compose_reset() { Fl::compose_state = 0; }
// implement to support drag-n-drop. use_selection = 1 means the GUI is welcome to display
// the selected text during the D&D operation
virtual int dnd(int use_selection) {return 0;}
};
#endif // FL_SYSTEM_DRIVER_H

View File

@ -191,7 +191,6 @@ public:
static int insertion_point_location(int *px, int *py, int *pheight); // computes window coordinates & height of insertion point
static const int CoreText_threshold; // Mac OS version from which the Core Text API is used to display text
static Fl_Fontdesc* calc_fl_fonts(void); // computes the fl_fonts global variable
static int dnd(int use_selection); // call Fl_X::dnd(1) to support text dragging
static int calc_mac_os_version(void); // computes the fl_mac_os_version global variable
static void clip_to_rounded_corners(CGContextRef gc, int w, int h);
static void complete_copy_pdf_and_tiff(CGContextRef gc, CFMutableDataRef pdfdata);

View File

@ -113,7 +113,6 @@ set (CPPFILES
fl_cursor.cxx
fl_curve.cxx
fl_diamond_box.cxx
fl_dnd.cxx
fl_draw.cxx
fl_draw_pixmap.cxx
fl_engraved_label.cxx
@ -185,6 +184,7 @@ if (USE_X11)
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
Fl_x.cxx
fl_dnd_x.cxx
)
if (USE_XFT)
set (DRIVER_FILES ${DRIVER_FILES}
@ -278,6 +278,7 @@ else ()
drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx
Fl_win32.cxx
fl_dnd_win32.cxx
)
set (DRIVER_HEADER_FILES
drivers/WinAPI/Fl_WinAPI_System_Driver.H

View File

@ -33,6 +33,7 @@
#include <FL/x.H>
#include <FL/Fl_Screen_Driver.H>
#include <FL/Fl_Window_Driver.H>
#include <FL/Fl_System_Driver.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tooltip.H>
#include <FL/fl_draw.H>
@ -1876,6 +1877,10 @@ Fl_Widget_Tracker::~Fl_Widget_Tracker()
int Fl::use_high_res_GL_ = 0;
int Fl::dnd()
{
return Fl_System_Driver::driver()->dnd(0);
}
//
// End of "$Id$".

View File

@ -34,6 +34,7 @@
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_System_Driver.H>
#include <FL/Fl_Input.H>
#include <FL/fl_draw.H>
#include <FL/fl_ask.H>
@ -687,11 +688,7 @@ int Fl_Input::handle(int event) {
dnd_save_focus = this;
// drag the data:
copy(0);
#ifdef __APPLE__ // PORTME: dnd
Fl_X::dnd(1);
#else
Fl::dnd();
#endif
Fl_System_Driver::driver()->dnd(1);
return 1;
}
}

View File

@ -31,6 +31,7 @@
#include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_System_Driver.H>
#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform editor feel
#elif defined(FL_PORTING)
@ -3913,11 +3914,7 @@ int Fl_Text_Display::handle(int event) {
if (dragType==DRAG_START_DND) {
if (!Fl::event_is_click() && Fl::dnd_text_ops()) {
const char* copy = buffer()->selection_text();
#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform behavior
Fl_X::dnd(1);
#else
Fl::dnd();
#endif
Fl_System_Driver::driver()->dnd(1);
free((void*)copy);
}
return 1;

View File

@ -45,6 +45,7 @@ extern "C" {
#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.H"
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
#include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H"
#include "drivers/Darwin/Fl_Darwin_System_Driver.H"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -3945,12 +3946,8 @@ static NSImage *defaultDragImage(int *pwidth, int *pheight)
return image;
}
int Fl::dnd()
{
return Fl_X::dnd(0);
}
int Fl_X::dnd(int use_selection)
int Fl_Darwin_System_Driver::dnd(int use_selection)
{
CFDataRef text = CFDataCreate(kCFAllocatorDefault, (UInt8*)fl_selection_buffer[0], fl_selection_length[0]);
if (text==NULL) return false;

View File

@ -132,7 +132,6 @@ CPPFILES = \
fl_cursor.cxx \
fl_curve.cxx \
fl_diamond_box.cxx \
fl_dnd.cxx \
fl_draw.cxx \
fl_draw_pixmap.cxx \
fl_encoding_latin1.cxx \
@ -253,7 +252,8 @@ XLIBCPPFILES = \
drivers/X11/Fl_X11_Screen_Driver.cxx \
drivers/Posix/Fl_Posix_System_Driver.cxx \
drivers/Posix/Fl_Posix_Printer_Driver.cxx \
Fl_x.cxx
Fl_x.cxx \
fl_dnd_x.cxx
XLIBFONTFILES = \
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
@ -276,7 +276,8 @@ GDICPPFILES = \
drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx \
drivers/WinAPI/Fl_WinAPI_System_Driver.cxx \
drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx \
Fl_win32.cxx
Fl_win32.cxx \
fl_dnd_win32.cxx
PSCPPFILES = \
drivers/PostScript/Fl_PostScript.cxx \

View File

@ -44,6 +44,7 @@ public:
virtual int single_arg(const char *arg);
virtual int arg_and_value(const char *name, const char *value);
virtual int compose(int &del);
virtual int dnd(int use_selection);
};
#endif // FL_DARWIN_SYSTEM_DRIVER_H

View File

@ -45,6 +45,7 @@ public:
virtual int XParseGeometry(const char*, int*, int*, unsigned int*, unsigned int*);
virtual int compose(int &del);
virtual void compose_reset();
virtual int dnd(int unused);
};
#endif // FL_POSIX_SYSTEM_DRIVER_H

View File

@ -46,6 +46,7 @@ public:
virtual void error(const char *format, va_list args);
virtual void fatal(const char *format, va_list args);
virtual int compose(int &del);
virtual int dnd(int unused);
};
#endif // FL_WINAPI_SYSTEM_DRIVER_H

View File

@ -24,6 +24,7 @@
#include <FL/x.H>
#include <FL/Fl_Window.H>
#include <FL/fl_utf8.h>
#include "drivers/WinAPI/Fl_WinAPI_System_Driver.H"
#include "flstring.h"
#include <stdio.h>
#include <stdlib.h>
@ -520,7 +521,7 @@ public:
};
int Fl::dnd()
int Fl_WinAPI_System_Driver::dnd(int unused)
{
DWORD dropEffect;
ReleaseCapture();

View File

@ -20,6 +20,7 @@
#include <FL/Fl_Window.H>
#include <FL/x.H>
#include "flstring.h"
#include "drivers/Posix/Fl_Posix_System_Driver.H"
extern Atom fl_XdndAware;
@ -79,7 +80,7 @@ static int local_handle(int event, Fl_Window* window) {
return ret;
}
int Fl::dnd() {
int Fl_Posix_System_Driver::dnd(int unused) {
Fl_Window *source_fl_win = Fl::first_window();
Fl::first_window()->cursor(FL_CURSOR_MOVE);
Window source_window = fl_xid(Fl::first_window());
@ -97,7 +98,7 @@ int Fl::dnd() {
for (Window child = RootWindow(fl_display, fl_screen);;) {
Window root; unsigned int junk3;
XQueryPointer(fl_display, child, &root, &child,
&e_x_root, &e_y_root, &dest_x, &dest_y, &junk3);
&Fl::e_x_root, &Fl::e_y_root, &dest_x, &dest_y, &junk3);
if (!child) {
if (!new_window && (new_version = dnd_aware(root))) new_window = root;
break;
@ -151,7 +152,7 @@ int Fl::dnd() {
local_handle(FL_DND_DRAG, local_window);
} else if (dndversion) {
fl_sendClientMessage(target_window, fl_XdndPosition, source_window,
0, (e_x_root<<16)|e_y_root, fl_event_time,
0, (Fl::e_x_root<<16)|Fl::e_y_root, fl_event_time,
fl_XdndActionCopy);
}
Fl::wait();
@ -159,7 +160,7 @@ int Fl::dnd() {
if (local_window) {
fl_i_own_selection[0] = 1;
if (local_handle(FL_DND_RELEASE, local_window)) paste(*belowmouse(), 0);
if (local_handle(FL_DND_RELEASE, local_window)) Fl::paste(*Fl::belowmouse(), 0);
} else if (dndversion) {
fl_sendClientMessage(target_window, fl_XdndDrop, source_window,
0, fl_event_time);