summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-05-06 07:14:13 +0000
committerManolo Gouy <Manolo>2018-05-06 07:14:13 +0000
commit5c16dcb65bfd8831a6834589fcfe5d5854386098 (patch)
tree5b1abc66856de9dd36ce65c75467b842969d4289
parentaab1b72af4924293ffc2fa74180480dc9afcc06f (diff)
Simplify Fl_XXX_Window_Driver::capture_titlebar_and_borders() using Fl_Image::scale().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12902 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Window_Driver.H4
-rw-r--r--src/Fl_Widget_Surface.cxx10
-rw-r--r--src/Fl_Window_Driver.cxx2
-rw-r--r--src/Fl_cocoa.mm7
-rw-r--r--src/Fl_win32.cxx17
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm4
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H2
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H2
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.H2
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx21
10 files changed, 30 insertions, 41 deletions
diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H
index 09bd098f4..986989c30 100644
--- a/FL/Fl_Window_Driver.H
+++ b/FL/Fl_Window_Driver.H
@@ -175,8 +175,8 @@ public:
static void default_icons(const Fl_RGB_Image *icons[], int count);
// --- window printing/drawing helper
- virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left,
- Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
+ virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left,
+ Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
#if defined(FL_PORTING)
# pragma message "FL_PORTING: implement scrolling of the screen contents"
#endif
diff --git a/src/Fl_Widget_Surface.cxx b/src/Fl_Widget_Surface.cxx
index f255164fc..d52d9f641 100644
--- a/src/Fl_Widget_Surface.cxx
+++ b/src/Fl_Widget_Surface.cxx
@@ -185,7 +185,7 @@ int Fl_Widget_Surface::printable_rect(int *w, int *h) {return 1;}
*/
void Fl_Widget_Surface::draw_decorated_window(Fl_Window *win, int x_offset, int y_offset)
{
- Fl_Shared_Image *top=0, *left=0, *bottom=0, *right=0;
+ Fl_RGB_Image *top=0, *left=0, *bottom=0, *right=0;
if (win->border() && !win->parent()) {
win->driver()->capture_titlebar_and_borders(top, left, bottom, right);
}
@@ -193,19 +193,19 @@ void Fl_Widget_Surface::draw_decorated_window(Fl_Window *win, int x_offset, int
int toph = top ? top->h() : 0;
if (top) {
top->draw(x_offset, y_offset);
- top->release();
+ delete top;
}
if (left) {
left->draw(x_offset, y_offset + toph);
- left->release();
+ delete left;
}
if (right) {
right->draw(x_offset + wsides + win->w(), y_offset + toph);
- right->release();
+ delete right;
}
if (bottom) {
bottom->draw(x_offset, y_offset + toph + win->h());
- bottom->release();
+ delete bottom;
}
this->draw(win, x_offset + wsides, y_offset + toph);
}
diff --git a/src/Fl_Window_Driver.cxx b/src/Fl_Window_Driver.cxx
index 3cba792c7..f59235971 100644
--- a/src/Fl_Window_Driver.cxx
+++ b/src/Fl_Window_Driver.cxx
@@ -164,7 +164,7 @@ void Fl_Window_Driver::shape_pixmap_(Fl_Image* pixmap) {
delete rgba;
}
-void Fl_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right) {
+void Fl_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right) {
top = left = bottom = right = NULL;
}
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 20c15e857..06c8af91c 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -4332,7 +4332,7 @@ void Fl_Cocoa_Window_Driver::draw_layer_to_context(CALayer *layer, CGContextRef
/* Returns images of the capture of the window title-bar.
On the Mac OS platform, left, bottom and right are returned NULL; top is returned with depth 4.
*/
-void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
+void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
{
left = bottom = right = NULL;
int htop = pWindow->decorated_h() - h();
@@ -4370,9 +4370,8 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top,
CGContextRestoreGState(auxgc);
CFRelease(img);
}
- Fl_RGB_Image *top_rgb = new Fl_RGB_Image(rgba, 2 * scaled_w, 2 * htop, 4);
- top_rgb->alloc_array = 1;
- top = Fl_Shared_Image::get(top_rgb);
+ top = new Fl_RGB_Image(rgba, 2 * scaled_w, 2 * htop, 4);
+ top->alloc_array = 1;
top->scale(w(),htop, s <1 ? 0 : 1, 1);
CGContextRelease(auxgc);
}
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 6d11be0bf..c20db1cdd 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -2673,9 +2673,8 @@ void fl_cleanup_dc_list(void) { // clean up the list
This function exploits a feature of Fl_WinAPI_Screen_Driver::read_win_rectangle() which,
when fl_gc is set to the screen device context, captures the window decoration.
*/
-void Fl_WinAPI_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image *&top, Fl_Shared_Image *&left,
- Fl_Shared_Image *&bottom, Fl_Shared_Image *&right) {
- Fl_RGB_Image *r_top, *r_left, *r_bottom, *r_right;
+void Fl_WinAPI_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image *&top, Fl_RGB_Image *&left,
+ Fl_RGB_Image *&bottom, Fl_RGB_Image *&right) {
top = left = bottom = right = NULL;
if (!shown() || parent() || !border() || !visible())
return;
@@ -2699,18 +2698,14 @@ void Fl_WinAPI_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image *&top
// capture the 4 window sides from screen
Fl_WinAPI_Screen_Driver *dr = (Fl_WinAPI_Screen_Driver *)Fl::screen_driver();
if (htop) {
- r_top = dr->read_win_rectangle_unscaled(r.left, r.top, r.right - r.left, htop);
- top = Fl_Shared_Image::get(r_top);
+ top = dr->read_win_rectangle_unscaled(r.left, r.top, r.right - r.left, htop);
if (scaling != 1)
top->scale(ww, htop / scaling, 0, 1);
}
if (wsides) {
- r_left = dr->read_win_rectangle_unscaled(r.left, r.top + htop, wsides, h() * scaling);
- left = Fl_Shared_Image::get(r_left);
- r_right = dr->read_win_rectangle_unscaled(r.right - wsides, r.top + htop, wsides, h() * scaling);
- right = Fl_Shared_Image::get(r_right);
- r_bottom = dr->read_win_rectangle_unscaled(r.left, r.bottom - hbottom, ww, hbottom);
- bottom = Fl_Shared_Image::get(r_bottom);
+ left = dr->read_win_rectangle_unscaled(r.left, r.top + htop, wsides, h() * scaling);
+ right = dr->read_win_rectangle_unscaled(r.right - wsides, r.top + htop, wsides, h() * scaling);
+ bottom = dr->read_win_rectangle_unscaled(r.left, r.bottom - hbottom, ww, hbottom);
if (scaling != 1) {
left->scale(wsides, h(), 0, 1);
right->scale(wsides, h(), 0, 1);
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
index 4a7a713dd..a69514174 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
+++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
@@ -428,12 +428,12 @@ void Fl_Cocoa_Printer_Driver::draw_decorated_window(Fl_Window *win, int x_offset
win->show();
Fl::check();
// capture the window title bar with no title
- Fl_Shared_Image *top, *left, *bottom, *right;
+ Fl_RGB_Image *top, *left, *bottom, *right;
win->driver()->capture_titlebar_and_borders(top, left, bottom, right);
[(NSWindow*)fl_xid(win) setTitle:title]; // put back the window title
this->set_current(); // back to the Fl_Paged_Device
top->draw(x_offset, y_offset); // print the title bar
- top->release();
+ delete top;
if (win->label()) { // print the window title
const int skip = 65; // approx width of the zone of the 3 window control buttons
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index 256a89a6f..43538c175 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -120,7 +120,7 @@ public:
virtual void shape(const Fl_Image* img);
// that one is implemented in Fl_Cocoa.mm because it uses Objective-c
- virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
+ virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
//this one is in Fl_cocoa.mm because it uses Objective-c
virtual void wait_for_expose();
static void draw_layer_to_context(CALayer *layer, CGContextRef gc, int w, int h);
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
index 83d36e98c..72996db60 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
@@ -116,7 +116,7 @@ public:
virtual void free_icons();
void set_icons(); // driver-internal support function
// this one is implemented in Fl_win32.cxx
- virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
+ virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
virtual int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y,
void (*draw_area)(void*, int,int,int,int), void* data);
static void resize_after_screen_change(void *data);
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H
index 800cc1d40..a3eb304ea 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.H
+++ b/src/drivers/X11/Fl_X11_Window_Driver.H
@@ -137,7 +137,7 @@ public:
virtual void icon(const void * ic);
virtual void free_icons();
void set_icons(); // driver-internal support function
- virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
+ virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
virtual int can_do_overlay();
virtual void redraw_overlay();
virtual int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, void (*draw_area)(void*, int,int,int,int), void* data);
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx
index b89688b47..2e3de7b59 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx
@@ -390,9 +390,8 @@ void Fl_X11_Window_Driver::free_icons() {
This function exploits a feature of Fl_X11_Screen_Driver::read_win_rectangle() which,
when called with negative 4th argument, captures the window decoration.
*/
-void Fl_X11_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
+void Fl_X11_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
{
- Fl_RGB_Image *r_top, *r_left, *r_bottom, *r_right;
top = left = bottom = right = NULL;
if (pWindow->decorated_h() == h()) return;
Window from = fl_window;
@@ -413,24 +412,20 @@ void Fl_X11_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top, F
htop /= s; wsides /= s;
fl_window = parent;
if (htop) {
- r_top = Fl::screen_driver()->read_win_rectangle(0, 0, - (w() + 2 * wsides), htop);
- top = Fl_Shared_Image::get(r_top);
+ top = Fl::screen_driver()->read_win_rectangle(0, 0, - (w() + 2 * wsides), htop);
top->scale(w() + 2 * wsides, htop, 0, 1);
}
if (wsides) {
- r_left = Fl::screen_driver()->read_win_rectangle(0, htop, -wsides, h());
- if (r_left) {
- left = Fl_Shared_Image::get(r_left);
+ left = Fl::screen_driver()->read_win_rectangle(0, htop, -wsides, h());
+ if (left) {
left->scale(wsides, h(), 0, 1);
}
- r_right = Fl::screen_driver()->read_win_rectangle(w() + wsides, htop, -wsides, h());
- if (r_right) {
- right = Fl_Shared_Image::get(r_right);
+ right = Fl::screen_driver()->read_win_rectangle(w() + wsides, htop, -wsides, h());
+ if (right) {
right->scale(wsides, h(), 0, 1);
}
- r_bottom = Fl::screen_driver()->read_win_rectangle(0, htop + h(), -(w() + 2*wsides), hbottom);
- if (r_bottom) {
- bottom = Fl_Shared_Image::get(r_bottom);
+ bottom = Fl::screen_driver()->read_win_rectangle(0, htop + h(), -(w() + 2*wsides), hbottom);
+ if (bottom) {
bottom->scale(w() + 2*wsides, wsides, 0, 1);
} }
fl_window = from;