diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-04-17 14:22:02 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-04-17 14:22:02 +0000 |
| commit | cc57af841a11ee314efca6a434ff14bed51706e4 (patch) | |
| tree | f3080908a464e23d2c24c3643a049afc4f449708 /src/drivers | |
| parent | a4e5dc0267bf972b5897aec0f167b3e2d9488a8c (diff) | |
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
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 5 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 28 | ||||
| -rw-r--r-- | src/drivers/Pico/Fl_Pico_Window_Driver.cxx | 2 | ||||
| -rw-r--r-- | src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx | 13 | ||||
| -rw-r--r-- | src/drivers/PicoSDL/Fl_PicoSDL_System_Driver.cxx | 1 | ||||
| -rw-r--r-- | src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx | 30 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | 75 |
8 files changed, 127 insertions, 29 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index 4d4a50bd1..bbda02bc2 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -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 // diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 7da208573..817c7e154 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -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$". // diff --git a/src/drivers/Pico/Fl_Pico_Window_Driver.cxx b/src/drivers/Pico/Fl_Pico_Window_Driver.cxx index da8be8097..cdd5eed27 100644 --- a/src/drivers/Pico/Fl_Pico_Window_Driver.cxx +++ b/src/drivers/Pico/Fl_Pico_Window_Driver.cxx @@ -36,8 +36,6 @@ Fl_Pico_Window_Driver::~Fl_Pico_Window_Driver() } -// --- window data - int Fl_Pico_Window_Driver::decorated_w() { return w(); diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx b/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx index 30377c0a9..c1a96e2cc 100644 --- a/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx +++ b/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx @@ -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() { } diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_System_Driver.cxx b/src/drivers/PicoSDL/Fl_PicoSDL_System_Driver.cxx index 7b3b9e4fb..6122ff5f1 100644 --- a/src/drivers/PicoSDL/Fl_PicoSDL_System_Driver.cxx +++ b/src/drivers/PicoSDL/Fl_PicoSDL_System_Driver.cxx @@ -29,7 +29,6 @@ Fl_System_Driver *Fl_System_Driver::newSystemDriver() { return new Fl_System_Driver(); -// return new Fl_PicoSDL_System_Driver(); } diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx b/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx index 531e697d8..1c56b42b5 100644 --- a/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx +++ b/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx @@ -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(); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index 808900677..ff037c3e1 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -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(); }; diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index 44d0ad1a5..717718cb4 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -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$". // |
