ScummVM API documentation
WidgetTextBox.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_WIDGET_TEXT_BOX_H
29 #define HPL_WIDGET_TEXT_BOX_H
30 
31 #include "hpl1/engine/gui/Widget.h"
32 
33 namespace hpl {
34 
35 class cGuiSkinFont;
36 
37 class cWidgetTextBox : public iWidget {
38 public:
39  cWidgetTextBox(cGuiSet *apSet, cGuiSkin *apSkin);
40  virtual ~cWidgetTextBox();
41 
42  void SetMaxTextLength(int alLength);
43  int GetMaxTextLength() { return mlMaxCharacters; }
44 
45  cVector2f GetBackgroundSize();
46 
47  void SetMaxTextSizeNeg(float afX);
48 
49  void SetCanEdit(bool abX);
50  bool GetCanEdit() { return mbCanEdit; }
51 
52 protected:
54  // Own functions
55  int WorldToCharPos(const cVector2f &avWorldPos);
56  float CharToLocalPos(int alChar);
57  void SetMarkerPos(int alPos);
58  int GetLastCharInSize(int alStartPos, float afMaxSize, float afLengthAdd);
59  int GetFirstCharInSize(int alStartPos, float afMaxSize, float afLengthAdd);
60 
62  // Implemented functions
63  void OnLoadGraphics();
64  void OnChangeSize();
65  void OnChangeText();
66 
67  void OnDraw(float afTimeStep, cGuiClipRegion *apClipRegion);
68 
69  bool OnMouseMove(cGuiMessageData &aData);
70  bool OnMouseDown(cGuiMessageData &aData);
71  bool OnMouseDoubleClick(cGuiMessageData &aData);
72  bool OnMouseUp(cGuiMessageData &aData);
73  bool OnMouseEnter(cGuiMessageData &aData);
74  bool OnMouseLeave(cGuiMessageData &aData);
75 
76  bool OnLostFocus(cGuiMessageData &aData);
77 
78  bool OnKeyPress(cGuiMessageData &aData);
79 
81  // Data
82  bool mbPressed;
83  int mlMarkerCharPos;
84  int mlSelectedTextEnd;
85  int mlFirstVisibleChar;
86  int mlVisibleCharSize;
87  float mfTextMaxSize;
88 
89  int mlMaxCharacters;
90 
91  float mfMaxTextSizeNeg;
92 
93  bool mbCanEdit;
94 
95  cGuiGfxElement *mpGfxMarker;
96  cGuiGfxElement *mpGfxSelectedTextBack;
97 
98  cGuiGfxElement *mpGfxBackground;
99 
100  cGuiGfxElement *mvGfxBorders[4];
101  cGuiGfxElement *mvGfxCorners[4];
102 };
103 
104 } // namespace hpl
105 
106 #endif // HPL_WIDGET_TEXT_BOX_H
Definition: AI.h:36
Definition: WidgetTextBox.h:37
Definition: GuiGfxElement.h:72
Definition: GuiTypes.h:263
Definition: Widget.h:65
Definition: GuiSet.h:112
Definition: GuiSet.h:96
Definition: GuiSkin.h:59