1 /////////////////////////////////////////
2 //
3 //             OpenLieroX
4 //
5 // code under LGPL, based on JasonBs work,
6 // enhanced by Dark Charlie and Albert Zeyer
7 //
8 //
9 /////////////////////////////////////////
10 
11 
12 // Input box
13 // Created 31/7/02
14 // Jason Boettcher
15 
16 
17 #ifndef __CINPUTBOX_H__DEPRECATED_GUI__
18 #define __CINPUTBOX_H__DEPRECATED_GUI__
19 
20 #include "InputEvents.h"
21 #include "DeprecatedGUI/CGuiSkinnedLayout.h"
22 
23 namespace DeprecatedGUI {
24 
25 // Inputbox events
26 enum {
27 	INB_NONE=-1,
28 	INB_MOUSEUP
29 };
30 
31 
32 // inputbox messages
33 enum {
34 	INM_GETVALUE=0,
35 	INS_GETTEXT
36 };
37 
38 
39 class CInputbox : public CWidget {
40 public:
41 	// Constructor
CInputbox(int val,const std::string & _text,SmartPointer<SDL_Surface> img,const std::string & name)42 	CInputbox(int val, const std::string& _text, SmartPointer<SDL_Surface> img, const std::string& name) {
43 		iKeyvalue = val;
44 		sText = _text;
45 		sName = name;
46 
47 		bmpImage = img;
48 		iType = wid_Inputbox;
49 		bMouseOver = false;
50 		sVar = NULL;
51 	}
52 
53 
54 private:
55 	// Attributes
56 
57 	int			iKeyvalue;
58 	std::string	sText;
59 	SmartPointer<SDL_Surface> bmpImage;
60 	bool		bMouseOver;
61 	std::string	sName;
62 
63 	std::string		*sVar;
64 
65 public:
66 	// Methods
67 
Create()68 	void	Create() { }
Destroy()69 	void	Destroy() { }
70 
71 	//These events return an event id, otherwise they return -1
MouseOver(mouse_t * tMouse)72 	int		MouseOver(mouse_t *tMouse)			{ bMouseOver = true; return INB_NONE; }
MouseUp(mouse_t * tMouse,int nDown)73 	int		MouseUp(mouse_t *tMouse, int nDown)		{ return INB_MOUSEUP; }
MouseDown(mouse_t * tMouse,int nDown)74 	int		MouseDown(mouse_t *tMouse, int nDown)	{ return INB_NONE; }
MouseWheelDown(mouse_t * tMouse)75 	int		MouseWheelDown(mouse_t *tMouse)		{ return INB_NONE; }
MouseWheelUp(mouse_t * tMouse)76 	int		MouseWheelUp(mouse_t *tMouse)		{ return INB_NONE; }
KeyDown(UnicodeChar c,int keysym,const ModifiersState & modstate)77 	int		KeyDown(UnicodeChar c, int keysym, const ModifiersState& modstate)	{ return INB_NONE; }
78 	int		KeyUp(UnicodeChar c, int keysym, const ModifiersState& modstate); // return event on key up so we won't process that same event inside key reader
79 
80 
81 	// Process a message sent
SendMessage(int iMsg,DWORD Param1,DWORD Param2)82 	inline DWORD SendMessage(int iMsg, DWORD Param1, DWORD Param2) {
83 
84 				if(iMsg == INM_GETVALUE) {
85 						return iKeyvalue;
86 				}
87 
88 				return 0;
89 			}
90 
SendMessage(int iMsg,const std::string & sStr,DWORD Param)91 	DWORD SendMessage(int iMsg, const std::string& sStr, DWORD Param) { return 0; }
SendMessage(int iMsg,std::string * sStr,DWORD Param)92 	DWORD SendMessage(int iMsg, std::string *sStr, DWORD Param)  {
93 		if (iMsg == INS_GETTEXT)  {
94 			*sStr = sText;
95 		}
96 		return 0;
97 	}
98 
99 	// Draw the title button
100 	void	Draw(SDL_Surface * bmpDest);
101 
102 
getValue()103 	inline int		getValue()						{ return iKeyvalue; }
setValue(int _v)104 	inline void	setValue(int _v)					{ iKeyvalue = _v; }
getText()105 	inline std::string	getText()				{ return sText; }
setText(const std::string & _t)106 	inline void	setText(const std::string& _t)		{ sText = _t; }
getName()107 	inline std::string	getName()				{ return sName; }
108 
109 	static CInputbox * InputBoxSelected;
110 	static std::string InputBoxLabel;	// "GUI.InputBoxLabel" skin string
111 };
112 
113 } // namespace DeprecatedGUI
114 
115 #endif  //  __CINPUTBOX_H__DEPRECATED_GUI__
116