On approximately 10/7/2004 3:15 PM, came the following characters from
the keyboard of Glenn Linderman:
On approximately 10/7/2004 2:23 PM, came the following characters from
the keyboard of Laurent ROCHER:
Hi Blair,
Fix and commit on CVS.
Problem come from BS_CENTER style is BS_LEFT | BS_RIGHT so SwitchBit
order it's important.
I rewrite like this :
if(strcmp(option, "-align") == 0) {
// BS_CENTER is BS_LEFT | BS_RIGHT
if(strcmp(SvPV_nolen(value), "left") == 0) {
SwitchBit(perlcs->cs.style, BS_RIGHT, 0);
SwitchBit(perlcs->cs.style, BS_LEFT, 1);
} else if(strcmp(SvPV_nolen(value), "center") == 0) {
SwitchBit(perlcs->cs.style, BS_CENTER, 1);
Shouldn't this be
SwitchBit(perlcs->cs.style, BS_CENTER, 3);
No, not this one. I misread how SwitchBit works. Sorry for multiple
postings, but I remembered tha SwitchBit was pretty obscure... but I
forgot in what way it was obscure.
or alternately (to expose that BS_CENTER is BS_LEFT | BS_RIGHT)
SwitchBit(perlcs->cs.style, BS_RIGHT, 1);
SwitchBit(perlcs->cs.style, BS_LEFT, 1);
This is the only one that will work. SwitchBit is not smart enough to
deal with multi-bit values. If the previous value was BS_RIGHT or
BS_LEFT, SwitchBit is not smart enough to only turn on the other bit.
Because of its "if(!(mask & bit)) test, which will be false. Nor is it
smart enough to turn off both bits with "SwitchBit(perlcs->cs.style,
BS_CENTER,0);", because it uses "mask ^= bit;" which will turn on the
other bit.
Really, it would be easier if there were a primitive that dealt with
setting bitfields of variable width. Such exist, but not as part of
Win32::GUI.
#define SetBits(mask, bits) {mask |= bits;}
#define ResetBits(mask, bits) {mask &= ~(bits);}
#define SwitchBits(mask, bits, set) \
{if (set) SetBits(mask,bits) else ResetBits(mask,bits);}
would be more useful, in my opinion.
} else if(strcmp(SvPV_nolen(value), "right") == 0) {
SwitchBit(perlcs->cs.style, BS_LEFT, 0);
SwitchBit(perlcs->cs.style, BS_RIGHT, 1);
} else {
if(PL_dowarn) warn("Win32::GUI: Invalid value for -align!");
}
}
Thank for bug report.
Laurent.
I've noticed that the button attribute "align" breaks if you specify
"center", if empty it works (i.e. default).
<pre>
use Win32::GUI;
my $W = new GUI::Window(-height=>100,-width=>100);
my $B = $W->AddButton(-text=>'Test', -width=>'100', -align=>'center');
$W->Center();
$W->Show();
Win32::GUI::Dialog;
</pre>
If one replaces "center" with "right" it works as expected. The error is
not apparent in Button.xs and I've happens on XPsp2 and W2Ksp4.
Blair
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Perl-Win32-GUI-Hackers mailing list
Perl-Win32-GUI-Hackers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers
--
Glenn -- http://nevcal.com/
===========================
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.