Prompt.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * The contents of this file are subject to the Mozilla Public
  3. * License Version 1.1 (the "License"); you may not use this file
  4. * except in compliance with the License. You may obtain a copy of
  5. * the License at http://www.mozilla.org/MPL/
  6. *
  7. * Software distributed under the License is distributed on an "AS
  8. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9. * implied. See the License for the specific language governing
  10. * rights and limitations under the License.
  11. *
  12. * The Original Code is Vision.
  13. *
  14. * The Initial Developer of the Original Code is The Vision Team.
  15. * Portions created by The Vision Team are
  16. * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights
  17. * Reserved.
  18. *
  19. * Contributor(s): Rene Gollent
  20. * Wade Majors
  21. * Todd Lair
  22. */
  23. #ifndef PROMPTWINDOW_H_
  24. #define PROMPTWINDOW_H_
  25. #include <Window.h>
  26. #include <MessageFilter.h>
  27. #include <String.h>
  28. #ifdef __INTEL__
  29. #include <regex.h>
  30. #endif
  31. class VTextControl;
  32. class BButton;
  33. class PromptValidate
  34. {
  35. public:
  36. PromptValidate (void);
  37. virtual ~PromptValidate (void);
  38. virtual bool Validate (const char *) = 0;
  39. };
  40. class RegExValidate : public PromptValidate
  41. {
  42. #ifdef __INTEL__
  43. regex_t re;
  44. #endif
  45. bool compiled;
  46. BString title;
  47. public:
  48. RegExValidate (const char *);
  49. virtual ~RegExValidate (void);
  50. virtual bool Validate (const char *);
  51. };
  52. class PromptWindow : public BWindow
  53. {
  54. BHandler *handler;
  55. BMessage *invoked;
  56. VTextControl *field;
  57. BButton *done, *cancel;
  58. PromptValidate *validate;
  59. bool blanks;
  60. public:
  61. PromptWindow (
  62. BPoint,
  63. const char *,
  64. const char *,
  65. const char *,
  66. BHandler *,
  67. BMessage *,
  68. PromptValidate * = 0,
  69. bool = false);
  70. virtual ~PromptWindow (void);
  71. virtual void MessageReceived (BMessage *);
  72. };
  73. class EscapeFilter : public BMessageFilter
  74. {
  75. BWindow *window;
  76. public:
  77. EscapeFilter (BWindow *);
  78. virtual ~EscapeFilter (void);
  79. virtual filter_result Filter (BMessage *, BHandler **);
  80. };
  81. #endif