using wx 2.9.1 and reading header file wxWidgets\include\wx\propgrid\advprops.h, I'm wondering
what the correct way is to get a wxColour from a wxColourProperty (that is available via a
wxPGProperty*).
That is, in
void WindowInspectorT::OnPropertyGridChanged(wxPropertyGridEvent& Event)
{
const wxPGProperty* Prop=Event.GetProperty();
wxString ColStr=Prop->GetValueAsString();
}
ColStr can be "(123, 0, 255)" but also "Blue", "White", "Navy", etc.
The problem is that
wxColour col1(ColStr);
seems to work when ColStr is one of the color names like "Blue", but is missing the "rgb" prefix
when it is of the form "(r, g, b)".
wxColour col2("rgb" + ColStr);
works when ColStr is of the form "(r, g, b)" but oviously not when it is a colour name.
Next, we could cast Prop to wxColourProperty, e.g. (untested)
const wxColourProperty* ColProp=dynamic_cast<const wxColourProperty*>(Prop);
if (ColProp)
{
wxColour col3=ColProp->GetColour(index);
}
but what is "index" supposed to mean??
Third option, calling Prop->GetValue() returns a wxVariant, which doesn't seem to help with
colours either.
In summary, when I want to obtain the wxColour that is defined by the wxColourProperty, what it
the "canoncial" way of doing so??
Many thanks for your help,
and best regards,
Carsten
--
Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
Learn more at http://www.cafu.de
On 30.04.2010 14:33, Jaakko Salli wrote:
> wxVariant value = Prop->GetValue();
> wxColour col;
> col<< value;
Thanks for your quick reply, that works very well!
> Of course, with SVN trunk it is also possible to use wxAny
> facilities ;)
>
> Like this:
>
> wxAny value = Prop->GetValue();
> wxColour col = value.As<wxColour>();
I cannot easily upgrade to SVN trunk head, but I'm very much looking forward to the next 2.9.x
series release! :-)
Best regards,