Atrinik Client 2.5
include/list.h
Go to the documentation of this file.
00001 /************************************************************************
00002 *            Atrinik, a Multiplayer Online Role Playing Game            *
00003 *                                                                       *
00004 *    Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team    *
00005 *                                                                       *
00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game)     *
00007 * and Crossfire (Multiplayer game for X-windows).                       *
00008 *                                                                       *
00009 * This program is free software; you can redistribute it and/or modify  *
00010 * it under the terms of the GNU General Public License as published by  *
00011 * the Free Software Foundation; either version 2 of the License, or     *
00012 * (at your option) any later version.                                   *
00013 *                                                                       *
00014 * This program is distributed in the hope that it will be useful,       *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017 * GNU General Public License for more details.                          *
00018 *                                                                       *
00019 * You should have received a copy of the GNU General Public License     *
00020 * along with this program; if not, write to the Free Software           *
00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             *
00022 *                                                                       *
00023 * The author can be reached at admin@atrinik.org                        *
00024 ************************************************************************/
00025 
00030 #ifndef LIST_H
00031 #define LIST_H
00032 
00034 typedef struct list_struct
00035 {
00037     struct list_struct *next;
00038 
00040     struct list_struct *prev;
00041 
00043     uint32 id;
00044 
00046     int x;
00047 
00049     int y;
00050 
00054     int px;
00055 
00059     int py;
00060 
00062     int width;
00063 
00065     uint32 max_rows;
00066 
00068     uint32 rows;
00069 
00071     uint32 cols;
00072 
00074     int spacing;
00075 
00077     uint32 *col_widths;
00078 
00080     int *col_spacings;
00081 
00083     char **col_names;
00084 
00086     uint8 *col_centered;
00087 
00092     char ***text;
00093 
00095     sint16 row_height_adjust;
00096 
00100     sint16 frame_offset;
00101 
00103     uint16 header_height;
00104 
00108     uint32 row_highlighted;
00109 
00113     uint32 row_selected;
00114 
00120     uint32 row_offset;
00121 
00125     uint32 click_tick;
00126 
00128     sint32 repeat_key;
00129 
00133     uint32 repeat_key_ticks;
00134 
00136     uint8 focus;
00137 
00139     uint8 scrollbar_dragging;
00140 
00142     uint8 scrollbar;
00143 
00145     int scrollbar_h;
00146 
00148     int scrollbar_y;
00149 
00151     int font;
00152 
00154     SDL_Surface *surface;
00155 
00157     uint64 text_flags;
00158 
00163     void (*draw_frame_func)(struct list_struct *list);
00164 
00170     void (*row_color_func)(struct list_struct *list, int row, SDL_Rect box);
00171 
00176     void (*row_highlight_func)(struct list_struct *list, SDL_Rect box);
00177 
00182     void (*row_selected_func)(struct list_struct *list, SDL_Rect box);
00183 
00187     void (*handle_esc_func)(struct list_struct *list);
00188 
00193     void (*handle_enter_func)(struct list_struct *list);
00194 
00202     int (*key_event_func)(struct list_struct *list, SDLKey key);
00203 
00211     const char *(*text_color_hook)(struct list_struct *list, const char *default_color, uint32 row, uint32 col);
00212 
00213     void (*post_column_func)(struct list_struct *list, uint32 row, uint32 col);
00214 
00215     void (*handle_mouse_row_func)(struct list_struct *list, uint32 row, SDL_Event *event);
00216 } list_struct;
00217 
00223 #define LIST_SERVERS 1
00224 
00225 #define LIST_NEWS 2
00226 
00227 #define LIST_CREATION 3
00228 
00229 #define LIST_MPLAYER 4
00230 
00231 #define LIST_SPELLS 5
00232 
00233 #define LIST_SKILLS 6
00234 
00235 #define LIST_PARTY 7
00236 
00237 #define LIST_SETTINGS 8
00238 
00241 #define LIST_ROW_HEIGHT(list) (FONT_HEIGHT((list)->font) + (list)->row_height_adjust)
00242 
00243 #define LIST_ROWS_START(list) ((list)->y + (list)->header_height + (list)->spacing)
00244 
00245 #define LIST_ROWS_MAX(list) ((uint32) ((list)->height + (list)->spacing) / LIST_ROW_HEIGHT((list)))
00246 
00247 #define LIST_ROWS_HEIGHT(list) (LIST_ROW_HEIGHT((list)) * (list)->max_rows)
00248 
00251 #define LIST_ROW_OFFSET(row, list) ((row) - (list)->row_offset)
00252 
00253 #define LIST_HEIGHT_FULL(list) ((int) LIST_ROWS_HEIGHT((list)) + (list)->spacing + (list)->header_height)
00254 
00255 #define LIST_MOUSE_OVER(list, mx, my) ((mx) > (list)->x && (mx) < (list)->x + (list)->width + LIST_SCROLLBAR_WIDTH && (my) > (list)->y && (my) < (list)->y + LIST_HEIGHT_FULL((list)))
00256 
00257 #define LIST_SCROLLBAR_WIDTH 6
00258 
00264 #define LIST_SORT_ALPHA 1
00265 
00268 #define DOUBLE_CLICK_DELAY 300
00269 
00270 #define KEY_REPEAT_DELAY 25
00271 
00272 #define KEY_REPEAT_DELAY_INIT 175
00273 
00274 #endif