|
From: James L. <ja...@mi...> - 2001-12-13 11:12:31
|
Mattia,
Thanks, as usual, for the to-the-point and quick support!
If/when I manage to produce a useful validator, I would be more than
happy to submit it. Currently I'm still getting my head round how
everything fits together!
James
> -----Original Message-----
> From: Mattia Barbon [mailto:mb...@ds...]
> Sent: 13 December 2001 11:04
> To: wxp...@li...
> Subject: [wxperl-users] Re: wxValidator available via wxPerl
>=20
>=20
> > Dear Mattia,
> > I would like to use validators in my Perl application, but=20
> am not clear
> > whether they have been wrapped.
> >=20
> > Are they available?
> Yes, and no; you can use Wx::PlValidator and derive
> your own valiadtors, but the standard
> Wx::TextValidator and Wx::GenericValidator are not wrapped,
> because at the time I has quite a lot other more important=20
> classes to wrap ( it was=20
> before wxPerl 0.01 ), and then just forgot about it.
>=20
> By the way, I think that wxGenericValidator and wxTextValidator are
> quite limited, and their functionalities can be implemented
> in Perl ( using Wx::PlValidator ), probably with a better interface.
>=20
> To derive a new validator:
>=20
> package MyValidator;
>=20
> use vars qw(@ISA); @ISA =3D qw(Wx::PlValidator);
>=20
> sub new {
> my $class =3D shift;
> my $this =3D $class->SUPER::new();
>=20
> ...
>=20
> return $this;
> }
>=20
> # see the docs for the three following functions
> sub TransferFromWindow { ... }
> sub TransferToWindow { ... }
> sub Validate { ... }
>=20
> 1;
>=20
> Of course no one stops you from contributing your validators
> back to wxPerl, if you feel like it...
>=20
> Regards
> Mattia
>=20
> _______________________________________________
> wxperl-users mailing list
> wxp...@li...
> https://lists.sourceforge.net/lists/listinfo/wxperl-users
>=20
>=20
|
|
From: James L. <ja...@mi...> - 2001-12-18 09:55:25
|
Dear Mattia, Thanks - this works a treat! I was so close... Anyway, now I'm up and running. I had noticed the 'Attempt to free unreferenced...' error - will await a fix. Now that I've got things working, what do you suggest/would you like? I feel that validators are the way to go when it comes to transferring data to/from controls (rather than explicit GetValue/SetValue calls all over the place) - I have had to implement a similar concept (though not as elegant) in a very large Perl/Tk application which we have developed. I see that you think we should create Perl versions of wxGenericValidator and wxTextValidator - I am happy to do this and contribute them to the project. If I do this, do you (or anyone else on the list) have ideas on how we should name/implement them? What 'better interface' can you envisage for a Perl-based Validator? I have not examined the native wxGenericValidator and wxTextValidator yet, so am interested in your thoughts. Regards, James > -----Original Message----- > From: Mattia Barbon [mailto:mb...@ds...] > Sent: 17 December 2001 22:22 > To: wxp...@li... > Subject: RE: [wxperl-users] Re: wxValidator available via wxPerl >=20 >=20 > > Dear Mattia (or others, if they can help), > > I've been delving into how to use wxValidators, and I think=20 > I understand the > > concept (and I like it!). > >=20 > > However, I'm having real trouble deriving my own validator (called, > > unimaginitively, myValidator) from Wx::PlValidator. > >=20 > > >From the wxWindows documentation, all validators must=20 > implement a Clone > > method. I have tried implementing a Clone method, which I=20 > can see getting > > called, but myValidator's Validate, TransferFromWindow, and=20 > TransferToWindow > > never seem to get called. > >=20 > > Here is my code (with the methods apart from Clone doing=20 > nothing useful > > apart from printing to STDOUT): > >=20 > > VVVVVVVVVVVVVVVVVVVV > > use Wx; > >=20 > > package myValidator; > This is OK ( in fact the sample I sant uses this code ) >=20 > > ^^^^^^^^^^^^ > >=20 > =20 > > Could you post a very simple example of how to create a=20 > validator class in > > Perl, and how to create a frame which uses it, please? > Here is your example ( modified minimal sample, use Help->About to > show the validator dialog ) >=20 > I am getting a "Attempt to free unreferenced scalar at=20 > C:/Developement/wxPerl/wxPerl/blib/lib/Wx.pm line 61.",=20 > which I was not getting when I first tested Validators. > It is obviously something I am doing wrong with reference > counting in wxPerl; will fix. >=20 > A caveat: do not use a validator after you did > ->SetValidator(); for implementation reasons, > once you do ->SetValidator() it is no more valid. >=20 > Regards > Mattia >=20 >=20 >=20 >=20 |
|
From: Mattia B. <mb...@ds...> - 2001-12-18 10:21:49
|
On Tue, 18 Dec 2001, James Lavery wrote:
>Dear Mattia,
>Thanks - this works a treat!
>
>I was so close... Anyway, now I'm up and running.
>
>I had noticed the 'Attempt to free unreferenced...' error - will await a
>fix.
>
>Now that I've got things working, what do you suggest/would you like? I
>feel that validators are the way to go when it comes to transferring
>data to/from controls (rather than explicit GetValue/SetValue calls all
>over the place) - I have had to implement a similar concept (though not
>as elegant) in a very large Perl/Tk application which we have developed.
>
>I see that you think we should create Perl versions of
>wxGenericValidator and wxTextValidator - I am happy to do this and
>contribute them to the project. If I do this, do you (or anyone else on
>the list) have ideas on how we should name/implement them? What 'better
>interface' can you envisage for a Perl-based Validator? I have not
>examined the native wxGenericValidator and wxTextValidator yet, so am
>interested in your thoughts.
wxTextValidator is OK for Perl, while wxGenericValidator does
1 - use overloading
wxGV construtor takes one of a int/bool/string/integer array
(C++) pointer ( think Perl references ), but in Perl
int/string/bool map to scalar.
2 - there is no NumericValidator ( or whatever you want to call it )
one that does a text->number conversion with error
checking/bound checking, for intehers and floats
3 - I don't like wxGV because it tries to do
validation for all controls, doing the Right Thing, but this
sometimes is not possible ( like: for comboboxes
if you pass a string, it returns the selected string,
if you pass an integer it returns the index of the selected string in
the combobox, but if I want the selected string as a number
( because my combobox contains, say, 1,2,3,4,6,12 ) I need
a custom validator ( this relates to the lack of a NumericValidator )
BTW this example does not fit with Perl ( because in Perl a
number "is" a string, but I hope you get the idea )
But since I do not use validator that much, it's up to you to decide
Thanks!
Mattia
|
|
From: James L. <ja...@mi...> - 2001-12-18 11:11:52
|
> wxTextValidator is OK for Perl, while wxGenericValidator does > 1 - use overloading > wxGV construtor takes one of a int/bool/string/integer array > (C++) pointer ( think Perl references ), but in Perl > int/string/bool map to scalar. Yes, I think a Perl-implemented GenericValidator can just take the address of the variable to/from which to deposit/get data, and can handle it appropriately internally by checking the reference type. > 2 - there is no NumericValidator ( or whatever you want to call it ) > one that does a text->number conversion with error > checking/bound checking, for intehers and floats What would you like it to do? Take a mask and validate the input according to the mask? (I'm assuming there's no existing wx masked text control already). > 3 - I don't like wxGV because it tries to do > validation for all controls, doing the Right Thing, but this > sometimes is not possible ( like: for comboboxes > if you pass a string, it returns the selected string, > if you pass an integer it returns the index of the=20 > selected string in > the combobox, but if I want the selected string as a number > ( because my combobox contains, say, 1,2,3,4,6,12 ) I need > a custom validator ( this relates to the lack of a=20 > NumericValidator )=20 > BTW this example does not fit with Perl ( because in Perl a > number "is" a string, but I hope you get the idea ) >=20 Hmm... Have looked at the C++ code for the GV, and see what you mean with comboboxes. =20 Just trying to work out how we can differentiate between setting selection by index or string. In this case, I think we need a separate ComboBoxValidator (or rather ChoiceValidator), with a flag passed to the constructor indicating how we want to set the selection (index or string). In the light of this, do you think we should not have a GV, but have individual ones for each control type, or implement the GV in Perl with more intelligence? > But since I do not use validator that much, it's up to you to decide Oh goody! In terms of package/object naming, what should I do? Not sure if the Perl validators should be in the Wx namespace. Notwithstanding that, I think I should name the validators PlGenericValidator, PlChoiceValidator etc., to differentiate from the 'native' wx validators. What do you think? I don't know if there are standards already published on this in the Wx/Perl community. James |
|
From: Mattia B. <mb...@ds...> - 2001-12-19 18:13:22
|
Sorry for the delay > > wxTextValidator is OK for Perl, while wxGenericValidator does > > 1 - use overloading > > wxGV construtor takes one of a int/bool/string/integer array > > (C++) pointer ( think Perl references ), but in Perl > > int/string/bool map to scalar. > Yes, I think a Perl-implemented GenericValidator can just take the > address of the variable to/from which to deposit/get data, and can > handle it appropriately internally by checking the reference type. the trouble is that in perl you can only have scalar references, so you need a flag to tell the class you want a number/string/bool transferred > > 2 - there is no NumericValidator ( or whatever you want to call it ) > > one that does a text->number conversion with error > > checking/bound checking, for intehers and floats > What would you like it to do? Take a mask and validate the input > according to the mask? (I'm assuming there's no existing wx masked text > control already). the one I wrote in C++ a year ago could: * check that the number is aproper integer number ( if you passed a int/long pointer ) * check that the number is a proper float number ( if you passed a float/double pointer ) * optionally check that the number is in some range > > 3 - I don't like wxGV because it tries to do > > validation for all controls, doing the Right Thing, but this > > sometimes is not possible ( like: for comboboxes > > if you pass a string, it returns the selected string, > > if you pass an integer it returns the index of the > > selected string in > > the combobox, but if I want the selected string as a number > > ( because my combobox contains, say, 1,2,3,4,6,12 ) I need > > a custom validator ( this relates to the lack of a > > NumericValidator ) > > BTW this example does not fit with Perl ( because in Perl a > > number "is" a string, but I hope you get the idea ) > > > Hmm... Have looked at the C++ code for the GV, and see what you mean > with comboboxes. > > Just trying to work out how we can differentiate between setting > selection by index or string. In this case, I think we need a separate > ComboBoxValidator (or rather ChoiceValidator), with a flag passed to the > constructor indicating how we want to set the selection (index or > string). > > In the light of this, do you think we should not have a GV, but have > individual ones for each control type, or implement the GV in Perl with > more intelligence? > > But since I do not use validator that much, it's up to you to decide > Oh goody! > In terms of package/object naming, what should I do? Not sure if the > Perl validators should be in the Wx namespace. Notwithstanding that, I > think I should name the validators PlGenericValidator, PlChoiceValidator > etc., to differentiate from the 'native' wx validators. What do you > think? I don't know if there are standards already published on this in > the Wx/Perl community. See my other mail. Thanks! Mattia |
|
From: James L. <ja...@mi...> - 2001-12-20 08:28:05
|
Mattia, > > Yes, I think a Perl-implemented GenericValidator can just take the > > address of the variable to/from which to deposit/get data, and can > > handle it appropriately internally by checking the reference type. > the trouble is that in perl you can only have scalar references, > so you need a flag to tell the class you want a number/string/bool > transferred Good point. I think I'll use the 'flag' approach. This has approach has been used elsewhere (in Win32::API, I think), so I'll try to be consistent with other modules. =20 > > > 2 - there is no NumericValidator ( or whatever you want ... > the one I wrote in C++ a year ago could: > * check that the number is aproper integer number > ( if you passed a int/long pointer ) > * check that the number is a proper float number > ( if you passed a float/double pointer ) > * optionally check that the number is in some > range Sounds reasonable for a first cut. James |
|
From: Mattia B. <mb...@ds...> - 2001-12-21 17:00:33
|
> Dear Mattia,
> Thanks - this works a treat!
>
> I was so close... Anyway, now I'm up and running.
>
> I had noticed the 'Attempt to free unreferenced...' error - will await a
> fix.
I think it is a Perl bug: putting an (empty) DESTROY in Wx::PlVlaidator make it
disappear.
The strange thing is that base classes do not have DESTROY methods
( so it can't be the empty one masking a base class' DESTROY ),
but if you put UNIVERSAL::can( $_[0], 'SUPER::DESTROY' ); in the
previously empty DESTROY {}, this triggers the error.
Regards
Mattia
|
|
From: James L. <jl...@bi...> - 2002-02-23 07:12:30
|
Hi everyone, I want to use Perl2Exe to package up my application, but am having problems. Perl2Exe runs fine, and produces a .exe file, but when I run it, I get the following errors: Compilation failed in require at C:\MY DOCUMENTS\PROG\TFC\PERL_SRC\TFFC.EXE line 10. BEGIN failed--compilation aborted at C:\MY DOCUMENTS\PROG\TFC\PERL_SRC\TFFC.EXE line 10. Line 10 is my 'use Wx' line. Has anyone else succeeded in using Perl2Exe with wxPerl? Thanks, James |
|
From: Marcus <li...@wo...> - 2002-02-23 19:49:53
|
On 23.02.02 at 07:17 James Lavery wrote: >Has anyone else succeeded in using Perl2Exe with wxPerl? You do know it has to be Wx case-sensitive? Yes, I have. You do need to package the wx_version.dll with it. I can't figure out your problem right now, but it did work with wxPerl wx22_8.dll and ActivePerl build 623 (5.6.1), and wx MSW 2.2.x. Perl2Exe is picky about module paths, so that could be a possibility. Have you added Perl2Exe to your path variable, instead of running it with a full path. Just a thought. Marcus |