Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

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 #19593 is a reply to message #19591] Mon, 22 December 2008 08:29 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Something is really strage there. I wonder where it comes from Smile. I'll try to find out what's going on.
Re: ColorRows() in GridCtrl - Strange code. Help pls. [message #19596 is a reply to message #19593] Mon, 22 December 2008 10:07 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

unodgs wrote on Mon, 22 December 2008 10:29

I'll try to find out what's going on.


GridCtrl.h line 1035 definition of ColorRows().
(I use svn-643)


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: ColorRows() in GridCtrl - Strange code. Help pls. [message #19597 is a reply to message #19596] Mon, 22 December 2008 10:09 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Oops ColorCols have same logic!

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 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

No, nothing is strange, just haven't seen this code for a long time Wink. 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 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

unodgs wrote on Mon, 22 December 2008 19:27

No, nothing is strange, just haven't seen this code for a long time Wink. 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 Go to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

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 );
}
Previous Topic: Problem with ColumnWidths in GridCtrl
Next Topic: GridCtrl - crashes on UBUNTU.
Goto Forum:
  


Current Time: Sun Apr 28 22:10:03 CEST 2024

Total time taken to generate the page: 0.04324 seconds