From 1358c434b227276896a08e07000dbd56acb3f49c Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 12 Nov 2016 13:28:53 +0000 Subject: Rename misspelled files. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12106 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/CMakeLists.txt | 4 +- src/Makefile | 4 +- src/forms_compatability.cxx | 204 ------------------- src/forms_compatibility.cxx | 204 +++++++++++++++++++ src/glut_compatability.cxx | 484 -------------------------------------------- src/glut_compatibility.cxx | 484 ++++++++++++++++++++++++++++++++++++++++++++ src/makedepend | 80 ++++---- 7 files changed, 732 insertions(+), 732 deletions(-) delete mode 100644 src/forms_compatability.cxx create mode 100644 src/forms_compatibility.cxx delete mode 100644 src/glut_compatability.cxx create mode 100644 src/glut_compatibility.cxx (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c43a8557..4af7eb2a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -310,7 +310,7 @@ set (CPPFILES ) set (FLCPPFILES - forms_compatability.cxx + forms_compatibility.cxx forms_bitmap.cxx forms_free.cxx forms_fselect.cxx @@ -329,7 +329,7 @@ set (GLCPPFILES freeglut_teapot.cxx gl_draw.cxx gl_start.cxx - glut_compatability.cxx + glut_compatibility.cxx glut_font.cxx ) diff --git a/src/Makefile b/src/Makefile index 0e767b404..5059e2012 100644 --- a/src/Makefile +++ b/src/Makefile @@ -168,7 +168,7 @@ OBJCPPFILES = \ Fl_Sys_Menu_Bar.mm FLCPPFILES = \ - forms_compatability.cxx \ + forms_compatibility.cxx \ forms_bitmap.cxx \ forms_free.cxx \ forms_fselect.cxx \ @@ -186,7 +186,7 @@ GLCPPFILES = \ freeglut_teapot.cxx \ gl_draw.cxx \ gl_start.cxx \ - glut_compatability.cxx \ + glut_compatibility.cxx \ glut_font.cxx \ drivers/OpenGL/Fl_OpenGL_Display_Device.cxx \ drivers/OpenGL/Fl_OpenGL_Graphics_Driver.cxx \ diff --git a/src/forms_compatability.cxx b/src/forms_compatability.cxx deleted file mode 100644 index d66fa7ab5..000000000 --- a/src/forms_compatability.cxx +++ /dev/null @@ -1,204 +0,0 @@ -// -// "$Id$" -// -// Forms compatibility functions for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2010 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 -// - -// Forms library compatibility functions. -// Many more functions are defined as inlines in forms.h! - -#include -#include - -char fl_flip = 2; -void fl_end_form() { - while (Fl_Group::current()) Fl_Group::current()->forms_end(); -} -void Fl_Group::forms_end() { - // set the dimensions of a group to surround contents - if (children() && !w()) { - Fl_Widget*const* a = array(); - Fl_Widget* o = *a++; - int rx = o->x(); - int ry = o->y(); - int rw = rx+o->w(); - int rh = ry+o->h(); - for (int i=children_-1; i--;) { - o = *a++; - if (o->x() < rx) rx = o->x(); - if (o->y() < ry) ry = o->y(); - if (o->x()+o->w() > rw) rw = o->x()+o->w(); - if (o->y()+o->h() > rh) rh = o->y()+o->h(); - } - x(rx); - y(ry); - w(rw-rx); - h(rh-ry); - } - // flip all the children's coordinate systems: - if (fl_flip) { - Fl_Widget* o = (type()>=FL_WINDOW) ? this : window(); - int Y = o->h(); - Fl_Widget*const* a = array(); - for (int i=children(); i--;) { - Fl_Widget* ow = *a++; - int newy = Y-ow->y()-ow->h(); - ow->y(newy); - } - } - end(); -} - -static int initargc; -static char **initargv; - -void fl_initialize(int *argc, char **argv, const char *, FL_CMD_OPT *, int) { - initargc = *argc; - initargv = new char*[*argc+1]; - int i,j; - for (i=0; i<=*argc; i++) initargv[i] = argv[i]; - for (i=j=1; i<*argc; ) { - if (Fl::arg(*argc,argv,i)); - else argv[j++] = argv[i++]; - } - argv[j] = 0; - *argc = j; - if (fl_flip==2) fl_flip = 0; -} - -char fl_modal_next; // set by fl_freeze_forms() - -void fl_show_form(Fl_Window *f,int place,int b,const char *n) { - - f->label(n); - if (!b) f->clear_border(); - if (fl_modal_next || b==FL_TRANSIENT) {f->set_modal(); fl_modal_next = 0;} - - if (place & FL_PLACE_MOUSE) f->hotspot(f); - - if (place & FL_PLACE_CENTER) { - int scr_x, scr_y, scr_w, scr_h; - Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h); - f->position(scr_x+(scr_w-f->w())/2, scr_y+(scr_h-f->h())/2); - } - - if (place & FL_PLACE_FULLSCREEN) - f->fullscreen(); - - if (place & (FL_PLACE_POSITION | FL_PLACE_GEOMETRY)) - f->position( - (f->x() < 0) ? Fl::w()-f->w()+f->x()-1 : f->x(), - (f->y() < 0) ? Fl::h()-f->h()+f->y()-1 : f->y()); - -// if (place & FL_PLACE_ASPECT) { -// this is not yet implemented -// it can be done by setting size_range(). - - if (place == FL_PLACE_FREE || place == FL_PLACE_SIZE) - f->free_position(); - - if (place == FL_PLACE_FREE || place & FL_FREE_SIZE) - if (!f->resizable()) f->resizable(f); - - if (initargc) {f->show(initargc,initargv); initargc = 0;} - else f->show(); -} - -Fl_Widget *fl_do_forms(void) { - Fl_Widget *obj; - while (!(obj = Fl::readqueue())) if (!Fl::wait()) exit(0); - return obj; -} - -Fl_Widget *fl_check_forms() { - Fl::check(); - return Fl::readqueue(); -} - -void fl_set_graphics_mode(int /*r*/,int /*d*/) {} - -#ifndef FL_DOXYGEN // FIXME: suppress doxygen warning -void Fl_FormsText::draw() { - draw_box(); - align(align()|FL_ALIGN_INSIDE); // questionable method of compatibility - draw_label(); -} -#endif - -// Create a forms button by selecting correct fltk subclass: - -#include -#include - -Fl_Button *fl_add_button(uchar t,int x,int y,int w,int h,const char *l) { - Fl_Button *b; - switch (t) { - case FL_RETURN_BUTTON: - case FL_HIDDEN_RET_BUTTON: - b = new Fl_Return_Button(x,y,w,h,l); - break; - case FL_TOUCH_BUTTON: - b = new Fl_Repeat_Button(x,y,w,h,l); - break; - default: - b = new Fl_Button(x,y,w,h,l); - } - switch (t) { - case FL_TOGGLE_BUTTON: - case FL_RADIO_BUTTON: - b->type(t); - break; - case FL_HIDDEN_BUTTON: - case FL_HIDDEN_RET_BUTTON: - b->type(FL_HIDDEN_BUTTON); - break; - case FL_INOUT_BUTTON: - b->when(FL_WHEN_CHANGED); - break; - } - return b; -} - -void fl_show_message(const char *q1,const char *q2,const char *q3) { - fl_message("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:""); -} - -void fl_show_alert(const char *q1,const char *q2,const char *q3,int) { - fl_alert("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:""); -} - -int fl_show_question(const char *q1,const char *q2,const char *q3) { - return fl_choice("%s\n%s\n%s", "No", "Yes", 0L, q1?q1:"", q2?q2:"", q3?q3:""); -} - -int fl_show_choice( - const char *q1, - const char *q2, - const char *q3, - int, // number of buttons, ignored - const char *b0, - const char *b1, - const char *b2) { - return fl_choice("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:"", b0,b1,b2)+1; -} - -char *fl_show_simple_input(const char *str1, const char *defstr) { - const char *r = fl_input("%s", defstr, str1); - return (char *)(r ? r : defstr); -} - -// -// End of "$Id$". -// diff --git a/src/forms_compatibility.cxx b/src/forms_compatibility.cxx new file mode 100644 index 000000000..d66fa7ab5 --- /dev/null +++ b/src/forms_compatibility.cxx @@ -0,0 +1,204 @@ +// +// "$Id$" +// +// Forms compatibility functions for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 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 +// + +// Forms library compatibility functions. +// Many more functions are defined as inlines in forms.h! + +#include +#include + +char fl_flip = 2; +void fl_end_form() { + while (Fl_Group::current()) Fl_Group::current()->forms_end(); +} +void Fl_Group::forms_end() { + // set the dimensions of a group to surround contents + if (children() && !w()) { + Fl_Widget*const* a = array(); + Fl_Widget* o = *a++; + int rx = o->x(); + int ry = o->y(); + int rw = rx+o->w(); + int rh = ry+o->h(); + for (int i=children_-1; i--;) { + o = *a++; + if (o->x() < rx) rx = o->x(); + if (o->y() < ry) ry = o->y(); + if (o->x()+o->w() > rw) rw = o->x()+o->w(); + if (o->y()+o->h() > rh) rh = o->y()+o->h(); + } + x(rx); + y(ry); + w(rw-rx); + h(rh-ry); + } + // flip all the children's coordinate systems: + if (fl_flip) { + Fl_Widget* o = (type()>=FL_WINDOW) ? this : window(); + int Y = o->h(); + Fl_Widget*const* a = array(); + for (int i=children(); i--;) { + Fl_Widget* ow = *a++; + int newy = Y-ow->y()-ow->h(); + ow->y(newy); + } + } + end(); +} + +static int initargc; +static char **initargv; + +void fl_initialize(int *argc, char **argv, const char *, FL_CMD_OPT *, int) { + initargc = *argc; + initargv = new char*[*argc+1]; + int i,j; + for (i=0; i<=*argc; i++) initargv[i] = argv[i]; + for (i=j=1; i<*argc; ) { + if (Fl::arg(*argc,argv,i)); + else argv[j++] = argv[i++]; + } + argv[j] = 0; + *argc = j; + if (fl_flip==2) fl_flip = 0; +} + +char fl_modal_next; // set by fl_freeze_forms() + +void fl_show_form(Fl_Window *f,int place,int b,const char *n) { + + f->label(n); + if (!b) f->clear_border(); + if (fl_modal_next || b==FL_TRANSIENT) {f->set_modal(); fl_modal_next = 0;} + + if (place & FL_PLACE_MOUSE) f->hotspot(f); + + if (place & FL_PLACE_CENTER) { + int scr_x, scr_y, scr_w, scr_h; + Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h); + f->position(scr_x+(scr_w-f->w())/2, scr_y+(scr_h-f->h())/2); + } + + if (place & FL_PLACE_FULLSCREEN) + f->fullscreen(); + + if (place & (FL_PLACE_POSITION | FL_PLACE_GEOMETRY)) + f->position( + (f->x() < 0) ? Fl::w()-f->w()+f->x()-1 : f->x(), + (f->y() < 0) ? Fl::h()-f->h()+f->y()-1 : f->y()); + +// if (place & FL_PLACE_ASPECT) { +// this is not yet implemented +// it can be done by setting size_range(). + + if (place == FL_PLACE_FREE || place == FL_PLACE_SIZE) + f->free_position(); + + if (place == FL_PLACE_FREE || place & FL_FREE_SIZE) + if (!f->resizable()) f->resizable(f); + + if (initargc) {f->show(initargc,initargv); initargc = 0;} + else f->show(); +} + +Fl_Widget *fl_do_forms(void) { + Fl_Widget *obj; + while (!(obj = Fl::readqueue())) if (!Fl::wait()) exit(0); + return obj; +} + +Fl_Widget *fl_check_forms() { + Fl::check(); + return Fl::readqueue(); +} + +void fl_set_graphics_mode(int /*r*/,int /*d*/) {} + +#ifndef FL_DOXYGEN // FIXME: suppress doxygen warning +void Fl_FormsText::draw() { + draw_box(); + align(align()|FL_ALIGN_INSIDE); // questionable method of compatibility + draw_label(); +} +#endif + +// Create a forms button by selecting correct fltk subclass: + +#include +#include + +Fl_Button *fl_add_button(uchar t,int x,int y,int w,int h,const char *l) { + Fl_Button *b; + switch (t) { + case FL_RETURN_BUTTON: + case FL_HIDDEN_RET_BUTTON: + b = new Fl_Return_Button(x,y,w,h,l); + break; + case FL_TOUCH_BUTTON: + b = new Fl_Repeat_Button(x,y,w,h,l); + break; + default: + b = new Fl_Button(x,y,w,h,l); + } + switch (t) { + case FL_TOGGLE_BUTTON: + case FL_RADIO_BUTTON: + b->type(t); + break; + case FL_HIDDEN_BUTTON: + case FL_HIDDEN_RET_BUTTON: + b->type(FL_HIDDEN_BUTTON); + break; + case FL_INOUT_BUTTON: + b->when(FL_WHEN_CHANGED); + break; + } + return b; +} + +void fl_show_message(const char *q1,const char *q2,const char *q3) { + fl_message("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:""); +} + +void fl_show_alert(const char *q1,const char *q2,const char *q3,int) { + fl_alert("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:""); +} + +int fl_show_question(const char *q1,const char *q2,const char *q3) { + return fl_choice("%s\n%s\n%s", "No", "Yes", 0L, q1?q1:"", q2?q2:"", q3?q3:""); +} + +int fl_show_choice( + const char *q1, + const char *q2, + const char *q3, + int, // number of buttons, ignored + const char *b0, + const char *b1, + const char *b2) { + return fl_choice("%s\n%s\n%s", q1?q1:"", q2?q2:"", q3?q3:"", b0,b1,b2)+1; +} + +char *fl_show_simple_input(const char *str1, const char *defstr) { + const char *r = fl_input("%s", defstr, str1); + return (char *)(r ? r : defstr); +} + +// +// End of "$Id$". +// diff --git a/src/glut_compatability.cxx b/src/glut_compatability.cxx deleted file mode 100644 index 13e06242a..000000000 --- a/src/glut_compatability.cxx +++ /dev/null @@ -1,484 +0,0 @@ -// -// "$Id$" -// -// GLUT emulation 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 -// - -// Emulation of Glut using fltk. - -// GLUT is Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. -// "This program is freely distributable without licensing fees and is -// provided without guarantee or warrantee expressed or implied. This -// program is -not- in the public domain." - -// Although I have copied the GLUT API, none of my code is based on -// any Glut implementation details and is therefore covered by the LGPL. - -#include "flstring.h" -#if HAVE_GL -# include -# include -# define MAXWINDOWS 32 - -static Fl_Glut_Window *windows[MAXWINDOWS+1]; - -static void (*glut_idle_func)() = 0; // global glut idle function - -Fl_Glut_Window *glut_window; -int glut_menu; -void (*glut_menustate_function)(int); -void (*glut_menustatus_function)(int,int,int); - -static void default_reshape(int w, int h) {glViewport(0,0,w,h);} -static void default_display() {} - -void Fl_Glut_Window::make_current() { - glut_window = this; - if (shown()) Fl_Gl_Window::make_current(); -} - -static int indraw; -void Fl_Glut_Window::draw() { - glut_window = this; - indraw = 1; - if (!valid()) {reshape(pixel_w(),pixel_h()); valid(1);} - display(); - indraw = 0; -} - -void glutSwapBuffers() { - if (!indraw) glut_window->swap_buffers(); -} - -void Fl_Glut_Window::draw_overlay() { - glut_window = this; - if (!valid()) {reshape(pixel_w(),pixel_h()); valid(1);} - overlaydisplay(); -} - -static void domenu(int, int, int); - -int Fl_Glut_Window::handle(int event) { - make_current(); - int ex = Fl::event_x(); - int ey = Fl::event_y(); - float factor = pixels_per_unit(); - ex = int(ex * factor + 0.5f); - ey = int(ey * factor + 0.5f); - int button; - switch (event) { - - case FL_PUSH: - if (keyboard || special) Fl::focus(this); - button = Fl::event_button()-1; - if (button<0) button = 0; - if (button>2) button = 2; - if (menu[button]) {domenu(menu[button],ex,ey); return 1;} - mouse_down |= 1< 0) {if (mouse) mouse(4,GLUT_DOWN,ex,ey); --button;} - return 1; - - case FL_RELEASE: - for (button = 0; button < 3; button++) if (mouse_down & (1< FL_F && k <= FL_F_Last) k -= FL_F; - special(k,ex,ey); - return 1; - } - break; - } - - case FL_HIDE: - if (visibility) visibility(GLUT_NOT_VISIBLE); - break; - - case FL_SHOW: - if (visibility) visibility(GLUT_VISIBLE); - break; - } - - return Fl_Gl_Window::handle(event); -} - -static int glut_mode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH; - -void Fl_Glut_Window::_init() { - for (number=1; numberresizable(W); - if (initargc) { - W->show(initargc,initargv); - initargc = 0; - } else { - W->show(); - } - W->valid(0); - W->context_valid(0); - W->make_current(); - return W->number; -} - -int glutCreateSubWindow(int win, int x, int y, int w, int h) { - Fl_Glut_Window *W = new Fl_Glut_Window(x,y,w,h,0); - windows[win]->add(W); - if (windows[win]->shown()) W->show(); - W->make_current(); - return W->number; -} -/** Destroys the glut window, first unregister it from the glut windows list */ -Fl_Glut_Window::~Fl_Glut_Window() { - if (glut_window == this) glut_window = 0; - windows[number] = 0; -} - -void glutDestroyWindow(int win) { - // should destroy children!!! - delete windows[win]; -} - -void glutPostWindowRedisplay(int win) { - windows[win]->redraw(); -} - -void glutSetWindow(int win) { - windows[win]->make_current(); -} - -//////////////////////////////////////////////////////////////// -#include - -struct menu { - void (*cb)(int); - Fl_Menu_Item *m; - int size; - int alloc; -}; - -#define MAXMENUS 32 -static menu menus[MAXMENUS+1]; - -static void domenu(int n, int ex, int ey) { - glut_menu = n; - menu *m = &menus[n]; - if (glut_menustate_function) glut_menustate_function(1); - if (glut_menustatus_function) glut_menustatus_function(1,ex,ey); - const Fl_Menu_Item* g = m->m->popup(Fl::event_x(), Fl::event_y(), 0); - if (g && g->callback_) ((void (*)(int))(g->callback_))(int(g->argument())); - if (glut_menustatus_function) glut_menustatus_function(0,ex,ey); - if (glut_menustate_function) glut_menustate_function(0); -} - -int glutCreateMenu(void (*cb)(int)) { - int i; - for (i=1; icb = cb; - return glut_menu = i; -} - -void glutDestroyMenu(int n) { - menu *m = &menus[n]; - delete[] m->m; - m->m = 0; - m->cb = 0; - m->size = m->alloc = 0; -} - -static Fl_Menu_Item* additem(menu *m) { - if (m->size+1 >= m->alloc) { - m->alloc = m->size*2+10; - Fl_Menu_Item* nm = new Fl_Menu_Item[m->alloc]; - for (int i=0; isize; i++) nm[i] = m->m[i]; - delete[] m->m; - m->m = nm; - } - int n = m->size++; - m->m[n+1].text = 0; - Fl_Menu_Item* i = &(m->m[n]); - i->shortcut_ = 0; - i->flags = 0; - i->labeltype_ = i->labelfont_ = i->labelsize_ = i->labelcolor_ = 0; - return i; -} - -void glutAddMenuEntry(char *label, int value) { - menu *m = &menus[glut_menu]; - Fl_Menu_Item* i = additem(m); - i->text = label; - i->callback_ = (Fl_Callback*)(m->cb); - i->argument(value); -} - -void glutAddSubMenu(char *label, int submenu) { - menu *m = &menus[glut_menu]; - Fl_Menu_Item* i = additem(m); - i->text = label; - i->callback_ = 0; - i->user_data_ = (void *)(menus[submenu].m); - i->flags = FL_PUP_SUBMENU; -} - -void glutChangeToMenuEntry(int item, char *label, int value) { - menu *m = &menus[glut_menu]; - Fl_Menu_Item* i = &m->m[item-1]; - i->text = label; - i->callback_ = (Fl_Callback*)(m->cb); - i->argument(value); - i->flags = 0; -} - -void glutChangeToSubMenu(int item, char *label, int submenu) { - menu *m = &menus[glut_menu]; - Fl_Menu_Item* i = &m->m[item-1]; - i->text = label; - i->callback_ = 0; - i->user_data_ = (void *)(menus[submenu].m); - i->flags = FL_PUP_SUBMENU; -} - -void glutRemoveMenuItem(int item) { - menu *m = &menus[glut_menu]; - if (item > m->size || item < 1) return; - for (int i = item-1; i <= m->size; i++) m->m[i] = m->m[i+1]; - m->size--; -} - -//////////////////////////////////////////////////////////////// - -int glutGet(GLenum type) { - switch (type) { - case GLUT_RETURN_ZERO: return 0; - case GLUT_WINDOW_X: return glut_window->x(); - case GLUT_WINDOW_Y: return glut_window->y(); - case GLUT_WINDOW_WIDTH: return glut_window->pixel_w(); - case GLUT_WINDOW_HEIGHT: return glut_window->pixel_h(); - case GLUT_WINDOW_PARENT: - if (glut_window->parent()) - return ((Fl_Glut_Window *)(glut_window->parent()))->number; - else - return 0; -//case GLUT_WINDOW_NUM_CHILDREN: -//case GLUT_WINDOW_CURSOR: return - case GLUT_SCREEN_WIDTH: return Fl::w(); - case GLUT_SCREEN_HEIGHT: return Fl::h(); -//case GLUT_SCREEN_WIDTH_MM: -//case GLUT_SCREEN_HEIGHT_MM: - case GLUT_MENU_NUM_ITEMS: return menus[glut_menu].size; - case GLUT_DISPLAY_MODE_POSSIBLE: return Fl_Gl_Window::can_do(glut_mode); - case GLUT_INIT_WINDOW_X: return initx; - case GLUT_INIT_WINDOW_Y: return inity; - case GLUT_INIT_WINDOW_WIDTH: return initw; - case GLUT_INIT_WINDOW_HEIGHT: return inith; - case GLUT_INIT_DISPLAY_MODE: return glut_mode; -//case GLUT_ELAPSED_TIME: - case GLUT_WINDOW_BUFFER_SIZE: - if (glutGet(GLUT_WINDOW_RGBA)) - return glutGet(GLUT_WINDOW_RED_SIZE)+ - glutGet(GLUT_WINDOW_GREEN_SIZE)+ - glutGet(GLUT_WINDOW_BLUE_SIZE)+ - glutGet(GLUT_WINDOW_ALPHA_SIZE); - else - return glutGet(GLUT_WINDOW_COLORMAP_SIZE); - case GLUT_VERSION: return 20400; - default: {GLint p; glGetIntegerv(type, &p); return p;} - } -} - -int glutLayerGet(GLenum type) { - switch (type) { - case GLUT_OVERLAY_POSSIBLE: return glut_window->can_do_overlay(); -//case GLUT_LAYER_IN_USE: -//case GLUT_HAS_OVERLAY: - case GLUT_TRANSPARENT_INDEX: return 0; // true for SGI - case GLUT_NORMAL_DAMAGED: return glut_window->damage(); - case GLUT_OVERLAY_DAMAGED: return 1; // kind of works... - default: return 0; - } -} - -int glutDeviceGet(GLenum type) { - switch (type) { - case GLUT_HAS_KEYBOARD : return 1; - case GLUT_HAS_MOUSE : return 1; - case GLUT_NUM_MOUSE_BUTTONS : return 3; - default : return 0; - } -} - -// Get extension function address... -GLUTproc glutGetProcAddress(const char *procName) { - return (GLUTproc)Fl_Gl_Window_Driver::global()->GetProcAddress(procName); -} - -// Parse the GL_EXTENSIONS string to see if the named extension is -// supported. -// -// This code was copied from FreeGLUT 2.4.0 which carries the -// following notice: -// -// Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. -int glutExtensionSupported( const char* extension ) -{ - if (!extension || strchr(extension, ' ')) return 0; - - const char *extensions, *start; - const int len = strlen( extension ); - - start = extensions = (const char *) glGetString(GL_EXTENSIONS); - - if (!extensions) return 0; - - for (;;) { - const char *p = strstr(extensions, extension); - if (!p) return 0; /* not found */ - /* check that the match isn't a super string */ - if ((p == start || p[-1] == ' ') && - (p[len] == ' ' || p[len] == 0)) return 1; - /* skip the false match and continue */ - extensions = p + len; - } -} - -// Add a mechanism to handle adding/removing the glut idle function -// without depending on the (deprecated) set_idle method. -void glutIdleFunc(void (*f)()) -{ - // no change - if(glut_idle_func == f) return; - // remove current idle - if(glut_idle_func) Fl::remove_idle((void (*)(void *))glut_idle_func); - // install new idle func - if one was passed - if(f) Fl::add_idle((void (*)(void *))f); - // record new idle func - even if it is NULL - glut_idle_func = f; -} // glutIdleFunc - -#endif // HAVE_GL - -// -// End of "$Id$". -// diff --git a/src/glut_compatibility.cxx b/src/glut_compatibility.cxx new file mode 100644 index 000000000..13e06242a --- /dev/null +++ b/src/glut_compatibility.cxx @@ -0,0 +1,484 @@ +// +// "$Id$" +// +// GLUT emulation 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 +// + +// Emulation of Glut using fltk. + +// GLUT is Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. +// "This program is freely distributable without licensing fees and is +// provided without guarantee or warrantee expressed or implied. This +// program is -not- in the public domain." + +// Although I have copied the GLUT API, none of my code is based on +// any Glut implementation details and is therefore covered by the LGPL. + +#include "flstring.h" +#if HAVE_GL +# include +# include +# define MAXWINDOWS 32 + +static Fl_Glut_Window *windows[MAXWINDOWS+1]; + +static void (*glut_idle_func)() = 0; // global glut idle function + +Fl_Glut_Window *glut_window; +int glut_menu; +void (*glut_menustate_function)(int); +void (*glut_menustatus_function)(int,int,int); + +static void default_reshape(int w, int h) {glViewport(0,0,w,h);} +static void default_display() {} + +void Fl_Glut_Window::make_current() { + glut_window = this; + if (shown()) Fl_Gl_Window::make_current(); +} + +static int indraw; +void Fl_Glut_Window::draw() { + glut_window = this; + indraw = 1; + if (!valid()) {reshape(pixel_w(),pixel_h()); valid(1);} + display(); + indraw = 0; +} + +void glutSwapBuffers() { + if (!indraw) glut_window->swap_buffers(); +} + +void Fl_Glut_Window::draw_overlay() { + glut_window = this; + if (!valid()) {reshape(pixel_w(),pixel_h()); valid(1);} + overlaydisplay(); +} + +static void domenu(int, int, int); + +int Fl_Glut_Window::handle(int event) { + make_current(); + int ex = Fl::event_x(); + int ey = Fl::event_y(); + float factor = pixels_per_unit(); + ex = int(ex * factor + 0.5f); + ey = int(ey * factor + 0.5f); + int button; + switch (event) { + + case FL_PUSH: + if (keyboard || special) Fl::focus(this); + button = Fl::event_button()-1; + if (button<0) button = 0; + if (button>2) button = 2; + if (menu[button]) {domenu(menu[button],ex,ey); return 1;} + mouse_down |= 1< 0) {if (mouse) mouse(4,GLUT_DOWN,ex,ey); --button;} + return 1; + + case FL_RELEASE: + for (button = 0; button < 3; button++) if (mouse_down & (1< FL_F && k <= FL_F_Last) k -= FL_F; + special(k,ex,ey); + return 1; + } + break; + } + + case FL_HIDE: + if (visibility) visibility(GLUT_NOT_VISIBLE); + break; + + case FL_SHOW: + if (visibility) visibility(GLUT_VISIBLE); + break; + } + + return Fl_Gl_Window::handle(event); +} + +static int glut_mode = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH; + +void Fl_Glut_Window::_init() { + for (number=1; numberresizable(W); + if (initargc) { + W->show(initargc,initargv); + initargc = 0; + } else { + W->show(); + } + W->valid(0); + W->context_valid(0); + W->make_current(); + return W->number; +} + +int glutCreateSubWindow(int win, int x, int y, int w, int h) { + Fl_Glut_Window *W = new Fl_Glut_Window(x,y,w,h,0); + windows[win]->add(W); + if (windows[win]->shown()) W->show(); + W->make_current(); + return W->number; +} +/** Destroys the glut window, first unregister it from the glut windows list */ +Fl_Glut_Window::~Fl_Glut_Window() { + if (glut_window == this) glut_window = 0; + windows[number] = 0; +} + +void glutDestroyWindow(int win) { + // should destroy children!!! + delete windows[win]; +} + +void glutPostWindowRedisplay(int win) { + windows[win]->redraw(); +} + +void glutSetWindow(int win) { + windows[win]->make_current(); +} + +//////////////////////////////////////////////////////////////// +#include + +struct menu { + void (*cb)(int); + Fl_Menu_Item *m; + int size; + int alloc; +}; + +#define MAXMENUS 32 +static menu menus[MAXMENUS+1]; + +static void domenu(int n, int ex, int ey) { + glut_menu = n; + menu *m = &menus[n]; + if (glut_menustate_function) glut_menustate_function(1); + if (glut_menustatus_function) glut_menustatus_function(1,ex,ey); + const Fl_Menu_Item* g = m->m->popup(Fl::event_x(), Fl::event_y(), 0); + if (g && g->callback_) ((void (*)(int))(g->callback_))(int(g->argument())); + if (glut_menustatus_function) glut_menustatus_function(0,ex,ey); + if (glut_menustate_function) glut_menustate_function(0); +} + +int glutCreateMenu(void (*cb)(int)) { + int i; + for (i=1; icb = cb; + return glut_menu = i; +} + +void glutDestroyMenu(int n) { + menu *m = &menus[n]; + delete[] m->m; + m->m = 0; + m->cb = 0; + m->size = m->alloc = 0; +} + +static Fl_Menu_Item* additem(menu *m) { + if (m->size+1 >= m->alloc) { + m->alloc = m->size*2+10; + Fl_Menu_Item* nm = new Fl_Menu_Item[m->alloc]; + for (int i=0; isize; i++) nm[i] = m->m[i]; + delete[] m->m; + m->m = nm; + } + int n = m->size++; + m->m[n+1].text = 0; + Fl_Menu_Item* i = &(m->m[n]); + i->shortcut_ = 0; + i->flags = 0; + i->labeltype_ = i->labelfont_ = i->labelsize_ = i->labelcolor_ = 0; + return i; +} + +void glutAddMenuEntry(char *label, int value) { + menu *m = &menus[glut_menu]; + Fl_Menu_Item* i = additem(m); + i->text = label; + i->callback_ = (Fl_Callback*)(m->cb); + i->argument(value); +} + +void glutAddSubMenu(char *label, int submenu) { + menu *m = &menus[glut_menu]; + Fl_Menu_Item* i = additem(m); + i->text = label; + i->callback_ = 0; + i->user_data_ = (void *)(menus[submenu].m); + i->flags = FL_PUP_SUBMENU; +} + +void glutChangeToMenuEntry(int item, char *label, int value) { + menu *m = &menus[glut_menu]; + Fl_Menu_Item* i = &m->m[item-1]; + i->text = label; + i->callback_ = (Fl_Callback*)(m->cb); + i->argument(value); + i->flags = 0; +} + +void glutChangeToSubMenu(int item, char *label, int submenu) { + menu *m = &menus[glut_menu]; + Fl_Menu_Item* i = &m->m[item-1]; + i->text = label; + i->callback_ = 0; + i->user_data_ = (void *)(menus[submenu].m); + i->flags = FL_PUP_SUBMENU; +} + +void glutRemoveMenuItem(int item) { + menu *m = &menus[glut_menu]; + if (item > m->size || item < 1) return; + for (int i = item-1; i <= m->size; i++) m->m[i] = m->m[i+1]; + m->size--; +} + +//////////////////////////////////////////////////////////////// + +int glutGet(GLenum type) { + switch (type) { + case GLUT_RETURN_ZERO: return 0; + case GLUT_WINDOW_X: return glut_window->x(); + case GLUT_WINDOW_Y: return glut_window->y(); + case GLUT_WINDOW_WIDTH: return glut_window->pixel_w(); + case GLUT_WINDOW_HEIGHT: return glut_window->pixel_h(); + case GLUT_WINDOW_PARENT: + if (glut_window->parent()) + return ((Fl_Glut_Window *)(glut_window->parent()))->number; + else + return 0; +//case GLUT_WINDOW_NUM_CHILDREN: +//case GLUT_WINDOW_CURSOR: return + case GLUT_SCREEN_WIDTH: return Fl::w(); + case GLUT_SCREEN_HEIGHT: return Fl::h(); +//case GLUT_SCREEN_WIDTH_MM: +//case GLUT_SCREEN_HEIGHT_MM: + case GLUT_MENU_NUM_ITEMS: return menus[glut_menu].size; + case GLUT_DISPLAY_MODE_POSSIBLE: return Fl_Gl_Window::can_do(glut_mode); + case GLUT_INIT_WINDOW_X: return initx; + case GLUT_INIT_WINDOW_Y: return inity; + case GLUT_INIT_WINDOW_WIDTH: return initw; + case GLUT_INIT_WINDOW_HEIGHT: return inith; + case GLUT_INIT_DISPLAY_MODE: return glut_mode; +//case GLUT_ELAPSED_TIME: + case GLUT_WINDOW_BUFFER_SIZE: + if (glutGet(GLUT_WINDOW_RGBA)) + return glutGet(GLUT_WINDOW_RED_SIZE)+ + glutGet(GLUT_WINDOW_GREEN_SIZE)+ + glutGet(GLUT_WINDOW_BLUE_SIZE)+ + glutGet(GLUT_WINDOW_ALPHA_SIZE); + else + return glutGet(GLUT_WINDOW_COLORMAP_SIZE); + case GLUT_VERSION: return 20400; + default: {GLint p; glGetIntegerv(type, &p); return p;} + } +} + +int glutLayerGet(GLenum type) { + switch (type) { + case GLUT_OVERLAY_POSSIBLE: return glut_window->can_do_overlay(); +//case GLUT_LAYER_IN_USE: +//case GLUT_HAS_OVERLAY: + case GLUT_TRANSPARENT_INDEX: return 0; // true for SGI + case GLUT_NORMAL_DAMAGED: return glut_window->damage(); + case GLUT_OVERLAY_DAMAGED: return 1; // kind of works... + default: return 0; + } +} + +int glutDeviceGet(GLenum type) { + switch (type) { + case GLUT_HAS_KEYBOARD : return 1; + case GLUT_HAS_MOUSE : return 1; + case GLUT_NUM_MOUSE_BUTTONS : return 3; + default : return 0; + } +} + +// Get extension function address... +GLUTproc glutGetProcAddress(const char *procName) { + return (GLUTproc)Fl_Gl_Window_Driver::global()->GetProcAddress(procName); +} + +// Parse the GL_EXTENSIONS string to see if the named extension is +// supported. +// +// This code was copied from FreeGLUT 2.4.0 which carries the +// following notice: +// +// Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. +int glutExtensionSupported( const char* extension ) +{ + if (!extension || strchr(extension, ' ')) return 0; + + const char *extensions, *start; + const int len = strlen( extension ); + + start = extensions = (const char *) glGetString(GL_EXTENSIONS); + + if (!extensions) return 0; + + for (;;) { + const char *p = strstr(extensions, extension); + if (!p) return 0; /* not found */ + /* check that the match isn't a super string */ + if ((p == start || p[-1] == ' ') && + (p[len] == ' ' || p[len] == 0)) return 1; + /* skip the false match and continue */ + extensions = p + len; + } +} + +// Add a mechanism to handle adding/removing the glut idle function +// without depending on the (deprecated) set_idle method. +void glutIdleFunc(void (*f)()) +{ + // no change + if(glut_idle_func == f) return; + // remove current idle + if(glut_idle_func) Fl::remove_idle((void (*)(void *))glut_idle_func); + // install new idle func - if one was passed + if(f) Fl::add_idle((void (*)(void *))f); + // record new idle func - even if it is NULL + glut_idle_func = f; +} // glutIdleFunc + +#endif // HAVE_GL + +// +// End of "$Id$". +// diff --git a/src/makedepend b/src/makedepend index 5c677ef2f..f15683f6c 100644 --- a/src/makedepend +++ b/src/makedepend @@ -1432,38 +1432,38 @@ drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.o: ../FL/Enumerations.H drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.o: ../FL/Fl.H ../FL/fl_utf8.h drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.o: ../FL/fl_draw.H drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.o: drivers/Xlib/Fl_Font.H -forms_compatability.o: ../FL/forms.H ../FL/Fl.H ../FL/Fl_Export.H -forms_compatability.o: ../FL/platform_types.h ../FL/fl_utf8.h -forms_compatability.o: ../FL/Fl_Export.H ../FL/fl_types.h -forms_compatability.o: ../FL/Enumerations.H ../FL/abi-version.h -forms_compatability.o: ../FL/Fl_Group.H ../FL/Fl_Window.H ../FL/fl_draw.H -forms_compatability.o: ../FL/Enumerations.H ../FL/Fl_Graphics_Driver.H -forms_compatability.o: ../FL/Fl_Device.H ../FL/Fl_Plugin.H -forms_compatability.o: ../FL/Fl_Preferences.H ../FL/Fl_Image.H -forms_compatability.o: ../FL/Fl_Widget.H ../FL/Fl_Bitmap.H ../FL/Fl_Image.H -forms_compatability.o: ../FL/Fl_Pixmap.H ../FL/Fl_RGB_Image.H -forms_compatability.o: ../FL/Fl_FormsBitmap.H ../FL/Fl_Bitmap.H -forms_compatability.o: ../FL/Fl_FormsPixmap.H ../FL/Fl_Pixmap.H -forms_compatability.o: ../FL/Fl_Box.H ../FL/Fl_Browser.H ../FL/Fl_Button.H -forms_compatability.o: ../FL/Fl_Light_Button.H ../FL/Fl_Round_Button.H -forms_compatability.o: ../FL/Fl_Check_Button.H ../FL/Fl_Chart.H -forms_compatability.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_.H -forms_compatability.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Clock.H -forms_compatability.o: ../FL/Fl_Counter.H ../FL/Fl_Dial.H ../FL/Fl_Free.H -forms_compatability.o: ../FL/fl_ask.H ../FL/fl_show_colormap.H -forms_compatability.o: ../FL/filename.H ../FL/Fl_File_Chooser.H ../FL/Fl.H -forms_compatability.o: ../FL/Fl_Double_Window.H ../FL/Fl_Group.H -forms_compatability.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_Button.H -forms_compatability.o: ../FL/Fl_Button.H ../FL/Fl_Preferences.H -forms_compatability.o: ../FL/Fl_Tile.H ../FL/Fl_File_Browser.H -forms_compatability.o: ../FL/Fl_File_Icon.H ../FL/Fl_Box.H -forms_compatability.o: ../FL/Fl_Check_Button.H ../FL/Fl_File_Input.H -forms_compatability.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H -forms_compatability.o: ../FL/Fl_Return_Button.H ../FL/fl_ask.H -forms_compatability.o: ../FL/Fl_Input.H ../FL/Fl_Menu_Button.H -forms_compatability.o: ../FL/Fl_Positioner.H ../FL/Fl_Slider.H -forms_compatability.o: ../FL/Fl_Valuator.H ../FL/Fl_Value_Slider.H -forms_compatability.o: ../FL/Fl_Timer.H ../FL/Fl_Repeat_Button.H +forms_compatibility.o: ../FL/forms.H ../FL/Fl.H ../FL/Fl_Export.H +forms_compatibility.o: ../FL/platform_types.h ../FL/fl_utf8.h +forms_compatibility.o: ../FL/Fl_Export.H ../FL/fl_types.h +forms_compatibility.o: ../FL/Enumerations.H ../FL/abi-version.h +forms_compatibility.o: ../FL/Fl_Group.H ../FL/Fl_Window.H ../FL/fl_draw.H +forms_compatibility.o: ../FL/Enumerations.H ../FL/Fl_Graphics_Driver.H +forms_compatibility.o: ../FL/Fl_Device.H ../FL/Fl_Plugin.H +forms_compatibility.o: ../FL/Fl_Preferences.H ../FL/Fl_Image.H +forms_compatibility.o: ../FL/Fl_Widget.H ../FL/Fl_Bitmap.H ../FL/Fl_Image.H +forms_compatibility.o: ../FL/Fl_Pixmap.H ../FL/Fl_RGB_Image.H +forms_compatibility.o: ../FL/Fl_FormsBitmap.H ../FL/Fl_Bitmap.H +forms_compatibility.o: ../FL/Fl_FormsPixmap.H ../FL/Fl_Pixmap.H +forms_compatibility.o: ../FL/Fl_Box.H ../FL/Fl_Browser.H ../FL/Fl_Button.H +forms_compatibility.o: ../FL/Fl_Light_Button.H ../FL/Fl_Round_Button.H +forms_compatibility.o: ../FL/Fl_Check_Button.H ../FL/Fl_Chart.H +forms_compatibility.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_.H +forms_compatibility.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Clock.H +forms_compatibility.o: ../FL/Fl_Counter.H ../FL/Fl_Dial.H ../FL/Fl_Free.H +forms_compatibility.o: ../FL/fl_ask.H ../FL/fl_show_colormap.H +forms_compatibility.o: ../FL/filename.H ../FL/Fl_File_Chooser.H ../FL/Fl.H +forms_compatibility.o: ../FL/Fl_Double_Window.H ../FL/Fl_Group.H +forms_compatibility.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_Button.H +forms_compatibility.o: ../FL/Fl_Button.H ../FL/Fl_Preferences.H +forms_compatibility.o: ../FL/Fl_Tile.H ../FL/Fl_File_Browser.H +forms_compatibility.o: ../FL/Fl_File_Icon.H ../FL/Fl_Box.H +forms_compatibility.o: ../FL/Fl_Check_Button.H ../FL/Fl_File_Input.H +forms_compatibility.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H +forms_compatibility.o: ../FL/Fl_Return_Button.H ../FL/fl_ask.H +forms_compatibility.o: ../FL/Fl_Input.H ../FL/Fl_Menu_Button.H +forms_compatibility.o: ../FL/Fl_Positioner.H ../FL/Fl_Slider.H +forms_compatibility.o: ../FL/Fl_Valuator.H ../FL/Fl_Value_Slider.H +forms_compatibility.o: ../FL/Fl_Timer.H ../FL/Fl_Repeat_Button.H forms_bitmap.o: ../FL/forms.H ../FL/Fl.H ../FL/Fl_Export.H forms_bitmap.o: ../FL/platform_types.h ../FL/fl_utf8.h ../FL/Fl_Export.H forms_bitmap.o: ../FL/fl_types.h ../FL/Enumerations.H ../FL/abi-version.h @@ -1631,14 +1631,14 @@ gl_start.o: ../FL/Fl_Image.H ../FL/Fl_Widget.H ../FL/fl_draw.H ../FL/gl.h gl_start.o: ../FL/Fl_Gl_Window.H ../FL/Fl_Window.H gl_start.o: ../FL/Fl_Gl_Window_Driver.H ../FL/x.H ../FL/fl_types.h gl_start.o: ../FL/Enumerations.H Fl_Gl_Choice.H -glut_compatability.o: flstring.h ../FL/Fl_Export.H ../config.h -glut_compatability.o: ../FL/Fl_Gl_Window_Driver.H ../FL/Fl_Gl_Window.H -glut_compatability.o: ../FL/Fl_Window.H ../FL/glut.H ../FL/gl.h -glut_compatability.o: ../FL/Enumerations.H ../FL/abi-version.h -glut_compatability.o: ../FL/Fl_Export.H ../FL/fl_types.h -glut_compatability.o: ../FL/platform_types.h ../FL/Fl.H ../FL/fl_utf8.h -glut_compatability.o: ../FL/Fl_Gl_Window.H ../FL/Fl_Menu_Item.H -glut_compatability.o: ../FL/Fl_Widget.H ../FL/Fl_Image.H +glut_compatibility.o: flstring.h ../FL/Fl_Export.H ../config.h +glut_compatibility.o: ../FL/Fl_Gl_Window_Driver.H ../FL/Fl_Gl_Window.H +glut_compatibility.o: ../FL/Fl_Window.H ../FL/glut.H ../FL/gl.h +glut_compatibility.o: ../FL/Enumerations.H ../FL/abi-version.h +glut_compatibility.o: ../FL/Fl_Export.H ../FL/fl_types.h +glut_compatibility.o: ../FL/platform_types.h ../FL/Fl.H ../FL/fl_utf8.h +glut_compatibility.o: ../FL/Fl_Gl_Window.H ../FL/Fl_Menu_Item.H +glut_compatibility.o: ../FL/Fl_Widget.H ../FL/Fl_Image.H glut_font.o: ../config.h ../FL/glut.H ../FL/gl.h ../FL/Enumerations.H glut_font.o: ../FL/abi-version.h ../FL/Fl_Export.H ../FL/fl_types.h glut_font.o: ../FL/platform_types.h ../FL/Fl.H ../FL/Fl_Export.H -- cgit v1.2.3