summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2016-03-08 00:35:00 +0000
committerMatthias Melcher <fltk@matthiasm.com>2016-03-08 00:35:00 +0000
commit00750d4c333a304366a1adbd8780f9f44c9cdafb (patch)
treea95aad533893c6f7ca4dad9e2145e0925ac0192a
parentb73bf4a73eeda279042883139106eacbe4b3d791 (diff)
Add very basic graphics support to PicoSDL.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11311 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Window.H1
-rw-r--r--FL/Fl_Window_Driver.H3
-rw-r--r--src/drivers/Pico/Fl_Pico_Graphics_Driver.H220
-rw-r--r--src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx299
-rw-r--r--src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.H124
-rw-r--r--src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.cxx70
-rw-r--r--src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx68
-rw-r--r--src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.H8
-rw-r--r--src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx48
9 files changed, 812 insertions, 29 deletions
diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H
index 659495f32..ce9582475 100644
--- a/FL/Fl_Window.H
+++ b/FL/Fl_Window.H
@@ -71,6 +71,7 @@ class FL_EXPORT Fl_Window : public Fl_Group {
friend class Fl_X;
friend class Fl_Window_Driver;
+ friend class Fl_PicoSDL_Window_Driver;
Fl_X *i; // points at the system-specific stuff, but exists only after the window is mapped
Fl_Window_Driver *pWindowDriver; // points at the system-specific stuff at window creatino time
diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H
index 9f938606f..e252d22bf 100644
--- a/FL/Fl_Window_Driver.H
+++ b/FL/Fl_Window_Driver.H
@@ -41,6 +41,9 @@ public:
virtual ~Fl_Window_Driver();
static Fl_Window_Driver *newWindowDriver(Fl_Window *);
+ virtual Fl_X *makeWindow() { /* FIXME: move Fl_X::make(Fl_Window*) here for OSX, MSWin, and X11 */ return 0; }
+ virtual void flush() { /* FIXME: move Fl_X::flush() here for OSX, MSWin, and X11 */ }
+
virtual void take_focus() { }
virtual int double_flush(int eraseoverlay);
virtual void destroy_double_buffer();
diff --git a/src/drivers/Pico/Fl_Pico_Graphics_Driver.H b/src/drivers/Pico/Fl_Pico_Graphics_Driver.H
index 8b1378917..1570c2463 100644
--- a/src/drivers/Pico/Fl_Pico_Graphics_Driver.H
+++ b/src/drivers/Pico/Fl_Pico_Graphics_Driver.H
@@ -1 +1,221 @@
+//
+// "$Id: Fl_Pico_Graphics_Driver.H 11017 2016-01-20 21:40:12Z matt $"
+//
+// Definition of the Pico minimal graphics driver
+// 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 Fl_Pico_Graphics_Driver.H
+ \brief Definition of Pico minimal graphics driver.
+ */
+
+#ifndef FL_PICO_GRAPHICS_DRIVER_H
+#define FL_PICO_GRAPHICS_DRIVER_H
+
+#include <FL/Fl_Graphics_Driver.H>
+
+
+/**
+ \brief The Pico minimal graphics class.
+ *
+ This class is implemented as a base class for minimal core drivers.
+ */
+class Fl_Pico_Graphics_Driver : public Fl_Graphics_Driver {
+// friend class Fl_Surface_Device;
+// friend class Fl_Pixmap;
+// friend class Fl_Bitmap;
+// friend class Fl_RGB_Image;
+// friend int fl_draw_pixmap(const char*const* cdata, int x, int y, Fl_Color bg);
+//public:
+// // The following functions create the various graphics drivers that are required
+// // for core operations. They must be implemented as members of Fl_Graphics_Driver,
+// // but located in the device driver module that is linked to the core library
+// static Fl_Graphics_Driver *newMainGraphicsDriver();
+// //static Fl_Graphics_Driver *newOpenGLGraphicsDriver();
+// //static Fl_Graphics_Driver *newPrinterGraphicsDriver();
+// //static Fl_Graphics_Driver *new...;
+//public:
+// /** A 2D coordinate transformation matrix */
+// struct matrix {double a, b, c, d, x, y;};
+// /** Features that a derived class may possess. */
+// typedef enum {
+// NATIVE = 1, /**< native graphics driver for the platform */
+// PRINTER = 2 /**< graphics driver for a printer drawing surface */
+// } driver_feature;
+//
+// int fl_clip_state_number;
+//protected:
+// static const matrix m0;
+// Fl_Font font_; // current font
+// Fl_Fontsize size_; // current font size
+// Fl_Color color_; // current color
+// int sptr;
+// static const int matrix_stack_size = FL_MATRIX_STACK_SIZE;
+// matrix stack[FL_MATRIX_STACK_SIZE];
+// matrix m;
+// int n, p_size, gap_;
+// XPOINT *p;
+// int what;
+// int rstackptr;
+// static const int region_stack_max = FL_REGION_STACK_SIZE - 1;
+// Fl_Region rstack[FL_REGION_STACK_SIZE];
+// Fl_Font_Descriptor *font_descriptor_;
+//#ifndef FL_DOXYGEN
+// enum {LINE, LOOP, POLYGON, POINT_};
+// inline int vertex_no() { return n; }
+// inline XPOINT *vertices() {return p;}
+// inline int vertex_kind() {return what;}
+//#endif
+// matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */
+//
+// // === all code below in this class has been to the reorganisation FL_PORTING process
+//public:
+// Fl_Graphics_Driver();
+// virtual ~Fl_Graphics_Driver() { if (p) free(p); }
+// virtual char can_do_alpha_blending() { return 0; }
+// // --- implementation is in src/fl_rect.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_rect.cxx
+ virtual void point(int x, int y);
+ virtual void rect(int x, int y, int w, int h);
+// virtual void focus_rect(int x, int y, int w, int h);
+ virtual void rectf(int x, int y, int w, int h);
+ virtual void line(int x, int y, int x1, int y1);
+ virtual void line(int x, int y, int x1, int y1, int x2, int y2);
+ virtual void xyline(int x, int y, int x1);
+ virtual void xyline(int x, int y, int x1, int y2);
+ virtual void xyline(int x, int y, int x1, int y2, int x3) ;
+ virtual void yxline(int x, int y, int y1) ;
+ virtual void yxline(int x, int y, int y1, int x2) ;
+ virtual void yxline(int x, int y, int y1, int x2, int y3) ;
+ virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2) ;
+ virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) ;
+ virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2) ;
+ virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) ;
+// // --- clipping
+ virtual void push_clip(int x, int y, int w, int h) ;
+ virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) ;
+ virtual int not_clipped(int x, int y, int w, int h) ;
+ virtual void push_no_clip() ;
+ virtual void pop_clip() ;
+// virtual Fl_Region clip_region(); // has default implementation
+// virtual void clip_region(Fl_Region r); // has default implementation
+// virtual void restore_clip();
+// // --- implementation is in src/fl_vertex.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_vertex.cxx
+// virtual void push_matrix();
+// virtual void pop_matrix();
+// virtual void mult_matrix(double a, double b, double c, double d, double x, double y);
+// virtual void rotate(double d);
+// virtual void scale(double x, double y);
+// virtual void scale(double x);
+// virtual void translate(double x,double y);
+// virtual void begin_points();
+// virtual void begin_line();
+// virtual void begin_loop();
+// virtual void begin_polygon();
+ virtual void begin_complex_polygon() ;
+// virtual double transform_x(double x, double y);
+// virtual double transform_y(double x, double y);
+// virtual double transform_dx(double x, double y);
+// virtual double transform_dy(double x, double y);
+ virtual void transformed_vertex(double xf, double yf) ;
+ virtual void vertex(double x, double y) ;
+ virtual void end_points() ;
+ virtual void end_line() ;
+ virtual void end_loop() ;
+ virtual void end_polygon() ;
+ virtual void end_complex_polygon() ;
+ virtual void gap() ;
+ virtual void circle(double x, double y, double r) ;
+// // --- implementation is in src/fl_arc.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_arc.cxx if needed
+// virtual void arc(double x, double y, double r, double start, double end);
+// // --- implementation is in src/fl_arci.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_arci.cxx
+ virtual void arc(int x, int y, int w, int h, double a1, double a2) ;
+ virtual void pie(int x, int y, int w, int h, double a1, double a2) ;
+// // --- implementation is in src/fl_curve.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_curve.cxx if needed
+// virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3);
+// // --- implementation is in src/fl_line_style.cxx which includes src/cfg_gfx/xxx_line_style.cxx
+ virtual 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
+// virtual void color(Fl_Color c) { color_ = c; }
+// virtual Fl_Color color() { return color_; }
+ virtual void color(uchar r, uchar g, uchar b) ;
+// // --- implementation is in src/fl_font.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_font.cxx
+ virtual void draw(const char *str, int n, int x, int y) ;
+// virtual void draw(const char *str, int n, float x, float y) { draw(str, n, (int)(x+0.5), (int)(y+0.5));}
+// virtual void draw(int angle, const char *str, int n, int x, int y) { draw(str, n, x, y); }
+// virtual void rtl_draw(const char *str, int n, int x, int y) { draw(str, n, x, y); }
+// /** Returns non-zero if the graphics driver possesses the \p feature */
+// virtual int has_feature(driver_feature feature) { return 0; }
+// virtual void font(Fl_Font face, Fl_Fontsize fsize) {font_ = face; size_ = fsize;}
+// virtual Fl_Font font() {return font_; }
+// virtual Fl_Fontsize size() {return size_; }
+ virtual double width(const char *str, int n);
+// virtual double width(unsigned int c) { char ch = (char)c; return width(&ch, 1); }
+ virtual void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
+ virtual int height();
+ virtual int descent();
+// virtual Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;}
+// virtual void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;}
+// // --- implementation is in src/fl_image.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_font.cxx
+ virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) ;
+// virtual fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array) { return 0; }
+// virtual fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array) { return 0; }
+// virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_) { }
+ virtual void delete_bitmask(Fl_Bitmask bm) ;
+// virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) {}
+// virtual void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) {}
+// virtual void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) {}
+// virtual void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) {}
+// /** \brief Draws an Fl_RGB_Image object to the device.
+// *
+// Specifies a bounding box for the image, with the origin (upper left-hand corner) of
+// the image offset by the cx and cy arguments.
+// */
+// virtual void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) {}
+// /** \brief Draws an Fl_Pixmap object to the device.
+// *
+// Specifies a bounding box for the image, with the origin (upper left-hand corner) of
+// the image offset by the cx and cy arguments.
+// */
+// virtual void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) {}
+// /** \brief Draws an Fl_Bitmap object to the device.
+// *
+// Specifies a bounding box for the image, with the origin (upper left-hand corner) of
+// the image offset by the cx and cy arguments.
+// */
+// virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {}
+// virtual int draw_scaled(Fl_Image *img, int X, int Y, int W, int H);
+// virtual void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
+//
+// /** Sets the value of the driver-specific graphics context. */
+// virtual void gc(void*) {}
+// /** Returns the driver-specific graphics context, of NULL if there's none. */
+// virtual void *gc(void) {return NULL;}
+// /** Support for pixmap drawing */
+// virtual uchar **mask_bitmap() { return 0; }
+// /** Support for pixmap drawing */
+// virtual void mask_bitmap(uchar **) {}
+//protected:
+// // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx
+// virtual void transformed_vertex0(COORD_T x, COORD_T y);
+// virtual void fixloop();
+// void global_gc(void);
+};
+
+#endif // FL_PICO_GRAPHICS_DRIVER_H
+
+//
+// End of "$Id: Fl_Pico_Graphics_Driver.H 11017 2016-01-20 21:40:12Z matt $".
+//
diff --git a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx
index 8b1378917..873e51c79 100644
--- a/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx
+++ b/src/drivers/Pico/Fl_Pico_Graphics_Driver.cxx
@@ -1 +1,300 @@
+//
+// "$Id: Fl_Pico_Graphics_Driver.cxx 11241 2016-02-27 13:52:27Z manolo $"
+//
+// 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
+//
+
+#include "../../config_lib.h"
+#include "Fl_Pico_Graphics_Driver.h"
+
+void Fl_Pico_Graphics_Driver::point(int x, int y)
+{
+ // implement in derived class
+}
+
+void Fl_Pico_Graphics_Driver::rect(int x, int y, int w, int h)
+{
+ line(x, y, x+w, y);
+ line(x+w, y, x+w, y+h);
+ line(x+w, y+h, x, y+h);
+ line(x, y+h, x, y);
+}
+
+void Fl_Pico_Graphics_Driver::rectf(int x, int y, int w, int h)
+{
+ // implement in derived class
+}
+
+void Fl_Pico_Graphics_Driver::line(int x, int y, int x1, int y1)
+{
+ // implement in derived class
+}
+
+void Fl_Pico_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2)
+{
+ line(x, y, x1, y1);
+ line(x1, y1, x2, y2);
+}
+
+void Fl_Pico_Graphics_Driver::xyline(int x, int y, int x1)
+{
+ line(x, y, x1, y);
+}
+
+void Fl_Pico_Graphics_Driver::xyline(int x, int y, int x1, int y2)
+{
+ line(x, y, x1, y, x1, y2);
+}
+
+void Fl_Pico_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3)
+{
+ line(x, y, x1, y, x1, y2);
+ line(x1, y2, x3, y2);
+}
+
+void Fl_Pico_Graphics_Driver::yxline(int x, int y, int y1)
+{
+ line(x, y, x, y1);
+}
+
+void Fl_Pico_Graphics_Driver::yxline(int x, int y, int y1, int x2)
+{
+ line(x, y, x, y1, x2, y1);
+}
+
+void Fl_Pico_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3)
+{
+ line(x, y, x, y1, x2, y1);
+ line(x2, y1, x2, y3);
+}
+
+void Fl_Pico_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2)
+{
+ line(x0, y0, x1, y1);
+ line(x1, y1, x2, y2);
+ line(x2, y2, x0, y0);
+}
+
+void Fl_Pico_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
+{
+ line(x0, y0, x1, y1);
+ line(x1, y1, x2, y2);
+ line(x2, y2, x3, y3);
+ line(x3, y3, x0, y0);
+}
+
+void Fl_Pico_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2)
+{
+}
+
+void Fl_Pico_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
+{
+}
+
+void Fl_Pico_Graphics_Driver::push_clip(int x, int y, int w, int h)
+{
+}
+
+int Fl_Pico_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
+{
+ return 0;
+}
+
+int Fl_Pico_Graphics_Driver::not_clipped(int x, int y, int w, int h)
+{
+ return 1;
+}
+
+void Fl_Pico_Graphics_Driver::push_no_clip()
+{
+}
+
+void Fl_Pico_Graphics_Driver::pop_clip()
+{
+}
+
+void Fl_Pico_Graphics_Driver::begin_complex_polygon()
+{
+}
+
+void Fl_Pico_Graphics_Driver::transformed_vertex(double xf, double yf)
+{
+}
+
+static double px, py; // FIXME: aaaah!
+
+void Fl_Pico_Graphics_Driver::vertex(double x, double y)
+{
+ if (n>0) {
+ if (what==LINE) {
+ line(px, py, x, y);
+ }
+ }
+ n++;
+ px = x; py = y;
+}
+
+void Fl_Pico_Graphics_Driver::end_points()
+{
+}
+
+void Fl_Pico_Graphics_Driver::end_line()
+{
+ // nothing to do
+}
+
+void Fl_Pico_Graphics_Driver::end_loop()
+{
+}
+
+void Fl_Pico_Graphics_Driver::end_polygon()
+{
+}
+
+void Fl_Pico_Graphics_Driver::end_complex_polygon()
+{
+}
+
+void Fl_Pico_Graphics_Driver::gap()
+{
+}
+
+void Fl_Pico_Graphics_Driver::circle(double x, double y, double r)
+{
+}
+
+void Fl_Pico_Graphics_Driver::arc(int x, int y, int w, int h, double a1, double a2)
+{
+}
+
+void Fl_Pico_Graphics_Driver::pie(int x, int y, int w, int h, double a1, double a2)
+{
+}
+
+void Fl_Pico_Graphics_Driver::line_style(int style, int width, char* dashes)
+{
+}
+
+void Fl_Pico_Graphics_Driver::color(uchar r, uchar g, uchar b)
+{
+}
+
+Fl_Bitmask Fl_Pico_Graphics_Driver::create_bitmask(int w, int h, const uchar *array)
+{
+ return 0;
+}
+
+void Fl_Pico_Graphics_Driver::delete_bitmask(Fl_Bitmask bm)
+{
+}
+
+
+
+/*
+ |01234567|
+ -+--------+
+ 0| |____
+ 1|++++++++|font
+ 2|++++++++|
+ 3|++++++++|
+ 4|++++++++|
+ 5|++++++++|____
+ 6| |descent
+ 7| |
+ -+--------+
+ */
+
+
+static const char *font_data[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ /* */0, /*!*/"\31\34\100\35\36", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ /*H*/"\11\15\100\61\65\100\13\63", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, /*T*/"\11\71\100\41\45", 0, 0, /*W*/"\01\15\33\55\61",
+ 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, /*d*/"\64\55\55\25\14\13\22\52\63\100\61\65", /*e*/"\55\25\14\13\22\52\63\64\14", 0, 0,
+ 0, 0, 0, 0, /*l*/"\31\34\45", 0, 0, /*o*/"\55\25\14\13\22\52\63\64\55",
+ 0, 0, /*r*/"\25\22\100\23\32\52", /*s*/"\62\22\13\64\55\15", /*t*/"\41\44\55\65\100\22\62", 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+
+double Fl_Pico_Graphics_Driver::width(const char *str, int n) {
+ return size_*n*0.5;
+}
+
+int Fl_Pico_Graphics_Driver::descent() {
+ return (int)(size_ - size_*0.8);
+}
+
+int Fl_Pico_Graphics_Driver::height() {
+ return (int)(size_);
+}
+
+void Fl_Pico_Graphics_Driver::text_extents(const char *str, int n, int& dx, int& dy, int& w, int& h)
+{
+ dx = 0;
+ dy = descent();
+ w = (int)width(str, n);
+ h = size_;
+}
+
+void Fl_Pico_Graphics_Driver::draw(const char *str, int n, int x, int y)
+{
+ int i;
+ for (i=0; i<n; i++) {
+ char c = str[i] & 0x7f;
+ const char *fd = font_data[(int)c];
+ if (fd) {
+ char rendering = 0;
+ float px=0.0f, py=0.0f;
+ for (;;) {
+ char cmd = *fd++;
+ if (cmd==0) {
+ if (rendering) {
+ end_line();
+ rendering = 0;
+ }
+ break;
+ } else if (cmd>63) {
+ if (cmd=='\100' && rendering) {
+ end_line();
+ rendering = 0;
+ }
+ } else {
+ if (!rendering) { begin_line(); rendering = 1; }
+ int vx = (cmd & '\70')>>3;
+ int vy = (cmd & '\07');
+ px = (int)(0.5+x+vx*size_*0.5/8.0);
+ py = (int)(0.5+y+vy*size_/8.0-0.8*size_);
+ vertex(px, py);
+ }
+ }
+ }
+ x += size_*0.5;
+ }
+}
+
+
+
+//
+// End of "$Id: Fl_Pico_Graphics_Driver.cxx 11241 2016-02-27 13:52:27Z manolo $".
+//
diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.H b/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.H
index 8b1378917..d9ab01b0f 100644
--- a/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.H
+++ b/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.H
@@ -1 +1,125 @@
+//
+// "$Id: Fl_PicoSDL_Graphics_Driver.H 11017 2016-01-20 21:40:12Z matt $"
+//
+// Definition of the Pico minimal SDL graphics driver
+// 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 Fl_PicoSDL_Graphics_Driver.H
+ \brief Definition of Pico minimal graphics driver.
+ */
+
+#ifndef FL_PICOSDL_GRAPHICS_DRIVER_H
+#define FL_PICOSDL_GRAPHICS_DRIVER_H
+
+#include "../Pico/Fl_Pico_Graphics_Driver.H"
+
+
+/**
+ \brief The Pico minimal SDL graphics class.
+ *
+ This class is implemented as a base class for minimal core SDL drivers.
+ */
+class Fl_PicoSDL_Graphics_Driver : public Fl_Pico_Graphics_Driver {
+protected:
+ // CGContextRef gc_;
+public:
+ // virtual int has_feature(driver_feature mask) { return mask & NATIVE; }
+ // virtual void gc(void *ctxt) {if (ctxt != gc_) global_gc(); gc_ = (CGContextRef)ctxt; }
+ // virtual void *gc() {return gc_;}
+ // char can_do_alpha_blending();
+ //
+ // // --- bitmap stuff
+ // Fl_Bitmask create_bitmask(int w, int h, const uchar *array);
+ // void delete_bitmask(Fl_Bitmask bm);
+ // 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);
+ // int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
+ // 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);
+ // fl_uintptr_t cache(Fl_Pixmap *img, int w, int h, const char *const*array);
+ // fl_uintptr_t cache(Fl_Bitmap *img, int w, int h, const uchar *array);
+ // void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_);
+ // void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
+ // void draw_CGImage(CGImageRef cgimg, int x, int y, int w, int h, int srcx, int srcy, int sw, int sh);
+ //protected:
+ // // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/quartz_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);
+ // // --- implementation is in src/fl_font.cxx which includes src/cfg_gfx/xxx_font.cxx
+ // void draw(const char *str, int n, int x, int y);
+ // void draw(const char *str, int n, float x, float 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 fsize);
+ // 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();
+};
+
+#endif // FL_PICOSDL_GRAPHICS_DRIVER_H
+
+//
+// End of "$Id: Fl_PicoSDL_Graphics_Driver.H 11017 2016-01-20 21:40:12Z matt $".
+//
diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.cxx b/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.cxx
index 8b1378917..4964fce58 100644
--- a/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.cxx
+++ b/src/drivers/PicoSDL/Fl_PicoSDL_Graphics_Driver.cxx
@@ -1 +1,71 @@
+//
+// "$Id: Fl_PicoSDL_Graphics_Driver.cxx 11241 2016-02-27 13:52:27Z manolo $"
+//
+// 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
+//
+
+#include "../../config_lib.h"
+#include "Fl_PicoSDL_Graphics_Driver.h"
+
+#include <FL/Fl.H>
+#define __APPLE__
+#include <SDL2/SDL.h>
+#undef __APPLE__
+
+/*
+ * By linking this module, the following static method will instatiate the
+ * PicoSDL Graphics driver as the main display driver.
+ */
+Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
+{
+ return new Fl_PicoSDL_Graphics_Driver();
+}
+
+
+void Fl_PicoSDL_Graphics_Driver::rectf(int x, int y, int w, int h)
+{
+ uchar r, g, b;
+ Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
+ printf("[] %d %d %d\n", r, g, b);
+ SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
+ SDL_Rect rect = {x, y, w, h};
+ SDL_RenderFillRect((SDL_Renderer*)fl_window, &rect);
+}
+
+
+void Fl_PicoSDL_Graphics_Driver::line(int x, int y, int x1, int y1)
+{
+ uchar r, g, b;
+ Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
+ printf("-- %d %d %d\n", r, g, b);
+ SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
+ SDL_RenderDrawLine((SDL_Renderer*)fl_window, x, y, x1, y1);
+}
+
+
+void Fl_PicoSDL_Graphics_Driver::point(int x, int y)
+{
+ uchar r, g, b;
+ Fl::get_color(Fl_Graphics_Driver::color(), r, g, b);
+ SDL_SetRenderDrawColor((SDL_Renderer*)fl_window, r, g, b, SDL_ALPHA_OPAQUE);
+ SDL_RenderDrawPoint((SDL_Renderer*)fl_window, x, y);
+}
+
+
+
+//
+// End of "$Id: Fl_PicoSDL_Graphics_Driver.cxx 11241 2016-02-27 13:52:27Z manolo $".
+//
diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx b/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx
index cf25d1091..a4a44a748 100644
--- a/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx
+++ b/src/drivers/PicoSDL/Fl_PicoSDL_Screen_Driver.cxx
@@ -44,11 +44,32 @@ Fl_PicoSDL_Screen_Driver::~Fl_PicoSDL_Screen_Driver()
double Fl_PicoSDL_Screen_Driver::wait(double time_to_wait)
{
+ Fl::flush();
SDL_Event e;
if (SDL_PollEvent(&e)) {
- if (e.type == SDL_QUIT) {
- exit(0);
- // TODO: do something
+ switch (e.type) {
+ case SDL_QUIT:
+ exit(0);
+ case SDL_WINDOWEVENT_EXPOSED:
+ case SDL_WINDOWEVENT_SHOWN:
+ { // not happening!
+ //event->window.windowID
+ Fl_Window *window = Fl::first_window();
+ if ( !window ) break;;
+ Fl_X *i = Fl_X::i(Fl::first_window());
+ i->wait_for_expose = 0;
+
+ if ( i->region ) {
+ XDestroyRegion(i->region);
+ i->region = 0;
+ }
+ window->clear_damage(FL_DAMAGE_ALL);
+ i->flush();
+ window->clear_damage();
+ Fl_X::first->wait_for_expose = 0;
+ }
+ break;
+
}
}
return 0.0;
@@ -82,7 +103,7 @@ const char *fl_filename_name(char const*) { return 0; }
void fl_clipboard_notify_change() { }
//Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver() { return 0; }
-Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() { return 0; }
+//Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() { return 0; }
void Fl_Graphics_Driver::global_gc() { }
int Fl::dnd() { return 0; }
void Fl::copy(char const*, int, int, char const*) { }
@@ -92,11 +113,22 @@ void Fl::set_color(unsigned int, unsigned int) { }
int Fl_X::set_cursor(Fl_Cursor) { return 0; }
int Fl_X::set_cursor(Fl_RGB_Image const*, int, int) { return 0; }
void Fl_X::set_default_icons(Fl_RGB_Image const**, int) { }
-void Fl_X::flush() { }
+
+void Fl_X::flush()
+{
+ w->driver()->flush();
+}
+
void Fl_X::set_icons() { }
void Fl_Window::size_range_() { }
void Fl_Window::fullscreen_x() { }
-void Fl_Window::make_current() { }
+
+void Fl_Window::make_current()
+{
+ fl_window = i->xid;
+ current_ = this;
+}
+
void Fl_Window::fullscreen_off_x(int, int, int, int) { }
Window fl_xid(const Fl_Window* w)
@@ -113,29 +145,7 @@ void Fl_Window::show() {
Fl_X* Fl_X::make(Fl_Window *w)
{
- Fl_Group::current(0);
- if (w->parent() && !Fl_X::i(w->window())) {
- w->set_visible();
- return 0L;
- }
- Window parent;
- if (w->parent()) {
- parent = fl_xid(w->window());
- } else {
- parent = 0;
- }
- Fl_X *x = new Fl_X;
- x->other_xid = 0;
- x->w = w;
- x->region = 0;
- if (!w->force_position()) {
- x->xid = SDL_CreateWindow(w->label(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w->w(), w->h(), 0);
- } else {
- x->xid = SDL_CreateWindow(w->label(), w->x(), w->y(), w->w(), w->h(), 0);
- }
- x->next = Fl_X::first;
- Fl_X::first = x;
- return x;
+ return w->driver()->makeWindow();
}
void Fl_Window::label(char const*, char const*) { }
diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.H b/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.H
index 6246211a9..cc4fb81c4 100644
--- a/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.H
+++ b/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.H
@@ -27,12 +27,20 @@
#include "../Pico/Fl_Pico_Window_Driver.H"
+#define __APPLE__
+#include <SDL2/SDL.h>
+#undef __APPLE__
+
class FL_EXPORT Fl_PicoSDL_Window_Driver : public Fl_Pico_Window_Driver
{
+ SDL_Window *pNativeWindow;
public:
Fl_PicoSDL_Window_Driver(Fl_Window *win);
virtual ~Fl_PicoSDL_Window_Driver();
+
+ virtual Fl_X *makeWindow();
+ virtual void flush();
};
diff --git a/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx b/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx
index 60b9bb383..5b009bd4a 100644
--- a/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx
+++ b/src/drivers/PicoSDL/Fl_PicoSDL_Window_Driver.cxx
@@ -19,6 +19,7 @@
#include "../../config_lib.h"
#include "Fl_PicoSDL_Window_Driver.H"
+#include <FL/Fl.H>
Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *win)
@@ -38,6 +39,53 @@ Fl_PicoSDL_Window_Driver::~Fl_PicoSDL_Window_Driver()
}
+Fl_X *Fl_PicoSDL_Window_Driver::makeWindow()
+{
+ Fl_Group::current(0);
+ if (pWindow->parent() && !Fl_X::i(pWindow->window())) {
+ pWindow->set_visible();
+ return 0L;
+ }
+ Window parent;
+ if (pWindow->parent()) {
+ parent = fl_xid(pWindow->window());
+ } else {
+ parent = 0;
+ }
+ Fl_X *x = new Fl_X;
+ x->other_xid = 0;
+ x->w = pWindow;
+ x->region = 0;
+ if (!pWindow->force_position()) {
+ pNativeWindow = SDL_CreateWindow(pWindow->label(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, pWindow->w(), pWindow->h(), 0);
+ } else {
+ pNativeWindow = SDL_CreateWindow(pWindow->label(), pWindow->x(), pWindow->y(), pWindow->w(), pWindow->h(), 0);
+ }
+ x->xid = SDL_CreateRenderer(pNativeWindow, -1, SDL_RENDERER_ACCELERATED);
+ x->next = Fl_X::first;
+ x->wait_for_expose = 0;
+ pWindow->i = x;
+ Fl_X::first = x;
+
+ pWindow->set_visible();
+ pWindow->redraw();
+ flush();
+ int old_event = Fl::e_number;
+ pWindow->handle(Fl::e_number = FL_SHOW);
+ Fl::e_number = old_event;
+
+ return x;
+}
+
+
+void Fl_PicoSDL_Window_Driver::flush()
+{
+ SDL_RenderClear((SDL_Renderer*)fl_window);
+ pWindow->flush();
+ SDL_RenderPresent((SDL_Renderer*)fl_window);
+}
+
+
//
// End of "$Id: Fl_PicoSDL_Window_Driver.cxx 11253 2016-03-01 00:54:21Z matt $".
// \ No newline at end of file