Can menus in wxMenuBar have icons/images? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Can menus in wxMenuBar have icons/images?

Post by rakeshthp » Tue Jul 17, 2012 4:36 am

Hello,

Is there any method, to get menus with corresponding icons/images on the left of the menu label? Just as it appears in visual studio. I have attached a sample file for your reference.

Thanks

Regards
Rakesh Patil
Attachments
1052-01.png
1052-01.png (24.76 KiB) Viewed 3041 times

Dummy
Earned some good credits
Earned some good credits
Posts: 119
Joined: Tue May 10, 2005 10:29 am

Re: Can menus in wxMenuBar have icons/images?

Post by Dummy » Tue Jul 17, 2012 4:47 am

Hi,

wxMenuItem::SetBitmap(...) should do what you want.

rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Re: Can menus in wxMenuBar have icons/images?

Post by rakeshthp » Tue Jul 17, 2012 6:23 am

Hi Dummy,

Sorry for not being more specific about my question. I have used that function to get icons, but I just wanted to know is it possible to get a strip on the left hand side as shown in image? Please note the seperator line, from where it starts and from where it ends( both in image and in wxWidget one).

So is it possible to get this look and feel?


Thanks

Regards

User avatar
bishop.gis
Earned a small fee
Earned a small fee
Posts: 20
Joined: Fri May 25, 2012 6:47 pm

Re: Can menus in wxMenuBar have icons/images?

Post by bishop.gis » Tue Jul 17, 2012 7:39 am

I have such look of wxmenu under Windows 7. Is is close to you expectation?
wxmenu.png
wxmenu.png (25.19 KiB) Viewed 3030 times
Also, under Ubuntu there are no icons at all :(

rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Re: Can menus in wxMenuBar have icons/images?

Post by rakeshthp » Tue Jul 17, 2012 10:49 am

Yes. That's how I wanted. How did you get it? Is it the same code or any you wrote your own class?

Regards

ptDev
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Nov 27, 2009 4:24 pm

Re: Can menus in wxMenuBar have icons/images?

Post by ptDev » Tue Jul 17, 2012 1:26 pm

rakeshthp wrote:Hi Dummy,

Sorry for not being more specific about my question. I have used that function to get icons, but I just wanted to know is it possible to get a strip on the left hand side as shown in image? Please note the seperator line, from where it starts and from where it ends( both in image and in wxWidget one).

So is it possible to get this look and feel?


Thanks

Regards
For this exact look and feel (Office 2003 style), you can try wxFlatMenu. Try reading this thread.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2676
Joined: Sun Jan 03, 2010 5:45 pm

Re: Can menus in wxMenuBar have icons/images?

Post by PB » Tue Jul 17, 2012 7:23 pm

This is how menu looks in menu sample bundled with wxWidgets 2.9.4, so I doubt you have to use an external component to achieve that look. In 2.8, the vertical line is not there. AFAIK wxWidgets 2.9 are considered production ready (it is not considered stable as in "API is frozen").
Attachments
wxmenu.png
wxmenu.png (19.95 KiB) Viewed 3002 times

ptDev
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Nov 27, 2009 4:24 pm

Re: Can menus in wxMenuBar have icons/images?

Post by ptDev » Wed Jul 18, 2012 3:18 pm

The screenshot you are showing is an example of the default native menu look.
That is not the menu style that is shown in the original post.

In either case, icons are always supported.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2676
Joined: Sun Jan 03, 2010 5:45 pm

Re: Can menus in wxMenuBar have icons/images?

Post by PB » Wed Jul 18, 2012 3:43 pm

ptDev wrote:The screenshot you are showing is an example of the default native menu look.
That is not the menu style that is shown in the original post.
Nevertheless, it matches the menu look displayed in the bishop.gis' post, to which the OP replied "Yes. That's how I wanted. How did you get it? Is it the same code or any you wrote your own class?" :wink:

rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Re: Can menus in wxMenuBar have icons/images?

Post by rakeshthp » Thu Jul 19, 2012 11:18 am

Hi,

Well, it would be nice if it is possible to get the same effect as it is shown in original post. But something is better than nothing, so I compromised with bishop.gi's output. Well, I tried with 2.9.4 version. I am not getting like the one shown by PB.

And the links in the thread which ptDev gave reference, are broken links. None opens properly. Even after googling for wxFlatMenu, I wasn't able to find a proper link to download it. When will it be added to the main trunk of wxWidgets?

Thanks & Regards

ptDev
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Nov 27, 2009 4:24 pm

Re: Can menus in wxMenuBar have icons/images?

Post by ptDev » Thu Jul 19, 2012 11:35 am

rakeshthp wrote:Hi,
Well, it would be nice if it is possible to get the same effect as it is shown in original post. But something is better than nothing, so I compromised with bishop.gi's output. Well, I tried with 2.9.4 version. I am not getting like the one shown by PB.


Note that it will look like this under Windows 7, not XP.
And the links in the thread which ptDev gave reference, are broken links. None opens properly. Even after googling for wxFlatMenu, I wasn't able to find a proper link to download it. When will it be added to the main trunk of wxWidgets?
If you dig a little deeper in that thread, you will find this link: http://codelite.org/download/wxflatmenu-src.zip to the wxFlatMenu source, including a sample. You might need a bit of adapting before you get the demo app to build.

rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Re: Can menus in wxMenuBar have icons/images?

Post by rakeshthp » Fri Jul 20, 2012 5:15 am

Thanks ptDev. That one is excellent. :-)

Post Reply