EDIT.H 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/EDIT.H 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : EDIT.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 01/15/95 *
  26. * *
  27. * Last Update : January 15, 1995 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef EDIT_H
  33. #define EDIT_H
  34. class EditClass : public ControlClass
  35. {
  36. public:
  37. typedef enum EditStyle {
  38. ALPHA =0x0001, // Edit accepts alphabetic characters.
  39. NUMERIC =0x0002, // Edit accepts numbers.
  40. MISC =0x0004, // Edit accepts misc graphic characters.
  41. UPPERCASE =0x0008, // Force to upper case.
  42. ALPHANUMERIC=(int)ALPHA|(int)NUMERIC|(int)MISC
  43. } EditStyle;
  44. EditClass (int id, char * text, int max_len, TextPrintType flags, int x, int y, int w=-1, int h=-1, EditStyle style=ALPHANUMERIC);
  45. virtual ~EditClass(void);
  46. virtual void Set_Focus(void);
  47. virtual int Draw_Me(int forced);
  48. virtual void Set_Text(char * text, int max_len);
  49. virtual char * Get_Text(void) {return(String);};
  50. void Set_Color (RemapControlType * color) { Color = color; }
  51. void Set_Read_Only(int rdonly) {IsReadOnly = rdonly;}
  52. protected:
  53. /*
  54. ** These are the text size and style flags to be used when displaying the text
  55. ** of the edit gadget.
  56. */
  57. TextPrintType TextFlags;
  58. /*
  59. ** Input flags that control what characters are allowed in the string.
  60. */
  61. EditStyle EditFlags;
  62. /*
  63. ** Pointer to text staging buffer and the maximum length of the string it
  64. ** can contain.
  65. */
  66. char *String;
  67. int MaxLength;
  68. /*
  69. ** This is the current length of the string. This length will never exceed the
  70. ** MaxLength allowed.
  71. */
  72. int Length;
  73. /*
  74. ** This is the desired color of the edit control.
  75. */
  76. RemapControlType * Color;
  77. virtual int Action (unsigned flags, KeyNumType &key);
  78. virtual void Draw_Background(void);
  79. virtual void Draw_Text(char const * text);
  80. virtual bool Handle_Key(KeyASCIIType ascii);
  81. private:
  82. int IsReadOnly;
  83. };
  84. //PG inline EditClass::EditStyle operator |(EditClass::EditStyle, EditClass::EditStyle);
  85. //PG inline EditClass::EditStyle operator &(EditClass::EditStyle, EditClass::EditStyle);
  86. //PG inline EditClass::EditStyle operator ~(EditClass::EditStyle);
  87. inline EditClass::EditStyle operator|(EditClass::EditStyle a, EditClass::EditStyle b)
  88. {
  89. return static_cast<EditClass::EditStyle>(static_cast<int>(a) | static_cast<int>(b));
  90. }
  91. inline EditClass::EditStyle operator&(EditClass::EditStyle a, EditClass::EditStyle b)
  92. {
  93. return static_cast<EditClass::EditStyle>(static_cast<int>(a) & static_cast<int>(b));
  94. }
  95. inline EditClass::EditStyle operator~(EditClass::EditStyle a)
  96. {
  97. return static_cast<EditClass::EditStyle>(~static_cast<int>(a));
  98. }
  99. #endif