Move dnd and character-composition related functions from Fl_System_Driver to Fl_Screen_Driver

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11489 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-03-31 19:55:03 +00:00
parent 5d12ea5ab1
commit 519673a776
23 changed files with 74 additions and 78 deletions

View File

@ -98,6 +98,13 @@ public:
virtual int has_marked_text() { return 0; }
virtual void reset_marked_text() {}
virtual void insertion_point_location(int x, int y, int height) {}
// implement so text-editing widgets support dead keys
virtual int compose(int &del) {del = 0; return 0;}
// default implementation may be enough
virtual void compose_reset();
// 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 = 0) {return 0;}
};

View File

@ -97,13 +97,6 @@ public:
static void fatal(const char* format, ...);
// implement to set the default effect of Fl::error()
virtual void fatal(const char* format, va_list args);
// implement so text-editing widgets support dead keys
virtual int compose(int &del) {del = 0; return 0;}
// default implementation may be enough
virtual void compose_reset();
// 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 = 0) {return 0;}
// implement these to support cross-platform file operations
virtual char *utf2mbcs(const char *s) {return (char*)s;}

View File

@ -1879,7 +1879,7 @@ int Fl::use_high_res_GL_ = 0;
int Fl::dnd()
{
return Fl_System_Driver::driver()->dnd();
return Fl::screen_driver()->dnd();
}
void Fl::reset_marked_text() {

View File

@ -687,7 +687,7 @@ int Fl_Input::handle(int event) {
dnd_save_focus = this;
// drag the data:
copy(0);
Fl_System_Driver::driver()->dnd(1);
Fl::screen_driver()->dnd(1);
return 1;
}
}

View File

@ -145,6 +145,10 @@ const char *Fl_Screen_Driver::get_system_scheme()
/** The bullet character used by default by Fl_Secret_Input */
int Fl_Screen_Driver::secret_input_character = 0x2022;
void Fl_Screen_Driver::compose_reset() {
Fl::compose_state = 0;
}
//
// End of "$Id$".
//

View File

@ -372,10 +372,6 @@ int Fl_System_Driver::clocale_printf(FILE *output, const char *format, va_list a
return vfprintf(output, format, args);
}
void Fl_System_Driver::compose_reset() {
Fl::compose_state = 0;
}
//
// End of "$Id$".
//

View File

@ -31,7 +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>
#include <FL/Fl_Screen_Driver.H>
#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform editor feel
#elif defined(FL_PORTING)
@ -3912,7 +3912,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();
Fl_System_Driver::driver()->dnd(1);
Fl::screen_driver()->dnd(1);
free((void*)copy);
}
return 1;

View File

@ -3949,7 +3949,7 @@ static NSImage *defaultDragImage(int *pwidth, int *pheight)
}
int Fl_Darwin_System_Driver::dnd(int use_selection)
int Fl_Cocoa_Screen_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

@ -22,7 +22,7 @@ Utility functions to support text input.
*/
#include <FL/Fl.H>
#include <FL/Fl_System_Driver.H>
#include <FL/Fl_Screen_Driver.H>
#ifndef FL_DOXYGEN
int Fl::compose_state = 0;
@ -70,7 +70,7 @@ int Fl::compose_state = 0;
other user-interface things to allow characters to be selected.
*/
int Fl::compose(int& del) {
return Fl_System_Driver::driver()->compose(del);
return Fl::screen_driver()->compose(del);
}
/**
@ -81,7 +81,7 @@ int Fl::compose(int& del) {
*/
void Fl::compose_reset()
{
Fl_System_Driver::driver()->compose_reset();
Fl::screen_driver()->compose_reset();
}
//

View File

@ -83,6 +83,8 @@ public:
virtual void reset_marked_text();
virtual void insertion_point_location(int x, int y, int height);
int insertion_point_location(int *px, int *py, int *pheight);
virtual int dnd(int use_selection);
virtual int compose(int &del);
};

View File

@ -264,6 +264,18 @@ void Fl_Cocoa_Screen_Driver::insertion_point_location(int x, int y, int height)
insertion_point_height = height;
}
int Fl_Cocoa_Screen_Driver::compose(int &del) {
int condition;
int has_text_key = Fl::compose_state || Fl::e_keysym <= '~' || Fl::e_keysym == FL_Iso_Key ||
(Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last && Fl::e_keysym != FL_KP_Enter);
condition = Fl::e_state&(FL_META | FL_CTRL) ||
(Fl::e_keysym >= FL_Shift_L && Fl::e_keysym <= FL_Alt_R) || // called from flagsChanged
!has_text_key ;
if (condition) { del = 0; return 0;} // this stuff is to be treated as a function key
del = Fl::compose_state;
Fl::compose_state = Fl_X::next_marked_length;
return 1;
}
//
// End of "$Id$".

View File

@ -48,8 +48,6 @@ public:
Fl_Darwin_System_Driver();
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);
virtual int mkdir(const char* f, int mode) {return ::mkdir(f, mode);}
virtual int open(const char* f, int oflags, int pmode) {
return pmode == -1 ? ::open(f, oflags) : ::open(f, oflags, pmode);

View File

@ -59,19 +59,6 @@ int Fl_Darwin_System_Driver::arg_and_value(const char *name, const char *value)
return strcmp(name, "NSDocumentRevisionsDebugMode") == 0;
}
int Fl_Darwin_System_Driver::compose(int &del) {
int condition;
int has_text_key = Fl::compose_state || Fl::e_keysym <= '~' || Fl::e_keysym == FL_Iso_Key ||
(Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last && Fl::e_keysym != FL_KP_Enter);
condition = Fl::e_state&(FL_META | FL_CTRL) ||
(Fl::e_keysym >= FL_Shift_L && Fl::e_keysym <= FL_Alt_R) || // called from flagsChanged
!has_text_key ;
if (condition) { del = 0; return 0;} // this stuff is to be treated as a function key
del = Fl::compose_state;
Fl::compose_state = Fl_X::next_marked_length;
return 1;
}
int Fl_Darwin_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
if (fl_mac_os_version >= 100400) {

View File

@ -47,9 +47,6 @@ class Fl_Posix_System_Driver : public Fl_System_Driver
public:
virtual void display_arg(const char *arg);
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);
virtual int mkdir(const char* f, int mode) {return ::mkdir(f, mode);}
virtual int open(const char* f, int oflags, int pmode) {
return pmode == -1 ? ::open(f, oflags) : ::open(f, oflags, pmode);

View File

@ -47,24 +47,6 @@ int Fl_Posix_System_Driver::XParseGeometry(const char* string, int* x, int* y,
return ::XParseGeometry(string, x, y, width, height);
}
int Fl_Posix_System_Driver::compose(int& del) {
int condition;
unsigned char ascii = (unsigned char)Fl::e_text[0];
condition = (Fl::e_state & (FL_ALT | FL_META | FL_CTRL)) && !(ascii & 128) ;
if (condition) { del = 0; return 0;} // this stuff is to be treated as a function key
del = Fl::compose_state;
Fl::compose_state = 0;
// Only insert non-control characters:
if ( (!Fl::compose_state) && ! (ascii & ~31 && ascii!=127)) { return 0; }
return 1;
}
void Fl_Posix_System_Driver::compose_reset()
{
Fl::compose_state = 0;
if (fl_xim_ic) XmbResetIC(fl_xim_ic);
}
int Fl_Posix_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) {
char *saved_locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");

View File

@ -69,6 +69,8 @@ public:
virtual void repeat_timeout(double time, Fl_Timeout_Handler cb, void *argp);
virtual int has_timeout(Fl_Timeout_Handler cb, void *argp);
virtual void remove_timeout(Fl_Timeout_Handler cb, void *argp);
virtual int dnd(int unused);
virtual int compose(int &del);
};

View File

@ -510,7 +510,21 @@ void Fl_WinAPI_Screen_Driver::remove_timeout(Fl_Timeout_Handler cb, void* data)
}
}
int Fl_WinAPI_Screen_Driver::compose(int &del) {
unsigned char ascii = (unsigned char)Fl::e_text[0];
int condition = (Fl::e_state & (FL_ALT | FL_META)) && !(ascii & 128) ;
if (condition) { // this stuff is to be treated as a function key
del = 0;
return 0;
}
del = Fl::compose_state;
Fl::compose_state = 0;
// Only insert non-control characters:
if ( (!Fl::compose_state) && ! (ascii & ~31 && ascii!=127)) {
return 0;
}
return 1;
}
//
// End of "$Id$".

View File

@ -45,8 +45,6 @@ public:
virtual void warning(const char *format, va_list args);
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);
virtual char *utf2mbcs(const char *s);
virtual char *getenv(const char* v);
virtual int open(const char* f, int oflags, int pmode);

View File

@ -62,22 +62,6 @@ void Fl_WinAPI_System_Driver::fatal(const char *format, va_list args) {
::exit(1);
}
int Fl_WinAPI_System_Driver::compose(int &del) {
unsigned char ascii = (unsigned char)Fl::e_text[0];
int condition = (Fl::e_state & (FL_ALT | FL_META)) && !(ascii & 128) ;
if (condition) { // this stuff is to be treated as a function key
del = 0;
return 0;
}
del = Fl::compose_state;
Fl::compose_state = 0;
// Only insert non-control characters:
if ( (!Fl::compose_state) && ! (ascii & ~31 && ascii!=127)) {
return 0;
}
return 1;
}
char *Fl_WinAPI_System_Driver::utf2mbcs(const char *s) {
if (!s) return NULL;
size_t l = strlen(s);

View File

@ -73,6 +73,9 @@ public:
virtual void repeat_timeout(double time, Fl_Timeout_Handler cb, void *argp);
virtual int has_timeout(Fl_Timeout_Handler cb, void *argp);
virtual void remove_timeout(Fl_Timeout_Handler cb, void *argp);
virtual int dnd(int unused);
virtual int compose(int &del);
virtual void compose_reset();
};

View File

@ -34,6 +34,7 @@
#endif
extern Atom fl_NET_WORKAREA;
extern XIC fl_xim_ic; // in Fl_x.cxx
// Add these externs to allow X11 port to build - same as Fl_WinAPI_Screen_Driver.cxx.
// These should be in an internal header somewhere?
@ -609,7 +610,23 @@ void Fl_X11_Screen_Driver::remove_timeout(Fl_Timeout_Handler cb, void *argp) {
}
}
int Fl_X11_Screen_Driver::compose(int& del) {
int condition;
unsigned char ascii = (unsigned char)Fl::e_text[0];
condition = (Fl::e_state & (FL_ALT | FL_META | FL_CTRL)) && !(ascii & 128) ;
if (condition) { del = 0; return 0;} // this stuff is to be treated as a function key
del = Fl::compose_state;
Fl::compose_state = 0;
// Only insert non-control characters:
if ( (!Fl::compose_state) && ! (ascii & ~31 && ascii!=127)) { return 0; }
return 1;
}
void Fl_X11_Screen_Driver::compose_reset()
{
Fl::compose_state = 0;
if (fl_xim_ic) XmbResetIC(fl_xim_ic);
}
//
// End of "$Id$".

View File

@ -24,7 +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 "drivers/WinAPI/Fl_WinAPI_Screen_Driver.H"
#include "flstring.h"
#include <stdio.h>
#include <stdlib.h>
@ -521,7 +521,7 @@ public:
};
int Fl_WinAPI_System_Driver::dnd(int unused)
int Fl_WinAPI_Screen_Driver::dnd(int unused)
{
DWORD dropEffect;
ReleaseCapture();

View File

@ -20,7 +20,7 @@
#include <FL/Fl_Window.H>
#include <FL/x.H>
#include "flstring.h"
#include "drivers/Posix/Fl_Posix_System_Driver.H"
#include "drivers/X11/Fl_X11_Screen_Driver.H"
extern Atom fl_XdndAware;
@ -80,7 +80,7 @@ static int local_handle(int event, Fl_Window* window) {
return ret;
}
int Fl_Posix_System_Driver::dnd(int unused) {
int Fl_X11_Screen_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());