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
This commit is contained in:
Vadim Zeitlin
2010-10-18 23:43:20 +00:00
parent 40f48834fc
commit 1780a38b7b
7 changed files with 27 additions and 12 deletions

View 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};

View 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};

View 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};

View 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];
}

View 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};

View 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};

View 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};