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 to modify the back colour of a Static Text
How to modify the back colour of a Static Text [message #27202] Thu, 01 July 2010 21:38 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Hi,

A simple question: how to modify the back colour of a Static Text? I am unable to find it in the manual.

Thanks,

Javier
Re: How to modify the back colour of a Static Text [message #27203 is a reply to message #27202] Thu, 01 July 2010 21:46 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I don't think it has a back-color. It's easy enough to inherit from it and draw a backcolor yourself and then call StaticText::Paint. Just remember to set Transparent(false) too.
Re: How to modify the back colour of a Static Text [message #27210 is a reply to message #27203] Fri, 02 July 2010 20:05 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
I am sorry: I am unable to understand your example. Would you mind explaining it with more details?

An additional question: how a virtual function of this sort

virtual void MouseMove(Point p, dword keyflags)

can be invoked for a widget placed in a TopWindow ( in other words, how the function can be re written when, for instance, the mouse hovers above a button placed in a widget?).

Thanks,

Javier
Re: How to modify the back colour of a Static Text [message #27281 is a reply to message #27210] Sat, 10 July 2010 21:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello Javier

Imagine you want to do an special Label control (an static text) with custom background and with some behavior when the mouse moves over it.

It could be more or less like this (I have not tested it Smile):

class MyCtrl : public Label {
typedef MyCtrl CLASSNAME;	 
public:
	virtual void Paint(Draw& draw) {
		Size sz = GetSize();
		w.DrawRect(0, 0, sz.cx, sz.cy);
	
		Label::Paint(w);
	}
	virtual void MouseMove(Point p, dword keyflags) {
		do here what you want
	}
	
public:
	Color background;

	MyCtrl& SetBackground(Color c) {background = c; Refresh(); return *this;}
	
	MyCtrl() {
		Transparent();
		NoWantFocus();

		background = Null;
	}
};




Best regards
Iñaki
Re: How to modify the back colour of a Static Text [message #27286 is a reply to message #27281] Sun, 11 July 2010 02:12 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Or simple - Add StaticRect behind of StaticText.

StaticRect has Color() member. Use it.

dlg.txt = t_("You do not have any choice. Select the appropriate job and click OK."); //set text of foreground control
dlg.txt.SetInk(White()).SetFont(StdFont().Bold()); //set color of foreground control
dlg.txt_back.Color(LtRed()); //set color of background control.


Razz

PS
Text version of my .lay file.
LAYOUT(PositionSelectLayout, 480, 288)
	ITEM(StaticRect, txt_back, HSizePosZ(16, 16).TopPosZ(16, 23))
	ITEM(StaticText, txt, SetAlign(ALIGN_CENTER).HSizePosZ(16, 16).TopPosZ(16, 23))
	ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(136, -84).BottomPosZ(16, 48))
	ITEM(Button, cancelimport, SetLabel(t_("Stop import")).HCenterPosZ(136, 84).BottomPosZ(16, 48))
END_LAYOUT



SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: How to modify the back colour of a Static Text [message #27298 is a reply to message #27281] Sun, 11 July 2010 13:59 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Thanks, very useful.

Javier
Re: How to modify the back colour of a Static Text [message #27304 is a reply to message #27298] Sun, 11 July 2010 17:10 Go to previous message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Additional questions:

1.-How can I show the cursor’s coordinates in two labels located in the TopWindow, not within the "custom" widget?.
2.- If I derive the class from Ctrl class, then it works fine (i.e. it shows mouse’s coordinates WITHIN itself). However, I derive the class from either Label or StaticRect, it doesn’t work. Why?.

Thanks chaps,

Javier
Previous Topic: guides and tutorials for a absolute beginner?
Next Topic: What is the difference between Splitter and SplitterFrame?
Goto Forum:
  


Current Time: Thu Mar 28 10:51:14 CET 2024

Total time taken to generate the page: 0.01135 seconds