summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-01-28 11:51:07 +0000
committerManolo Gouy <Manolo>2016-01-28 11:51:07 +0000
commit1c3c544edf1af6884e4002f04aa28cce4a06fbec (patch)
tree26f72eccf3d60dc04d5026df9678eec7652d33d1
parente2cc1a80f09b7b33665be2ae14ef20673f9d6f7b (diff)
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
-rw-r--r--FL/Fl_Window.H3
-rw-r--r--FL/mac.H1
-rw-r--r--FL/win32.H1
-rw-r--r--FL/x.H1
-rw-r--r--ide/Xcode4/FLTK.xcodeproj/project.pbxproj2
-rw-r--r--src/Fl_Paged_Device.cxx7
-rw-r--r--src/Fl_Window.cxx11
-rw-r--r--src/Fl_cocoa.mm22
-rw-r--r--src/Fl_win32.cxx18
-rw-r--r--src/Fl_x.cxx24
10 files changed, 49 insertions, 41 deletions
diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H
index a8f2515e8..49b511a71 100644
--- a/FL/Fl_Window.H
+++ b/FL/Fl_Window.H
@@ -70,6 +70,7 @@ class FL_EXPORT Fl_Window : public Fl_Group {
int fullscreen_screen_right;
friend class Fl_X;
+ friend class Fl_Paged_Device;
Fl_X *i; // points at the system-specific stuff
struct icon_data {
@@ -97,6 +98,8 @@ class FL_EXPORT Fl_Window : public Fl_Group {
uchar size_range_set;
// cursor stuff
Fl_Cursor cursor_default;
+ // Captures the titlebar and borders of the window, if they exist.
+ void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
protected:
/** Data supporting a non-rectangular window shape */
diff --git a/FL/mac.H b/FL/mac.H
index 586ae918c..528da4a8b 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -187,7 +187,6 @@ public:
void set_icons() {};
int set_cursor(Fl_Cursor);
int set_cursor(const Fl_RGB_Image*, int, int);
- void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h);
diff --git a/FL/win32.H b/FL/win32.H
index c7f689ede..657a66d9f 100644
--- a/FL/win32.H
+++ b/FL/win32.H
@@ -90,7 +90,6 @@ public:
void set_icons();
int set_cursor(Fl_Cursor);
int set_cursor(const Fl_RGB_Image*, int, int);
- void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
static Fl_X* make(Fl_Window*);
};
extern FL_EXPORT UINT fl_wake_msg;
diff --git a/FL/x.H b/FL/x.H
index 5f3d80279..2358ed003 100644
--- a/FL/x.H
+++ b/FL/x.H
@@ -147,7 +147,6 @@ public:
void set_icons();
int set_cursor(Fl_Cursor);
int set_cursor(const Fl_RGB_Image*, int, int);
- void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
static Fl_X* set_xid(Fl_Window*, Window);
// kludges to get around protection:
diff --git a/ide/Xcode4/FLTK.xcodeproj/project.pbxproj b/ide/Xcode4/FLTK.xcodeproj/project.pbxproj
index 385461512..fbc7ab9e1 100644
--- a/ide/Xcode4/FLTK.xcodeproj/project.pbxproj
+++ b/ide/Xcode4/FLTK.xcodeproj/project.pbxproj
@@ -4556,6 +4556,7 @@
7F66B1D712BB924C00C67B59 /* Fl_Native_File_Chooser_MAC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Fl_Native_File_Chooser_MAC.mm; path = ../../src/Fl_Native_File_Chooser_MAC.mm; sourceTree = SOURCE_ROOT; };
7F66B1D812BB924C00C67B59 /* Fl_Quartz_Printer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Fl_Quartz_Printer.mm; path = ../../src/Fl_Quartz_Printer.mm; sourceTree = SOURCE_ROOT; };
7F6F526319CF0FED0075F408 /* Fl_Window_shape.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_Window_shape.cxx; path = ../../src/Fl_Window_shape.cxx; sourceTree = "<group>"; };
+ 7F72C8CE1C5A310D001BCD85 /* Fl_win32.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_win32.cxx; path = ../../src/Fl_win32.cxx; sourceTree = "<group>"; };
7F784151AF1B748D0F3DB1C0 /* forms.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = forms.cxx; path = ../../test/forms.cxx; sourceTree = SOURCE_ROOT; };
7F7CF7F51AB97CEF00E12B22 /* animated.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = animated.app; sourceTree = BUILT_PRODUCTS_DIR; };
7F7CF81E1AB9836C00E12B22 /* animated.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = animated.cxx; path = ../../test/animated.cxx; sourceTree = SOURCE_ROOT; };
@@ -5793,6 +5794,7 @@
D004B2D87C53E063F848C539 /* Fl_lock.cxx */,
AAE8D31DC4F024028C66743C /* Fl_own_colormap.cxx */,
5B2B6ED6A3649923BAAFFDF1 /* Fl_visual.cxx */,
+ 7F72C8CE1C5A310D001BCD85 /* Fl_win32.cxx */,
09A359CA8F522F64BAF6CEAF /* Fl_x.cxx */,
AC0F7C69B25854F609BD1A0C /* cmap.cxx */,
D60CC89D1A70BE6AA3929604 /* filename_absolute.cxx */,
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;