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)
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
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) \
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); \
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); \
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); \
58 #define show_scrollbar(scrollbar) \
60 if (scrollbar->pUp_Left_Button) { \
61 clear_wflag(scrollbar->pUp_Left_Button, WF_HIDDEN); \
62 clear_wflag(scrollbar->pDown_Right_Button, WF_HIDDEN); \
64 if (scrollbar->pScrollBar) { \
65 clear_wflag(scrollbar->pScrollBar, WF_HIDDEN); \
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
,
78 void setup_vertical_scrollbar_area(struct ScrollBar
*pScroll
,
79 Sint16 start_x
, Sint16 start_y
, Uint16 hight
,
82 void setup_vertical_scrollbar_default_callbacks(struct ScrollBar
*pScroll
);
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
,
95 #endif /* FC__WIDGET_SCROLLBAR_H */