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
Re: Change images [message #35591 is a reply to message #35590] Fri, 02 March 2012 15:56 Go to previous messageGo to previous 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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Sun Aug 24 10:47:52 CEST 2025

Total time taken to generate the page: 0.04400 seconds