Freeciv-3.2
Loading...
Searching...
No Matches
widget_scrollbar.h
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifndef FC__WIDGET_SCROLLBAR_H
15#define FC__WIDGET_SCROLLBAR_H
16
17/* gui-sdl3 */
18#include "widget.h"
19
20struct scroll_bar {
21 struct widget *up_left_button;
22 struct widget *pscroll_bar;
24 Uint8 active; /* used by scroll: numbers of displayed rows */
25 Uint8 step; /* used by scroll: numbers of displayed columns */
26 /* total displayed widget = active * step */
27 Uint16 count; /* total size of scroll list */
28 Sint16 min; /* used by scroll: min pixel position */
29 Sint16 max; /* used by scroll: max pixel position */
30};
31
32#define scrollbar_size(scroll) \
33 ((float)((float)(scroll->active * scroll->step) / \
34 (float)scroll->count) * (scroll->max - scroll->min))
35
36#define hide_scrollbar(scrollbar) \
37do { \
38 if (scrollbar->up_left_button) { \
39 if (!(get_wflags(scrollbar->up_left_button) & WF_HIDDEN)) {\
40 widget_undraw(scrollbar->up_left_button); \
41 widget_mark_dirty(scrollbar->up_left_button); \
42 set_wflag(scrollbar->up_left_button, WF_HIDDEN); \
43 } \
44 if (!(get_wflags(scrollbar->down_right_button) & WF_HIDDEN)) {\
45 widget_undraw(scrollbar->down_right_button); \
46 widget_mark_dirty(scrollbar->down_right_button); \
47 set_wflag(scrollbar->down_right_button, WF_HIDDEN); \
48 } \
49 } \
50 if (scrollbar->pscroll_bar) { \
51 if (!(get_wflags(scrollbar->pscroll_bar) & WF_HIDDEN)) { \
52 widget_undraw(scrollbar->pscroll_bar); \
53 widget_mark_dirty(scrollbar->pscroll_bar); \
54 set_wflag(scrollbar->pscroll_bar, WF_HIDDEN); \
55 } \
56 } \
57} while (FALSE)
58
59#define show_scrollbar(scrollbar) \
60do { \
61 if (scrollbar->up_left_button) { \
62 clear_wflag(scrollbar->up_left_button, WF_HIDDEN); \
63 clear_wflag(scrollbar->down_right_button, WF_HIDDEN); \
64 } \
65 if (scrollbar->pscroll_bar) { \
66 clear_wflag(scrollbar->pscroll_bar, WF_HIDDEN); \
67 } \
68} while (FALSE)
69
70/* VERTICAL */
72 Uint16 height, Uint32 flags);
73int draw_vert(struct widget *vert, Sint16 x, Sint16 y);
74
76 Uint8 step, Uint8 active,
78
81 bool swap_start_x);
82
84
85/* HORIZONTAL */
87 struct gui_layer *pdest,
88 Uint16 width, Uint32 flags);
89int draw_horiz(struct widget *horiz, Sint16 x, Sint16 y);
90
92 Sint16 start_x, Sint16 start_y,
93 Uint16 width, Uint16 active,
95 bool swap_start_y);
96
97#endif /* FC__WIDGET_SCROLLBAR_H */
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
char * incite_cost
Definition comments.c:75
int draw_vert(struct widget *vert, Sint16 x, Sint16 y)
Uint32 create_horizontal_scrollbar(struct advanced_dialog *dlg, Sint16 start_x, Sint16 start_y, Uint16 width, Uint16 active, bool create_scrollbar, bool create_buttons, bool swap_start_y)
struct widget * create_horizontal(SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
int draw_horiz(struct widget *horiz, Sint16 x, Sint16 y)
void setup_vertical_scrollbar_default_callbacks(struct scroll_bar *scroll)
struct widget * create_vertical(SDL_Surface *vert_theme, struct gui_layer *pdest, Uint16 height, Uint32 flags)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
int step
Definition specpq.h:92
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
struct widget * up_left_button
struct widget * down_right_button
struct widget * pscroll_bar