Atrinik Client  4.0
list.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
30 #ifndef LIST_H
31 #define LIST_H
32 
34 typedef struct list_struct {
36  int x;
37 
39  int y;
40 
45  int px;
46 
51  int py;
52 
54  int width;
55 
57  uint32_t max_rows;
58 
60  uint32_t rows;
61 
63  uint32_t cols;
64 
66  int spacing;
67 
69  uint32_t *col_widths;
70 
73 
75  char **col_names;
76 
78  uint8_t *col_centered;
79 
85  char ***text;
86 
89 
94  int16_t frame_offset;
95 
97  uint16_t header_height;
98 
103  uint32_t row_highlighted;
104 
109  uint32_t row_selected;
110 
117  uint32_t row_offset;
118 
123  uint32_t click_tick;
124 
126  uint8_t focus;
127 
130 
133 
136 
138  SDL_Surface *surface;
139 
141  uint64_t text_flags;
142 
147  void *data;
148 
155  void (*draw_frame_func)(struct list_struct *list);
156 
166  void (*row_color_func)(struct list_struct *list, int row, SDL_Rect box);
167 
175  void (*row_highlight_func)(struct list_struct *list, SDL_Rect box);
176 
184  void (*row_selected_func)(struct list_struct *list, SDL_Rect box);
185 
191  void (*handle_esc_func)(struct list_struct *list);
192 
201  void (*handle_enter_func)(struct list_struct *list, SDL_Event *event);
202 
214  int (*key_event_func)(struct list_struct *list, SDLKey key);
215 
228  void (*text_color_hook)(struct list_struct *list, uint32_t row, uint32_t col, const char **color, const char **color_shadow);
229 
239  void (*post_column_func)(struct list_struct *list, uint32_t row, uint32_t col);
240 
252  void (*handle_mouse_row_func)(struct list_struct *list, uint32_t row, SDL_Event *event);
253 } list_struct;
254 
256 #define LIST_ROW_HEIGHT(list) (((list)->font != NULL ? FONT_HEIGHT((list)->font) : 0) + (list)->row_height_adjust)
257 
258 #define LIST_ROWS_START(list) ((list)->y + (list)->header_height + (list)->spacing + (list)->frame_offset)
259 
260 #define LIST_ROWS_MAX(list) ((uint32_t) ((list)->height + (list)->spacing) / LIST_ROW_HEIGHT((list)))
261 
262 #define LIST_ROWS_HEIGHT(list) (LIST_ROW_HEIGHT((list)) * (list)->max_rows)
263 
267 #define LIST_ROW_OFFSET(row, list) ((row) - (list)->row_offset)
268 
271 #define LIST_HEIGHT_FULL(list) ((int) LIST_ROWS_HEIGHT((list)) + (list)->spacing + (list)->header_height)
272 
276 #define LIST_WIDTH_FULL(list) ((list)->width + ((list)->scrollbar_enabled ? (list)->scrollbar.background.w : 0))
277 
278 #define LIST_MOUSE_OVER(list, mx, my) ((mx) > (list)->x && (mx) < (list)->x + LIST_WIDTH_FULL((list)) && (my) > (list)->y && (my) < (list)->y + LIST_HEIGHT_FULL((list)))
279 
285 #define LIST_SORT_ALPHA 1
286 
289 #define DOUBLE_CLICK_DELAY 300
290 
291 #endif
int spacing
Definition: list.h:66
void(* row_selected_func)(struct list_struct *list, SDL_Rect box)
Definition: list.h:184
void * data
Definition: list.h:147
font_struct * font
Definition: list.h:135
uint8_t focus
Definition: list.h:126
int x
Definition: list.h:36
uint8_t scrollbar_enabled
Definition: list.h:129
uint8_t * col_centered
Definition: list.h:78
int16_t frame_offset
Definition: list.h:94
int y
Definition: list.h:39
void(* draw_frame_func)(struct list_struct *list)
Definition: list.h:155
uint32_t row_offset
Definition: list.h:117
uint64_t text_flags
Definition: list.h:141
int px
Definition: list.h:45
char *** text
Definition: list.h:85
int py
Definition: list.h:51
void(* handle_mouse_row_func)(struct list_struct *list, uint32_t row, SDL_Event *event)
Definition: list.h:252
uint32_t click_tick
Definition: list.h:123
uint32_t row_highlighted
Definition: list.h:103
int * col_spacings
Definition: list.h:72
void(* row_color_func)(struct list_struct *list, int row, SDL_Rect box)
Definition: list.h:166
void(* text_color_hook)(struct list_struct *list, uint32_t row, uint32_t col, const char **color, const char **color_shadow)
Definition: list.h:228
struct list_struct list_struct
uint32_t max_rows
Definition: list.h:57
void(* row_highlight_func)(struct list_struct *list, SDL_Rect box)
Definition: list.h:175
void(* post_column_func)(struct list_struct *list, uint32_t row, uint32_t col)
Definition: list.h:239
int width
Definition: list.h:54
SDL_Surface * surface
Definition: list.h:138
uint32_t * col_widths
Definition: list.h:69
char ** col_names
Definition: list.h:75
uint16_t header_height
Definition: list.h:97
void(* handle_esc_func)(struct list_struct *list)
Definition: list.h:191
int16_t row_height_adjust
Definition: list.h:88
scrollbar_struct scrollbar
Definition: list.h:132
uint32_t cols
Definition: list.h:63
int(* key_event_func)(struct list_struct *list, SDLKey key)
Definition: list.h:214
uint32_t rows
Definition: list.h:60
void(* handle_enter_func)(struct list_struct *list, SDL_Event *event)
Definition: list.h:201
uint32_t row_selected
Definition: list.h:109