EDIT.H (4990B)
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 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/EDIT.H 1 3/03/97 10:24a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : EDIT.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 01/15/95 * 28 * * 29 * Last Update : January 15, 1995 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef EDIT_H 36 #define EDIT_H 37 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 49 EditClass (int id, char * text, int max_len, TextPrintType flags, int x, int y, int w=-1, int h=-1, EditStyle style=ALPHANUMERIC); 50 virtual ~EditClass(void); 51 52 virtual void Set_Focus(void); 53 virtual int Draw_Me(int forced); 54 virtual void Set_Text(char * text, int max_len); 55 virtual char * Get_Text(void) {return(String);}; 56 void Set_Color (RemapControlType * color) { Color = color; } 57 58 void Set_Read_Only(int rdonly) {IsReadOnly = rdonly;} 59 60 protected: 61 62 /* 63 ** These are the text size and style flags to be used when displaying the text 64 ** of the edit gadget. 65 */ 66 TextPrintType TextFlags; 67 68 /* 69 ** Input flags that control what characters are allowed in the string. 70 */ 71 EditStyle EditFlags; 72 73 /* 74 ** Pointer to text staging buffer and the maximum length of the string it 75 ** can contain. 76 */ 77 char *String; 78 int MaxLength; 79 80 /* 81 ** This is the current length of the string. This length will never exceed the 82 ** MaxLength allowed. 83 */ 84 int Length; 85 86 /* 87 ** This is the desired color of the edit control. 88 */ 89 RemapControlType * Color; 90 91 virtual int Action (unsigned flags, KeyNumType &key); 92 virtual void Draw_Background(void); 93 virtual void Draw_Text(char const * text); 94 virtual bool Handle_Key(KeyASCIIType ascii); 95 96 private: 97 int IsReadOnly; 98 }; 99 100 //PG inline EditClass::EditStyle operator |(EditClass::EditStyle, EditClass::EditStyle); 101 //PG inline EditClass::EditStyle operator &(EditClass::EditStyle, EditClass::EditStyle); 102 //PG inline EditClass::EditStyle operator ~(EditClass::EditStyle); 103 104 inline EditClass::EditStyle operator|(EditClass::EditStyle a, EditClass::EditStyle b) 105 { 106 return static_cast<EditClass::EditStyle>(static_cast<int>(a) | static_cast<int>(b)); 107 } 108 109 inline EditClass::EditStyle operator&(EditClass::EditStyle a, EditClass::EditStyle b) 110 { 111 return static_cast<EditClass::EditStyle>(static_cast<int>(a) & static_cast<int>(b)); 112 } 113 114 inline EditClass::EditStyle operator~(EditClass::EditStyle a) 115 { 116 return static_cast<EditClass::EditStyle>(~static_cast<int>(a)); 117 } 118 119 120 #endif