OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
uilistbox.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25extern Event EV_Layout_AddListItem;
26extern Event EV_UIListBase_ItemDoubleClicked;
27extern Event EV_UIListBase_ItemSelected;
28
29class UIListBase : public UIWidget
30{
31protected:
32 int m_currentItem;
33 class UIVertScroll *m_vertscroll;
34 qboolean m_bUseVertScroll;
35
36public:
37 CLASS_PROTOTYPE(UIListBase);
38
39protected:
40 virtual void TrySelectItem(int which);
41 qboolean KeyEvent(int key, unsigned int time) override;
42
43public:
44 UIListBase();
45
46 void FrameInitialized(void) override;
47 int getCurrentItem(void);
48 virtual int getNumItems(void);
49 virtual void DeleteAllItems(void);
50 virtual void DeleteItem(int which);
51 UIVertScroll *GetScrollBar(void);
52 void SetUseScrollBar(qboolean bUse);
53};
54typedef class UIListBase UIListBase;
55
56class ListItem : public Class
57{
58public:
59 str string;
60 str command;
61 int index;
62
63public:
64 ListItem();
65 ListItem(str string, int index, str command);
66};
67
68class UIListBox : public UIListBase
69{
70protected:
71 Container<ListItem *> m_itemlist;
72
73 struct {
74 int time;
75 int selected;
76 UIPoint2D point;
77 } m_clickState;
78
79public:
80 CLASS_PROTOTYPE(UIListBox);
81
82protected:
83 void Draw(void) override;
84 void MousePressed(Event *ev);
85 void MouseReleased(Event *ev);
86 void DeleteAllItems(Event *ev);
87 void SetListFont(Event *ev);
88 void TrySelectItem(int which) override;
89
90public:
91 UIListBox();
92
93 void AddItem(const char *item, const char *command);
94 void AddItem(int index, const char *command);
95 void FrameInitialized(void) override;
96 void LayoutAddListItem(Event *ev);
97 void LayoutAddConfigstringListItem(Event *ev);
98 str getItemText(int which);
99 int getNumItems(void) override;
100 void DeleteAllItems(void) override;
101 void DeleteItem(int which) override;
102 void InsertItem(const char *string, int which, const char *command = NULL);
103 void setCurrentItem(int which);
104};
Definition container.h:85
Definition listener.h:246
Definition uilistbox.h:30
Definition uipoint2d.h:25
Definition uivertscroll.h:31
Definition uiconsole.h:27
Definition str.h:77