Added Fl_Printer::add_image(const ichar*) needed for correct memory usage by

Fl_Paged_Device::print_window_part().

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8341 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy
2011-01-31 13:02:55 +00:00
parent 2c5006563f
commit 1993f08a33
5 changed files with 16 additions and 12 deletions
+4 -7
View File
@@ -108,26 +108,23 @@ public:
*/ */
static const page_format page_formats[NO_PAGE_FORMATS]; static const page_format page_formats[NO_PAGE_FORMATS];
private:
#ifdef __APPLE__ #ifdef __APPLE__
struct chain_elt { struct chain_elt {
Fl_Image *image;
const uchar *data; const uchar *data;
struct chain_elt *next; struct chain_elt *next;
}; };
void add_image(Fl_Image *image, const uchar *data); // adds an image to the page image list
#endif #endif
private:
void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them
protected: protected:
/** \brief horizontal offset to the origin of graphics coordinates */ /** \brief horizontal offset to the origin of graphics coordinates */
int x_offset; int x_offset;
/** \brief vertical offset to the origin of graphics coordinates */ /** \brief vertical offset to the origin of graphics coordinates */
int y_offset; int y_offset;
/** \brief chained list of Fl_Image's used in this page */
struct chain_elt *image_list_;
#ifdef __APPLE__ #ifdef __APPLE__
/** \brief deletes the page image list */ struct chain_elt *image_list_; // chained list of images used in this page
void delete_image_list(); virtual void add_image(const uchar *data); // adds an image to the page image list
void delete_image_list(); // deletes the page image list
#endif #endif
/** \brief The constructor */ /** \brief The constructor */
Fl_Paged_Device() : Fl_Surface_Device(NULL) {class_name( class_id);}; Fl_Paged_Device() : Fl_Surface_Device(NULL) {class_name( class_id);};
+3
View File
@@ -164,6 +164,9 @@ public:
void untranslate(void); void untranslate(void);
int end_page (void); int end_page (void);
void end_job (void); void end_job (void);
#ifdef __APPLE__
void add_image(const uchar *data);
#endif
/** \brief The destructor */ /** \brief The destructor */
~Fl_Printer(void); ~Fl_Printer(void);
-1
View File
@@ -194,7 +194,6 @@ int Fl_System_Printer::start_page (void)
} }
printable_rect(&w, &h); printable_rect(&w, &h);
origin(0, 0); origin(0, 0);
image_list_ = NULL;
fl_clip_region(0); fl_clip_region(0);
gc = (void *)fl_gc; gc = (void *)fl_gc;
} }
+2 -4
View File
@@ -156,7 +156,7 @@ void Fl_Paged_Device::print_window_part(Fl_Window *win, int x, int y, int w, int
if (offset + width > w) width = w - offset; if (offset + width > w) width = w - offset;
fl_draw_image(image_data[i], delta_x + offset, delta_y, width, h, 3); fl_draw_image(image_data[i], delta_x + offset, delta_y, width, h, 3);
#ifdef __APPLE__ #ifdef __APPLE__
add_image(NULL, image_data[i]); add_image(image_data[i]);
#else #else
delete image_data[i]; delete image_data[i];
#endif #endif
@@ -164,10 +164,9 @@ void Fl_Paged_Device::print_window_part(Fl_Window *win, int x, int y, int w, int
} }
#ifdef __APPLE__ #ifdef __APPLE__
void Fl_Paged_Device::add_image(Fl_Image *image, const uchar *data) void Fl_Paged_Device::add_image(const uchar *data)
{ {
struct chain_elt *elt = (struct chain_elt *)calloc(sizeof(struct chain_elt), 1); struct chain_elt *elt = (struct chain_elt *)calloc(sizeof(struct chain_elt), 1);
elt->image = image;
elt->data = data; elt->data = data;
if (image_list_) { elt->next = image_list_; } if (image_list_) { elt->next = image_list_; }
image_list_ = elt; image_list_ = elt;
@@ -177,7 +176,6 @@ void Fl_Paged_Device::delete_image_list()
{ {
while(image_list_) { while(image_list_) {
struct chain_elt *next = image_list_->next; struct chain_elt *next = image_list_->next;
if(image_list_->image) delete image_list_->image;
if (image_list_->data) delete (uchar*) image_list_->data; // msvc6 compilation fix if (image_list_->data) delete (uchar*) image_list_->data; // msvc6 compilation fix
free(image_list_); free(image_list_);
image_list_ = next; image_list_ = next;
+7
View File
@@ -160,6 +160,13 @@ void Fl_Printer::end_job (void)
printer->end_job(); printer->end_job();
} }
#ifdef __APPLE__
void Fl_Printer::add_image(const uchar *data)
{
printer->add_image(data);
}
#endif
Fl_Printer::~Fl_Printer(void) Fl_Printer::~Fl_Printer(void)
{ {
delete printer; delete printer;