WxHaskell/Development/classes/wxAny
< WxHaskell | Development
Status
It would be highly convenient to wrap the wxAny class. Currently it is not implemented in wxHaskell, work was started, but shelved.
Previous work
Several posts were made to the wxhaskell-devel mailing list, text is given below:
Hi all, I've spent a few hours now trying to wrap the wxAny class, I just wondered if anyone had given any thought to this (or it's 2.8 predecessor: wxVariant) already? It's needed because I'm wrapping this functionality: http://docs.wxwidgets.org/2.9.2/classwx_property_grid_event.html#577d7fb277be169e295726878dcbb7db (wxVariant is automatically promoted to the preferred wxAny in 2.9)
Hi all, I'm still struggling along with this. I've summarised my current problem here: http://hpaste.org/51854 If any of you would be kind enough to take a look.
Here is the contents of that hpaste for reference:
I have a little test application which looks like this: Firstly import[1] some functions: foreign import ccall "wxStringProperty_Create" wxStringProperty_Create :: Ptr (TWxString a) -> IO (Ptr (TStringProperty ())) foreign import ccall "wxPGProperty_GetValue" wxPGProperty_GetValue :: Ptr (TPGProperty a) -> IO (Ptr (TAny ())) foreign import ccall "wxAny_IsInt" anyIsInt :: Ptr (TAny a) -> IO Bool foreign import ccall "wxAny_IsString" anyIsString :: Ptr (TAny a) -> IO Bool And then we do this: main = start test test = do pAny <- withStringPtr "TEST" wxStringProperty_Create >>= wxPGProperty_GetValue anyIsInt pAny >>= putStrLn . show anyIsString pAny >>= putStrLn . show Now what I expected is "False" and "True", but I actually get back "True" twice. I've written what should be an identical program[2] in C++ and it works as expected. Any suggestions? [1] Here's the source of those functions (which I've created in wxcore/cpp/extra.cpp): EWXWEXPORT(wxStringProperty*,wxStringProperty_Create)(wxString const* label) { return new wxStringProperty(*label); } EWXWEXPORT(wxAny*,wxPGProperty_GetValue)(wxPGProperty* self) { wxAny *result = new wxAny(); *result = self->GetValue(); return result; } EWXWEXPORT(bool,wxAny_IsInt)(wxAny* self) { return self->CheckType< int >(); } EWXWEXPORT(bool,wxAny_IsString)(wxAny* self) { return self->CheckType< wxString >(); } [2] The C++ version looks like this: wxStringProperty testStr("TEST"); wxPGProperty prop = testStr; wxAny *result = new wxAny(); *result = prop.GetValue(); printf("is Int? %s\n", result->CheckType< int >() ? "yes" : "no"); printf("is String? %s\n", result->CheckType< wxString >() ? "yes" : "no");
If you are considering working on wrapping `wxAny` you may find this patch useful.