1 //=============================================================================
2 //
3 // Adventure Game Studio (AGS)
4 //
5 // Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
6 // The full list of copyright holders can be found in the Copyright.txt
7 // file, which is part of this source code distribution.
8 //
9 // The AGS source code is provided under the Artistic License 2.0.
10 // A copy of this license can be found in the file License.txt and at
11 // http://www.opensource.org/licenses/artistic-license-2.0.php
12 //
13 //=============================================================================
14 
15 #ifndef __AC_GUILISTBOX_H
16 #define __AC_GUILISTBOX_H
17 
18 #include <vector>
19 #include "gui/guiobject.h"
20 #include "util/string.h"
21 
22 struct GUIListBox:public GUIObject
23 {
24   AGS::Common::String items[MAX_LISTBOX_ITEMS];
25   short saveGameIndex[MAX_LISTBOX_ITEMS];
26   int numItems, selected, topItem, mousexp, mouseyp;
27   int rowheight, num_items_fit;
28   int font, textcol, backcol, exflags;
29   int selectedbgcol;
30   int alignment, reserved1;
31   virtual void WriteToFile(Common::Stream *out);
32   virtual void ReadFromFile(Common::Stream *in, GuiVersion gui_version);
33   int  AddItem(const char *toadd);
34   int  InsertItem(int index, const char *toadd);
35   void SetItemText(int index, const char *newtext);
36   void RemoveItem(int index);
37   void Clear();
38   virtual void Draw(Common::Bitmap *ds);
39   int  IsInRightMargin(int x);
40   int  GetIndexFromCoordinates(int x, int y);
41   void ChangeFont(int newFont);
42   virtual int MouseDown();
43 
MouseMoveGUIListBox44   void MouseMove(int nx, int ny)
45   {
46     mousexp = nx - x;
47     mouseyp = ny - y;
48   }
49 
MouseOverGUIListBox50   void MouseOver()
51   {
52   }
53 
MouseLeaveGUIListBox54   void MouseLeave()
55   {
56   }
57 
MouseUpGUIListBox58   void MouseUp()
59   {
60   }
61 
KeyPressGUIListBox62   void KeyPress(int kp)
63   {
64   }
65 
66   virtual void Resized();
67 
resetGUIListBox68   void reset()
69   {
70     GUIObject::init();
71     mousexp = 0;
72     mouseyp = 0;
73     activated = 0;
74     numItems = 0;
75     topItem = 0;
76     selected = 0;
77     font = 0;
78     textcol = 0;
79     selectedbgcol = 16;
80     backcol = 7;
81     exflags = 0;
82     rowheight = 0;
83     num_items_fit = 0;
84     alignment = GALIGN_LEFT;
85     numSupportedEvents = 1;
86     supportedEvents[0] = "SelectionChanged";
87     supportedEventArgs[0] = "GUIControl *control";
88   }
89 
GUIListBoxGUIListBox90   GUIListBox() {
91     reset();
92   }
93 
~GUIListBoxGUIListBox94   virtual ~GUIListBox()
95   {
96     for (int i = 0; i < numItems; i++)
97       items[i].Free();
98   }
99 
100 private:
101   int numItemsTemp;
102 
103   void Draw_items_fix();
104   void Draw_items_unfix();
105   void Draw_set_oritext(char *oritext, const char *text);
106 };
107 
108 extern std::vector<GUIListBox> guilist;
109 extern int numguilist;
110 
111 #endif // __AC_GUILISTBOX_H
112