summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Window_Driver.H8
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H1
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx13
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H2
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx55
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.H1
-rw-r--r--src/drivers/X11/Fl_X11_Window_Driver.cxx17
-rw-r--r--src/fl_scroll_area.cxx90
8 files changed, 101 insertions, 86 deletions
diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H
index 0bcc5eca1..d2d485a52 100644
--- a/FL/Fl_Window_Driver.H
+++ b/FL/Fl_Window_Driver.H
@@ -149,7 +149,13 @@ public:
static void default_icons(const Fl_RGB_Image *icons[], int count);
// --- window printing 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_Shared_Image*& top, Fl_Shared_Image*& left,
+ Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
+#if defined(FL_PORTING)
+# pragma message "FL_PORTING: implement scrolling of the screen contents"
+#endif
+ 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) { return 0; }
};
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index 0e4244ba7..2251391a2 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -98,6 +98,7 @@ public:
//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);
+ 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/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
index c202da51f..0d98ff108 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
@@ -18,7 +18,8 @@
#include "../../config_lib.h"
-#include "Fl_Cocoa_Window_Driver.h"
+#include "Fl_Cocoa_Window_Driver.H"
+#include "../Quartz/Fl_Quartz_Graphics_Driver.H"
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Overlay_Window.H>
#include <FL/fl_draw.H>
@@ -274,6 +275,16 @@ void Fl_Cocoa_Window_Driver::decoration_sizes(int *top, int *left, int *right,
*bottom = 2;
}
+int Fl_Cocoa_Window_Driver::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)
+{
+ CGImageRef img = Fl_X::CGImage_from_window_rect(Fl_Window::current(), src_x, src_y, src_w, src_h);
+ if (img) {
+ ((Fl_Quartz_Graphics_Driver*)fl_graphics_driver)->draw_CGImage(img,dest_x,dest_y,src_w,src_h,0,0,src_w,src_h);
+ CFRelease(img);
+ }
+ return 0;
+}
+
//
// End of "$Id$".
//
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
index a6fa71ec4..3c2b002db 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
@@ -98,6 +98,8 @@ public:
// 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 wait_for_expose();
+ 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/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index 6833b83ec..04c7a8edd 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -625,6 +625,61 @@ void Fl_WinAPI_Window_Driver::decoration_sizes(int *top, int *left, int *right,
*top += GetSystemMetrics(SM_CYCAPTION);
}
+int Fl_WinAPI_Window_Driver::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)
+{
+ typedef int (WINAPI* fl_GetRandomRgn_func)(HDC, HRGN, INT);
+ static fl_GetRandomRgn_func fl_GetRandomRgn = 0L;
+ static char first_time = 1;
+ // We will have to do some Region magic now, so let's see if the
+ // required function is available (and it should be staring w/Win95)
+ if (first_time) {
+ HMODULE hMod = GetModuleHandle("GDI32.DLL");
+ if (hMod) {
+ fl_GetRandomRgn = (fl_GetRandomRgn_func)GetProcAddress(hMod, "GetRandomRgn");
+ }
+ first_time = 0;
+ }
+ // Now check if the source scrolling area is fully visible.
+ // If it is, we will do a quick scroll and just update the
+ // newly exposed area. If it is not, we go the safe route and
+ // re-render the full area instead.
+ // Note 1: we could go and find the areas that are actually
+ // obscured and recursively call fl_scroll for the newly found
+ // rectangles. However, this practice would rely on the
+ // elements of the undocumented Rgn structure.
+ // Note 2: although this method should take care of most
+ // multi-screen solutions, it will not solve issues scrolling
+ // from a different resolution screen onto another.
+ // Note 3: this has been tested with image maps, too.
+ HDC gc = (HDC)fl_graphics_driver->gc();
+ if (fl_GetRandomRgn) {
+ // get the DC region minus all overlapping windows
+ HRGN sys_rgn = CreateRectRgn(0, 0, 0, 0);
+ fl_GetRandomRgn(gc, sys_rgn, 4);
+ // now get the source scrolling rectangle
+ HRGN src_rgn = CreateRectRgn(src_x, src_y, src_x+src_w, src_y+src_h);
+ POINT offset = { 0, 0 };
+ if (GetDCOrgEx(gc, &offset)) {
+ OffsetRgn(src_rgn, offset.x, offset.y);
+ }
+ // see if all source pixels are available in the system region
+ // Note: we could be a bit more merciful and subtract the
+ // scroll destination region as well.
+ HRGN dst_rgn = CreateRectRgn(0, 0, 0, 0);
+ int r = CombineRgn(dst_rgn, src_rgn, sys_rgn, RGN_DIFF);
+ DeleteObject(dst_rgn);
+ DeleteObject(src_rgn);
+ DeleteObject(sys_rgn);
+ if (r != NULLREGION) {
+ return 1;
+ }
+ }
+ // Great, we can do an accelerated scroll instead of re-rendering
+ BitBlt(gc, dest_x, dest_y, src_w, src_h, gc, src_x, src_y,SRCCOPY);
+ return 0;
+}
+
//
// End of "$Id$".
//
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H
index 2c4c432aa..cf71bb935 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.H
+++ b/src/drivers/X11/Fl_X11_Window_Driver.H
@@ -114,6 +114,7 @@ public:
virtual void wait_for_expose();
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 06343fb1b..538a728a6 100644
--- a/src/drivers/X11/Fl_X11_Window_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx
@@ -658,6 +658,23 @@ void Fl_X11_Window_Driver::erase_menu() {
#endif
}
+int Fl_X11_Window_Driver::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)
+{
+ XCopyArea(fl_display, fl_window, fl_window, (GC)fl_graphics_driver->gc(),
+ src_x, src_y, src_w, src_h, dest_x, dest_y);
+ // we have to sync the display and get the GraphicsExpose events! (sigh)
+ for (;;) {
+ XEvent e; XWindowEvent(fl_display, fl_window, ExposureMask, &e);
+ if (e.type == NoExpose) break;
+ // otherwise assume it is a GraphicsExpose event:
+ draw_area(data, e.xexpose.x, e.xexpose.y,
+ e.xexpose.width, e.xexpose.height);
+ if (!e.xgraphicsexpose.count) break;
+ }
+ return 0;
+}
+
//
// End of "$Id$".
//
diff --git a/src/fl_scroll_area.cxx b/src/fl_scroll_area.cxx
index aa63976f7..5c045a72c 100644
--- a/src/fl_scroll_area.cxx
+++ b/src/fl_scroll_area.cxx
@@ -20,13 +20,7 @@
// a "callback" which is called to draw rectangular areas that are moved
// into the drawing area.
-#include <config.h>
-#include <FL/Fl.H>
-#include <FL/x.H>
-#include <FL/fl_draw.H>
-#ifdef __APPLE__
-#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.h"
-#endif
+#include <Fl/Fl_Window_Driver.H>
// scroll a rectangle and redraw the newly exposed portions:
/**
@@ -78,84 +72,12 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
clip_h = H-src_h;
}
-#if defined(USE_X11)
- XCopyArea(fl_display, fl_window, fl_window, (GC)fl_graphics_driver->gc(),
- src_x, src_y, src_w, src_h, dest_x, dest_y);
- // we have to sync the display and get the GraphicsExpose events! (sigh)
- for (;;) {
- XEvent e; XWindowEvent(fl_display, fl_window, ExposureMask, &e);
- if (e.type == NoExpose) break;
- // otherwise assume it is a GraphicsExpose event:
- draw_area(data, e.xexpose.x, e.xexpose.y,
- e.xexpose.width, e.xexpose.height);
- if (!e.xgraphicsexpose.count) break;
- }
-#elif defined(WIN32)
- typedef int (WINAPI* fl_GetRandomRgn_func)(HDC, HRGN, INT);
- static fl_GetRandomRgn_func fl_GetRandomRgn = 0L;
- static char first_time = 1;
-
- // We will have to do some Region magic now, so let's see if the
- // required function is available (and it should be staring w/Win95)
- if (first_time) {
- HMODULE hMod = GetModuleHandle("GDI32.DLL");
- if (hMod) {
- fl_GetRandomRgn = (fl_GetRandomRgn_func)GetProcAddress(hMod, "GetRandomRgn");
- }
- first_time = 0;
- }
-
- // Now check if the source scrolling area is fully visible.
- // If it is, we will do a quick scroll and just update the
- // newly exposed area. If it is not, we go the safe route and
- // re-render the full area instead.
- // Note 1: we could go and find the areas that are actually
- // obscured and recursively call fl_scroll for the newly found
- // rectangles. However, this practice would rely on the
- // elements of the undocumented Rgn structure.
- // Note 2: although this method should take care of most
- // multi-screen solutions, it will not solve issues scrolling
- // from a different resolution screen onto another.
- // Note 3: this has been tested with image maps, too.
- HDC gc = (HDC)fl_graphics_driver->gc();
- if (fl_GetRandomRgn) {
- // get the DC region minus all overlapping windows
- HRGN sys_rgn = CreateRectRgn(0, 0, 0, 0);
- fl_GetRandomRgn(gc, sys_rgn, 4);
- // now get the source scrolling rectangle
- HRGN src_rgn = CreateRectRgn(src_x, src_y, src_x+src_w, src_y+src_h);
- POINT offset = { 0, 0 };
- if (GetDCOrgEx(gc, &offset)) {
- OffsetRgn(src_rgn, offset.x, offset.y);
- }
- // see if all source pixels are available in the system region
- // Note: we could be a bit more merciful and subtract the
- // scroll destination region as well.
- HRGN dst_rgn = CreateRectRgn(0, 0, 0, 0);
- int r = CombineRgn(dst_rgn, src_rgn, sys_rgn, RGN_DIFF);
- DeleteObject(dst_rgn);
- DeleteObject(src_rgn);
- DeleteObject(sys_rgn);
- if (r!=NULLREGION) {
- draw_area(data,X,Y,W,H);
- return;
- }
+ int retval = Fl_Window::current()->driver()->scroll(src_x, src_y, src_w, src_h,
+ dest_x, dest_y, draw_area, data);
+ if (retval) {
+ draw_area(data,X,Y,W,H);
+ return;
}
-
- // Great, we can do an accelerated scroll instead of re-rendering
- BitBlt(gc, dest_x, dest_y, src_w, src_h, gc, src_x, src_y,SRCCOPY);
-
-#elif defined(__APPLE_QUARTZ__) // PORTME: Fl_Graphics_Driver - platform scrolling
- CGImageRef img = Fl_X::CGImage_from_window_rect(Fl_Window::current(), src_x, src_y, src_w, src_h);
- if (img) {
- ((Fl_Quartz_Graphics_Driver*)fl_graphics_driver)->draw_CGImage(img,dest_x,dest_y,src_w,src_h,0,0,src_w,src_h);
- CFRelease(img);
- }
-#elif defined(FL_PORTING)
-# pragma message "FL_PORTING: implement scrolling of the screen contents"
-#else
-# error unsupported platform
-#endif
if (dx) draw_area(data, clip_x, dest_y, clip_w, src_h);
if (dy) draw_area(data, X, clip_y, W, clip_h);
}