|
|
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ColorRows() in GridCtrl - Strange code. Help pls.
ColorRows() in GridCtrl - Strange code. Help pls. [message #19591] |
Mon, 22 December 2008 01:39 |
|
I try to set custom even and odd colors of GridCtrl. Then I switch on Coloring mode - ColorRows() , - but GridCtrl set for even rows some default color.
I try to set directly ColoringMode(2); - work fine - custom colors are right.
I found code, which very strange -
GridCtrl& ColorRows(bool b = true) { return ColoringMode(2 * b).EvenColor(); }
And see to EvenColor definition :
GridCtrl& EvenColor(Color fg = SColorText, Color bg = Blend(SColorHighlight, SColorPaper, 220));
That is, the operator ColoringMode(2 * b).EvenColor(); call EvenColor without parameters - thus replaces my custom color.
Maybe this logic is wrong?
I suggested that in some cases so convenient to initialize color even lines by default.
But what about when you need to set their color does not match the default.
I propose that the code
GridCtrl& ColorRows(bool b = true) { return ColoringMode(2 * b).EvenColor(); }
replaced by the code
GridCtrl& ColorRows(bool b = true) { return ColoringMode(2 * b); }
, and the even color initialize another method.
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
|
|
|
Re: ColorRows() in GridCtrl - Strange code. Help pls. [message #19606 is a reply to message #19593] |
Mon, 22 December 2008 17:27 |
|
No, nothing is strange, just haven't seen this code for a long time . The idea behind ColorRows/ColorCols was to enable or disable coloring of even rows/cols with single method call. They are just "wrappers" to ColoringMode, Even(Odd)Color sequence. So to enable your custom coloring scheme call EvenColor after ColorRows or call it with ColoringMode method without taking care of call order.
I know ColorRows is more readable than ColoringMode(1) but I won't change it now (you can achieve what you want in a little bit different way)
|
|
|
Re: ColorRows() in GridCtrl - Strange code. Help pls. [message #19608 is a reply to message #19606] |
Mon, 22 December 2008 20:02 |
|
unodgs wrote on Mon, 22 December 2008 19:27 | No, nothing is strange, just haven't seen this code for a long time . The idea behind ColorRows/ColorCols was to enable or disable coloring of even rows/cols with single method call. They are just "wrappers" to ColoringMode, Even(Odd)Color sequence. So to enable your custom coloring scheme call EvenColor after ColorRows or call it with ColoringMode method without taking care of call order.
I know ColorRows is more readable than ColoringMode(1) but I won't change it now (you can achieve what you want in a little bit different way)
|
I think the difference these functions not essential, but the similarity of names is - and not selfrefference and not transparent, why not obvious use of this or that.
Maybe once, add the words in the title of functions, which would be more accurately referred to the actions that they produce?
And the rest - Thank you for a quick response.
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: ColorRows() in GridCtrl - Strange code. Help pls. [message #19611 is a reply to message #19608] |
Mon, 22 December 2008 21:40 |
|
I understand that is already written hundreds or even thousands of lines of programming, and change the names of functions - will make a non-working programs.
I offer a beautiful solution that at least will be informative to once again use this feature (ColorRows and ColorCols).
Definition must be like this:
GridCtrl& ColorRows(bool b = true, bool initializeDefaultColor = true) {
if(initializeDefaultColor)
return ColoringMode(2 * b).EvenColor();
else
return ColoringMode(2 * b);
}
Variable initializeDefaultColor is SELFREFFERENCING and other people will do not make my mistake
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Goto Forum:
Current Time: Sun Apr 28 22:10:03 CEST 2024
Total time taken to generate the page: 0.04324 seconds
|
|
|