summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--FL/Fl_Menu_Item.H2
-rw-r--r--FL/Fl_Widget.H14
-rw-r--r--fluid/Fl_Widget_Type.cxx8
-rw-r--r--fluid/fluid.cxx2
-rw-r--r--src/Fl.cxx14
-rw-r--r--src/Fl_win32.cxx9
-rw-r--r--src/fl_ask.cxx2
-rw-r--r--src/fl_dnd_win32.cxx2
-rw-r--r--test/arc.cxx2
-rw-r--r--test/cursor.cxx2
-rw-r--r--test/curve.cxx2
-rw-r--r--test/fractals.cxx6
-rw-r--r--test/input.cxx2
-rw-r--r--test/keyboard.cxx4
-rw-r--r--test/line_style.cxx6
-rw-r--r--test/scroll.cxx4
-rw-r--r--test/table.cxx6
-rw-r--r--test/tree.fl2
19 files changed, 54 insertions, 36 deletions
diff --git a/CHANGES b/CHANGES
index d2347a5f5..b31760628 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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)
diff --git a/FL/Fl_Menu_Item.H b/FL/Fl_Menu_Item.H
index 2a96a521c..7c01379ef 100644
--- a/FL/Fl_Menu_Item.H
+++ b/FL/Fl_Menu_Item.H
@@ -241,7 +241,7 @@ struct FL_EXPORT Fl_Menu_Item {
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
diff --git a/FL/Fl_Widget.H b/FL/Fl_Widget.H
index dc3cc408d..9bcaf0beb 100644
--- a/FL/Fl_Widget.H
+++ b/FL/Fl_Widget.H
@@ -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 @@ public:
/** 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
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 0dbfcf2ef..221afb248 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -1142,7 +1142,7 @@ static Fl_Menu_Item alignmenu[] = {
{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 @@ void align_position_cb(Fl_Choice *i, void *v) {
}
} 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 @@ void align_text_image_cb(Fl_Choice *i, void *v) {
}
} 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 @@ void user_data_type_cb(Fl_Input *i, void *v) {
// "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 {
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index 8374a0ef7..532a03d0e 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -1978,7 +1978,7 @@ FILE * Fl_Process::popen(const char *cmd, const char *mode) {
// 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
}
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 6a4daaabe..d0042ba77 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -33,8 +33,20 @@
#include "config.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
-#include <FL/x.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 <ctype.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index b1bb2e3ff..f825106a9 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -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>
diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx
index 7e11fb944..20e5bb5c3 100644
--- a/src/fl_ask.cxx
+++ b/src/fl_ask.cxx
@@ -72,7 +72,7 @@ static char avoidRecursion = 0;
// 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();
}
diff --git a/src/fl_dnd_win32.cxx b/src/fl_dnd_win32.cxx
index 7915d3881..4bd2d87bd 100644
--- a/src/fl_dnd_win32.cxx
+++ b/src/fl_dnd_win32.cxx
@@ -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];
diff --git a/test/arc.cxx b/test/arc.cxx
index 69854eda5..77d37a96f 100644
--- a/test/arc.cxx
+++ b/test/arc.cxx
@@ -66,7 +66,7 @@ Drawing *d;
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();
}
diff --git a/test/cursor.cxx b/test/cursor.cxx
index 75f645241..3f3ab0c49 100644
--- a/test/cursor.cxx
+++ b/test/cursor.cxx
@@ -39,7 +39,7 @@ Fl_Cursor cursor = FL_CURSOR_DEFAULT;
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);
}
diff --git a/test/curve.cxx b/test/curve.cxx
index db9b28c20..f69f7241b 100644
--- a/test/curve.cxx
+++ b/test/curve.cxx
@@ -83,7 +83,7 @@ void points_cb(Fl_Widget* o, void*) {
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();
}
diff --git a/test/fractals.cxx b/test/fractals.cxx
index d9bf34468..d0167464b 100644
--- a/test/fractals.cxx
+++ b/test/fractals.cxx
@@ -765,11 +765,11 @@ void MenuInit(void)
/***************************************************************/
// 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>
diff --git a/test/input.cxx b/test/input.cxx
index 35322c3f6..428a65cb1 100644
--- a/test/input.cxx
+++ b/test/input.cxx
@@ -65,7 +65,7 @@ void button_cb(Fl_Widget *,void *) {
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;
diff --git a/test/keyboard.cxx b/test/keyboard.cxx
index 0bf88cf92..2d0034899 100644
--- a/test/keyboard.cxx
+++ b/test/keyboard.cxx
@@ -109,14 +109,14 @@ int main(int argc, char** argv) {
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)
diff --git a/test/line_style.cxx b/test/line_style.cxx
index d32a47482..c37b0a7ec 100644
--- a/test/line_style.cxx
+++ b/test/line_style.cxx
@@ -58,9 +58,9 @@ void test_box::draw() {
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);
diff --git a/test/scroll.cxx b/test/scroll.cxx
index 069d10f64..0cc229b5d 100644
--- a/test/scroll.cxx
+++ b/test/scroll.cxx
@@ -71,7 +71,7 @@ void box_cb(Fl_Widget* o, void*) {
}
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 @@ Fl_Menu_Item choices[] = {
};
void align_cb(Fl_Widget*, void* v) {
- thescroll->scrollbar.align((uchar)((long)v));
+ thescroll->scrollbar.align((uchar)((fl_intptr_t)v));
thescroll->redraw();
}
diff --git a/test/table.cxx b/test/table.cxx
index ec94314c6..c36713ef5 100644
--- a/test/table.cxx
+++ b/test/table.cxx
@@ -273,19 +273,19 @@ char *itoa(int val)
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[] = {
diff --git a/test/tree.fl b/test/tree.fl
index a184e6c91..5fec7fd60 100644
--- a/test/tree.fl
+++ b/test/tree.fl
@@ -152,7 +152,7 @@ Fl_Tree_Item *item = tree->callback_item();
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",