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 » Look and Chameleon Technology » Does SetStyle needs a refresh ?
Does SetStyle needs a refresh ? [message #16752] Wed, 09 July 2008 20:44 Go to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Hi all,
I download today the latest version of Upp and I have to adapt my app code, basically on SetBkColor calls. Now, I thing we showld use the SetStyle. Well, In a form I want to change the bk of the edit field where the user enters text (OnChange event). I have this code:



void X::OnChangeEditBox(void) //Called from on change event
{
EditField * pEdit=dynamic_cast<EditField*> (GetLastCtrl());
edits=EditField::StyleDefault();
edits.paper=Yellow();
pEdit->SetStyle(edits);
}

Then when I try it I write text on the edit boxes but bkground only get yellow when the Edit box loose the focus and not while I write text to it.

Any help?

Thanks


Kim

[Updated on: Wed, 09 July 2008 21:43]

Report message to a moderator

Re: SetStyle needs a refresh ? [message #16753 is a reply to message #16752] Wed, 09 July 2008 21:13 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Also, If focus returns to the yellow backgrounf editfiled, its background is painted with the windows default color and the yellow color only appers when it looses focus again.
What I am doing in the wrong way?

With SetBkColor it worked very fine

Thank you

Kim
Re: SetStyle needs a refresh ? [message #16763 is a reply to message #16753] Thu, 10 July 2008 11:15 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
The EditField style has a different colour for focus/unfocused. It was actually me that added it so that I could do exactly what I think you are trying to do (highlight the currently focused EditField).

This has the advantage that you can set it for every EditField in your app with one line:
EditField::StyleDefault().Write().focus = Yellow();

But if you really want to only change the colour when a field has text in it then this works:
void CtrlLibTest::OnEdit(EditField *ctrl)
{
	static EditField::Style s = EditField::StyleDefault();
	s.focus = Yellow();
	ctrl->SetStyle(ctrl->GetLength() ? s : EditField::StyleDefault());
}

Incidentally, you can avoid the need for a dynamic cast by setting the callback to this function with the ctrl as a parameter:
edit1 <<= THISBACK1(OnEdit, &edit1);
edit2 <<= THISBACK1(OnEdit, &edit2);
...etc


Hope that helps!

[Updated on: Thu, 10 July 2008 11:31]

Report message to a moderator

Re: Does SetStyle needs a refresh ? [message #16764 is a reply to message #16752] Thu, 10 July 2008 12:15 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Hi, I just want to show to the user that he or she has changed the contents of a form and it need to be saved. So I want to paint edit boxes with yellow color when it contents has changed and after pushing save button I want to paint them with the default windows xp color for the background.

By using the SetStyle method I saw two problems:
1. When user is typing text the backgound remains with the default color and not yellow. Only When loose focus occurs it is painted with yellow color. What I want if "real-time Smile " painting while user is typing and not only when lost focus happens.

2. Suppose a form with 2 edit boxes. I type text on the first and it doesnt changed the color (see 1.). When I pass focus to the second edit it becomes yellow. But If I put focus on the first edit box again it is painted with default color again while editing. It seems that while the focus is in the widget no backcolor is applied.



I liked this (your) code to avoid cast Wink
edit1 <<= THISBACK1(OnEdit, &edit1);
edit2 <<= THISBACK1(OnEdit, &edit2);






Sorry, If your source code and ideas solve this, but only at night I can try it on the other computer. This one still has the 2007 version of Upp.

Thanks

Kim


[Updated on: Thu, 10 July 2008 12:17]

Report message to a moderator

Re: Does SetStyle needs a refresh ? [message #16766 is a reply to message #16764] Thu, 10 July 2008 12:27 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I obviously wasn't very clear Smile. The basic problem was that you were stting Style::paper, if you set Style::focus instead/as well it will work.
Re: Does SetStyle needs a refresh ? [message #16777 is a reply to message #16766] Fri, 11 July 2008 00:45 Go to previous message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Ok, understood! Wink

Kim
Previous Topic: Global style changes using Chameleon...
Next Topic: Menu look correction for Vista
Goto Forum:
  


Current Time: Thu Apr 25 04:02:53 CEST 2019

Total time taken to generate the page: 0.01348 seconds