New virtual member function bool Fl_Surface_Device::is_current()
This commit is contained in:
parent
22a5dc3085
commit
7a0bebb22f
@ -56,6 +56,7 @@ public:
|
||||
Fl_Copy_Surface(int w, int h);
|
||||
~Fl_Copy_Surface();
|
||||
void set_current();
|
||||
virtual bool is_current();
|
||||
/** Returns the pixel width of the copy surface */
|
||||
int w();
|
||||
/** Returns the pixel height of the copy surface */
|
||||
@ -87,11 +88,10 @@ protected:
|
||||
int height;
|
||||
Fl_Copy_Surface_Driver(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) {}
|
||||
virtual ~Fl_Copy_Surface_Driver() {}
|
||||
virtual void set_current() {}
|
||||
virtual void translate(int x, int y) {}
|
||||
virtual void untranslate() {}
|
||||
int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
|
||||
virtual Fl_RGB_Image *image() {return NULL;}
|
||||
virtual void set_current() = 0;
|
||||
virtual void translate(int x, int y) = 0;
|
||||
virtual void untranslate() = 0;
|
||||
int printable_rect(int *w, int *h);
|
||||
/** Each platform implements this function its own way.
|
||||
It returns an object implementing all virtual functions
|
||||
of class Fl_Copy_Surface_Driver for the plaform.
|
||||
|
@ -77,6 +77,7 @@ protected:
|
||||
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; }
|
||||
public:
|
||||
virtual void set_current(void);
|
||||
virtual bool is_current();
|
||||
/** \brief Sets the graphics driver of this drawing surface. */
|
||||
inline void driver(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver;};
|
||||
/** \brief Returns the graphics driver of this drawing surface. */
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
Fl_Image_Surface(int w, int h, int high_res = 0, Fl_Offscreen off = 0);
|
||||
~Fl_Image_Surface();
|
||||
void set_current();
|
||||
virtual bool is_current();
|
||||
Fl_RGB_Image *image();
|
||||
Fl_Shared_Image *highres_image();
|
||||
void origin(int *x, int *y);
|
||||
@ -106,11 +107,11 @@ protected:
|
||||
int external_offscreen;
|
||||
Fl_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Widget_Surface(NULL), width(w), height(h), offscreen(off) {external_offscreen = (off != 0);}
|
||||
virtual ~Fl_Image_Surface_Driver() {}
|
||||
virtual void set_current() {}
|
||||
virtual void translate(int x, int y) {}
|
||||
virtual void untranslate() {}
|
||||
int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
|
||||
virtual Fl_RGB_Image *image() {return NULL;}
|
||||
virtual void set_current() = 0;
|
||||
virtual void translate(int x, int y) = 0;
|
||||
virtual void untranslate() = 0;
|
||||
int printable_rect(int *w, int *h);
|
||||
virtual Fl_RGB_Image *image() = 0;
|
||||
/** Each platform implements this function its own way.
|
||||
It returns an object implementing all virtual functions
|
||||
of class Fl_Image_Surface_Driver for the plaform.
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
void end_job (void);
|
||||
void draw_decorated_window(Fl_Window *win, int x_offset, int y_offset);
|
||||
void set_current(void);
|
||||
virtual bool is_current();
|
||||
|
||||
/** \name These attributes are useful for the Linux/Unix platform only.
|
||||
\{
|
||||
|
@ -38,6 +38,10 @@ void Fl_Copy_Surface::set_current() {
|
||||
if (platform_surface) platform_surface->set_current();
|
||||
}
|
||||
|
||||
bool Fl_Copy_Surface::is_current() {
|
||||
return surface() == platform_surface;
|
||||
}
|
||||
|
||||
void Fl_Copy_Surface::translate(int x, int y) {
|
||||
if (platform_surface) platform_surface->translate(x, y);
|
||||
}
|
||||
@ -59,6 +63,11 @@ int Fl_Copy_Surface::printable_rect(int *w, int *h) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_Copy_Surface_Driver::printable_rect(int *w, int *h) {
|
||||
*w = width; *h = height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -72,6 +72,10 @@ void Fl_Surface_Device::set_current(void)
|
||||
|
||||
Fl_Surface_Device* Fl_Surface_Device::surface_; // the current target surface of graphics operations
|
||||
|
||||
/** Is this surface the current drawing surface? */
|
||||
bool Fl_Surface_Device::is_current() {
|
||||
return surface_ == this;
|
||||
}
|
||||
|
||||
Fl_Surface_Device::~Fl_Surface_Device()
|
||||
{
|
||||
|
@ -54,6 +54,10 @@ void Fl_Image_Surface::set_current() {
|
||||
if (platform_surface) platform_surface->set_current();
|
||||
}
|
||||
|
||||
bool Fl_Image_Surface::is_current() {
|
||||
return surface() == platform_surface;
|
||||
}
|
||||
|
||||
void Fl_Image_Surface::translate(int x, int y) {
|
||||
if (platform_surface) platform_surface->translate(x, y);
|
||||
}
|
||||
@ -72,6 +76,10 @@ Fl_Offscreen Fl_Image_Surface::offscreen() {
|
||||
|
||||
int Fl_Image_Surface::printable_rect(int *w, int *h) {return platform_surface->printable_rect(w, h);}
|
||||
|
||||
int Fl_Image_Surface_Driver::printable_rect(int *w, int *h) {
|
||||
*w = width; *h = height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Returns an image made of all drawings sent to the Fl_Image_Surface object.
|
||||
The returned object contains its own copy of the RGB data.
|
||||
|
@ -214,6 +214,10 @@ void Fl_Printer::set_current(void)
|
||||
printer->set_current();
|
||||
}
|
||||
|
||||
bool Fl_Printer::is_current() {
|
||||
return surface() == printer;
|
||||
}
|
||||
|
||||
Fl_Printer::~Fl_Printer(void)
|
||||
{
|
||||
delete printer;
|
||||
|
@ -47,6 +47,8 @@ void Fl_Widget_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y)
|
||||
{
|
||||
int old_x, old_y, new_x, new_y, is_window;
|
||||
if ( ! widget->visible() ) return;
|
||||
bool need_push = !is_current();
|
||||
if (need_push) Fl_Surface_Device::push_current(this);
|
||||
is_window = (widget->as_window() != NULL);
|
||||
uchar old_damage = widget->damage();
|
||||
widget->damage(FL_DAMAGE_ALL);
|
||||
@ -87,6 +89,7 @@ void Fl_Widget_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y)
|
||||
}
|
||||
if ((old_damage & FL_DAMAGE_CHILD) == 0) widget->clear_damage(old_damage);
|
||||
else widget->damage(FL_DAMAGE_ALL);
|
||||
if (need_push) Fl_Surface_Device::pop_current();
|
||||
}
|
||||
|
||||
|
||||
@ -150,7 +153,8 @@ void Fl_Widget_Surface::origin(int x, int y) {
|
||||
*/
|
||||
void Fl_Widget_Surface::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y)
|
||||
{
|
||||
Fl_Surface_Device::push_current(Fl_Display_Device::display_device());
|
||||
bool need_push = !Fl_Display_Device::display_device()->is_current();
|
||||
if (need_push) Fl_Surface_Device::push_current(Fl_Display_Device::display_device());
|
||||
Fl_Window *save_front = Fl::first_window();
|
||||
win->show();
|
||||
Fl::check();
|
||||
@ -158,9 +162,12 @@ void Fl_Widget_Surface::print_window_part(Fl_Window *win, int x, int y, int w, i
|
||||
Fl_RGB_Image *img = Fl_Screen_Driver::traverse_to_gl_subwindows(win, x, y, w, h, NULL);
|
||||
if (img) img->scale(w, h, 1, 1);
|
||||
if (save_front != win) save_front->show();
|
||||
Fl_Surface_Device::pop_current();
|
||||
if (need_push) Fl_Surface_Device::pop_current();
|
||||
if (img) {
|
||||
need_push = !is_current();
|
||||
if (need_push) Fl_Surface_Device::push_current(this);
|
||||
img->draw(delta_x, delta_y);
|
||||
if (need_push) Fl_Surface_Device::pop_current();
|
||||
delete img;
|
||||
}
|
||||
}
|
||||
@ -187,6 +194,8 @@ void Fl_Widget_Surface::draw_decorated_window(Fl_Window *win, int win_offset_x,
|
||||
if (win->border() && !win->parent()) {
|
||||
Fl_Window_Driver::driver(win)->capture_titlebar_and_borders(top, left, bottom, right);
|
||||
}
|
||||
bool need_push = !is_current();
|
||||
if (need_push) Fl_Surface_Device::push_current(this);
|
||||
int wsides = left ? left->w() : 0;
|
||||
int toph = top ? top->h() : 0;
|
||||
if (top) {
|
||||
@ -206,6 +215,7 @@ void Fl_Widget_Surface::draw_decorated_window(Fl_Window *win, int win_offset_x,
|
||||
delete bottom;
|
||||
}
|
||||
this->draw(win, win_offset_x + wsides, win_offset_y + toph);
|
||||
if (need_push) Fl_Surface_Device::pop_current();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -37,7 +37,6 @@ protected:
|
||||
void untranslate();
|
||||
int w() {return width;}
|
||||
int h() {return height;}
|
||||
int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
|
||||
};
|
||||
|
||||
|
||||
|
@ -39,7 +39,6 @@ protected:
|
||||
void untranslate();
|
||||
int w() {return width;}
|
||||
int h() {return height;}
|
||||
int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
|
||||
};
|
||||
|
||||
#endif /* Fl_Quartz_Copy_Surface_Driver_H */
|
||||
|
@ -39,7 +39,6 @@ protected:
|
||||
void untranslate();
|
||||
int w() {return width;}
|
||||
int h() {return height;}
|
||||
int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user