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 » RichText,QTF,RTF... » how to get Text Size from controls like EditString?
how to get Text Size from controls like EditString? [message #2344] Sun, 09 April 2006 03:11 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
how to get Text Size from controls like EditString?
Re: how to get Text Size from controls like EditString? [message #2345 is a reply to message #2344] Sun, 09 April 2006 03:23 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
fudadmin wrote on Sun, 09 April 2006 02:11

how to get Text Size from controls like EditString?

ok. I've found and it looks ok for height:
	Font font = StdFont();
	int fheight = editor.GetStdHeight(font);

But how this works?:
Size GetSmartTextSize(Draw& w, const char *text, Font font = StdFont())

Re: how to get Text Size from controls like EditString? [message #2349 is a reply to message #2345] Sun, 09 April 2006 07:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
What is "Text Size" ?

How you expect GetSmartTextSize to be related?

GetSmartTextSize returns the size of text that can contain some control codes - '&' to designate hotkey, or '\1' at the beginning that marks text as QTF.

Mirek
Re: how to get Text Size from controls like EditString? [message #2354 is a reply to message #2349] Sun, 09 April 2006 13:41 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sun, 09 April 2006 06:26

1. What is "Text Size" ?

2. How you expect GetSmartTextSize to be related?

GetSmartTextSize returns the size of text that can contain some control codes - '&' to designate hotkey, or '\1' at the beginning that marks text as QTF.

Mirek



1. Text height and width (length) in pixels (for a font used in a control or any font).

2. That's what I want to find out... Smile I just found it...

I need to adjust my tree node size after editing...
Re: how to get Text Size from controls like EditString? [message #2358 is a reply to message #2354] Sun, 09 April 2006 15:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Sun, 09 April 2006 07:41

luzr wrote on Sun, 09 April 2006 06:26

1. What is "Text Size" ?

2. How you expect GetSmartTextSize to be related?

GetSmartTextSize returns the size of text that can contain some control codes - '&' to designate hotkey, or '\1' at the beginning that marks text as QTF.

Mirek



1. Text height and width (length) in pixels (for a font used in a control or any font).

2. That's what I want to find out... Smile I just found it...

I need to adjust my tree node size after editing...


Draw::GetTextSize?

Mirek
Re: how to get Text Size from controls like EditString? [message #2372 is a reply to message #2358] Mon, 10 April 2006 03:55 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Sun, 09 April 2006 14:55


...
Draw::GetTextSize?

Mirek


1. How to use it? (Same difficulty as Image resize... Smile )

2. I've found more...
Size sz1 = 	ScreenInfo().GetTextSize("text size test",font);
Size sz2 = 	StdDisplay().GetStdSize(editvalue);


but they require recalculations EditString...

3. Actually, it would be good to have EditField::AutoSize(true) or similar...
Re: how to get Text Size from controls like EditString? [message #2373 is a reply to message #2372] Mon, 10 April 2006 09:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Sun, 09 April 2006 21:55

luzr wrote on Sun, 09 April 2006 14:55


...
Draw::GetTextSize?

Mirek


1. How to use it? (Same difficulty as Image resize... Smile )

2. I've found more...
Size sz1 = 	ScreenInfo().GetTextSize("text size test",font);
Size sz2 = 	StdDisplay().GetStdSize(editvalue);


but they require recalculations EditString...

3. Actually, it would be good to have EditField::AutoSize(true) or similar...



1. Not at all - quite minimal interface IMHO (to get the text size, you have to know the text and the font, do not you).

OK, that ScreenInfo() is unnecessary and current refactoring will remove that...

2. Beware, StdDisplay().GetStdSize does not do exactly the same thing!

3. Ok, that would solve that, would not it? Wink I am sorry, not until now I have seen that that F2 feature in IE resizes editfield.... BTW, it is pretty fuzzy bussines....

Mirek
Re: how to get Text Size from controls like EditString? [message #2390 is a reply to message #2373] Mon, 10 April 2006 17:59 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
this code solved a problem for TreeCtrl without getting text size
after editing... Cool
    tree.GetNode(editid).size=Size(Null);


is this approach correct?
Re: how to get Text Size from controls like EditString? [message #2391 is a reply to message #2390] Mon, 10 April 2006 18:55 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Just some more thoughts...
Now I want to find a way to set
valuesize=???
editor.SetMinSize(valuesize);

(would be good automatically after char enter or Action...)
without Paint and Draw...

maybe editor.GetCaret could be used...?
or GetStringCx - is for length? if not, why there is no GetStringCy...? Smile

or get display from editor and to use like in TreeCtrl:
return display ? display->GetStdSize(value) : StdDisplay().GetStdSize(value);


...
(because TreeCtrl uses)
m.ctrl->GetMinSize();
Re: how to get Text Size from controls like EditString? [message #2392 is a reply to message #2391] Mon, 10 April 2006 22:22 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Just a reminder for other people that this code doesn't work... Smile
	Size sz1 = Draw::GetTextSize("text size test");
Re: how to get Text Size from controls like EditString? [message #2394 is a reply to message #2373] Tue, 11 April 2006 04:31 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Mon, 10 April 2006 08:22


3. Ok, that would solve that, would not it? Wink I am sorry, not until now I have seen that that F2 feature in IE resizes editfield.... BTW, it is pretty fuzzy bussines....

Mirek


I did it. Cool
Edit: P.S. Why is it fuzzy?

[Updated on: Tue, 11 April 2006 04:37]

Report message to a moderator

Re: how to get Text Size from controls like EditString? [message #2395 is a reply to message #2394] Tue, 11 April 2006 10:13 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 10 April 2006 22:31

luzr wrote on Mon, 10 April 2006 08:22


3. Ok, that would solve that, would not it? Wink I am sorry, not until now I have seen that that F2 feature in IE resizes editfield.... BTW, it is pretty fuzzy bussines....

Mirek


I did it. Cool
Edit: P.S. Why is it fuzzy?



Well, see HOW it gets resized... It grows when you type characters in, but the size is limited by the size of "view".

However, when you get the text scrolled, size is defined just by the part after the "scrollpoint", so if you delete them, it gets smaller than it would need to be to show the whole text. Quite weird Wink

Mirek
Re: how to get Text Size from controls like EditString? [message #2396 is a reply to message #2395] Tue, 11 April 2006 13:18 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Tue, 11 April 2006 09:13

fudadmin wrote on Mon, 10 April 2006 22:31

luzr wrote on Mon, 10 April 2006 08:22


3. Ok, that would solve that, would not it? Wink I am sorry, not until now I have seen that that F2 feature in IE resizes editfield.... BTW, it is pretty fuzzy bussines....

Mirek


I did it. Cool
Edit: P.S. Why is it fuzzy?



Well, see HOW it gets resized... It grows when you type characters in, but the size is limited by the size of "view".

However, when you get the text scrolled, size is defined just by the part after the "scrollpoint", so if you delete them, it gets smaller than it would need to be to show the whole text. Quite weird Wink

Mirek


I think it's more weird when Ultimate++ TreeCtrl doesn't have any editing capabilities... and users have to spend enormous amount of time searching for simple simple methods ... Wink

ok, this is a piece of code for it
Size NodeEditor::GetMinFitSize()  //todo: other fonts and displays
{
	Size sz = StdDisplay().GetStdSize(GetData());
	sz += Size(2 * 4, 2 * 3); //adding some margins...
	return sz;
}


BTW, it's possible to make the view to grow or grow Edit vertically, too.

[Updated on: Tue, 11 April 2006 16:20]

Report message to a moderator

Previous Topic: Is LineEdit the main normal text edit control? +DocEdit [SOLVED...]
Next Topic: Scrollable log window with colour text
Goto Forum:
  


Current Time: Fri Mar 29 11:59:35 CET 2024

Total time taken to generate the page: 0.02777 seconds