diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 66 | ||||
| -rw-r--r-- | src/Fl_Bitmap.cxx | 134 | ||||
| -rw-r--r-- | src/Fl_Cairo.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_Double_Window.cxx | 106 | ||||
| -rw-r--r-- | src/Fl_Gl_Choice.cxx | 195 | ||||
| -rw-r--r-- | src/Fl_Gl_Window.cxx | 39 | ||||
| -rw-r--r-- | src/Fl_Image.cxx | 76 | ||||
| -rw-r--r-- | src/Fl_Pixmap.cxx | 58 | ||||
| -rw-r--r-- | src/Fl_Widget.cxx | 12 | ||||
| -rw-r--r-- | src/Fl_Window_fullscreen.cxx | 8 | ||||
| -rw-r--r-- | src/Fl_mac.cxx | 11 | ||||
| -rw-r--r-- | src/fl_arci.cxx | 22 | ||||
| -rw-r--r-- | src/fl_color_mac.cxx | 18 | ||||
| -rw-r--r-- | src/fl_draw_image_mac.cxx | 114 | ||||
| -rw-r--r-- | src/fl_font_mac.cxx | 80 | ||||
| -rw-r--r-- | src/fl_line_style.cxx | 79 | ||||
| -rw-r--r-- | src/fl_overlay.cxx | 16 | ||||
| -rw-r--r-- | src/fl_rect.cxx | 358 | ||||
| -rw-r--r-- | src/fl_scroll_area.cxx | 34 | ||||
| -rw-r--r-- | src/fl_vertex.cxx | 64 | ||||
| -rw-r--r-- | src/gl_draw.cxx | 75 | ||||
| -rw-r--r-- | src/gl_start.cxx | 21 |
22 files changed, 472 insertions, 1118 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index 050abe510..3c826e774 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -555,12 +555,12 @@ Fl_X* Fl_X::first; Fl_Window* fl_find(Window xid) { Fl_X *window; for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next) -#ifdef __APPLE_QD__ - if (window->xid == xid && !window->w->window()) { +#if defined(WIN32) || defined(USE_X11) + if (window->xid == xid) { #elif defined(__APPLE_QUARTZ__) if (window->xid == xid && !window->w->window()) { #else - if (window->xid == xid) { +# error unsupported platform #endif // __APPLE__ if (window != Fl_X::first && !Fl::modal()) { // make this window be first to speed up searches @@ -632,19 +632,15 @@ void Fl::flush() { if (i->region) {XDestroyRegion(i->region); i->region = 0;} } } - -#ifdef WIN32 +#if defined(USE_X11) + if (fl_display) XFlush(fl_display); +#elif defined(WIN32) GdiFlush(); -#elif defined(__APPLE_QD__) - GrafPtr port; - GetPort( &port ); - if ( port ) - QDFlushPortBuffer( port, 0 ); #elif defined (__APPLE_QUARTZ__) if (fl_gc) CGContextFlush(fl_gc); #else - if (fl_display) XFlush(fl_display); +# error unsupported platform #endif } @@ -1170,7 +1166,7 @@ void Fl_Window::hide() { fl_throw_focus(this); handle(FL_HIDE); -#ifdef WIN32 +#if defined(WIN32) // this little trick keeps the current clipboard alive, even if we are about // to destroy the window that owns the selection. if (GetClipboardOwner()==ip->xid) { @@ -1192,9 +1188,6 @@ void Fl_Window::hide() { if (Fl::cairo_autolink_context()) Fl::cairo_make_current((Fl_Window*) 0); # endif } -#elif defined(__APPLE_QD__) - if ( ip->xid == fl_window && !parent() ) - fl_window = 0; #elif defined(__APPLE_QUARTZ__) Fl_X::q_release_context(ip); if ( ip->xid == fl_window && !parent() ) @@ -1203,7 +1196,12 @@ void Fl_Window::hide() { if (ip->region) XDestroyRegion(ip->region); -#ifdef WIN32 +#if defined(USE_X11) +# if USE_XFT + fl_destroy_xft_draw(ip->xid); +# endif + XDestroyWindow(fl_display, ip->xid); +#elif defined(WIN32) // this little trickery seems to avoid the popup window stacking problem HWND p = GetForegroundWindow(); if (p==GetParent(ip->xid)) { @@ -1211,15 +1209,10 @@ void Fl_Window::hide() { ShowWindow(p, SW_SHOWNA); } XDestroyWindow(fl_display, ip->xid); -#elif defined(__APPLE_QD__) - MacDestroyWindow(this, ip->xid); #elif defined(__APPLE_QUARTZ__) MacDestroyWindow(this, ip->xid); #else -# if USE_XFT - fl_destroy_xft_draw(ip->xid); -# endif - XDestroyWindow(fl_display, ip->xid); +# error unsupported platform #endif #ifdef WIN32 @@ -1249,12 +1242,12 @@ int Fl_Window::handle(int ev) case FL_SHOW: if (!shown()) show(); else { -#ifdef __APPLE_QD__ - MacMapWindow(this, fl_xid(this)); +#if defined(USE_X11) || defined(WIN32) + XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless #elif defined(__APPLE_QUARTZ__) MacMapWindow(this, fl_xid(this)); #else - XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless +# error unsupported platform #endif // __APPLE__ } break; @@ -1271,13 +1264,13 @@ int Fl_Window::handle(int ev) Fl_Widget* p = parent(); for (;p->visible();p = p->parent()) {} if (p->type() >= FL_WINDOW) break; // don't do the unmap } -#ifdef __APPLE_QD__ - MacUnmapWindow(this, fl_xid(this)); +#if defined(USE_X11) || defined(WIN32) + XUnmapWindow(fl_display, fl_xid(this)); #elif defined(__APPLE_QUARTZ__) MacUnmapWindow(this, fl_xid(this)); #else - XUnmapWindow(fl_display, fl_xid(this)); -#endif // __APPLE__ +# error platform unsupported +#endif } break; } @@ -1418,24 +1411,21 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) { if (wi->damage()) { // if we already have damage we must merge with existing region: if (i->region) { -#ifdef WIN32 +#if defined(USE_X11) + XRectangle R; + R.x = X; R.y = Y; R.width = W; R.height = H; + XUnionRectWithRegion(&R, i->region, i->region); +#elif defined(WIN32) Fl_Region R = XRectangleRegion(X, Y, W, H); CombineRgn(i->region, i->region, R, RGN_OR); XDestroyRegion(R); -#elif defined(__APPLE_QD__) - Fl_Region R = NewRgn(); - SetRectRgn(R, X, Y, X+W, Y+H); - UnionRgn(R, i->region, i->region); - DisposeRgn(R); #elif defined(__APPLE_QUARTZ__) Fl_Region R = NewRgn(); SetRectRgn(R, X, Y, X+W, Y+H); UnionRgn(R, i->region, i->region); DisposeRgn(R); #else - XRectangle R; - R.x = X; R.y = Y; R.width = W; R.height = H; - XUnionRectWithRegion(&R, i->region, i->region); +# error unsupported platform #endif } wi->damage_ |= fl; diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 7eeca6cc3..fc43015b5 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -39,53 +39,7 @@ #include <FL/Fl_Bitmap.H> #include "flstring.h" -#ifdef __APPLE_QD__ // MacOS bitmask functions -Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) { - Rect srcRect; - srcRect.left = 0; srcRect.right = w; - srcRect.top = 0; srcRect.bottom = h; - GrafPtr savePort; - - GetPort(&savePort); // remember the current port - - Fl_Bitmask gw; - NewGWorld( &gw, 1, &srcRect, 0L, 0L, 0 ); - PixMapHandle pm = GetGWorldPixMap( gw ); - if ( pm ) - { - LockPixels( pm ); - if ( *pm ) - { - uchar *base = (uchar*)GetPixBaseAddr( pm ); - if ( base ) - { - PixMapPtr pmp = *pm; - // verify the parameters for direct memory write - if ( pmp->pixelType == 0 || pmp->pixelSize == 1 || pmp->cmpCount == 1 || pmp->cmpSize == 1 ) - { - static uchar reverse[16] = /* Bit reversal lookup table */ - { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff }; - uchar *dst = base; - const uchar *src = array; - int rowBytesSrc = (w+7)>>3 ; - int rowPatch = (pmp->rowBytes&0x3fff) - rowBytesSrc; - for ( int j=0; j<h; j++,dst+=rowPatch ) - for ( int i=0; i<rowBytesSrc; i++,src++ ) - *dst++ = (reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f); - } - } - UnlockPixels( pm ); - } - } - - SetPort(savePort); - return gw; /* tell caller we succeeded! */ -} - -void fl_delete_bitmask(Fl_Bitmask id) { - if (id) DisposeGWorld(id); -} -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) { static uchar reverse[16] = /* Bit reversal lookup table */ { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, @@ -236,54 +190,6 @@ void fl_delete_bitmask(Fl_Bitmask bm) { #endif // __APPLE__ -// MRS: Currently it appears that CopyDeepMask() does not work with an 8-bit alpha mask. -// If you want to test/fix this, uncomment the "#ifdef __APPLE__" and comment out -// the "#if 0" here. Also see Fl_Image.cxx for a similar check... - -//#ifdef __APPLE_QD__ -#if 0 -// Create an 8-bit mask used for alpha blending -Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) { - Rect srcRect; - srcRect.left = 0; srcRect.right = w; - srcRect.top = 0; srcRect.bottom = h; - GrafPtr savePort; - - GetPort(&savePort); // remember the current port - - Fl_Bitmask gw; - NewGWorld( &gw, 8, &srcRect, 0L, 0L, 0 ); - PixMapHandle pm = GetGWorldPixMap( gw ); - if ( pm ) - { - LockPixels( pm ); - if ( *pm ) - { - uchar *base = (uchar*)GetPixBaseAddr( pm ); - if ( base ) - { - PixMapPtr pmp = *pm; - // verify the parameters for direct memory write - if ( pmp->pixelType == 0 || pmp->pixelSize == 8 || pmp->cmpCount == 1 || pmp->cmpSize == 8 ) - { - // Copy alpha values from the source array to the pixmap... - array += d - 1; - int rowoffset = (pmp->rowBytes & 0x3fff) - w; - for (int y = h; y > 0; y --, array += ld, base += rowoffset) { - for (int x = w; x > 0; x --, array += d) { - *base++ = 255 /*255 - *array*/; - } - } - } - } - UnlockPixels( pm ); - } - } - - SetPort(savePort); - return gw; /* tell caller we succeeded! */ -} -#else // Create a 1-bit mask used for alpha blending Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) { Fl_Bitmask mask; @@ -356,7 +262,6 @@ Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) return (mask); } -#endif // __APPLE__ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { if (!array) { @@ -374,7 +279,18 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { if (cy < 0) {H += cy; Y -= cy; cy = 0;} if ((cy+H) > h()) H = h()-cy; if (H <= 0) return; -#ifdef WIN32 + +#if defined(USE_X11) + if (!id) id = fl_create_bitmask(w(), h(), array); + + XSetStipple(fl_display, fl_gc, id); + int ox = X-cx; if (ox < 0) ox += w(); + int oy = Y-cy; if (oy < 0) oy += h(); + XSetTSOrigin(fl_display, fl_gc, ox, oy); + XSetFillStyle(fl_display, fl_gc, FillStippled); + XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H); + XSetFillStyle(fl_display, fl_gc, FillSolid); +#elif defined(WIN32) if (!id) id = fl_create_bitmap(w(), h(), array); HDC tempdc = CreateCompatibleDC(fl_gc); @@ -385,20 +301,6 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L); RestoreDC(tempdc, save); DeleteDC(tempdc); -#elif defined(__APPLE_QD__) - if (!id) id = fl_create_bitmask(w(), h(), array); - GrafPtr dstPort; - GetPort( &dstPort ); - Rect src, dst; - GetPortBounds( (Fl_Offscreen)id, &src ); - SetRect( &src, cx, cy, cx+W, cy+H ); - SetRect( &dst, X, Y, X+W, Y+H ); - CopyBits(GetPortBitMapForCopyBits((Fl_Offscreen)id), // srcBits - GetPortBitMapForCopyBits(dstPort), // dstBits - &src, // src bounds - &dst, // dst bounds - srcOr, // mode - 0L); // mask region #elif defined(__APPLE_QUARTZ__) if (!id) id = fl_create_bitmask(w(), h(), array); if (id && fl_gc) { @@ -408,15 +310,7 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { Fl_X::q_end_image(); } #else - if (!id) id = fl_create_bitmask(w(), h(), array); - - XSetStipple(fl_display, fl_gc, id); - int ox = X-cx; if (ox < 0) ox += w(); - int oy = Y-cy; if (oy < 0) oy += h(); - XSetTSOrigin(fl_display, fl_gc, ox, oy); - XSetFillStyle(fl_display, fl_gc, FillStippled); - XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H); - XSetFillStyle(fl_display, fl_gc, FillSolid); +# error unsupported platform #endif } diff --git a/src/Fl_Cairo.cxx b/src/Fl_Cairo.cxx index dda01f142..eb79c37de 100644 --- a/src/Fl_Cairo.cxx +++ b/src/Fl_Cairo.cxx @@ -79,14 +79,12 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) { gc is an HDC context in WIN32, a CGContext* in Quartz, a display on X11 */ static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) { -# if defined(USE_X11) // X11 +# if defined(USE_X11) return cairo_xlib_surface_create(fl_display, fl_window, fl_visual->visual, W, H); # elif defined(WIN32) return cairo_win32_surface_create((HDC) gc); # elif defined(__APPLE_QUARTZ__) return cairo_quartz_surface_create_for_cg_context((CGContext*) gc, W, H); -# elif defined(__APPLE_QD__) -# error Cairo is not supported under Apple Quickdraw, please use Apple Quartz. # else # error Cairo is not supported under this platform. # endif diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index 37bdd9e96..9264efc86 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -64,7 +64,13 @@ void Fl_Double_Window::show() { Fl_Window::show(); } -#ifdef WIN32 +#if defined(X11) + +// maybe someone feels inclined to implement alpha blending on X11? +char fl_can_do_alpha_blending() { + return 0; +} +#elif defined(WIN32) // Code used to switch output to an off-screen window. See macros in // win32.H which save the old state in local variables. @@ -154,83 +160,6 @@ void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int src extern void fl_restore_clip(); -#elif defined(__APPLE_QD__) - -char fl_can_do_alpha_blending() { - return 0; -} - -GWorldPtr fl_create_offscreen(int w, int h) { - GWorldPtr gw; - Rect bounds; - bounds.left=0; bounds.right=w; bounds.top=0; bounds.bottom=h; - QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, 0); // 'useTempMem' should not be used (says the Carbon port manual) - if ( err == -108 ) - { } -// fl_message( "The application memory is low. Please increase the initial memory assignment.\n" ); - if (err!=noErr || gw==0L) return 0L; - return gw; -} - -void fl_copy_offscreen(int x,int y,int w,int h,GWorldPtr gWorld,int srcx,int srcy) { - Rect src; - if ( !gWorld ) return; - src.top = srcy; src.left = srcx; src.bottom = srcy+h; src.right = srcx+w; - Rect dst; - GrafPtr dstPort; GetPort(&dstPort); - dst.top = y; dst.left = x; dst.bottom = y+h; dst.right = x+w; - RGBColor rgb, oldbg, oldfg; - GetForeColor(&oldfg); - GetBackColor(&oldbg); - rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff; - RGBBackColor( &rgb ); - rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000; - RGBForeColor( &rgb ); - CopyBits(GetPortBitMapForCopyBits(gWorld), GetPortBitMapForCopyBits(dstPort), &src, &dst, srcCopy, 0L); - RGBBackColor(&oldbg); - RGBForeColor(&oldfg); -} - -void fl_delete_offscreen(GWorldPtr gWorld) { - DisposeGWorld(gWorld); -} - -static GrafPtr prevPort; -static GDHandle prevGD; - -void fl_begin_offscreen(GWorldPtr gWorld) { - GetGWorld( &prevPort, &prevGD ); - if ( gWorld ) - { - SetGWorld( gWorld, 0 ); // sets the correct port - PixMapHandle pm = GetGWorldPixMap(gWorld); - Boolean ret = LockPixels(pm); - if ( ret == false ) - { - Rect rect; - GetPortBounds( gWorld, &rect ); - UpdateGWorld( &gWorld, 0, &rect, 0, 0, 0 ); - pm = GetGWorldPixMap( gWorld ); - LockPixels( pm ); - } - fl_window = 0; - } - fl_push_no_clip(); -} - -void fl_end_offscreen() { - GWorldPtr currPort; - GDHandle currGD; - GetGWorld( &currPort, &currGD ); - fl_pop_clip(); - PixMapHandle pm = GetGWorldPixMap(currPort); - UnlockPixels(pm); - SetGWorld( prevPort, prevGD ); - fl_window = GetWindowFromPort( prevPort ); -} - -extern void fl_restore_clip(); - #elif defined(__APPLE_QUARTZ__) char fl_can_do_alpha_blending() { @@ -318,13 +247,8 @@ void fl_end_offscreen() { extern void fl_restore_clip(); -#else // X11 - -// maybe someone feels inclined to implement alpha blending on X11? -char fl_can_do_alpha_blending() { - return 0; -} - +#else +# error unsupported platform #endif /** @@ -351,20 +275,16 @@ void Fl_Double_Window::flush(int eraseoverlay) { myi->backbuffer_bad = 1; } else #endif -#ifdef __APPLE_QD__ - if ( ( !QDIsPortBuffered( GetWindowPort(myi->xid) ) ) - || force_doublebuffering_ ) { - myi->other_xid = fl_create_offscreen(w(), h()); - clear_damage(FL_DAMAGE_ALL); - } +#if defined(USE_X11) || defined(WIN32) + myi->other_xid = fl_create_offscreen(w(), h()); + clear_damage(FL_DAMAGE_ALL); #elif defined(__APPLE_QUARTZ__) if (force_doublebuffering_) { myi->other_xid = fl_create_offscreen(w(), h()); clear_damage(FL_DAMAGE_ALL); } #else - myi->other_xid = fl_create_offscreen(w(), h()); - clear_damage(FL_DAMAGE_ALL); +# error unsupported platform #endif } #if USE_XDBE diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index 7c2787b68..87f87f6ff 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -56,7 +56,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { if (g->mode == m && g->alist == alistp) return g; -# ifdef __APPLE_QD__ +#if defined(USE_X11) const int *blist; int list[32]; @@ -65,45 +65,55 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { else { int n = 0; if (m & FL_INDEX) { - list[n++] = AGL_BUFFER_SIZE; + list[n++] = GLX_BUFFER_SIZE; list[n++] = 8; // glut tries many sizes, but this should work... } else { - list[n++] = AGL_RGBA; - list[n++] = AGL_GREEN_SIZE; + list[n++] = GLX_RGBA; + list[n++] = GLX_GREEN_SIZE; list[n++] = (m & FL_RGB8) ? 8 : 1; if (m & FL_ALPHA) { - list[n++] = AGL_ALPHA_SIZE; + list[n++] = GLX_ALPHA_SIZE; list[n++] = (m & FL_RGB8) ? 8 : 1; } if (m & FL_ACCUM) { - list[n++] = AGL_ACCUM_GREEN_SIZE; + list[n++] = GLX_ACCUM_GREEN_SIZE; list[n++] = 1; if (m & FL_ALPHA) { - list[n++] = AGL_ACCUM_ALPHA_SIZE; + list[n++] = GLX_ACCUM_ALPHA_SIZE; list[n++] = 1; } } } if (m & FL_DOUBLE) { - list[n++] = AGL_DOUBLEBUFFER; + list[n++] = GLX_DOUBLEBUFFER; } if (m & FL_DEPTH) { - list[n++] = AGL_DEPTH_SIZE; list[n++] = 24; + list[n++] = GLX_DEPTH_SIZE; list[n++] = 1; } if (m & FL_STENCIL) { - list[n++] = AGL_STENCIL_SIZE; list[n++] = 1; + list[n++] = GLX_STENCIL_SIZE; list[n++] = 1; } -# ifdef AGL_STEREO if (m & FL_STEREO) { - list[n++] = AGL_STEREO; + list[n++] = GLX_STEREO; + } +# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) + if (m & FL_MULTISAMPLE) { + list[n++] = GLX_SAMPLES_SGIS; + list[n++] = 4; // value Glut uses } # endif - list[n] = AGL_NONE; + list[n] = 0; blist = list; } + fl_open_display(); - AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, (GLint*)blist); - if (!fmt) return 0; + XVisualInfo *visp = glXChooseVisual(fl_display, fl_screen, (int *)blist); + if (!visp) { +# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) + if (m&FL_MULTISAMPLE) return find(m&~FL_MULTISAMPLE,0); +# endif + return 0; + } #elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL @@ -155,67 +165,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, (GLint*)blist); if (!fmt) return 0; -# elif !defined(WIN32) - - const int *blist; - int list[32]; - - if (alistp) - blist = alistp; - else { - int n = 0; - if (m & FL_INDEX) { - list[n++] = GLX_BUFFER_SIZE; - list[n++] = 8; // glut tries many sizes, but this should work... - } else { - list[n++] = GLX_RGBA; - list[n++] = GLX_GREEN_SIZE; - list[n++] = (m & FL_RGB8) ? 8 : 1; - if (m & FL_ALPHA) { - list[n++] = GLX_ALPHA_SIZE; - list[n++] = (m & FL_RGB8) ? 8 : 1; - } - if (m & FL_ACCUM) { - list[n++] = GLX_ACCUM_GREEN_SIZE; - list[n++] = 1; - if (m & FL_ALPHA) { - list[n++] = GLX_ACCUM_ALPHA_SIZE; - list[n++] = 1; - } - } - } - if (m & FL_DOUBLE) { - list[n++] = GLX_DOUBLEBUFFER; - } - if (m & FL_DEPTH) { - list[n++] = GLX_DEPTH_SIZE; list[n++] = 1; - } - if (m & FL_STENCIL) { - list[n++] = GLX_STENCIL_SIZE; list[n++] = 1; - } - if (m & FL_STEREO) { - list[n++] = GLX_STEREO; - } -# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) - if (m & FL_MULTISAMPLE) { - list[n++] = GLX_SAMPLES_SGIS; - list[n++] = 4; // value Glut uses - } -# endif - list[n] = 0; - blist = list; - } - - fl_open_display(); - XVisualInfo *visp = glXChooseVisual(fl_display, fl_screen, (int *)blist); - if (!visp) { -# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) - if (m&FL_MULTISAMPLE) return find(m&~FL_MULTISAMPLE,0); -# endif - return 0; - } - -# else +#elif defined(WIN32) // Replacement for ChoosePixelFormat() that finds one with an overlay // if possible: @@ -250,8 +200,9 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { } //printf("Chosen pixel format is %d\n", pixelformat); if (!pixelformat) return 0; - -# endif +#else +# error platform unsupported +#endif g = new Fl_Gl_Choice; g->mode = m; @@ -259,15 +210,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { g->next = first; first = g; -# ifdef WIN32 - g->pixelformat = pixelformat; - g->pfd = chosen_pfd; -# elif defined(__APPLE_QD__) - g->pixelformat = fmt; -# elif defined(__APPLE_QUARTZ__) - // warning: the Quartz version should probably use Core GL (CGL) instead of AGL - g->pixelformat = fmt; -# else +#if defined(USE_X11) g->vis = visp; if (/*MaxCmapsOfScreen(ScreenOfDisplay(fl_display,fl_screen))==1 && */ @@ -277,6 +220,14 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { else g->colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen), visp->visual, AllocNone); +# elif defined(WIN32) + g->pixelformat = pixelformat; + g->pfd = chosen_pfd; +# elif defined(__APPLE_QUARTZ__) + // warning: the Quartz version should probably use Core GL (CGL) instead of AGL + g->pixelformat = fmt; +# else +# error unsupported platform # endif return g; @@ -309,7 +260,17 @@ static void del_context(GLContext ctx) { if (!nContext) gl_remove_displaylist_fonts(); } -# ifdef WIN32 +#if defined(USE_X11) + +GLContext fl_create_gl_context(XVisualInfo* vis) { + GLContext shared_ctx = context_list ? context_list[0] : 0; + GLContext context = glXCreateContext(fl_display, vis, shared_ctx, 1); + if (context) + add_context(context); + return context; +} + +#elif defined(WIN32) GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { Fl_X* i = Fl_X::i(window); @@ -332,21 +293,6 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay return context; } -# elif defined(__APPLE_QD__) -GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { - GLContext context, shared_ctx = context_list ? context_list[0] : 0; - context = aglCreateContext( g->pixelformat, shared_ctx); - if (!context) return 0; - add_context((GLContext)context); - if ( window->parent() ) { - Rect wrect; GetWindowPortBounds( fl_xid(window), &wrect ); - GLint rect[] = { window->x(), wrect.bottom-window->h()-window->y(), window->w(), window->h() }; - aglSetInteger( (GLContext)context, AGL_BUFFER_RECT, rect ); - aglEnable( (GLContext)context, AGL_BUFFER_RECT ); - } - aglSetDrawable( context, GetWindowPort( fl_xid(window) ) ); - return (context); -} # elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { @@ -364,15 +310,7 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay return (context); } # else - -GLContext fl_create_gl_context(XVisualInfo* vis) { - GLContext shared_ctx = context_list ? context_list[0] : 0; - GLContext context = glXCreateContext(fl_display, vis, shared_ctx, 1); - if (context) - add_context(context); - return context; -} - +# error unsupported platform # endif static GLContext cached_context; @@ -382,17 +320,10 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) { if (context != cached_context || w != cached_window) { cached_context = context; cached_window = w; -# ifdef WIN32 +# if defined(USE_X11) + glXMakeCurrent(fl_display, fl_xid(w), context); +# elif defined(WIN32) wglMakeCurrent(Fl_X::i(w)->private_dc, context); -# elif defined(__APPLE_QD__) - if ( w->parent() ) { //: resize our GL buffer rectangle - Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect ); - GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() }; - aglSetInteger( context, AGL_BUFFER_RECT, rect ); - aglEnable( context, AGL_BUFFER_RECT ); - } - aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); - aglSetCurrentContext(context); # elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL if ( w->parent() ) { //: resize our GL buffer rectangle @@ -404,7 +335,7 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) { aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); aglSetCurrentContext(context); # else - glXMakeCurrent(fl_display, fl_xid(w), context); +# error unsupported platform # endif } } @@ -412,33 +343,31 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) { void fl_no_gl_context() { cached_context = 0; cached_window = 0; -# ifdef WIN32 +# if defined(USE_X11) + glXMakeCurrent(fl_display, 0, 0); +# elif defined(WIN32) wglMakeCurrent(0, 0); -# elif defined(__APPLE_QD__) - aglSetCurrentContext(0); # elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL aglSetCurrentContext(0); # else - glXMakeCurrent(fl_display, 0, 0); +# error unsupported platform # endif } void fl_delete_gl_context(GLContext context) { if (cached_context == context) fl_no_gl_context(); -# ifdef WIN32 +# if defined(USE_X11) + glXDestroyContext(fl_display, context); +# elif defined(WIN32) wglDeleteContext(context); -# elif defined(__APPLE_QD__) - aglSetCurrentContext( NULL ); - aglSetDrawable( context, NULL ); - aglDestroyContext( context ); # elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL aglSetCurrentContext( NULL ); aglSetDrawable( context, NULL ); aglDestroyContext( context ); # else - glXDestroyContext(fl_display, context); +# error unsupported platform # endif del_context(context); } diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx index a6757a2ce..db6fe011d 100644 --- a/src/Fl_Gl_Window.cxx +++ b/src/Fl_Gl_Window.cxx @@ -122,22 +122,23 @@ int Fl_Gl_Window::mode(int m, const int *a) { mode_ = m; alist = a; if (shown()) { g = Fl_Gl_Choice::find(m, a); -#if defined(WIN32) + +#if defined(USE_X11) + // under X, if the visual changes we must make a new X window (yuck!): + if (!g || g->vis->visualid!=oldg->vis->visualid || (oldmode^m)&FL_DOUBLE) { + hide(); + show(); + } +#elif defined(WIN32) if (!g || (oldmode^m)&(FL_DOUBLE|FL_STEREO)) { hide(); show(); } -#elif defined(__APPLE_QD__) - redraw(); #elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL redraw(); #else - // under X, if the visual changes we must make a new X window (yuck!): - if (!g || g->vis->visualid!=oldg->vis->visualid || (oldmode^m)&FL_DOUBLE) { - hide(); - show(); - } +# error unsupported platform #endif } else { g = 0; @@ -224,7 +225,9 @@ void Fl_Gl_Window::ortho() { It is called automatically after the draw() method is called. */ void Fl_Gl_Window::swap_buffers() { -#ifdef WIN32 +#if defined(USE_X11) + glXSwapBuffers(fl_display, fl_xid(this)); +#elif defined(WIN32) # if HAVE_GL_OVERLAY // Do not swap the overlay, to match GLX: BOOL ret = wglSwapLayerBuffers(Fl_X::i(this)->private_dc, WGL_SWAP_MAIN_PLANE); @@ -232,13 +235,11 @@ void Fl_Gl_Window::swap_buffers() { # else SwapBuffers(Fl_X::i(this)->private_dc); # endif -#elif defined(__APPLE_QD__) - aglSwapBuffers((AGLContext)context_); #elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL aglSwapBuffers((AGLContext)context_); #else - glXSwapBuffers(fl_display, fl_xid(this)); +# error unsupported platform #endif } @@ -253,15 +254,7 @@ void Fl_Gl_Window::flush() { uchar save_valid_f = valid_f_; #endif -#ifdef __APPLE_QD__ - //: clear previous clipping in this shared port - GrafPtr port = GetWindowPort( fl_xid(this) ); - Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff ); - GrafPtr old; GetPort( &old ); - SetPort( port ); - ClipRect( &rect ); - SetPort( old ); -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL //: clear previous clipping in this shared port GrafPtr port = GetWindowPort( fl_xid(this) ); @@ -309,9 +302,7 @@ void Fl_Gl_Window::flush() { glDrawBuffer(GL_BACK); if (!SWAP_TYPE) { -#ifdef __APPLE_QD__ - SWAP_TYPE = COPY; -#elif defined __APPLE_QUARTZ__ +#if defined __APPLE_QUARTZ__ // warning: the Quartz version should probably use Core GL (CGL) instead of AGL SWAP_TYPE = COPY; #else diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index ed5ff1dbe..b2385437d 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -482,56 +482,8 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { } #endif } -#ifdef WIN32 - if (mask) { - HDC new_gc = CreateCompatibleDC(fl_gc); - int save = SaveDC(new_gc); - SelectObject(new_gc, (void*)mask); - BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND); - SelectObject(new_gc, (void*)id); - BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT); - RestoreDC(new_gc,save); - DeleteDC(new_gc); - } else if (d()==2 || d()==4) { - fl_copy_offscreen_with_alpha(X, Y, W, H, (Fl_Offscreen)id, cx, cy); - } else { - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); - } -#elif defined(__APPLE_QD__) - if (mask) { - Rect src, dst; - // MRS: STR #114 says we should be using cx, cy, W, and H... -// src.left = 0; src.right = w(); -// src.top = 0; src.bottom = h(); -// dst.left = X; dst.right = X+w(); -// dst.top = Y; dst.bottom = Y+h(); - src.left = cx; src.right = cx+W; - src.top = cy; src.bottom = cy+H; - dst.left = X; dst.right = X+W; - dst.top = Y; dst.bottom = Y+H; - RGBColor rgb; - rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff; - RGBBackColor(&rgb); - rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000; - RGBForeColor(&rgb); - - CopyMask(GetPortBitMapForCopyBits((GrafPtr)id), - GetPortBitMapForCopyBits((GrafPtr)mask), - GetPortBitMapForCopyBits(GetWindowPort(fl_window)), - &src, &src, &dst); - } else if (id) fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); - else { - // Composite image with alpha manually each time... - alpha_blend(this, X, Y, W, H, cx, cy); - } -#elif defined(__APPLE_QUARTZ__) - if (id && fl_gc) { - CGRect rect = { { X, Y }, { W, H } }; - Fl_X::q_begin_image(rect, cx, cy, w(), h()); - CGContextDrawImage(fl_gc, rect, (CGImageRef)id); - Fl_X::q_end_image(); - } -#else + +#if defined(USE_X11) if (id) { if (mask) { // I can't figure out how to combine a mask with existing region, @@ -557,6 +509,30 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { // Composite image with alpha manually each time... alpha_blend(this, X, Y, W, H, cx, cy); } +#elif defined(WIN32) + if (mask) { + HDC new_gc = CreateCompatibleDC(fl_gc); + int save = SaveDC(new_gc); + SelectObject(new_gc, (void*)mask); + BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND); + SelectObject(new_gc, (void*)id); + BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT); + RestoreDC(new_gc,save); + DeleteDC(new_gc); + } else if (d()==2 || d()==4) { + fl_copy_offscreen_with_alpha(X, Y, W, H, (Fl_Offscreen)id, cx, cy); + } else { + fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); + } +#elif defined(__APPLE_QUARTZ__) + if (id && fl_gc) { + CGRect rect = { { X, Y }, { W, H } }; + Fl_X::q_begin_image(rect, cx, cy, w(), h()); + CGContextDrawImage(fl_gc, rect, (CGImageRef)id); + Fl_X::q_end_image(); + } +#else +# error unsupported platform #endif } diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index dd6ba5644..817caba1b 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -118,45 +118,8 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { fl_end_offscreen(); #endif } -#ifdef WIN32 - if (mask) { - HDC new_gc = CreateCompatibleDC(fl_gc); - int save = SaveDC(new_gc); - SelectObject(new_gc, (void*)mask); - BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND); - SelectObject(new_gc, (void*)id); - BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT); - RestoreDC(new_gc,save); - DeleteDC(new_gc); - } else { - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); - } -#elif defined(__APPLE_QD__) - if (mask) { - Rect src, dst; - src.left = cx; src.right = cx+W; - src.top = cy; src.bottom = cy+H; - dst.left = X; dst.right = X+W; - dst.top = Y; dst.bottom = Y+H; - RGBColor rgb, oldfg, oldbg; - GetForeColor(&oldfg); - GetBackColor(&oldbg); - rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff; - RGBBackColor(&rgb); - rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000; - RGBForeColor(&rgb); - CopyMask(GetPortBitMapForCopyBits((GrafPtr)id), - GetPortBitMapForCopyBits((GrafPtr)mask), - GetPortBitMapForCopyBits(GetWindowPort(fl_window)), - &src, &src, &dst); - RGBBackColor(&oldbg); - RGBForeColor(&oldfg); - } else { - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); - } -#elif defined(__APPLE_QUARTZ__) - fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); -#else + +#if defined(USE_X11) if (mask) { // I can't figure out how to combine a mask with existing region, // so cut the image down to a clipped rectangle: @@ -175,6 +138,23 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) { XSetClipOrigin(fl_display, fl_gc, 0, 0); fl_restore_clip(); } +#elif defined(WIN32) + if (mask) { + HDC new_gc = CreateCompatibleDC(fl_gc); + int save = SaveDC(new_gc); + SelectObject(new_gc, (void*)mask); + BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND); + SelectObject(new_gc, (void*)id); + BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT); + RestoreDC(new_gc,save); + DeleteDC(new_gc); + } else { + fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); + } +#elif defined(__APPLE_QUARTZ__) + fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy); +#else +# error unsupported platform #endif } diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 24f3a02ff..b0df5afa0 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -164,7 +164,12 @@ Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const { fl_color(fl_contrast(FL_BLACK, color())); -#if defined(WIN32) || defined(__APPLE_QD__) +#if defined(USE_X11) || defined(__APPLE_QUARTZ__) + fl_line_style(FL_DOT); + fl_rect(X + Fl::box_dx(B), Y + Fl::box_dy(B), + W - Fl::box_dw(B) - 1, H - Fl::box_dh(B) - 1); + fl_line_style(FL_SOLID); +#elif defined(WIN32) // Windows 95/98/ME do not implement the dotted line style, so draw // every other pixel around the focus area... // @@ -183,10 +188,7 @@ Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const { for (xx = W; xx > 0; xx --, i ++) if (i & 1) fl_point(X + xx, Y + H); for (yy = H; yy > 0; yy --, i ++) if (i & 1) fl_point(X, Y + yy); #else - fl_line_style(FL_DOT); - fl_rect(X + Fl::box_dx(B), Y + Fl::box_dy(B), - W - Fl::box_dw(B) - 1, H - Fl::box_dh(B) - 1); - fl_line_style(FL_SOLID); +# error unsupported platform #endif // WIN32 } diff --git a/src/Fl_Window_fullscreen.cxx b/src/Fl_Window_fullscreen.cxx index 03d9798b8..c72e70ec0 100644 --- a/src/Fl_Window_fullscreen.cxx +++ b/src/Fl_Window_fullscreen.cxx @@ -50,15 +50,15 @@ void Fl_Window::border(int b) { if (!border()) return; set_flag(FL_NOBORDER); } -#ifdef WIN32 +#if defined(USE_X11) + if (shown()) Fl_X::i(this)->sendxjunk(); +#elif defined(WIN32) // not yet implemented, but it's possible // for full fullscreen we have to make the window topmost as well -#elif defined(__APPLE_QD__) - // warning: not implemented in Quickdraw/Carbon #elif defined(__APPLE_QUARTZ__) // warning: not implemented in Quartz/Carbon #else - if (shown()) Fl_X::i(this)->sendxjunk(); +# error unsupported platform #endif } diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index f90d95609..e889db4d8 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -680,7 +680,7 @@ static pascal void do_timer(EventLoopTimerRef timer, void* data) */ static double do_queued_events( double time = 0.0 ) { - static bool been_here = 0; + static bool been_here = false; static RgnHandle rgn; // initialize events and a region that enables mouse move events @@ -690,7 +690,7 @@ static double do_queued_events( double time = 0.0 ) GetMouse(&mp); SetRectRgn(rgn, mp.h, mp.v, mp.h, mp.v); SetEventMask(everyEvent); - been_here = 1; + been_here = true; } OSStatus ret; static EventTargetRef target = 0; @@ -1569,15 +1569,8 @@ unsigned short mac2fltk(ulong macKey) void Fl_X::flush() { w->flush(); -#ifdef __APPLE_QD__ - GrafPtr port; - GetPort( &port ); - if ( port ) - QDFlushPortBuffer( port, 0 ); -#elif defined (__APPLE_QUARTZ__) if (fl_gc) CGContextFlush(fl_gc); -#endif SetOrigin( 0, 0 ); } diff --git a/src/fl_arci.cxx b/src/fl_arci.cxx index 69425554c..f3464e34a 100644 --- a/src/fl_arci.cxx +++ b/src/fl_arci.cxx @@ -73,7 +73,10 @@ */ void fl_arc(int x,int y,int w,int h,double a1,double a2) { if (w <= 0 || h <= 0) return; -#ifdef WIN32 + +#if defined(USE_X11) + XDrawArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); +#elif defined(WIN32) int xa = x+w/2+int(w*cos(a1/180.0*M_PI)); int ya = y+h/2-int(h*sin(a1/180.0*M_PI)); int xb = x+w/2+int(w*cos(a2/180.0*M_PI)); @@ -82,10 +85,6 @@ void fl_arc(int x,int y,int w,int h,double a1,double a2) { if (xa == xb && ya == yb) SetPixel(fl_gc, xa, ya, fl_RGB()); else Arc(fl_gc, x, y, x+w, y+h, xa, ya, xb, yb); } else Arc(fl_gc, x, y, x+w, y+h, xa, ya, xb, yb); -#elif defined(__APPLE_QD__) - Rect r; r.left=x; r.right=x+w; r.top=y; r.bottom=y+h; - a1 = a2-a1; a2 = 450-a2; - FrameArc(&r, (short int)a2, (short int)a1); #elif defined(__APPLE_QUARTZ__) a1 = (-a1)/180.0f*M_PI; a2 = (-a2)/180.0f*M_PI; float cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f; @@ -101,7 +100,7 @@ void fl_arc(int x,int y,int w,int h,double a1,double a2) { } CGContextStrokePath(fl_gc); #else - XDrawArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); +# error unsupported platform #endif } @@ -119,7 +118,10 @@ void fl_arc(int x,int y,int w,int h,double a1,double a2) { */ void fl_pie(int x,int y,int w,int h,double a1,double a2) { if (w <= 0 || h <= 0) return; -#ifdef WIN32 + +#if defined(USE_X11) + XFillArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); +#elif defined(WIN32) if (a1 == a2) return; int xa = x+w/2+int(w*cos(a1/180.0*M_PI)); int ya = y+h/2-int(h*sin(a1/180.0*M_PI)); @@ -133,10 +135,6 @@ void fl_pie(int x,int y,int w,int h,double a1,double a2) { SetPixel(fl_gc, xa, ya, fl_RGB()); } else Pie(fl_gc, x, y, x+w, y+h, xa, ya, xb, yb); } else Pie(fl_gc, x, y, x+w, y+h, xa, ya, xb, yb); -#elif defined(__APPLE_QD__) - Rect r; r.left=x; r.right=x+w; r.top=y; r.bottom=y+h; - a1 = a2-a1; a2 = 450-a2; - PaintArc(&r, (short int)a2, (short int)a1); #elif defined(__APPLE_QUARTZ__) a1 = (-a1)/180.0f*M_PI; a2 = (-a2)/180.0f*M_PI; float cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f; @@ -156,7 +154,7 @@ void fl_pie(int x,int y,int w,int h,double a1,double a2) { } CGContextFillPath(fl_gc); #else - XFillArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); +# error unsupported platform #endif } diff --git a/src/fl_color_mac.cxx b/src/fl_color_mac.cxx index 7a472b32e..a179219e6 100644 --- a/src/fl_color_mac.cxx +++ b/src/fl_color_mac.cxx @@ -66,13 +66,7 @@ void fl_color(Fl_Color i) { g = c>>16; b = c>> 8; } -#ifdef __APPLE_QD__ - RGBColor rgb; - rgb.red = (r<<8)|r; - rgb.green = (g<<8)|g; - rgb.blue = (b<<8)|b; - RGBForeColor(&rgb); -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) if (!fl_gc) return; // no context yet? We will assign the color later. float fr = r/255.0f; float fg = g/255.0f; @@ -86,20 +80,14 @@ void fl_color(Fl_Color i) { void fl_color(uchar r, uchar g, uchar b) { fl_color_ = fl_rgb_color(r, g, b); -#ifdef __APPLE_QD__ - RGBColor rgb; - rgb.red = (r<<8)|r; - rgb.green = (g<<8)|g; - rgb.blue = (b<<8)|b; - RGBForeColor(&rgb); -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) float fr = r/255.0f; float fg = g/255.0f; float fb = b/255.0f; CGContextSetRGBFillColor(fl_gc, fr, fg, fb, 1.0f); CGContextSetRGBStrokeColor(fl_gc, fr, fg, fb, 1.0f); #else -# error : neither Quickdraw nor Quartz defined +# error : Quartz not defined #endif } diff --git a/src/fl_draw_image_mac.cxx b/src/fl_draw_image_mac.cxx index fb493b487..d8ccb14b0 100644 --- a/src/fl_draw_image_mac.cxx +++ b/src/fl_draw_image_mac.cxx @@ -56,117 +56,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, { if (!linedelta) linedelta = W*delta; -#ifdef __APPLE_QD__ - // theoretically, if the current GPort permits, we could write - // directly into it, avoiding the temporary GWorld. For now I - // will go the safe way... . - char direct = 0; - GWorldPtr gw; - Rect bounds; - bounds.left=0; bounds.right=W; bounds.top=0; bounds.bottom=H; - QDErr err = NewGWorld( &gw, 32, &bounds, 0L, 0L, useTempMem ); - if (err==noErr && gw) { - PixMapHandle pm = GetGWorldPixMap( gw ); - if ( pm ) { - LockPixels( pm ); - if ( *pm ) { - uchar *base = (uchar*)GetPixBaseAddr( pm ); - if ( base ) { - PixMapPtr pmp = *pm; - // make absolutely sure that we can use a direct memory write to - // create the pixmap! - if ( pmp->pixelType == 16 || pmp->pixelSize == 32 || pmp->cmpCount == 3 || pmp->cmpSize == 8 ) { - int rowBytes = pmp->rowBytes & 0x3fff; - if ( cb ) - { - uchar *tmpBuf = new uchar[ W*delta ]; - if ( mono ) delta -= 1; else delta -= 3; - for ( int i=0; i<H; i++ ) - { - uchar *src = tmpBuf; - uchar *dst = base + i*rowBytes; - cb( userdata, 0, i, W, tmpBuf ); - if ( mono ) { - for ( int j=0; j<W; j++ ) - { uchar c = *src++; *dst++ = 0; *dst++ = c; *dst++ = c; *dst++ = c; src += delta; } - } else { - for ( int j=0; j<W; j++ ) - { *dst++ = 0; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; src += delta; } - } - } - delete[] tmpBuf; - } - else - { - if ( mono ) delta -= 1; else delta -= 3; - for ( int i=0; i<H; i++ ) - { - const uchar *src = buf+i*linedelta; - uchar *dst = base + i*rowBytes; - if ( mono ) { - for ( int j=0; j<W; j++ ) - { uchar c = *src++; *dst++ = 0; *dst++ = c; *dst++ = c; *dst++ = c; src += delta; } - } else { - for ( int j=0; j<W; j++ ) - { *dst++ = 0; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; src += delta; } - } - } - } - - fl_copy_offscreen( X, Y, W, H, gw, 0, 0 ); - direct = 1; - } - } - } - - UnlockPixels( pm ); - } - - DisposeGWorld( gw ); - } - - // great. We were able to write the pixels directly into memory, so we can return now. - if ( direct ) - return; - - // following the very save (and very slow) way to write the image into the give port - if ( cb ) - { - uchar *tmpBuf = new uchar[ W*3 ]; - for ( int i=0; i<H; i++ ) - { - uchar *src = tmpBuf; - cb( userdata, 0, i, W, tmpBuf ); - for ( int j=0; j<W; j++ ) - { - if ( mono ) - { fl_color( src[0], src[0], src[0] ); src++; } - else - { fl_color( src[0], src[1], src[2] ); src+=3; } - MoveTo( X+j, Y+i ); - Line( 0, 0 ); - } - } - delete[] tmpBuf; - } - else - { - for ( int i=0; i<H; i++ ) - { - const uchar *src = buf+i*linedelta; - for ( int j=0; j<W; j++ ) - { - if ( mono ) - fl_color( src[0], src[0], src[0] ); - else - fl_color( src[0], src[1], src[2] ); - MoveTo( X+j, Y+i ); - Line( 0, 0 ); - src += delta; - } - } - } -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) const void *array = buf; uchar *tmpBuf = 0; if (cb) { @@ -245,7 +135,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, } CGContextSetShouldAntialias(fl_gc, true); #else -# error : you must defined __APPLE_QD__ or __APPLE_QUARTZ__ +# error : you must define __APPLE_QUARTZ__ #endif } diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index 8c7f5bfee..c5d04c6ed 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -38,25 +38,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) { # if HAVE_GL listbase = 0; # endif -#if defined(__APPLE_QD__) - knowMetrics = 0; - switch (*name++) { - case 'I': face = italic; break; - case 'P': face = italic | bold; break; - case 'B': face = bold; break; - default: face = 0; break; - } - unsigned char fn[80]; - fn[0] = strlen(name); strcpy((char*)(fn+1), name); - GetFNum(fn, &font); - size = Size; - FMInput fIn = { font, size, face, 0, 0, { 1, 1}, { 1, 1} }; - FMOutput *fOut = FMSwapFont(&fIn); - ascent = fOut->ascent; //: the following three lines give only temporary aproimations - descent = fOut->descent; - for (int i=0; i<256; i++) width[i] = fOut->widMax; - minsize = maxsize = size; -#elif defined(__APPLE_QUARTZ__) + // knowWidths = 0; // OpenGL needs those for its font handling q_name = strdup(name); @@ -130,7 +112,6 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) { // cause ATSU to find a suitable font to render any chars the current font can't do... ATSUSetTransientFontMatching (layout, true); # endif -#endif // defined(__APPLE_QD__) } Fl_Font_Descriptor* fl_fontsize = 0L; @@ -151,33 +132,13 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() { #endif */ if (this == fl_fontsize) fl_fontsize = 0; -#ifdef __APPLE_QUARTZ__ ATSUDisposeTextLayout(layout); ATSUDisposeStyle(style); -#endif } //////////////////////////////////////////////////////////////// static Fl_Fontdesc built_in_table[] = { -#ifdef __APPLE_QD__ -{" Arial"}, -{"BArial"}, -{"IArial"}, -{"PArial"}, -{" Courier New"}, -{"BCourier New"}, -{"ICourier New"}, -{"PCourier New"}, -{" Times New Roman"}, -{"BTimes New Roman"}, -{"ITimes New Roman"}, -{"PTimes New Roman"}, -{" Symbol"}, -{" Chicago"}, -{"BChicago"}, -{" Webdings"}, -#elif defined(__APPLE_QUARTZ__) {"Arial"}, {"Arial Bold"}, {"Arial Italic"}, @@ -194,7 +155,6 @@ static Fl_Fontdesc built_in_table[] = { {"Monaco"}, {"Andale Mono"}, // there is no bold Monaco font on standard Mac {"Webdings"}, -#endif }; static UniChar *utfWbuf = 0; @@ -218,22 +178,7 @@ Fl_Fontdesc* fl_fonts = built_in_table; void fl_font(Fl_Font_Descriptor* s) { fl_fontsize = s; -#ifdef __APPLE_QD__ - if (fl_window) SetPort( GetWindowPort(fl_window) ); - TextFont(fl_fontsize->font); //: select font into current QuickDraw GC - TextFace(fl_fontsize->face); - TextSize(fl_fontsize->size); - if (!fl_fontsize->knowMetrics) { //: get the true metrics for the current GC - //: (fails on multiple monitors with different dpi's!) - FontInfo fi; GetFontInfo(&fi); - fl_fontsize->ascent = fi.ascent; - fl_fontsize->descent = fi.descent; - FMetricRec mr; FontMetrics(&mr); - short *f = (short*)*mr.wTabHandle; //: get the char size table - for (int i=0; i<256; i++) fl_fontsize->width[i] = f[2*i]; - fl_fontsize->knowMetrics = 1; - } -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) // we will use fl_fontsize later to access the required style and layout #else # error : need to defined either Quartz or Quickdraw @@ -281,9 +226,6 @@ int fl_descent() { } double fl_width(const UniChar* txt, int n) { -#ifdef __APPLE_QD__ - return (double)TextWidth( txt, 0, n ); -#else if (!fl_fontsize) { check_default_font(); // avoid a crash! if (!fl_fontsize) @@ -310,7 +252,6 @@ double fl_width(const UniChar* txt, int n) { // If err is OK then return length, else return 0. Or something... int len = FixedToInt(bAfter); return len; -#endif } double fl_width(const char* txt, int n) { @@ -330,18 +271,10 @@ double fl_width(unsigned int wc) { void fl_draw(const char *str, int n, float x, float y); void fl_draw(const char* str, int n, int x, int y) { -#ifdef __APPLE_QD__ - MoveTo(x, y); - DrawText((const char *)str, 0, n); -#elif defined(__APPLE_QUARTZ__) fl_draw(str, n, (float)x-0.0f, (float)y-0.5f); -#endif } void fl_draw(const char *str, int n, float x, float y) { -#ifdef __APPLE_QD__ - fl_draw(str, n, (int)x, (int)y); // FIXME no utf8 rtl impl for QD -#elif defined(__APPLE_QUARTZ__) OSStatus err; // convert to UTF-16 first UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); @@ -358,15 +291,9 @@ void fl_draw(const char *str, int n, float x, float y) { err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n); err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y)); -#else -# error : neither Quartz no Quickdraw chosen -#endif } void fl_rtl_draw(const char* c, int n, int x, int y) { -#if defined __APPLE_QD__ - fl_draw(c, n, x, y); -#elif defined __APPLE_QUARTZ__ // I guess with ATSU the thing to do is force the layout mode to RTL and let ATSU draw the text... double offs = fl_width(c, n); OSStatus err; @@ -383,9 +310,6 @@ void fl_rtl_draw(const char* c, int n, int x, int y) { err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n); err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x-offs), FloatToFixed(y)); -#else -# error : neither Quartz no Quickdraw chosen -#endif } // diff --git a/src/fl_line_style.cxx b/src/fl_line_style.cxx index 908685aa9..222ba8a68 100644 --- a/src/fl_line_style.cxx +++ b/src/fl_line_style.cxx @@ -46,7 +46,39 @@ void fl_quartz_restore_line_style_() { #endif void fl_line_style(int style, int width, char* dashes) { -#ifdef WIN32 + +#if defined(USE_X11) + int ndashes = dashes ? strlen(dashes) : 0; + // emulate the WIN32 dash patterns on X + char buf[7]; + if (!ndashes && (style&0xff)) { + int w = width ? width : 1; + char dash, dot, gap; + // adjust lengths to account for cap: + if (style & 0x200) { + dash = char(2*w); + dot = 1; // unfortunately 0 does not work + gap = char(2*w-1); + } else { + dash = char(3*w); + dot = gap = char(w); + } + char* p = dashes = buf; + switch (style & 0xff) { + case FL_DASH: *p++ = dash; *p++ = gap; break; + case FL_DOT: *p++ = dot; *p++ = gap; break; + case FL_DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; break; + case FL_DASHDOTDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; *p++ = dot; *p++ = gap; break; + } + ndashes = p-buf; + } + static int Cap[4] = {CapButt, CapButt, CapRound, CapProjecting}; + static int Join[4] = {JoinMiter, JoinMiter, JoinRound, JoinBevel}; + XSetLineAttributes(fl_display, fl_gc, width, + ndashes ? LineOnOffDash : LineSolid, + Cap[(style>>8)&3], Join[(style>>12)&3]); + if (ndashes) XSetDashes(fl_display, fl_gc, 0, dashes, ndashes); +#elif defined(WIN32) // According to Bill, the "default" cap and join should be the // "fastest" mode supported for the platform. I don't know why // they should be different (same graphics cards, etc., right?) MRS @@ -71,20 +103,6 @@ void fl_line_style(int style, int width, char* dashes) { DeleteObject(oldpen); DeleteObject(fl_current_xmap->pen); fl_current_xmap->pen = newpen; -#elif defined(__APPLE_QD__) - // QuickDraw supports pen size and pattern, but no arbitrary line styles. - static Pattern styles[] = { - { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }, // FL_SOLID - { { 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f } }, // FL_DASH - { { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 } } // FL_DOT - }; - - if (!width) width = 1; - PenSize(width, width); - - style &= 0xff; - if (style > 2) style = 2; - PenPat(styles + style); #elif defined(__APPLE_QUARTZ__) static enum CGLineCap Cap[4] = { kCGLineCapButt, kCGLineCapButt, kCGLineCapRound, kCGLineCapSquare }; @@ -126,36 +144,7 @@ void fl_line_style(int style, int width, char* dashes) { } fl_quartz_restore_line_style_(); #else - int ndashes = dashes ? strlen(dashes) : 0; - // emulate the WIN32 dash patterns on X - char buf[7]; - if (!ndashes && (style&0xff)) { - int w = width ? width : 1; - char dash, dot, gap; - // adjust lengths to account for cap: - if (style & 0x200) { - dash = char(2*w); - dot = 1; // unfortunately 0 does not work - gap = char(2*w-1); - } else { - dash = char(3*w); - dot = gap = char(w); - } - char* p = dashes = buf; - switch (style & 0xff) { - case FL_DASH: *p++ = dash; *p++ = gap; break; - case FL_DOT: *p++ = dot; *p++ = gap; break; - case FL_DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; break; - case FL_DASHDOTDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; *p++ = dot; *p++ = gap; break; - } - ndashes = p-buf; - } - static int Cap[4] = {CapButt, CapButt, CapRound, CapProjecting}; - static int Join[4] = {JoinMiter, JoinMiter, JoinRound, JoinBevel}; - XSetLineAttributes(fl_display, fl_gc, width, - ndashes ? LineOnOffDash : LineSolid, - Cap[(style>>8)&3], Join[(style>>12)&3]); - if (ndashes) XSetDashes(fl_display, fl_gc, 0, dashes, ndashes); +# error unsupported platform #endif } diff --git a/src/fl_overlay.cxx b/src/fl_overlay.cxx index 8accee16c..a308322ee 100644 --- a/src/fl_overlay.cxx +++ b/src/fl_overlay.cxx @@ -48,24 +48,22 @@ static int bgx, bgy, bgw, bgh; static void draw_current_rect() { #ifdef USE_XOR -# ifdef WIN32 +# if defined(USE_X11) + XSetFunction(fl_display, fl_gc, GXxor); + XSetForeground(fl_display, fl_gc, 0xffffffff); + XDrawRectangle(fl_display, fl_window, fl_gc, px, py, pw, ph); + XSetFunction(fl_display, fl_gc, GXcopy); +# elif defined(WIN32) int old = SetROP2(fl_gc, R2_NOT); fl_rect(px, py, pw, ph); SetROP2(fl_gc, old); -# elif defined(__APPLE_QD__) - PenMode( patXor ); - fl_rect(px, py, pw, ph); - PenMode( patCopy ); # elif defined(__APPLE_QUARTZ__) // warning: Quartz does not support xor drawing // Use the Fl_Overlay_Window instead. fl_color(FL_WHITE); fl_rect(px, py, pw, ph); # else - XSetFunction(fl_display, fl_gc, GXxor); - XSetForeground(fl_display, fl_gc, 0xffffffff); - XDrawRectangle(fl_display, fl_window, fl_gc, px, py, pw, ph); - XSetFunction(fl_display, fl_gc, GXcopy); +# error unsupported platform # endif #else if (bgN) { free(bgN); bgN = 0L; } diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index 71937f507..1edeecce2 100644 --- a/src/fl_rect.cxx +++ b/src/fl_rect.cxx @@ -50,23 +50,21 @@ extern float fl_quartz_line_width_; */ void fl_rect(int x, int y, int w, int h) { if (w<=0 || h<=0) return; -#ifdef WIN32 +#if defined(USE_X11) + XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1); +#elif defined(WIN32) MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x+w-1, y); LineTo(fl_gc, x+w-1, y+h-1); LineTo(fl_gc, x, y+h-1); LineTo(fl_gc, x, y); -#elif defined(__APPLE_QD__) - Rect rect; - SetRect(&rect, x, y, x+w, y+h); - FrameRect(&rect); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGRect rect = CGRectMake(x, y, w-1, h-1); CGContextStrokeRect(fl_gc, rect); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1); +# error unsupported platform #endif } @@ -75,22 +73,20 @@ void fl_rect(int x, int y, int w, int h) { */ void fl_rectf(int x, int y, int w, int h) { if (w<=0 || h<=0) return; -#ifdef WIN32 +#if defined(USE_X11) + if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h); +#elif defined(WIN32) RECT rect; rect.left = x; rect.top = y; rect.right = x + w; rect.bottom = y + h; FillRect(fl_gc, &rect, fl_brush()); -#elif defined(__APPLE_QD__) - Rect rect; - SetRect(&rect, x, y, x+w, y+h); - PaintRect(&rect); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGRect rect = CGRectMake(x, y, w-1, h-1); CGContextFillRect(fl_gc, rect); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h); +# error unsupported platform #endif } @@ -98,10 +94,10 @@ void fl_rectf(int x, int y, int w, int h) { Draw horizontal line from x,y to x1,y */ void fl_xyline(int x, int y, int x1) { -#ifdef WIN32 +#if defined(USE_X11) + XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y); +#elif defined(WIN32) MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1+1, y); -#elif defined(__APPLE_QD__) - MoveTo(x, y); LineTo(x1, y); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -109,7 +105,7 @@ void fl_xyline(int x, int y, int x1) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y); +# error unsupported platform #endif } @@ -117,16 +113,17 @@ void fl_xyline(int x, int y, int x1) { Draw horizontal line from x,y to x1,y, then vertical from x1,y to x1,y2 */ void fl_xyline(int x, int y, int x1, int y2) { -#ifdef WIN32 +#if defined (USE_X11) + XPoint p[3]; + p[0].x = x; p[0].y = p[1].y = y; + p[1].x = p[2].x = x1; p[2].y = y2; + XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); +#elif defined(WIN32) if (y2 < y) y2--; else y2++; MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1, y); LineTo(fl_gc, x1, y2); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x1, y); - LineTo(x1, y2); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -135,10 +132,7 @@ void fl_xyline(int x, int y, int x1, int y2) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XPoint p[3]; - p[0].x = x; p[0].y = p[1].y = y; - p[1].x = p[2].x = x1; p[2].y = y2; - XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); +#error unsupported platform #endif } @@ -147,18 +141,19 @@ void fl_xyline(int x, int y, int x1, int y2) { and then another horizontal from x1,y2 to x3,y2 */ void fl_xyline(int x, int y, int x1, int y2, int x3) { -#ifdef WIN32 +#if defined(USE_X11) + XPoint p[4]; + p[0].x = x; p[0].y = p[1].y = y; + p[1].x = p[2].x = x1; p[2].y = p[3].y = y2; + p[3].x = x3; + XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +#elif defined(WIN32) if(x3 < x1) x3--; else x3++; MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1, y); LineTo(fl_gc, x1, y2); LineTo(fl_gc, x3, y2); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x1, y); - LineTo(x1, y2); - LineTo(x3, y2); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -168,11 +163,7 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XPoint p[4]; - p[0].x = x; p[0].y = p[1].y = y; - p[1].x = p[2].x = x1; p[2].y = p[3].y = y2; - p[3].x = x3; - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +# error unsupported platform #endif } @@ -180,12 +171,12 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) { Draw a vertical line from x,y to x,y1 */ void fl_yxline(int x, int y, int y1) { -#ifdef WIN32 +#if defined(USE_X11) + XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1); +#elif defined(WIN32) if (y1 < y) y1--; else y1++; MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1); -#elif defined(__APPLE_QD__) - MoveTo(x, y); LineTo(x, y1); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -193,7 +184,7 @@ void fl_yxline(int x, int y, int y1) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1); +# error unsupported platform #endif } @@ -201,16 +192,17 @@ void fl_yxline(int x, int y, int y1) { Draw a vertical line from x,y to x,y1 then a horizontal from x,y1 to x2,y1 */ void fl_yxline(int x, int y, int y1, int x2) { -#ifdef WIN32 +#if defined(USE_X11) + XPoint p[3]; + p[0].x = p[1].x = x; p[0].y = y; + p[1].y = p[2].y = y1; p[2].x = x2; + XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); +#elif defined(WIN32) if (x2 > x) x2++; else x2--; MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1); LineTo(fl_gc, x2, y1); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x, y1); - LineTo(x2, y1); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -219,10 +211,7 @@ void fl_yxline(int x, int y, int y1, int x2) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XPoint p[3]; - p[0].x = p[1].x = x; p[0].y = y; - p[1].y = p[2].y = y1; p[2].x = x2; - XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); +# error unsupported platform #endif } @@ -231,18 +220,19 @@ void fl_yxline(int x, int y, int y1, int x2) { then another vertical from x2,y1 to x2,y3 */ void fl_yxline(int x, int y, int y1, int x2, int y3) { -#ifdef WIN32 +#if defined(USE_X11) + XPoint p[4]; + p[0].x = p[1].x = x; p[0].y = y; + p[1].y = p[2].y = y1; p[2].x = p[3].x = x2; + p[3].y = y3; + XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +#elif defined(WIN32) if(y3<y1) y3--; else y3++; MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1); LineTo(fl_gc, x2, y1); LineTo(fl_gc, x2, y3); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x, y1); - LineTo(x2, y1); - LineTo(x2, y3); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -252,11 +242,7 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XPoint p[4]; - p[0].x = p[1].x = x; p[0].y = y; - p[1].y = p[2].y = y1; p[2].x = p[3].x = x2; - p[3].y = y3; - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +# error unsupported platform #endif } @@ -264,15 +250,14 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) { Draw a line from x,y to x1,y1 */ void fl_line(int x, int y, int x1, int y1) { -#ifdef WIN32 +#if defined(USE_X11) + XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1); +#elif defined(WIN32) MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1, y1); // Draw the last point *again* because the GDI line drawing // functions will not draw the last point ("it's a feature!"...) SetPixel(fl_gc, x1, y1, fl_RGB()); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x1, y1); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -280,7 +265,7 @@ void fl_line(int x, int y, int x1, int y1) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1); +# error unsupported platform #endif } @@ -288,17 +273,19 @@ void fl_line(int x, int y, int x1, int y1) { Draw a line from x,y to x1,y1 and another from x1,y1 to x2,y2 */ void fl_line(int x, int y, int x1, int y1, int x2, int y2) { -#ifdef WIN32 +#if defined(USE_X11) + XPoint p[3]; + p[0].x = x; p[0].y = y; + p[1].x = x1; p[1].y = y1; + p[2].x = x2; p[2].y = y2; + XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); +#elif defined(WIN32) MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1, y1); LineTo(fl_gc, x2, y2); // Draw the last point *again* because the GDI line drawing // functions will not draw the last point ("it's a feature!"...) SetPixel(fl_gc, x2, y2, fl_RGB()); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x1, y1); - LineTo(x2, y2); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -307,11 +294,7 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f ) CGContextSetShouldAntialias(fl_gc, true); #else - XPoint p[3]; - p[0].x = x; p[0].y = y; - p[1].x = x1; p[1].y = y1; - p[2].x = x2; p[2].y = y2; - XDrawLines(fl_display, fl_window, fl_gc, p, 3, 0); +# error unsupported platform #endif } @@ -319,16 +302,18 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) { Outline a 3-sided polygon with lines */ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) { -#ifdef WIN32 +#if defined(USE_X11) + XPoint p[4]; + p[0].x = x; p[0].y = y; + p[1].x = x1; p[1].y = y1; + p[2].x = x2; p[2].y = y2; + p[3].x = x; p[3].y = y; + XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +#elif defined(WIN32) MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1, y1); LineTo(fl_gc, x2, y2); LineTo(fl_gc, x, y); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x1, y1); - LineTo(x2, y2); - LineTo(x, y); #elif defined(__APPLE_QUARTZ__) CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); @@ -336,12 +321,7 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) { CGContextClosePath(fl_gc); CGContextStrokePath(fl_gc); #else - XPoint p[4]; - p[0].x = x; p[0].y = y; - p[1].x = x1; p[1].y = y1; - p[2].x = x2; p[2].y = y2; - p[3].x = x; p[3].y = y; - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +# error unsupported platform #endif } @@ -349,18 +329,20 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) { Outline a 4-sided polygon with lines */ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { -#ifdef WIN32 +#if defined(USE_X11) + XPoint p[5]; + p[0].x = x; p[0].y = y; + p[1].x = x1; p[1].y = y1; + p[2].x = x2; p[2].y = y2; + p[3].x = x3; p[3].y = y3; + p[4].x = x; p[4].y = y; + XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0); +#elif defined(WIN32) MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1, y1); LineTo(fl_gc, x2, y2); LineTo(fl_gc, x3, y3); LineTo(fl_gc, x, y); -#elif defined(__APPLE_QD__) - MoveTo(x, y); - LineTo(x1, y1); - LineTo(x2, y2); - LineTo(x3, y3); - LineTo(x, y); #elif defined(__APPLE_QUARTZ__) CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); @@ -369,13 +351,7 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { CGContextClosePath(fl_gc); CGContextStrokePath(fl_gc); #else - XPoint p[5]; - p[0].x = x; p[0].y = y; - p[1].x = x1; p[1].y = y1; - p[2].x = x2; p[2].y = y2; - p[3].x = x3; p[3].y = y3; - p[4].x = x; p[4].y = y; - XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0); +# error unsupported platform #endif } @@ -387,19 +363,13 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) { p[0].x = x; p[0].y = y; p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; -#ifdef WIN32 +#if defined (USE_X11) + p[3].x = x; p[3].y = y; + XFillPolygon(fl_display, fl_window, fl_gc, p, 3, Convex, 0); + XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +#elif defined(WIN32) SelectObject(fl_gc, fl_brush()); Polygon(fl_gc, p, 3); -#elif defined(__APPLE_QD__) - PolyHandle poly = OpenPoly(); - MoveTo(x, y); - LineTo(x1, y1); - LineTo(x2, y2); - LineTo(x, y); - ClosePoly(); - PaintPoly(poly); - FramePoly(poly); - KillPoly(poly); #elif defined(__APPLE_QUARTZ__) CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); @@ -407,9 +377,7 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) { CGContextClosePath(fl_gc); CGContextFillPath(fl_gc); #else - p[3].x = x; p[3].y = y; - XFillPolygon(fl_display, fl_window, fl_gc, p, 3, Convex, 0); - XDrawLines(fl_display, fl_window, fl_gc, p, 4, 0); +# error unsupported platform #endif } @@ -422,20 +390,13 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { p[1].x = x1; p[1].y = y1; p[2].x = x2; p[2].y = y2; p[3].x = x3; p[3].y = y3; -#ifdef WIN32 +#if defined(USE_X11) + p[4].x = x; p[4].y = y; + XFillPolygon(fl_display, fl_window, fl_gc, p, 4, Convex, 0); + XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0); +#elif defined(WIN32) SelectObject(fl_gc, fl_brush()); Polygon(fl_gc, p, 4); -#elif defined(__APPLE_QD__) - PolyHandle poly = OpenPoly(); - MoveTo(x, y); - LineTo(x1, y1); - LineTo(x2, y2); - LineTo(x3, y3); - LineTo(x, y); - ClosePoly(); - PaintPoly(poly); - FramePoly(poly); - KillPoly(poly); #elif defined(__APPLE_QUARTZ__) CGContextMoveToPoint(fl_gc, x, y); CGContextAddLineToPoint(fl_gc, x1, y1); @@ -444,9 +405,7 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { CGContextClosePath(fl_gc); CGContextFillPath(fl_gc); #else - p[4].x = x; p[4].y = y; - XFillPolygon(fl_display, fl_window, fl_gc, p, 4, Convex, 0); - XDrawLines(fl_display, fl_window, fl_gc, p, 5, 0); +# error unsupported platform #endif } @@ -454,10 +413,10 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) { Draw a single pixel at the given coordinates */ void fl_point(int x, int y) { -#ifdef WIN32 +#if defined(USE_X11) + XDrawPoint(fl_display, fl_window, fl_gc, x, y); +#elif defined(WIN32) SetPixel(fl_gc, x, y, fl_RGB()); -#elif defined(__APPLE_QD__) - MoveTo(x, y); Line(0, 0); #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); CGContextMoveToPoint(fl_gc, x, y); @@ -465,7 +424,7 @@ void fl_point(int x, int y) { CGContextStrokePath(fl_gc); if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true); #else - XDrawPoint(fl_display, fl_window, fl_gc, x, y); +# error unsupported platform #endif } @@ -489,51 +448,22 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h) { } #endif -#ifdef __APPLE_QD__ -extern Fl_Region fl_window_region; -#elif defined(__APPLE_QUARTZ__) +#if defined(__APPLE_QUARTZ__) // warning: the Quartz implementation currently uses Quickdraw calls to achieve // clipping. A future version should instead use 'CGContectClipToRect' // and friends. extern Fl_Region fl_window_region; #endif -// undo any clobbering of clip done by your program: +/** Undoes any clobbering of clip done by your program */ void fl_restore_clip() { fl_clip_state_number++; Fl_Region r = rstack[rstackptr]; -#ifdef WIN32 +#if defined(USE_X11) + if (r) XSetRegion(fl_display, fl_gc, r); + else XSetClipMask(fl_display, fl_gc, 0); +#elif defined(WIN32) SelectClipRgn(fl_gc, r); //if r is NULL, clip is automatically cleared -#elif defined(__APPLE_QD__) -# if 1 - // This code is required to allow true subwindows to work on Mac. - // During regular operation however, this seems overkill. - // See also: Fl_Window::make_current() - if ( fl_window ) { - GrafPtr port = GetWindowPort( fl_window ); - if ( port ) { // port will be NULL if we are using a GWorld (and fl_window_region is invalid) - RgnHandle portClip = NewRgn(); - CopyRgn( fl_window_region, portClip ); // changed - if ( r ) - SectRgn( portClip, r, portClip ); - SetPortClipRegion( port, portClip ); - DisposeRgn( portClip ); - } - } else { - if (r) - SetClip(r); - else { - Rect rect; rect.left=0; rect.top=0; rect.right=0x7fff; rect.bottom=0x7fff; - ClipRect(&rect); - } - } -# else - if (r) SetClip(r); - else { - Rect rect; rect.left=0; rect.top=0; rect.right=0x7fff; rect.bottom=0x7fff; - ClipRect(&rect); - } -# endif #elif defined(__APPLE_QUARTZ__) if ( fl_window ) // clipping for a true window { @@ -561,8 +491,7 @@ void fl_restore_clip() { Fl_X::q_fill_context(); } #else - if (r) XSetRegion(fl_display, fl_gc, r); - else XSetClipMask(fl_display, fl_gc, 0); +# error unsupported platform #endif } @@ -596,30 +525,29 @@ void fl_push_clip(int x, int y, int w, int h) { r = XRectangleRegion(x,y,w,h); Fl_Region current = rstack[rstackptr]; if (current) { -#ifdef WIN32 - CombineRgn(r,r,current,RGN_AND); -#elif defined(__APPLE_QD__) - SectRgn(r, current, r); -#elif defined(__APPLE_QUARTZ__) - SectRgn(r, current, r); -#else +#if defined(USE_X11) Fl_Region temp = XCreateRegion(); XIntersectRegion(current, r, temp); XDestroyRegion(r); r = temp; +#elif defined(WIN32) + CombineRgn(r,r,current,RGN_AND); +#elif defined(__APPLE_QUARTZ__) + SectRgn(r, current, r); +#else +# error unsupported platform #endif } } else { // make empty clip region: -#ifdef WIN32 +#if defined(USE_X11) + r = XCreateRegion(); +#elif defined(WIN32) r = CreateRectRgn(0,0,0,0); -#elif defined(__APPLE_QD__) - r = NewRgn(); - SetEmptyRgn(r); #elif defined(__APPLE_QUARTZ__) r = NewRgn(); SetEmptyRgn(r); #else - r = XCreateRegion(); +# error unsupported platform #endif } if (rstackptr < STACK_MAX) rstack[++rstackptr] = r; @@ -665,23 +593,20 @@ void fl_pop_clip() { int fl_not_clipped(int x, int y, int w, int h) { if (x+w <= 0 || y+h <= 0) return 0; Fl_Region r = rstack[rstackptr]; -#ifdef WIN32 +#if defined (USE_X11) + return r ? XRectInRegion(r, x, y, w, h) : 1; +#elif defined(WIN32) if (!r) return 1; RECT rect; rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h; return RectInRegion(r,&rect); -#elif defined(__APPLE_QD__) - if (!r) return 1; - Rect rect; - rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h; - return RectInRgn(&rect, r); #elif defined(__APPLE_QUARTZ__) if (!r) return 1; Rect rect; rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h; return RectInRgn(&rect, r); #else - return r ? XRectInRegion(r, x, y, w, h) : 1; +# error unsupported platform #endif } @@ -703,7 +628,26 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ X = x; Y = y; W = w; H = h; Fl_Region r = rstack[rstackptr]; if (!r) return 0; -#ifdef WIN32 +#if defined(USE_X11) + switch (XRectInRegion(r, x, y, w, h)) { + case 0: // completely outside + W = H = 0; + return 2; + case 1: // completely inside: + return 0; + default: // partial: + break; + } + Fl_Region rr = XRectangleRegion(x,y,w,h); + Fl_Region temp = XCreateRegion(); + XIntersectRegion(r, rr, temp); + XRectangle rect; + XClipBox(temp, &rect); + X = rect.x; Y = rect.y; W = rect.width; H = rect.height; + XDestroyRegion(temp); + XDestroyRegion(rr); + return 1; +#elif defined(WIN32) // The win32 API makes no distinction between partial and complete // intersection, so we have to check for partial intersection ourselves. // However, given that the regions may be composite, we have to do @@ -725,19 +669,6 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ DeleteObject(temp); DeleteObject(rr); return ret; -#elif defined(__APPLE_QD__) - RgnHandle rr = NewRgn(); - SetRectRgn( rr, x, y, x+w, y+h ); - SectRgn( r, rr, rr ); - Rect rp; GetRegionBounds(rr, &rp); - X = rp.left; - Y = rp.top; - W = rp.right - X; - H = rp.bottom - Y; - DisposeRgn( rr ); - if ( H==0 ) return 2; - if ( h==H && w==W ) return 0; - return 0; #elif defined(__APPLE_QUARTZ__) RgnHandle rr = NewRgn(); SetRectRgn( rr, x, y, x+w, y+h ); @@ -752,24 +683,7 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){ if ( h==H && w==W ) return 0; return 0; #else - switch (XRectInRegion(r, x, y, w, h)) { - case 0: // completely outside - W = H = 0; - return 2; - case 1: // completely inside: - return 0; - default: // partial: - break; - } - Fl_Region rr = XRectangleRegion(x,y,w,h); - Fl_Region temp = XCreateRegion(); - XIntersectRegion(r, rr, temp); - XRectangle rect; - XClipBox(temp, &rect); - X = rect.x; Y = rect.y; W = rect.width; H = rect.height; - XDestroyRegion(temp); - XDestroyRegion(rr); - return 1; +# error unsupported platform #endif } diff --git a/src/fl_scroll_area.cxx b/src/fl_scroll_area.cxx index 0fa807bf2..fbb37d51f 100644 --- a/src/fl_scroll_area.cxx +++ b/src/fl_scroll_area.cxx @@ -72,7 +72,20 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy, clip_y = Y+src_h; clip_h = H-src_h; } -#ifdef WIN32 + +#if defined(USE_X11) + XCopyArea(fl_display, fl_window, fl_window, fl_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 assumme 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; @@ -126,13 +139,6 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy, // Great, we can do an accelerated scroll insteasd of re-rendering BitBlt(fl_gc, dest_x, dest_y, src_w, src_h, fl_gc, src_x, src_y,SRCCOPY); -#elif defined(__APPLE_QD__) - Rect src = { src_y, src_x, src_y+src_h, src_x+src_w }; - Rect dst = { dest_y, dest_x, dest_y+src_h, dest_x+src_w }; - static RGBColor bg = { 0xffff, 0xffff, 0xffff }; RGBBackColor( &bg ); - static RGBColor fg = { 0x0000, 0x0000, 0x0000 }; RGBForeColor( &fg ); - CopyBits( GetPortBitMapForCopyBits( GetWindowPort(fl_window) ), - GetPortBitMapForCopyBits( GetWindowPort(fl_window) ), &src, &dst, srcCopy, 0L); #elif defined(__APPLE_QUARTZ__) // warning: there does not seem to be an equivalent to this function in Quartz // ScrollWindowRect is a QuickDraw function and won't work here. @@ -145,17 +151,7 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy, CopyBits( GetPortBitMapForCopyBits( GetWindowPort(fl_window) ), GetPortBitMapForCopyBits( GetWindowPort(fl_window) ), &src, &dst, srcCopy, 0L); #else - XCopyArea(fl_display, fl_window, fl_window, fl_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 assumme 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; - } +# 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); diff --git a/src/fl_vertex.cxx b/src/fl_vertex.cxx index c3756e0c3..acc8db9af 100644 --- a/src/fl_vertex.cxx +++ b/src/fl_vertex.cxx @@ -150,10 +150,10 @@ void fl_vertex(double x,double y) { } void fl_end_points() { -#ifdef WIN32 +#if defined(USE_X11) + if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0); +#elif defined(WIN32) for (int i=0; i<n; i++) SetPixel(fl_gc, p[i].x, p[i].y, fl_RGB()); -#elif defined(__APPLE_QD__) - for (int i=0; i<n; i++) { MoveTo(p[i].x, p[i].y); Line(0, 0); } #elif defined(__APPLE_QUARTZ__) if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); for (int i=0; i<n; i++) { @@ -163,7 +163,7 @@ void fl_end_points() { } if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false); #else - if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0); +# error unsupported platform #endif } @@ -172,12 +172,10 @@ void fl_end_line() { fl_end_points(); return; } -#ifdef WIN32 +#if defined(USE_X11) + if (n>1) XDrawLines(fl_display, fl_window, fl_gc, p, n, 0); +#elif defined(WIN32) if (n>1) Polyline(fl_gc, p, n); -#elif defined(__APPLE_QD__) - if (n<=1) return; - MoveTo(p[0].x, p[0].y); - for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y); #elif defined(__APPLE_QUARTZ__) if (n<=1) return; CGContextMoveToPoint(fl_gc, p[0].x, p[0].y); @@ -185,7 +183,7 @@ void fl_end_line() { CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y); CGContextStrokePath(fl_gc); #else - if (n>1) XDrawLines(fl_display, fl_window, fl_gc, p, n, 0); +# error unsupported platform #endif } @@ -205,19 +203,13 @@ void fl_end_polygon() { fl_end_line(); return; } -#ifdef WIN32 +#if defined(USE_X11) + if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, Convex, 0); +#elif defined(WIN32) if (n>2) { SelectObject(fl_gc, fl_brush()); Polygon(fl_gc, p, n); } -#elif defined(__APPLE_QD__) - if (n<=1) return; - PolyHandle ph = OpenPoly(); - MoveTo(p[0].x, p[0].y); - for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y); - ClosePoly(); - PaintPoly(ph); - KillPoly(ph); #elif defined(__APPLE_QUARTZ__) if (n<=1) return; CGContextMoveToPoint(fl_gc, p[0].x, p[0].y); @@ -226,12 +218,12 @@ void fl_end_polygon() { CGContextClosePath(fl_gc); CGContextFillPath(fl_gc); #else - if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, Convex, 0); +# error unsupported platform #endif } static int gap; -#ifdef WIN32 +#if defined(WIN32) static int counts[20]; static int numcount; #endif @@ -239,7 +231,7 @@ static int numcount; void fl_begin_complex_polygon() { fl_begin_polygon(); gap = 0; -#ifdef WIN32 +#if defined(WIN32) numcount = 0; #endif } @@ -248,7 +240,7 @@ void fl_gap() { while (n>gap+2 && p[n-1].x == p[gap].x && p[n-1].y == p[gap].y) n--; if (n > gap+2) { fl_transformed_vertex((COORD_T)p[gap].x, (COORD_T)p[gap].y); -#ifdef WIN32 +#if defined(WIN32) counts[numcount++] = n-gap; #endif gap = n; @@ -263,19 +255,13 @@ void fl_end_complex_polygon() { fl_end_line(); return; } -#ifdef WIN32 +#if defined(USE_X11) + if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, 0, 0); +#elif defined(WIN32) if (n>2) { SelectObject(fl_gc, fl_brush()); PolyPolygon(fl_gc, p, counts, numcount); } -#elif defined(__APPLE_QD__) - if (n<=1) return; - PolyHandle ph = OpenPoly(); - MoveTo(p[0].x, p[0].y); - for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y); - ClosePoly(); - PaintPoly(ph); - KillPoly(ph); #elif defined(__APPLE_QUARTZ__) if (n<=1) return; CGContextMoveToPoint(fl_gc, p[0].x, p[0].y); @@ -284,7 +270,7 @@ void fl_end_complex_polygon() { CGContextClosePath(fl_gc); CGContextFillPath(fl_gc); #else - if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, 0, 0); +# error unsupported platform #endif } @@ -301,22 +287,22 @@ void fl_circle(double x, double y,double r) { int w = (int)rint(xt+rx)-llx; int lly = (int)rint(yt-ry); int h = (int)rint(yt+ry)-lly; -#ifdef WIN32 + +#if defined(USE_X11) + (what == POLYGON ? XFillArc : XDrawArc) + (fl_display, fl_window, fl_gc, llx, lly, w, h, 0, 360*64); +#elif defined(WIN32) if (what==POLYGON) { SelectObject(fl_gc, fl_brush()); Pie(fl_gc, llx, lly, llx+w, lly+h, 0,0, 0,0); } else Arc(fl_gc, llx, lly, llx+w, lly+h, 0,0, 0,0); -#elif defined(__APPLE_QD__) - Rect rt; rt.left=llx; rt.right=llx+w; rt.top=lly; rt.bottom=lly+h; - (what == POLYGON ? PaintOval : FrameOval)(&rt); #elif defined(__APPLE_QUARTZ__) // Quartz warning : circle won't scale to current matrix! CGContextAddArc(fl_gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 1); (what == POLYGON ? CGContextFillPath : CGContextStrokePath)(fl_gc); #else - (what == POLYGON ? XFillArc : XDrawArc) - (fl_display, fl_window, fl_gc, llx, lly, w, h, 0, 360*64); +# error unsupported platform #endif } diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 3bc2e3a73..e45f04287 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -73,32 +73,9 @@ void gl_font(int fontid, int size) { fl_fontsize->listbase = glGenLists(0x10000); #else // Fltk-1.1.8 style GL font selection -# ifdef WIN32 - int base = fl_fontsize->metr.tmFirstChar; - int count = fl_fontsize->metr.tmLastChar-base+1; - HFONT oldFid = (HFONT)SelectObject(fl_gc, fl_fontsize->fid); - fl_fontsize->listbase = glGenLists(256); - wglUseFontBitmaps(fl_gc, base, count, fl_fontsize->listbase+base); - SelectObject(fl_gc, oldFid); -# elif defined(__APPLE_QD__) - // undefined characters automatically receive an empty GL list in aglUseFont - fl_fontsize->listbase = glGenLists(256); - aglUseFont(aglGetCurrentContext(), fl_fontsize->font, fl_fontsize->face, - fl_fontsize->size, 0, 256, fl_fontsize->listbase); -# elif defined(__APPLE_QUARTZ__) - short font, face, size; - uchar fn[256]; - fn[0]=strlen(fl_fontsize->q_name); - strcpy((char*)(fn+1), fl_fontsize->q_name); - GetFNum(fn, &font); - face = 0; - size = fl_fontsize->size; - fl_fontsize->listbase = glGenLists(256); - aglUseFont(aglGetCurrentContext(), font, face, - size, 0, 256, fl_fontsize->listbase); -# else // X-windows options follow, either XFT or "plain" X +#if defined (USE_X11) // X-windows options follow, either XFT or "plain" X # if USE_XFT // XFT case -#warning We really need a glXUseXftFont implementation here... +# warning We really need a glXUseXftFont implementation here... // fl_xfont = fl_xxfont(); XFontStruct *font = fl_xxfont(); int base = font->min_char_or_byte2; @@ -106,7 +83,7 @@ void gl_font(int fontid, int size) { fl_fontsize->listbase = glGenLists(256); glXUseXFont(font->fid, base, count, fl_fontsize->listbase+base); # else // plain X -#warning GL font selection is basically wrong here +# warning GL font selection is basically wrong here /* OksiD has a fairly sophisticated scheme for storing multiple X fonts in a XUtf8FontStruct, * then sorting through them at draw time (for normal X rendering) to find which one can * render the current glyph... But for now, just use the first font in the list for GL... @@ -117,6 +94,26 @@ void gl_font(int fontid, int size) { fl_fontsize->listbase = glGenLists(256); glXUseXFont(tmp_font->fid, base, count, fl_fontsize->listbase+base); # endif // USE_XFT +# elif defined(WIN32) + int base = fl_fontsize->metr.tmFirstChar; + int count = fl_fontsize->metr.tmLastChar-base+1; + HFONT oldFid = (HFONT)SelectObject(fl_gc, fl_fontsize->fid); + fl_fontsize->listbase = glGenLists(256); + wglUseFontBitmaps(fl_gc, base, count, fl_fontsize->listbase+base); + SelectObject(fl_gc, oldFid); +# elif defined(__APPLE_QUARTZ__) + short font, face, size; + uchar fn[256]; + fn[0]=strlen(fl_fontsize->q_name); + strcpy((char*)(fn+1), fl_fontsize->q_name); + GetFNum(fn, &font); + face = 0; + size = fl_fontsize->size; + fl_fontsize->listbase = glGenLists(256); + aglUseFont(aglGetCurrentContext(), font, face, + size, 0, 256, fl_fontsize->listbase); +# else +# error unsupported platform # endif #endif // USE_OksiD_style_GL_font_selection @@ -130,18 +127,10 @@ void gl_font(int fontid, int size) { // The OSX build does not use this at present... It probbaly should, though... static void get_list(int r) { gl_fontsize->glok[r] = 1; -#ifdef WIN32 - unsigned int ii = r * 0x400; - HFONT oldFid = (HFONT)SelectObject(fl_gc, gl_fontsize->fid); - wglUseFontBitmapsW(fl_gc, ii, ii + 0x03ff, gl_fontsize->listbase+ii); - SelectObject(fl_gc, oldFid); -#elif defined(__APPLE_QD__) +#if defined(USE_X11) +# if USE_XFT // FIXME -#elif defined(__APPLE_QUARTZ__) -// FIXME -#elif USE_XFT -// FIXME -#else +# else unsigned int ii = r * 0x400; for (int i = 0; i < 0x400; i++) { XFontStruct *font = NULL; @@ -150,6 +139,16 @@ static void get_list(int r) { if (font) glXUseXFont(font->fid, id, 1, gl_fontsize->listbase+ii); ii++; } +# endif +#elif defined(WIN32) + unsigned int ii = r * 0x400; + HFONT oldFid = (HFONT)SelectObject(fl_gc, gl_fontsize->fid); + wglUseFontBitmapsW(fl_gc, ii, ii + 0x03ff, gl_fontsize->listbase+ii); + SelectObject(fl_gc, oldFid); +#elif defined(__APPLE_QUARTZ__) +// FIXME +#else +# error unsupported platform #endif } // get_list #endif @@ -279,7 +278,7 @@ extern int fl_overlay_depth; void gl_color(Fl_Color i) { #if HAVE_GL_OVERLAY -#ifdef WIN32 +#if defined(WIN32) if (fl_overlay && fl_overlay_depth) { if (fl_overlay_depth < 8) { // only black & white produce the expected colors. This could diff --git a/src/gl_start.cxx b/src/gl_start.cxx index f83a04889..f3933dddd 100644 --- a/src/gl_start.cxx +++ b/src/gl_start.cxx @@ -64,17 +64,16 @@ Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx void gl_start() { if (!context) { -#ifdef WIN32 +#if defined(USE_X11) + context = fl_create_gl_context(fl_visual); +#elif defined(WIN32) if (!gl_choice) Fl::gl_visual(0); context = fl_create_gl_context(Fl_Window::current(), gl_choice); -#elif defined(__APPLE_QD__) - // \todo Mac : We need to check the code and verify it with Apple Sample code. The 'shiny'-test should at least work with the software OpenGL emulator - context = fl_create_gl_context(Fl_Window::current(), gl_choice); #elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL context = fl_create_gl_context(Fl_Window::current(), gl_choice); #else - context = fl_create_gl_context(fl_visual); +# error Unsupported platform #endif } fl_set_gl_context(Fl_Window::current(), context); @@ -109,23 +108,23 @@ void gl_finish() { glXWaitGL(); #endif } + int Fl::gl_visual(int mode, int *alist) { Fl_Gl_Choice *c = Fl_Gl_Choice::find(mode,alist); if (!c) return 0; -#ifdef WIN32 - gl_choice = c; -#elif defined(__APPLE_QD__) +#if defined(USE_X11) + fl_visual = c->vis; + fl_colormap = c->colormap; +#elif defined(WIN32) gl_choice = c; #elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL gl_choice = c; #else - fl_visual = c->vis; - fl_colormap = c->colormap; +# error Unsupported platform #endif return 1; } - #endif // |
