forked from QW-Group/ezquake-source
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ctrl_Tab.h
109 lines (80 loc) · 2.55 KB
/
Ctrl_Tab.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Copyright (C) 2011 azazello and ezQuake team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Tab Control
#ifndef __CTRL_TAB_H__
#define __CTRL_TAB_H__
#include "keys.h"
#define TAB_MAX_NAME_LENGTH 15
#define TAB_MAX_TABS 16
struct CTab_s;
struct CTabPage_s;
typedef void (*CTabPage_OnShowType) (void);
typedef void (*CTabPage_DrawType)(int x, int y, int w, int h, struct CTab_s *, struct CTabPage_s *);
typedef int (*CTabPage_KeyType)(int key, wchar unichar, struct CTab_s *, struct CTabPage_s *);
typedef qbool (*CTabPage_MouseMoveType) (const mouse_state_t * ms);
typedef struct CTabPage_Handlers_s
{
CTabPage_DrawType draw;
CTabPage_KeyType key;
CTabPage_OnShowType onshow;
CTabPage_MouseMoveType mousemove;
}
CTabPage_Handlers_t;
typedef struct CTabPage_s
{
char name[TAB_MAX_NAME_LENGTH+1];
int id;
CTabPage_Handlers_t handlers;
}
CTabPage_t;
typedef struct CTab_s
{
CTabPage_t pages[TAB_MAX_TABS];
int nPages;
int activePage;
int lastViewedPage;
int hoveredPage;
int width;
int height;
struct { int x, y, x2, y2; } navi_boxes[TAB_MAX_TABS];
void *tag;
}
CTab_t;
// initialize control
void CTab_Init(CTab_t *);
// clear control
void CTab_Clear(CTab_t *);
// create new control
CTab_t * CTab_New(void);
// free control
void CTab_Free(CTab_t *);
// add tab
void CTab_AddPage(CTab_t *, const char *name, int id, const CTabPage_Handlers_t *handlers);
// draw control
void CTab_Draw(CTab_t *, int x, int y, int w, int h);
// process key
int CTab_Key(CTab_t *, int key, wchar unichar);
// process mouse move event
qbool CTab_Mouse_Event(CTab_t *, const mouse_state_t *ms);
// get current page
CTabPage_t * CTab_GetCurrent(CTab_t *);
// get current page id
int CTab_GetCurrentId(CTab_t *);
// get current page name
char * CTab_GetCurrentPage(CTab_t *);
// set current page by ID
void CTab_SetCurrentId(CTab_t *, int);
// set current page by string
void CTab_SetCurrentPage(CTab_t *, char *);
#endif // __CTRL_TAB_H__