Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/widget_scrollbar.h Source File

Freeciv-3.1

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-sdl2 */
18#include "widget.h"
19
20 struct scroll_bar {
21 struct widget *up_left_button;
22 struct widget *pscroll_bar;
23 struct widget *down_right_button;
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 */
71struct widget *create_vertical(SDL_Surface *vert_theme, struct gui_layer *pdest,
72 Uint16 height, Uint32 flags);
73int draw_vert(struct widget *vert, Sint16 x, Sint16 y);
74
75 Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg,
76 Uint8 step, Uint8 active,
77 bool create_scrollbar, bool create_buttons);
78
79void setup_vertical_scrollbar_area(struct scroll_bar *scroll,
80 Sint16 start_x, Sint16 start_y, Uint16 hight,
81 bool swap_start_x);
82
83void setup_vertical_scrollbar_default_callbacks(struct scroll_bar *scroll);
84
85/* HORIZONTAL */
86struct widget *create_horizontal(SDL_Surface *horiz_theme,
87 struct gui_layer *pdest,
88 Uint16 width, Uint32 flags);
89int draw_horiz(struct widget *horiz, Sint16 x, Sint16 y);
90
91 Uint32 create_horizontal_scrollbar(struct advanced_dialog *dlg,
92 Sint16 start_x, Sint16 start_y,
93 Uint16 width, Uint16 active,
94 bool create_scrollbar, bool create_buttons,
95 bool swap_start_y);
96
97#endif /* FC__WIDGET_SCROLLBAR_H */
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
step
int step
Definition specpq.h:92
advanced_dialog
Definition widget.h:180
gui_layer
Definition graphics.h:227
scroll_bar
Definition widget_scrollbar.h:20
scroll_bar::up_left_button
struct widget * up_left_button
Definition widget_scrollbar.h:21
scroll_bar::pscroll_bar
struct widget * pscroll_bar
Definition widget_scrollbar.h:22
scroll_bar::active
Uint8 active
Definition widget_scrollbar.h:24
scroll_bar::max
Sint16 max
Definition widget_scrollbar.h:29
scroll_bar::step
Uint8 step
Definition widget_scrollbar.h:25
scroll_bar::count
Uint16 count
Definition widget_scrollbar.h:27
scroll_bar::min
Sint16 min
Definition widget_scrollbar.h:28
scroll_bar::down_right_button
struct widget * down_right_button
Definition widget_scrollbar.h:23
widget
Definition widget.h:112
widget::cont
struct container * cont
Definition widget.h:127
widget.h
setup_vertical_scrollbar_area
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 hight, bool swap_start_x)
Definition widget_scrollbar.c:572
draw_vert
int draw_vert(struct widget *vert, Sint16 x, Sint16 y)
Definition widget_scrollbar.c:187
create_horizontal_scrollbar
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)
Definition widget_scrollbar.c:1550
create_horizontal
struct widget * create_horizontal(SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
Definition widget_scrollbar.c:301
draw_horiz
int draw_horiz(struct widget *horiz, Sint16 x, Sint16 y)
Definition widget_scrollbar.c:325
setup_vertical_scrollbar_default_callbacks
void setup_vertical_scrollbar_default_callbacks(struct scroll_bar *scroll)
Definition widget_scrollbar.c:1527
create_vertical
struct widget * create_vertical(SDL_Surface *vert_theme, struct gui_layer *pdest, Uint16 height, Uint32 flags)
Definition widget_scrollbar.c:164
create_vertical_scrollbar
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
Definition widget_scrollbar.c:491