home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / kwclass.zip / KENTRYFD.CPP < prev    next >
C/C++ Source or Header  |  1994-04-18  |  1KB  |  69 lines

  1. #include <kentryfd.hpp>
  2. #include <kvalid.hpp>
  3. #include <istring.hpp>
  4.  
  5.  
  6. KEntryField::KEntryField(unsigned long id,
  7.                   IWindow *wndParent,
  8.                   IWindow *wndOwner,
  9.                   const IRectangle &initial,
  10.                   const IResourceId &resText,
  11.                   const IEntryField::Style style)
  12.   : IEntryField(id, wndParent, wndOwner, initial, style)
  13.   , _validator(0)
  14. {
  15.    setText(resText);
  16. }
  17.  
  18. KEntryField::KEntryField(unsigned long id,
  19.                   IWindow *wndParent,
  20.                   IWindow *wndOwner,
  21.                   const IRectangle &initial,
  22.                   const IEntryField::Style style)
  23.   : IEntryField(id, wndParent, wndOwner, initial, style)
  24.   , _validator(0)
  25. {
  26. }
  27.  
  28. KValidator* KEntryField::validator() const
  29. {
  30.    return _validator;
  31. }
  32.  
  33. KEntryField& KEntryField::setValidator(KValidator *val) 
  34.    _validator = val;
  35.    return *this;
  36. }
  37.  
  38. Boolean KEntryField::validate(unsigned long pos)
  39. {
  40.    if (validator())
  41.      return validator()->isValid(text());
  42. }
  43.  
  44. ITextControl &KEntryField::setText(const IResourceId &text)
  45. {
  46.   return Inherited::setText(text);
  47. }
  48.  
  49. ITextControl &KEntryField::setText(const char *text)
  50. {
  51.   IString string(text);
  52.  
  53. //  if (validator())
  54. //    validator()->fill(string);
  55.  
  56.   return Inherited::setText(string);
  57. }
  58.  
  59. IString KEntryField::text() const
  60. {
  61.   IString string(Inherited::text());
  62.  
  63.   if (validator())
  64.     validator()->strip(string);
  65.  
  66.   return string;
  67. }
  68.