]> git.saurik.com Git - wxWidgets.git/commitdiff
Use unsigned char for XBM bitmaps data.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Oct 2010 23:43:20 +0000 (23:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Oct 2010 23:43:20 +0000 (23:43 +0000)
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

src/gtk/bdiag.xbm
src/gtk/cdiag.xbm
src/gtk/cross.xbm
src/gtk/dcclient.cpp
src/gtk/fdiag.xbm
src/gtk/horiz.xbm
src/gtk/verti.xbm

index 9ff0a1822f2a59be293ab4e1a5391bda8b83217e..6b3ba001e9fe334e581ae37b553efbec8f98042c 100644 (file)
@@ -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};
index 15dc7ba86d426aad3af6dc6903b00855dd9fd5b9..e0502f2303bd2db6af36a9876762bf7e826cfc90 100644 (file)
@@ -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};
index b07cbe7fcdfc2844b7726ae68b6ab5f2ff451e85..916ee76e3a876cf98d8b82285a3bc4c2b72bbbdd 100644 (file)
@@ -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};
index a27b61ae1fbd653b7b1b247bfe876210b1b67810..f6a7f3a94251d39c1ba7bbef9f8bc6bf989df793 100644 (file)
@@ -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<gchar *>(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];
 }
index 67d3b4732a1e851dcf69523873f6a929cb651eeb..76aa9f28b48878bcc165683a7ec079c6189d0d50 100644 (file)
@@ -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};
index ff3309bcc45a4b8c797bebb2985d6cab193de944..f4a31c6e9d6417f1421630edf1c491e3a7cf5857 100644 (file)
@@ -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};
index 2dd9dc4c05148dc8e345d9162c899c166df81e2b..b71941e82e0982713dc431a5052cae758045c572 100644 (file)
@@ -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};