wxValidator in wxCrafter

Post here wxCrafter related issues / features / bugs
marcelinux
CodeLite Enthusiast
Posts: 17
Joined: Mon Nov 02, 2015 3:26 pm
Genuine User: Yes
IDE Question: C++
Location: Spain
Contact:

wxValidator in wxCrafter

Post by marcelinux » Fri Apr 22, 2016 11:51 pm

Hi.
I need a litle help, please.
I would like include a validator in a wxTextCtrl created by wxCrafter.
Seeing validate sample i found:

Code: Select all

    m_numericTextDouble = new wxTextCtrl
                              (
                                this,
                                wxID_ANY,
                                "",
                                wxDefaultPosition,
                                wxDefaultSize,
                                wxTE_RIGHT,
                                wxMakeFloatingPointValidator
                                (
                                    3,
                                    &g_data.m_doubleValue,
                                    wxNUM_VAL_THOUSANDS_SEPARATOR |
                                    wxNUM_VAL_NO_TRAILING_ZEROES
                                )
                              );
And it works, of course.

But I don’t know how make in wxCrafter.
I tryed this:
In the wxTextCtrl’s attributes there is a Subclass combo.
Herein, I input:
Class Name: wxTextCtrl
Include File: globalNum.h
Style: wxTE_RIGTH, wxMakeFloatingPointValidator(2, &g_valueFloat, wxNUM_VAL_THOUSANDS_SEPARATOR | wxNUM_VAL_NO_TRAILING_ZEROES )

Then, I add globalNum.h file in the project with:

Code: Select all

#include “wx/valnum.h”
// Global variable for wxMakeFloatingValidator
float g_valueFloat;
Resulting a compiling error:

Code: Select all

/bin/sh -c '/usr/bin/make -j8 -e -f  Makefile'
----------Building project:[ crafter_validate - Debug ]----------
make[1]: Entering directory '/home/marcel/dev/wxSamples/crafter_validate'
/usr/bin/g++  -c  "/home/marcel/dev/wxSamples/crafter_validate/main.cpp" -g -O0 -Wall -I/home/marcel/dev/wx31/buildgtk3r/lib/wx/include/gtk3-unicode-3.1 -I/home/marcel/dev/wx31/include -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -DWXUSINGDLL -D__WXGTK__ -pthread   -o ./Debug/main.cpp.o -I. -I.
/usr/bin/g++  -c  "/home/marcel/dev/wxSamples/crafter_validate/wxcrafter.cpp" -g -O0 -Wall -I/home/marcel/dev/wx31/buildgtk3r/lib/wx/include/gtk3-unicode-3.1 -I/home/marcel/dev/wx31/include -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -DWXUSINGDLL -D__WXGTK__ -pthread   -o ./Debug/wxcrafter.cpp.o -I. -I.
/usr/bin/g++  -c  "/home/marcel/dev/wxSamples/crafter_validate/MainDialog.cpp" -g -O0 -Wall -I/home/marcel/dev/wx31/buildgtk3r/lib/wx/include/gtk3-unicode-3.1 -I/home/marcel/dev/wx31/include -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -DWXUSINGDLL -D__WXGTK__ -pthread   -o ./Debug/MainDialog.cpp.o -I. -I.
/usr/bin/g++ -o ./Debug/crafter_validate @"crafter_validate.txt" -L.   -L/home/marcel/dev/wx31/buildgtk3r/lib -pthread   -Wl,-rpath,/home/marcel/dev/wx31/buildgtk3r/lib -lwx_gtk3u_xrc-3.1 -lwx_gtk3u_html-3.1 -lwx_gtk3u_qa-3.1 -lwx_gtk3u_adv-3.1 -lwx_gtk3u_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1
./Debug/wxcrafter.cpp.o:(.bss+0x0): multiple definition of `g_valueFloat'
./Debug/main.cpp.o:(.bss+0x0): first defined here
./Debug/MainDialog.cpp.o:(.bss+0x0): multiple definition of `g_valueFloat'
./Debug/main.cpp.o:/home/marcel/dev/wx31/include/wx/imagjpeg.h:26: first defined here
collect2: error: ld returned 1 exit status
crafter_validate.mk:76: recipe for target 'Debug/crafter_validate' failed
make[1]: *** [Debug/crafter_validate] Error 1
make[1]: Leaving directory '/home/marcel/dev/wxSamples/crafter_validate'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
====2 errors, 0 warnings====
Please, where can I find an example?

Thanks.

My environment:
OS debian stretch 64bits
g++ (Debian 5.3.1-14) 5.3.1 20160409
wxWidgets 3.1.0 self compiled
CodeLite 9.1.5 binary package
You do not have the required permissions to view the files attached to this post.

User avatar
eranif
CodeLite Plugin
Posts: 5898
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxValidator in wxCrafter

Post by eranif » Sat Apr 23, 2016 12:17 am

You should change it to:

Code: Select all

extern float g_valueFloat;
and place the *definition* in a .cpp file (not in a header)

Eran
Make sure you have read the HOW TO POST thread

marcelinux
CodeLite Enthusiast
Posts: 17
Joined: Mon Nov 02, 2015 3:26 pm
Genuine User: Yes
IDE Question: C++
Location: Spain
Contact:

Re: wxValidator in wxCrafter

Post by marcelinux » Sat Apr 23, 2016 12:58 am

:oops: Great!
Thank you!
Now, I need to know whats flags can I apply.
I'll look for in http://docs.wxwidgets.org/3.0/classwx_validator.html

marcelinux
CodeLite Enthusiast
Posts: 17
Joined: Mon Nov 02, 2015 3:26 pm
Genuine User: Yes
IDE Question: C++
Location: Spain
Contact:

Re: wxValidator in wxCrafter

Post by marcelinux » Mon Apr 25, 2016 12:30 am

I have made a little tutorial to explain this solution.
I would like if a moderator could review it and, if would be of interest, please say me how must I send it.
Thank you.

User avatar
eranif
CodeLite Plugin
Posts: 5898
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxValidator in wxCrafter

Post by eranif » Mon Apr 25, 2016 6:34 am

You can attach it here as a text document and I will update the wiki pages

Eran
Make sure you have read the HOW TO POST thread

marcelinux
CodeLite Enthusiast
Posts: 17
Joined: Mon Nov 02, 2015 3:26 pm
Genuine User: Yes
IDE Question: C++
Location: Spain
Contact:

Re: wxValidator in wxCrafter

Post by marcelinux » Mon Apr 25, 2016 11:53 am

OK. Tonigth I will attach a 'odt' document.

marcelinux
CodeLite Enthusiast
Posts: 17
Joined: Mon Nov 02, 2015 3:26 pm
Genuine User: Yes
IDE Question: C++
Location: Spain
Contact:

Re: wxValidator in wxCrafter

Post by marcelinux » Tue Apr 26, 2016 1:29 am

Here is. Thanks.
You do not have the required permissions to view the files attached to this post.

Post Reply