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 » U++ Widgets - General questions or Mixed problems » Background color of StaticText or EditString
Background color of StaticText or EditString [message #54801] Thu, 17 September 2020 11:20 Go to next message
aquilarubra is currently offline  aquilarubra
Messages: 23
Registered: December 2019
Promising Member
Hi, how can I set a background color for StaticText or EditString?

I don't know if Chamaleon is necessary, but I would prefer a "quick and dirty" way Smile
Re: Background color of StaticText or EditString [message #54805 is a reply to message #54801] Thu, 17 September 2020 13:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
aquilarubra wrote on Thu, 17 September 2020 11:20
Hi, how can I set a background color for StaticText or EditString?

I don't know if Chamaleon is necessary, but I would prefer a "quick and dirty" way Smile


EditString: Probably best option is to use NoBackground and put the StaticRect widget behind.

StaticText: Similar, but use Transparent instead of NoBackground.
Re: Background color of StaticText or EditString [message #54806 is a reply to message #54805] Thu, 17 September 2020 14:24 Go to previous messageGo to next message
aquilarubra is currently offline  aquilarubra
Messages: 23
Registered: December 2019
Promising Member
Using layouts, I seem unable to add a widget (StaticRect) from code.

Even a button doesn't show up, whether I put it into the constructor or a click event:
Button button;
*this << button.SetLabel("Button").LeftPosZ(10, 64).TopPosZ(10, 24);

I suspect the layout hides everything under itself. Any way to do that?
Re: Background color of StaticText or EditString [message #54807 is a reply to message #54806] Thu, 17 September 2020 14:40 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello aquilarubra,


Quote:
Using layouts, I seem unable to add a widget (StaticRect) from code.

Even a button doesn't show up, whether I put it into the constructor or a click event:
Button button;
*this << button.SetLabel("Button").LeftPosZ(10, 64).TopPosZ(10, 24);

I suspect the layout hides everything under itself. Any way to do that?



1) StaticRect is not predefined in Layout manager. You have to add it as a "User class" (it is in the context menu).
Just set the CtrlType to StaticRect.

2) Order is important. StaticRect should come first, then StaticText on the ctrl list in the layout editor.

I have attached an example. It sets a backround rectangle and overlays a static text over it.

Best regards,
Oblivion

  • Attachment: TestApp.zip
    (Size: 1.46KB, Downloaded 139 times)


Re: Background color of StaticText or EditString [message #54808 is a reply to message #54807] Thu, 17 September 2020 16:37 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Mirek and Oblivion,

Simple question - why do not add support for StaticRect to the CtrlLib.usc? Typing it every-time you want to use it seems to be too complected. The same is true for other controls like ParentCtrl, ImageCtrl, Picture (should be renamed to PictureCtrl) etc.. The more controls we have the more things non advanced user can do there. Even for advanced user it is simpler to select it from list...

Also, analyzing this situation I think the nice improvement would be if we manage to display documentation from the tpp in LayoutDesign. It will display what Ctrl supposed to do. In context of StaticRect it might not be obvious.

Klugier


U++ - one framework to rule them all.

[Updated on: Thu, 17 September 2020 16:44]

Report message to a moderator

Re: Background color of StaticText or EditString [message #54809 is a reply to message #54808] Thu, 17 September 2020 16:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Klugier wrote on Thu, 17 September 2020 16:37
Hello Mirek and Oblivion,

Simple question - why do not add support for StaticRect to the CtrlLib.usc? Typing it every-time you want to use it seems to be too complected. The same is true for other controls like ParentCtrl, ImageCtrl, Picture (should be renamed to PictureCtrl) etc.. The more controls we have the more things non advanced user can do there. Even for advanced user it is simpler to select it from list...


You are right. Will do.

Quote:

Also, analyzing this situation I think the nice improvement would be if we manage to display documentation from the tpp in LayoutDesign. It will display what Ctrl supposed to do. In context of StaticRect it might not be obvious.

Klugier


That is a good idea, but one that will take some effort to implement.

Mirek
Re: Background color of StaticText or EditString [message #54810 is a reply to message #54809] Thu, 17 September 2020 17:01 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Quote:
Also, analyzing this situation I think the nice improvement would be if we manage to display documentation from the tpp in LayoutDesign. It will display what Ctrl supposed to do. In context of StaticRect it might not be obvious.


Quote:
That is a good idea, but one that will take some effort to implement.



This is something I truly miss in TheIDE. My suggestion: At least the API docs should be accessible in split panes.

Best regards,
Oblivion


[Updated on: Thu, 17 September 2020 17:02]

Report message to a moderator

Re: Background color of StaticText or EditString [message #54811 is a reply to message #54810] Thu, 17 September 2020 17:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Thu, 17 September 2020 17:01
Quote:
Also, analyzing this situation I think the nice improvement would be if we manage to display documentation from the tpp in LayoutDesign. It will display what Ctrl supposed to do. In context of StaticRect it might not be obvious.


Quote:
That is a good idea, but one that will take some effort to implement.



This is something I truly miss in TheIDE. My suggestion: At least the API docs should be accessible in split panes.

Best regards,
Oblivion


Actually to have one specialized pane with docs could be cool...

I would say another tab in bottom areay would do, but it would be better it was more vertical for more info. But maybe I can display two columns there (column-list style...)

Either way, not in 2020.2....
Re: Background color of StaticText or EditString [message #54812 is a reply to message #54809] Thu, 17 September 2020 19:12 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
By the way,

I'd already proposed a modified ctrlib layout file with ColumnList and FileList, some time ago:

index.php?t=getfile&id=6206&private=0

If it is ok, I can re-send the patched usc file in a couple of days, along with StaticRect, etc....
  • Attachment: layout.png
    (Size: 60.20KB, Downloaded 303 times)


[Updated on: Thu, 17 September 2020 19:13]

Report message to a moderator

Re: Background color of StaticText or EditString [message #54813 is a reply to message #54812] Thu, 17 September 2020 19:44 Go to previous messageGo to next message
aquilarubra is currently offline  aquilarubra
Messages: 23
Registered: December 2019
Promising Member
Wonderful, got it working, thank you.

Sorry for my very basic questions. Using the StaticText, I can add text to it, but it has always a centered vertical alignment.
.AlignTop() seems ignored.
Is there a way to set vertical alignment?
Re: Background color of StaticText or EditString [message #54814 is a reply to message #54813] Thu, 17 September 2020 20:17 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Quote:
Is there a way to set vertical alignment?


Not unless you use a PaintRect (or override the Paint method) and draw the text/background yourself.

If you need full control over the style and position of text, I'd suggest using RichTextCtrl instead. It displays text/richtext with formatting (even hyperlinks) and supports background colors.

Best regards,
Oblivion


Previous Topic: Changing mouse icon with MouseEvent
Next Topic: Add Button crashes program on start
Goto Forum:
  


Current Time: Thu Mar 28 20:22:24 CET 2024

Total time taken to generate the page: 0.01777 seconds