Author: manolo
Date: 2012-03-14 09:14:53 -0700 (Wed, 14 Mar 2012)
New Revision: 9285
Log:
Removed all uses of fltk3::Device::class_name(). Class fltk3::Device becomes
useless and is removed.
Modified:
branches/branch-3.0/include/FL/Fl_Device.H
branches/branch-3.0/include/FL/Fl_Paged_Device.H
branches/branch-3.0/include/FL/Fl_PostScript.H
branches/branch-3.0/include/FL/Fl_Printer.H
branches/branch-3.0/include/FL/x.H
branches/branch-3.0/include/fltk3/Device.h
branches/branch-3.0/include/fltk3/PagedDevice.h
branches/branch-3.0/include/fltk3/PostScript.h
branches/branch-3.0/include/fltk3/Printer.h
branches/branch-3.0/include/fltk3/x.h
branches/branch-3.0/src/fltk3/Bitmap.cxx
branches/branch-3.0/src/fltk3/Device.cxx
branches/branch-3.0/src/fltk3/DoubleWindow.cxx
branches/branch-3.0/src/fltk3/Image.cxx
branches/branch-3.0/src/fltk3/PagedDevice.cxx
branches/branch-3.0/src/fltk3/Pixmap.cxx
branches/branch-3.0/src/fltk3/PostScript.cxx
branches/branch-3.0/src/fltk3/Printer.cxx
branches/branch-3.0/src/fltk3/TextDisplay.cxx
branches/branch-3.0/src/fltk3/cocoa.mm
branches/branch-3.0/src/fltk3/cocoa_draw_image.cxx
branches/branch-3.0/src/fltk3/draw_pixmap.cxx
branches/branch-3.0/src/fltk3/line_style.cxx
branches/branch-3.0/src/fltk3/rect.cxx
branches/branch-3.0/src/fltk3/win32.cxx
branches/branch-3.0/src/fltk3/win32_draw_image.cxx
branches/branch-3.0/src/fltk3/win32_font.cxx
Modified: branches/branch-3.0/include/FL/Fl_Device.H
===================================================================
--- branches/branch-3.0/include/FL/Fl_Device.H 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/include/FL/Fl_Device.H 2012-03-14 16:14:53 UTC (rev
9285)
@@ -78,10 +78,6 @@
Fl_Device() { /* don't call me */ }
public:
-
- virtual const char *class_name() {
- return ((fltk3::Device*)_p)->class_name();
- }
};
@@ -362,8 +358,6 @@
virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int
cy) = 0;
public:
- static const char *class_id;
- virtual const char *class_name() {return class_id;};
/** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */
virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ =
size;}
/** \brief see fl_font(void). */
@@ -398,8 +392,6 @@
*/
class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
void color(Fl_Color c);
void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y);
@@ -431,8 +423,6 @@
*/
class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
void color(Fl_Color c);
void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y);
@@ -461,8 +451,6 @@
*/
class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
void color(Fl_Color c);
void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y);
@@ -496,10 +484,6 @@
public:
- const char *class_name() {
- return ((fltk3::SurfaceDevice*)_p)->class_name();
- }
-
virtual void set_current(void) {
((fltk3::SurfaceDevice*)_p)->set_current();
}
@@ -526,8 +510,6 @@
class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device {
static Fl_Display_Device *_display; // the platform display device
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
/** \brief A constructor that sets the graphics driver used by the display */
Fl_Display_Device(Fl_Graphics_Driver *graphics_driver);
/** Returns the platform display device. */
Modified: branches/branch-3.0/include/FL/Fl_Paged_Device.H
===================================================================
--- branches/branch-3.0/include/FL/Fl_Paged_Device.H 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/include/FL/Fl_Paged_Device.H 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -93,10 +93,6 @@
public:
- const char *class_name() {
- return ((fltk3::PagedDevice*)_p)->class_name();
- }
-
virtual int start_job(int pagecount, int *frompage = NULL, int *topage =
NULL) {
return ((fltk3::PagedDevice*)_p)->start_job(pagecount, frompage, topage);
}
Modified: branches/branch-3.0/include/FL/Fl_PostScript.H
===================================================================
--- branches/branch-3.0/include/FL/Fl_PostScript.H 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/include/FL/Fl_PostScript.H 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -64,8 +64,6 @@
*/
class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
Fl_PostScript_Graphics_Driver();
#ifndef FL_DOXYGEN
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
@@ -221,8 +219,6 @@
protected:
Fl_PostScript_Graphics_Driver *driver();
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
Fl_PostScript_File_Device();
~Fl_PostScript_File_Device();
int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format =
Fl_Paged_Device::A4,
Modified: branches/branch-3.0/include/FL/Fl_Printer.H
===================================================================
--- branches/branch-3.0/include/FL/Fl_Printer.H 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/include/FL/Fl_Printer.H 2012-03-14 16:14:53 UTC (rev
9285)
@@ -48,10 +48,6 @@
public:
- const char *class_name() {
- return ((fltk3::Printer*)_p)->class_name();
- }
-
Fl_Printer() {
_p = new fltk3::Printer();
_p->wrapper(this);
Modified: branches/branch-3.0/include/FL/x.H
===================================================================
--- branches/branch-3.0/include/FL/x.H 2012-03-14 15:59:02 UTC (rev 9284)
+++ branches/branch-3.0/include/FL/x.H 2012-03-14 16:14:53 UTC (rev 9285)
@@ -55,7 +55,7 @@
typedef ulong Fl_Offscreen;
# define fl_create_offscreen(w,h) \
XCreatePixmap(fl_display, \
- (Fl_Surface_Device::surface()->class_name() ==
Fl_Display_Device::class_id ? \
+ (fltk3::SurfaceDevice::to_display() ? \
fl_window : fl_xid(Fl::first_window()) ) , \
w, h, fl_visual->depth)
// begin/end are macros that save the old state in local variables:
Modified: branches/branch-3.0/include/fltk3/Device.h
===================================================================
--- branches/branch-3.0/include/fltk3/Device.h 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/include/fltk3/Device.h 2012-03-14 16:14:53 UTC (rev
9285)
@@ -1,7 +1,7 @@
//
// "$Id: Device.h 8529 2011-03-23 12:49:30Z AlbrechtS $"
//
-// Definition of classes fltk3::Device, fltk3::GraphicsDriver,
fltk3::SurfaceDevice, fltk3::DisplayDevice
+// Definition of classes fltk3::GraphicsDriver, fltk3::SurfaceDevice,
fltk3::DisplayDevice
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2011 by Bill Spitzak and others.
@@ -26,7 +26,7 @@
// http://www.fltk.org/str.php
//
/** \file Device.h
- \brief declaration of classes fltk3::Device, fltk3::GraphicsDriver,
fltk3::SurfaceDevice,
+ \brief declaration of classes fltk3::GraphicsDriver, fltk3::SurfaceDevice,
fltk3::DisplayDevice, fltk3::DevicePlugin.
*/
@@ -76,33 +76,7 @@
to this buffer.
*/
typedef void (*DrawImageCb)(void* data,int x,int y,int w,uchar* buf);
-
- /**
- \brief All graphical output devices and all graphics systems.
- */
- class FLTK3_EXPORT Device : public Object {
- public:
- /** A string that identifies each subclass of fltk3::Device.
- Function class_name() applied to a device of this class returns this
string.
- */
- static const char *class_id;
- /**
- Returns the name of the class of this object.
- The class of an instance of an fltk3::Device subclass can be checked with
code such as:
- \code
- if ( instance->class_name() == fltk3::Printer::class_id ) { ... }
- \endcode
- */
- virtual const char *class_name() {return class_id;};
- /**
- Virtual destructor.
-
- The destructor of fltk3::Device must be virtual to make the destructors of
- derived classes being called correctly on destruction.
- */
- virtual ~Device() {};
- };
-
+
const int REGION_STACK_SIZE = 10;
const int MATRIX_STACK_SIZE = 32;
@@ -114,7 +88,7 @@
<br> The public API for drawing operations is functionally presented in
\ref drawing and as function lists
in the \ref fl_drawings and \ref fl_attributes modules.
*/
- class FLTK3_EXPORT GraphicsDriver : public fltk3::Device {
+ class FLTK3_EXPORT GraphicsDriver : public Object {
friend void ::gl_start();
public:
/** A 2D coordinate transformation matrix
@@ -310,8 +284,6 @@
*/
virtual void draw(fltk3::Bitmap *bm, int XP, int YP, int WP, int HP, int
cx, int cy) {}
- static const char *class_id;
- virtual const char *class_name() {return class_id;};
/** \brief see fltk3::font(fltk3::Font face, fltk3::Fontsize size). */
virtual void font(fltk3::Font face, fltk3::Fontsize size) {font_ = face;
size_ = size;}
/** \brief see fltk3::font(void). */
@@ -350,8 +322,6 @@
*/
class FLTK3_EXPORT QuartzGraphicsDriver : public fltk3::GraphicsDriver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
void color(fltk3::Color c);
void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y);
@@ -419,8 +389,6 @@
int numcount;
int counts[20];
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
void color(fltk3::Color c);
void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y);
@@ -484,8 +452,6 @@
*/
class XlibGraphicsDriver : public fltk3::GraphicsDriver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
void color(fltk3::Color c);
void color(uchar r, uchar g, uchar b);
void draw(const char* str, int n, int x, int y);
@@ -539,7 +505,7 @@
/**
\brief A surface that's susceptible to receive graphical output.
*/
- class FLTK3_EXPORT SurfaceDevice : public fltk3::Device {
+ class FLTK3_EXPORT SurfaceDevice : public Object {
/** \brief The graphics driver in use by this surface. */
fltk3::GraphicsDriver *_driver;
static SurfaceDevice *_surface; // the surface that currently receives
graphics output
@@ -547,17 +513,17 @@
/** \brief Constructor that sets the graphics driver to use for the
created surface. */
SurfaceDevice(fltk3::GraphicsDriver *graphics_driver) {_driver =
graphics_driver; };
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
virtual void set_current(void);
/** \brief Sets the graphics driver of this drawing surface. */
inline void driver(fltk3::GraphicsDriver *graphics_driver) {_driver =
graphics_driver;};
/** \brief Returns the graphics driver of this drawing surface. */
inline fltk3::GraphicsDriver *driver() {return _driver; };
/** \brief the surface that currently receives graphics output */
- static inline fltk3::SurfaceDevice *surface() {return _surface; };
+ static inline fltk3::SurfaceDevice *surface() {return _surface; };
+ /** returns true if the current output surface is the system's display,
and false otherwise */
+ static bool to_display();
/** \brief The destructor. */
- virtual ~SurfaceDevice() {}
+ virtual ~SurfaceDevice();
};
/**
@@ -566,8 +532,6 @@
class FLTK3_EXPORT DisplayDevice : public fltk3::SurfaceDevice {
static DisplayDevice *_display; // the platform display device
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
/** \brief A constructor that sets the graphics driver used by the display
*/
DisplayDevice(fltk3::GraphicsDriver *graphics_driver);
/** Returns the platform display device. */
Modified: branches/branch-3.0/include/fltk3/PagedDevice.h
===================================================================
--- branches/branch-3.0/include/fltk3/PagedDevice.h 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/include/fltk3/PagedDevice.h 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -121,8 +121,6 @@
public:
/** \brief The destructor */
virtual ~PagedDevice() {};
- static const char *class_id;
- const char *class_name() {return class_id;};
virtual int start_job(int pagecount, int *frompage = NULL, int *topage =
NULL);
virtual int start_page(void);
virtual int printable_rect(int *w, int *h);
Modified: branches/branch-3.0/include/fltk3/PostScript.h
===================================================================
--- branches/branch-3.0/include/fltk3/PostScript.h 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/include/fltk3/PostScript.h 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -65,8 +65,6 @@
*/
class FLTK3_EXPORT PostScriptGraphicsDriver : public fltk3::GraphicsDriver {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
PostScriptGraphicsDriver();
#ifndef FLTK3_DOXYGEN
enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
@@ -222,8 +220,6 @@
protected:
fltk3::PostScriptGraphicsDriver *driver();
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
PostScriptFileDevice();
~PostScriptFileDevice();
int start_job(int pagecount, enum fltk3::PagedDevice::Page_Format format =
fltk3::PagedDevice::A4,
@@ -244,7 +240,6 @@
#ifdef __APPLE__
void set_current() { fl_gc = gc; fltk3::PagedDevice::set_current(); }
#endif
-
static const char *file_chooser_title;
};
Modified: branches/branch-3.0/include/fltk3/Printer.h
===================================================================
--- branches/branch-3.0/include/fltk3/Printer.h 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/include/fltk3/Printer.h 2012-03-14 16:14:53 UTC (rev
9285)
@@ -81,8 +81,6 @@
/** \brief The constructor */
SystemPrinter(void);
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
int start_page (void);
int printable_rect(int *w, int *h);
@@ -115,8 +113,6 @@
/** The constructor */
PostScriptPrinter(void) {};
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
};
@@ -157,8 +153,6 @@
*/
class FLTK3_EXPORT Printer : public fltk3::PagedDevice {
public:
- static const char *class_id;
- const char *class_name() {return class_id;};
/** \brief The constructor */
Printer(void);
int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
Modified: branches/branch-3.0/include/fltk3/x.h
===================================================================
--- branches/branch-3.0/include/fltk3/x.h 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/include/fltk3/x.h 2012-03-14 16:14:53 UTC (rev
9285)
@@ -102,7 +102,7 @@
}
# define fl_create_offscreen(w,h) \
XCreatePixmap(fl_display, \
- (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::DisplayDevice::class_id ? \
+ (fltk3::SurfaceDevice::to_display() ? \
fl_window : fl_xid(fltk3::first_window()) ) , \
w, h, fl_visual->depth)
// begin/end are macros that save the old state in local variables:
Modified: branches/branch-3.0/src/fltk3/Bitmap.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Bitmap.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/Bitmap.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -304,7 +304,7 @@
HDC tempdc;
int save;
BOOL use_print_algo = false;
- if (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) {
+ if (!fltk3::SurfaceDevice::to_display()) {
static HMODULE hMod = NULL;
if (!hMod) {
hMod = LoadLibrary("MSIMG32.DLL");
@@ -313,8 +313,6 @@
if (fl_TransparentBlt) use_print_algo = true;
}
if (use_print_algo) { // algorithm for bitmap output to Fl_GDI_Printer
- fltk3::Offscreen tmp_id = fl_create_offscreen(W, H);
- fl_begin_offscreen(tmp_id);
fltk3::Color save_c = fltk3::color(); // save bitmap's desired color
uchar r, g, b;
fltk3::get_color(save_c, r, g, b);
@@ -322,6 +320,8 @@
g = 255-g;
b = 255-b;
fltk3::Color background = fltk3::rgb_color(r, g, b); // a color very
different from the bitmap's
+ fltk3::Offscreen tmp_id = fl_create_offscreen(W, H);
+ fl_begin_offscreen(tmp_id);
fltk3::color(background);
fltk3::rectf(0,0,W,H); // use this color as offscreen background
fltk3::color(save_c); // back to bitmap's color
Modified: branches/branch-3.0/src/fltk3/Device.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Device.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/Device.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -29,23 +29,6 @@
#include <fltk3/Device.h>
#include <fltk3/Image.h>
-const char *fltk3::Device::class_id = "fltk3::Device";
-const char *fltk3::SurfaceDevice::class_id = "fltk3::SurfaceDevice";
-const char *fltk3::DisplayDevice::class_id = "fltk3::DisplayDevice";
-const char *fltk3::GraphicsDriver::class_id = "fltk3::GraphicsDriver";
-#if defined(__APPLE__) || defined(FLTK3_DOXYGEN)
-const char *fltk3::QuartzGraphicsDriver::class_id =
"fltk3::QuartzGraphicsDriver";
-#endif
-#if defined(WIN32) || defined(FLTK3_DOXYGEN)
-const char *fltk3::GDIGraphicsDriver::class_id = "fltk3::GDIGraphicsDriver";
-#endif
-#if !(defined(__APPLE__) || defined(WIN32))
-namespace fltk3 {
- const char *XlibGraphicsDriver::class_id = "fltk3::XlibGraphicsDriver";
-}
-#endif
-
-
/** \brief Use this drawing surface for future graphics requests. */
void fltk3::SurfaceDevice::set_current(void)
{
@@ -53,6 +36,13 @@
_surface = this;
}
+bool fltk3::SurfaceDevice::to_display() {
+ return fltk3::SurfaceDevice::surface() ==
fltk3::DisplayDevice::display_device();
+}
+
+fltk3::SurfaceDevice::~SurfaceDevice() { }
+
+
const fltk3::GraphicsDriver::matrix fltk3::GraphicsDriver::m0 = {1, 0, 0, 1,
0, 0};
fltk3::GraphicsDriver::GraphicsDriver() {
@@ -89,7 +79,6 @@
#endif
};
-
//
// End of "$Id$".
//
Modified: branches/branch-3.0/src/fltk3/DoubleWindow.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/DoubleWindow.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/DoubleWindow.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -178,11 +178,11 @@
HDC new_gc = CreateCompatibleDC(fl_gc);
int save = SaveDC(new_gc);
SelectObject(new_gc, bitmap);
+ can_do_alpha_blending(); // make sure this is run
BOOL alpha_ok = 0;
// first try to alpha blend
// if to printer, always try alpha_blend
- int to_display = fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::DisplayDevice::class_id; // true iff display output
- if ( (to_display && can_do_alpha_blending()) ||
fltk3::SurfaceDevice::surface()->class_name() == fltk3::Printer::class_id) {
+ if ( (!fltk3::SurfaceDevice::to_display()) || can_do_alpha_blending() ) {
if (fl_alpha_blend) alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc,
srcx, srcy, w, h, blendfunc);
}
// if that failed (it shouldn't), still copy the bitmap over, but now alpha
is 1
Modified: branches/branch-3.0/src/fltk3/Image.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Image.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/Image.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -459,6 +459,11 @@
}
#ifdef __APPLE__
+static void imgProviderReleaseData (void *info, const void *data, size_t size)
+{
+ delete[] (unsigned char *)data;
+}
+
void fltk3::QuartzGraphicsDriver::draw(fltk3::RGBImage *img, int XP, int YP,
int WP, int HP, int cx, int cy) {
int X, Y, W, H;
// Don't draw an empty image...
@@ -471,12 +476,24 @@
}
if (!img->id_) {
CGColorSpaceRef lut = 0;
+ CGDataProviderReleaseDataCallback release_cb = NULL;
+ const uchar* img_bytes = img->array;
+ int ld = img->ld();
+ if (fltk3::SurfaceDevice::surface() !=
fltk3::DisplayDevice::display_device()) {
+ // when printing, duplicate the image data so it can be deleted later,
at page end
+ release_cb = imgProviderReleaseData;
+ fltk3::RGBImage* img2 = (fltk3::RGBImage*)img->copy();
+ img2->alloc_array = 0;
+ img_bytes = img2->array;
+ ld = 0;
+ delete img2;
+ }
if (img->d()<=2)
lut = CGColorSpaceCreateDeviceGray();
else
lut = CGColorSpaceCreateDeviceRGB();
- CGDataProviderRef src = CGDataProviderCreateWithData( 0L, img->array,
img->w()*img->h()*img->d(), 0L);
- img->id_ = CGImageCreate( img->w(), img->h(), 8, img->d()*8,
img->ld()?img->ld():img->w()*img->d(),
+ CGDataProviderRef src = CGDataProviderCreateWithData( NULL, img_bytes,
img->w()*img->h()*img->d(), release_cb);
+ img->id_ = CGImageCreate( img->w(), img->h(), 8, img->d()*8,
ld?ld:img->w()*img->d(),
lut, (img->d()&1)?kCGImageAlphaNone:kCGImageAlphaLast,
src, 0L, false, kCGRenderingIntentDefault);
CGColorSpaceRelease(lut);
Modified: branches/branch-3.0/src/fltk3/PagedDevice.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/PagedDevice.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/PagedDevice.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -32,9 +32,6 @@
#include <fltk3/run.h>
#include <fltk3/draw.h>
-const char *fltk3::PagedDevice::class_id = "fltk3::PagedDevice";
-
-
/**
@brief Draws the widget on the printed page.
*
Modified: branches/branch-3.0/src/fltk3/Pixmap.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Pixmap.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/Pixmap.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -147,7 +147,7 @@
}
fl_end_offscreen();
}
- if (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) {
+ if (!fltk3::SurfaceDevice::to_display()) {
typedef BOOL (WINAPI* fl_transp_func)
(HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static HMODULE hMod = NULL;
static fl_transp_func fl_TransparentBlt = NULL;
Modified: branches/branch-3.0/src/fltk3/PostScript.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/PostScript.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/PostScript.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -39,8 +39,6 @@
#endif
#endif
-const char *fltk3::PostScriptGraphicsDriver::class_id =
"fltk3::PostScriptGraphicsDriver";
-const char *fltk3::PostScriptFileDevice::class_id =
"fltk3::PostScriptFileDevice";
/** \brief Label of the PostScript file chooser window */
const char *fltk3::PostScriptFileDevice::file_chooser_title = "Select a .ps
file";
Modified: branches/branch-3.0/src/fltk3/Printer.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/Printer.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/Printer.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -76,14 +76,6 @@
/** [this text may be customized at run-time] */
const char *fltk3::Printer::property_cancel = "Cancel";
-const char *fltk3::Printer::class_id = "fltk3::Printer";
-#if defined(__APPLE__) || defined(WIN32) || defined(FLTK3_DOXYGEN)
-const char *fltk3::SystemPrinter::class_id = fltk3::Printer::class_id;
-#endif
-#if !( defined(__APPLE__) || defined(WIN32) )
-const char *fltk3::PostScriptPrinter::class_id = fltk3::Printer::class_id;
-#endif
-
#if defined(__APPLE__) || defined(WIN32)
void fltk3::SystemPrinter::set_current(void)
{
Modified: branches/branch-3.0/src/fltk3/TextDisplay.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/TextDisplay.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/TextDisplay.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -3378,7 +3378,7 @@
// draw the non-text, non-scrollbar areas.
if (damage() & fltk3::DAMAGE_ALL) {
// printf("drawing all (box = %d)\n", box());
- if (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) {
+ if (!fltk3::SurfaceDevice::to_display()) {
// if to printer, draw the background
fltk3::rectf(text_area.x, text_area.y, text_area.w, text_area.h, color()
);
}
Modified: branches/branch-3.0/src/fltk3/cocoa.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa.mm 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/cocoa.mm 2012-03-14 16:14:53 UTC (rev
9285)
@@ -3130,23 +3130,14 @@
fltk3::check();
win->make_current();
this->set_current(); // back to the fltk3::PagedDevice
- if (driver()->class_name() == fltk3::QuartzGraphicsDriver::class_id) {
- // capture as transparent image the window title bar from screen
- CGImageRef img = Fl_X::CGImage_from_window_rect(win, 0, -bt, win->w(), bt);
- CGRect rect = { { x_offset, y_offset }, { win->w(), bt } }; // print the
title bar
- Fl_X::q_begin_image(rect, 0, 0, win->w(), bt);
- CGContextDrawImage(fl_gc, rect, img);
- Fl_X::q_end_image();
- CGImageRelease(img);
- }
- else {
- // capture the window title bar from screen
- uchar *top_image = fltk3::read_image(NULL, 0, -bt, win->w(), bt);
- if (top_image) { // print the title bar
- fltk3::draw_image(top_image, x_offset, y_offset, win->w(), bt, 3);
- delete[] top_image;
- }
- }
+ int bpp;
+ // capture the window title bar as an RGBA image
+ unsigned char *top_image = Fl_X::bitmap_from_window_rect(win, 0, -bt,
win->w(), bt, &bpp);
+ fltk3::RGBImage* rgba = new fltk3::RGBImage(top_image, win->w(), bt, bpp);
+ // and print it
+ rgba->draw(x_offset, y_offset);
+ delete rgba;
+ delete[] top_image;
this->print_widget(win, x_offset, y_offset + bt); // print the window inner
part
}
Modified: branches/branch-3.0/src/fltk3/cocoa_draw_image.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa_draw_image.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/cocoa_draw_image.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -64,7 +64,7 @@
const void *array = buf;
uchar *tmpBuf = 0;
- if (cb || fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) {
+ if (cb || !fltk3::SurfaceDevice::to_display()) {
tmpBuf = new uchar[ H*W*delta ];
if (cb) {
for (int i=0; i<H; i++) {
Modified: branches/branch-3.0/src/fltk3/draw_pixmap.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/draw_pixmap.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/draw_pixmap.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -341,9 +341,7 @@
#endif
#ifdef __APPLE_QUARTZ__
- if (fltk3::graphics_driver->class_name() ==
fltk3::QuartzGraphicsDriver::class_id ) {
- bool transparent = (transparent_index>=0);
- transparent = true;
+ if ( fltk3::SurfaceDevice::to_display() ) {
U32 *array = new U32[d.w * d.h], *q = array;
for (int Y = 0; Y < d.h; Y++) {
const uchar* p = data[Y];
@@ -358,18 +356,9 @@
}
}
}
- CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
- CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, d.w * d.h
* 4, 0L);
- CGImageRef img = CGImageCreate(d.w, d.h, 8, 4*8, 4*d.w,
- lut,
transparent?kCGImageAlphaLast:kCGImageAlphaNoneSkipLast,
- src, 0L, false, kCGRenderingIntentDefault);
- CGColorSpaceRelease(lut);
- CGDataProviderRelease(src);
- CGRect rect = { { x, y} , { d.w, d.h } };
- Fl_X::q_begin_image(rect, 0, 0, d.w, d.h);
- CGContextDrawImage(fl_gc, rect, img);
- Fl_X::q_end_image();
- CGImageRelease(img);
+ fltk3::RGBImage* rgb = new fltk3::RGBImage((uchar*)array, d.w, d.h, 4);
+ rgb->draw(x, y);
+ delete rgb;
delete[] array;
}
else {
Modified: branches/branch-3.0/src/fltk3/line_style.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/line_style.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/line_style.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -69,7 +69,7 @@
fl_quartz_line_width_ = (float)width;
fl_quartz_line_cap_ = Cap[(style>>8)&3];
// when printing kCGLineCapSquare seems better for solid lines
- if ( fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id && style == fltk3::SOLID && dashes == NULL ) {
+ if ( (!fltk3::SurfaceDevice::to_display()) && style == fltk3::SOLID &&
dashes == NULL ) {
fl_quartz_line_cap_ = kCGLineCapSquare;
}
fl_quartz_line_join_ = Join[(style>>12)&3];
Modified: branches/branch-3.0/src/fltk3/rect.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/rect.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/rect.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -49,7 +49,6 @@
#ifdef __APPLE_QUARTZ__
extern float fl_quartz_line_width_;
-#define USINGQUARTZPRINTER (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id)
#endif
#ifdef USE_X11
@@ -167,10 +166,10 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::rect(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
- if ( (!USINGQUARTZPRINTER) && fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if ( fltk3::SurfaceDevice::to_display() && fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextStrokeRect(fl_gc, rect);
- if ( (!USINGQUARTZPRINTER) && fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if ( fltk3::SurfaceDevice::to_display() && fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::rect(int x, int y, int w, int h) {
@@ -215,11 +214,11 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::xyline(int x, int y, int x1) {
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextStrokePath(fl_gc);
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::xyline(int x, int y, int x1) {
@@ -234,12 +233,12 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::xyline(int x, int y, int x1, int y2) {
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextStrokePath(fl_gc);
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::xyline(int x, int y, int x1, int y2) {
@@ -261,13 +260,13 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::xyline(int x, int y, int x1, int y2, int x3)
{
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextAddLineToPoint(fl_gc, x3, y2);
CGContextStrokePath(fl_gc);
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::xyline(int x, int y, int x1, int y2, int x3) {
@@ -291,11 +290,11 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::yxline(int x, int y, int y1) {
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextStrokePath(fl_gc);
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::yxline(int x, int y, int y1) {
@@ -312,12 +311,12 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::yxline(int x, int y, int y1, int x2) {
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextStrokePath(fl_gc);
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::yxline(int x, int y, int y1, int x2) {
@@ -339,13 +338,13 @@
#if defined(__APPLE_QUARTZ__)
void fltk3::QuartzGraphicsDriver::yxline(int x, int y, int y1, int x2, int y3)
{
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, true);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextAddLineToPoint(fl_gc, x2, y3);
CGContextStrokePath(fl_gc);
- if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
+ if (!fltk3::SurfaceDevice::to_display() || fl_quartz_line_width_ > 1.5f)
CGContextSetShouldAntialias(fl_gc, false);
}
#elif defined(WIN32)
void fltk3::GDIGraphicsDriver::yxline(int x, int y, int y1, int x2, int y3) {
@@ -711,7 +710,7 @@
fltk3::Region r = clip_region();
if (!r) return 1;
RECT rect;
- if (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) { // in case of print context, convert coords from
logical to device
+ if (!fltk3::SurfaceDevice::to_display()) { // in case of print context,
convert coords from logical to device
POINT pt[2] = { {x, y}, {x + w, y + h} };
LPtoDP(fl_gc, pt, 2);
rect.left = pt[0].x; rect.top = pt[0].y; rect.right = pt[1].x; rect.bottom
= pt[1].y;
@@ -775,7 +774,7 @@
} else { // partial intersection
RECT rect;
GetRgnBox(temp, &rect);
- if(fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) { // if print context, convert coords from device to
logical
+ if (!fltk3::SurfaceDevice::to_display()) { // if print context, convert
coords from device to logical
POINT pt[2] = { {rect.left, rect.top}, {rect.right, rect.bottom} };
DPtoLP(fl_gc, pt, 2);
X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y;
Modified: branches/branch-3.0/src/fltk3/win32.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/win32.cxx 2012-03-14 15:59:02 UTC (rev
9284)
+++ branches/branch-3.0/src/fltk3/win32.cxx 2012-03-14 16:14:53 UTC (rev
9285)
@@ -1960,7 +1960,7 @@
}
fltk3::Region XRectangleRegion(int x, int y, int w, int h) {
- if (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::DisplayDevice::class_id) return CreateRectRgn(x,y,x+w,y+h);
+ if (fltk3::SurfaceDevice::to_display()) return CreateRectRgn(x,y,x+w,y+h);
// because rotation may apply, the rectangle becomes a polygon in device
coords
POINT pt[4] = { {x, y}, {x + w, y}, {x + w, y + h}, {x, y + h} };
LPtoDP(fl_gc, pt, 4);
Modified: branches/branch-3.0/src/fltk3/win32_draw_image.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/win32_draw_image.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/win32_draw_image.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -178,7 +178,7 @@
int blocking = h;
{int size = linesize*h;
// when printing, don't limit buffer size not to get a crash in StretchDIBits
- if (size > MAXBUFFER && fltk3::SurfaceDevice::surface()->class_name() !=
fltk3::Printer::class_id) {
+ if (size > MAXBUFFER && fltk3::SurfaceDevice::to_display()) {
size = MAXBUFFER;
blocking = MAXBUFFER/linesize;
}
@@ -256,7 +256,7 @@
}
}
}
- if(fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) {
+ if(!fltk3::SurfaceDevice::to_display()) {
// if print context, device and logical units are not equal, so
SetDIBitsToDevice
// does not do the expected job, whereas StretchDIBits does it.
StretchDIBits(fl_gc, x, y+j-k, w, k, 0, 0, w, k,
Modified: branches/branch-3.0/src/fltk3/win32_font.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/win32_font.cxx 2012-03-14 15:59:02 UTC
(rev 9284)
+++ branches/branch-3.0/src/fltk3/win32_font.cxx 2012-03-14 16:14:53 UTC
(rev 9285)
@@ -272,7 +272,7 @@
// if printer context, extents shd be converted to logical coords
#define EXTENTS_UPDATE(x,y,w,h) \
- if (fltk3::SurfaceDevice::surface()->class_name() ==
fltk3::Printer::class_id) { on_printer_extents_update(x,y,w,h); }
+ if (!fltk3::SurfaceDevice::to_display()) {
on_printer_extents_update(x,y,w,h); }
// Function to determine the extent of the "inked" area of the glyphs in a
string
void fltk3::GDIGraphicsDriver::text_extents(const char *c, int n, int &dx, int
&dy, int &w, int &h) {
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit