virtualizes fl_set_spot and fl_reset_spot

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11640 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2016-04-17 14:22:02 +00:00
parent a4e5dc0267
commit cc57af841a
15 changed files with 149 additions and 146 deletions
+2
View File
@@ -240,6 +240,8 @@ public:
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s) { return float(s); }
// default implementation may be enough
virtual float scale_bitmap_for_PostScript() { return 2; }
virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
virtual void reset_spot();
// each platform implements these 3 functions its own way
static void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h);
static Fl_Region XRectangleRegion(int x, int y, int w, int h);
+9
View File
@@ -69,6 +69,15 @@ void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen
delete[] img;
}
void Fl_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
// nothing to do
}
void Fl_Graphics_Driver::reset_spot()
{
// nothing to do
}
//
// End of "$Id$".
-8
View File
@@ -147,14 +147,6 @@ static KeyScript_type KeyScript;
/* fltk-utf8 placekeepers */
void fl_reset_spot()
{
}
void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
}
void fl_set_status(int x, int y, int w, int h)
{
}
-10
View File
@@ -40,16 +40,6 @@ void *fl_gc = NULL;
Window fl_window = NULL;
void fl_reset_spot()
{
# pragma message "FL_PORTING: implement fl_reset_spot"
}
void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
# pragma message "FL_PORTING: implement fl_set_spot"
}
void fl_set_status(int x, int y, int w, int h)
{
# pragma message "FL_PORTING: implement fl_set_status"
-26
View File
@@ -290,32 +290,6 @@ static struct FD {
extern unsigned int fl_codepage;
void fl_reset_spot()
{
}
void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
if (!win) return;
Fl_Window* tw = win;
while (tw->parent()) tw = tw->window(); // find top level window
if (!tw->shown())
return;
HIMC himc = flImmGetContext(fl_xid(tw));
if (himc) {
COMPOSITIONFORM cfs;
cfs.dwStyle = CFS_POINT;
cfs.ptCurrentPos.x = X;
cfs.ptCurrentPos.y = Y - tw->labelsize();
MapWindowPoints(fl_xid(win), fl_xid(tw), &cfs.ptCurrentPos, 1);
flImmSetCompositionWindow(himc, &cfs);
flImmReleaseContext(fl_xid(tw), himc);
}
}
void fl_set_status(int x, int y, int w, int h)
{
}
-73
View File
@@ -489,79 +489,6 @@ static void fl_new_ic()
}
static XRectangle spot;
static int spotf = -1;
static int spots = -1;
void fl_reset_spot(void)
{
spot.x = -1;
spot.y = -1;
//if (fl_xim_ic) XUnsetICFocus(fl_xim_ic);
}
void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
int change = 0;
XVaNestedList preedit_attr;
static XFontSet fs = NULL;
char **missing_list;
int missing_count;
char *def_string;
char *fnt = NULL;
bool must_free_fnt =true;
static XIC ic = NULL;
if (!fl_xim_ic || !fl_is_over_the_spot) return;
//XSetICFocus(fl_xim_ic);
if (X != spot.x || Y != spot.y) {
spot.x = X;
spot.y = Y;
spot.height = H;
spot.width = W;
change = 1;
}
if (font != spotf || size != spots) {
spotf = font;
spots = size;
change = 1;
if (fs) {
XFreeFontSet(fl_display, fs);
}
#if USE_XFT
#if defined(__GNUC__)
// FIXME: warning XFT support here
#endif /*__GNUC__*/
fnt = NULL; // fl_get_font_xfld(font, size);
if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
fs = XCreateFontSet(fl_display, fnt, &missing_list,
&missing_count, &def_string);
#else
fnt = fl_get_font_xfld(font, size);
if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
fs = XCreateFontSet(fl_display, fnt, &missing_list,
&missing_count, &def_string);
#endif
}
if (fl_xim_ic != ic) {
ic = fl_xim_ic;
change = 1;
}
if (fnt && must_free_fnt) free(fnt);
if (!change) return;
preedit_attr = XVaCreateNestedList(0,
XNSpotLocation, &spot,
XNFontSet, fs, NULL);
XSetICValues(fl_xim_ic, XNPreeditAttributes, preedit_attr, NULL);
XFree(preedit_attr);
}
void fl_set_status(int x, int y, int w, int h)
{
XVaNestedList status_attr;
+5
View File
@@ -127,8 +127,11 @@ protected:
void color(Fl_Color c);
Fl_Color color() { return color_; }
void color(uchar r, uchar g, uchar b);
void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
void reset_spot();
};
/**
The graphics driver used when printing on MSWindows.
*
@@ -142,6 +145,7 @@ public:
int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
};
class Fl_Translated_GDI_Graphics_Driver : public Fl_GDI_Graphics_Driver {
unsigned depth;
POINT origins[10];
@@ -151,6 +155,7 @@ public:
virtual void untranslate_all(void);
};
#endif // FL_GDI_GRAPHICS_DRIVER_H
//
@@ -179,6 +179,34 @@ void Fl_Graphics_Driver::XDestroyRegion(Fl_Region r) {
}
void Fl_Graphics_Driver::reset_spot()
{
}
void Fl_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
if (!win) return;
Fl_Window* tw = win;
while (tw->parent()) tw = tw->window(); // find top level window
if (!tw->shown())
return;
HIMC himc = flImmGetContext(fl_xid(tw));
if (himc) {
COMPOSITIONFORM cfs;
cfs.dwStyle = CFS_POINT;
cfs.ptCurrentPos.x = X;
cfs.ptCurrentPos.y = Y - tw->labelsize();
MapWindowPoints(fl_xid(win), fl_xid(tw), &cfs.ptCurrentPos, 1);
flImmSetCompositionWindow(himc, &cfs);
flImmReleaseContext(fl_xid(tw), himc);
}
}
//
// End of "$Id$".
//
@@ -36,8 +36,6 @@ Fl_Pico_Window_Driver::~Fl_Pico_Window_Driver()
}
// --- window data
int Fl_Pico_Window_Driver::decorated_w()
{
return w();
@@ -38,6 +38,7 @@ Fl_PicoSDL_Screen_Driver::Fl_PicoSDL_Screen_Driver()
{
}
Fl_PicoSDL_Screen_Driver::~Fl_PicoSDL_Screen_Driver()
{
}
@@ -118,12 +119,22 @@ double Fl_PicoSDL_Screen_Driver::wait(double time_to_wait)
break;
case SDL_MOUSEWHEEL:
break;
case SDL_KEYDOWN: // full keyboard support is a lot more complex
case SDL_KEYUP:
if (e.type==SDL_KEYDOWN) Fl::e_number = FL_KEYDOWN; else Fl::e_number = FL_KEYUP;
if (!window) break;
if (e.key.keysym.sym==SDLK_ESCAPE) {
Fl::e_keysym = FL_Escape;
Fl::handle(Fl::e_number, window);
}
break;
}
}
return 0.0;
}
// FIXME: remove the stuff below
#include <FL/x.H>
#include <FL/Fl.H>
@@ -147,8 +158,6 @@ double Fl_PicoSDL_Screen_Driver::wait(double time_to_wait)
#if !defined(FL_DOXYGEN) // FIXME silence Doxygen warnings
void fl_set_spot(int, int, int, int, int, int, Fl_Window*) { }
void fl_reset_spot() { }
//const char *fl_filename_name(char const*) { return 0; }
void fl_clipboard_notify_change() { }
@@ -29,7 +29,6 @@
Fl_System_Driver *Fl_System_Driver::newSystemDriver()
{
return new Fl_System_Driver();
// return new Fl_PicoSDL_System_Driver();
}
@@ -24,7 +24,7 @@
#include <FL/Fl.H>
#include <FL/Fl_WIndow.H>
void Fl_Window_Driver::default_icons(Fl_RGB_Image const**, int) { }
const char *fl_local_alt = "alt";
const char *fl_local_ctrl = "ctrl";
@@ -38,6 +38,10 @@ Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *win)
}
void Fl_Window_Driver::default_icons(Fl_RGB_Image const**, int) {
}
Fl_PicoSDL_Window_Driver::Fl_PicoSDL_Window_Driver(Fl_Window *win)
: Fl_Pico_Window_Driver(win)
{
@@ -88,32 +92,9 @@ Fl_X *Fl_PicoSDL_Window_Driver::makeWindow()
}
#if 0
void Fl_PicoSDL_Window_Driver::flush_single()
{
if (!shown()) return;
pWindow->make_current();
Fl_X *i = Fl_X::i(pWindow);
if (!i) return;
fl_clip_region(i->region);
i->region = 0;
// SDL_RenderClear((SDL_Renderer*)i->xid);
pWindow->draw();
SDL_RenderPresent((SDL_Renderer*)i->xid);
}
#endif
void Fl_PicoSDL_Window_Driver::draw_end()
{
// if (!shown()) return;
// pWindow->make_current();
Fl_X *i = Fl_X::i(pWindow);
// if (!i) return;
// fl_clip_region(i->region);
// i->region = 0;
// // SDL_RenderClear((SDL_Renderer*)i->xid);
// pWindow->draw();
SDL_RenderPresent((SDL_Renderer*)i->xid);
}
@@ -123,6 +104,7 @@ void Fl_PicoSDL_Window_Driver::make_current()
fl_window = pWindow->i->xid;
}
void Fl_PicoSDL_Window_Driver::show() {
if (!shown()) {
makeWindow();
@@ -129,6 +129,8 @@ protected:
void color(uchar r, uchar g, uchar b);
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s);
virtual float scale_bitmap_for_PostScript();
virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
virtual void reset_spot();
};
@@ -118,6 +118,81 @@ void Fl_Xlib_Graphics_Driver::fixloop() { // remove equal points from closed pa
while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
}
// FIXME: should be members of Fl_Xlib_Graphics_Driver
static XRectangle spot;
static int spotf = -1;
static int spots = -1;
void Fl_Xlib_Graphics_Driver::reset_spot(void)
{
spot.x = -1;
spot.y = -1;
//if (fl_xim_ic) XUnsetICFocus(fl_xim_ic);
}
void Fl_Xlib_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
int change = 0;
XVaNestedList preedit_attr;
static XFontSet fs = NULL;
char **missing_list;
int missing_count;
char *def_string;
char *fnt = NULL;
bool must_free_fnt =true;
static XIC ic = NULL;
if (!fl_xim_ic || !fl_is_over_the_spot) return;
//XSetICFocus(fl_xim_ic);
if (X != spot.x || Y != spot.y) {
spot.x = X;
spot.y = Y;
spot.height = H;
spot.width = W;
change = 1;
}
if (font != spotf || size != spots) {
spotf = font;
spots = size;
change = 1;
if (fs) {
XFreeFontSet(fl_display, fs);
}
#if USE_XFT
#if defined(__GNUC__)
// FIXME: warning XFT support here
#endif /*__GNUC__*/
fnt = NULL; // fl_get_font_xfld(font, size);
if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
fs = XCreateFontSet(fl_display, fnt, &missing_list,
&missing_count, &def_string);
#else
fnt = fl_get_font_xfld(font, size);
if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
fs = XCreateFontSet(fl_display, fnt, &missing_list,
&missing_count, &def_string);
#endif
}
if (fl_xim_ic != ic) {
ic = fl_xim_ic;
change = 1;
}
if (fnt && must_free_fnt) free(fnt);
if (!change) return;
preedit_attr = XVaCreateNestedList(0,
XNSpotLocation, &spot,
XNFontSet, fs, NULL);
XSetICValues(fl_xim_ic, XNPreeditAttributes, preedit_attr, NULL);
XFree(preedit_attr);
}
//
// End of "$Id$".
//
+11
View File
@@ -50,6 +50,17 @@ void fl_text_extents(const char *c, int &dx, int &dy, int &w, int &h) {
void fl_draw(const char* str, int l, float x, float y) {
fl_graphics_driver->draw(str, l, x, y);
}
void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
{
fl_graphics_driver->set_spot(font, size, X, Y, W, H, win);
}
void fl_reset_spot()
{
fl_graphics_driver->reset_spot();
}
//
// End of "$Id$".
//