Page 1 of 1

why doesnt Wxwidgets work with data types like Ms .net ?

Posted: Wed Dec 09, 2009 6:38 pm
by Hossein
i have a question , why doesnt wxwidgets work like Microsoft .net Framework on data types like string ?.
i mean Microsoft .net framework lets you use your conventional data types ( for example string in c++/C#) and then when compiling it converts it to its .net framework type !
the same thing can be done to wxwidgets specific data types like wxString ,
why doesnt wxwidgets do this job?
this will save us from alot of trouble for converting between wxwdigets wxstring and other equivalent types, and we can easily continue to code in our conventional way .and also will bring a more consistent look to our source code .

Regards
Hossein

Posted: Wed Dec 09, 2009 6:48 pm
by DavidHart
Hi,

(I deleted your duplicate post.)

You can, of course, already convert between e.g. std::string and wxString. However wxWidgets tries to manage both ansi and unicode builds with the same code. This currently is done using the wxT() macro; starting from wx2.9 it happens invisibly: see http://docs.wxwidgets.org/trunk/overview_unicode.html.

Regards,

David

Posted: Wed Dec 09, 2009 10:40 pm
by Frank
Also, with wx 2.8 (and before, I use this since 2.5) you can use wxUSE_STL (or something like that) in your Setup.h.

WX then derives wxString from std::string. Wich means, in this case, wxString IS a std::string. I use this for years now wihtout any trouble. In my Code I use std::string only. When calling wx methods I can use std::string. When getting a string from wx, I use std::string.

I can use std::string and wxString as if they were the same, so I never use wxString at all.

Code: Select all

std::string value = myTextCtrl->GetValue();
myTextCtrl->SetValue(value.substr(0, 5)); 
Works just fine

Posted: Thu Dec 10, 2009 2:34 am
by Hossein
DavidHart wrote:Hi,

(I deleted your duplicate post.)

You can, of course, already convert between e.g. std::string and wxString. However wxWidgets tries to manage both ansi and unicode builds with the same code. This currently is done using the wxT() macro; starting from wx2.9 it happens invisibly: see http://docs.wxwidgets.org/trunk/overview_unicode.html.

Regards,

David
so beginning form wxWidgets 2.9.X we can have such a thing huh?
thats Great .
[and by the way sorry for duplication, that happened because of my low speed internet connection, sorry about that]
and about the link you posted , it said
'Documentation Not Found'

Posted: Thu Dec 10, 2009 2:36 am
by Hossein
Frank wrote:Also, with wx 2.8 (and before, I use this since 2.5) you can use wxUSE_STL (or something like that) in your Setup.h.

WX then derives wxString from std::string. Wich means, in this case, wxString IS a std::string. I use this for years now wihtout any trouble. In my Code I use std::string only. When calling wx methods I can use std::string. When getting a string from wx, I use std::string.

I can use std::string and wxString as if they were the same, so I never use wxString at all.

Code: Select all

std::string value = myTextCtrl->GetValue();
myTextCtrl->SetValue(value.substr(0, 5)); 
Works just fine
its just Great, i would be grateful if you guide me how to do t hat ?
which setup.h and where? would you post an tutorial on this ?

Posted: Thu Dec 10, 2009 5:40 am
by Frank
Where to find your setup.h depends on your Plattform. My is here: include/wx/msw/setup.h

It's all documented direcly in that file. The lines you have to change are wxUSE_STD_STRING and (don't know if this is even neccesary for std::string to work, I have my set to 1 because it's 2009 and not 1995) wxUSE_STL. If you wan't to use STL instead of crappy markos for List, Vector, you definiteley should set this.

Posted: Thu Dec 10, 2009 8:05 am
by upCASE
Hi!
Just an addon comment: For Linux you don't have to modify setup.h yourself. The configure script has an option you may enable and the correct values will be set in setup.h.

Posted: Thu Dec 10, 2009 10:46 am
by DavidHart
and about the link you posted , it said
'Documentation Not Found'
It works better without the terminal '.' ;)

Posted: Thu Dec 10, 2009 11:22 am
by Hossein
thank you guys .
and the WXUSE_STD_STRING stuff .
i found

Code: Select all

#if defined(__DMC__) || defined(__WATCOMC__) \
        || (defined(_MSC_VER) && _MSC_VER < 1200)
    #define wxUSE_STD_STRING  0
#else
    #define wxUSE_STD_STRING  1
#endif
so you mean i should change " #define wxUSE_STD_STRING 0" to #define wxUSE_STD_STRING 1 ?

and i changed
#define wxUSE_STL 0

to #define wxUSE_STL 1

i just need confirmation for the first one !

Posted: Fri Dec 11, 2009 1:06 pm
by Frank
Yes, that's the one.

Don't forget to recompile your wxWidgets after the change.