Hi,
I am new to wxwindows (I come from Java),
I need to create a complex button, I mean a button which can have several lines, this line containing different kind of objects, for exemple:-
- 1st line: an icon on the left + text on the right
-2nd line: Text in bold + specific color
-3rd line: text (font1) on the left, text font2 on the middel, and another text on the right.
I already developed this kind of button under Java, it was easy because in Java a button contain a Panel, and in a Panel you can do what ever you want (using a specific layout, insert child panels, etc...)
I am shure this can be possible, but I dont know how !
Thanks for your help !
Bart
[wxwidgets] create a complex button
-
- Knows some wx things
- Posts: 31
- Joined: Fri Sep 10, 2004 1:03 pm
- Location: Troy, NY
- Contact:
Re: [wxwidgets] create a complex button
Take a look at the implementation for wxBitmapButton...it is a custom button derived from wxButton. Theoretically you can derive from wxButton and have your own custom control.
CKO
CKO
baert wrote:I need to create a complex button, I mean a button which can have several lines, this line containing different kind of objects, for exemple:-
- 1st line: an icon on the left + text on the right
-2nd line: Text in bold + specific color
-3rd line: text (font1) on the left, text font2 on the middel, and another text on the right.
I already developed this kind of button under Java, it was easy because in Java a button contain a Panel, and in a Panel you can do what ever you want (using a specific layout, insert child panels, etc...)
-
- Knows some wx things
- Posts: 31
- Joined: Fri Sep 10, 2004 1:03 pm
- Location: Troy, NY
- Contact:
Right. What I meant was that you could use wxBitmapButton as a means to better understanding how to do this. And the bitmaps and text on buttons can be changed dynamically now. No modification needed.
baert wrote:Thanks for your help,
The probleme in my case is that Data are dynamic: I can't put all the data in a fixed bitmap, and display the bitmap.
Text ad Icon on the buttons are dynamic, they can automatially change due to some events.
-
- Knows some wx things
- Posts: 31
- Joined: Fri Sep 10, 2004 1:03 pm
- Location: Troy, NY
- Contact:
Yeah...I was also thinking...baert wrote:you mean, I should look at the implementation of wxBitmapButton ?
I'll try thiis and let you know what I can learn with that !
wxButton is a wxWindow, which you can place new elements into. So you could (I think) add a sizer and sub-elements to a wxButton. Should work just fine.
CKO
You have to understand where wxWidgets is built on. The wxButton, wxTextCtrl etc are all native components. Which means the wxButton is a wrapper .. since it is a native control you can't really insert something inside a button like a panel or a sizer because the button in Windows cannot be treated that way as well ..
If you want this, you will have to compose your own button from a panel and sizer, and make it look like a button by catching mouse up and down events..
Regards,
- Jorgen
If you want this, you will have to compose your own button from a panel and sizer, and make it look like a button by catching mouse up and down events..
Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Question, then why is it derived from wxWindow then? Shouldn't a correct way it to derive it only from wxControl (which is derived from wxObject and wxEventHandler)? Surely, the wxControl class would also need to contain more generic methods like Show(), Hide(), Enable(), Disable(), and so on...Jorg wrote:You have to understand where wxWidgets is built on. The wxButton, wxTextCtrl etc are all native components. Which means the wxButton is a wrapper .. since it is a native control you can't really insert something inside a button like a panel or a sizer because the button in Windows cannot be treated that way as well ..
If you want this, you will have to compose your own button from a panel and sizer, and make it look like a button by catching mouse up and down events..
Regards,
- Jorgen
I guess because it does implement some of the wxWindow based methods like sizing etc. Also, there is one base class needed to add all those elements to a panel or frame. It might have been given some more consideration, but hey MFC also did it like this. CButton was in no way extendible when it was in fact a wrapped control like al wxButton would be
I guess it is common sense for most people who know that the wxButton is a native component, and thus cannot be extended. But I can understand the confusion. Maybe they should at least perform checks in debug mode if people are trying to do "the impossible"
Regards,
- Jorgen
I guess it is common sense for most people who know that the wxButton is a native component, and thus cannot be extended. But I can understand the confusion. Maybe they should at least perform checks in debug mode if people are trying to do "the impossible"
Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb