Rewrite Fl_compose.cxx under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11454 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
28d1a2d684
commit
4fbbab8b41
@ -25,6 +25,7 @@
|
||||
#define FL_SYSTEM_DRIVER_H
|
||||
|
||||
#include <FL/Fl_Export.H>
|
||||
#include <FL/Fl.H>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -85,6 +86,10 @@ 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() { Fl::compose_state = 0; }
|
||||
};
|
||||
|
||||
#endif // FL_SYSTEM_DRIVER_H
|
||||
|
@ -22,21 +22,12 @@ Utility functions to support text input.
|
||||
*/
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_System_Driver.H>
|
||||
|
||||
#ifndef FL_DOXYGEN
|
||||
int Fl::compose_state = 0;
|
||||
#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform character composition
|
||||
int Fl_X::next_marked_length = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform character composition
|
||||
#elif defined(FL_PORTING)
|
||||
# pragma message "FL_PORTING: implement keyboard composing in the code below"
|
||||
#else // X11
|
||||
extern XIC fl_xim_ic;
|
||||
#endif
|
||||
|
||||
/** Any text editing widget should call this for each FL_KEYBOARD event.
|
||||
Use of this function is very simple.
|
||||
@ -79,63 +70,9 @@ extern XIC fl_xim_ic;
|
||||
other user-interface things to allow characters to be selected.
|
||||
*/
|
||||
int Fl::compose(int& del) {
|
||||
int condition;
|
||||
#if defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform character composition
|
||||
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 ;
|
||||
#else
|
||||
unsigned char ascii = (unsigned char)e_text[0];
|
||||
#if defined(WIN32)
|
||||
condition = (e_state & (FL_ALT | FL_META)) && !(ascii & 128) ;
|
||||
#else
|
||||
condition = (e_state & (FL_ALT | FL_META | FL_CTRL)) && !(ascii & 128) ;
|
||||
#endif // WIN32
|
||||
#endif // __APPLE__ // PORTME: Fl_Screen_Driver - platform character composition
|
||||
if (condition) { del = 0; return 0;} // this stuff is to be treated as a function key
|
||||
del = Fl::compose_state;
|
||||
#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform character composition
|
||||
Fl::compose_state = Fl_X::next_marked_length;
|
||||
#else
|
||||
Fl::compose_state = 0;
|
||||
// Only insert non-control characters:
|
||||
if ( (!Fl::compose_state) && ! (ascii & ~31 && ascii!=127)) { return 0; }
|
||||
#endif
|
||||
return 1;
|
||||
return Fl_System_Driver::driver()->compose(del);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform character composition
|
||||
static int insertion_point_x = 0;
|
||||
static int insertion_point_y = 0;
|
||||
static int insertion_point_height = 0;
|
||||
static bool insertion_point_location_is_valid = false;
|
||||
|
||||
void Fl::reset_marked_text() {
|
||||
Fl::compose_state = 0;
|
||||
Fl_X::next_marked_length = 0;
|
||||
insertion_point_location_is_valid = false;
|
||||
}
|
||||
|
||||
int Fl_X::insertion_point_location(int *px, int *py, int *pheight)
|
||||
// return true if the current coordinates of the insertion point are available
|
||||
{
|
||||
if ( ! insertion_point_location_is_valid ) return false;
|
||||
*px = insertion_point_x;
|
||||
*py = insertion_point_y;
|
||||
*pheight = insertion_point_height;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Fl::insertion_point_location(int x, int y, int height) {
|
||||
insertion_point_location_is_valid = true;
|
||||
insertion_point_x = x;
|
||||
insertion_point_y = y;
|
||||
insertion_point_height = height;
|
||||
}
|
||||
#endif // __APPLE__ // PORTME: Fl_Screen_Driver - platform character composition
|
||||
|
||||
/**
|
||||
If the user moves the cursor, be sure to call Fl::compose_reset().
|
||||
The next call to Fl::compose() will start out in an initial state. In
|
||||
@ -144,13 +81,7 @@ void Fl::insertion_point_location(int x, int y, int height) {
|
||||
*/
|
||||
void Fl::compose_reset()
|
||||
{
|
||||
Fl::compose_state = 0;
|
||||
#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform character composition
|
||||
#elif defined(FL_PORTING)
|
||||
# pragma message "FL_PORTING: compose reset extra functions"
|
||||
#else
|
||||
if (fl_xim_ic) XmbResetIC(fl_xim_ic);
|
||||
#endif
|
||||
Fl_System_Driver::driver()->compose_reset();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -43,6 +43,7 @@ class Fl_Darwin_System_Driver : public Fl_System_Driver
|
||||
public:
|
||||
virtual int single_arg(const char *arg);
|
||||
virtual int arg_and_value(const char *name, const char *value);
|
||||
virtual int compose(int &del);
|
||||
};
|
||||
|
||||
#endif // FL_DARWIN_SYSTEM_DRIVER_H
|
||||
|
@ -19,8 +19,12 @@
|
||||
|
||||
#include "../../config_lib.h"
|
||||
#include "Fl_Darwin_System_Driver.H"
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/x.H>
|
||||
#include <string.h>
|
||||
|
||||
int Fl_X::next_marked_length = 0;
|
||||
|
||||
//const char* fl_local_alt = "\xe2\x8c\xa5\\"; // U+2325 (option key)
|
||||
const char* fl_local_alt = "⌥\\"; // U+2325 (option key)
|
||||
//const char* fl_local_ctrl = "\xe2\x8c\x83\\"; // U+2303 (up arrowhead)
|
||||
@ -45,6 +49,46 @@ int Fl_Darwin_System_Driver::arg_and_value(const char *name, const char *value)
|
||||
return strcmp(name, "NSDocumentRevisionsDebugMode") == 0;
|
||||
}
|
||||
|
||||
static int insertion_point_x = 0;
|
||||
static int insertion_point_y = 0;
|
||||
static int insertion_point_height = 0;
|
||||
static bool insertion_point_location_is_valid = false;
|
||||
|
||||
void Fl::reset_marked_text() {
|
||||
Fl::compose_state = 0;
|
||||
Fl_X::next_marked_length = 0;
|
||||
insertion_point_location_is_valid = false;
|
||||
}
|
||||
|
||||
int Fl_X::insertion_point_location(int *px, int *py, int *pheight)
|
||||
// return true if the current coordinates of the insertion point are available
|
||||
{
|
||||
if ( ! insertion_point_location_is_valid ) return false;
|
||||
*px = insertion_point_x;
|
||||
*py = insertion_point_y;
|
||||
*pheight = insertion_point_height;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Fl::insertion_point_location(int x, int y, int height) {
|
||||
insertion_point_location_is_valid = true;
|
||||
insertion_point_x = x;
|
||||
insertion_point_y = y;
|
||||
insertion_point_height = height;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
@ -43,6 +43,8 @@ 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();
|
||||
};
|
||||
|
||||
#endif // FL_POSIX_SYSTEM_DRIVER_H
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "Fl_Posix_System_Driver.H"
|
||||
#include <FL/Fl.H>
|
||||
|
||||
extern XIC fl_xim_ic; // in Fl_x.cxx
|
||||
|
||||
|
||||
// Pointers you can use to change FLTK to a foreign language.
|
||||
// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx
|
||||
@ -42,6 +44,24 @@ 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);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -45,6 +45,7 @@ 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);
|
||||
};
|
||||
|
||||
#endif // FL_WINAPI_SYSTEM_DRIVER_H
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "../../config_lib.h"
|
||||
#include "Fl_WinAPI_System_Driver.H"
|
||||
#include <FL/Fl.H>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
@ -51,6 +52,21 @@ 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;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
Loading…
Reference in New Issue
Block a user