Hi Team,
I am using wxWidgets 3.0.2 for my application which works on Windows and MAC. I have a problem in using SetLabel function for wxBitmapButton control. For supporting automation of my application, I need to set label to each and every control. For other controls it works fine but for wxBitmapButton when I set the label, it shows the label string on the button by overriding the bitmap which is not we are expecting. On Windows it work fine but on MAC I face this issue.
Since my bitmap buttons are actually using bitmaps which are proper images, any string overriding it looks bad. On Windows I am able to set the labels without getting it shown on the controls but on MAC I am having this issue. Please help me to resolve it or provide me other alternative (if any) to setlabels without showing it.
Following is the code where I am creating the button and setting the labels which is very simple :
wxBitmap bmp;
bmp = *( m_lptoolBarBitmaps[ BITMAPID_PREV ] );
wxBitmapButton *goPrevButton = new wxBitmapButton( bottomToolBackgroundPanel, ID_VEDIT_PREVSURFACE, bmp, wxDefaultPosition,
wxDefaultSize, wxBORDER_NONE );
goPrevButton->SetBackgroundColour(bottomToolBackgroundPanel->GetBackgroundColour());
goPrevButton->SetBitmapCurrent( bmp );
goPrevButton->SetBitmapDisabled( *( m_lptoolBarBitmaps[ BITMAPID_PREV + 1 ] ) );
goPrevButton->SetBitmapHover( *( m_lptoolBarBitmaps[ BITMAPID_PREV + 2 ] ) );
goPrevButton->SetBitmapPressed( *( m_lptoolBarBitmaps[ BITMAPID_PREV + 3 ] ) );
goPrevButton->SetLabel(_("Previous Page"));
bottomToolInternalSizer->Add( goPrevButton, 0, wxALIGN_CENTER );
bottomToolInternalSizer->AddSpacer( 5 );
PFA the screenshot of the application window where the bitmap buttons are shown getting overridden with the set labels in black rectangles.
Thanks,
Vivek
SetLabel() on wxBitmapButton does not work as expected
Re: SetLabel() on wxBitmapButton does not work as expected
try it
Code: Select all
const wxBitmap bmpNormal = ...;
const wxBitmap bmpSelected = ...;
wxButton* pBtn = new wxButton(this, wxID_ANY, wxEmptyString,
wxDefaultPosition, bmpNormal.GetSize(), wxTRANSPARENT_WINDOW | wxBORDER_NONE);
pBtn->SetLabelText("YOUR LABEL");
pBtn->SetBitmap(bmpNormal);
pBtn->SetBitmapHover(bmpSelected);
pBtn->SetBitmapPressed(bmpSelected);
pBtn->SetBackgroundColour(GetBackgroundColour());
- xaviou
- Super wx Problem Solver
- Posts: 437
- Joined: Mon Aug 21, 2006 3:18 pm
- Location: Annecy - France
- Contact:
Re: SetLabel() on wxBitmapButton does not work as expected
Hi.
Did you try updating your sizers after changing the buttons labels ?
Regards
Xav'
Did you try updating your sizers after changing the buttons labels ?
Code: Select all
......
goPrevButton->SetLabel(_("Previous Page"));
bottomToolInternalSizer->Add( goPrevButton, 0, wxALIGN_CENTER );
bottomToolInternalSizer->AddSpacer( 5 );
bottomToolInternalSizer->Layout();
Xav'
My wxWidgets stuff web page : X@v's wxStuff