1998-10-20 00:46:58 +04:00
|
|
|
//
|
2005-02-05 23:28:31 +03:00
|
|
|
// "$Id$"
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2009-01-02 00:28:26 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Double_Window.H>
|
2010-05-27 21:20:18 +04:00
|
|
|
#include <FL/Fl_Printer.H>
|
1998-10-06 23:14:55 +04:00
|
|
|
#include <FL/x.H>
|
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
1998-10-20 00:46:58 +04:00
|
|
|
// On systems that support double buffering "naturally" the base
|
|
|
|
// Fl_Window class will probably do double-buffer and this subclass
|
|
|
|
// does nothing.
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
#if USE_XDBE
|
|
|
|
|
|
|
|
#include <X11/extensions/Xdbe.h>
|
|
|
|
|
|
|
|
static int use_xdbe;
|
|
|
|
|
|
|
|
static int can_xdbe() {
|
|
|
|
static int tried;
|
|
|
|
if (!tried) {
|
|
|
|
tried = 1;
|
|
|
|
int event_base, error_base;
|
|
|
|
if (!XdbeQueryExtension(fl_display, &event_base, &error_base)) return 0;
|
|
|
|
Drawable root = RootWindow(fl_display,fl_screen);
|
|
|
|
int numscreens = 1;
|
|
|
|
XdbeScreenVisualInfo *a = XdbeGetVisualInfo(fl_display,&root,&numscreens);
|
|
|
|
if (!a) return 0;
|
|
|
|
for (int j = 0; j < a->count; j++)
|
|
|
|
if (a->visinfo[j].visual == fl_visual->visualid
|
|
|
|
/*&& a->visinfo[j].perflevel > 0*/) {use_xdbe = 1; break;}
|
|
|
|
XdbeFreeVisualInfo(a);
|
|
|
|
}
|
|
|
|
return use_xdbe;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void Fl_Double_Window::show() {
|
|
|
|
Fl_Window::show();
|
|
|
|
}
|
|
|
|
|
2010-07-09 21:31:33 +04:00
|
|
|
static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
|
|
|
|
|
|
|
|
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
|
|
|
|
if( fl_graphics_driver == fl_display_device->driver()) {
|
|
|
|
fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy);
|
|
|
|
}
|
|
|
|
else { // when copy is not to the display
|
|
|
|
fl_begin_offscreen(pixmap);
|
|
|
|
uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0);
|
|
|
|
fl_end_offscreen();
|
|
|
|
fl_draw_image(img, x, y, w, h, 3, 0);
|
|
|
|
delete img;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 03:44:22 +04:00
|
|
|
#if defined(USE_X11)
|
2008-10-14 03:10:43 +04:00
|
|
|
|
2010-07-09 21:31:33 +04:00
|
|
|
static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
|
|
|
|
XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-14 03:10:43 +04:00
|
|
|
// maybe someone feels inclined to implement alpha blending on X11?
|
|
|
|
char fl_can_do_alpha_blending() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#elif defined(WIN32)
|
1998-10-06 23:14:55 +04:00
|
|
|
|
1998-10-15 18:06:16 +04:00
|
|
|
// Code used to switch output to an off-screen window. See macros in
|
|
|
|
// win32.H which save the old state in local variables.
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2006-09-15 19:35:16 +04:00
|
|
|
typedef struct { BYTE a; BYTE b; BYTE c; BYTE d; } FL_BLENDFUNCTION;
|
|
|
|
typedef BOOL (WINAPI* fl_alpha_blend_func)
|
|
|
|
(HDC,int,int,int,int,HDC,int,int,int,int,FL_BLENDFUNCTION);
|
|
|
|
static fl_alpha_blend_func fl_alpha_blend = NULL;
|
2006-09-17 16:49:19 +04:00
|
|
|
static FL_BLENDFUNCTION blendfunc = { 0, 0, 255, 1};
|
2006-09-15 19:35:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This function checks if the version of MSWindows that we
|
|
|
|
* curently run on supports alpha blending for bitmap transfers
|
|
|
|
* and finds the required function if so.
|
|
|
|
*/
|
|
|
|
char fl_can_do_alpha_blending() {
|
|
|
|
static char been_here = 0;
|
|
|
|
static char can_do = 0;
|
2006-09-17 16:49:19 +04:00
|
|
|
// do this test only once
|
2006-09-15 19:35:16 +04:00
|
|
|
if (been_here) return can_do;
|
2006-09-17 16:49:19 +04:00
|
|
|
been_here = 1;
|
|
|
|
// load the library that implements alpha blending
|
2006-09-15 19:35:16 +04:00
|
|
|
HMODULE hMod = LoadLibrary("MSIMG32.DLL");
|
2006-09-17 16:49:19 +04:00
|
|
|
// give up if that doesn't exist (Win95?)
|
2006-09-15 19:35:16 +04:00
|
|
|
if (!hMod) return 0;
|
2006-09-17 16:49:19 +04:00
|
|
|
// now find the blending function inside that dll
|
2006-09-15 19:35:16 +04:00
|
|
|
fl_alpha_blend = (fl_alpha_blend_func)GetProcAddress(hMod, "AlphaBlend");
|
2006-09-17 16:49:19 +04:00
|
|
|
// give up if we can't find it (Win95)
|
2006-09-15 19:35:16 +04:00
|
|
|
if (!fl_alpha_blend) return 0;
|
2010-01-15 17:29:48 +03:00
|
|
|
// we have the call, but does our display support alpha blending?
|
|
|
|
// get the desktop's device context
|
|
|
|
HDC dc = GetDC(0L);
|
2006-09-17 16:49:19 +04:00
|
|
|
if (!dc) return 0;
|
|
|
|
// check the device capabilities flags. However GetDeviceCaps
|
|
|
|
// does not return anything useful, so we have to do it manually:
|
|
|
|
|
|
|
|
HBITMAP bm = CreateCompatibleBitmap(dc, 1, 1);
|
|
|
|
HDC new_gc = CreateCompatibleDC(dc);
|
|
|
|
int save = SaveDC(new_gc);
|
|
|
|
SelectObject(new_gc, bm);
|
2007-05-14 19:51:00 +04:00
|
|
|
/*COLORREF set = */ SetPixel(new_gc, 0, 0, 0x01010101);
|
2006-09-17 16:49:19 +04:00
|
|
|
BOOL alpha_ok = fl_alpha_blend(dc, 0, 0, 1, 1, new_gc, 0, 0, 1, 1, blendfunc);
|
|
|
|
RestoreDC(new_gc, save);
|
|
|
|
DeleteDC(new_gc);
|
|
|
|
DeleteObject(bm);
|
2010-01-15 17:29:48 +03:00
|
|
|
ReleaseDC(0L, dc);
|
2006-09-17 16:49:19 +04:00
|
|
|
|
|
|
|
if (alpha_ok) can_do = 1;
|
|
|
|
return can_do;
|
2006-09-15 19:35:16 +04:00
|
|
|
}
|
|
|
|
|
1998-10-15 18:06:16 +04:00
|
|
|
HDC fl_makeDC(HBITMAP bitmap) {
|
|
|
|
HDC new_gc = CreateCompatibleDC(fl_gc);
|
|
|
|
SetTextAlign(new_gc, TA_BASELINE|TA_LEFT);
|
|
|
|
SetBkMode(new_gc, TRANSPARENT);
|
1998-10-06 23:14:55 +04:00
|
|
|
#if USE_COLORMAP
|
1998-10-15 18:06:16 +04:00
|
|
|
if (fl_palette) SelectPalette(new_gc, fl_palette, FALSE);
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
1998-10-15 18:06:16 +04:00
|
|
|
SelectObject(new_gc, bitmap);
|
|
|
|
return new_gc;
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
2010-07-09 21:31:33 +04:00
|
|
|
static void fl_copy_offscreen_to_display(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) {
|
2006-09-16 20:02:00 +04:00
|
|
|
HDC new_gc = CreateCompatibleDC(fl_gc);
|
|
|
|
int save = SaveDC(new_gc);
|
|
|
|
SelectObject(new_gc, bitmap);
|
|
|
|
BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
|
|
|
|
RestoreDC(new_gc, save);
|
|
|
|
DeleteDC(new_gc);
|
|
|
|
}
|
2006-09-15 19:35:16 +04:00
|
|
|
|
2006-09-16 20:02:00 +04:00
|
|
|
void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) {
|
1998-10-15 18:06:16 +04:00
|
|
|
HDC new_gc = CreateCompatibleDC(fl_gc);
|
2005-09-13 03:03:34 +04:00
|
|
|
int save = SaveDC(new_gc);
|
1998-10-15 18:06:16 +04:00
|
|
|
SelectObject(new_gc, bitmap);
|
2006-09-17 16:49:19 +04:00
|
|
|
BOOL alpha_ok = 0;
|
|
|
|
// first try to alpha blend
|
2010-05-27 21:20:18 +04:00
|
|
|
// if to printer, always try alpha_blend
|
|
|
|
int to_display = Fl_Surface_Device::surface()->type() == Fl_Display_Device::device_type; // true iff display output
|
|
|
|
if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) {
|
2006-09-17 16:49:19 +04:00
|
|
|
alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc);
|
2010-05-27 21:20:18 +04:00
|
|
|
}
|
2010-03-30 15:18:45 +04:00
|
|
|
// if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1
|
2010-05-27 21:20:18 +04:00
|
|
|
if (!alpha_ok) {
|
2006-09-15 19:35:16 +04:00
|
|
|
BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
|
2010-05-27 21:20:18 +04:00
|
|
|
}
|
2005-09-13 03:03:34 +04:00
|
|
|
RestoreDC(new_gc, save);
|
1998-10-15 18:38:16 +04:00
|
|
|
DeleteDC(new_gc);
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
1998-10-15 18:06:16 +04:00
|
|
|
extern void fl_restore_clip();
|
|
|
|
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
|
|
|
|
2006-09-15 19:35:16 +04:00
|
|
|
char fl_can_do_alpha_blending() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-08-31 04:27:40 +04:00
|
|
|
Fl_Offscreen fl_create_offscreen(int w, int h) {
|
2004-09-01 02:00:49 +04:00
|
|
|
void *data = calloc(w*h,4);
|
2004-08-31 04:27:40 +04:00
|
|
|
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
|
|
|
|
CGContextRef ctx = CGBitmapContextCreate(
|
|
|
|
data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast);
|
|
|
|
CGColorSpaceRelease(lut);
|
|
|
|
return (Fl_Offscreen)ctx;
|
2004-08-25 04:20:27 +04:00
|
|
|
}
|
|
|
|
|
2004-09-01 02:00:49 +04:00
|
|
|
Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) {
|
|
|
|
void *data = calloc(w*h,4);
|
|
|
|
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
|
|
|
|
CGContextRef ctx = CGBitmapContextCreate(
|
|
|
|
data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast);
|
|
|
|
CGColorSpaceRelease(lut);
|
|
|
|
return (Fl_Offscreen)ctx;
|
|
|
|
}
|
|
|
|
|
2010-07-03 14:13:22 +04:00
|
|
|
static void bmProviderRelease (void *src, const void *data, size_t size)
|
|
|
|
{
|
|
|
|
CFIndex count = CFGetRetainCount(src);
|
|
|
|
CFRelease(src);
|
|
|
|
if(count == 1) free((void*)data);
|
|
|
|
}
|
|
|
|
|
2010-07-09 21:31:33 +04:00
|
|
|
static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) {
|
2004-08-31 04:27:40 +04:00
|
|
|
CGContextRef src = (CGContextRef)osrc;
|
|
|
|
void *data = CGBitmapContextGetData(src);
|
|
|
|
int sw = CGBitmapContextGetWidth(src);
|
|
|
|
int sh = CGBitmapContextGetHeight(src);
|
2004-09-01 02:00:49 +04:00
|
|
|
CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src);
|
2004-08-31 04:27:40 +04:00
|
|
|
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
|
2010-07-03 14:13:22 +04:00
|
|
|
// when output goes to a Quartz printercontext, release of the bitmap must be
|
|
|
|
// delayed after the end of the print page
|
|
|
|
CFRetain(src);
|
|
|
|
CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data, sw*sh*4, bmProviderRelease);
|
2004-09-01 02:00:49 +04:00
|
|
|
CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha,
|
2004-08-31 04:27:40 +04:00
|
|
|
src_bytes, 0L, false, kCGRenderingIntentDefault);
|
|
|
|
// fl_push_clip();
|
2006-06-04 14:21:45 +04:00
|
|
|
CGRect rect = { { x, y }, { w, h } };
|
2004-09-01 02:00:49 +04:00
|
|
|
Fl_X::q_begin_image(rect, srcx, srcy, sw, sh);
|
2004-08-31 04:27:40 +04:00
|
|
|
CGContextDrawImage(fl_gc, rect, img);
|
|
|
|
Fl_X::q_end_image();
|
|
|
|
CGImageRelease(img);
|
|
|
|
CGColorSpaceRelease(lut);
|
|
|
|
CGDataProviderRelease(src_bytes);
|
2004-08-25 04:20:27 +04:00
|
|
|
}
|
|
|
|
|
2004-08-31 04:27:40 +04:00
|
|
|
void fl_delete_offscreen(Fl_Offscreen ctx) {
|
|
|
|
if (!ctx) return;
|
|
|
|
void *data = CGBitmapContextGetData((CGContextRef)ctx);
|
2010-07-03 14:13:22 +04:00
|
|
|
CFIndex count = CFGetRetainCount(ctx);
|
2004-08-31 04:27:40 +04:00
|
|
|
CGContextRelease((CGContextRef)ctx);
|
2010-07-03 14:13:22 +04:00
|
|
|
if(count == 1) free(data);
|
2004-08-31 04:27:40 +04:00
|
|
|
}
|
2004-08-25 04:20:27 +04:00
|
|
|
|
2006-06-06 12:00:56 +04:00
|
|
|
const int stack_max = 16;
|
|
|
|
static int stack_ix = 0;
|
|
|
|
static CGContextRef stack_gc[stack_max];
|
|
|
|
static Window stack_window[stack_max];
|
2010-07-09 21:31:33 +04:00
|
|
|
static Fl_Surface_Device *_ss;
|
2004-08-31 04:27:40 +04:00
|
|
|
|
|
|
|
void fl_begin_offscreen(Fl_Offscreen ctx) {
|
2010-07-09 21:31:33 +04:00
|
|
|
_ss = fl_surface;
|
|
|
|
fl_display_device->set_current();
|
2006-06-06 12:00:56 +04:00
|
|
|
if (stack_ix<stack_max) {
|
|
|
|
stack_gc[stack_ix] = fl_gc;
|
|
|
|
stack_window[stack_ix] = fl_window;
|
|
|
|
} else
|
|
|
|
fprintf(stderr, "FLTK CGContext Stack overflow error\n");
|
|
|
|
stack_ix++;
|
|
|
|
|
2004-08-31 04:27:40 +04:00
|
|
|
fl_gc = (CGContextRef)ctx;
|
|
|
|
fl_window = 0;
|
|
|
|
CGContextSaveGState(fl_gc);
|
2010-06-19 19:19:13 +04:00
|
|
|
fl_push_no_clip();
|
2004-08-25 04:20:27 +04:00
|
|
|
}
|
|
|
|
|
2001-11-27 20:44:08 +03:00
|
|
|
void fl_end_offscreen() {
|
2004-08-31 04:27:40 +04:00
|
|
|
Fl_X::q_release_context();
|
2010-06-19 19:19:13 +04:00
|
|
|
fl_pop_clip();
|
2006-06-06 12:00:56 +04:00
|
|
|
if (stack_ix>0)
|
|
|
|
stack_ix--;
|
|
|
|
else
|
|
|
|
fprintf(stderr, "FLTK CGContext Stack underflow error\n");
|
|
|
|
if (stack_ix<stack_max) {
|
|
|
|
fl_gc = stack_gc[stack_ix];
|
|
|
|
fl_window = stack_window[stack_ix];
|
|
|
|
}
|
2010-07-09 21:31:33 +04:00
|
|
|
_ss->set_current();
|
2001-11-27 20:44:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern void fl_restore_clip();
|
|
|
|
|
2008-10-14 03:10:43 +04:00
|
|
|
#else
|
|
|
|
# error unsupported platform
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
|
|
|
|
2008-09-21 22:55:58 +04:00
|
|
|
/**
|
|
|
|
Forces the window to be redrawn.
|
|
|
|
*/
|
1998-11-05 19:04:53 +03:00
|
|
|
void Fl_Double_Window::flush() {flush(0);}
|
|
|
|
|
2008-09-21 22:55:58 +04:00
|
|
|
/**
|
|
|
|
Forces the window to be redrawn.
|
|
|
|
\param[in] eraseoverlay non-zero to erase overlay, zero to ignore
|
|
|
|
|
|
|
|
Fl_Overlay_Window relies on flush(1) copying the back buffer to the
|
|
|
|
front everywhere, even if damage() == 0, thus erasing the overlay,
|
|
|
|
and leaving the clip region set to the entire window.
|
|
|
|
*/
|
1998-11-05 19:04:53 +03:00
|
|
|
void Fl_Double_Window::flush(int eraseoverlay) {
|
1998-10-06 23:14:55 +04:00
|
|
|
make_current(); // make sure fl_gc is non-zero
|
2000-11-20 22:02:20 +03:00
|
|
|
Fl_X *myi = Fl_X::i(this);
|
|
|
|
if (!myi->other_xid) {
|
1998-10-06 23:14:55 +04:00
|
|
|
#if USE_XDBE
|
2007-02-08 23:50:01 +03:00
|
|
|
if (can_xdbe()) {
|
|
|
|
myi->other_xid =
|
|
|
|
XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeCopied);
|
|
|
|
myi->backbuffer_bad = 1;
|
|
|
|
} else
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
2008-10-14 03:10:43 +04:00
|
|
|
#if defined(USE_X11) || defined(WIN32)
|
|
|
|
myi->other_xid = fl_create_offscreen(w(), h());
|
|
|
|
clear_damage(FL_DAMAGE_ALL);
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-12-27 22:16:42 +03:00
|
|
|
if (force_doublebuffering_) {
|
2000-11-20 22:02:20 +03:00
|
|
|
myi->other_xid = fl_create_offscreen(w(), h());
|
2004-12-27 22:16:42 +03:00
|
|
|
clear_damage(FL_DAMAGE_ALL);
|
|
|
|
}
|
2001-12-06 03:17:47 +03:00
|
|
|
#else
|
2008-10-14 03:10:43 +04:00
|
|
|
# error unsupported platform
|
2004-12-27 22:16:42 +03:00
|
|
|
#endif
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
1998-11-05 19:04:53 +03:00
|
|
|
#if USE_XDBE
|
|
|
|
if (use_xdbe) {
|
2010-06-09 12:36:25 +04:00
|
|
|
if (myi->backbuffer_bad || eraseoverlay) {
|
2007-02-08 23:50:01 +03:00
|
|
|
// Make sure we do a complete redraw...
|
2000-11-20 22:02:20 +03:00
|
|
|
if (myi->region) {XDestroyRegion(myi->region); myi->region = 0;}
|
1998-11-05 19:04:53 +03:00
|
|
|
clear_damage(FL_DAMAGE_ALL);
|
2007-02-08 23:50:01 +03:00
|
|
|
myi->backbuffer_bad = 0;
|
1998-11-05 19:04:53 +03:00
|
|
|
}
|
2007-02-08 23:50:01 +03:00
|
|
|
|
|
|
|
// Redraw as needed...
|
1998-11-05 19:04:53 +03:00
|
|
|
if (damage()) {
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_clip_region(myi->region); myi->region = 0;
|
|
|
|
fl_window = myi->other_xid;
|
1998-11-05 19:04:53 +03:00
|
|
|
draw();
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_window = myi->xid;
|
1998-11-05 19:04:53 +03:00
|
|
|
}
|
2007-02-08 23:50:01 +03:00
|
|
|
|
|
|
|
// Copy contents of back buffer to window...
|
|
|
|
XdbeSwapInfo s;
|
|
|
|
s.swap_window = fl_xid(this);
|
|
|
|
s.swap_action = XdbeCopied;
|
|
|
|
XdbeSwapBuffers(fl_display, &s, 1);
|
|
|
|
return;
|
1998-11-05 19:04:53 +03:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if (damage() & ~FL_DAMAGE_EXPOSE) {
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_clip_region(myi->region); myi->region = 0;
|
1998-10-06 23:14:55 +04:00
|
|
|
#ifdef WIN32
|
1998-10-15 18:06:16 +04:00
|
|
|
HDC _sgc = fl_gc;
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_gc = fl_makeDC(myi->other_xid);
|
2005-09-13 03:03:34 +04:00
|
|
|
int save = SaveDC(fl_gc);
|
1998-10-15 18:06:16 +04:00
|
|
|
fl_restore_clip(); // duplicate region into new gc
|
|
|
|
draw();
|
2005-09-13 03:03:34 +04:00
|
|
|
RestoreDC(fl_gc, save);
|
1998-10-15 18:38:16 +04:00
|
|
|
DeleteDC(fl_gc);
|
1998-10-15 18:06:16 +04:00
|
|
|
fl_gc = _sgc;
|
Cairo increment 2: Finer cairo granularity, less deps, new fltk_cairo lib
+ added new USE_CAIRO config preprocessor def.
to differentiate from HAVE_CAIRO so that we can use the cairo lib
without forcing the full fltk lib to be linked against it.
In that case, cairo autolink context functionality which needs fltk lib
instrumentation is disabled.
+ added new --enable-cairoext, which correspond to previous --enable-cairo.
now, --enable-cairo only adds HAVE_CAIRO def. and keeps fltk lib
from referencing cairo.
In both cases (--enable-cairo & --enable-cairoext), a new fltk_cairo lib is
created. This lib, similarly to local versions of png,jpeg and zlib,
is not generated if cairo is not enabled.
+ added cairo to fltk-config : now new --use-cairo flag is available
+ modified all unix like makefiles to now generate minimum cairo deps and also
new libfltk_cairo lib.
+ added new cairo subdir to permit conditional fltk_cairo lib generation.
+ vc2005 project minimum update to compile without be broken, but still needs
to create a similar fltk_cairo independent lib. For now, it works as before
with a dedicated cairo env. similar to --enable-cairoext context in unix.
+ regression tested ok with cairo disabled on win32, mac osx, mingw.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6462 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-10-19 05:42:35 +04:00
|
|
|
//# if defined(USE_CAIRO)
|
2008-09-25 22:26:33 +04:00
|
|
|
//if Fl::cairo_autolink_context() Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
|
|
|
|
//# endif
|
2004-09-01 02:00:49 +04:00
|
|
|
#elif defined(__APPLE__)
|
2001-12-20 08:27:14 +03:00
|
|
|
if ( myi->other_xid ) {
|
|
|
|
fl_begin_offscreen( myi->other_xid );
|
|
|
|
fl_clip_region( 0 );
|
|
|
|
draw();
|
|
|
|
fl_end_offscreen();
|
|
|
|
} else {
|
|
|
|
draw();
|
|
|
|
}
|
1998-10-15 18:06:16 +04:00
|
|
|
#else // X:
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_window = myi->other_xid;
|
1998-10-15 18:06:16 +04:00
|
|
|
draw();
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_window = myi->xid;
|
1998-10-15 18:06:16 +04:00
|
|
|
#endif
|
1998-11-05 19:04:53 +03:00
|
|
|
}
|
|
|
|
if (eraseoverlay) fl_clip_region(0);
|
1998-10-15 18:06:16 +04:00
|
|
|
// on Irix (at least) it is faster to reduce the area copied to
|
|
|
|
// the current clip region:
|
|
|
|
int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
|
2001-12-06 03:17:47 +03:00
|
|
|
if (myi->other_xid) fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y);
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Double_Window::resize(int X,int Y,int W,int H) {
|
|
|
|
int ow = w();
|
|
|
|
int oh = h();
|
|
|
|
Fl_Window::resize(X,Y,W,H);
|
|
|
|
#if USE_XDBE
|
2010-06-09 12:36:25 +04:00
|
|
|
if (use_xdbe) {
|
|
|
|
Fl_X* myi = Fl_X::i(this);
|
|
|
|
if (myi && myi->other_xid && (ow < w() || oh < h())) {
|
|
|
|
// STR #2152: Deallocate the back buffer to force creation of a new one.
|
|
|
|
XdbeDeallocateBackBufferName(fl_display,myi->other_xid);
|
|
|
|
myi->other_xid = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
2000-11-20 22:02:20 +03:00
|
|
|
Fl_X* myi = Fl_X::i(this);
|
|
|
|
if (myi && myi->other_xid && (ow != w() || oh != h())) {
|
|
|
|
fl_delete_offscreen(myi->other_xid);
|
|
|
|
myi->other_xid = 0;
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Double_Window::hide() {
|
2000-11-20 22:02:20 +03:00
|
|
|
Fl_X* myi = Fl_X::i(this);
|
|
|
|
if (myi && myi->other_xid) {
|
1998-10-06 23:14:55 +04:00
|
|
|
#if USE_XDBE
|
|
|
|
if (!use_xdbe)
|
|
|
|
#endif
|
2000-11-20 22:02:20 +03:00
|
|
|
fl_delete_offscreen(myi->other_xid);
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
Fl_Window::hide();
|
|
|
|
}
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
The destructor <I>also deletes all the children</I>. This allows a
|
|
|
|
whole tree to be deleted at once, without having to keep a pointer to
|
|
|
|
all the children in the user code.
|
|
|
|
*/
|
1998-10-06 23:14:55 +04:00
|
|
|
Fl_Double_Window::~Fl_Double_Window() {
|
|
|
|
hide();
|
|
|
|
}
|
1998-10-20 00:46:58 +04:00
|
|
|
|
|
|
|
//
|
2005-02-05 23:28:31 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|