Wild, wild hacking ... ;-)
Manolo, it's fine that you could fix this "id" problem, but I
strongly suggest that we should find another solution - even if
this is only needed for "old" gcc versions. Such hacks tend to
stay in the code forever(TM).
Fiddling around with #defines looks like a really bad solution.
I just did a quick rename of the id member variable in Fl_Pixmap
and Fl_Bitmap as a proof of concept, but I didn't really test it
other than compiling and running test/pixmap_browser (and it works).
Thus, I propose to rename the id variable, although it is public,
but marked as "for internal use".
Opinions, anybody? I just used "iid" instead of "id" - see attached
patch file. It's only a POC, and maybe I hit something that
doesn't need to be replaced, but just to show that it could be
done...
Matthias, Mike, I think that you would know the old code best,
so what are your opinions? Better names? Other ideas?
Albrecht
PS: excerpt from svn diff -c 7270:
$ svn diff -c 7270
Index: src/Fl_cocoa.mm
===================================================================
--- src/Fl_cocoa.mm (revision 7269)
+++ src/Fl_cocoa.mm (revision 7270)
@@ -90,7 +90,6 @@
}
-#include <FL/Fl_Device.H>
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/Fl_Window.H>
@@ -99,8 +98,12 @@
// because Fl_Image.H, included by Fl_Sys_Menu_Bar.H, uses a private
variable name id
// that's illegal under GCC 3 -x -objective-c++
#define id id_
+// because Fl_Bitmap.H and Fl_Pixmap.H included by Fl_Printer.H don't
compile with gcc3 and objective-c++
+#define Fl_Bitmap_H
+#define Fl_Pixmap_H
#endif
#include <FL/Fl_Sys_Menu_Bar.H>
+#include <FL/Fl_Printer.H>
#ifdef id
#undef id
#endif
Index: src/Fl_Bitmap.cxx
===================================================================
--- src/Fl_Bitmap.cxx (Revision 7263)
+++ src/Fl_Bitmap.cxx (Arbeitskopie)
@@ -52,12 +52,12 @@
*dst++ = ((reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] &
0x0f))^0xff;
}
CGDataProviderRef srcp = CGDataProviderCreateWithData( 0L, bmask,
rowBytes*h, 0L);
- CGImageRef id = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
+ CGImageRef iid = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
CGDataProviderRelease(srcp);
- return (Fl_Bitmask)id;
+ return (Fl_Bitmask)iid;
}
-void fl_delete_bitmask(Fl_Bitmask id) {
- if (id) CGImageRelease((CGImageRef)id);
+void fl_delete_bitmask(Fl_Bitmask iid) {
+ if (iid) CGImageRelease((CGImageRef)iid);
}
#elif defined(WIN32) // Windows bitmask functions...
// 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing...
@@ -69,7 +69,7 @@
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
- Fl_Bitmask id;
+ Fl_Bitmask iid;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
@@ -81,18 +81,18 @@
dest += w2-w1;
}
- id = CreateBitmap(w, h, 1, 1, newarray);
+ iid = CreateBitmap(w, h, 1, 1, newarray);
delete[] newarray;
- return id;
+ return iid;
}
// 'fl_create_bitmask()' - Create an N-bit bitmap for masking...
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data) {
// this won't work when the user changes display mode during run or
// has two screens with differnet depths
- Fl_Bitmask id;
+ Fl_Bitmask iid;
static uchar hiNibble[16] =
{ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0 };
@@ -141,10 +141,10 @@
dst += pad;
}
- id = CreateBitmap(w, h, np, bpp, newarray);
+ iid = CreateBitmap(w, h, np, bpp, newarray);
delete[] newarray;
- return id;
+ return iid;
}
#if 0 // This doesn't appear to be used anywhere...
@@ -156,7 +156,7 @@
uchar* newarray = new uchar[w2*h];
const uchar* src = data;
uchar* dest = newarray;
- Fl_Bitmask id;
+ Fl_Bitmask iid;
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
@@ -168,11 +168,11 @@
dest += w2-w1;
}
- id = CreateBitmap(w, h, 1, 1, newarray);
+ iid = CreateBitmap(w, h, 1, 1, newarray);
delete[] newarray;
- return (id);
+ return (iid);
}
# endif // 0
@@ -286,9 +286,9 @@
if (H <= 0) return;
#if defined(USE_X11)
- if (!id) id = fl_create_bitmask(w(), h(), array);
+ if (!iid) iid = fl_create_bitmask(w(), h(), array);
- XSetStipple(fl_display, fl_gc, id);
+ XSetStipple(fl_display, fl_gc, iid);
int ox = X-cx; if (ox < 0) ox += w();
int oy = Y-cy; if (oy < 0) oy += h();
XSetTSOrigin(fl_display, fl_gc, ox, oy);
@@ -296,7 +296,7 @@
XFillRectangle(fl_display, fl_window, fl_gc, X, Y, W, H);
XSetFillStyle(fl_display, fl_gc, FillSolid);
#elif defined(WIN32)
- if (!id) id = fl_create_bitmap(w(), h(), array);
+ if (!iid) iid = fl_create_bitmap(w(), h(), array);
typedef BOOL (WINAPI* fl_transp_func)
(HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static fl_transp_func fl_TransparentBlt;
@@ -326,7 +326,7 @@
fl_color(save_c); // back to bitmap's color
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
- SelectObject(tempdc, (HGDIOBJ)id);
+ SelectObject(tempdc, (HGDIOBJ)iid);
SelectObject(fl_gc, fl_brush()); // use bitmap's desired color
BitBlt(fl_gc, 0, 0, W, H, tempdc, 0, 0, 0xE20746L); // draw bitmap to
offscreen
fl_end_offscreen(); // offscreen data is in tmp_id
@@ -338,7 +338,7 @@
else { // algorithm for bitmap output to display
tempdc = CreateCompatibleDC(fl_gc);
save = SaveDC(tempdc);
- SelectObject(tempdc, (HGDIOBJ)id);
+ SelectObject(tempdc, (HGDIOBJ)iid);
SelectObject(fl_gc, fl_brush());
// secret bitblt code found in old MSWindows reference manual:
BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
@@ -346,11 +346,11 @@
RestoreDC(tempdc, save);
DeleteDC(tempdc);
#elif defined(__APPLE_QUARTZ__)
- if (!id) id = fl_create_bitmask(w(), h(), array);
- if (id && fl_gc) {
+ if (!iid) iid = fl_create_bitmask(w(), h(), array);
+ if (iid && fl_gc) {
CGRect rect = { { X, Y }, { W, H } };
Fl_X::q_begin_image(rect, cx, cy, w(), h());
- CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
+ CGContextDrawImage(fl_gc, rect, (CGImageRef)iid);
Fl_X::q_end_image();
}
#else
@@ -368,13 +368,13 @@
}
void Fl_Bitmap::uncache() {
- if (id) {
+ if (iid) {
#if defined(__APPLE__) && defined(__APPLE_COCOA__)
- fl_delete_bitmask((Fl_Bitmask)id);
+ fl_delete_bitmask((Fl_Bitmask)iid);
#else
- fl_delete_bitmask((Fl_Offscreen)id);
+ fl_delete_bitmask((Fl_Offscreen)iid);
#endif
- id = 0;
+ iid = 0;
}
}
Index: src/Fl_Pixmap.cxx
===================================================================
--- src/Fl_Pixmap.cxx (Revision 7263)
+++ src/Fl_Pixmap.cxx (Arbeitskopie)
@@ -103,15 +103,15 @@
if (cy < 0) {H += cy; Y -= cy; cy = 0;}
if (cy+H > h()) H = h()-cy;
if (H <= 0) return;
- if (!id) {
+ if (!iid) {
#ifdef __APPLE_QUARTZ__
- id = fl_create_offscreen_with_alpha(w(), h());
- fl_begin_offscreen((Fl_Offscreen)id);
+ iid = fl_create_offscreen_with_alpha(w(), h());
+ fl_begin_offscreen((Fl_Offscreen)iid);
fl_draw_pixmap(data(), 0, 0, FL_GREEN);
fl_end_offscreen();
#else
- id = fl_create_offscreen(w(), h());
- fl_begin_offscreen((Fl_Offscreen)id);
+ iid = fl_create_offscreen(w(), h());
+ fl_begin_offscreen((Fl_Offscreen)iid);
uchar *bitmap = 0;
fl_mask_bitmap = &bitmap;
fl_draw_pixmap(data(), 0, 0, FL_BLACK);
@@ -137,7 +137,7 @@
int oy = Y-cy; if (oy < 0) oy += h();
XSetClipOrigin(fl_display, fl_gc, X-cx, Y-cy);
}
- fl_copy_offscreen(X, Y, W, H, id, cx, cy);
+ fl_copy_offscreen(X, Y, W, H, iid, cx, cy);
if (mask) {
// put the old clip region back
XSetClipOrigin(fl_display, fl_gc, 0, 0);
@@ -188,7 +188,7 @@
fl_delete_offscreen(tmp_id);
}
else {
- fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
+ fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)iid, cx, cy);
}
}
else if (mask) {
@@ -196,15 +196,15 @@
int save = SaveDC(new_gc);
SelectObject(new_gc, (void*)mask);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCAND);
- SelectObject(new_gc, (void*)id);
+ SelectObject(new_gc, (void*)iid);
BitBlt(fl_gc, X, Y, W, H, new_gc, cx, cy, SRCPAINT);
RestoreDC(new_gc,save);
DeleteDC(new_gc);
} else {
- fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
+ fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)iid, cx, cy);
}
#elif defined(__APPLE_QUARTZ__)
- fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)id, cx, cy);
+ fl_copy_offscreen(X, Y, W, H, (Fl_Offscreen)iid, cx, cy);
#else
# error unsupported platform
#endif
@@ -220,9 +220,9 @@
}
void Fl_Pixmap::uncache() {
- if (id) {
- fl_delete_offscreen((Fl_Offscreen)id);
- id = 0;
+ if (iid) {
+ fl_delete_offscreen((Fl_Offscreen)iid);
+ iid = 0;
}
if (mask) {
Index: FL/Fl_Pixmap.H
===================================================================
--- FL/Fl_Pixmap.H (Revision 7262)
+++ FL/Fl_Pixmap.H (Arbeitskopie)
@@ -57,21 +57,21 @@
int alloc_data; // Non-zero if data was allocated
#if defined(__APPLE__) || defined(WIN32)
- void *id; // for internal use
+ void *iid; // for internal use
void *mask; // for internal use (mask bitmap)
#else
- unsigned id; // for internal use
+ unsigned iid; // for internal use
unsigned mask; // for internal use (mask bitmap)
#endif // __APPLE__ || WIN32
/** The constructors create a new pixmap from the specified XPM data. */
- explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0),
id(0), mask(0) {set_data((const char*const*)D); measure();}
+ explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0),
iid(0), mask(0) {set_data((const char*const*)D); measure();}
/** The constructors create a new pixmap from the specified XPM data. */
- explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0),
id(0), mask(0) {set_data((const char*const*)D); measure();}
+ explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0),
iid(0), mask(0) {set_data((const char*const*)D); measure();}
/** The constructors create a new pixmap from the specified XPM data. */
- explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1),
alloc_data(0), id(0), mask(0) {set_data((const char*const*)D); measure();}
+ explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1),
alloc_data(0), iid(0), mask(0) {set_data((const char*const*)D); measure();}
/** The constructors create a new pixmap from the specified XPM data. */
- explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1),
alloc_data(0), id(0), mask(0) {set_data((const char*const*)D); measure();}
+ explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1),
alloc_data(0), iid(0), mask(0) {set_data((const char*const*)D); measure();}
virtual ~Fl_Pixmap();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return copy(w(), h()); }
Index: FL/Fl_Bitmap.H
===================================================================
--- FL/Fl_Bitmap.H (Revision 7262)
+++ FL/Fl_Bitmap.H (Arbeitskopie)
@@ -48,17 +48,17 @@
int alloc_array;
#if defined(__APPLE__) || defined(WIN32)
/** for internal use */
- void *id;
+ void *iid;
#else
/** for internal use */
- unsigned id;
+ unsigned iid;
#endif // __APPLE__ || WIN32
/** The constructors create a new bitmap from the specified bitmap data */
Fl_Bitmap(const uchar *bits, int W, int H) :
- Fl_Image(W,H,0), array(bits), alloc_array(0), id(0) {data((const char
**)&array, 1);}
+ Fl_Image(W,H,0), array(bits), alloc_array(0), iid(0) {data((const char
**)&array, 1);}
/** The constructors create a new bitmap from the specified bitmap data */
Fl_Bitmap(const char *bits, int W, int H) :
- Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id(0)
{data((const char **)&array, 1);}
+ Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), iid(0)
{data((const char **)&array, 1);}
virtual ~Fl_Bitmap();
virtual Fl_Image *copy(int W, int H);
Fl_Image *copy() { return copy(w(), h()); }
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev