wxBitmapComboBox under OSX and wxComboBox under other platforms is used on Manipulation panel for coordinate space choice now.

+ Fix of warning on wxBitmap.SetWidth(): deleted meaningless from wxWidgets 3.0 code
This commit is contained in:
YuSanka 2021-01-20 17:34:25 +01:00
parent 6d7d482ca1
commit 59017a7dae
3 changed files with 17 additions and 44 deletions

View File

@ -888,6 +888,7 @@ void SpinCtrl::msw_rescale()
}
#ifdef __WXOSX__
static_assert(wxMAJOR_VERSION >= 3, "Use of wxBitmapComboBox on Settings Tabs requires wxWidgets 3.0 and newer");
using choice_ctrl = wxBitmapComboBox;
#else
using choice_ctrl = wxComboBox;
@ -942,22 +943,6 @@ void Choice::BUILD() {
set_selection();
}
#ifdef __WXOSX__
//#ifndef __WXGTK__
/* Workaround for a correct rendering of the control without Bitmap (under MSW and OSX):
*
* 1. We should create small Bitmap to fill Bitmaps RefData,
* ! in this case wxBitmap.IsOK() return true.
* 2. But then set width to 0 value for no using of bitmap left and right spacing
* 3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
*
* Note: Set bitmap height to the Font size because of OSX rendering.
*/
wxBitmap empty_bmp(1, temp->GetFont().GetPixelSize().y + 2);
empty_bmp.SetWidth(0);
temp->SetItemBitmap(0, empty_bmp);
#endif
temp->Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
if (m_suppress_scroll && !m_is_dropped)
e.StopPropagation();
@ -1289,10 +1274,6 @@ void Choice::msw_rescale()
}
}
wxBitmap empty_bmp(1, field->GetFont().GetPixelSize().y + 2);
empty_bmp.SetWidth(0);
field->SetItemBitmap(0, empty_bmp);
idx == m_opt.enum_values.size() ?
field->SetValue(selection) :
field->SetSelection(idx);

View File

@ -45,11 +45,11 @@ static double get_volume_min_z(const GLVolume* volume)
static wxBitmapComboBox* create_word_local_combo(wxWindow *parent)
static choice_ctrl* create_word_local_combo(wxWindow *parent)
{
wxSize size(15 * wxGetApp().em_unit(), -1);
wxBitmapComboBox *temp = nullptr;
choice_ctrl* temp = nullptr;
#ifdef __WXOSX__
/* wxBitmapComboBox with wxCB_READONLY style return NULL for GetTextCtrl(),
* so ToolTip doesn't shown.
@ -59,7 +59,7 @@ static wxBitmapComboBox* create_word_local_combo(wxWindow *parent)
temp->SetTextCtrlStyle(wxTE_READONLY);
temp->Create(parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr);
#else
temp = new wxBitmapComboBox(parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
temp = new choice_ctrl(parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY);
#endif //__WXOSX__
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -70,26 +70,11 @@ static wxBitmapComboBox* create_word_local_combo(wxWindow *parent)
temp->SetSelection(0);
temp->SetValue(temp->GetString(0));
#ifndef __WXGTK__
/* Workaround for a correct rendering of the control without Bitmap (under MSW and OSX):
*
* 1. We should create small Bitmap to fill Bitmaps RefData,
* ! in this case wxBitmap.IsOK() return true.
* 2. But then set width to 0 value for no using of bitmap left and right spacing
* 3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
*
* Note: Set bitmap height to the Font size because of OSX rendering.
*/
wxBitmap empty_bmp(1, temp->GetFont().GetPixelSize().y + 2);
empty_bmp.SetWidth(0);
temp->SetItemBitmap(0, empty_bmp);
#endif
temp->SetToolTip(_L("Select coordinate space, in which the transformation will be performed."));
return temp;
}
void msw_rescale_word_local_combo(wxBitmapComboBox* combo)
void msw_rescale_word_local_combo(choice_ctrl* combo)
{
const wxString selection = combo->GetString(combo->GetSelection());
@ -111,10 +96,6 @@ void msw_rescale_word_local_combo(wxBitmapComboBox* combo)
combo->Append(_L("World coordinates"));
combo->Append(_L("Local coordinates"));
wxBitmap empty_bmp(1, combo->GetFont().GetPixelSize().y + 2);
empty_bmp.SetWidth(0);
combo->SetItemBitmap(0, empty_bmp);
combo->SetValue(selection);
}

View File

@ -7,7 +7,11 @@
#include "libslic3r/Point.hpp"
#include <float.h>
#ifdef __WXOSX__
class wxBitmapComboBox;
#else
class wxComboBox;
#endif // __WXOSX__
class wxStaticText;
class LockButton;
class wxStaticBitmap;
@ -16,6 +20,13 @@ class wxCheckBox;
namespace Slic3r {
namespace GUI {
#ifdef __WXOSX__
static_assert(wxMAJOR_VERSION >= 3, "Use of wxBitmapComboBox on Manipulation panel requires wxWidgets 3.0 and newer");
using choice_ctrl = wxBitmapComboBox;
#else
using choice_ctrl = wxComboBox;
#endif // __WXOSX__
class Selection;
class ObjectManipulation;
@ -125,7 +136,7 @@ private:
// Does the object manipulation panel work in World or Local coordinates?
bool m_world_coordinates = true;
LockButton* m_lock_bnt{ nullptr };
wxBitmapComboBox* m_word_local_combo = nullptr;
choice_ctrl* m_word_local_combo { nullptr };
ScalableBitmap m_manifold_warning_bmp;
wxStaticBitmap* m_fix_throught_netfab_bitmap;