Skip to main content
Topic: uTextOutColorsTabbed() - default color for selected text? (Read 2307 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

uTextOutColorsTabbed() - default color for selected text?

I'm using custom formatting string with tabulators and colors ($tab(), $rgb()). I use owner-drawing on my DropDown List. Here is part of the code:

Code: [Select]
lpdis = (LPDRAWITEMSTRUCT) lparam;
DWORD defaultColor =
      GetSysColor(lpdis->itemState & ODS_SELECTED ?
      COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
.
.
.
uTextOutColorsTabbed(lpdis->hDC,
      formatted_titles[lpdis->itemID],
      infinite, &(lpdis->rcItem), 2, &(lpdis->rcItem),
      lpdis->itemState & ODS_SELECTED,
      defaultColor,
      true);


formatted_titles[n] is where I store my formatted string, for example:
Code: [Select]
Text_In_Default_Color $rgb(0,255,0) Text_In_Green $tab() RALIGN


The problem is: when the item is not selected - everything is OK. But, when the item is selected, then uTextOutColorsTabbed seems to ignore my defaultColor value and displays text (Text_In_Default_Color here) in black. There is no problem, when I set (BOOL) selected parameter to false (but then the selected color from $rgb(x,y,z,s_x,s_y,s_z) is ignored...)

Am I missing something?...

PS. What is the (BOOL) use_columns parameter for? I can't see the difference when using it or not.

uTextOutColorsTabbed() - default color for selected text?

Reply #1
If selected is true, the function inverts the default background color, so if you want to explicitly set a certain default color for the selected state, you should invert it before passing it to uTextOutColorsTabbed. Example:
Code: [Select]
uTextOutColorsTabbed(hDC, ..., selected, selected ? (selected_color ^ 0xFFFFFF) : normal_color, true);

If use_columns is true, the function behaves as in the Default User Interface playlist, i.e. everything after the last tab is right-aligned, and the other tabs (if any) are used to position left-aligned text at intervals determined by the total number of tabs in the text. If the parameter is false, every tab expands to an equal amount of space. If the text only contains one tab, there is no visible difference. However, try to compare these cases:
Code: [Select]
A$tab(2)B$tab(1)C
AAAA$tab(2)B$tab(1)C
A$tab()B$tab()
0123456789$tab()ABCDEFGHIJ$tab()
A$tab()
$tab()A

The output would vaguely resemble this with use_columns set to false (assumed width is 12 characters):
Code: [Select]
A      B   C
AAAA    B  C
A     B    
0123456789AB
A          
           A

If it is set to true, it would be something like this:
Code: [Select]
A       B  C
AAAA    B  C
A     B    
012345ABCDEF
A          
           A

Note the difference how text is clipped in the fourth line and how the right-aligned text in the first two lines is drawn in the space allocated to the second column with use_columns set to true.

This is from memory; I hope I got the examples right.

uTextOutColorsTabbed() - default color for selected text?

Reply #2
Thank you for your explanations, now everything look fine  Indeed, i didn't see the difference because I used only one tab.

 
SimplePortal 1.0.0 RC1 © 2008-2020