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 » Community » Newbie corner » How do I get parameters for GetTextSize ( Get parameters for GetTextSize)
How do I get parameters for GetTextSize [message #43275] Sat, 21 June 2014 16:32 Go to next message
awksed is currently offline  awksed
Messages: 61
Registered: April 2012
Member
I need to resize a DropList according to the longest string in the list.

How do I get the parameters for GetTextSize() (presumably something like Draw object and font)?

Thanks.
Re: How do I get parameters for GetTextSize [message #43295 is a reply to message #43275] Tue, 24 June 2014 21:44 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi awksed,

You could get your text width using GetTextSize(const FontInfo& ft,WString& str) and adapt the DropList width using DropList::SetMinSize(Size sz).

Hope this could be helpful

Cheers Smile

Biobytes
Re: How do I get parameters for GetTextSize [message #43316 is a reply to message #43295] Sun, 29 June 2014 14:09 Go to previous messageGo to next message
awksed is currently offline  awksed
Messages: 61
Registered: April 2012
Member
Hi BioBytes,

Thank you for your reply.

Sorry if my question was a little fuzzy.

What I really wanted to know is how do I obtain the actual font used in the DropList in question. (I assume this can be set to a different font from the standard font).

My code for the present is:

void MyDialog::MyFunction()
{
Font font = GetStdFont();
}

Presumably as this is called from the dialog it will not return the font used in the DropList if this has been changed. (DropList::GetStdFont() does not exist).

Regards,

awksed
Re: How do I get parameters for GetTextSize [message #43331 is a reply to message #43316] Mon, 30 June 2014 22:02 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Awksed,

Ok that is somewhat clearer now. Perhaps you could try the code below:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	DropList dl;
	TopWindow win;
	win.SetRect(0, 0, 400, 50);
	win.Add(dl.HSizePos(4, 4).TopPos(10, Ctrl::STDSIZE));
	dl.Add(0, AttrText("This is bold")SetFont(Courier(25)).Bold());
	dl.Add(1, AttrText("This is red").SetFont(Arial(25)).Ink(Red()));
	dl.Add(2, AttrText("This is centered").SetFont(Tahoma(25)).Center());
	dl.SetLineCy(30);
	dl <<= 0;
	win.Run();
}


Hope this could help you Nod

Good coding

Biobytes
Re: How do I get parameters for GetTextSize [message #43339 is a reply to message #43331] Tue, 01 July 2014 17:19 Go to previous messageGo to next message
awksed is currently offline  awksed
Messages: 61
Registered: April 2012
Member
Hi Biobytes,

Thank you. That is most informative.

Having set the font for the DropList item, how would I retrieve it.

Regards,

awksed
Re: How do I get parameters for GetTextSize [message #43344 is a reply to message #43339] Thu, 03 July 2014 21:45 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Awksed,

Sorry for late reply due to be busy IRL.

Perhaps you could have a look below:

http:// www.ultimatepp.org/forums/index.php?t=msg&goto=42079& ;&srch=font#msg_42079

Hope it helps Very Happy

Cheers

Biobytes
Re: How do I get parameters for GetTextSize [message #43345 is a reply to message #43344] Fri, 04 July 2014 18:38 Go to previous messageGo to next message
awksed is currently offline  awksed
Messages: 61
Registered: April 2012
Member
Hi Biobytes,

Sorry. I must be rather dense but I cannot see where in the link you provide there is a clue as to how answer the following question:-

Given:

DropList dl;

dl.Add(0, AttrText("This is bold")SetFont(Courier(25)).Bold());

Font font = ???

// Please replace the ??? with the appropriate code to obtain the Font object that is set in dl[0] above (which would be the appropriate Font object to pass to GetTextSize(..., font) for dl[0]).

Regards,

awksed
Re: How do I get parameters for GetTextSize [message #43346 is a reply to message #43345] Sun, 06 July 2014 10:49 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Awksed,

Sorry not having fully understood your second question Confused

I am not sure that getting the font of a line in the droplist could be done easily. AttrText does not have any corresponding function. You save the font name used in each line of the droplist in a Vector object.

Regards

Biobytes
Re: How do I get parameters for GetTextSize [message #43367 is a reply to message #43346] Sat, 12 July 2014 18:11 Go to previous message
awksed is currently offline  awksed
Messages: 61
Registered: April 2012
Member
Hi Biobytes,

I guess that makes sense.

Thanks for your help.

awksed

[Updated on: Sun, 13 July 2014 11:10]

Report message to a moderator

Previous Topic: How to position dialog in relation to parent window
Next Topic: Display of long text
Goto Forum:
  


Current Time: Thu Mar 28 14:15:09 CET 2024

Total time taken to generate the page: 0.01376 seconds