summaryrefslogtreecommitdiff
path: root/src/cfg_gfx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2016-01-26 21:10:49 +0000
committerMatthias Melcher <fltk@matthiasm.com>2016-01-26 21:10:49 +0000
commit6694780c2d02d645f053fd60864c9ff035296a64 (patch)
treefd205fc40c3b1b0aa432bbc1bdbe2c78f3d1c60b /src/cfg_gfx
parentac275b89bcd8333dd1b05bfc9f6fc0accd8e065d (diff)
Moving GDI/WIN32 files to new directroy structure
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11058 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/cfg_gfx')
-rw-r--r--src/cfg_gfx/gdi.H116
-rw-r--r--src/cfg_gfx/gdi_arci.cxx62
-rw-r--r--src/cfg_gfx/gdi_color.cxx245
-rw-r--r--src/cfg_gfx/gdi_line_style.cxx65
-rw-r--r--src/cfg_gfx/gdi_rect.cxx239
-rw-r--r--src/cfg_gfx/gdi_vertex.cxx127
6 files changed, 0 insertions, 854 deletions
diff --git a/src/cfg_gfx/gdi.H b/src/cfg_gfx/gdi.H
deleted file mode 100644
index c38b23a5c..000000000
--- a/src/cfg_gfx/gdi.H
+++ /dev/null
@@ -1,116 +0,0 @@
-//
-// "$Id$"
-//
-// Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device
-// for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 2010-2016 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-/**
- \file gdi.h
- \brief Definition of MSWindows GDI graphics driver.
- */
-
-#ifndef FL_CFG_GFX_GDI_H
-#define FL_CFG_GFX_GDI_H
-
-#include <FL/Fl_Device.H>
-
-
-/**
- \brief The MSWindows-specific graphics class.
- *
- This class is implemented only on the MSWindows platform.
- */
-class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
-protected:
- int numcount;
- int counts[20];
-public:
- static const char *class_id;
- const char *class_name() {return class_id;};
- void draw(const char* str, int n, int x, int y);
- void draw(int angle, const char *str, int n, int x, int y);
- void rtl_draw(const char* str, int n, int x, int y);
- void font(Fl_Font face, Fl_Fontsize size);
- void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
- void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
- void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
- void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
- void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
- void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
- void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
- double width(const char *str, int n);
- double width(unsigned int c);
- void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
- int height();
- int descent();
-#if ! defined(FL_DOXYGEN)
- void copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy);
-#endif
- void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
-protected:
- // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/gdi_rect.cxx
- void point(int x, int y);
- void rect(int x, int y, int w, int h);
- void rectf(int x, int y, int w, int h);
- void line(int x, int y, int x1, int y1);
- void line(int x, int y, int x1, int y1, int x2, int y2);
- void xyline(int x, int y, int x1);
- void xyline(int x, int y, int x1, int y2);
- void xyline(int x, int y, int x1, int y2, int x3);
- void yxline(int x, int y, int y1);
- void yxline(int x, int y, int y1, int x2);
- void yxline(int x, int y, int y1, int x2, int y3);
- void loop(int x0, int y0, int x1, int y1, int x2, int y2);
- void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
- void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
- void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
- // --- clipping
- void push_clip(int x, int y, int w, int h);
- int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
- int not_clipped(int x, int y, int w, int h);
- void push_no_clip();
- void pop_clip();
- void restore_clip();
- // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx
- void begin_complex_polygon();
- void transformed_vertex(double xf, double yf);
- void vertex(double x, double y);
- void end_points();
- void end_line();
- void end_loop();
- void end_polygon();
- void end_complex_polygon();
- void gap();
- void circle(double x, double y, double r);
- // --- implementation is in src/fl_arc.cxx which includes src/cfg_gfx/xxx_arc.cxx if needed
- // using void Fl_Graphics_Driver::arc(double x, double y, double r, double start, double end);
- // --- implementation is in src/fl_arci.cxx which includes src/cfg_gfx/xxx_arci.cxx
- void arc(int x, int y, int w, int h, double a1, double a2);
- void pie(int x, int y, int w, int h, double a1, double a2);
- // --- implementation is in src/fl_line_style.cxx which includes src/cfg_gfx/xxx_line_style.cxx
- void line_style(int style, int width=0, char* dashes=0);
- // --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx
- void color(Fl_Color c);
- Fl_Color color() { return color_; }
- void color(uchar r, uchar g, uchar b);
-};
-
-
-#endif // FL_CFG_GFX_GDI_H
-
-//
-// End of "$Id$".
-//
diff --git a/src/cfg_gfx/gdi_arci.cxx b/src/cfg_gfx/gdi_arci.cxx
deleted file mode 100644
index 5cba23851..000000000
--- a/src/cfg_gfx/gdi_arci.cxx
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// "$Id$"
-//
-// Arc (integer) drawing functions for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2016 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-#ifndef FL_CFG_GFX_GDI_ARCI_CXX
-#define FL_CFG_GFX_GDI_ARCI_CXX
-
-/**
- \file gdi_arci.cxx
- \brief Utility functions for drawing circles using integers
-*/
-
-#include <FL/math.h>
-
-void Fl_GDI_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) {
- if (w <= 0 || h <= 0) 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));
- int xb = x+w/2+int(w*cos(a2/180.0*M_PI));
- int yb = y+h/2-int(h*sin(a2/180.0*M_PI));
- if (fabs(a1 - a2) < 90) {
- 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);
-}
-
-void Fl_GDI_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) {
- if (w <= 0 || h <= 0) return;
- 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));
- int xb = x+w/2+int(w*cos(a2/180.0*M_PI));
- int yb = y+h/2-int(h*sin(a2/180.0*M_PI));
- SelectObject(fl_gc, fl_brush());
- if (fabs(a1 - a2) < 90) {
- if (xa == xb && ya == yb) {
- MoveToEx(fl_gc, x+w/2, y+h/2, 0L);
- LineTo(fl_gc, xa, ya);
- 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);
-}
-
-#endif // FL_CFG_GFX_GDI_ARCI_CXX
-
-//
-// End of "$Id$".
-//
diff --git a/src/cfg_gfx/gdi_color.cxx b/src/cfg_gfx/gdi_color.cxx
deleted file mode 100644
index 624546f39..000000000
--- a/src/cfg_gfx/gdi_color.cxx
+++ /dev/null
@@ -1,245 +0,0 @@
-//
-// "$Id$"
-//
-// MSWidnows' GDI color functions for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2016 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-// The fltk "colormap". This allows ui colors to be stored in 8-bit
-// locations, and provides a level of indirection so that global color
-// changes can be made. Not to be confused with the X colormap, which
-// I try to hide completely.
-
-#include <config.h>
-#include <FL/Fl.H>
-#include <FL/x.H>
-#include <FL/fl_draw.H>
-
-// FIXME: all the global functions in this file should probably be protected
-// members of the driver class. Starting with 1.4 we will allow multiple drivers
-// to co-exist, creating conflicts with multipe mapping.
-
-// FIXME: maybe we can forget about color mapping and assume RGB?
-
-static unsigned fl_cmap[256] = {
-#include "fl_cmap.h" // this is a file produced by "cmap.cxx":
-};
-
-// Translations to win32 data structures:
-Fl_XMap fl_xmap[256];
-
-Fl_XMap* fl_current_xmap;
-
-HPALETTE fl_palette;
-static HGDIOBJ tmppen=0;
-static HPEN savepen=0;
-
-void fl_cleanup_pens(void) {
- for (int i=0; i<256; i++) {
- if (fl_xmap[i].pen) DeleteObject(fl_xmap[i].pen);
- }
-}
-
-void fl_save_pen(void) {
- if(!tmppen) tmppen = CreatePen(PS_SOLID, 1, 0);
- savepen = (HPEN)SelectObject(fl_gc, tmppen);
-}
-
-void fl_restore_pen(void) {
- if (savepen) SelectObject(fl_gc, savepen);
- DeleteObject(tmppen);
- tmppen = 0;
- savepen = 0;
-}
-
-static void clear_xmap(Fl_XMap& xmap) {
- if (xmap.pen) {
- HGDIOBJ tmppen = GetStockObject(BLACK_PEN);
- HGDIOBJ oldpen = SelectObject(fl_gc, tmppen); // Push out the current pen of the gc
- if(oldpen != xmap.pen) SelectObject(fl_gc, oldpen); // Put it back if it is not the one we are about to delete
- DeleteObject((HGDIOBJ)(xmap.pen));
- xmap.pen = 0;
- xmap.brush = -1;
- }
-}
-
-static void set_xmap(Fl_XMap& xmap, COLORREF c) {
- xmap.rgb = c;
- if (xmap.pen) {
- HGDIOBJ oldpen = SelectObject(fl_gc,GetStockObject(BLACK_PEN)); // replace current pen with safe one
- if (oldpen != xmap.pen)SelectObject(fl_gc,oldpen); // if old one not xmap.pen, need to put it back
- DeleteObject(xmap.pen); // delete pen
- }
- xmap.pen = CreatePen(PS_SOLID, 1, xmap.rgb); // get a pen into xmap.pen
- xmap.brush = -1;
-}
-
-void Fl_GDI_Graphics_Driver::color(Fl_Color i) {
- if (i & 0xffffff00) {
- unsigned rgb = (unsigned)i;
- fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8));
- } else {
- Fl_Graphics_Driver::color(i);
- Fl_XMap &xmap = fl_xmap[i];
- if (!xmap.pen) {
-#if USE_COLORMAP
- if (fl_palette) {
- set_xmap(xmap, PALETTEINDEX(i));
- } else {
-#endif
- unsigned c = fl_cmap[i];
- set_xmap(xmap, RGB(uchar(c>>24), uchar(c>>16), uchar(c>>8)));
-#if USE_COLORMAP
- }
-#endif
- }
- fl_current_xmap = &xmap;
- SelectObject(fl_gc, (HGDIOBJ)(xmap.pen));
- }
-}
-
-void Fl_GDI_Graphics_Driver::color(uchar r, uchar g, uchar b) {
- static Fl_XMap xmap;
- COLORREF c = RGB(r,g,b);
- Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
- if (!xmap.pen || c != xmap.rgb) {
- clear_xmap(xmap);
- set_xmap(xmap, c);
- }
- fl_current_xmap = &xmap;
- SelectObject(fl_gc, (HGDIOBJ)(xmap.pen));
-}
-
-HBRUSH fl_brush() {
- return fl_brush_action(0);
-}
-
-HBRUSH fl_brush_action(int action) {
- Fl_XMap *xmap = fl_current_xmap;
- // Wonko: we use some statistics to cache only a limited number
- // of brushes:
-#define FL_N_BRUSH 16
- static struct Fl_Brush {
- HBRUSH brush;
- unsigned short usage;
- Fl_XMap* backref;
- } brushes[FL_N_BRUSH];
-
- if (action) {
- SelectObject(fl_gc, GetStockObject(BLACK_BRUSH)); // Load stock object
- for (int i=0; i<FL_N_BRUSH; i++) {
- if (brushes[i].brush)
- DeleteObject(brushes[i].brush); // delete all brushes in array
- }
- return NULL;
- }
-
- int i = xmap->brush; // find the associated brush
- if (i != -1) { // if the brush was allready allocated
- if (brushes[i].brush == NULL) goto CREATE_BRUSH;
- if ( (++brushes[i].usage) > 32000 ) { // keep a usage statistic
- for (int j=0; j<FL_N_BRUSH; j++) {
- if (brushes[j].usage>16000)
- brushes[j].usage -= 16000;
- else
- brushes[j].usage = 0;
- }
- }
- return brushes[i].brush;
- } else {
- int umin = 32000, imin = 0;
- for (i=0; i<FL_N_BRUSH; i++) {
- if (brushes[i].brush == NULL) goto CREATE_BRUSH;
- if (brushes[i].usage<umin) {
- umin = brushes[i].usage;
- imin = i;
- }
- }
- i = imin;
- HGDIOBJ tmpbrush = GetStockObject(BLACK_BRUSH); // get a stock brush
- HGDIOBJ oldbrush = SelectObject(fl_gc,tmpbrush); // load in into current context
- if (oldbrush != brushes[i].brush) SelectObject(fl_gc,oldbrush); // reload old one
- DeleteObject(brushes[i].brush); // delete the one in list
- brushes[i].brush = NULL;
- brushes[i].backref->brush = -1;
- }
-CREATE_BRUSH:
- brushes[i].brush = CreateSolidBrush(xmap->rgb);
- brushes[i].usage = 0;
- brushes[i].backref = xmap;
- xmap->brush = i;
- return brushes[i].brush;
-}
-
-void Fl::free_color(Fl_Color i, int overlay) {
- if (overlay) return; // do something about GL overlay?
- clear_xmap(fl_xmap[i]);
-}
-
-void Fl::set_color(Fl_Color i, unsigned c) {
- if (fl_cmap[i] != c) {
- clear_xmap(fl_xmap[i]);
- fl_cmap[i] = c;
- }
-}
-
-#if USE_COLORMAP
-
-// 'fl_select_palette()' - Make a color palette for 8-bit displays if necessary
-// Thanks to Michael Sweet @ Easy Software Products for this
-
-HPALETTE
-fl_select_palette(void)
-{
- static char beenhere;
- if (!beenhere) {
- beenhere = 1;
-
- //if (GetDeviceCaps(fl_gc, BITSPIXEL) > 8) return NULL;
- int nColors = GetDeviceCaps(fl_gc, SIZEPALETTE);
- if (nColors <= 0 || nColors > 256) return NULL;
- // this will try to work on < 256 color screens, but will probably
- // come out quite badly.
-
- // I lamely try to get this variable-sized object allocated on stack:
- ulong foo[(sizeof(LOGPALETTE)+256*sizeof(PALETTEENTRY))/sizeof(ulong)+1];
- LOGPALETTE *pPal = (LOGPALETTE*)foo;
-
- pPal->palVersion = 0x300;
- pPal->palNumEntries = nColors;
-
- // Build 256 colors from the standard FLTK colormap...
-
- for (int i = 0; i < nColors; i ++) {
- pPal->palPalEntry[i].peRed = (fl_cmap[i] >> 24) & 255;
- pPal->palPalEntry[i].peGreen = (fl_cmap[i] >> 16) & 255;
- pPal->palPalEntry[i].peBlue = (fl_cmap[i] >> 8) & 255;
- pPal->palPalEntry[i].peFlags = 0;
- };
-
- // Create the palette:
- fl_palette = CreatePalette(pPal);
- }
- if (fl_palette) {
- SelectPalette(fl_gc, fl_palette, FALSE);
- RealizePalette(fl_gc);
- }
- return fl_palette;
-}
-
-#endif
-
-//
-// End of "$Id$".
-//
diff --git a/src/cfg_gfx/gdi_line_style.cxx b/src/cfg_gfx/gdi_line_style.cxx
deleted file mode 100644
index a3ba0a71a..000000000
--- a/src/cfg_gfx/gdi_line_style.cxx
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// "$Id$"
-//
-// Line style code for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2016 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-#ifndef FL_CFG_GFX_GDI_LINE_STYLE_CXX
-#define FL_CFG_GFX_GDI_LINE_STYLE_CXX
-
-/**
- \file gdi_line_style.cxx
- \brief Line style drawing utility hiding different platforms.
-*/
-
-#include "gdi.H"
-
-void Fl_GDI_Graphics_Driver::line_style(int style, int width, char* dashes) {
-
- // save line width in global variable for X11 clipping
- if (width == 0) fl_line_width_ = 1;
- else fl_line_width_ = width>0 ? width : -width;
-
- // 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
- static DWORD Cap[4]= {PS_ENDCAP_FLAT, PS_ENDCAP_FLAT, PS_ENDCAP_ROUND, PS_ENDCAP_SQUARE};
- static DWORD Join[4]={PS_JOIN_ROUND, PS_JOIN_MITER, PS_JOIN_ROUND, PS_JOIN_BEVEL};
- int s1 = PS_GEOMETRIC | Cap[(style>>8)&3] | Join[(style>>12)&3];
- DWORD a[16]; int n = 0;
- if (dashes && dashes[0]) {
- s1 |= PS_USERSTYLE;
- for (n = 0; n < 16 && *dashes; n++) a[n] = *dashes++;
- } else {
- s1 |= style & 0xff; // allow them to pass any low 8 bits for style
- }
- if ((style || n) && !width) width = 1; // fix cards that do nothing for 0?
- LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()?
- HPEN newpen = ExtCreatePen(s1, width, &penbrush, n, n ? a : 0);
- if (!newpen) {
- Fl::error("fl_line_style(): Could not create GDI pen object.");
- return;
- }
- HPEN oldpen = (HPEN)SelectObject(fl_gc, newpen);
- DeleteObject(oldpen);
- DeleteObject(fl_current_xmap->pen);
- fl_current_xmap->pen = newpen;
-}
-
-#endif // FL_CFG_GFX_GDI_LINE_STYLE_CXX
-
-//
-// End of "$Id$".
-//
diff --git a/src/cfg_gfx/gdi_rect.cxx b/src/cfg_gfx/gdi_rect.cxx
deleted file mode 100644
index 466d8d83f..000000000
--- a/src/cfg_gfx/gdi_rect.cxx
+++ /dev/null
@@ -1,239 +0,0 @@
-//
-// "$Id$"
-//
-// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2016 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-#ifndef FL_CFG_GFX_QUARTZ_RECT_CXX
-#define FL_CFG_GFX_QUARTZ_RECT_CXX
-
-
-/**
- \file gdi_rect.cxx
- \brief MSWindows GDI specific line and polygon drawing with integer coordinates.
- */
-
-#include "gdi.h"
-
-
-// --- line and polygon drawing with integer coordinates
-
-void Fl_GDI_Graphics_Driver::point(int x, int y) {
- SetPixel(fl_gc, x, y, fl_RGB());
-}
-
-void Fl_GDI_Graphics_Driver::rect(int x, int y, int w, int h) {
- if (w<=0 || h<=0) return;
- 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);
-}
-
-void Fl_GDI_Graphics_Driver::rectf(int x, int y, int w, int h) {
- if (w<=0 || h<=0) return;
- RECT rect;
- rect.left = x; rect.top = y;
- rect.right = x + w; rect.bottom = y + h;
- FillRect(fl_gc, &rect, fl_brush());
-}
-
-void Fl_GDI_Graphics_Driver::line(int x, int y, int x1, int y1) {
- MoveToEx(fl_gc, x, y, 0L);
- LineTo(fl_gc, x1, y1);
- SetPixel(fl_gc, x1, y1, fl_RGB());
-}
-
-void Fl_GDI_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
- MoveToEx(fl_gc, x, y, 0L);
- LineTo(fl_gc, x1, y1);
- LineTo(fl_gc, x2, y2);
- SetPixel(fl_gc, x2, y2, fl_RGB());
-}
-
-void Fl_GDI_Graphics_Driver::xyline(int x, int y, int x1) {
- MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1+1, y);
-}
-
-void Fl_GDI_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
- if (y2 < y) y2--;
- else y2++;
- MoveToEx(fl_gc, x, y, 0L);
- LineTo(fl_gc, x1, y);
- LineTo(fl_gc, x1, y2);
-}
-
-void Fl_GDI_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
- 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);
-}
-
-void Fl_GDI_Graphics_Driver::yxline(int x, int y, int y1) {
- if (y1 < y) y1--;
- else y1++;
- MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1);
-}
-
-void Fl_GDI_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
- if (x2 > x) x2++;
- else x2--;
- MoveToEx(fl_gc, x, y, 0L);
- LineTo(fl_gc, x, y1);
- LineTo(fl_gc, x2, y1);
-}
-
-void Fl_GDI_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
- 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);
-}
-
-void Fl_GDI_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) {
- MoveToEx(fl_gc, x, y, 0L);
- LineTo(fl_gc, x1, y1);
- LineTo(fl_gc, x2, y2);
- LineTo(fl_gc, x, y);
-}
-
-void Fl_GDI_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
- 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);
-}
-
-void Fl_GDI_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2) {
- 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;
- SelectObject(fl_gc, fl_brush());
- Polygon(fl_gc, p, 3);
-}
-
-void Fl_GDI_Graphics_Driver::polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
- 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 = x3; p[3].y = y3;
- SelectObject(fl_gc, fl_brush());
- Polygon(fl_gc, p, 4);
-}
-
-// --- clipping
-
-void Fl_GDI_Graphics_Driver::push_clip(int x, int y, int w, int h) {
- Fl_Region r;
- if (w > 0 && h > 0) {
- r = XRectangleRegion(x,y,w,h);
- Fl_Region current = rstack[rstackptr];
- if (current) {
- CombineRgn(r,r,current,RGN_AND);
- }
- } else { // make empty clip region:
- r = CreateRectRgn(0,0,0,0);
- }
- if (rstackptr < region_stack_max) rstack[++rstackptr] = r;
- else Fl::warning("Fl_GDI_Graphics_Driver::push_clip: clip stack overflow!\n");
- fl_restore_clip();
-}
-
-int Fl_GDI_Graphics_Driver::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;
- // 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
- // some voodoo stuff...
- Fl_Region rr = XRectangleRegion(x,y,w,h);
- Fl_Region temp = CreateRectRgn(0,0,0,0);
- int ret;
- if (CombineRgn(temp, rr, r, RGN_AND) == NULLREGION) { // disjoint
- W = H = 0;
- ret = 2;
- } else if (EqualRgn(temp, rr)) { // complete
- ret = 0;
- } else { // partial intersection
- RECT rect;
- GetRgnBox(temp, &rect);
- if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { // if print context, convert coords from device to logical
- POINT pt[2] = { {rect.left, rect.top}, {rect.right, rect.bottom} };
- DPtoLP(fl_gc, pt, 2);
- X = pt[0].x; Y = pt[0].y; W = pt[1].x - X; H = pt[1].y - Y;
- }
- else {
- X = rect.left; Y = rect.top; W = rect.right - X; H = rect.bottom - Y;
- }
- ret = 1;
- }
- DeleteObject(temp);
- DeleteObject(rr);
- return ret;
-}
-
-int Fl_GDI_Graphics_Driver::not_clipped(int x, int y, int w, int h) {
- if (x+w <= 0 || y+h <= 0) return 0;
- Fl_Region r = rstack[rstackptr];
- if (!r) return 1;
- RECT rect;
- if (Fl_Surface_Device::surface() != Fl_Display_Device::display_device()) { // in case of print context, convert coords from logical to device
- POINT pt[2] = { {x, y}, {x + w, y + h} };
- LPtoDP(fl_gc, pt, 2);
- rect.left = pt[0].x; rect.top = pt[0].y; rect.right = pt[1].x; rect.bottom = pt[1].y;
- } else {
- rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
- }
- return RectInRegion(r,&rect);
-}
-
-// make there be no clip (used by fl_begin_offscreen() only!)
-void Fl_GDI_Graphics_Driver::push_no_clip() {
- if (rstackptr < region_stack_max) rstack[++rstackptr] = 0;
- else Fl::warning("Fl_GDI_Graphics_Driver::push_no_clip: clip stack overflow!\n");
- fl_restore_clip();
-}
-
-// pop back to previous clip:
-void Fl_GDI_Graphics_Driver::pop_clip() {
- if (rstackptr > 0) {
- Fl_Region oldr = rstack[rstackptr--];
- if (oldr) XDestroyRegion(oldr);
- } else Fl::warning("Fl_GDI_Graphics_Driver::pop_clip: clip stack underflow!\n");
- fl_restore_clip();
-}
-
-void Fl_GDI_Graphics_Driver::restore_clip() {
- fl_clip_state_number++;
- Fl_Region r = rstack[rstackptr];
- SelectClipRgn(fl_gc, r); //if r is NULL, clip is automatically cleared
-}
-
-
-#endif // FL_CFG_GFX_GDI_RECT_CXX
-
-//
-// End of "$Id$".
-//
diff --git a/src/cfg_gfx/gdi_vertex.cxx b/src/cfg_gfx/gdi_vertex.cxx
deleted file mode 100644
index 81267f1e0..000000000
--- a/src/cfg_gfx/gdi_vertex.cxx
+++ /dev/null
@@ -1,127 +0,0 @@
-//
-// "$Id$"
-//
-// Portable drawing routines for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2016 by Bill Spitzak and others.
-//
-// This library is free software. Distribution and use rights are outlined in
-// the file "COPYING" which should have been included with this file. If this
-// file is missing or damaged, see the license at:
-//
-// http://www.fltk.org/COPYING.php
-//
-// Please report all bugs and problems on the following page:
-//
-// http://www.fltk.org/str.php
-//
-
-#ifndef FL_CFG_GFX_GDI_VERTEX_CXX
-#define FL_CFG_GFX_GDI_VERTEX_CXX
-
-/**
- \file gdi_vertex.cxx
- \brief Portable drawing code for drawing arbitrary shapes with
- simple 2D transformations, implemented for MSWindows GDI.
- */
-
-#include "gdi.H"
-
-#include <FL/fl_draw.H>
-#include <FL/x.H>
-#include <FL/math.h>
-
-
-void Fl_GDI_Graphics_Driver::transformed_vertex(double xf, double yf) {
- transformed_vertex0(COORD_T(rint(xf)), COORD_T(rint(yf)));
-}
-
-void Fl_GDI_Graphics_Driver::vertex(double x,double y) {
- transformed_vertex0(COORD_T(x*m.a + y*m.c + m.x), COORD_T(x*m.b + y*m.d + m.y));
-}
-
-void Fl_GDI_Graphics_Driver::end_points() {
- for (int i=0; i<n; i++) SetPixel(fl_gc, p[i].x, p[i].y, fl_RGB());
-}
-
-void Fl_GDI_Graphics_Driver::end_line() {
- if (n < 2) {
- end_points();
- return;
- }
- if (n>1) Polyline(fl_gc, p, n);
-}
-
-void Fl_GDI_Graphics_Driver::end_loop() {
- fixloop();
- if (n>2) transformed_vertex((COORD_T)p[0].x, (COORD_T)p[0].y);
- end_line();
-}
-
-void Fl_GDI_Graphics_Driver::end_polygon() {
- fixloop();
- if (n < 3) {
- end_line();
- return;
- }
- if (n>2) {
- SelectObject(fl_gc, fl_brush());
- Polygon(fl_gc, p, n);
- }
-}
-
-void Fl_GDI_Graphics_Driver::begin_complex_polygon() {
- begin_polygon();
- gap_ = 0;
- numcount = 0;
-}
-
-void Fl_GDI_Graphics_Driver::gap() {
- while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--;
- if (n > gap_+2) {
- transformed_vertex((COORD_T)p[gap_].x, (COORD_T)p[gap_].y);
- counts[numcount++] = n-gap_;
- gap_ = n;
- } else {
- n = gap_;
- }
-}
-
-void Fl_GDI_Graphics_Driver::end_complex_polygon() {
- gap();
- if (n < 3) {
- end_line();
- return;
- }
- if (n>2) {
- SelectObject(fl_gc, fl_brush());
- PolyPolygon(fl_gc, p, counts, numcount);
- }
-}
-
-// shortcut the closed circles so they use XDrawArc:
-// warning: these do not draw rotated ellipses correctly!
-// See fl_arc.c for portable version.
-
-void Fl_GDI_Graphics_Driver::circle(double x, double y,double r) {
- double xt = transform_x(x,y);
- double yt = transform_y(x,y);
- double rx = r * (m.c ? sqrt(m.a*m.a+m.c*m.c) : fabs(m.a));
- double ry = r * (m.b ? sqrt(m.b*m.b+m.d*m.d) : fabs(m.d));
- int llx = (int)rint(xt-rx);
- int w = (int)rint(xt+rx)-llx;
- int lly = (int)rint(yt-ry);
- int h = (int)rint(yt+ry)-lly;
-
- 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);
-}
-
-#endif // FL_CFG_GFX_GDI_VERTEX_CXX
-
-//
-// End of "$Id$".
-//