I have a number of properties in a wxPropertyGrid which I would like to group with a wxPGProperty acting as a header for its child properties. This header property should not display an editor when clicking on it.
I started with a wxStringProperty, but I found no way to disable the editor (e.g. by vetoing an event).
Simply calling wxStringProperty::Enable (false) prevents the editor from being shown, but now the label is greyed out (not what I want).
Is there a better solution for creating a wxPGProperty without editor?
Custom wxPGProperty without editor
Re: Custom wxPGProperty without editor
Hi,
Did you look at the sample to see whether you can get another propertype?
Thank you.
Did you look at the sample to see whether you can get another propertype?
Thank you.
Re: Custom wxPGProperty without editor
Hi ONEEYEMAN,
Thanks for your quick reply. I had a look a the propgrid sample again but couldn't find an example for the problem.
To clarify things, I would like to use another level of structuring properties:
Category (wxCategoryProperty)
- Subcategory
-- Property 1 (wxPGProperty)
-- Property 2 (wxPGProperty)
I tried to use wxCategoryProperty for the subcategories without success. Both categories and subcategories are shown on the same level without nesting.
Thanks for your quick reply. I had a look a the propgrid sample again but couldn't find an example for the problem.
To clarify things, I would like to use another level of structuring properties:
Category (wxCategoryProperty)
- Subcategory
-- Property 1 (wxPGProperty)
-- Property 2 (wxPGProperty)
I tried to use wxCategoryProperty for the subcategories without success. Both categories and subcategories are shown on the same level without nesting.
Re: Custom wxPGProperty without editor
Hi,
Then it is probably not supported.
You can make such modification and submit it as patch on trac or PR on github, or send an E-mail on wx-users ML to see if someone else already made such modification.
Also in any case you can create a ticket on the trac.wxwidgets.org about this, so that hopefully someone can make it.
Thank you.
Then it is probably not supported.
You can make such modification and submit it as patch on trac or PR on github, or send an E-mail on wx-users ML to see if someone else already made such modification.
Also in any case you can create a ticket on the trac.wxwidgets.org about this, so that hopefully someone can make it.
Thank you.
Re: Custom wxPGProperty without editor
Hi ONEEYEMAN,
Thanks for the advice! I had a closer look at the source of wxPropertyGrid and found a solution for my problem without changing wxWidgets itself. It is safe to create a custom wxPGEditor without any attached window:
This editor can be used in a custom property derived from wxPGProperty. It just has to display its label:
In my first attempt I used wxStringProperty together with wxPGProperty::Enable (false) which caused the label to be greyed out. The difference is not large, but the label is now shown with its correct color.
Thanks for the advice! I had a closer look at the source of wxPropertyGrid and found a solution for my problem without changing wxWidgets itself. It is safe to create a custom wxPGEditor without any attached window:
Code: Select all
class EmptyEditor : public wxPGEditor
{
public:
EmptyEditor () {}
~EmptyEditor () override {}
wxPGWindowList CreateControls (wxPropertyGrid *propGrid,
wxPGProperty *property,
const wxPoint &pos,
const wxSize &sz) const override
{
return wxPGWindowList ();
}
void UpdateControl (wxPGProperty *property, wxWindow *ctrl) const override {}
bool OnEvent (wxPropertyGrid *propGrid,
wxPGProperty *property,
wxWindow *ctrl,
wxEvent &event) const override
{
return false;
}
};
Code: Select all
class SubcategoryProperty : public wxPGProperty
{
public:
SubcategoryProperty () {}
SubcategoryProperty (const wxString &label = wxPG_LABEL,
const wxString &name = wxPG_LABEL,
const wxString &value = wxEmptyString) :
wxPGProperty (label, name)
{
m_value = value;
}
~SubcategoryProperty () override {}
const wxPGEditor *DoGetEditorClass () const override
{
if (!m_editor)
m_editor = new EmptyEditor ();
return m_editor;
}
wxString ValueToString (wxVariant &value, int argFlags) const override
{
return wxEmptyString;
}
bool StringToValue (wxVariant &variant, const wxString &text, int argFlags) const override
{
return false;
}
private:
static EmptyEditor *m_editor;
};
EmptyEditor *SubcategoryProperty::m_editor = nullptr;