Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » How to change color of selected text in DropList ?
How to change color of selected text in DropList ? [message #36688] |
Mon, 25 June 2012 22:16  |
 |
BioBytes
Messages: 307 Registered: October 2008 Location: France
|
Senior Member |
|
|
Hi all,
I understood that Droplist can be customized using Display. So I created my own display as described below:
//Declaration of the specific display
struct dropListDisplay:Display
{
public:
void setColors(Color text,Color back);
void setFont(Font& ft);
private:
Color textColor,backColor;
Font textFont;
//Rect rect;
virtual void Paint(Draw& w,const Rect& r, const Value& q,
Color ink,Color paper,dword style)const;
};
//Implementation of the methods
void dropListDisplay::setColors(Color text,Color back)
{
textColor = text;
backColor = back;
}
void dropListDisplay::setFont(Font& ft)
{
textFont = ft;
}
void dropListDisplay::Paint(Draw& w,const Rect& r,const Value& q,Color ink,Color paper,dword style)const
{
paper = backColor;
ink = textColor;
w.DrawRect(r,paper);
w.DrawText(r.left + 2, r.top + (r.Height() - GetTextSize(AsString(q), textFont).cy)/2,AsString(q),textFont,ink);
}
I load my own droplist display in the dialog window as follows:
{....
dropListDisplay dlStatementDisplay;
dlStatementDisplay.setColors(Green(),White());
dlStatementDisplay.setFont(Arial(11).Bold());
qsSkillStmentDl.SetDisplay(dlStatementDisplay);
qsSkillStmentDl<<=THISBACK(ShowOpeNames);
}
All is working perfectly (color and font correctly implemented) but I did not find how to set the item color to highlight the selected item in droplist, i.e. when the user clicks on a selected item, the color of the selected item remains unchanged.
http://www.hostingpics.net/viewer.php?id=399709Droplist.jpg
I tried to add some code to modify the Droplist style as described below:
static MultiButton::Style es = qsSkillStmentDl.StyleDefault();
es.sep1 = Turquoise();
qsSkillStmentDl.SetStyle(es);
qsSkillStmentDl.Refresh();
dlStatementDisplay.setColors(Green(),White());
dlStatementDisplay.setFont(Arial(11).Bold());
qsSkillStmentDl.SetDisplay(dlStatementDisplay);
qsSkillStmentDl<<=THISBACK(ShowOpeNames);
As I ignore the meaning of the different fields in the MultiButton style structure, it is not easy to make modifications.
Somebody could explain how to deal with Droplist style ?
Thanks in advance for reply
Biobytes
|
|
|
|
|
Goto Forum:
Current Time: Mon May 29 23:17:02 CEST 2023
Total time taken to generate the page: 0.02563 seconds
|