From: Daniel Gonzalez Date: Thu, 2 May 2013 13:49:19 +0000 (+0200) Subject: Feature #2006 Black Box for BitmapButtons X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cf8160d9789d30e75ed8c987bf821214cb7d8d27;p=bbtk.git Feature #2006 Black Box for BitmapButtons Change to show label and bitmapbutton --- diff --git a/packages/wx/src/bbwxBitmapButton.cxx b/packages/wx/src/bbwxBitmapButton.cxx index 652ac4f..d2aba47 100644 --- a/packages/wx/src/bbwxBitmapButton.cxx +++ b/packages/wx/src/bbwxBitmapButton.cxx @@ -99,25 +99,28 @@ namespace bbwx ) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), box(bx) { - + this->title = title; wxPanel* panel = this; sizer = new wxBoxSizer(wxHORIZONTAL); if(bitmap != NULL) { button = new wxBitmapButton(panel, -1, *bitmap, wxDefaultPosition, wxSize(bitmap->GetWidth(),bitmap->GetHeight())); - std::cout << "Size: " << bitmap->GetWidth() << " " << bitmap->GetHeight() << std::endl; + + sizer -> Add(button, 0, wxALL | wxALIGN_CENTER, 3); + sizer -> Add(new wxStaticText(panel,-1,title), 0, wxALL | wxALIGN_CENTER, 3); } else { button = new wxButton( panel, -1, title); + sizer -> Add(button,1,wxEXPAND | wxALL | wxALIGN_CENTER, 5); } Connect( button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &BitmapButtonWidget::OnClick ); - sizer -> Add(button,1,wxEXPAND | wxALL, 5); + panel -> SetSizer(sizer); sizer->Fit(panel); @@ -210,7 +213,7 @@ namespace bbwx if(bitmap != NULL) { wxPanel* panel = this; - sizer->Remove(0); + sizer->Clear(); button->Destroy(); button = new wxBitmapButton(panel, -1, *bitmap, wxDefaultPosition, wxSize(bitmap->GetWidth(),bitmap->GetHeight())); @@ -220,7 +223,8 @@ namespace bbwx (void (wxPanel::*)(wxEvent&)) &BitmapButtonWidget::OnClick ); - sizer->Add(button, 0, wxALL, 5); + sizer->Add(button, 0, wxALL | wxALIGN_CENTER, 3); + sizer -> Add(new wxStaticText(panel,-1,title), 0, wxALL | wxALIGN_CENTER, 3); sizer->RecalcSizes(); } } diff --git a/packages/wx/src/bbwxBitmapButton.h b/packages/wx/src/bbwxBitmapButton.h index a1bdb26..13d8da5 100644 --- a/packages/wx/src/bbwxBitmapButton.h +++ b/packages/wx/src/bbwxBitmapButton.h @@ -51,6 +51,7 @@ namespace bbwx BitmapButton* box; wxBoxSizer* sizer; wxButton * button; + wxString title; }; typedef std::vector colorVector;