From: Vadim Zeitlin Date: Mon, 18 Oct 2010 23:43:20 +0000 (+0000) Subject: Use unsigned char for XBM bitmaps data. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1780a38b7bc9a9c04d33775a3176fe8516465f50 Use unsigned char for XBM bitmaps data. This fixes compilation with g++ in C++0x mode in which conversions of constants not fitting into signed char range to char are not permitted. Closes #12575. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/bdiag.xbm b/src/gtk/bdiag.xbm index 9ff0a1822f..6b3ba001e9 100644 --- a/src/gtk/bdiag.xbm +++ b/src/gtk/bdiag.xbm @@ -1,6 +1,6 @@ #define bdiag_width 16 #define bdiag_height 16 -static char bdiag_bits[] = { +static unsigned char bdiag_bits[] = { 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01}; diff --git a/src/gtk/cdiag.xbm b/src/gtk/cdiag.xbm index 15dc7ba86d..e0502f2303 100644 --- a/src/gtk/cdiag.xbm +++ b/src/gtk/cdiag.xbm @@ -1,6 +1,6 @@ #define cdiag_width 16 #define cdiag_height 16 -static char cdiag_bits[] = { +static unsigned char cdiag_bits[] = { 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x81, 0x81}; diff --git a/src/gtk/cross.xbm b/src/gtk/cross.xbm index b07cbe7fcd..916ee76e3a 100644 --- a/src/gtk/cross.xbm +++ b/src/gtk/cross.xbm @@ -1,6 +1,6 @@ #define cross_width 15 #define cross_height 15 -static char cross_bits[] = { +static unsigned char cross_bits[] = { 0x84, 0x10, 0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10}; diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index a27b61ae1f..f6a7f3a942 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -71,27 +71,42 @@ static GdkPixmap* GetHatch(int style) const int i = style - wxBRUSHSTYLE_FIRST_HATCH; if (hatches[i] == NULL) { + // This macro creates a bitmap from an XBM file included above. Notice + // the need for the cast because gdk_bitmap_create_from_data() doesn't + // accept unsigned data but the arrays in XBM need to be unsigned to + // avoid warnings (and even errors in C+0x mode) from g++. +#define CREATE_FROM_XBM_DATA(name) \ + gdk_bitmap_create_from_data \ + ( \ + NULL, \ + reinterpret_cast(name ## _bits), \ + name ## _width, \ + name ## _height \ + ) + switch (style) { case wxBRUSHSTYLE_BDIAGONAL_HATCH: - hatches[i] = gdk_bitmap_create_from_data(NULL, bdiag_bits, bdiag_width, bdiag_height); + hatches[i] = CREATE_FROM_XBM_DATA(bdiag); break; case wxBRUSHSTYLE_CROSSDIAG_HATCH: - hatches[i] = gdk_bitmap_create_from_data(NULL, cdiag_bits, cdiag_width, cdiag_height); + hatches[i] = CREATE_FROM_XBM_DATA(cdiag); break; case wxBRUSHSTYLE_CROSS_HATCH: - hatches[i] = gdk_bitmap_create_from_data(NULL, cross_bits, cross_width, cross_height); + hatches[i] = CREATE_FROM_XBM_DATA(cross); break; case wxBRUSHSTYLE_FDIAGONAL_HATCH: - hatches[i] = gdk_bitmap_create_from_data(NULL, fdiag_bits, fdiag_width, fdiag_height); + hatches[i] = CREATE_FROM_XBM_DATA(fdiag); break; case wxBRUSHSTYLE_HORIZONTAL_HATCH: - hatches[i] = gdk_bitmap_create_from_data(NULL, horiz_bits, horiz_width, horiz_height); + hatches[i] = CREATE_FROM_XBM_DATA(horiz); break; case wxBRUSHSTYLE_VERTICAL_HATCH: - hatches[i] = gdk_bitmap_create_from_data(NULL, verti_bits, verti_width, verti_height); + hatches[i] = CREATE_FROM_XBM_DATA(verti); break; } + +#undef CREATE_FROM_XBM_DATA } return hatches[i]; } diff --git a/src/gtk/fdiag.xbm b/src/gtk/fdiag.xbm index 67d3b4732a..76aa9f28b4 100644 --- a/src/gtk/fdiag.xbm +++ b/src/gtk/fdiag.xbm @@ -1,6 +1,6 @@ #define fdiag_width 16 #define fdiag_height 16 -static char fdiag_bits[] = { +static unsigned char fdiag_bits[] = { 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80}; diff --git a/src/gtk/horiz.xbm b/src/gtk/horiz.xbm index ff3309bcc4..f4a31c6e9d 100644 --- a/src/gtk/horiz.xbm +++ b/src/gtk/horiz.xbm @@ -1,6 +1,6 @@ #define horiz_width 15 #define horiz_height 15 -static char horiz_bits[] = { +static unsigned char horiz_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/gtk/verti.xbm b/src/gtk/verti.xbm index 2dd9dc4c05..b71941e82e 100644 --- a/src/gtk/verti.xbm +++ b/src/gtk/verti.xbm @@ -1,6 +1,6 @@ #define verti_width 15 #define verti_height 15 -static char verti_bits[] = { +static unsigned char verti_bits[] = { 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10};