From: Mattia B. <mb...@ds...> - 2002-07-06 21:16:35
|
> Hi Marcus, > Validators are similar to, but not the same as, Perl/Tk. As you say, in > Perl/Tk, changes to the underlying variable immediately appear in the Tk > widget - a great feature but also a source of problems, as you have found. > > However, I think that Wx validators only transfer the data to the control > when $window->TransferDataToWindow is called, and back again when > $window->TransferDataFromWindow is called. (I'll check this out with some > trials). This is correct. > For wxDialogs, these are both called automatically as part of Dialog > initialisation and dismissal (TransferDataFromWindow is only called when the > modal result is wxID_OK, I think). And this too. BTW, there is a wxValidator overview in the wxWindows manual (Topics overview -> wxValidator overview; I am not sure how much C++=oriented it is, but may be worth reading, especially "How validators interact with dialogs") > One feature I'm thinking of implementing is the ability to supply a callback > for the TransferToWindow and TransferFromWindow wxValidator methods, so that > we can supply data from object methods and pump data back into object > methods, rather than having to rely on variable addresses. (Most of my Perl > code is OO, and so I want to be able to use property accessors, rather than > property addresses). This looks like a nice feature, BTW Regards Mattia |
From: James L. <jl...@bi...> - 2003-04-11 06:00:34
Attachments:
validators.zip
|
Dear Mark, Attached should be the validator stuff I got working. There are three classes: base class Validator derived class TextValidator derived class GenericValidator The base class provides the basic methods needed - including the all-important Clone method. The TextValidator provides basic validation for text controls. It allows validation either by specifying a regexp pattern, or a reference to a subroutine to call at runtime like this: $this->GetTextDateFormat->SetValidator(Wx::Perl::TextValidator->new(variable => \$TFFC_main::aSettings{general}{date_format}, validate => \&main::validate_date, )); so that we don't have to create lots of different subclassed Validators for each type of validation (i.e. one for date validation, one for zip code, etc). This works very well. The GenericValidator is a start on, well, a generic validator. It handles Wx::TextCtrl, Wx::CheckBox, Wx::Choice, and Wx::RadioBox so far. The property choice_value determines whether the string value of the control or its selected item is returned/set - I think! (It's a long time since I looked at all this). I'm afraid the pod/documentation is sparse if not non-existent. However, here's a synopsis: use Wx::Perl::GenericValidator; use Wx::Perl::TextValidator; ... # set up validators for the filter checkboxes $this->GetCheckboxQif->SetValidator(Wx::Perl::GenericValidator->new(variable => \$aFilters{qif})); $this->GetCheckboxDelimited->SetValidator(Wx::Perl::GenericValidator->new(va riable => \$aFilters{delimited})); $this->GetCheckboxMT940->SetValidator(Wx::Perl::GenericValidator->new(variab le => \$aFilters{MT940})); # a generic validator returning the index for a Wx::Choice $this->FindWindow( $main::ID_CHOICE_ACCOUNT_TYPE ) ->SetValidator(Wx::Perl::GenericValidator->new(variable => \$this->{qifDef}->{nAcct_type}, choice_value =>'index')); Note that I'm using wxDesigner, so this generates the ->Get... routines. If you have any questions, please let me know. It would be great if you could progress the development on this - I've been sidetracked onto other projects at the moment, so have not got the time. I'm happy to review/help with what you do. Regards, James |
From: James L. <jl...@bi...> - 2003-04-11 06:32:40
|
Mark, Forgot to say, in my previous mail, that one feature I think would be very useful is to be able to specify a subroutine address for TransferToWindow and/or TransferFromWindow, so that, in an OO Perl application, the accessor methods could be called, rather than using variable/property addresses. I didn't get very far with this - but am happy to help on its development. James ----- Original Message ----- From: "Mark Wardell" <ma...@ne...> To: "'James Lavery'" <jl...@bi...> Sent: Thursday, April 10, 2003 2:47 PM Subject: RE: [wxperl-users] Validators > James, > > Yes I apologize, I must have previously read a message by Simon. > > I look forward to looking at your progress. I have managed to get the > basic concept of validators working but no real functionality yet. > > Regards > Mark > > -----Original Message----- > From: James Lavery [mailto:jl...@bi...] > Sent: 10 April 2003 07:15 AM > To: Mark Wardell; James Lavery > Cc: wxp...@li... > Subject: Re: [wxperl-users] Validators > > > Dear Mark, > I did get something working quite well several months ago - will look it > out and send it to you. It may have been overtaken by later wxPerl > versions... > > Regards, > > James > (PS Did you mean 'James' or 'Simon'...!) > > ----- Original Message ----- > From: "Mark Wardell" <ma...@ne...> > To: "James Lavery" <ja...@mi...> > Cc: <wxp...@li...> > Sent: Wednesday, April 09, 2003 9:57 AM > Subject: [wxperl-users] Validators > > > > Hi All, > > > > I have searched the archives and found several discussions relating to > > > validators. Simon, you have expressed interest in these, have you made > > > any progress? Do you have anything that you have stopped work on that > > I can continue with? It is pointless re-inventing the wheel but if > > nobody has anything to start with, then I will start at the beginning. > > > > Regards > > Mark Wardell > > > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by:ThinkGeek > > Welcome to geek heaven. > > http://thinkgeek.com/sf > > _______________________________________________ > > wxperl-users mailing list > > wxp...@li... > > https://lists.sourceforge.net/lists/listinfo/wxperl-users > > > |