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 » 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 Go to next message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced 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
Re: How to change color of selected text in DropList ? [message #36734 is a reply to message #36688] Fri, 29 June 2012 14:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
You need to use either of Paint parameters:

Color paper

- this returns correct background color for given situation

dword style

- this returns the visual style

(or you can combine, e.g. use paper is style != 0 is quite a good option usually)

Check here:

http://www.ultimatepp.org/src$Draw$Display$en-us.html

Re: How to change color of selected text in DropList ? [message #36742 is a reply to message #36734] Sat, 30 June 2012 15:42 Go to previous message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced Member
Thank you for your help Mirek,

Which value for style parameter ? Does 0 mean standard behaviour ?

Thank you again for your support

Regards
Biobytes
Previous Topic: how to dispaly moving text has any idea?
Next Topic: PNG in Draw
Goto Forum:
  


Current Time: Wed Nov 20 15:44:09 CET 2019

Total time taken to generate the page: 0.01746 seconds