mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Use the wxDataViewIconTextRenderer instead of the DataViewBitmapTextRenderer under GTK
This commit is contained in:
parent
c4569c93f2
commit
8b74ae4568
2 changed files with 43 additions and 4 deletions
|
@ -42,14 +42,14 @@ static std::string orange = "#ed6b21";
|
||||||
|
|
||||||
static void color_string(wxString& str, const std::string& color)
|
static void color_string(wxString& str, const std::string& color)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
#if defined(SUPPORTS_MARKUP) && /*!defined(__APPLE__)*/defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
||||||
str = from_u8((boost::format("<span color=\"%1%\">%2%</span>") % color % into_u8(str)).str());
|
str = from_u8((boost::format("<span color=\"%1%\">%2%</span>") % color % into_u8(str)).str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void make_string_bold(wxString& str)
|
static void make_string_bold(wxString& str)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
#if defined(SUPPORTS_MARKUP) && !defined(__APPLE__)//defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
||||||
str = from_u8((boost::format("<b>%1%</b>") % into_u8(str)).str());
|
str = from_u8((boost::format("<b>%1%</b>") % into_u8(str)).str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,11 @@ ModelNode::ModelNode(Preset::Type preset_type, const wxString& text) :
|
||||||
m_preset_type(preset_type),
|
m_preset_type(preset_type),
|
||||||
m_text(text)
|
m_text(text)
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
m_icon.CopyFromBitmap(create_scaled_bitmap(type_icon_names.at(preset_type)));
|
||||||
|
#else
|
||||||
m_icon = create_scaled_bitmap(type_icon_names.at(preset_type));
|
m_icon = create_scaled_bitmap(type_icon_names.at(preset_type));
|
||||||
|
#endif //__linux__
|
||||||
}
|
}
|
||||||
|
|
||||||
// group node
|
// group node
|
||||||
|
@ -68,7 +72,11 @@ ModelNode::ModelNode(ModelNode* parent, const wxString& text, const std::string&
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_text(text)
|
m_text(text)
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
m_icon.CopyFromBitmap(create_scaled_bitmap(icon_name));
|
||||||
|
#else
|
||||||
m_icon = create_scaled_bitmap(icon_name);
|
m_icon = create_scaled_bitmap(icon_name);
|
||||||
|
#endif //__linux__
|
||||||
}
|
}
|
||||||
|
|
||||||
// category node
|
// category node
|
||||||
|
@ -300,7 +308,11 @@ void UnsavedChangesModel::GetValue(wxVariant& variant, const wxDataViewItem& ite
|
||||||
variant = node->m_toggle;
|
variant = node->m_toggle;
|
||||||
break;
|
break;
|
||||||
case colIconText:
|
case colIconText:
|
||||||
|
#ifdef __linux__
|
||||||
|
variant << wxDataViewIconText(node->m_text, node->m_icon);
|
||||||
|
#else
|
||||||
variant << DataViewBitmapText(node->m_text, node->m_icon);
|
variant << DataViewBitmapText(node->m_text, node->m_icon);
|
||||||
|
#endif //__linux__
|
||||||
break;
|
break;
|
||||||
case colOldValue:
|
case colOldValue:
|
||||||
variant << DataViewBitmapText(node->m_old_value, node->m_old_color_bmp);
|
variant << DataViewBitmapText(node->m_old_value, node->m_old_color_bmp);
|
||||||
|
@ -322,10 +334,18 @@ bool UnsavedChangesModel::SetValue(const wxVariant& variant, const wxDataViewIte
|
||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case colIconText: {
|
case colIconText: {
|
||||||
|
#ifdef __linux__
|
||||||
|
wxDataViewIconText data;
|
||||||
|
#else
|
||||||
DataViewBitmapText data;
|
DataViewBitmapText data;
|
||||||
|
#endif //__linux__
|
||||||
data << variant;
|
data << variant;
|
||||||
node->m_icon = data.GetBitmap();
|
|
||||||
node->m_text = data.GetText();
|
node->m_text = data.GetText();
|
||||||
|
#ifdef __linux__
|
||||||
|
node->m_icon = data.GetIcon();
|
||||||
|
#else
|
||||||
|
node->m_icon = data.GetBitmap();
|
||||||
|
#endif //__linux__
|
||||||
return true; }
|
return true; }
|
||||||
case colToggle:
|
case colToggle:
|
||||||
node->m_toggle = variant.GetBool();
|
node->m_toggle = variant.GetBool();
|
||||||
|
@ -439,7 +459,16 @@ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type)
|
||||||
m_tree_model->SetAssociatedControl(m_tree);
|
m_tree_model->SetAssociatedControl(m_tree);
|
||||||
|
|
||||||
m_tree->AppendToggleColumn(L"\u2714", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE/*, 6 * em*/);//2610,11,12 //2714
|
m_tree->AppendToggleColumn(L"\u2714", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE/*, 6 * em*/);//2610,11,12 //2714
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
wxDataViewIconTextRenderer* rd = new wxDataViewIconTextRenderer();
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
rd->EnableMarkup(true);
|
||||||
|
#endif
|
||||||
|
wxDataViewColumn* icon_text_clmn = new wxDataViewColumn("", rd, UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_CELL_INERT);
|
||||||
|
#else
|
||||||
wxDataViewColumn* icon_text_clmn = new wxDataViewColumn("", new BitmapTextRenderer(true), UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE);
|
wxDataViewColumn* icon_text_clmn = new wxDataViewColumn("", new BitmapTextRenderer(true), UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE);
|
||||||
|
#endif //__linux__
|
||||||
m_tree->AppendColumn(icon_text_clmn);
|
m_tree->AppendColumn(icon_text_clmn);
|
||||||
m_tree->AppendColumn(new wxDataViewColumn("Old value", new BitmapTextRenderer(true), UnsavedChangesModel::colOldValue, 20 * em, wxALIGN_TOP));
|
m_tree->AppendColumn(new wxDataViewColumn("Old value", new BitmapTextRenderer(true), UnsavedChangesModel::colOldValue, 20 * em, wxALIGN_TOP));
|
||||||
m_tree->AppendColumn(new wxDataViewColumn("New value", new BitmapTextRenderer(true), UnsavedChangesModel::colNewValue, 20 * em, wxALIGN_TOP));
|
m_tree->AppendColumn(new wxDataViewColumn("New value", new BitmapTextRenderer(true), UnsavedChangesModel::colNewValue, 20 * em, wxALIGN_TOP));
|
||||||
|
|
|
@ -18,6 +18,12 @@ namespace GUI{
|
||||||
class ModelNode;
|
class ModelNode;
|
||||||
WX_DEFINE_ARRAY_PTR(ModelNode*, ModelNodePtrArray);
|
WX_DEFINE_ARRAY_PTR(ModelNode*, ModelNodePtrArray);
|
||||||
|
|
||||||
|
// On all of 3 different platforms Bitmap+Text icon column looks different
|
||||||
|
// because of Markup text is missed or not implemented.
|
||||||
|
// As a temporary workaround, we will use:
|
||||||
|
// MSW - DataViewBitmapText (our custom renderer wxBitmap + wxString, supported Markup text)
|
||||||
|
// OSX - -//-, but Markup text is not implemented right now
|
||||||
|
// GTK - wxDataViewIconText (wxWidgets for GTK renderer wxIcon + wxString, supported Markup text)
|
||||||
class ModelNode
|
class ModelNode
|
||||||
{
|
{
|
||||||
wxWindow* m_parent_win{ nullptr };
|
wxWindow* m_parent_win{ nullptr };
|
||||||
|
@ -47,7 +53,11 @@ class ModelNode
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool m_toggle {true};
|
bool m_toggle {true};
|
||||||
|
#ifdef __linux__
|
||||||
|
wxIcon m_icon;
|
||||||
|
#else
|
||||||
wxBitmap m_icon;
|
wxBitmap m_icon;
|
||||||
|
#endif //__linux__
|
||||||
wxBitmap m_old_color_bmp;
|
wxBitmap m_old_color_bmp;
|
||||||
wxBitmap m_new_color_bmp;
|
wxBitmap m_new_color_bmp;
|
||||||
wxString m_text;
|
wxString m_text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue