diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Copy_Surface.cxx | 89 | ||||
| -rw-r--r-- | src/Fl_Double_Window.cxx | 48 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx | 8 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx | 3 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx | 9 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx | 14 |
6 files changed, 88 insertions, 83 deletions
diff --git a/src/Fl_Copy_Surface.cxx b/src/Fl_Copy_Surface.cxx index 344ca5fc3..12eb0bcf7 100644 --- a/src/Fl_Copy_Surface.cxx +++ b/src/Fl_Copy_Surface.cxx @@ -57,7 +57,7 @@ void Fl_GDI_Surface_::untranslate() { if (depth > 0) depth--; SetWindowOrgEx(fl_gc, origins[depth].x, origins[depth].y, NULL); } - + const char *Fl_GDI_Surface_::class_id = "Fl_GDI_Surface_"; #endif @@ -65,7 +65,7 @@ const char *Fl_GDI_Surface_::class_id = "Fl_GDI_Surface_"; const char *Fl_Copy_Surface::class_id = "Fl_Copy_Surface"; -/** Constructor. +/** Constructor. \param w and \param h are the width and height of the clipboard surface in pixels where drawing will occur. */ @@ -91,13 +91,13 @@ Fl_Copy_Surface::Fl_Copy_Surface(int w, int h) : Fl_Surface_Device(NULL) ReleaseDC(NULL, hdc); float factorw = (100.f * hmm) / hdots; float factorh = (100.f * vmm) / vdots; - + RECT rect; rect.left = 0; rect.top = 0; rect.right = (LONG)(w * factorw); rect.bottom = (LONG)(h * factorh); gc = CreateEnhMetaFile (NULL, NULL, &rect, NULL); if (gc != NULL) { SetTextAlign(gc, TA_BASELINE|TA_LEFT); SetBkMode(gc, TRANSPARENT); - } + } #elif defined(FL_PORTING) # pragma message "FL_PORTING: initialize members of Fl_Copy_Surface" #else // Xlib @@ -139,9 +139,9 @@ Fl_Copy_Surface::~Fl_Copy_Surface() #elif defined(FL_PORTING) # pragma message "FL_PORTING: free resources in destructor of Fl_Copy_Surface" #else // Xlib - fl_pop_clip(); + fl_pop_clip(); unsigned char *data = fl_read_image(NULL,0,0,width,height,0); - fl_window = oldwindow; + fl_window = oldwindow; _ss->set_current(); Fl::copy_image(data,width,height,1); delete[] data; @@ -151,12 +151,12 @@ Fl_Copy_Surface::~Fl_Copy_Surface() } /** Copies a widget in the clipboard - + \param widget any FLTK widget (e.g., standard, custom, window, GL view) to copy - \param delta_x and \param delta_y give + \param delta_x and \param delta_y give the position in the clipboard of the top-left corner of the widget */ -void Fl_Copy_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y) +void Fl_Copy_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y) { helper->print_widget(widget, delta_x, delta_y); } @@ -170,8 +170,8 @@ void Fl_Copy_Surface::set_current() #elif defined(FL_PORTING) # pragma message "FL_PORTING: implement Fl_Copy_Surface::set_current" #else - fl_window=xid; - _ss = Fl_Surface_Device::surface(); + fl_window=xid; + _ss = Fl_Surface_Device::surface(); Fl_Surface_Device::set_current(); fl_push_no_clip(); #endif @@ -188,14 +188,14 @@ size_t Fl_Copy_Surface::MyPutBytes(void* info, const void* buffer, size_t count) void Fl_Copy_Surface::init_PDF_context(int w, int h) { - CGRect bounds = CGRectMake(0, 0, w, h ); + CGRect bounds = CGRectMake(0, 0, w, h ); pdfdata = CFDataCreateMutable(NULL, 0); CGDataConsumerRef myconsumer; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 if (&CGDataConsumerCreateWithCFData != NULL) { myconsumer = CGDataConsumerCreateWithCFData(pdfdata); // 10.4 } - else + else #endif { static CGDataConsumerCallbacks callbacks = { Fl_Copy_Surface::MyPutBytes, NULL }; @@ -209,7 +209,7 @@ void Fl_Copy_Surface::prepare_copy_pdf_and_tiff(int w, int h) { init_PDF_context(w, h); if (gc == NULL) return; - CGRect bounds = CGRectMake(0, 0, w, h ); + CGRect bounds = CGRectMake(0, 0, w, h ); CGContextBeginPage (gc, &bounds); CGContextTranslateCTM(gc, 0, h); CGContextScaleCTM(gc, 1.0f, -1.0f); @@ -219,7 +219,7 @@ void Fl_Copy_Surface::prepare_copy_pdf_and_tiff(int w, int h) #endif // __APPLE__ -/** Copies a window and its borders and title bar to the clipboard. +/** Copies a window and its borders and title bar to the clipboard. \param win an FLTK window to copy \param delta_x and \param delta_y give the position in the clipboard of the top-left corner of the window's title bar @@ -234,6 +234,9 @@ void Fl_Copy_Surface::draw_decorated_window(Fl_Window* win, int delta_x, int del #elif defined(FL_PORTING) # pragma message "FL_PORTING: do you need a helper class for your graphics driver" #elif !defined(FL_DOXYGEN) + +#include "drivers/Xlib/Fl_Xlib_Graphics_Driver.h" + /* graphics driver that translates all graphics coordinates before calling Xlib */ class Fl_translated_Xlib_Graphics_Driver_ : public Fl_Xlib_Graphics_Driver { int offset_x, offset_y; // translation between user and graphical coordinates: graphical = user + offset @@ -273,65 +276,65 @@ public: void yxline(int x, int y, int y1, int x2, int y3) { Fl_Xlib_Graphics_Driver::yxline(x+offset_x, y+offset_y, y1+offset_y, x2+offset_x, y3+offset_y); } void line(int x, int y, int x1, int y1) { Fl_Xlib_Graphics_Driver::line(x+offset_x, y+offset_y, x1+offset_x, y1+offset_y); } void line(int x, int y, int x1, int y1, int x2, int y2) { Fl_Xlib_Graphics_Driver::line(x+offset_x, y+offset_y, x1+offset_x, y1+offset_y, x2+offset_x, y2+offset_y); } - void draw(const char* str, int n, int x, int y) { - Fl_Xlib_Graphics_Driver::draw(str, n, x+offset_x, y+offset_y); + void draw(const char* str, int n, int x, int y) { + Fl_Xlib_Graphics_Driver::draw(str, n, x+offset_x, y+offset_y); } - void draw(int angle, const char *str, int n, int x, int y) { - Fl_Xlib_Graphics_Driver::draw(angle, str, n, x+offset_x, y+offset_y); + void draw(int angle, const char *str, int n, int x, int y) { + Fl_Xlib_Graphics_Driver::draw(angle, str, n, x+offset_x, y+offset_y); } - void rtl_draw(const char* str, int n, int x, int y) { - Fl_Xlib_Graphics_Driver::rtl_draw(str, n, x+offset_x, y+offset_y); + void rtl_draw(const char* str, int n, int x, int y) { + Fl_Xlib_Graphics_Driver::rtl_draw(str, n, x+offset_x, y+offset_y); } - void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { + void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) { XP += offset_x; YP += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw(pxm, XP, YP, WP,HP,cx,cy); + Fl_Xlib_Graphics_Driver::draw(pxm, XP, YP, WP,HP,cx,cy); untranslate_all(); } - void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) { + void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) { XP += offset_x; YP += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw(bm, XP, YP, WP,HP,cx,cy); + Fl_Xlib_Graphics_Driver::draw(bm, XP, YP, WP,HP,cx,cy); untranslate_all(); } - void draw(Fl_RGB_Image *img, 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) { XP += offset_x; YP += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw(img, XP, YP, WP,HP,cx,cy); + Fl_Xlib_Graphics_Driver::draw(img, XP, YP, WP,HP,cx,cy); untranslate_all(); } - void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) { + void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) { X += offset_x; Y += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw_image(buf, X, Y, W,H,D,L); + Fl_Xlib_Graphics_Driver::draw_image(buf, X, Y, W,H,D,L); untranslate_all(); } - void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) { + void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) { X += offset_x; Y += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw_image(cb, data, X, Y, W,H,D); + Fl_Xlib_Graphics_Driver::draw_image(cb, data, X, Y, W,H,D); untranslate_all(); } - void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) { + void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) { X += offset_x; Y += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw_image_mono(buf, X, Y, W,H,D,L); + Fl_Xlib_Graphics_Driver::draw_image_mono(buf, X, Y, W,H,D,L); untranslate_all(); } - void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) { + void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) { X += offset_x; Y += offset_y; translate_all(-offset_x, -offset_y); - Fl_Xlib_Graphics_Driver::draw_image_mono(cb, data, X, Y, W,H,D); + Fl_Xlib_Graphics_Driver::draw_image_mono(cb, data, X, Y, W,H,D); untranslate_all(); } - void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { - Fl_Xlib_Graphics_Driver::copy_offscreen(x+offset_x, y+offset_y, w, h,pixmap,srcx,srcy); + void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + Fl_Xlib_Graphics_Driver::copy_offscreen(x+offset_x, y+offset_y, w, h,pixmap,srcx,srcy); } void push_clip(int x, int y, int w, int h) { - Fl_Xlib_Graphics_Driver::push_clip(x+offset_x, y+offset_y, w, h); + Fl_Xlib_Graphics_Driver::push_clip(x+offset_x, y+offset_y, w, h); } int not_clipped(int x, int y, int w, int h) { return Fl_Xlib_Graphics_Driver::not_clipped(x + offset_x, y + offset_y, w, h); }; - int clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H) { + int clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H) { int retval = Fl_Xlib_Graphics_Driver::clip_box(x + offset_x, y + offset_y, w,h,X,Y,W,H); X -= offset_x; Y -= offset_y; @@ -352,11 +355,11 @@ public: const char *Fl_translated_Xlib_Graphics_Driver_::class_id = "Fl_translated_Xlib_Graphics_Driver_"; -void Fl_Xlib_Surface_::translate(int x, int y) { - ((Fl_translated_Xlib_Graphics_Driver_*)driver())->translate_all(x, y); +void Fl_Xlib_Surface_::translate(int x, int y) { + ((Fl_translated_Xlib_Graphics_Driver_*)driver())->translate_all(x, y); } -void Fl_Xlib_Surface_::untranslate() { - ((Fl_translated_Xlib_Graphics_Driver_*)driver())->untranslate_all(); +void Fl_Xlib_Surface_::untranslate() { + ((Fl_translated_Xlib_Graphics_Driver_*)driver())->untranslate_all(); } Fl_Xlib_Surface_::Fl_Xlib_Surface_() : Fl_Paged_Device() { diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index 5a8a42599..dae43a40d 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -60,18 +60,18 @@ static int can_xdbe() { #endif -Fl_Double_Window::Fl_Double_Window(int W, int H, const char *l) -: Fl_Window(W,H,l), - force_doublebuffering_(0) -{ - type(FL_DOUBLE_WINDOW); +Fl_Double_Window::Fl_Double_Window(int W, int H, const char *l) +: Fl_Window(W,H,l), + force_doublebuffering_(0) +{ + type(FL_DOUBLE_WINDOW); } Fl_Double_Window::Fl_Double_Window(int X, int Y, int W, int H, const char *l) -: Fl_Window(X,Y,W,H,l), - force_doublebuffering_(0) -{ +: Fl_Window(X,Y,W,H,l), + force_doublebuffering_(0) +{ type(FL_DOUBLE_WINDOW); } @@ -107,6 +107,8 @@ void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen #if defined(USE_X11) +#include "drivers/Xlib/Fl_Xlib_Graphics_Driver.h" + #if HAVE_XRENDER #include <X11/extensions/Xrender.h> #endif @@ -248,7 +250,7 @@ char fl_can_do_alpha_blending() { @{ */ -/** +/** Creation of an offscreen graphics buffer. \param w,h width and height in pixels of the buffer. \return the created graphics buffer. @@ -312,12 +314,12 @@ static Fl_Surface_Device *_ss; \param ctx the offscreen buffer. */ void fl_begin_offscreen(Fl_Offscreen ctx) { - _ss = Fl_Surface_Device::surface(); + _ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); if (stack_ix<stack_max) { stack_gc[stack_ix] = fl_gc; stack_window[stack_ix] = fl_window; - } else + } else fprintf(stderr, "FLTK CGContext Stack overflow error\n"); stack_ix++; @@ -433,7 +435,7 @@ void Fl_Double_Window::flush(int eraseoverlay) { #elif defined(__APPLE__) if ( myi->other_xid ) { fl_begin_offscreen( myi->other_xid ); - fl_clip_region( 0 ); + fl_clip_region( 0 ); draw(); fl_end_offscreen(); } else { @@ -498,23 +500,23 @@ Fl_Double_Window::~Fl_Double_Window() { Fl_Overlay_Window::Fl_Overlay_Window(int W, int H, const char *l) -: Fl_Double_Window(W,H,l) +: Fl_Double_Window(W,H,l) { - overlay_ = 0; - force_doublebuffering_=1; - image(0); + overlay_ = 0; + force_doublebuffering_=1; + image(0); } - - + + Fl_Overlay_Window::Fl_Overlay_Window(int X, int Y, int W, int H, const char *l) -: Fl_Double_Window(X,Y,W,H,l) +: Fl_Double_Window(X,Y,W,H,l) { - overlay_ = 0; - force_doublebuffering_=1; - image(0); + overlay_ = 0; + force_doublebuffering_=1; + image(0); } - + // // End of "$Id$". // diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx index 429e6fc7e..8bc9bfc66 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx @@ -16,12 +16,8 @@ // http://www.fltk.org/str.php // -#ifndef FL_CFG_GFX_XLIB_ARCI_CXX -#define FL_CFG_GFX_XLIB_ARCI_CXX - +#include "Fl_Xlib_Graphics_Driver.h" #include <FL/fl_draw.H> -#include <config.h> -#include "../../config_lib.h" /** \file xlib_arci.cxx @@ -39,8 +35,6 @@ void Fl_Xlib_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) { XFillArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); } -#endif // FL_CFG_GFX_XLIB_ARCI_CXX - // // End of "$Id$". // diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx index fecd840a4..b36ce8a41 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_color.cxx @@ -31,6 +31,7 @@ // being used to index arrays. So I always copy them to an integer // before use. +#include "Fl_Xlib_Graphics_Driver.h" # include "../../Fl_XColor.H" # include <FL/Fl.H> # include <FL/x.H> @@ -218,7 +219,7 @@ ulong fl_xpixel(Fl_Color i) { xmap.r = realcolor(r, fl_redmask); xmap.g = realcolor(g, fl_greenmask); xmap.b = realcolor(b, fl_bluemask); - return xmap.pixel = + return xmap.pixel = (((r&fl_redmask) << fl_redshift)+ ((g&fl_greenmask)<<fl_greenshift)+ ((b&fl_bluemask)<< fl_blueshift) diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx index 019c0d57f..274b6ec68 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx @@ -18,6 +18,7 @@ // Select fonts from the FLTK font table. #include "../../flstring.h" +#include "Fl_Xlib_Graphics_Driver.h" #include <FL/Fl.H> #include <FL/fl_draw.H> #include <FL/x.H> @@ -836,7 +837,7 @@ void Fl_Xlib_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &d // If this code fails to load the requested font, it falls back through a // series of tried 'n tested alternatives, ultimately resorting to what the // original fltk code did. -// NOTE: On my test boxes (FC6, FC7, FC8, ubuntu8.04, 9.04, 9.10) this works +// NOTE: On my test boxes (FC6, FC7, FC8, ubuntu8.04, 9.04, 9.10) this works // well for the fltk "built-in" font names. static XFontStruct* load_xfont_for_xft2(Fl_Graphics_Driver *driver) { XFontStruct* xgl_font = 0; @@ -883,9 +884,9 @@ static XFontStruct* load_xfont_for_xft2(Fl_Graphics_Driver *driver) { } snprintf(xlfd, 128, "-*-*%s*-%s-%c-*--*-%d-*-*-*-*-*-*", name, weight, slant, (size*10)); xgl_font = XLoadQueryFont(fl_display, xlfd); - } + } free(pc); // release our copy of the font name - + // if we have nothing loaded, try a generic proportional font if(!xgl_font) { snprintf(xlfd, 128, "-*-helvetica-*-%c-*--*-%d-*-*-*-*-*-*", slant, (size*10)); @@ -999,7 +1000,7 @@ void Fl_Xlib_Graphics_Driver::draw(const char *str, int n, int x, int y) { color.color.green = ((int)g)*0x101; color.color.blue = ((int)b)*0x101; color.color.alpha = 0xffff; - + const wchar_t *buffer = utf8reformat(str, n); #ifdef __CYGWIN__ XftDrawString16(draw_, &color, font_descriptor()->font, x, y, (XftChar16 *)buffer, n); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 479696b77..924ddec3e 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -45,11 +45,13 @@ //////////////////////////////////////////////////////////////// +#include "Fl_Xlib_Graphics_Driver.h" # include <FL/Fl.H> # include <FL/fl_draw.H> # include <FL/x.H> # include "../../Fl_XColor.H" # include "../../flstring.h" +#include <X11/Xregion.h> static XImage xi; // template used to pass info to X static int bytes_per_pixel; @@ -693,9 +695,9 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i *dstptr++ = (srcb * srca + dstb * dsta) >> 8; } } - + fl_draw_image(dst, X, Y, W, H, 3, 0); - + delete[] dst; } @@ -814,16 +816,18 @@ void Fl_Xlib_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int H else copy_offscreen(X, Y, W, H, pxm->id_, cx, cy); } +extern uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here + fl_uintptr_t Fl_Xlib_Graphics_Driver::cache(Fl_Pixmap *img, int w, int h, const char *const*data) { Fl_Offscreen id; - id = fl_create_offscreen(w(), h()); + id = fl_create_offscreen(w, h); fl_begin_offscreen(id); uchar *bitmap = 0; fl_mask_bitmap = &bitmap; - fl_draw_pixmap(data(), 0, 0, FL_BLACK); + fl_draw_pixmap(data, 0, 0, FL_BLACK); fl_mask_bitmap = 0; if (bitmap) { - img->mask_ = (fl_uintptr_t)fl_create_bitmask(w(), h(), bitmap); + img->mask_ = (fl_uintptr_t)fl_create_bitmask(w, h, bitmap); delete[] bitmap; } fl_end_offscreen(); |
