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