Author: AlbrechtS
Date: 2010-12-08 06:00:35 -0800 (Wed, 08 Dec 2010)
New Revision: 7978
Log:
Fixed Compiling with mingw-w64 (STR #2308).


Modified:
   branches/branch-1.3/CHANGES
   branches/branch-1.3/FL/Fl_Menu_Item.H
   branches/branch-1.3/FL/Fl_Widget.H
   branches/branch-1.3/fluid/Fl_Widget_Type.cxx
   branches/branch-1.3/fluid/fluid.cxx
   branches/branch-1.3/src/Fl.cxx
   branches/branch-1.3/src/Fl_win32.cxx
   branches/branch-1.3/src/fl_ask.cxx
   branches/branch-1.3/src/fl_dnd_win32.cxx
   branches/branch-1.3/test/arc.cxx
   branches/branch-1.3/test/cursor.cxx
   branches/branch-1.3/test/curve.cxx
   branches/branch-1.3/test/fractals.cxx
   branches/branch-1.3/test/input.cxx
   branches/branch-1.3/test/keyboard.cxx
   branches/branch-1.3/test/line_style.cxx
   branches/branch-1.3/test/scroll.cxx
   branches/branch-1.3/test/table.cxx
   branches/branch-1.3/test/tree.fl

Modified: branches/branch-1.3/CHANGES
===================================================================
--- branches/branch-1.3/CHANGES 2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/CHANGES 2010-12-08 14:00:35 UTC (rev 7978)
@@ -1,5 +1,6 @@
 CHANGES IN FLTK 1.3.0
 
+       - Fixed Compiling with mingw-w64 (STR #2308).
        - Fixed crashes when detecting illegal utf 8 sequences
          in Fl_Text_* widgets (STR #2348)
        - Fixed Fl_Text_Display Tabulator calculations (STR #2450)

Modified: branches/branch-1.3/FL/Fl_Menu_Item.H
===================================================================
--- branches/branch-1.3/FL/Fl_Menu_Item.H       2010-12-08 13:16:27 UTC (rev 
7977)
+++ branches/branch-1.3/FL/Fl_Menu_Item.H       2010-12-08 14:00:35 UTC (rev 
7978)
@@ -241,7 +241,7 @@
     and casting the long to a void* and may not be
     portable to some machines.
   */
-  long argument() const {return (long)user_data_;}
+  long argument() const {return (long)(fl_intptr_t)user_data_;}
   /**
     For convenience you can also define the callback as taking a long
     argument.  This is implemented by casting this to a Fl_Callback

Modified: branches/branch-1.3/FL/Fl_Widget.H
===================================================================
--- branches/branch-1.3/FL/Fl_Widget.H  2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/FL/Fl_Widget.H  2010-12-08 14:00:35 UTC (rev 7978)
@@ -33,6 +33,18 @@
 
 #include "Enumerations.H"
 
+/**
+  \todo        typedef's fl_intptr_t and fl_uintptr_t should be documented.
+*/
+#ifdef _WIN64
+#include <stdint.h>
+typedef intptr_t fl_intptr_t;
+typedef uintptr_t fl_uintptr_t;
+#else
+typedef long fl_intptr_t;
+typedef unsigned long fl_uintptr_t;
+#endif
+
 class Fl_Widget;
 class Fl_Window;
 class Fl_Group;
@@ -587,7 +599,7 @@
 
   /** Gets the current user data (long) argument that is passed to the 
callback function.
    */
-  long argument() const {return (long)user_data_;}
+  long argument() const {return (long)(fl_intptr_t)user_data_;}
 
   /** Sets the current user data (long) argument that is passed to the 
callback function.
       \todo The user data value must be implemented using a \em union to avoid 

Modified: branches/branch-1.3/fluid/Fl_Widget_Type.cxx
===================================================================
--- branches/branch-1.3/fluid/Fl_Widget_Type.cxx        2010-12-08 13:16:27 UTC 
(rev 7977)
+++ branches/branch-1.3/fluid/Fl_Widget_Type.cxx        2010-12-08 14:00:35 UTC 
(rev 7978)
@@ -1142,7 +1142,7 @@
 {0}};
 
 void align_cb(Fl_Button* i, void *v) {
-  Fl_Align b = Fl_Align(long(i->user_data()));
+  Fl_Align b = Fl_Align(fl_uintptr_t(i->user_data()));
   if (v == LOAD) {
     if (current_widget->is_menu_item()) {i->deactivate(); return;} else 
i->activate();
     i->value(current_widget->o->align() & b);
@@ -1190,7 +1190,7 @@
     }
   } else {
     const Fl_Menu_Item *mi = i->menu() + i->value();
-    Fl_Align b = Fl_Align(long(mi->user_data()));
+    Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data()));
     int mod = 0;
     for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
       if (o->selected && o->is_widget()) {
@@ -1219,7 +1219,7 @@
     }
   } else {
     const Fl_Menu_Item *mi = i->menu() + i->value();
-    Fl_Align b = Fl_Align(long(mi->user_data()));
+    Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data()));
     int mod = 0;
     for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
       if (o->selected && o->is_widget()) {
@@ -1311,7 +1311,7 @@
 // "v_attributes" let user type in random code for attribute settings:
 
 void v_input_cb(Fl_Input* i, void* v) {
-  int n = int(long(i->user_data()));
+  int n = fl_intptr_t(i->user_data());
   if (v == LOAD) {
     i->static_value(current_widget->extra_code(n));
   } else {

Modified: branches/branch-1.3/fluid/fluid.cxx
===================================================================
--- branches/branch-1.3/fluid/fluid.cxx 2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/fluid/fluid.cxx 2010-12-08 14:00:35 UTC (rev 7978)
@@ -1978,7 +1978,7 @@
     // don't need theses handles inherited by child process:
     clean_close(pin[0]); clean_close(pout[1]); clean_close(perr[1]);
     HANDLE & h = *mode == 'r' ? pout[0] : pin[1];
-    _fpt = _fdopen(_open_osfhandle((long) h,_O_BINARY),mode);
+    _fpt = _fdopen(_open_osfhandle((fl_intptr_t) h,_O_BINARY),mode);
     h= INVALID_HANDLE_VALUE;  // reset the handle pointer that is shared
     // with _fpt so we don't free it twice
   }

Modified: branches/branch-1.3/src/Fl.cxx
===================================================================
--- branches/branch-1.3/src/Fl.cxx      2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/src/Fl.cxx      2010-12-08 14:00:35 UTC (rev 7978)
@@ -33,8 +33,20 @@
 #include "config.h"
 #include <FL/Fl.H>
 #include <FL/Fl_Window.H>
+#include <FL/Fl_Tooltip.H>
+
+// recent versions of MinGW warn us "Please include winsock2.h before 
windows.h"
+// hence we must include winsock*.h before FL/x.H (A.S. Dec. 2010)
+#if defined(WIN32) && !defined(__CYGWIN__)
+# if !defined(USE_WSOCK1)
+#  include <winsock2.h>
+# else
+#  include <winsock.h>
+# endif
+#endif
+
 #include <FL/x.H>
-#include <FL/Fl_Tooltip.H>
+
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>

Modified: branches/branch-1.3/src/Fl_win32.cxx
===================================================================
--- branches/branch-1.3/src/Fl_win32.cxx        2010-12-08 13:16:27 UTC (rev 
7977)
+++ branches/branch-1.3/src/Fl_win32.cxx        2010-12-08 14:00:35 UTC (rev 
7978)
@@ -31,7 +31,6 @@
 
 #ifndef FL_DOXYGEN
 #include <FL/Fl.H>
-#include <FL/x.H>
 #include <FL/fl_utf8.h>
 #include <FL/Fl_Window.H>
 #include <FL/fl_draw.H>
@@ -46,13 +45,8 @@
 #ifdef __CYGWIN__
 #  include <sys/time.h>
 #  include <unistd.h>
-#else
-# if !defined(USE_WSOCK1)
-#  include <winsock2.h>
-#else
-#  include <winsock.h>
-# endif
 #endif
+// note: the corresponding winsock*.h has been #include'd in Fl.cxx
 #if !defined(USE_WSOCK1)
 #  define WSCK_DLL_NAME "WS2_32.DLL"
 #else
@@ -60,6 +54,7 @@
 #endif
 #include <winuser.h>
 #include <commctrl.h>
+#include <FL/x.H>
 
 #if defined(__GNUC__)
 # include <wchar.h>

Modified: branches/branch-1.3/src/fl_ask.cxx
===================================================================
--- branches/branch-1.3/src/fl_ask.cxx  2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/src/fl_ask.cxx  2010-12-08 14:00:35 UTC (rev 7978)
@@ -72,7 +72,7 @@
 // pointer to one of the buttons or an Fl_Window* pointer to the
 // message window (message_form).
 static void button_cb(Fl_Widget *, void *val) {
-  ret_val = (int)(long)val;
+  ret_val = (fl_intptr_t)val;
   message_form->hide();
 }
 

Modified: branches/branch-1.3/src/fl_dnd_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_dnd_win32.cxx    2010-12-08 13:16:27 UTC (rev 
7977)
+++ branches/branch-1.3/src/fl_dnd_win32.cxx    2010-12-08 14:00:35 UTC (rev 
7978)
@@ -41,8 +41,6 @@
 #if defined(__CYGWIN__)
 #include <sys/time.h>
 #include <unistd.h>
-#else
-#include <winsock2.h>
 #endif
 
 extern char *fl_selection_buffer[2];

Modified: branches/branch-1.3/test/arc.cxx
===================================================================
--- branches/branch-1.3/test/arc.cxx    2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/arc.cxx    2010-12-08 14:00:35 UTC (rev 7978)
@@ -66,7 +66,7 @@
 
 void slider_cb(Fl_Widget* o, void* v) {
   Fl_Slider* s = (Fl_Slider*)o;
-  args[long(v)] = s->value();
+  args[fl_intptr_t(v)] = s->value();
   d->redraw();
 }
 

Modified: branches/branch-1.3/test/cursor.cxx
===================================================================
--- branches/branch-1.3/test/cursor.cxx 2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/cursor.cxx 2010-12-08 14:00:35 UTC (rev 7978)
@@ -39,7 +39,7 @@
 Fl_Hor_Value_Slider *cursor_slider;
 
 void choice_cb(Fl_Widget *, void *v) {
-  cursor = (Fl_Cursor)(long)v;
+  cursor = (Fl_Cursor)(fl_intptr_t)v;
   cursor_slider->value(cursor);
   fl_cursor(cursor,fg,bg);
 }

Modified: branches/branch-1.3/test/curve.cxx
===================================================================
--- branches/branch-1.3/test/curve.cxx  2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/curve.cxx  2010-12-08 14:00:35 UTC (rev 7978)
@@ -83,7 +83,7 @@
 
 void slider_cb(Fl_Widget* o, void* v) {
   Fl_Slider* s = (Fl_Slider*)o;
-  args[long(v)] = s->value();
+  args[fl_intptr_t(v)] = s->value();
   d->redraw();
 }
 

Modified: branches/branch-1.3/test/fractals.cxx
===================================================================
--- branches/branch-1.3/test/fractals.cxx       2010-12-08 13:16:27 UTC (rev 
7977)
+++ branches/branch-1.3/test/fractals.cxx       2010-12-08 14:00:35 UTC (rev 
7978)
@@ -765,11 +765,11 @@
 /***************************************************************/
 
 // FLTK-style callbacks to Glut menu callback translators:
-void setlevel(Fl_Widget*, void *value) {setlevel(long(value));}
+void setlevel(Fl_Widget*, void *value) {setlevel(fl_intptr_t(value));}
 
-void choosefract(Fl_Widget*, void *value) {choosefract(long(value));}
+void choosefract(Fl_Widget*, void *value) {choosefract(fl_intptr_t(value));}
 
-void handlemenu(Fl_Widget*, void *value) {handlemenu(long(value));}
+void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_intptr_t(value));}
 
 #include <FL/Fl_Button.H>
 #include <FL/Fl_Group.H>

Modified: branches/branch-1.3/test/input.cxx
===================================================================
--- branches/branch-1.3/test/input.cxx  2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/input.cxx  2010-12-08 14:00:35 UTC (rev 7978)
@@ -65,7 +65,7 @@
 
 void color_cb(Fl_Widget* button, void* v) {
   Fl_Color c;
-  switch ((long)v) {
+  switch ((fl_intptr_t)v) {
   case 0: c = FL_BACKGROUND2_COLOR; break;
   case 1: c = FL_SELECTION_COLOR; break;
   default: c = FL_FOREGROUND_COLOR; break;

Modified: branches/branch-1.3/test/keyboard.cxx
===================================================================
--- branches/branch-1.3/test/keyboard.cxx       2010-12-08 13:16:27 UTC (rev 
7977)
+++ branches/branch-1.3/test/keyboard.cxx       2010-12-08 14:00:35 UTC (rev 
7978)
@@ -109,14 +109,14 @@
     for (int i = 0; i < window->children(); i++) {
       Fl_Widget* b = window->child(i);
       if (b->callback() == (Fl_Callback*)key_cb) {
-       int i = (long)b->user_data();
+       int i = b->argument();
        if (!i) i = b->label()[0];
         Fl_Button *btn = ((Fl_Button*)b);
         int state = Fl::event_key(i);
         if (btn->value()!=state)
          btn->value(state);
       } else if (b->callback() == (Fl_Callback*)shift_cb) {
-       int i = (long)b->user_data();
+       int i = b->argument();
         Fl_Button *btn = ((Fl_Button*)b);
         int state = Fl::event_state(i);
         if (btn->value()!=state)

Modified: branches/branch-1.3/test/line_style.cxx
===================================================================
--- branches/branch-1.3/test/line_style.cxx     2010-12-08 13:16:27 UTC (rev 
7977)
+++ branches/branch-1.3/test/line_style.cxx     2010-12-08 14:00:35 UTC (rev 
7978)
@@ -58,9 +58,9 @@
   dashes[3] = char(sliders[8]->value());
   dashes[4] = 0;
   fl_line_style(
-    (long)(choice[0]->mvalue()->user_data()) +
-    (long)(choice[1]->mvalue()->user_data()) +
-    (long)(choice[2]->mvalue()->user_data()),
+    (long)(choice[0]->mvalue()->argument()) +
+    (long)(choice[1]->mvalue()->argument()) +
+    (long)(choice[2]->mvalue()->argument()),
     (long)(sliders[3]->value()), // width
     dashes);
 

Modified: branches/branch-1.3/test/scroll.cxx
===================================================================
--- branches/branch-1.3/test/scroll.cxx 2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/scroll.cxx 2010-12-08 14:00:35 UTC (rev 7978)
@@ -71,7 +71,7 @@
 }
 
 void type_cb(Fl_Widget*, void* v) {
-  thescroll->type((uchar)((long)v));
+  thescroll->type((uchar)((fl_intptr_t)v));
   thescroll->redraw();
 }
 
@@ -87,7 +87,7 @@
 };
 
 void align_cb(Fl_Widget*, void* v) {
-  thescroll->scrollbar.align((uchar)((long)v));
+  thescroll->scrollbar.align((uchar)((fl_intptr_t)v));
   thescroll->redraw();
 }
 

Modified: branches/branch-1.3/test/table.cxx
===================================================================
--- branches/branch-1.3/test/table.cxx  2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/table.cxx  2010-12-08 14:00:35 UTC (rev 7978)
@@ -273,19 +273,19 @@
 
 void tablebox_choice_cb(Fl_Widget *w, void *data)
 {
-    G_table->table_box((Fl_Boxtype)(long)data);
+    G_table->table_box((Fl_Boxtype)(fl_intptr_t)data);
     G_table->redraw();
 }
 
 void widgetbox_choice_cb(Fl_Widget *w, void *data)
 {
-    G_table->box((Fl_Boxtype)(long)data);
+    G_table->box((Fl_Boxtype)(fl_intptr_t)data);
     G_table->resize(G_table->x(), G_table->y(), G_table->w(), G_table->h());
 }
 
 void type_choice_cb(Fl_Widget *w, void *data)
 {
-    G_table->type((Fl_Table_Row::TableRowSelectMode)(long)data);
+    G_table->type((Fl_Table_Row::TableRowSelectMode)(fl_intptr_t)data);
 }
 
 Fl_Menu_Item tablebox_choices[] = {

Modified: branches/branch-1.3/test/tree.fl
===================================================================
--- branches/branch-1.3/test/tree.fl    2010-12-08 13:16:27 UTC (rev 7977)
+++ branches/branch-1.3/test/tree.fl    2010-12-08 14:00:35 UTC (rev 7978)
@@ -152,7 +152,7 @@
 if ( item ) {
   fprintf(stderr, "TREE CALLBACK: label='%s' userdata=%ld reason=%s\\n",
           item->label(),
-          (long)tree->user_data(),
+          (long)(fl_intptr_t)tree->user_data(),
          reason_as_name(tree->callback_reason()));
 } else {
   fprintf(stderr, "TREE CALLBACK: reason=%s item=(no item -- probably multiple 
items were changed at once)\\n",

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to