diff options
| author | Manolo Gouy <Manolo> | 2016-02-26 12:51:47 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-02-26 12:51:47 +0000 |
| commit | 682f95079691dd9c9b0677cb66e727397f910e0d (patch) | |
| tree | 9be00996ebe41d8d87fb1965ceff4f6f69b41310 /src/Fl_Paged_Device.cxx | |
| parent | e1f5f5f7ec75ed203fb14571e6bcbf6b0bd30771 (diff) | |
Create class Fl_Widget_Surface that supports draw(Fl_Widget *, int, int).
This simplifies the implementation of Fl_Copy_Surface and Fl_Image_Surface
which now are made to derive from Fl_Widget_Surface.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11220 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Paged_Device.cxx')
| -rw-r--r-- | src/Fl_Paged_Device.cxx | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/src/Fl_Paged_Device.cxx b/src/Fl_Paged_Device.cxx index 51bedc127..2976d4a55 100644 --- a/src/Fl_Paged_Device.cxx +++ b/src/Fl_Paged_Device.cxx @@ -24,134 +24,7 @@ #include <FL/Fl.H> #include <FL/fl_draw.H> -#include "config_lib.h" -#ifdef FL_CFG_GFX_QUARTZ -#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.h" -#endif -/** - @brief Draws the widget on the printed page. - * - The widget's position on the printed page is determined by the last call to origin() - and by the optional delta_x and delta_y arguments. - Its dimensions are in points unless there was a previous call to scale(). - @param[in] widget Any FLTK widget (e.g., standard, custom, window). - @param[in] delta_x Optional horizontal offset for positioning the widget relatively - to the current origin of graphics functions. - @param[in] delta_y Same as above, vertically. - */ -void Fl_Paged_Device::print_widget(Fl_Widget* widget, int delta_x, int delta_y) -{ - int old_x, old_y, new_x, new_y, is_window; - if ( ! widget->visible() ) return; - is_window = (widget->as_window() != NULL); - uchar old_damage = widget->damage(); - widget->damage(FL_DAMAGE_ALL); - // set origin to the desired top-left position of the widget - origin(&old_x, &old_y); - new_x = old_x + delta_x; - new_y = old_y + delta_y; - if (!is_window) { - new_x -= widget->x(); - new_y -= widget->y(); - } - if (new_x != old_x || new_y != old_y) { - translate(new_x - old_x, new_y - old_y ); - } - // if widget is a main window, clip all drawings to the window area - if (is_window && !widget->window()) { - fl_push_clip(0, 0, widget->w(), widget->h() ); -#ifdef __APPLE__ // for Mac OS X 10.6 and above, make window with rounded bottom corners - if ( fl_mac_os_version >= 100600 && driver()->has_feature(Fl_Graphics_Driver::NATIVE) ) { - Fl_X::clip_to_rounded_corners((CGContextRef)driver()->gc(), widget->w(), widget->h()); - } -#endif - } - // we do some trickery to recognize OpenGL windows and draw them via a plugin - int drawn_by_plugin = 0; - if (widget->as_gl_window()) { - Fl_Plugin_Manager pm("fltk:device"); - Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org"); - if (pi) { - drawn_by_plugin = pi->print(widget, 0, 0, 0); - } - } - if (!drawn_by_plugin) { - widget->draw(); - } - if (is_window && !widget->window()) fl_pop_clip(); - // find subwindows of widget and print them - traverse(widget); - // reset origin to where it was - if (new_x != old_x || new_y != old_y) { - untranslate(); - } - if ((old_damage & FL_DAMAGE_CHILD) == 0) widget->clear_damage(old_damage); - else widget->damage(FL_DAMAGE_ALL); -} - - -void Fl_Paged_Device::traverse(Fl_Widget *widget) -{ - Fl_Group *g = widget->as_group(); - if (!g) return; - int n = g->children(); - for (int i = 0; i < n; i++) { - Fl_Widget *c = g->child(i); - if ( !c->visible() ) continue; - if ( c->as_window() ) { - print_widget(c, c->x(), c->y()); - } - else traverse(c); - } -} - -/** - @brief Computes the page coordinates of the current origin of graphics functions. - * - @param[out] x If non-null, *x is set to the horizontal page offset of graphics origin. - @param[out] y Same as above, vertically. - */ -void Fl_Paged_Device::origin(int *x, int *y) -{ - if (x) *x = x_offset; - if (y) *y = y_offset; -} - -/** - @brief Prints a rectangular part of an on-screen window. - - @param win The window from where to capture. - @param x The rectangle left - @param y The rectangle top - @param w The rectangle width - @param h The rectangle height - @param delta_x Optional horizontal offset from current graphics origin where to print the captured rectangle. - @param delta_y As above, vertically. - */ -void Fl_Paged_Device::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y) -{ - Fl_Surface_Device *current = Fl_Surface_Device::surface(); - Fl_Display_Device::display_device()->set_current(); - Fl_Window *save_front = Fl::first_window(); - win->show(); - Fl::check(); - win->make_current(); - uchar *image_data; - image_data = fl_read_image(NULL, x, y, w, h); -#ifdef __APPLE__ // PORTME: Fl_Surface_Driver - platform paged device - Fl_X::q_release_context(); // matches make_current() call above -#endif - if (save_front != win) save_front->show(); - current->set_current(); - fl_draw_image(image_data, delta_x, delta_y, w, h, 3); - delete[] image_data; -#ifdef WIN32 - HDC gc = GetDC(fl_xid(win)); - fl_graphics_driver->gc(gc); - ReleaseDC(fl_xid(win), gc); -#endif -} /** @brief Starts a print job. @@ -173,16 +46,6 @@ int Fl_Paged_Device::start_job(int pagecount, int *frompage, int *topage) {retur int Fl_Paged_Device::start_page (void) {return 1;} /** - @brief Computes the width and height of the printable area of the page. - - Values are in the same unit as that used by FLTK drawing functions, - are unchanged by calls to origin(), but are changed by scale() calls. - Values account for the user-selected paper type and print orientation. - @return 0 if OK, non-zero if any error - */ -int Fl_Paged_Device::printable_rect(int *w, int *h) {return 1;} - -/** @brief Computes the dimensions of margins that lie between the printable page area and the full page. @@ -195,18 +58,6 @@ int Fl_Paged_Device::printable_rect(int *w, int *h) {return 1;} */ void Fl_Paged_Device::margins(int *left, int *top, int *right, int *bottom) {} -/** - @brief Sets the position in page coordinates of the origin of graphics functions. - - Arguments should be expressed relatively to the result of a previous printable_rect() call. - That is, <tt>printable_rect(&w, &h); origin(w/2, 0);</tt> sets the graphics origin at the - top center of the page printable area. - Origin() calls are not affected by rotate() calls. - Successive origin() calls don't combine their effects. - @param[in] x Horizontal position in page coordinates of the desired origin of graphics functions. - @param[in] y Same as above, vertically. - */ -void Fl_Paged_Device::origin(int x, int y) {} /** @brief Changes the scaling of page coordinates. @@ -242,19 +93,6 @@ int Fl_Paged_Device::end_page (void) {return 1;} */ void Fl_Paged_Device::end_job (void) {} -/** - @brief Translates the current graphics origin accounting for the current rotation. - - This function is only useful after a rotate() call. - Each translate() call must be matched by an untranslate() call. - Successive translate() calls add up their effects. - */ -void Fl_Paged_Device::translate(int x, int y) {} - -/** - @brief Undoes the effect of a previous translate() call. - */ -void Fl_Paged_Device::untranslate(void) {} const Fl_Paged_Device::page_format Fl_Paged_Device::page_formats[NO_PAGE_FORMATS] = { // order of enum Page_Format @@ -297,38 +135,6 @@ const Fl_Paged_Device::page_format Fl_Paged_Device::page_formats[NO_PAGE_FORMATS { 297, 684, "Env10"} // envelope }; -void Fl_Paged_Device::draw_decorated_window(Fl_Window *win, int x_offset, int y_offset) -{ - Fl_Shared_Image *top, *left, *bottom, *right; - win->capture_titlebar_and_borders(top, left, bottom, right); - int wsides = left ? left->w() : 0; - int toph = top ? top->h() : 0; - if (top) { - top->draw(x_offset, y_offset); - top->release(); - } - if (left) { - left->draw(x_offset, y_offset + toph); - left->release(); - } - if (right) { - right->draw(x_offset + wsides + win->w(), y_offset + toph); - right->release(); - } - if (bottom) { - bottom->draw(x_offset, y_offset + toph + win->h()); - bottom->release(); - } - this->print_widget(win, x_offset + wsides, y_offset + toph); -} - -#if !defined(__APPLE__) // PORTME: Fl_Surface_Driver - platform paged device // Mac OS version in Fl_Cocoa.mm -void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) -{ - draw_decorated_window(win, x_offset, y_offset); -} -#endif - // // End of "$Id$". // |
