CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

EDIT.H (4886B)


      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:   F:\projects\c&c\vcs\code\edit.h_v   2.17   16 Oct 1995 16:46:32   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 int  Draw_Me(int forced);
     53 		virtual void Set_Text(char * text, int max_len);
     54 		void Set_Color (int color) { Color = color; }
     55 
     56 		void Set_Read_Only(int rdonly) {IsReadOnly = rdonly;}
     57 
     58 	protected:
     59 
     60 		/*
     61 		**	These are the text size and style flags to be used when displaying the text
     62 		**	of the edit gadget.
     63 		*/
     64 		TextPrintType TextFlags;
     65 
     66 		/*
     67 		**	Input flags that control what characters are allowed in the string.
     68 		*/
     69 		EditStyle EditFlags;
     70 
     71 		/*
     72 		**	Pointer to text staging buffer and the maximum length of the string it
     73 		**	can contain.
     74 		*/
     75 		char *String;
     76 		int MaxLength;
     77 
     78 		/*
     79 		**	This is the current length of the string. This length will never exceed the
     80 		**	MaxLength allowed.
     81 		*/
     82 		int Length;
     83 
     84 		/*
     85 		**	This is the desired color of the edit control.
     86 		*/
     87 		int Color;
     88 
     89 		virtual int Action (unsigned flags, KeyNumType &key);
     90 		virtual void Draw_Background(void);
     91 		virtual void Draw_Text(char const * text);
     92 		virtual bool Handle_Key(KeyASCIIType ascii);
     93 
     94 	private:
     95 		int IsReadOnly;
     96 
     97 };
     98 
     99 //inline EditClass::EditStyle operator |(EditClass::EditStyle, EditClass::EditStyle);
    100 //inline EditClass::EditStyle operator &(EditClass::EditStyle, EditClass::EditStyle);
    101 //inline EditClass::EditStyle operator ~(EditClass::EditStyle);
    102 
    103 inline EditClass::EditStyle operator|(EditClass::EditStyle a, EditClass::EditStyle b)
    104 {return static_cast<EditClass::EditStyle>(static_cast<int>(a) | static_cast<int>(b));}
    105 
    106 inline EditClass::EditStyle operator&(EditClass::EditStyle a, EditClass::EditStyle b)
    107 {return static_cast<EditClass::EditStyle>(static_cast<int>(a) & static_cast<int>(b));}
    108 
    109 inline EditClass::EditStyle operator~(EditClass::EditStyle a)
    110 {return static_cast<EditClass::EditStyle>(~static_cast<int>(a));}
    111 
    112 
    113 #endif