summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-12-28 12:02:23 +0000
committerManolo Gouy <Manolo>2010-12-28 12:02:23 +0000
commitb431c1e0e7cec74dfe55d558a42a0f162079b0c1 (patch)
treecfda391b077654629ea20a6edbde5590e45c09e9
parentf3e04b8b87a7acd6a46486bd21258d4bf3a6b06d (diff)
Use device abstraction for font and text drawing.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8126 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Device.H23
-rw-r--r--src/fl_font.cxx2
-rw-r--r--src/fl_font_mac.cxx8
-rw-r--r--src/fl_font_win32.cxx8
-rw-r--r--src/fl_font_x.cxx14
-rw-r--r--src/fl_font_xft.cxx12
6 files changed, 34 insertions, 33 deletions
diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H
index 38a7f9500..32a480857 100644
--- a/FL/Fl_Device.H
+++ b/FL/Fl_Device.H
@@ -122,9 +122,6 @@ protected:
friend void fl_line(int x, int y, int x1, int y1);
friend void fl_line(int x, int y, int x1, int y1, int x2, int y2);
friend void fl_draw(const char *str, int n, int x, int y);
-#ifdef __APPLE__
- friend void fl_draw(const char *str, int n, float x, float y);
-#endif
friend void fl_draw(int angle, const char *str, int n, int x, int y);
friend void fl_rtl_draw(const char *str, int n, int x, int y);
friend void fl_font(Fl_Font face, Fl_Fontsize size);
@@ -188,13 +185,13 @@ protected:
/** \brief see fl_line(int x, int y, int x1, int y1, int x2, int y2). */
virtual void line(int x, int y, int x1, int y1, int x2, int y2);
/** \brief see fl_draw(const char *str, int n, int x, int y). */
- virtual void draw(const char *str, int n, int x, int y);
+ virtual void draw(const char *str, int n, int x, int y) {};
/** \brief 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);
+ virtual void draw(int angle, const char *str, int n, int x, int y) {};
/** \brief 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);
+ virtual void rtl_draw(const char *str, int n, int x, int y) {};
/** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
- virtual void font(Fl_Font face, Fl_Fontsize size);
+ virtual void font(Fl_Font face, Fl_Fontsize size) {};
/** \brief see fl_color(Fl_Color c). */
virtual void color(Fl_Color c);
/** \brief see fl_color(uchar r, uchar g, uchar b). */
@@ -301,6 +298,10 @@ public:
/** \brief The constructor. */
Fl_Quartz_Graphics_Driver() { type_ = device_type; };
static const char *device_type;
+ void draw(const char* str, int n, int x, int y);
+ void draw(int angle, const char *str, int n, int x, int y);
+ void rtl_draw(const char* str, int n, int x, int y);
+ void font(Fl_Font face, Fl_Fontsize size);
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
@@ -317,6 +318,10 @@ public:
/** \brief The constructor. */
Fl_GDI_Graphics_Driver() { type_ = device_type; };
static const char *device_type;
+ void draw(const char* str, int n, int x, int y);
+ void draw(int angle, const char *str, int n, int x, int y);
+ void rtl_draw(const char* str, int n, int x, int y);
+ void font(Fl_Font face, Fl_Fontsize size);
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
@@ -333,6 +338,10 @@ public:
/** \brief The constructor. */
Fl_Xlib_Graphics_Driver() { type_ = device_type; };
static const char *device_type;
+ void draw(const char* str, int n, int x, int y);
+ void draw(int angle, const char *str, int n, int x, int y);
+ void rtl_draw(const char* str, int n, int x, int y);
+ void font(Fl_Font face, Fl_Fontsize size);
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
diff --git a/src/fl_font.cxx b/src/fl_font.cxx
index 91f5ea54e..2a6833adf 100644
--- a/src/fl_font.cxx
+++ b/src/fl_font.cxx
@@ -81,7 +81,7 @@ void fl_text_extents(const char *c, int &dx, int &dy, int &w, int &h) {
} // fl_text_extents
-#if !USE_XFT && !__APPLE__
+#ifndef __APPLE__
void fl_draw(const char* str, int l, float x, float y) {
fl_draw(str, l, (int)x, (int)y);
}
diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx
index b5749f0dd..414dc7a84 100644
--- a/src/fl_font_mac.cxx
+++ b/src/fl_font_mac.cxx
@@ -237,7 +237,7 @@ Fl_Font fl_font_ = 0;
Fl_Fontsize fl_size_ = 0;
-void Fl_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
+void Fl_Quartz_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
if (fnum==-1) {
fl_font_ = 0;
fl_size_ = 0;
@@ -400,7 +400,7 @@ void fl_text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h) {
void fl_draw(const char *str, int n, float x, float y);
-void Fl_Graphics_Driver::draw(const char* str, int n, int x, int y) {
+void Fl_Quartz_Graphics_Driver::draw(const char* str, int n, int x, int y) {
fl_draw(str, n, (float)x-0.0f, (float)y+0.5f);
}
@@ -476,7 +476,7 @@ void fl_draw(const char *str, int n, float x, float y) {
#endif
}
-void Fl_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
+void Fl_Quartz_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
CGContextSaveGState(fl_gc);
CGContextTranslateCTM(fl_gc, x, y);
CGContextRotateCTM(fl_gc, - angle*(M_PI/180) );
@@ -484,7 +484,7 @@ void Fl_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
CGContextRestoreGState(fl_gc);
}
-void Fl_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
+void Fl_Quartz_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
draw(c, n, int(x - fl_width(c, n)), y);
}
diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx
index f1f545bb8..285ff8bad 100644
--- a/src/fl_font_win32.cxx
+++ b/src/fl_font_win32.cxx
@@ -146,7 +146,7 @@ void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
fl_fontsize = find(fnum, size, angle);
}
-void Fl_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
+void Fl_GDI_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
fl_font(fnum, size, 0);
}
@@ -334,7 +334,7 @@ exit_error:
return;
} // fl_text_extents
-void Fl_Graphics_Driver::draw(const char* str, int n, int x, int y) {
+void Fl_GDI_Graphics_Driver::draw(const char* str, int n, int x, int y) {
int i = 0;
int lx = 0;
char *end = (char *)&str[n];
@@ -362,7 +362,7 @@ void Fl_Graphics_Driver::draw(const char* str, int n, int x, int y) {
SetTextColor(fl_gc, oldColor);
}
-void Fl_Graphics_Driver::draw(int angle, const char* str, int n, int x, int y) {
+void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, int y) {
fl_font(fl_font_, fl_size_, angle);
// fl_draw(str, n, (int)x, (int)y);
int i = 0, i2=0;
@@ -386,7 +386,7 @@ void Fl_Graphics_Driver::draw(int angle, const char* str, int n, int x, int y) {
fl_font(fl_font_, fl_size_);
}
-void Fl_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
+void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
int wn;
int i = 0;
int lx = 0;
diff --git a/src/fl_font_x.cxx b/src/fl_font_x.cxx
index 8ac870d79..247770ede 100644
--- a/src/fl_font_x.cxx
+++ b/src/fl_font_x.cxx
@@ -269,7 +269,7 @@ XFontStruct* Fl_XFont_On_Demand::value() {
return ptr;
}
-void Fl_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
+void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
if (fnum==-1) {
fl_font_ = 0; fl_size_ = 0;
return;
@@ -318,24 +318,20 @@ void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
} // fl_text_extents
-void Fl_Graphics_Driver::draw(const char* c, int n, int x, int y) {
+void Fl_Xlib_Graphics_Driver::draw(const char* c, int n, int x, int y) {
if (font_gc != fl_gc) {
if (!current_font) fl_font(FL_HELVETICA, 14);
font_gc = fl_gc;
XSetFont(fl_display, fl_gc, current_font->fid);
}
-// XDrawString(fl_display, fl_window, fl_gc, x, y, c, n);
XUtf8DrawString(fl_display, fl_window, current_font, fl_gc, x, y, c, n);
}
-void Fl_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
- fprintf(stderr,"ROTATING TEXT NOT IMPLIMENTED\n");
+void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
+ fprintf(stderr,"ROTATING TEXT NOT IMPLEMENTED\n");
fl_draw(str, n, (int)x, (int)y);
}
-//void fl_draw(const char* str, int n, float x, float y) {
-// fl_draw(str, n, (int)x, (int)y);
-//}
-void Fl_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
+void Fl_Xlib_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
if (font_gc != fl_gc) {
if (!current_font) fl_font(FL_HELVETICA, 12);
font_gc = fl_gc;
diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx
index f6cebde0b..f0f0aece6 100644
--- a/src/fl_font_xft.cxx
+++ b/src/fl_font_xft.cxx
@@ -152,7 +152,7 @@ void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
fl_xftfont = (void*)f->font;
}
-void Fl_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
+void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
fl_font(fnum,size,0);
}
@@ -552,7 +552,7 @@ void fl_destroy_xft_draw(Window id) {
#endif
}
-void Fl_Graphics_Driver::draw(const char *str, int n, int x, int y) {
+void Fl_Xlib_Graphics_Driver::draw(const char *str, int n, int x, int y) {
if ( !current_font ) {
fl_font(FL_HELVETICA, 14);
}
@@ -589,16 +589,12 @@ void Fl_Graphics_Driver::draw(const char *str, int n, int x, int y) {
XftDrawStringUtf8(draw_, &color, current_font, x, y, (XftChar8 *)str, n);
}
-void Fl_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
+void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) {
fl_font(fl_font_, fl_size_, angle);
fl_draw(str, n, (int)x, (int)y);
fl_font(fl_font_, fl_size_);
}
-void fl_draw(const char* str, int n, float x, float y) {
- fl_draw(str, n, (int)x, (int)y);
-}
-
static void fl_drawUCS4(const FcChar32 *str, int n, int x, int y) {
#if USE_OVERLAY
XftDraw*& draw_ = fl_overlay ? draw_overlay : ::draw_;
@@ -634,7 +630,7 @@ static void fl_drawUCS4(const FcChar32 *str, int n, int x, int y) {
}
-void Fl_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
+void Fl_Xlib_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
#if defined(__GNUC__)
// FIXME: warning Need to improve this XFT right to left draw function