OpenMoHAA 0.82.1
Loading...
Searching...
No Matches
uilistctrl.h
1/*
2===========================================================================
3Copyright (C) 2024 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
25typedef enum {
26 TYPE_STRING,
27 TYPE_OWNERDRAW
28} griditemtype_t;
29
31{
32public:
33 virtual griditemtype_t getListItemType(int which) const = 0;
34 virtual str getListItemString(int which) const = 0;
35 virtual int getListItemValue(int which) const = 0;
36 virtual void DrawListItem(int iColumn, const UIRect2D& drawRect, bool bSelected, UIFont *pFont) = 0;
37 virtual qboolean IsHeaderEntry(void) const = 0;
38};
39
40typedef struct m_clickState_s {
41 int time;
42 int selected;
43 UIPoint2D point;
44} m_clickState_t;
45
46class UIListCtrl : public UIListBase
47{
48public:
49 struct columndef_t {
50 str title;
51 int name;
52 int width;
53 bool numeric;
54 bool reverse_sort;
55 };
56
57protected:
58 static bool s_qsortreverse;
59 static int s_qsortcolumn;
60 static class UIListCtrl *s_qsortobject;
61
62 int m_iLastSortColumn;
63 class UIFont *m_headerfont;
66
67 qboolean m_bDrawHeader;
68
69 struct {
70 int column;
71 int min;
72 } m_sizestate;
73
74 m_clickState_s m_clickState;
75
76 int (*m_comparefunction)(const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname);
77
78public:
79 CLASS_PROTOTYPE(UIListCtrl);
80
81protected:
82 static int StringCompareFunction(const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname);
83 static int StringNumberCompareFunction(const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname);
84 static int QsortCompare(const void *e1, const void *e2);
85 void Draw(void) override;
86 int getHeaderHeight(void);
87 void MousePressed(Event *ev);
88 void MouseDragged(Event *ev);
89 void MouseReleased(Event *ev);
90 void MouseEntered(Event *ev);
91 void OnSizeChanged(Event *ev);
92 void DrawColumns(void);
93 void DrawContent(void);
94
95public:
96 UIListCtrl();
98
99 void FrameInitialized(void) override;
100 void SetDrawHeader(qboolean bDrawHeader);
101 void AddItem(UIListCtrlItem *item);
102 void InsertItem(UIListCtrlItem *item, int where);
103 int FindItem(UIListCtrlItem *item);
104 UIListCtrlItem *GetItem(int item);
105 void AddColumn(str title, int name, int width, bool numeric, bool reverse_sort);
106 void RemoveAllColumns(void);
107 int getNumItems(void) override;
108 void DeleteAllItems(void) override;
109 void DeleteItem(int which) override;
110 virtual void SortByColumn(int column);
111 void SortByLastSortColumn(void);
112 void setCompareFunction(int (*func)(const UIListCtrlItem *i1, const UIListCtrlItem *i2, int columnname));
113 void setHeaderFont(const char *name);
114};
Definition container.h:85
Definition listener.h:246
Definition uifont.h:40
Definition uilistctrl.h:31
Definition uilistctrl.h:47
Definition uipoint2d.h:26
Definition uirect2d.h:29
Definition uiconsole.h:28
Definition str.h:77
Definition uilistctrl.h:49
Definition uilistctrl.h:40