[openbeos] ifdef style
- From: "Jonas Sundström" <jonas@xxxxxxxxxxx>
- To: openbeos@xxxxxxxxxxxxx
- Date: Sun, 25 Feb 2007 22:19:57 +0100 CET
Which ifdef:ing is the most desirable in this case?
(OT's coding guidelines don't mention defines.)
This:
if (fDeviceIcon) {
if (IsEnabled()) {
#ifdef __HAIKU__
Menu()->SetDrawingMode(B_OP_ALPHA);
#else
Menu()->SetDrawingMode(B_OP_OVER);
#endif
}
else {
#ifdef __HAIKU__
Menu()->SetDrawingMode(B_OP_ALPHA);
Menu()->SetDrawingMode(B_OP_ALPHA);
Menu()->SetHighColor(0, 0, 0, 64);
Menu()->SetBlendingMode(B_CONSTANT_ALPHA,
B_ALPHA_OVERLAY);
#else
Menu()->SetDrawingMode(B_OP_BLEND);
#endif
}
Menu()->DrawBitmapAsync(fDeviceIcon, where);
}
Or this:
#ifdef __HAIKU__
if (fDeviceIcon) {
if (IsEnabled()) {
Menu()->SetDrawingMode(B_OP_ALPHA);
}
else {
Menu()->SetDrawingMode(B_OP_ALPHA);
Menu()->SetDrawingMode(B_OP_ALPHA);
Menu()->SetHighColor(0, 0, 0, 64);
Menu()->SetBlendingMode(B_CONSTANT_ALPHA,
B_ALPHA_OVERLAY);
}
Menu()->DrawBitmapAsync(fDeviceIcon, where);
}
#else
if (fDeviceIcon) {
if (IsEnabled())
Menu()->SetDrawingMode(B_OP_OVER);
else
Menu()->SetDrawingMode(B_OP_BLEND);
Menu()->DrawBitmapAsync(fDeviceIcon, where);
}
#endif
I think the latter is a lot easier to read, but leaves up to the
reader to understand what the diff is between the two cases,
(the actual drawing mode setting), which of course in this case'
is very easy to see. Is this okay?
Also, is it really necessary to #endif // __HAIKU__ or is that
only used for multipage #ifdefs, such as header guards ?
TIA,
Jonas Sundström.
- Follow-Ups:
- [openbeos] Re: ifdef style
- From: Jonas Sundström
- [openbeos] Re: ifdef style
- From: Ingo Weinhold
Other related posts:
- » [openbeos] ifdef style
- » [openbeos] Re: ifdef style
- » [openbeos] Re: ifdef style
- » [openbeos] Re: ifdef style
- [openbeos] Re: ifdef style
- From: Jonas Sundström
- [openbeos] Re: ifdef style
- From: Ingo Weinhold