EDIT.H 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. ** Command & Conquer(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: F:\projects\c&c\vcs\code\edit.h_v 2.17 16 Oct 1995 16:46:32 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : EDIT.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 01/15/95 *
  30. * *
  31. * Last Update : January 15, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef EDIT_H
  37. #define EDIT_H
  38. class EditClass : public ControlClass
  39. {
  40. public:
  41. typedef enum EditStyle {
  42. ALPHA =0x0001, // Edit accepts alphabetic characters.
  43. NUMERIC =0x0002, // Edit accepts numbers.
  44. MISC =0x0004, // Edit accepts misc graphic characters.
  45. UPPERCASE =0x0008, // Force to upper case.
  46. ALPHANUMERIC=(int)ALPHA|(int)NUMERIC|(int)MISC,
  47. } EditStyle;
  48. EditClass (int id, char * text, int max_len, TextPrintType flags, int x, int y, int w=-1, int h=-1, EditStyle style=ALPHANUMERIC);
  49. virtual ~EditClass(void);
  50. virtual int Draw_Me(int forced);
  51. virtual void Set_Text(char * text, int max_len);
  52. void Set_Color (int color) { Color = color; }
  53. void Set_Read_Only(int rdonly) {IsReadOnly = rdonly;}
  54. protected:
  55. /*
  56. ** These are the text size and style flags to be used when displaying the text
  57. ** of the edit gadget.
  58. */
  59. TextPrintType TextFlags;
  60. /*
  61. ** Input flags that control what characters are allowed in the string.
  62. */
  63. EditStyle EditFlags;
  64. /*
  65. ** Pointer to text staging buffer and the maximum length of the string it
  66. ** can contain.
  67. */
  68. char *String;
  69. int MaxLength;
  70. /*
  71. ** This is the current length of the string. This length will never exceed the
  72. ** MaxLength allowed.
  73. */
  74. int Length;
  75. /*
  76. ** This is the desired color of the edit control.
  77. */
  78. int Color;
  79. virtual int Action (unsigned flags, KeyNumType &key);
  80. virtual void Draw_Background(void);
  81. virtual void Draw_Text(char const * text);
  82. virtual bool Handle_Key(KeyASCIIType ascii);
  83. private:
  84. int IsReadOnly;
  85. };
  86. inline EditClass::EditStyle operator |(EditClass::EditStyle, EditClass::EditStyle);
  87. inline EditClass::EditStyle operator &(EditClass::EditStyle, EditClass::EditStyle);
  88. inline EditClass::EditStyle operator ~(EditClass::EditStyle);
  89. #endif