webperimental: Mountain vision bonus.
[freeciv.git] / client / gui-sdl2 / widget_scrollbar.h
bloba993893e1dd3cc6be29b8a78a796fc6ff18e9468
1 /**********************************************************************
2 Freeciv - Copyright (C) 2006 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifndef FC__WIDGET_SCROLLBAR_H
15 #define FC__WIDGET_SCROLLBAR_H
17 #include "widget.h"
19 struct ScrollBar {
20 struct widget *pUp_Left_Button;
21 struct widget *pScrollBar;
22 struct widget *pDown_Right_Button;
23 Uint8 active; /* used by scroll: numbers of displayed rows */
24 Uint8 step; /* used by scroll: numbers of displayed columns */
25 /* total dispalyed widget = active * step */
26 Uint16 count; /* total size of scroll list */
27 Sint16 min; /* used by scroll: min pixel position */
28 Sint16 max; /* used by scroll: max pixel position */
31 #define scrollbar_size(pScroll) \
32 ((float)((float)(pScroll->active * pScroll->step) / \
33 (float)pScroll->count) * (pScroll->max - pScroll->min))
35 #define hide_scrollbar(scrollbar) \
36 do { \
37 if (scrollbar->pUp_Left_Button) { \
38 if (!(get_wflags(scrollbar->pUp_Left_Button) & WF_HIDDEN)) {\
39 widget_undraw(scrollbar->pUp_Left_Button); \
40 widget_mark_dirty(scrollbar->pUp_Left_Button); \
41 set_wflag(scrollbar->pUp_Left_Button, WF_HIDDEN); \
42 } \
43 if (!(get_wflags(scrollbar->pDown_Right_Button) & WF_HIDDEN)) {\
44 widget_undraw(scrollbar->pDown_Right_Button); \
45 widget_mark_dirty(scrollbar->pDown_Right_Button); \
46 set_wflag(scrollbar->pDown_Right_Button, WF_HIDDEN); \
47 } \
48 } \
49 if (scrollbar->pScrollBar) { \
50 if (!(get_wflags(scrollbar->pScrollBar) & WF_HIDDEN)) { \
51 widget_undraw(scrollbar->pScrollBar); \
52 widget_mark_dirty(scrollbar->pScrollBar); \
53 set_wflag(scrollbar->pScrollBar, WF_HIDDEN); \
54 } \
55 } \
56 } while (FALSE)
58 #define show_scrollbar(scrollbar) \
59 do { \
60 if (scrollbar->pUp_Left_Button) { \
61 clear_wflag(scrollbar->pUp_Left_Button, WF_HIDDEN); \
62 clear_wflag(scrollbar->pDown_Right_Button, WF_HIDDEN); \
63 } \
64 if (scrollbar->pScrollBar) { \
65 clear_wflag(scrollbar->pScrollBar, WF_HIDDEN); \
66 } \
67 } while (FALSE)
69 /* VERTICAL */
70 struct widget *create_vertical(SDL_Surface *pVert_theme, struct gui_layer *pDest,
71 Uint16 high, Uint32 flags);
72 int draw_vert(struct widget *pVert, Sint16 x, Sint16 y);
74 Uint32 create_vertical_scrollbar(struct ADVANCED_DLG *pDlg,
75 Uint8 step, Uint8 active, bool create_scrollbar,
76 bool create_buttons);
78 void setup_vertical_scrollbar_area(struct ScrollBar *pScroll,
79 Sint16 start_x, Sint16 start_y, Uint16 hight,
80 bool swap_start_x);
82 void setup_vertical_scrollbar_default_callbacks(struct ScrollBar *pScroll);
84 /* HORIZONTAL */
85 struct widget *create_horizontal(SDL_Surface *pHoriz_theme, struct gui_layer *pDest,
86 Uint16 width, Uint32 flags);
87 int draw_horiz(struct widget *pHoriz, Sint16 x, Sint16 y);
89 Uint32 create_horizontal_scrollbar(struct ADVANCED_DLG *pDlg,
90 Sint16 start_x, Sint16 start_y,
91 Uint16 width, Uint16 active,
92 bool create_scrollbar, bool create_buttons,
93 bool swap_start_y);
95 #endif /* FC__WIDGET_SCROLLBAR_H */