Page 1 of 1

wxBitmapCheckBox and wxBitmapRadioButton

Posted: Sun Aug 07, 2005 8:53 am
by Ugly!
Hi!!! well, i finish this two classes. I m actually a newbie and these are the fisrt components that i ve ever wrote, so please if you think that something is wrong or there can be improvements (which i m sure there must be) let me know.
I hope this can help somebody, as for the utilty of he clases or as model to create components with custom events (that was the hardest part to get for me).

So thnx to this greate forum, and again, critisize all u think, it would really help me.

Posted: Sun Aug 07, 2005 9:07 am
by Ugly!
Here are the codes:....

Code: Select all

/////////////////////////////////////////////////////////////////////////////
// Name:        BitmapCheckBox.h
// Author:     Mat

Posted: Sun Aug 07, 2005 3:49 pm
by bobmanc
Graphically it is working great but I can't get the EVT_BMPRADIOBUTTON code to compile. What should that look like? Also is there a way to specify a range like in EVT_MENU_RANGE?

Thanks a lot.

Posted: Sun Aug 07, 2005 7:56 pm
by Ugly!
bobmanc wrote:Graphically it is working great but I can't get the EVT_BMPRADIOBUTTON code to compile. What should that look like? Also is there a way to specify a range like in EVT_MENU_RANGE?

Thanks a lot.
Please post the compiler errors for the EVT_BMPRADIOBUTTON and what compiler r you using? what version of wxwidgets? platform???
(I had no problem using vc++ 6.0 with wxwidgets 2.6.1 and wx-devcpp 6.7, i have not tried in linux because my linux boxis not working right now)

About EVT_MENU_RANGE i think it could be implemented easely so i ll do it sometime tonight or tomorrow, or you can try to implemented ur self and post the code here.

Regards...

Posted: Fri Aug 12, 2005 12:26 pm
by bobmanc
I got it. I just needed this.

EVT_BMPRADIOBUTTON(IDM_TOOLBAR_TOGGLERADIOBTN1,MyFrame::OnBtn)

void MyFrame::OnBtn(wxBmpRadioButtonEvent& event)
{
//do something here
}

Posted: Fri Aug 12, 2005 12:29 pm
by bobmanc
I ran Boundschecker on it and added this line to stop a memory leak.

wxBitmapRadioGroup::~wxBitmapRadioGroup(){
while(group->GetCount()>0)
group->RemoveAt(0);
delete group; //<===== added this line
}

It also complains about this line. Don't know what to do about that though.

WX_DEFINE_ARRAY(wxBitmapRadioButton *,radioArray);

C:\projects\BitmapRadioButton.h(51) : warning C4284: return type for 'radioArray::reverse_iterator::operator ->' is 'class wxBitmapRadioButton ** ' (ie; not a UDT or referenc
e to a UDT. Will produce errors if applied using infix notation)

Posted: Fri Aug 12, 2005 1:17 pm
by Ugly!
THNX FOR THE FEEDBACK, i corrected that memory leak.
bobmanc wrote: It also complains about this line. Don't know what to do about that though.
WX_DEFINE_ARRAY(wxBitmapRadioButton *,radioArray);

C:\projects\BitmapRadioButton.h(51) : warning C4284: return type for 'radioArray::reverse_iterator::operator ->' is 'class wxBitmapRadioButton ** ' (ie; not a UDT or referenc
e to a UDT. Will produce errors if applied using infix notation)
I think this is just a warning, nothing big.

Posted: Fri Aug 12, 2005 1:46 pm
by Ugly!
The code was edited. Fix some bugs. It s posted above.
Regards...

Posted: Wed Jun 27, 2007 9:07 am
by bcteh
Hi ,

I try to compile the BitmapCheckBox, but it hit the below error.
Can you help ?

I am using wxWidget 2.8.3 on MS Studio 8 on window XP.

Regards
Teh
1>Compiling...
1>bitmapcheckbox.cpp
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2143: syntax error : missing ')' before ','
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2373: 'wxEVT_BMPCHECKBOX_CLICKED' : redefinition; different type modifiers
1> c:\dev\cafesql\gui\bitmapcheckbox.h(102) : see declaration of 'wxEVT_BMPCHECKBOX_CLICKED'
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2512: 'wxEventTableEntry' : no appropriate default constructor available
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2512: 'wxEventTableEntry' : no appropriate default constructor available
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2059: syntax error : '-'
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2017: illegal escape sequence
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2017: illegal escape sequence
1>c:\dev\cafesql\gui\bitmapcheckbox.h(109) : error C2059: syntax error : ')'
1>c:\dev\cafesql\gui\bitmapcheckbox.cpp(17) : error C2143: syntax error : missing ';' before '{'
1>c:\dev\cafesql\gui\bitmapcheckbox.cpp(17) : error C2447: '{' : missing function header (old-style formal list?)

Events?

Posted: Thu Feb 07, 2008 1:27 pm
by sNapik
Hi I tryed this to get working but I got this linker error:
Linking executable: bin\button.exe
obj\buttonMain.o: In function `Z41__static_initialization_and_destruction_0ii':E:/pokus/button/buttonMain.cpp:56: undefined reference to `buttonFrame::OnCheck(wxBmpCheckBoxEvent&)'
collect2: ld returned 1 exit status

Using wxWidgets 2.8 on winXP.

Code: Select all

BEGIN_EVENT_TABLE(buttonFrame, wxFrame)
    EVT_CLOSE(buttonFrame::OnClose)
    EVT_MENU(idMenuQuit, buttonFrame::OnQuit)
    EVT_MENU(idMenuAbout, buttonFrame::OnAbout)

    EVT_BMPCHECKBOX(1010,buttonFrame::OnCheck)
    //EVT_BMPRADIOBUTTON(1011,buttonFrame::radioChanged1)
    //EVT_BMPRADIOBUTTON(1012,buttonFrame::radioChanged2)
END_EVENT_TABLE()

Code: Select all

wxBitmap bsrc1 = wxBitmap(wxT("src1"),wxBITMAP_TYPE_BMP_RESOURCE);
        wxBitmap bsrc2 = wxBitmap(wxT("src2"),wxBITMAP_TYPE_BMP_RESOURCE);
        btn1=new wxBitmapCheckBox(this,1010,&bsrc1,&bsrc2,PUSH_LIKE,wxPoint(170,160));

Code: Select all

void OnCheck(wxBmpCheckBoxEvent& event){

}
Thanks for any tips.. This component looks ideal for my solution and I really want to get it working.

Posted: Thu Jul 24, 2008 12:40 pm
by guyothomas
Hello all, I got a question not very specific to this topic but that is however in some way related.

I used some instances of wxBitmapCheckBox class in my design and I created them with the wxDefaultPosition parameter.
I add it a bit later in a sizer (in the fane Frame of my app), and then Layout() the sizer.
The result of this is at the launching of the app my bitmap drawn at position (0,0) and staying there untill I click on the checkBox. If I create it with the position (3000,2000), there's still a hole on my window at the CheckBox' position in the sizer.

If someone has an idea or a trick I didn't see to solve this.. I'd be glad!
Thanks,
Tom.

Re: wxBitmapCheckBox and wxBitmapRadioButton

Posted: Thu Apr 24, 2014 9:20 pm
by meltahaw
Hi,
Please I am working with wxGTK3.0.0 and I would like to use wxBitmapCheckBox, can you please send me the code ?

Thanks
Mahmoud