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 » Menus&Toolbars » images as menu
images as menu [message #19486] Mon, 08 December 2008 00:09 Go to next message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
Hi,

attached you find my testpackage for images as menu item in the main bar

Is this a bug or just not wanted?

When I put the images in a submenu it works ..
but only with a String in the item ...

I only want to show the image, because all other information is redundant.

Reinhard


[Updated on: Mon, 08 December 2008 00:12]

Report message to a moderator

Re: images as menu [message #19494 is a reply to message #19486] Mon, 08 December 2008 16:56 Go to previous messageGo to next message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
sapiency wrote on Mon, 08 December 2008 00:09

Hi,

Is this a bug or just not wanted?




sorry ...
" Also, items without Image are automatically added to menus only and vice versa, items without text are added to toolbars only."

just read the documentation ...

reinhard
Re: images as menu [message #19495 is a reply to message #19494] Mon, 08 December 2008 17:31 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
If you only want a button (no submenu) you can do it quite easily.

First, you need a custom ctrl to display the image and respond correctly to mouse events:
struct ImageBtn : public ImageCtrl
{
        ImageBtn() 						{ IgnoreMouse(false); }
	virtual void LeftDown(Point p, dword keyflags) 		{ Action(); }
	virtual void MouseEnter(Point p, dword keyflags) 	{ Refresh(); }
	virtual void MouseLeave() 				{ Refresh(); }
	virtual void Paint(Draw& draw) { 
		if (HasMouse()) 
			draw.DrawRect(GetSize(), SColorHighlight());
		ImageCtrl::Paint(draw);
	}		
};

And then add instances of this to your MenuBar:
void basicWindow::MenuMain(Bar &bar){
	bar.Add("Menu", Image::Arrow(), THISBACK(SubMenu));
	
	imagebtn1.SetImage(MyImages::layout1());
	imagebtn1 <<= THISBACK(setLayout1);
	bar.Add(imagebtn1.Tip("Layout 1"), MyImages::layout1().GetSize());
	
	bar.Gap(4);

	imagebtn2.SetImage(MyImages::layout2());
	imagebtn2 <<= THISBACK(setLayout2);
	bar.Add(imagebtn2.Tip("Layout 2"), MyImages::layout2().GetSize());	
}

void basicWindow::SubMenu(Bar &bar)
{
	bar.Add("Item1", Callback());	
	bar.Add("Item2", Callback());
	bar.Add("Item3", Callback());
}
(I've also added a sub-menu to make the example clearer)

Hope that helps,
James

[Updated on: Mon, 08 December 2008 17:33]

Report message to a moderator

Re: images as menu [message #19497 is a reply to message #19495] Mon, 08 December 2008 21:46 Go to previous message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
mrjt wrote on Mon, 08 December 2008 17:31


(I've also added a sub-menu to make the example clearer)

Hope that helps,
James




THANKS!

That's a really good example.

regards

reinhard
Previous Topic: [not a bug] Menu isn`t drawn. NOGTK. FreeBSD/Fluxbox
Next Topic: DropList in Toolbar
Goto Forum:
  


Current Time: Fri Nov 15 03:30:59 CET 2019

Total time taken to generate the page: 0.01633 seconds