diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2018-03-27 15:31:26 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2018-03-27 15:31:26 +0000 |
| commit | e52b55c09daa15566e60bab7b8fd46afeb063564 (patch) | |
| tree | e9eb6df9e9ccd3ddd351d978d1391710b00253ef /src/drivers | |
| parent | daca2a95cf0e0d14df68b4e21ed077a88dbb19be (diff) | |
Android: Fl_Android_Graphics_Driver now derives from Fl_Graphics_Driver and no longer from the dpi-aware scaling version. I may add this level of complexity later, but for now, unscaled drivers are difficult enough. Also, the new setup lets me easily find unimplemented methods of the driver.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12809 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Driver.H | 463 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Driver.cxx | 205 | ||||
| -rw-r--r-- | src/drivers/Android/Fl_Android_Graphics_Font.cxx | 28 |
3 files changed, 492 insertions, 204 deletions
diff --git a/src/drivers/Android/Fl_Android_Graphics_Driver.H b/src/drivers/Android/Fl_Android_Graphics_Driver.H index e6b4991a2..0b67e8c7a 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Driver.H +++ b/src/drivers/Android/Fl_Android_Graphics_Driver.H @@ -39,149 +39,370 @@ class Fl_Android_Bytemap; This class is implemented only on the Windows platform. */ -class FL_EXPORT Fl_Android_Graphics_Driver : public Fl_Scalable_Graphics_Driver +class FL_EXPORT Fl_Android_Graphics_Driver : public Fl_Graphics_Driver { - class Vertex { - public: - void set(float x, float y, bool gap = false) { pX = x; pY = y; pIsGap = gap; } - float pX, pY; - bool pIsGap; - }; + // easy access to the super class + typedef Fl_Graphics_Driver super; -public: - Fl_Android_Graphics_Driver(); - virtual ~Fl_Android_Graphics_Driver() override; +protected: + class Vertex; // see below - void make_current(Fl_Window*); + // --- this is a copy of Fl_Graphics_Driver ---------------------------------- + // - use this to find unimplementet calls in the derived driver + // - excluded by #if/#endif means that we have not implemneted this yet + // - methods marked with // super: use the implemnetation of the super class + // - virtual ... override functions are implemented for Android +#if 0 +private: + // some platforms may need to reimplement this + virtual void set_current_(); +protected: + float scale_; // scale between user and graphical coordinates: graphical = user * scale_ + /** Sets the current value of the scaling factor */ + virtual void scale(float f) { scale_ = f; } +public: + // The following functions create the various graphics drivers that are required + // for core operations. They must be implemented as members of Fl_Graphics_Driver, + // but located in the device driver module that is linked to the core library + /** Instantiate the graphics driver adequate to draw to the platform's display driver. + Each platform implements this method its own way. + */ + static Fl_Graphics_Driver *newMainGraphicsDriver(); + /** A 2D coordinate transformation matrix */ + struct matrix {double a, b, c, d, x, y;}; + /** Features that a derived class may possess. */ + typedef enum { + NATIVE = 1, /**< native graphics driver for the platform */ + PRINTER = 2 /**< graphics driver for a printer drawing surface */ + } driver_feature; - // --- text and font stuff - virtual void draw_unscaled(const char* str, int n, int x, int y) override; - virtual double width_unscaled(const char *str, int n) override; - virtual double width_unscaled(unsigned int c) override; - virtual Fl_Fontsize size_unscaled() override; - virtual void text_extents_unscaled(const char *str, int n, int &dx, int &dy, int &w, int &h) override; - virtual int height_unscaled() override; - virtual int descent_unscaled() override; - virtual void font_unscaled(Fl_Font face, Fl_Fontsize size) override; - virtual const char *get_font_name(Fl_Font fnum, int* ap) override; - virtual const char *font_name(int num) override; - virtual int get_font_sizes(Fl_Font fnum, int*& sizep) override; - virtual Fl_Font set_fonts(const char *name) override; - virtual void font_name(int num, const char *name) override; +protected: + int fl_clip_state_number; ///< For internal use by FLTK + static const matrix m0; ///< For internal use by FLTK + Fl_Font font_; ///< current font + Fl_Fontsize size_; ///< current font size + Fl_Color color_; ///< current color + int sptr;///< For internal use by FLTK + static const int matrix_stack_size = FL_MATRIX_STACK_SIZE; ///< For internal use by FLTK + matrix stack[FL_MATRIX_STACK_SIZE]; ///< For internal use by FLTK + matrix m; ///< current transformation matrix + int n; ///< For internal use by FLTK + int gap_; ///< For internal use by FLTK + int what; ///< For internal use by FLTK + int rstackptr; ///< For internal use by FLTK + static const int region_stack_max = FL_REGION_STACK_SIZE - 1; ///< For internal use by FLTK + Fl_Region rstack[FL_REGION_STACK_SIZE]; ///< For internal use by FLTK + Fl_Font_Descriptor *font_descriptor_; ///< For internal use by FLTK +#ifndef FL_DOXYGEN + enum {LINE, LOOP, POLYGON, POINT_}; + inline int vertex_no() { return n; } + inline int vertex_kind() {return what;} +#endif + matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */ + virtual void global_gc(); + /** Support function for Fl_Pixmap drawing */ + virtual fl_uintptr_t cache(Fl_Pixmap *img) { return 0; } +#endif + /** Support function for Fl_Bitmap drawing */ + virtual fl_uintptr_t cache(Fl_Bitmap *img) override; +#if 0 + /** Support function for Fl_RGB_Image drawing */ + virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) { } + // --- implementation is in src/drivers/xxx/Fl_xxx_Graphics_Driver_image.cxx + /** see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L) */ + virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) {} + /** see fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L) */ + virtual void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) {} + /** see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) */ + virtual void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) {} + /** see fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) */ + virtual void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) {} + /** \brief Draws an Fl_RGB_Image object using this graphics driver. + * + Specifies a bounding box for the image, with the origin (upper left-hand corner) of + the image offset by the cx and cy arguments. + */ + virtual void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) {} + /** \brief Draws an Fl_Pixmap object using this graphics driver. + * + Specifies a bounding box for the image, with the origin (upper left-hand corner) of + the image offset by the cx and cy arguments. + */ + virtual void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) {} +#endif + /** \brief Draws an Fl_Bitmap object using this graphics driver. + * + Specifies a bounding box for the image, with the origin (upper left-hand corner) of + the image offset by the cx and cy arguments. + */ + virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) override; +#if 0 + virtual void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); - // --- line drawing stuff - virtual void rectf_unscaled(float x, float y, float w, float h) override; - void rectf_unclipped(float x, float y, float w, float h); - virtual void point_unscaled(float x, float y) override; - virtual void rect_unscaled(float x, float y, float w, float h) override; - virtual void xyline_unscaled(float x, float y, float x1) override; - void xyline_unclipped(float x, float y, float x1); - virtual void yxline_unscaled(float x, float y, float y1) override; - void yxline_unclipped(float x, float y, float y1); - virtual void line_unscaled(float x, float y, float x1, float y1) override; - virtual void line_unscaled(float x, float y, float x1, float y1, float x2, float y2) override; - virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2) override; - virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) override; - virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2) override; - virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) override; - virtual void arc_unscaled(float x, float y, float w, float h, double a1, double a2) override; - virtual void pie_unscaled(float x, float y, float w, float h, double a1, double a2) override; - virtual void ellipse_unscaled(double xt, double yt, double rx, double ry) override; - - // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx + /** Support function for image drawing */ + virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) {return 0; } + /** Support function for image drawing */ + virtual void delete_bitmask(Fl_Bitmask bm) {} + /** For internal library use only */ + static void change_image_size(Fl_Image *img, int W, int H) { + img->w(W); + img->h(H); + } + // Support function for image drawing + virtual void uncache_pixmap(fl_uintptr_t p); + // accessor functions to protected image members + int start_image(Fl_Image *img, int XP, int YP, int WP, int HP, int &cx, int &cy, + int &X, int &Y, int &W, int &H); + /** Accessor to a private member variable of Fl_RGB_Image */ + static fl_uintptr_t* id(Fl_RGB_Image *rgb) {return &(rgb->id_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static fl_uintptr_t* id(Fl_Pixmap *pm) {return &(pm->id_);} + /** Accessor to a private member variable of Fl_Bitmap */ + static fl_uintptr_t* id(Fl_Bitmap *bm) {return &(bm->id_);} + /** Accessor to a private member variable of Fl_RGB_Image */ + static fl_uintptr_t* mask(Fl_RGB_Image *rgb) {return &(rgb->mask_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static fl_uintptr_t* mask(Fl_Pixmap *pm) {return &(pm->mask_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static float* cache_scale(Fl_Pixmap *pm) {return &(pm->cache_scale_);} + /** Accessor to a private member variable of Fl_Bitmap */ + static float* cache_scale(Fl_Bitmap *bm) {return &(bm->cache_scale_);} + /** Accessor to a private member variable of Fl_RGB_Image */ + static float* cache_scale(Fl_RGB_Image *rgb) {return &(rgb->cache_scale_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static Fl_Color* pixmap_bg_color(Fl_Pixmap *pm) {return &(pm->pixmap_bg_color);} + /** For internal library use only */ + static void draw_empty(Fl_Image* img, int X, int Y) {img->draw_empty(X, Y);} + /** Accessor to a private member function of Fl_Bitmap */ + static int prepare(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int &cx, int &cy, + int &X, int &Y, int &W, int &H) { + return bm->prepare(XP,YP,WP,HP,cx,cy,X,Y,W,H); + } + /** Accessor to a private member function of Fl_Pixmap */ + static int prepare(Fl_Pixmap *pm, int XP, int YP, int WP, int HP, int &cx, int &cy, + int &X, int &Y, int &W, int &H) { + return pm->prepare(XP,YP,WP,HP,cx,cy,X,Y,W,H); + } +#endif +public: + /** Constructor, C++11 initialises member variables in-line */ + Fl_Android_Graphics_Driver(); + /** destructor */ + virtual ~Fl_Android_Graphics_Driver() override; + /** Return whether the graphics driver can do alpha blending */ + virtual char can_do_alpha_blending() override { return 0; } + // --- implementation is in src/fl_rect.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_rect.cxx + /** see fl_point() */ + virtual void point(int x, int y) override; + /** see fl_rect() */ + virtual void rect(int x, int y, int w, int h) override; + // super: virtual void focus_rect(int x, int y, int w, int h); + /** see fl_rectf() */ + virtual void rectf(int x, int y, int w, int h) override; + /** see fl_line(int, int, int, int) */ + virtual void line(int x, int y, int x1, int y1) override; + /** see fl_line(int, int, int, int, int, int) */ + virtual void line(int x, int y, int x1, int y1, int x2, int y2) override; + /** see fl_xyline(int, int, int) */ + virtual void xyline(int x, int y, int x1) override; + /** see fl_xyline(int, int, int, int) */ + virtual void xyline(int x, int y, int x1, int y2) override; + /** see fl_xyline(int, int, int, int, int) */ + virtual void xyline(int x, int y, int x1, int y2, int x3) override; + /** see fl_yxline(int, int, int) */ + virtual void yxline(int x, int y, int y1) override; + /** see fl_yxline(int, int, int, int) */ + virtual void yxline(int x, int y, int y1, int x2) override; + /** see fl_yxline(int, int, int, int, int) */ + virtual void yxline(int x, int y, int y1, int x2, int y3) override; + /** see fl_loop(int, int, int, int, int, int) */ + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2) override; + /** see fl_loop(int, int, int, int, int, int, int, int) */ + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) override; + /** see fl_polygon(int, int, int, int, int, int) */ + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2) override; + /** see fl_polygon(int, int, int, int, int, int, int, int) */ + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) override; + // --- clipping + /** see fl_push_clip() */ + virtual void push_clip(int x, int y, int w, int h) override; + /** see fl_clip_box() */ + virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) override; + /** see fl_not_clipped() */ + virtual int not_clipped(int x, int y, int w, int h) override; + /** see fl_push_no_clip() */ + virtual void push_no_clip() override; + /** see fl_pop_clip() */ + virtual void pop_clip() override; + virtual Fl_Region clip_region() override; + virtual void clip_region(Fl_Region r) override; + virtual void restore_clip() override; + // --- implementation is in src/fl_vertex.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_vertex.cxx + // super: virtual void push_matrix(); + // super: virtual void pop_matrix(); + // super: virtual void mult_matrix(double a, double b, double c, double d, double x, double y); + // super: virtual void rotate(double d); + // super: virtual void translate(double x,double y); virtual void begin_points() override; virtual void begin_line() override; virtual void begin_loop() override; virtual void begin_polygon() override; virtual void begin_complex_polygon() override; + // super: virtual double transform_x(double x, double y); + // super: virtual double transform_y(double x, double y); + // super: virtual double transform_dx(double x, double y); + // super: virtual double transform_dy(double x, double y); + /** see fl_transformed_vertex() */ + virtual void transformed_vertex(double xf, double yf) override; + /** see fl_vertex() */ + virtual void vertex(double x, double y) override; + /** see fl_end_points() */ virtual void end_points() override; + /** see fl_end_line() */ virtual void end_line() override; + /** see fl_end_loop() */ virtual void end_loop() override; + /** see fl_end_polygon() */ virtual void end_polygon() override; - void end_polygon(int begin, int end); + /** see fl_end_complex_polygon() */ virtual void end_complex_polygon() override; + /** see fl_gap() */ virtual void gap() override; - virtual void transformed_vertex0(float x, float y) override; - - // --- clipping - virtual void push_clip(int x, int y, int w, int h) override; - virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) override; - virtual int not_clipped(int x, int y, int w, int h) override; - virtual void push_no_clip() override; - virtual void pop_clip() override; - virtual void restore_clip() override; - virtual void clip_region(Fl_Region r) override; - virtual Fl_Region clip_region() override; - - virtual void line_style_unscaled(int style, float width, char* dashes) override; - - // --- matrix based drawing -// virtual void line_unscaled(float x, float y, float x1, float y1) override; - - // --- image drawing - - virtual void draw_unscaled(Fl_Bitmap *pxm, float s, int XP, int YP, int WP, int HP, int cx, int cy) override; - virtual fl_uintptr_t cache(Fl_Bitmap *img) override; - + /** see fl_circle() */ + virtual void circle(double x, double y, double r) override; #if 0 - virtual int has_feature(driver_feature mask) { return mask & NATIVE; } - char can_do_alpha_blending(); - // --- bitmap stuff - Fl_Bitmask create_bitmask(int w, int h, const uchar *array); - void delete_bitmask(Fl_Bitmask bm); - virtual void draw_unscaled(int angle, const char *str, int n, int x, int y); - virtual void rtl_draw_unscaled(const char* str, int n, int x, int y); - void draw_unscaled(Fl_Pixmap *pxm, float s, int XP, int YP, int WP, int HP, int cx, int cy); - void draw_unscaled(Fl_RGB_Image *img, float s, int XP, int YP, int WP, int HP, int cx, int cy); - int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP); - virtual void draw_image_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); - virtual void draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); - virtual void draw_image_mono_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); - virtual void draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); - fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array); - virtual void uncache_pixmap(fl_uintptr_t p); - fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array); - void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); - void copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy); - virtual void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); - void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h); - Fl_Region XRectangleRegion(int x, int y, int w, int h); - void XDestroyRegion(Fl_Region r); - void translate_all(int x, int y); - void untranslate_all(void); - static HRGN scale_region(HRGN r, float f, Fl_GDI_Graphics_Driver *dr); - virtual void scale(float f); -protected: - void fixloop(); - // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/gdi_rect.cxx - virtual Fl_Region scale_clip(float f); - // --- implementation is in src/fl_arc.cxx which includes src/cfg_gfx/xxx_arc.cxx if needed - // using void Fl_Graphics_Driver::arc(double x, double y, double r, double start, double end); - // --- implementation is in src/fl_arci.cxx which includes src/cfg_gfx/xxx_arci.cxx + // TODO: arc() + // --- implementation is in src/fl_arc.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_arc.cxx if needed + virtual void arc(double x, double y, double r, double start, double end); +#endif + // --- implementation is in src/fl_arci.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_arci.cxx + /** see fl_arc(int x, int y, int w, int h, double a1, double a2) */ + virtual void arc(int x, int y, int w, int h, double a1, double a2) override; + /** see fl_pie() */ + virtual void pie(int x, int y, int w, int h, double a1, double a2) override; +#if 0 + // TODO: curve() + // --- implementation is in src/fl_curve.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_curve.cxx if needed + virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3); +#endif // --- implementation is in src/fl_line_style.cxx which includes src/cfg_gfx/xxx_line_style.cxx - virtual void line_style_unscaled(int style, float width, char* dashes); + // TODO: line_style() + /** see fl_line_style() */ + virtual void line_style(int style, int width=0, char* dashes=0) override; // --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx - void color(Fl_Color c); - void color(uchar r, uchar g, uchar b); - Fl_Color color() { return color_; } - void set_color(Fl_Color i, unsigned int c); - void free_color(Fl_Color i, int overlay); - void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win); - void reset_spot(); - void global_gc(); - virtual void overlay_rect(int x, int y, int w , int h); - + /** see fl_color(Fl_Color) */ + // super: virtual void color(Fl_Color c); +#if 0 + virtual void set_color(Fl_Color i, unsigned int c); + virtual void free_color(Fl_Color i, int overlay); + /** see fl_color(void) */ + virtual Fl_Color color() { return color_; } + /** see fl_color(uchar, uchar, uchar) */ + virtual void color(uchar r, uchar g, uchar b) {} #endif + /** see fl_draw(const char *str, int n, int x, int y) */ + virtual void draw(const char *str, int n, int x, int y) override; +#if 0 + /** Draw the first \p n bytes of the string \p str starting at position \p x , \p y */ + virtual void draw(const char *str, int n, float x, float y) { draw(str, n, (int)(x+0.5), (int)(y+0.5));} + /** see fl_draw(int angle, const char *str, int n, int x, int y) */ + virtual void draw(int angle, const char *str, int n, int x, int y) { draw(str, n, x, y); } + /** see fl_rtl_draw(const char *str, int n, int x, int y) */ + virtual void rtl_draw(const char *str, int n, int x, int y) { draw(str, n, x, y); } + /** Returns non-zero if the graphics driver possesses the \p feature */ + virtual int has_feature(driver_feature feature) { return 0; } +#endif + /** see fl_font(Fl_Font, Fl_Fontsize) */ + virtual void font(Fl_Font face, Fl_Fontsize fsize) override; + /** see fl_font(void) */ + // super: virtual Fl_Font font() {return font_; } + /** Return the current font size */ + virtual Fl_Fontsize size() override; + /** Compute the width of the first \p n bytes of the string \p str if drawn with current font */ + virtual double width(const char *str, int n) override; + /** Compute the width of Unicode character \p c if drawn with current font */ + virtual double width(unsigned int c) override; + virtual void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h) override; + /** Return the current line height */ + virtual int height() override; + /** Return the current line descent */ + virtual int descent() override; + /** Return the current Fl_Font_Descriptor */ + // super: inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;} + /** Set the current Fl_Font_Descriptor */ + // super: virtual void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;} +#if 0 + /** Sets the value of the driver-specific graphics context. */ + virtual void gc(void*) {} + /** Returns the driver-specific graphics context, of NULL if there's none. */ + virtual void *gc(void) {return NULL;} + /** Support for pixmap drawing */ + virtual uchar **mask_bitmap() { return 0; } + /** Support for pixmap drawing */ + virtual void mask_bitmap(uchar **) {} + // default implementation may be enough + /** Support for PostScript drawing */ + virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s) { return float(s); } + // default implementation may be enough + /** Support for PostScript drawing */ + 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 + virtual void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h); + virtual Fl_Region XRectangleRegion(int x, int y, int w, int h); + virtual void XDestroyRegion(Fl_Region r); +#endif + /** Support for Fl::get_font_name() */ + virtual const char* get_font_name(Fl_Font fnum, int* ap) override; + /** Support for Fl::get_font_sizes() */ + virtual int get_font_sizes(Fl_Font fnum, int*& sizep) override; + /** Support for Fl::set_fonts() */ + virtual Fl_Font set_fonts(const char *name) override; +#if 0 + /** Some platforms may need to implement this to support fonts */ + virtual Fl_Fontdesc* calc_fl_fonts(void) {return NULL;} + /** Support for Fl::set_font() */ + virtual unsigned font_desc_size(); +#endif + /** Support for Fl::get_font() */ + virtual const char *font_name(int num) override; + /** Support for Fl::set_font() */ + virtual void font_name(int num, const char *name) override; +#if 0 + // Draws an Fl_Image scaled to width W & height H + virtual int draw_scaled(Fl_Image *img, int X, int Y, int W, int H); + /** Support function for fl_overlay_rect() and scaled GUI. + Defaut implementation may be enough */ + virtual bool overlay_rect_unscaled(); + /** Support function for fl_overlay_rect() and scaled GUI. + Defaut implementation may be enough */ + virtual void overlay_rect(int x, int y, int w , int h) { loop(x, y, x+w-1, y, x+w-1, y+h-1, x, y+h-1); } +#endif + // --- end of original Fl_Graphics_Driver header ----------------------------- + + // --- start of Android additions -------------------------------------------- + // start drawing with this driver into the given window + // TODO: how is this different to Fl_Graphics_Driver::set_current_() above + void make_current(Fl_Window*); protected: static uint16_t make565(Fl_Color crgba); - + void rectf_unclipped(int x, int y, int w, int h); + void xyline_unclipped(int x, int y, int x1); + void yxline_unclipped(int x, int y, int y1); + void end_polygon(int begin, int end); + void ellipse(double xt, double yt, double rx, double ry); void render_bytemap(int x, int y, Fl_Android_Bytemap *bm, Fl_Rect_Region &r); int render_letter(int xx, int yy, uint32_t c, Fl_Rect_Region &r); - int32_t pStride; - uint16_t *pBits; + // pointer into the screen buffer at the top left corner of the current window + uint16_t *pBits = nullptr; + + // advance to next line in screen buffer + int32_t pStride = 0; + // TODO: current line style, temp kludge to make focus rect work. int pLineStyle = 0; // Clipping region of the current window in window coordinates (see: pStride and pBits) @@ -193,6 +414,14 @@ protected: // Final clipping region for all graphics calls to this class. Fl_Complex_Region pClippingRegion; + // store vertices for begin_.../end_... drawing + class Vertex { + public: + void set(float x, float y, bool gap = false) { pX = x; pY = y; pIsGap = gap; } + float pX, pY; + bool pIsGap; + }; + void begin_vertices(); void add_vertex(float x, float y, bool gap=false); int pnVertex = 0, pNVertex = 0, pVertexGapStart = 0; @@ -200,6 +429,7 @@ protected: }; +#if 0 /** The graphics driver used when printing on Android. */ @@ -219,6 +449,7 @@ public: #endif }; +#endif #endif // FL_ANDROID_GRAPHICS_DRIVER_H diff --git a/src/drivers/Android/Fl_Android_Graphics_Driver.cxx b/src/drivers/Android/Fl_Android_Graphics_Driver.cxx index c727a9d0e..b6fa13c23 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Driver.cxx +++ b/src/drivers/Android/Fl_Android_Graphics_Driver.cxx @@ -38,8 +38,11 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() } +/** + * Private default constructor. + */ Fl_Android_Graphics_Driver::Fl_Android_Graphics_Driver() : - pStride(0), pBits(0) + super() { } @@ -96,7 +99,7 @@ uint16_t Fl_Android_Graphics_Driver::make565(Fl_Color crgba) } -void Fl_Android_Graphics_Driver::rectf_unscaled(float x, float y, float w, float h) +void Fl_Android_Graphics_Driver::rectf(int x, int y, int w, int h) { for (const auto &it: pClippingRegion.overlapping(Fl_Rect_Region(x, y, w, h))) { Fl_Rect_Region &s = it->clipped_rect(); @@ -105,7 +108,7 @@ void Fl_Android_Graphics_Driver::rectf_unscaled(float x, float y, float w, float } -void Fl_Android_Graphics_Driver::rectf_unclipped(float x, float y, float w, float h) +void Fl_Android_Graphics_Driver::rectf_unclipped(int x, int y, int w, int h) { if (w<=0 || h<=0) return; @@ -125,7 +128,7 @@ void Fl_Android_Graphics_Driver::rectf_unclipped(float x, float y, float w, floa } -void Fl_Android_Graphics_Driver::xyline_unscaled(float x, float y, float x1) +void Fl_Android_Graphics_Driver::xyline(int x, int y, int x1) { float w; if (x1>x) { @@ -141,7 +144,22 @@ void Fl_Android_Graphics_Driver::xyline_unscaled(float x, float y, float x1) } -void Fl_Android_Graphics_Driver::xyline_unclipped(float x, float y, float x1) +void Fl_Android_Graphics_Driver::xyline(int x, int y, int x1, int y2) +{ + xyline(x, y, x1); + yxline(x1, y, y2); +} + + +void Fl_Android_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) +{ + xyline(x, y, x1); + yxline(x1, y, y2); + xyline(x1, y2, x3); +} + + +void Fl_Android_Graphics_Driver::xyline_unclipped(int x, int y, int x1) { uint16_t cc = make565(color()); float w; @@ -165,7 +183,8 @@ void Fl_Android_Graphics_Driver::xyline_unclipped(float x, float y, float x1) } } -void Fl_Android_Graphics_Driver::yxline_unscaled(float x, float y, float y1) + +void Fl_Android_Graphics_Driver::yxline(int x, int y, int y1) { float h; if (y1>y) { @@ -180,7 +199,23 @@ void Fl_Android_Graphics_Driver::yxline_unscaled(float x, float y, float y1) } } -void Fl_Android_Graphics_Driver::yxline_unclipped(float x, float y, float y1) + +void Fl_Android_Graphics_Driver::yxline(int x, int y, int y1, int x2) +{ + yxline(x, y, y1); + xyline(x, y1, x2); +} + + +void Fl_Android_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) +{ + yxline(x, y, y1); + xyline(x, y1, x2); + yxline(x2, y1, y3); +} + + +void Fl_Android_Graphics_Driver::yxline_unclipped(int x, int y, int y1) { uint16_t cc = make565(color()); float h = y1-y; @@ -198,7 +233,7 @@ void Fl_Android_Graphics_Driver::yxline_unclipped(float x, float y, float y1) } -void Fl_Android_Graphics_Driver::rect_unscaled(float x, float y, float w, float h) +void Fl_Android_Graphics_Driver::rect(int x, int y, int w, int h) { xyline(x, y, x+w-1); yxline(x, y, y+h-1); @@ -207,14 +242,17 @@ void Fl_Android_Graphics_Driver::rect_unscaled(float x, float y, float w, float } -void Fl_Android_Graphics_Driver::line_style_unscaled(int style, float width, char* dashes) +void Fl_Android_Graphics_Driver::line_style(int style, int width, char* dashes) { pLineStyle = style; // TODO: finish this! } - -void Fl_Android_Graphics_Driver::point_unscaled(float x, float y) +/** + * Draw a single dot in the current color. + * @param x, y position relative to window. + */ +void Fl_Android_Graphics_Driver::point(int x, int y) { // drawing a single point is insanely inefficient because we need to walk the // entire clipping region every time to see if the point needs to be drawn. @@ -237,7 +275,7 @@ void Fl_Android_Graphics_Driver::point_unscaled(float x, float y) * FIXME: clipping maust be moved into this call and drawing to the screen should happen right here * FIXME: line width is not considered */ -void Fl_Android_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1) +void Fl_Android_Graphics_Driver::line(int x, int y, int x1, int y1) { if (x==x1) { return yxline(x, y, y1); @@ -261,7 +299,7 @@ void Fl_Android_Graphics_Driver::line_unscaled(float x, float y, float x1, float } int num = max/2; for (int i=max+1; i>0; i--) { - point_unscaled(x, y); + point(x, y); num += min; if (num>=max) { num -= max; @@ -275,54 +313,54 @@ void Fl_Android_Graphics_Driver::line_unscaled(float x, float y, float x1, float } -void Fl_Android_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1, float x2, float y2) +void Fl_Android_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) { begin_line(); - transformed_vertex0(x, y); - transformed_vertex0(x1, y1); - transformed_vertex0(x2, y2); + transformed_vertex(x, y); + transformed_vertex(x1, y1); + transformed_vertex(x2, y2); end_line(); } -void Fl_Android_Graphics_Driver::loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2) +void Fl_Android_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2) { begin_loop(); - transformed_vertex0(x0, y0); - transformed_vertex0(x1, y1); - transformed_vertex0(x2, y2); + transformed_vertex(x0, y0); + transformed_vertex(x1, y1); + transformed_vertex(x2, y2); end_loop(); } -void Fl_Android_Graphics_Driver::loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) +void Fl_Android_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { begin_loop(); - transformed_vertex0(x0, y0); - transformed_vertex0(x1, y1); - transformed_vertex0(x2, y2); - transformed_vertex0(x3, y3); + transformed_vertex(x0, y0); + transformed_vertex(x1, y1); + transformed_vertex(x2, y2); + transformed_vertex(x3, y3); end_loop(); } -void Fl_Android_Graphics_Driver::polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2) +void Fl_Android_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2) { begin_polygon(); - transformed_vertex0(x0, y0); - transformed_vertex0(x1, y1); - transformed_vertex0(x2, y2); + transformed_vertex(x0, y0); + transformed_vertex(x1, y1); + transformed_vertex(x2, y2); end_polygon(); } -void Fl_Android_Graphics_Driver::polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) +void Fl_Android_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { begin_polygon(); - transformed_vertex0(x0, y0); - transformed_vertex0(x1, y1); - transformed_vertex0(x2, y2); - transformed_vertex0(x3, y3); + transformed_vertex(x0, y0); + transformed_vertex(x1, y1); + transformed_vertex(x2, y2); + transformed_vertex(x3, y3); end_polygon(); } @@ -358,7 +396,7 @@ void Fl_Android_Graphics_Driver::add_vertex(float x, float y, bool gap) void Fl_Android_Graphics_Driver::begin_points() { begin_vertices(); - Fl_Scalable_Graphics_Driver::begin_points(); + super::begin_points(); } /** @@ -367,7 +405,7 @@ void Fl_Android_Graphics_Driver::begin_points() void Fl_Android_Graphics_Driver::begin_line() { begin_vertices(); - Fl_Scalable_Graphics_Driver::begin_line(); + super::begin_line(); } /** @@ -376,7 +414,7 @@ void Fl_Android_Graphics_Driver::begin_line() void Fl_Android_Graphics_Driver::begin_loop() { begin_vertices(); - Fl_Scalable_Graphics_Driver::begin_loop(); + super::begin_loop(); } /** @@ -385,7 +423,7 @@ void Fl_Android_Graphics_Driver::begin_loop() void Fl_Android_Graphics_Driver::begin_polygon() { begin_vertices(); - Fl_Scalable_Graphics_Driver::begin_polygon(); + super::begin_polygon(); } /** @@ -394,7 +432,7 @@ void Fl_Android_Graphics_Driver::begin_polygon() void Fl_Android_Graphics_Driver::begin_complex_polygon() { begin_vertices(); - Fl_Scalable_Graphics_Driver::begin_complex_polygon(); + super::begin_complex_polygon(); } /** @@ -405,7 +443,7 @@ void Fl_Android_Graphics_Driver::end_points() for (int i=0; i<pnVertex; ++i) { Vertex &v = pVertex[i]; if (!v.pIsGap) - point_unscaled(v.pX, v.pY); + point(v.pX, v.pY); } } @@ -418,7 +456,7 @@ void Fl_Android_Graphics_Driver::end_line() for (int i=1; i<pnVertex; ++i) { Vertex &v2 = pVertex[i]; if (!v1.pIsGap && !v2.pIsGap) - line_unscaled(v1.pX, v1.pY, v2.pX, v2.pY); + line(v1.pX, v1.pY, v2.pX, v2.pY); v1 = v2; } } @@ -433,7 +471,7 @@ void Fl_Android_Graphics_Driver::end_loop() for (int i=1; i<pnVertex; ++i) { Vertex &v2 = pVertex[i]; if (!v1.pIsGap) - line_unscaled(v1.pX, v1.pY, v2.pX, v2.pY); + line(v1.pX, v1.pY, v2.pX, v2.pY); v1 = v2; } } @@ -501,7 +539,7 @@ void Fl_Android_Graphics_Driver::end_polygon(int begin, int end) if (nodeX[i + 1] > xMin) { if (nodeX[i] < xMin) nodeX[i] = xMin; if (nodeX[i + 1] > xMax) nodeX[i + 1] = xMax; - xyline_unscaled(nodeX[i], pixelY, nodeX[i + 1]); + xyline(nodeX[i], pixelY, nodeX[i + 1]); } } } @@ -595,7 +633,7 @@ void Fl_Android_Graphics_Driver::end_complex_polygon() if (nodeX[i + 1] > xMin) { if (nodeX[i] < xMin) nodeX[i] = xMin; if (nodeX[i + 1] > xMax) nodeX[i + 1] = xMax; - xyline_unscaled(nodeX[i], pixelY, nodeX[i + 1]); + xyline(nodeX[i], pixelY, nodeX[i + 1]); } } } @@ -620,12 +658,18 @@ void Fl_Android_Graphics_Driver::gap() * Add a vertex to the list. * TODO: we should maintain a bounding box for faster clipping. */ -void Fl_Android_Graphics_Driver::transformed_vertex0(float x, float y) +void Fl_Android_Graphics_Driver::transformed_vertex(double x, double y) { add_vertex(x, y); } +void Fl_Android_Graphics_Driver::vertex(double x,double y) +{ + transformed_vertex(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y); +} + + /** * Draw an arc. * @param xi @@ -636,7 +680,7 @@ void Fl_Android_Graphics_Driver::transformed_vertex0(float x, float y) * @param a2 * FIXME: float-to-int interpolation is horrible! */ -void Fl_Android_Graphics_Driver::arc_unscaled(float xi, float yi, float w, float h, double a1, double a2) +void Fl_Android_Graphics_Driver::arc(int xi, int yi, int w, int h, double a1, double a2) { if (a2<=a1) return; @@ -660,7 +704,7 @@ void Fl_Android_Graphics_Driver::arc_unscaled(float xi, float yi, float w, float px = nx; py = ny; nx = x + cos(a1)*rx; ny = y - sin(a1)*ry; - line_unscaled(px, py, nx, ny); + line(px, py, nx, ny); } } @@ -674,7 +718,7 @@ void Fl_Android_Graphics_Driver::arc_unscaled(float xi, float yi, float w, float * @param b1 * @param b2 */ -void Fl_Android_Graphics_Driver::pie_unscaled(float xi, float yi, float w, float h, double b1, double b2) +void Fl_Android_Graphics_Driver::pie(int xi, int yi, int w, int h, double b1, double b2) { // quick access to bounding box size double rx = w / 2.0; @@ -750,21 +794,21 @@ void Fl_Android_Graphics_Driver::pie_unscaled(float xi, float yi, float w, float if (loInside && hiInside && !flipped) { // fl_color(FL_GREEN); if (a1 < aL) - xyline_unscaled(x + hiLeft, iy, x + loRight); + xyline(x + hiLeft, iy, x + loRight); } else { if ((!loInside) && (!hiInside)) { // fl_color(FL_MAGENTA); if ( (b1o<=0.0 && b2>=90.0) || (b1o<=(0.0-360.0) && b2>=(90.0-360.0)) ) - xyline_unscaled(x - sinALrx, iy, x); + xyline(x - sinALrx, iy, x); } else { if (loInside) { // fl_color(FL_BLUE); if (a1 < aL) - xyline_unscaled(x + loLeft, iy, x + loRight); + xyline(x + loLeft, iy, x + loRight); } if (hiInside) { // fl_color(FL_YELLOW); - xyline_unscaled(x + hiLeft, iy, x); + xyline(x + hiLeft, iy, x); } } } @@ -788,21 +832,21 @@ void Fl_Android_Graphics_Driver::pie_unscaled(float xi, float yi, float w, float if (loInside && hiInside && !flipped) { // fl_color(FL_GREEN); if (a2 > aL) - xyline_unscaled(x + loLeft, iy, x + hiRight); + xyline(x + loLeft, iy, x + hiRight); } else { if ((!loInside) && (!hiInside)) { // fl_color(FL_MAGENTA); if ( (b1o<=90.0 && b2>=180.0) || (b1o<=(90.0-360.0) && b2>=(180.0-360.0)) ) - xyline_unscaled(x - sinALrx, iy, x); + xyline(x - sinALrx, iy, x); } else { if (loInside) { // fl_color(FL_BLUE); - xyline_unscaled(x + loLeft, iy, x); + xyline(x + loLeft, iy, x); } if (hiInside) { // fl_color(FL_YELLOW); if (a2 > aL) - xyline_unscaled(x + hiLeft, iy, x + hiRight); + xyline(x + hiLeft, iy, x + hiRight); } } } @@ -827,21 +871,21 @@ void Fl_Android_Graphics_Driver::pie_unscaled(float xi, float yi, float w, float if (loInside && hiInside && !flipped) { // fl_color(FL_GREEN); if (a1 < aR) - xyline_unscaled(x + hiLeft, iy, x + loRight); + xyline(x + hiLeft, iy, x + loRight); } else { if ((!loInside) && (!hiInside)) { // fl_color(FL_MAGENTA); if ( (b1o<=180.0 && b2>=270.0) || (b1o<=(180.0-360.0) && b2>=(270.0-360.0)) ) - xyline_unscaled(x + sinALrx, iy, x); + xyline(x + sinALrx, iy, x); } else { if (loInside) { // fl_color(FL_BLUE); if (a1 < aR) - xyline_unscaled(x + loLeft, iy, x + loRight); + xyline(x + loLeft, iy, x + loRight); } if (hiInside) { // fl_color(FL_YELLOW); - xyline_unscaled(x + hiLeft, iy, x); + xyline(x + hiLeft, iy, x); } } } @@ -865,21 +909,21 @@ void Fl_Android_Graphics_Driver::pie_unscaled(float xi, float yi, float w, float if (loInside && hiInside && !flipped) { // fl_color(FL_GREEN); if (a2 > aR) - xyline_unscaled(x + loLeft, iy, x + hiRight); + xyline(x + loLeft, iy, x + hiRight); } else { if ((!loInside) && (!hiInside)) { // fl_color(FL_MAGENTA); if ( (b1o<=270.0 && b2>=360.0) || (b1o<=(270.0-360.0) && b2>=(360.0-360.0)) ) - xyline_unscaled(x + sinALrx, iy, x); + xyline(x + sinALrx, iy, x); } else { if (loInside) { // fl_color(FL_BLUE); - xyline_unscaled(x + loLeft, iy, x); + xyline(x + loLeft, iy, x); } if (hiInside) { // fl_color(FL_YELLOW); if (a2 > aR) - xyline_unscaled(x + hiLeft, iy, x + hiRight); + xyline(x + hiLeft, iy, x + hiRight); } } } @@ -888,23 +932,34 @@ void Fl_Android_Graphics_Driver::pie_unscaled(float xi, float yi, float w, float } /** - * shortcut the closed circles so they use XDrawArc: * FIXME: these do not draw rotated ellipses correctly! + * FIXME: use floating point version of arc and pie?! * */ -void Fl_Android_Graphics_Driver::ellipse_unscaled(double xt, double yt, double rx, double ry) { - float llx = xt-rx; - float w = xt+rx-llx; - float lly = yt-ry; - float h = yt+ry-lly; +void Fl_Android_Graphics_Driver::ellipse(double xt, double yt, double rx, double ry) +{ + int llx = xt-rx; + int w = xt+rx-llx; + int lly = yt-ry; + int h = yt+ry-lly; if (what==POLYGON) - pie_unscaled(llx, lly, w, h, 0.0, 360.0); + pie(llx, lly, w, h, 0.0, 360.0); else - arc_unscaled(llx, lly, w, h, 0.0, 360.0); + arc(llx, lly, w, h, 0.0, 360.0); +} + + +void Fl_Android_Graphics_Driver::circle(double x, double y, double r) +{ + double xt = transform_x(x,y); + double yt = transform_y(x,y); + double rx = r * (m.c ? sqrt(m.a*m.a+m.c*m.c) : fabs(m.a)); + double ry = r * (m.b ? sqrt(m.b*m.b+m.d*m.d) : fabs(m.d)); + ellipse(xt, yt, rx, ry); } -void Fl_Android_Graphics_Driver::draw_unscaled(Fl_Bitmap *bm, float s, int XP, int YP, int WP, int HP, int cx, int cy) +void Fl_Android_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) { int X, Y, W, H; if (Fl_Graphics_Driver::prepare(bm, XP, YP, WP, HP, cx, cy, X, Y, W, H)) { @@ -928,7 +983,7 @@ fl_uintptr_t Fl_Android_Graphics_Driver::cache(Fl_Bitmap *bm) for (int yy=0; yy<w; yy++) { const uchar *src = bm->array + yy*rowBytes; uchar *dst = cache->pBytes + yy*cache->pStride; - uchar d; + uchar d = 0; for (int xx=0; xx<w; xx++) { if ((xx&7)==0) d = *src++; if (d&1) *dst = 0xff; else *dst = 0; diff --git a/src/drivers/Android/Fl_Android_Graphics_Font.cxx b/src/drivers/Android/Fl_Android_Graphics_Font.cxx index 21a7c1fe2..d536c0ded 100644 --- a/src/drivers/Android/Fl_Android_Graphics_Font.cxx +++ b/src/drivers/Android/Fl_Android_Graphics_Font.cxx @@ -420,7 +420,7 @@ Fl_Android_Font_Descriptor* Fl_Android_Font_Descriptor::find(Fl_Font fnum, Fl_Fo * @param fnum index into fl_fonts * @param size height in pixels */ -void Fl_Android_Graphics_Driver::font_unscaled(Fl_Font fnum, Fl_Fontsize size) { +void Fl_Android_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) { font_descriptor( Fl_Android_Font_Descriptor::find(fnum, size) ); size_ = size; font_ = fnum; @@ -520,11 +520,11 @@ int Fl_Android_Graphics_Driver::render_letter(int xx, int yy, uint32_t c, Fl_Rec * @param n number of bytes to render * @param x, y position on screen */ -void Fl_Android_Graphics_Driver::draw_unscaled(const char* str, int n, int x, int y) +void Fl_Android_Graphics_Driver::draw(const char* str, int n, int x, int y) { if (str) { int dx, dy, w, h; - text_extents_unscaled(str, n, dx, dy, w, h); + text_extents(str, n, dx, dy, w, h); //pClippingRegion.print("<---- clip text to this"); //Fl_Rect_Region(x+dx, y+dy, w, h).print(str); for (const auto &it: pClippingRegion.overlapping(Fl_Rect_Region(x+dx, y+dy, w, h))) { @@ -551,7 +551,7 @@ void Fl_Android_Graphics_Driver::draw_unscaled(const char* str, int n, int x, in } -double Fl_Android_Graphics_Driver::width_unscaled(const char *str, int n) +double Fl_Android_Graphics_Driver::width(const char *str, int n) { Fl_Android_Font_Descriptor *fd = (Fl_Android_Font_Descriptor*)font_descriptor(); if (!fd) return 0; @@ -568,7 +568,7 @@ double Fl_Android_Graphics_Driver::width_unscaled(const char *str, int n) } -double Fl_Android_Graphics_Driver::width_unscaled(unsigned int uniChar) +double Fl_Android_Graphics_Driver::width(unsigned int uniChar) { Fl_Android_Font_Descriptor *fd = (Fl_Android_Font_Descriptor*)font_descriptor(); if (!fd) return 0; @@ -576,24 +576,26 @@ double Fl_Android_Graphics_Driver::width_unscaled(unsigned int uniChar) } -Fl_Fontsize Fl_Android_Graphics_Driver::size_unscaled() +Fl_Fontsize Fl_Android_Graphics_Driver::size() { Fl_Android_Font_Descriptor *fd = (Fl_Android_Font_Descriptor*)font_descriptor(); if (!fd) return 0; return fd->size; } - -void Fl_Android_Graphics_Driver::text_extents_unscaled(const char *str, int n, int &dx, int &dy, int &w, int &h) +/** + * FIXME: use the actual size of all glyphs, which is easily found in the Bytemap! + */ +void Fl_Android_Graphics_Driver::text_extents(const char *str, int n, int &dx, int &dy, int &w, int &h) { - w = width_unscaled(str, n); - h = height_unscaled(); + w = width(str, n); + h = height(); dx = 0; - dy = descent_unscaled() - h; + dy = descent() - h; } -int Fl_Android_Graphics_Driver::height_unscaled() +int Fl_Android_Graphics_Driver::height() { // This should really be "ascent - descent + lineGap" Fl_Android_Font_Descriptor *fd = (Fl_Android_Font_Descriptor*)font_descriptor(); @@ -602,7 +604,7 @@ int Fl_Android_Graphics_Driver::height_unscaled() } -int Fl_Android_Graphics_Driver::descent_unscaled() +int Fl_Android_Graphics_Driver::descent() { Fl_Android_Font_Descriptor *fd = (Fl_Android_Font_Descriptor*)font_descriptor(); if (!fd) return 0; |
