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 » LineEdit, EditFields, DocEdit » Set color in lineedit widget
Set color in lineedit widget [message #9433] Mon, 07 May 2007 22:46 Go to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
I want to output some user-actions in my application like user logged in and so on...

Is the LineEdit the right widget for this?

If yes, how can i add text, set fontsize, fontcolor and backgroundcolor in LineEdit widget?

Sorry for those basic questions, i'm still very new to ultimate++ and do not understand some maybe well documented things in the manual.

Thanks.

Michael

[Updated on: Tue, 08 May 2007 10:45]

Report message to a moderator

Re: Set color in lineedit widget [message #9436 is a reply to message #9433] Tue, 08 May 2007 13:03 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
You can change the font using LineEdit::SetFont. Colors are set with LineEdit::SetColor. For example:
editctrl.SetFont(Font::ARIAL, 16);
editctrl.SetColor(INK_NORMAL, Blue());

The colours that can be set are defined in CtrlLib/TextEdit.h. It is not possible to set colours for individual lines.

James

[edit] added brace for code

[Updated on: Tue, 08 May 2007 13:18] by Moderator

Report message to a moderator

Re: Set color in lineedit widget [message #9437 is a reply to message #9433] Tue, 08 May 2007 13:18 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Hi James,

when i use this

editor.SetFont(Font::ARIAL, 16);
editor.SetColor(INK_NORMALž Blue());


i get these error:

G:\Entwicklung\UPP\prohibisZA\main.cpp: In constructor `prohibisZA::prohibisZA()':
G:\Entwicklung\UPP\prohibisZA\main.cpp:29: error: no matching function for call to `Upp::LineEdit::SetFont(Upp::Font::<anonymous enum>, in
	t)'
C:/Programme/UltimatePP/uppsrc/CtrlLib/TextEdit.h:311: note: candidates are: Upp::LineEdit& Upp::LineEdit::SetFont(Upp::Font)
G:\Entwicklung\UPP\prohibisZA\main.cpp:30: error: stray '\184' in program
G:\Entwicklung\UPP\prohibisZA\main.cpp:30: error: `INK_NORMAL' undeclared (first use this function)
G:\Entwicklung\UPP\prohibisZA\main.cpp:30: error: (Each undeclared identifier is reported only once for each function it appears in.)
prohibisZA: 1 file(s) built in (0:02.34), 2344 msecs / file, duration = 2375 msecs, parallelization 0%


Do i have to include somethings special to use font or color?

Michael
Re: Set color in lineedit widget [message #9438 is a reply to message #9437] Tue, 08 May 2007 13:19 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
after INK_NORMAL use a ','

Bas
Re: Set color in lineedit widget [message #9439 is a reply to message #9433] Tue, 08 May 2007 13:28 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
changed it but same 'undeclared error'.

G:\Entwicklung\UPP\prohibisZA\main.cpp: In constructor `prohibisZA::prohibisZA()':
G:\Entwicklung\UPP\prohibisZA\main.cpp:29: error: no matching function for call to `Upp::LineEdit::SetFont(Upp::Font::<anonymous enum>, in
	t)'
C:/Programme/UltimatePP/uppsrc/CtrlLib/TextEdit.h:311: note: candidates are: Upp::LineEdit& Upp::LineEdit::SetFont(Upp::Font)
G:\Entwicklung\UPP\prohibisZA\main.cpp:30: error: `INK_NORMAL' undeclared (first use this function)


is there anything special to include when using color or font?

and how can i add simple strings to this LineEdit Control?

Don't think i'm too lazy to read the manual, but i didn't get it there...

Michael

[Updated on: Tue, 08 May 2007 14:48]

Report message to a moderator

Re: Set color in lineedit widget [message #9443 is a reply to message #9439] Tue, 08 May 2007 16:19 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Embarassed My humble apologies, the code segment above contained some glaring errors. The correct code is:
editctrl.SetFont(Font(Font::ARIAL, 14));
editctrl.SetColor(LineEdit::INK_NORMAL, SBlue());

Serves me right for not compiling it myself.
Re: Set color in lineedit widget [message #9444 is a reply to message #9443] Tue, 08 May 2007 16:44 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Great, that works. But which values can be set as color? Blue(), Black() etc. Where is this defnied?

And besides this problem... It couldn't be that hard to add some simple String to this LineEdit Control. Yes, i can type some text into this control but i would like to add some string like this:

editor.Insert("A_Test");


What's the right method to insert a string into a LineEdit Control?

Michael
Re: Set color in lineedit widget [message #9445 is a reply to message #9444] Tue, 08 May 2007 16:50 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Use LineEdit::Insert to add lines. For instance:
editctrl.Insert(editctrl.GetLength(), "Some text\nSome More text\n")

Appends two lines to the end of the text.

There are two ways of find functions like these yourself that are much quicker than asking here or even using the manual:
- Typing the name of the class or an instantialion of it followed by :: or . (ie LineEdit::) brings up the autocomplete box with all the member functions for that class and allows filtering as you type.
- Query(Ctrl-Q) allows you to find functions, classes and enums very quickly. For instance, querying 'Blue' takes you straight to all the color definitions. Right clicking on a function gives the option to goto the definition/declaration.

James

[Updated on: Tue, 08 May 2007 16:59]

Report message to a moderator

Re: Set color in lineedit widget [message #9446 is a reply to message #9433] Tue, 08 May 2007 17:52 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Thank you, James.

This was very helpful.

Michael
Re: Set color in lineedit widget [message #9453 is a reply to message #9445] Tue, 08 May 2007 19:17 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12020
Registered: November 2005
Ultimate Member
mrjt wrote on Tue, 08 May 2007 10:50


- Query(Ctrl-Q) allows you to find functions, classes and enums very quickly. For instance, querying 'Blue' takes you straight to all the color definitions. Right clicking on a function gives the option to goto the definition/declaration.



You can also try Alt+J with cursor at "Blue".

Mirek
Re: Set color in lineedit widget [message #9884 is a reply to message #9443] Wed, 06 June 2007 13:04 Go to previous messageGo to next message
waxblood is currently offline  waxblood
Messages: 95
Registered: January 2007
Member
mrjt wrote on Tue, 08 May 2007 16:19

Embarassed My humble apologies, the code segment above contained some glaring errors. The correct code is:
editctrl.SetFont(Font(Font::ARIAL, 14));
editctrl.SetColor(LineEdit::INK_NORMAL, SBlue());

Serves me right for not compiling it myself.



SBlue() seems to be deprecated

extract from Draw.h
//DEPRECATED: TODO
Color SBlack();
Color SGray();
Color SLtGray();
Color SWhiteGray();
Color SWhite();
Color SRed();
Color SGreen();
Color SBrown();
Color SBlue();
Color SMagenta();
Color SCyan();
Color SYellow();
Color SLtRed();
Color SLtGreen();
Color SLtYellow();
Color SLtBlue();
Color SLtMagenta();
Color SLtCyan();
//END OF DEPRECATED


the right color names seem to be without the S in front of them
i.e. Blue() instead of SBlue()


Ciao,
David

[Updated on: Wed, 06 June 2007 13:05]

Report message to a moderator

Re: Set color in lineedit widget [message #9895 is a reply to message #9884] Wed, 06 June 2007 22:48 Go to previous message
mirek is currently offline  mirek
Messages: 12020
Registered: November 2005
Ultimate Member
Yes, SBlue was in fact *usually* blue color used to highlight menu items on host platform. All others S* were derived that way, the idea was that using such mapping colors, GUI would better react to color scheme changes.

However, over time, idea was found flawed, therefore they are now deprecated. You can use "direct" SColor* colors (e.g. SColorHighlight) to accomodate your widgets to host color scheme.
Previous Topic: LineEdit scroll to last line
Next Topic: EditIntCtrl callback?
Goto Forum:
  


Current Time: Fri Sep 20 03:14:51 CEST 2019

Total time taken to generate the page: 0.01819 seconds