diff options
Diffstat (limited to 'test/penpal.cxx')
| -rw-r--r-- | test/penpal.cxx | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/test/penpal.cxx b/test/penpal.cxx index 9b5ddde16..eec1307bb 100644 --- a/test/penpal.cxx +++ b/test/penpal.cxx @@ -37,8 +37,8 @@ extern Fl_Menu_Item app_menu[]; extern int popup_app_menu(); -Fl_Widget *cv1 { nullptr }; -Fl_Window *cvwin { nullptr }; +Fl_Widget *cv1 = 0; +Fl_Window *cvwin = 0; // // The canvas interface implements incremental drawing and handles draw events. @@ -46,17 +46,21 @@ Fl_Window *cvwin { nullptr }; // And it implements an overlay plane that visualizes pen event data. // class CanvasInterface { - Fl_Widget *widget_ { nullptr }; - bool in_window_ { false }; - bool first_draw_ { true }; - Fl_Offscreen offscreen_ { 0 }; - Fl_Color color_ { 1 }; - enum { NONE, HOVER, DRAW, PEN_HOVER, PEN_DRAW } overlay_ { NONE }; - int ov_x_ { 0 }; - int ov_y_ { 0 }; + Fl_Widget *widget_; + bool in_window_; + bool first_draw_; + Fl_Offscreen offscreen_; + Fl_Color color_; + enum { NONE, HOVER, DRAW, PEN_HOVER, PEN_DRAW } overlay_; + int ov_x_; + int ov_y_; public: - CanvasInterface(Fl_Widget *w) : widget_(w) { } - CanvasInterface(Fl_Window *w) : widget_(w), in_window_(true) { } + CanvasInterface(Fl_Widget *w) + : widget_(w), in_window_(false), first_draw_(true), offscreen_(0), + color_(1), overlay_(NONE), ov_x_(0), ov_y_(0) { } + CanvasInterface(Fl_Window *w) + : widget_(w), in_window_(true), first_draw_(true), offscreen_(0), + color_(1), overlay_(NONE), ov_x_(0), ov_y_(0) { } ~CanvasInterface() { if (offscreen_) fl_delete_offscreen(offscreen_); } @@ -215,15 +219,15 @@ void CanvasInterface::cv_pen_paint() { // class CanvasWidget : public Fl_Widget, CanvasInterface { public: - CanvasWidget(int x, int y, int w, int h, const char *l=nullptr) + CanvasWidget(int x, int y, int w, int h, const char *l=0) : Fl_Widget(x, y, w, h, l), CanvasInterface(this) { } - ~CanvasWidget() override { } - int handle(int event) override { + ~CanvasWidget() { } + int handle(int event) { // puts(fl_eventname_str(event).c_str()); - auto ret = cv_handle(event); + int ret = cv_handle(event); return ret ? ret : Fl_Widget::handle(event); } - void draw() override { return cv_draw(); } + void draw() { return cv_draw(); } }; // @@ -232,14 +236,14 @@ public: // class CanvasWindow : public Fl_Window, CanvasInterface { public: - CanvasWindow(int x, int y, int w, int h, const char *l=nullptr) + CanvasWindow(int x, int y, int w, int h, const char *l=0) : Fl_Window(x, y, w, h, l), CanvasInterface(this) { } - ~CanvasWindow() override { } - int handle(int event) override { - auto ret = cv_handle(event); + ~CanvasWindow() { } + int handle(int event) { + int ret = cv_handle(event); return ret ? ret : Fl_Window::handle(event); } - void draw() override { return cv_draw(); } + void draw() { return cv_draw(); } }; // A popup menu with a few test tasks. @@ -249,7 +253,7 @@ Fl_Menu_Item app_menu[] = { "pen events while this window is open."); } }, { "with non-modal window", 0, [](Fl_Widget*, void*) { - auto w = new Fl_Window(400, 32, "Toolbox"); + Fl_Window *w = new Fl_Window(400, 32, "Toolbox"); w->set_non_modal(); w->show(); } }, @@ -260,16 +264,16 @@ Fl_Menu_Item app_menu[] = { if (cv1) Fl::Pen::subscribe(cv1); } }, { "delete middle canvas", 0, [](Fl_Widget*, void*) { - if (cv1) { cv1->top_window()->redraw(); delete cv1; cv1 = nullptr; } + if (cv1) { cv1->top_window()->redraw(); delete cv1; cv1 = 0; } } }, - { nullptr } + { 0 } }; // // Show the menu and run the callback. // int popup_app_menu() { - auto mi = app_menu->popup(Fl::event_x(), Fl::event_y(), "Tests"); + const Fl_Menu_Item *mi = app_menu->popup(Fl::event_x(), Fl::event_y(), "Tests"); if (mi) mi->do_callback((Fl_Widget*)mi); return 1; } @@ -280,26 +284,26 @@ int popup_app_menu() { int main(int argc, char **argv) { // Create our main app window - auto window = new Fl_Window(100, 100, 640, 220, "FLTK Pen/Stylus/Tablet test, Ctrl-Tap for menu"); + Fl_Window *window = new Fl_Window(100, 100, 640, 220, "FLTK Pen/Stylus/Tablet test, Ctrl-Tap for menu"); // One testing canvas is just a regular child widget of the window - auto canvas_widget_0 = new CanvasWidget( 10, 10, 200, 200, "CV0"); + CanvasWidget *canvas_widget_0 = new CanvasWidget( 10, 10, 200, 200, "CV0"); // The second canvas is inside a group - auto cv1_group = new Fl_Group(215, 5, 210, 210); + Fl_Group *cv1_group = new Fl_Group(215, 5, 210, 210); cv1_group->box(FL_FRAME_BOX); - auto canvas_widget_1 = cv1 = new CanvasWidget(220, 10, 200, 200, "CV1"); + CanvasWidget *canvas_widget_1 = cv1 = new CanvasWidget(220, 10, 200, 200, "CV1"); cv1_group->end(); // The third canvas is a window inside a window, so we can verify // that pen coordinates are calculated correctly. - auto canvas_widget_2 = new CanvasWindow(430, 10, 200, 200, "CV2"); + CanvasWindow *canvas_widget_2 = new CanvasWindow(430, 10, 200, 200, "CV2"); canvas_widget_2->end(); window->end(); // A fourth canvas is a top level window by itself. - auto cv_window = cvwin = new CanvasWindow(100, 380, 200, 200, "Canvas Window"); + CanvasWindow *cv_window = cvwin = new CanvasWindow(100, 380, 200, 200, "Canvas Window"); // All canvases subscribe to pen events. Fl::Pen::subscribe(canvas_widget_0); |
