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

This forum is reserved for everything you want to talk about. It could be about programming, opinions, open source programs, development in general, or just cool stuff to share!
Post Reply
Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

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

Post by Hossein » Wed Dec 09, 2009 6:38 pm

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
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/

DavidHart
Site Admin
Site Admin
Posts: 3982
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Wed Dec 09, 2009 6:48 pm

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

Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank » Wed Dec 09, 2009 10:40 pm

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

Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

Post by Hossein » Thu Dec 10, 2009 2:34 am

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'
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/

Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

Post by Hossein » Thu Dec 10, 2009 2:36 am

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 ?
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/

Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank » Thu Dec 10, 2009 5:40 am

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.

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Thu Dec 10, 2009 8:05 am

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.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

DavidHart
Site Admin
Site Admin
Posts: 3982
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Thu Dec 10, 2009 10:46 am

and about the link you posted , it said
'Documentation Not Found'
It works better without the terminal '.' ;)

Hossein
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Sep 21, 2008 7:23 am
Location: Somwhere nearby...
Contact:

Post by Hossein » Thu Dec 10, 2009 11:22 am

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 !
Add-on Components (90)
Applications (183)
Development Tools (27)
Icons and Resources (1)
Sample Code and Project Templates (10)
Utilities (4)
wxWidgets (10)

http://www.wxcommunity.com/

Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank » Fri Dec 11, 2009 1:06 pm

Yes, that's the one.

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

Post Reply