Custom renderers extracted from the ObjectDataViewModel
This commit is contained in:
parent
1674d2af29
commit
93c1671e09
6 changed files with 490 additions and 460 deletions
|
@ -165,6 +165,8 @@ set(SLIC3R_GUI_SOURCES
|
||||||
GUI/Search.hpp
|
GUI/Search.hpp
|
||||||
GUI/UnsavedChangesDialog.cpp
|
GUI/UnsavedChangesDialog.cpp
|
||||||
GUI/UnsavedChangesDialog.hpp
|
GUI/UnsavedChangesDialog.hpp
|
||||||
|
GUI/ExtraRenderers.cpp
|
||||||
|
GUI/ExtraRenderers.hpp
|
||||||
Utils/Http.cpp
|
Utils/Http.cpp
|
||||||
Utils/Http.hpp
|
Utils/Http.hpp
|
||||||
Utils/FixModelByWin10.cpp
|
Utils/FixModelByWin10.cpp
|
||||||
|
|
314
src/slic3r/GUI/ExtraRenderers.cpp
Normal file
314
src/slic3r/GUI/ExtraRenderers.cpp
Normal file
|
@ -0,0 +1,314 @@
|
||||||
|
#include "ExtraRenderers.hpp"
|
||||||
|
#include "wxExtensions.hpp"
|
||||||
|
#include "GUI.hpp"
|
||||||
|
#include "I18N.hpp"
|
||||||
|
|
||||||
|
#include <wx/dc.h>
|
||||||
|
#include "wx/generic/private/markuptext.h"
|
||||||
|
#include "wx/generic/private/rowheightcache.h"
|
||||||
|
#include "wx/generic/private/widthcalc.h"
|
||||||
|
#if wxUSE_ACCESSIBILITY
|
||||||
|
#include "wx/private/markupparser.h"
|
||||||
|
#endif // wxUSE_ACCESSIBILITY
|
||||||
|
|
||||||
|
using Slic3r::GUI::from_u8;
|
||||||
|
using Slic3r::GUI::into_u8;
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// DataViewBitmapText
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxIMPLEMENT_DYNAMIC_CLASS(DataViewBitmapText, wxObject)
|
||||||
|
|
||||||
|
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// BitmapTextRenderer
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
BitmapTextRenderer::BitmapTextRenderer(wxDataViewCellMode mode /*= wxDATAVIEW_CELL_EDITABLE*/,
|
||||||
|
int align /*= wxDVR_DEFAULT_ALIGNMENT*/):
|
||||||
|
wxDataViewRenderer(wxT("PrusaDataViewBitmapText"), mode, align)
|
||||||
|
{
|
||||||
|
SetMode(mode);
|
||||||
|
SetAlignment(align);
|
||||||
|
}
|
||||||
|
#endif // ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
|
||||||
|
BitmapTextRenderer::~BitmapTextRenderer()
|
||||||
|
{
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
if (m_markupText)
|
||||||
|
delete m_markupText;
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
void BitmapTextRenderer::EnableMarkup(bool enable)
|
||||||
|
{
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
if (!m_markupText)
|
||||||
|
{
|
||||||
|
m_markupText = new wxItemMarkupText(wxString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_markupText)
|
||||||
|
{
|
||||||
|
delete m_markupText;
|
||||||
|
m_markupText = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
|
||||||
|
bool BitmapTextRenderer::SetValue(const wxVariant &value)
|
||||||
|
{
|
||||||
|
m_value << value;
|
||||||
|
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
if (m_markupText)
|
||||||
|
m_markupText->SetMarkup(m_value.GetText());
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitmapTextRenderer::GetValue(wxVariant& WXUNUSED(value)) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
||||||
|
wxString BitmapTextRenderer::GetAccessibleDescription() const
|
||||||
|
{
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
if (m_markupText)
|
||||||
|
return wxMarkupParser::Strip(m_text);
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
|
||||||
|
return m_value.GetText();
|
||||||
|
}
|
||||||
|
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
|
||||||
|
bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
|
||||||
|
{
|
||||||
|
int xoffset = 0;
|
||||||
|
|
||||||
|
const wxBitmap& icon = m_value.GetBitmap();
|
||||||
|
if (icon.IsOk())
|
||||||
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
|
wxSize icon_sz = icon.GetScaledSize();
|
||||||
|
#else
|
||||||
|
wxSize icon_sz = icon.GetSize();
|
||||||
|
#endif
|
||||||
|
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
|
||||||
|
xoffset = icon_sz.x + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
if (m_markupText)
|
||||||
|
{
|
||||||
|
int flags = 0;
|
||||||
|
|
||||||
|
rect.x += xoffset;
|
||||||
|
m_markupText->Render(GetView(), *dc, rect, flags, GetEllipsizeMode());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize BitmapTextRenderer::GetSize() const
|
||||||
|
{
|
||||||
|
if (!m_value.GetText().empty())
|
||||||
|
{
|
||||||
|
wxSize size;
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
if (m_markupText)
|
||||||
|
{
|
||||||
|
wxDataViewCtrl* const view = GetView();
|
||||||
|
wxClientDC dc(view);
|
||||||
|
if (GetAttr().HasFont())
|
||||||
|
dc.SetFont(GetAttr().GetEffectiveFont(view->GetFont()));
|
||||||
|
|
||||||
|
size = m_markupText->Measure(dc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
size = GetTextExtent(m_value.GetText());
|
||||||
|
|
||||||
|
int lines = m_value.GetText().Freq('\n') + 1;
|
||||||
|
size.SetHeight(size.GetHeight() * lines);
|
||||||
|
|
||||||
|
if (m_value.GetBitmap().IsOk())
|
||||||
|
size.x += m_value.GetBitmap().GetWidth() + 4;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
return wxSize(80, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxWindow* BitmapTextRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
||||||
|
{
|
||||||
|
if (!can_create_editor_ctrl())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
DataViewBitmapText data;
|
||||||
|
data << value;
|
||||||
|
|
||||||
|
m_was_unusable_symbol = false;
|
||||||
|
|
||||||
|
wxPoint position = labelRect.GetPosition();
|
||||||
|
if (data.GetBitmap().IsOk()) {
|
||||||
|
const int bmp_width = data.GetBitmap().GetWidth();
|
||||||
|
position.x += bmp_width;
|
||||||
|
labelRect.SetWidth(labelRect.GetWidth() - bmp_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTextCtrl* text_editor = new wxTextCtrl(parent, wxID_ANY, data.GetText(),
|
||||||
|
position, labelRect.GetSize(), wxTE_PROCESS_ENTER);
|
||||||
|
text_editor->SetInsertionPointEnd();
|
||||||
|
text_editor->SelectAll();
|
||||||
|
|
||||||
|
return text_editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitmapTextRenderer::GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value)
|
||||||
|
{
|
||||||
|
wxTextCtrl* text_editor = wxDynamicCast(ctrl, wxTextCtrl);
|
||||||
|
if (!text_editor || text_editor->GetValue().IsEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string chosen_name = into_u8(text_editor->GetValue());
|
||||||
|
const char* unusable_symbols = "<>:/\\|?*\"";
|
||||||
|
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
|
||||||
|
if (chosen_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
|
||||||
|
m_was_unusable_symbol = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The icon can't be edited so get its old value and reuse it.
|
||||||
|
wxVariant valueOld;
|
||||||
|
GetView()->GetModel()->GetValue(valueOld, m_item, /*colName*/0);
|
||||||
|
|
||||||
|
DataViewBitmapText bmpText;
|
||||||
|
bmpText << valueOld;
|
||||||
|
|
||||||
|
// But replace the text with the value entered by user.
|
||||||
|
bmpText.SetText(text_editor->GetValue());
|
||||||
|
|
||||||
|
value << bmpText;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// BitmapChoiceRenderer
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool BitmapChoiceRenderer::SetValue(const wxVariant& value)
|
||||||
|
{
|
||||||
|
m_value << value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitmapChoiceRenderer::GetValue(wxVariant& value) const
|
||||||
|
{
|
||||||
|
value << m_value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
|
||||||
|
{
|
||||||
|
int xoffset = 0;
|
||||||
|
|
||||||
|
const wxBitmap& icon = m_value.GetBitmap();
|
||||||
|
if (icon.IsOk())
|
||||||
|
{
|
||||||
|
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
||||||
|
xoffset = icon.GetWidth() + 4;
|
||||||
|
|
||||||
|
if (rect.height==0)
|
||||||
|
rect.height= icon.GetHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize BitmapChoiceRenderer::GetSize() const
|
||||||
|
{
|
||||||
|
wxSize sz = GetTextExtent(m_value.GetText());
|
||||||
|
|
||||||
|
if (m_value.GetBitmap().IsOk())
|
||||||
|
sz.x += m_value.GetBitmap().GetWidth() + 4;
|
||||||
|
|
||||||
|
return sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
||||||
|
{
|
||||||
|
if (!can_create_editor_ctrl())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
std::vector<wxBitmap*> icons = get_extruder_color_icons();
|
||||||
|
if (icons.empty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
DataViewBitmapText data;
|
||||||
|
data << value;
|
||||||
|
|
||||||
|
auto c_editor = new wxBitmapComboBox(parent, wxID_ANY, wxEmptyString,
|
||||||
|
labelRect.GetTopLeft(), wxSize(labelRect.GetWidth(), -1),
|
||||||
|
0, nullptr , wxCB_READONLY);
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
for (wxBitmap* bmp : icons) {
|
||||||
|
if (i==0) {
|
||||||
|
c_editor->Append(_L("default"), *bmp);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
c_editor->Append(wxString::Format("%d", i), *bmp);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
c_editor->SetSelection(atoi(data.GetText().c_str()));
|
||||||
|
|
||||||
|
// to avoid event propagation to other sidebar items
|
||||||
|
c_editor->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
||||||
|
evt.StopPropagation();
|
||||||
|
// FinishEditing grabs new selection and triggers config update. We better call
|
||||||
|
// it explicitly, automatic update on KILL_FOCUS didn't work on Linux.
|
||||||
|
this->FinishEditing();
|
||||||
|
});
|
||||||
|
|
||||||
|
return c_editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitmapChoiceRenderer::GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value)
|
||||||
|
{
|
||||||
|
wxBitmapComboBox* c = (wxBitmapComboBox*)ctrl;
|
||||||
|
int selection = c->GetSelection();
|
||||||
|
if (selection < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DataViewBitmapText bmpText;
|
||||||
|
|
||||||
|
bmpText.SetText(c->GetString(selection));
|
||||||
|
bmpText.SetBitmap(c->GetItemBitmap(selection));
|
||||||
|
|
||||||
|
value << bmpText;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
162
src/slic3r/GUI/ExtraRenderers.hpp
Normal file
162
src/slic3r/GUI/ExtraRenderers.hpp
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
#ifndef slic3r_GUI_ExtraRenderers_hpp_
|
||||||
|
#define slic3r_GUI_ExtraRenderers_hpp_
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
|
||||||
|
#if wxUSE_MARKUP && wxCHECK_VERSION(3, 1, 1)
|
||||||
|
#define SUPPORTS_MARKUP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// DataViewBitmapText: helper class used by BitmapTextRenderer
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class DataViewBitmapText : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DataViewBitmapText( const wxString &text = wxEmptyString,
|
||||||
|
const wxBitmap& bmp = wxNullBitmap) :
|
||||||
|
m_text(text),
|
||||||
|
m_bmp(bmp)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
DataViewBitmapText(const DataViewBitmapText &other)
|
||||||
|
: wxObject(),
|
||||||
|
m_text(other.m_text),
|
||||||
|
m_bmp(other.m_bmp)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void SetText(const wxString &text) { m_text = text; }
|
||||||
|
wxString GetText() const { return m_text; }
|
||||||
|
void SetBitmap(const wxBitmap &bmp) { m_bmp = bmp; }
|
||||||
|
const wxBitmap &GetBitmap() const { return m_bmp; }
|
||||||
|
|
||||||
|
bool IsSameAs(const DataViewBitmapText& other) const {
|
||||||
|
return m_text == other.m_text && m_bmp.IsSameAs(other.m_bmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const DataViewBitmapText& other) const {
|
||||||
|
return IsSameAs(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const DataViewBitmapText& other) const {
|
||||||
|
return !IsSameAs(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_text;
|
||||||
|
wxBitmap m_bmp;
|
||||||
|
|
||||||
|
wxDECLARE_DYNAMIC_CLASS(DataViewBitmapText);
|
||||||
|
};
|
||||||
|
DECLARE_VARIANT_OBJECT(DataViewBitmapText)
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// BitmapTextRenderer
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
class BitmapTextRenderer : public wxDataViewRenderer
|
||||||
|
#else
|
||||||
|
class BitmapTextRenderer : public wxDataViewCustomRenderer
|
||||||
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BitmapTextRenderer(wxWindow* parent,
|
||||||
|
wxDataViewCellMode mode =
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
wxDATAVIEW_CELL_INERT
|
||||||
|
#else
|
||||||
|
wxDATAVIEW_CELL_EDITABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
, int align = wxDVR_DEFAULT_ALIGNMENT
|
||||||
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
) :
|
||||||
|
wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align),
|
||||||
|
m_parent(parent)
|
||||||
|
{
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
m_markupText = nullptr;
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
}
|
||||||
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
|
||||||
|
~BitmapTextRenderer();
|
||||||
|
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
void EnableMarkup(bool enable = true);
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
|
||||||
|
bool SetValue(const wxVariant& value);
|
||||||
|
bool GetValue(wxVariant& value) const;
|
||||||
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
||||||
|
virtual wxString GetAccessibleDescription() const override;
|
||||||
|
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
|
||||||
|
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
||||||
|
virtual wxSize GetSize() const override;
|
||||||
|
|
||||||
|
bool HasEditorCtrl() const override
|
||||||
|
{
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
wxWindow* CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value) override;
|
||||||
|
bool GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value) override;
|
||||||
|
bool WasCanceled() const { return m_was_unusable_symbol; }
|
||||||
|
|
||||||
|
void set_can_create_editor_ctrl_function(std::function<bool()> can_create_fn) { can_create_editor_ctrl = can_create_fn; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
DataViewBitmapText m_value;
|
||||||
|
bool m_was_unusable_symbol{ false };
|
||||||
|
wxWindow* m_parent{ nullptr };
|
||||||
|
|
||||||
|
std::function<bool()> can_create_editor_ctrl { nullptr };
|
||||||
|
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
class wxItemMarkupText* m_markupText;
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// BitmapChoiceRenderer
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BitmapChoiceRenderer : public wxDataViewCustomRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BitmapChoiceRenderer(wxDataViewCellMode mode =
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
wxDATAVIEW_CELL_INERT
|
||||||
|
#else
|
||||||
|
wxDATAVIEW_CELL_EDITABLE
|
||||||
|
#endif
|
||||||
|
, int align = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
|
||||||
|
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
|
||||||
|
|
||||||
|
bool SetValue(const wxVariant& value);
|
||||||
|
bool GetValue(wxVariant& value) const;
|
||||||
|
|
||||||
|
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
||||||
|
virtual wxSize GetSize() const override;
|
||||||
|
|
||||||
|
bool HasEditorCtrl() const override { return true; }
|
||||||
|
wxWindow* CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value) override;
|
||||||
|
bool GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value) override;
|
||||||
|
|
||||||
|
void set_can_create_editor_ctrl_function(std::function<bool()> can_create_fn) { can_create_editor_ctrl = can_create_fn; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
DataViewBitmapText m_value;
|
||||||
|
std::function<bool()> can_create_editor_ctrl { nullptr };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // slic3r_GUI_ExtraRenderers_hpp_
|
|
@ -277,7 +277,11 @@ void ObjectList::create_objects_ctrl()
|
||||||
|
|
||||||
// column ItemName(Icon+Text) of the view control:
|
// column ItemName(Icon+Text) of the view control:
|
||||||
// And Icon can be consisting of several bitmaps
|
// And Icon can be consisting of several bitmaps
|
||||||
AppendColumn(new wxDataViewColumn(_(L("Name")), new BitmapTextRenderer(this),
|
BitmapTextRenderer* bmp_text_renderer = new BitmapTextRenderer(this);
|
||||||
|
bmp_text_renderer->set_can_create_editor_ctrl_function([this]() {
|
||||||
|
return m_objects_model->GetItemType(GetSelection()) & (itVolume | itObject);
|
||||||
|
});
|
||||||
|
AppendColumn(new wxDataViewColumn(_L("Name"), bmp_text_renderer,
|
||||||
colName, 20*em, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
|
colName, 20*em, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
|
||||||
|
|
||||||
// column PrintableProperty (Icon) of the view control:
|
// column PrintableProperty (Icon) of the view control:
|
||||||
|
@ -285,11 +289,15 @@ void ObjectList::create_objects_ctrl()
|
||||||
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
|
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
|
||||||
|
|
||||||
// column Extruder of the view control:
|
// column Extruder of the view control:
|
||||||
AppendColumn(new wxDataViewColumn(_(L("Extruder")), new BitmapChoiceRenderer(),
|
BitmapChoiceRenderer* bmp_choice_renderer = new BitmapChoiceRenderer();
|
||||||
|
bmp_choice_renderer->set_can_create_editor_ctrl_function([this]() {
|
||||||
|
return m_objects_model->GetItemType(GetSelection()) & (itVolume | itLayer | itObject);
|
||||||
|
});
|
||||||
|
AppendColumn(new wxDataViewColumn(_L("Extruder"), bmp_choice_renderer,
|
||||||
colExtruder, 8*em, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE));
|
colExtruder, 8*em, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE));
|
||||||
|
|
||||||
// column ItemEditing of the view control:
|
// column ItemEditing of the view control:
|
||||||
AppendBitmapColumn(_(L("Editing")), colEditing, wxDATAVIEW_CELL_INERT, 3*em,
|
AppendBitmapColumn(_L("Editing"), colEditing, wxDATAVIEW_CELL_INERT, 3*em,
|
||||||
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
|
wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE);
|
||||||
|
|
||||||
// For some reason under OSX on 4K(5K) monitors in wxDataViewColumn constructor doesn't set width of column.
|
// For some reason under OSX on 4K(5K) monitors in wxDataViewColumn constructor doesn't set width of column.
|
||||||
|
|
|
@ -1555,311 +1555,6 @@ void ObjectDataViewModel::DeleteWarningIcon(const wxDataViewItem& item, const bo
|
||||||
DeleteWarningIcon(child);
|
DeleteWarningIcon(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// DataViewBitmapText
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(DataViewBitmapText, wxObject)
|
|
||||||
|
|
||||||
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
// BitmapTextRenderer
|
|
||||||
// ---------------------------------------------------------
|
|
||||||
|
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
BitmapTextRenderer::BitmapTextRenderer(wxDataViewCellMode mode /*= wxDATAVIEW_CELL_EDITABLE*/,
|
|
||||||
int align /*= wxDVR_DEFAULT_ALIGNMENT*/):
|
|
||||||
wxDataViewRenderer(wxT("PrusaDataViewBitmapText"), mode, align)
|
|
||||||
{
|
|
||||||
SetMode(mode);
|
|
||||||
SetAlignment(align);
|
|
||||||
}
|
|
||||||
#endif // ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
|
|
||||||
BitmapTextRenderer::~BitmapTextRenderer()
|
|
||||||
{
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
if (m_markupText)
|
|
||||||
delete m_markupText;
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
void BitmapTextRenderer::EnableMarkup(bool enable)
|
|
||||||
{
|
|
||||||
if (enable)
|
|
||||||
{
|
|
||||||
if (!m_markupText)
|
|
||||||
{
|
|
||||||
m_markupText = new wxItemMarkupText(wxString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_markupText)
|
|
||||||
{
|
|
||||||
delete m_markupText;
|
|
||||||
m_markupText = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
|
|
||||||
bool BitmapTextRenderer::SetValue(const wxVariant &value)
|
|
||||||
{
|
|
||||||
m_value << value;
|
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
if (m_markupText)
|
|
||||||
m_markupText->SetMarkup(m_value.GetText());
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BitmapTextRenderer::GetValue(wxVariant& WXUNUSED(value)) const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
|
||||||
wxString BitmapTextRenderer::GetAccessibleDescription() const
|
|
||||||
{
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
if (m_markupText)
|
|
||||||
return wxMarkupParser::Strip(m_text);
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
|
|
||||||
return m_value.GetText();
|
|
||||||
}
|
|
||||||
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
|
|
||||||
bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
|
|
||||||
{
|
|
||||||
int xoffset = 0;
|
|
||||||
|
|
||||||
const wxBitmap& icon = m_value.GetBitmap();
|
|
||||||
if (icon.IsOk())
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
wxSize icon_sz = icon.GetScaledSize();
|
|
||||||
#else
|
|
||||||
wxSize icon_sz = icon.GetSize();
|
|
||||||
#endif
|
|
||||||
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
|
|
||||||
xoffset = icon_sz.x + 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
if (m_markupText)
|
|
||||||
{
|
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
rect.x += xoffset;
|
|
||||||
m_markupText->Render(GetView(), *dc, rect, flags, GetEllipsizeMode());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize BitmapTextRenderer::GetSize() const
|
|
||||||
{
|
|
||||||
if (!m_value.GetText().empty())
|
|
||||||
{
|
|
||||||
wxSize size;
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
if (m_markupText)
|
|
||||||
{
|
|
||||||
wxDataViewCtrl* const view = GetView();
|
|
||||||
wxClientDC dc(view);
|
|
||||||
if (GetAttr().HasFont())
|
|
||||||
dc.SetFont(GetAttr().GetEffectiveFont(view->GetFont()));
|
|
||||||
|
|
||||||
size = m_markupText->Measure(dc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
size = GetTextExtent(m_value.GetText());
|
|
||||||
|
|
||||||
int lines = m_value.GetText().Freq('\n') + 1;
|
|
||||||
size.SetHeight(size.GetHeight() * lines);
|
|
||||||
|
|
||||||
if (m_value.GetBitmap().IsOk())
|
|
||||||
size.x += m_value.GetBitmap().GetWidth() + 4;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
return wxSize(80, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxWindow* BitmapTextRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
|
||||||
{
|
|
||||||
wxDataViewCtrl* const dv_ctrl = GetOwner()->GetOwner();
|
|
||||||
ObjectDataViewModel* const model = dynamic_cast<ObjectDataViewModel*>(dv_ctrl->GetModel());
|
|
||||||
|
|
||||||
if ( !(model->GetItemType(dv_ctrl->GetSelection()) & (itVolume | itObject)) )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
DataViewBitmapText data;
|
|
||||||
data << value;
|
|
||||||
|
|
||||||
m_was_unusable_symbol = false;
|
|
||||||
|
|
||||||
wxPoint position = labelRect.GetPosition();
|
|
||||||
if (data.GetBitmap().IsOk()) {
|
|
||||||
const int bmp_width = data.GetBitmap().GetWidth();
|
|
||||||
position.x += bmp_width;
|
|
||||||
labelRect.SetWidth(labelRect.GetWidth() - bmp_width);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxTextCtrl* text_editor = new wxTextCtrl(parent, wxID_ANY, data.GetText(),
|
|
||||||
position, labelRect.GetSize(), wxTE_PROCESS_ENTER);
|
|
||||||
text_editor->SetInsertionPointEnd();
|
|
||||||
text_editor->SelectAll();
|
|
||||||
|
|
||||||
return text_editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BitmapTextRenderer::GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value)
|
|
||||||
{
|
|
||||||
wxTextCtrl* text_editor = wxDynamicCast(ctrl, wxTextCtrl);
|
|
||||||
if (!text_editor || text_editor->GetValue().IsEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
std::string chosen_name = Slic3r::normalize_utf8_nfc(text_editor->GetValue().ToUTF8());
|
|
||||||
const char* unusable_symbols = "<>:/\\|?*\"";
|
|
||||||
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
|
|
||||||
if (chosen_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
|
|
||||||
m_was_unusable_symbol = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The icon can't be edited so get its old value and reuse it.
|
|
||||||
wxVariant valueOld;
|
|
||||||
GetView()->GetModel()->GetValue(valueOld, m_item, colName);
|
|
||||||
|
|
||||||
DataViewBitmapText bmpText;
|
|
||||||
bmpText << valueOld;
|
|
||||||
|
|
||||||
// But replace the text with the value entered by user.
|
|
||||||
bmpText.SetText(text_editor->GetValue());
|
|
||||||
|
|
||||||
value << bmpText;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// BitmapChoiceRenderer
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool BitmapChoiceRenderer::SetValue(const wxVariant& value)
|
|
||||||
{
|
|
||||||
m_value << value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BitmapChoiceRenderer::GetValue(wxVariant& value) const
|
|
||||||
{
|
|
||||||
value << m_value;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
|
|
||||||
{
|
|
||||||
int xoffset = 0;
|
|
||||||
|
|
||||||
const wxBitmap& icon = m_value.GetBitmap();
|
|
||||||
if (icon.IsOk())
|
|
||||||
{
|
|
||||||
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
|
||||||
xoffset = icon.GetWidth() + 4;
|
|
||||||
|
|
||||||
if (rect.height==0)
|
|
||||||
rect.height= icon.GetHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize BitmapChoiceRenderer::GetSize() const
|
|
||||||
{
|
|
||||||
wxSize sz = GetTextExtent(m_value.GetText());
|
|
||||||
|
|
||||||
if (m_value.GetBitmap().IsOk())
|
|
||||||
sz.x += m_value.GetBitmap().GetWidth() + 4;
|
|
||||||
|
|
||||||
return sz;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
|
||||||
{
|
|
||||||
wxDataViewCtrl* const dv_ctrl = GetOwner()->GetOwner();
|
|
||||||
ObjectDataViewModel* const model = dynamic_cast<ObjectDataViewModel*>(dv_ctrl->GetModel());
|
|
||||||
|
|
||||||
if (!(model->GetItemType(dv_ctrl->GetSelection()) & (itVolume | itLayer | itObject)))
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
std::vector<wxBitmap*> icons = get_extruder_color_icons();
|
|
||||||
if (icons.empty())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
DataViewBitmapText data;
|
|
||||||
data << value;
|
|
||||||
|
|
||||||
auto c_editor = new wxBitmapComboBox(parent, wxID_ANY, wxEmptyString,
|
|
||||||
labelRect.GetTopLeft(), wxSize(labelRect.GetWidth(), -1),
|
|
||||||
0, nullptr , wxCB_READONLY);
|
|
||||||
|
|
||||||
int i=0;
|
|
||||||
for (wxBitmap* bmp : icons) {
|
|
||||||
if (i==0) {
|
|
||||||
c_editor->Append(_(L("default")), *bmp);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
c_editor->Append(wxString::Format("%d", i), *bmp);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
c_editor->SetSelection(atoi(data.GetText().c_str()));
|
|
||||||
|
|
||||||
// to avoid event propagation to other sidebar items
|
|
||||||
c_editor->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
|
||||||
evt.StopPropagation();
|
|
||||||
// FinishEditing grabs new selection and triggers config update. We better call
|
|
||||||
// it explicitly, automatic update on KILL_FOCUS didn't work on Linux.
|
|
||||||
this->FinishEditing();
|
|
||||||
});
|
|
||||||
|
|
||||||
return c_editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BitmapChoiceRenderer::GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value)
|
|
||||||
{
|
|
||||||
wxBitmapComboBox* c = (wxBitmapComboBox*)ctrl;
|
|
||||||
int selection = c->GetSelection();
|
|
||||||
if (selection < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
DataViewBitmapText bmpText;
|
|
||||||
|
|
||||||
bmpText.SetText(c->GetString(selection));
|
|
||||||
bmpText.SetBitmap(c->GetItemBitmap(selection));
|
|
||||||
|
|
||||||
value << bmpText;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <wx/dataview.h>
|
#include <wx/dataview.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "GUI_App.hpp"
|
#include "ExtraRenderers.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
@ -15,157 +15,6 @@ namespace GUI {
|
||||||
typedef double coordf_t;
|
typedef double coordf_t;
|
||||||
typedef std::pair<coordf_t, coordf_t> t_layer_height_range;
|
typedef std::pair<coordf_t, coordf_t> t_layer_height_range;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// DataViewBitmapText: helper class used by BitmapTextRenderer
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DataViewBitmapText : public wxObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataViewBitmapText( const wxString &text = wxEmptyString,
|
|
||||||
const wxBitmap& bmp = wxNullBitmap) :
|
|
||||||
m_text(text),
|
|
||||||
m_bmp(bmp)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
DataViewBitmapText(const DataViewBitmapText &other)
|
|
||||||
: wxObject(),
|
|
||||||
m_text(other.m_text),
|
|
||||||
m_bmp(other.m_bmp)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void SetText(const wxString &text) { m_text = text; }
|
|
||||||
wxString GetText() const { return m_text; }
|
|
||||||
void SetBitmap(const wxBitmap &bmp) { m_bmp = bmp; }
|
|
||||||
const wxBitmap &GetBitmap() const { return m_bmp; }
|
|
||||||
|
|
||||||
bool IsSameAs(const DataViewBitmapText& other) const {
|
|
||||||
return m_text == other.m_text && m_bmp.IsSameAs(other.m_bmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const DataViewBitmapText& other) const {
|
|
||||||
return IsSameAs(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const DataViewBitmapText& other) const {
|
|
||||||
return !IsSameAs(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxString m_text;
|
|
||||||
wxBitmap m_bmp;
|
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(DataViewBitmapText);
|
|
||||||
};
|
|
||||||
DECLARE_VARIANT_OBJECT(DataViewBitmapText)
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// BitmapTextRenderer
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
class BitmapTextRenderer : public wxDataViewRenderer
|
|
||||||
#else
|
|
||||||
class BitmapTextRenderer : public wxDataViewCustomRenderer
|
|
||||||
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BitmapTextRenderer(wxWindow* parent,
|
|
||||||
wxDataViewCellMode mode =
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
wxDATAVIEW_CELL_INERT
|
|
||||||
#else
|
|
||||||
wxDATAVIEW_CELL_EDITABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
, int align = wxDVR_DEFAULT_ALIGNMENT
|
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
) :
|
|
||||||
wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align),
|
|
||||||
m_parent(parent)
|
|
||||||
{
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
m_markupText = nullptr;
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
}
|
|
||||||
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
|
|
||||||
~BitmapTextRenderer();
|
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
void EnableMarkup(bool enable = true);
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
|
|
||||||
bool SetValue(const wxVariant& value);
|
|
||||||
bool GetValue(wxVariant& value) const;
|
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
|
||||||
virtual wxString GetAccessibleDescription() const override;
|
|
||||||
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
||||||
|
|
||||||
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
|
||||||
virtual wxSize GetSize() const override;
|
|
||||||
|
|
||||||
bool HasEditorCtrl() const override
|
|
||||||
{
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
wxWindow* CreateEditorCtrl(wxWindow* parent,
|
|
||||||
wxRect labelRect,
|
|
||||||
const wxVariant& value) override;
|
|
||||||
bool GetValueFromEditorCtrl(wxWindow* ctrl,
|
|
||||||
wxVariant& value) override;
|
|
||||||
bool WasCanceled() const { return m_was_unusable_symbol; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
DataViewBitmapText m_value;
|
|
||||||
bool m_was_unusable_symbol{ false };
|
|
||||||
wxWindow* m_parent{ nullptr };
|
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
class wxItemMarkupText* m_markupText;
|
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// BitmapChoiceRenderer
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class BitmapChoiceRenderer : public wxDataViewCustomRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BitmapChoiceRenderer(wxDataViewCellMode mode =
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
wxDATAVIEW_CELL_INERT
|
|
||||||
#else
|
|
||||||
wxDATAVIEW_CELL_EDITABLE
|
|
||||||
#endif
|
|
||||||
, int align = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
|
|
||||||
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
|
|
||||||
|
|
||||||
bool SetValue(const wxVariant& value);
|
|
||||||
bool GetValue(wxVariant& value) const;
|
|
||||||
|
|
||||||
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
|
||||||
virtual wxSize GetSize() const override;
|
|
||||||
|
|
||||||
bool HasEditorCtrl() const override { return true; }
|
|
||||||
wxWindow* CreateEditorCtrl(wxWindow* parent,
|
|
||||||
wxRect labelRect,
|
|
||||||
const wxVariant& value) override;
|
|
||||||
bool GetValueFromEditorCtrl(wxWindow* ctrl,
|
|
||||||
wxVariant& value) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DataViewBitmapText m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// ObjectDataViewModelNode: a node inside ObjectDataViewModel
|
// ObjectDataViewModelNode: a node inside ObjectDataViewModel
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue