From 1c3c544edf1af6884e4002f04aa28cce4a06fbec Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 28 Jan 2016 11:51:07 +0000 Subject: Added Fl_Window::capture_titlebar_and_borders a new private member function that triggers a warning when FL_PORTING is ON and with a default platform-neutral implementation. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11074 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Paged_Device.cxx | 7 +------ src/Fl_Window.cxx | 11 +++++++++++ src/Fl_cocoa.mm | 22 +++++++++++----------- src/Fl_win32.cxx | 18 +++++++++--------- src/Fl_x.cxx | 24 ++++++++++++------------ 5 files changed, 44 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/Fl_Paged_Device.cxx b/src/Fl_Paged_Device.cxx index c951b4345..0147976d5 100644 --- a/src/Fl_Paged_Device.cxx +++ b/src/Fl_Paged_Device.cxx @@ -301,12 +301,7 @@ const Fl_Paged_Device::page_format Fl_Paged_Device::page_formats[NO_PAGE_FORMATS void Fl_Paged_Device::draw_decorated_window(Fl_Window *win, int x_offset, int y_offset) { Fl_RGB_Image *top, *left, *bottom, *right; -#if defined(FL_PORTING) - top=left=bottom=right=NULL; -# pragma message "FL_PORTING: implement Fl_X::capture_titlebar_and_borders" -#else - Fl_X::i(win)->capture_titlebar_and_borders(top, left, bottom, right); -#endif + win->capture_titlebar_and_borders(top, left, bottom, right); int wsides = left ? left->w() : 0; int toph = top ? top->h() : 0; if (top) { diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 3271b4db6..e54f60d60 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -468,6 +468,17 @@ void Fl_Window::wait_for_expose() { Fl::wait(); } } + +#if defined(FL_PORTING) +# pragma message "FL_PORTING: implement Fl_Window::capture_titlebar_and_borders" +void 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; +} +#endif + +} + #endif // ! __APPLE__ // diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 3e0bbbb44..534323965 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -4378,27 +4378,27 @@ static void draw_layer_to_context(CALayer *layer, CGContextRef gc, int w, int h) /* 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_X::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right) +void Fl_Window::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 = w->decorated_h() - w->h(); - CALayer *layer = get_titlebar_layer(w); + int htop = decorated_h() - h(); + CALayer *layer = get_titlebar_layer(this); CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); - uchar *rgba = new uchar[4 * w->w() * htop]; - CGContextRef auxgc = CGBitmapContextCreate(rgba, w->w(), htop, 8, 4 * w->w(), cspace, kCGImageAlphaPremultipliedLast); + uchar *rgba = new uchar[4 * w() * htop]; + CGContextRef auxgc = CGBitmapContextCreate(rgba, w(), htop, 8, 4 * w(), cspace, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(cspace); - CGRect rect = CGRectMake(0, 0, w->w(), htop); + CGRect rect = CGRectMake(0, 0, w(), htop); if (layer) { - draw_layer_to_context(layer, auxgc, w->w(), htop); + draw_layer_to_context(layer, auxgc, w(), htop); } else { - CGImageRef img = Fl_X::CGImage_from_window_rect(w, 0, -htop, w->w(), htop); + CGImageRef img = Fl_X::CGImage_from_window_rect(this, 0, -htop, w(), htop); CGContextSaveGState(auxgc); - Fl_X::clip_to_rounded_corners(auxgc, w->w(), htop); + Fl_X::clip_to_rounded_corners(auxgc, w(), htop); CGContextDrawImage(auxgc, rect, img); CGContextRestoreGState(auxgc); CFRelease(img); } - top = new Fl_RGB_Image(rgba, w->w(), htop, 4); + top = new Fl_RGB_Image(rgba, w(), htop, 4); top->alloc_array = 1; CGContextRelease(auxgc); } @@ -4451,7 +4451,7 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset) Fl::check(); // capture the window title bar with no title Fl_RGB_Image *top, *left, *bottom, *right; - Fl_X::i(win)->capture_titlebar_and_borders(top, left, bottom, right); + win->capture_titlebar_and_borders(top, left, bottom, right); win->label(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 diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index ea4a43fac..2d4c9d8fc 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -2741,10 +2741,10 @@ int Fl_Window::decorated_h() On the WIN32 platform, this function exploits a feature of fl_read_image() which, when called with NULL first argument and when fl_gc is set to the screen device context, captures the window decoration. */ -void Fl_X::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right) +void Fl_Window::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 (!w->shown() || w->parent() || !w->border() || !w->visible()) return; + if (!shown() || parent() || !border() || !visible()) return; int wsides, hbottom, bt; RECT r = border_width_title_bar_height(w, wsides, hbottom, bt); int htop = bt + hbottom; @@ -2752,11 +2752,11 @@ void Fl_X::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Window save_win = fl_window; Fl_Surface_Device *previous = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); - w->show(); + show(); Fl::check(); - w->make_current(); + make_current(); fl_gc = GetDC(NULL); // get the screen device context - int ww = w->w() + 2 * wsides; + int ww = w() + 2 * wsides; // capture the 4 window sides from screen fl_window = NULL; // force use of read_win_rectangle() by fl_read_image() uchar *rgb; @@ -2766,11 +2766,11 @@ void Fl_X::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, top->alloc_array = 1; } if (wsides) { - rgb = fl_read_image(NULL, r.left, r.top + htop, wsides, w->h()); - left = new Fl_RGB_Image(rgb, wsides, w->h(), 3); + rgb = fl_read_image(NULL, r.left, r.top + htop, wsides, h()); + left = new Fl_RGB_Image(rgb, wsides, h(), 3); left->alloc_array = 1; - rgb = fl_read_image(NULL, r.right - wsides, r.top + htop, wsides, w->h()); - right = new Fl_RGB_Image(rgb, wsides, w->h(), 3); + rgb = fl_read_image(NULL, r.right - wsides, r.top + htop, wsides, h()); + right = new Fl_RGB_Image(rgb, wsides, h(), 3); right->alloc_array = 1; rgb = fl_read_image(NULL, r.left, r.bottom-hbottom, ww, hbottom); bottom = new Fl_RGB_Image(rgb, ww, hbottom, 3); diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index c8a7620eb..bd13607da 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -3029,16 +3029,16 @@ int Fl_Window::decorated_w() On the X11 platform, this function exploits a feature of fl_read_image() which, when called with negative 4th argument, captures the window decoration. */ -void Fl_X::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right) +void Fl_Window::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 (w->decorated_h() == w->h()) return; + if (decorated_h() == h()) return; Window from = fl_window; Fl_Surface_Device *previous = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); - w->show(); + show(); Fl::check(); - w->make_current(); + make_current(); Window root, parent, *children, child_win; unsigned n = 0; int do_it; @@ -3050,19 +3050,19 @@ void Fl_X::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, fl_window = parent; uchar *rgb; if (htop) { - rgb = fl_read_image(NULL, 0, 0, - (w->w() + 2 * wsides), htop); - top = new Fl_RGB_Image(rgb, w->w() + 2 * wsides, htop, 3); + rgb = fl_read_image(NULL, 0, 0, - (w() + 2 * wsides), htop); + top = new Fl_RGB_Image(rgb, w() + 2 * wsides, htop, 3); top->alloc_array = 1; } if (wsides) { - rgb = fl_read_image(NULL, 0, htop, -wsides, w->h()); - left = new Fl_RGB_Image(rgb, wsides, w->h(), 3); + rgb = fl_read_image(NULL, 0, htop, -wsides, h()); + left = new Fl_RGB_Image(rgb, wsides, h(), 3); left->alloc_array = 1; - rgb = fl_read_image(NULL, w->w() + wsides, htop, -wsides, w->h()); - right = new Fl_RGB_Image(rgb, wsides, w->h(), 3); + rgb = fl_read_image(NULL, w() + wsides, htop, -wsides, h()); + right = new Fl_RGB_Image(rgb, wsides, h(), 3); right->alloc_array = 1; - rgb = fl_read_image(NULL, 0, htop + w->h(), -(w->w() + 2*wsides), hbottom); - bottom = new Fl_RGB_Image(rgb, w->w() + 2*wsides, hbottom, 3); + rgb = fl_read_image(NULL, 0, htop + h(), -(w() + 2*wsides), hbottom); + bottom = new Fl_RGB_Image(rgb, w() + 2*wsides, hbottom, 3); bottom->alloc_array = 1; } fl_window = from; -- cgit v1.2.3