forked from QW-Group/ezquake-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ez_scrollpane.h
134 lines (106 loc) · 4.29 KB
/
ez_scrollpane.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef __EZ_SCROLLPANE_H__
#define __EZ_SCROLLPANE_H__
/*
Copyright (C) 2007 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: ez_scrollpane.h,v 1.55 2007-10-27 14:51:15 cokeman1982 Exp $
*/
#include "ez_controls.h"
#include "ez_scrollbar.h"
// =========================================================================================
// Scrollpane
// =========================================================================================
typedef enum ez_scrollpane_flags_e
{
always_v_scrollbar = (1 << 0),
always_h_scrollbar = (1 << 1)
} ez_scrollpane_flags_t;
typedef enum ez_scrollpane_iflags_e
{
show_v_scrollbar = (1 << 0), // Should the vertical scrollbar be shown?
show_h_scrollbar = (1 << 1), // Should the horizontal scrollbar be shown?
resizing_target = (1 << 2) // Are we resizing the target (if we are, don't care about OnResize events, it'll cause an infinite loop).
} ez_scrollpane_iflags_t;
typedef struct ez_scrollpane_eventcount_s
{
int OnTargetChanged;
int OnScrollbarThicknessChanged;
} ez_scrollpane_eventcount_t;
typedef struct ez_scrollpane_events_s
{
ez_event_fp OnTargetChanged;
ez_event_fp OnTargetResize;
ez_event_fp OnTargetScroll;
ez_event_fp OnScrollbarThicknessChanged;
} ez_scrollpane_events_t;
typedef struct ez_scrollpane_eventhandlers_s
{
ez_eventhandler_t *OnTargetChanged;
ez_eventhandler_t *OnTargetResize;
ez_eventhandler_t *OnTargetScroll;
ez_eventhandler_t *OnScrollbarThicknessChanged;
} ez_scrollpane_eventhandlers_t;
typedef struct ez_scrollpane_s
{
ez_control_t super; // The super class.
ez_scrollpane_events_t events;
ez_scrollpane_eventhandlers_t event_handlers;
ez_scrollpane_eventcount_t inherit_levels;
ez_scrollpane_eventcount_t override_counts;
ez_control_t *target; // The target of the scrollbar if the parent isn't targeted (ext_flag & target_parent).
ez_control_t *prev_target; // The previous target control. We keep this to clean up when we change target.
ez_scrollbar_t *v_scrollbar; // The vertical scrollbar.
ez_scrollbar_t *h_scrollbar; // The horizontal scrollbar.
int scrollbar_thickness; // The thickness of the scrollbars.
ez_scrollpane_flags_t ext_flags; // External flags for the scrollbar.
ez_scrollpane_iflags_t int_flags; // The internal flags for the scrollbar.
} ez_scrollpane_t;
//
// Scrollpane - Creates a new Scrollpane and initializes it.
//
ez_scrollpane_t *EZ_scrollpane_Create(ez_tree_t *tree, ez_control_t *parent,
char *name, char *description,
int x, int y, int width, int height,
ez_control_flags_t flags);
//
// Scrollpane - Initializes a Scrollpane.
//
void EZ_scrollpane_Init(ez_scrollpane_t *scrollpane, ez_tree_t *tree, ez_control_t *parent,
char *name, char *description,
int x, int y, int width, int height,
ez_control_flags_t flags);
//
// Scrollpane - Destroys the scrollpane.
//
int EZ_scrollpane_Destroy(ez_control_t *self, qbool destroy_children);
//
// Scrollpane - Set the target control of the scrollpane (the one to be scrolled).
//
void EZ_scrollpane_SetTarget(ez_scrollpane_t *scrollpane, ez_control_t *target);
//
// Scrollpane - Set the thickness of the scrollbar controls.
//
void EZ_scrollpane_SetScrollbarThickness(ez_scrollpane_t *scrollpane, int scrollbar_thickness);
//
// Scrollpane - The target control changed.
//
int EZ_scrollpane_OnTargetChanged(ez_control_t *self, void *ext_event_info);
//
// Scrollpane - The scrollbar thickness changed.
//
int EZ_scrollpane_OnScrollbarThicknessChanged(ez_control_t *self, void *ext_event_info);
//
// Scrollpane - OnResize event.
//
int EZ_scrollpane_OnResize(ez_control_t *self, void *ext_event_info);
#endif // __EZ_SCROLLPANE_H__