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 » Change images
Change images [message #35580] Thu, 01 March 2012 11:56 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member

I wanna try to change images when fields got focus...
what the best way?
ChildGotFocus() can be the right solutions ?

Regards, Matteo
Re: Change images [message #35582 is a reply to message #35580] Thu, 01 March 2012 13:04 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Matteo

Please clarify a little bit what image control do you refer and what field get focus.


Best regards
Iñaki
Re: Change images [message #35585 is a reply to message #35580] Thu, 01 March 2012 14:19 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member

Here my little app...

void Scala::Paint(Draw& w)
{
	w.DrawRect(GetSize(),SColorFace());
	w.DrawImage(180, 125, 200, 180, Images::Scala());
	//w.DrawImage(180, 125, 200, 180, Images::Logo());
}


The image I was speaking about is Images::Scala().
I would like to change it when user get focus on this fields:

alzataEdit
deltaEdit
altezzaEdit
pedataEdit

Thanks,
Matteo

  • Attachment: Scala.rar
    (Size: 49.16KB, Downloaded 193 times)
Re: Change images [message #35587 is a reply to message #35585] Thu, 01 March 2012 21:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Matteo

A way could be to do a new class like this:
class MyEditString : public EditString {
public:
	MyEditString(Scala &scala) : scala(scala)  {}
	virtual void GotFocus() {
		// Change image of scala
	}
private:
	Scala *scala;
};



Best regards
Iñaki
Re: Change images [message #35590 is a reply to message #35580] Fri, 02 March 2012 14:09 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member
Thank you cold for ur reply. I cant understand the meaning of
MyEditString(Scala &scala) : scala(scala)  {}  :( 

I need to use Paint(Draw& w) to add the new image? So I have to make it member of the new class ?

Maybe can I find an example into Bazar ?!

Sorry for my stupid questions...

Matteo

[Updated on: Fri, 02 March 2012 14:14]

Report message to a moderator

Re: Change images [message #35591 is a reply to message #35590] Fri, 02 March 2012 15:56 Go to previous messageGo to next message
unknown user
Hi Matteo,

Koldo solution was to create a new class which inherit from EditString (or class you use, EditDouble for example) and pass to it's constructor a reference to your Scala class and from GotFocus method of that class to notify Scala instance that it should change the image.

Another solution would be to notify your Scala instance using callbacks.

After using namespace Upp; and before #define LAYOUTFILE <Scala/Scala.lay> add following code.
class EditDoubleSpinMod : public EditDoubleSpin {
public:
	Callback WhenFocus;
	virtual void GotFocus()
	{
		WhenFocus();
	}
};

class EditDoubleMod : public EditDouble {
public:
	Callback WhenFocus;
	virtual void GotFocus()
	{
		WhenFocus();
	}
};


In Scala class (private section) add:
Image img;
	
void changeImage()
{
	img = Images::Scala();
	Refresh();
}


In Scala constructor add:
img = Images::Logo();
alzataEdit.WhenFocus = THISBACK(changeImage);
deltaEdit.WhenFocus = THISBACK(changeImage);
altezzaEdit.WhenFocus = THISBACK(changeImage);
pedataEdit.WhenFocus = THISBACK(changeImage);


Modify Scala::Paint like:
void Scala::Paint(Draw& w)
{
	w.DrawRect(GetSize(),SColorFace());
	w.DrawImage(180, 125, 200, 180, img);
	//w.DrawImage(180, 125, 200, 180, Images::Logo());
}


In layout file make alzataEdit, deltaEdit, pedataEdit to use EditDoubleSpinMod and pedataEdit EditDoubleMod.

Initial image would be Images::Logo() because we added in constructor img = Images::Logo();, change it to whatever you want. When one of specified controls got focus chageImage will be called and image would be changed to Images::Scala().
Now your constructor set focus on one of modified control, so your Images::Scala() will get displayed without you being able to see that initially Images::Logo() was displayed. Change in constructor ActiveFocus to pendenza control or other not modified.

Best regards,
Andrei

[Updated on: Fri, 02 March 2012 16:03] by Moderator

Report message to a moderator

Re: Change images [message #35592 is a reply to message #35591] Fri, 02 March 2012 16:00 Go to previous messageGo to next message
unknown user
P.S.: Please use zip, 7z format for archives instead of rar.
Thank you.
Re: Change images [message #35593 is a reply to message #35580] Fri, 02 March 2012 17:14 Go to previous message
idkfa46 is currently offline  idkfa46
Messages: 155
Registered: December 2011
Experienced Member

Oh... realy thanks !
I understood so many interesting things today Very Happy

Matteo
Previous Topic: Using TheIDE/U++ and Visual Studio 2008/2010 IDE as a team in a project
Next Topic: Key pressing with MINGW and Windows XP does not work
Goto Forum:
  


Current Time: Tue Apr 23 16:55:56 CEST 2024

Total time taken to generate the page: 0.02507 seconds