Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
widget_scrollbar.c File Reference
#include <SDL2/SDL.h>
#include "log.h"
#include "colors.h"
#include "graphics.h"
#include "gui_id.h"
#include "gui_tilespec.h"
#include "mapview.h"
#include "themespec.h"
#include "widget.h"
#include "widget_p.h"

Go to the source code of this file.

Data Structures

struct  UP_DOWN
 

Macros

#define widget_add_next(new_widget, add_dock)
 

Functions

static SDL_Surfacecreate_vertical_surface (SDL_Surface *vert_theme, enum widget_state state, Uint16 height)
 
static int redraw_vert (struct widget *vert)
 
struct widgetcreate_vertical (SDL_Surface *vert_theme, struct gui_layer *pdest, Uint16 height, Uint32 flags)
 
int draw_vert (struct widget *vert, Sint16 x, Sint16 y)
 
static SDL_Surfacecreate_horizontal_surface (SDL_Surface *horiz_theme, enum widget_state state, Uint16 width)
 
static int redraw_horiz (struct widget *horiz)
 
struct widgetcreate_horizontal (SDL_Surface *horiz_theme, struct gui_layer *pdest, Uint16 width, Uint32 flags)
 
int draw_horiz (struct widget *horiz, Sint16 x, Sint16 y)
 
static int get_step (struct scroll_bar *scroll)
 
static int get_position (struct advanced_dialog *dlg)
 
static struct widgetup_scroll_widget_list (struct scroll_bar *vscroll, struct widget *begin_active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list)
 
static struct widgetdown_scroll_widget_list (struct scroll_bar *vscroll, struct widget *begin_active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list)
 
static struct widgetvertic_scroll_widget_list (struct scroll_bar *vscroll, struct widget *begin_active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list)
 
static int std_up_advanced_dlg_callback (struct widget *pwidget)
 
static int std_down_advanced_dlg_callback (struct widget *pwidget)
 
static int std_vscroll_advanced_dlg_callback (struct widget *pscroll_bar)
 
Uint32 create_vertical_scrollbar (struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
 
void setup_vertical_scrollbar_area (struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
 
static struct widgetvertical_scroll_widget_list (struct widget *active_widget_list, struct widget *begin_widget_list, struct widget *end_widget_list, int active, int step, int dir)
 
static void inside_scroll_down_loop (void *data)
 
static void inside_scroll_up_loop (void *data)
 
static Uint16 scroll_mouse_motion_handler (SDL_MouseMotionEvent *motion_event, void *data)
 
static Uint16 scroll_mouse_button_up (SDL_MouseButtonEvent *button_event, void *data)
 
bool add_widget_to_vertical_scroll_widget_list (struct advanced_dialog *dlg, struct widget *new_widget, struct widget *add_dock, bool dir, Sint16 start_x, Sint16 start_y)
 
bool del_widget_from_vertical_scroll_widget_list (struct advanced_dialog *dlg, struct widget *pwidget)
 
void setup_vertical_scrollbar_default_callbacks (struct scroll_bar *scroll)
 
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)
 

Variables

static int(* baseclass_redraw )(struct widget *pwidget)
 

Macro Definition Documentation

◆ widget_add_next

#define widget_add_next (   new_widget,
  add_dock 
)
Value:
do { \
new_widget->prev = add_dock; \
new_widget->next = add_dock->next; \
if (add_dock->next) { \
add_dock->next->prev = new_widget; \
} \
add_dock->next = new_widget; \
} while (FALSE)
char * incite_cost
Definition comments.c:75
#define FALSE
Definition support.h:47

Definition at line 52 of file widget_scrollbar.c.

Function Documentation

◆ add_widget_to_vertical_scroll_widget_list()

bool add_widget_to_vertical_scroll_widget_list ( struct advanced_dialog dlg,
struct widget new_widget,
struct widget add_dock,
bool  dir,
Sint16  start_x,
Sint16  start_y 
)

Add new widget to scrolled list and set draw position of all changed widgets. dir : TRUE - upper add => add_dock->next = new_widget. FALSE - down add => add_dock->prev = new_widget. start_x, start_y - positions of first seen widget (active_widget_list). dlg->scroll ( scrollbar ) must exist. It isn't full secure to multi widget list.

Definition at line 1146 of file widget_scrollbar.c.

◆ create_horizontal()

struct widget * create_horizontal ( SDL_Surface horiz_theme,
struct gui_layer pdest,
Uint16  width,
Uint32  flags 
)

Create ( malloc ) horizontal scroll_bar widget structure.

Theme graphic is taken from horiz_theme surface;

This function determinate future size of horizontal scroll_bar ( width = 'width', height = 'horiz_theme->h' ) and save this in: pwidget->size rectangle ( SDL_Rect )

Return pointer to created widget.

Definition at line 296 of file widget_scrollbar.c.

Referenced by create_horizontal_scrollbar(), economy_report_dialog_popup(), and popup_city_cma_dialog().

◆ 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 
)

Create a new horizontal scrollbar to active widgets list.

Definition at line 1545 of file widget_scrollbar.c.

◆ create_horizontal_surface()

static SDL_Surface * create_horizontal_surface ( SDL_Surface horiz_theme,
enum widget_state  state,
Uint16  width 
)
static

Create background image for hscrollbars then return pointer to this image.

Graphic is taken from horiz_theme surface and blit to new created image.

Definition at line 206 of file widget_scrollbar.c.

Referenced by redraw_horiz().

◆ create_vertical()

struct widget * create_vertical ( SDL_Surface vert_theme,
struct gui_layer pdest,
Uint16  height,
Uint32  flags 
)

Create ( malloc ) vertical scroll_bar widget structure.

Theme graphic is taken from vert_theme surface;

This function determinate future size of vertical scroll_bar ( width = 'vert_theme->w', height = 'height' ) and save this in: pwidget->size rectangle ( SDL_Rect )

Return pointer to created widget.

Definition at line 164 of file widget_scrollbar.c.

Referenced by create_vertical_scrollbar().

◆ create_vertical_scrollbar()

Uint32 create_vertical_scrollbar ( struct advanced_dialog dlg,
Uint8  step,
Uint8  active,
bool  create_scrollbar,
bool  create_buttons 
)

◆ create_vertical_surface()

static SDL_Surface * create_vertical_surface ( SDL_Surface vert_theme,
enum widget_state  state,
Uint16  height 
)
static

Create background image for vscrollbars, then return pointer to that image.

Graphic is taken from vert_theme surface and blit to new created image.

Definition at line 74 of file widget_scrollbar.c.

Referenced by redraw_vert().

◆ del_widget_from_vertical_scroll_widget_list()

bool del_widget_from_vertical_scroll_widget_list ( struct advanced_dialog dlg,
struct widget pwidget 
)

Delete widget from scrolled list and set draw position of all changed widgets. Don't free dlg and dlg->scroll (if exist) It is full secure for multi widget list case.

Definition at line 1344 of file widget_scrollbar.c.

◆ down_scroll_widget_list()

static struct widget * down_scroll_widget_list ( struct scroll_bar vscroll,
struct widget begin_active_widget_list,
struct widget begin_widget_list,
struct widget end_widget_list 
)
static

Scroll widgets down.

Definition at line 1054 of file widget_scrollbar.c.

Referenced by std_down_advanced_dlg_callback().

◆ draw_horiz()

int draw_horiz ( struct widget horiz,
Sint16  x,
Sint16  y 
)

Draw horizontal scrollbar.

Definition at line 320 of file widget_scrollbar.c.

◆ draw_vert()

int draw_vert ( struct widget vert,
Sint16  x,
Sint16  y 
)

Draw vertical scrollbar.

Definition at line 187 of file widget_scrollbar.c.

◆ get_position()

static int get_position ( struct advanced_dialog dlg)
static

◆ get_step()

static int get_step ( struct scroll_bar scroll)
static

Get step of the scrollbar.

Definition at line 336 of file widget_scrollbar.c.

Referenced by down_scroll_widget_list(), get_position(), up_scroll_widget_list(), and vertic_scroll_widget_list().

◆ inside_scroll_down_loop()

static void inside_scroll_down_loop ( void data)
static

Callback for the scroll-down event loop.

Definition at line 868 of file widget_scrollbar.c.

Referenced by down_scroll_widget_list().

◆ inside_scroll_up_loop()

static void inside_scroll_up_loop ( void data)
static

Callback for the scroll-up event loop.

Definition at line 915 of file widget_scrollbar.c.

Referenced by up_scroll_widget_list().

◆ redraw_horiz()

static int redraw_horiz ( struct widget horiz)
static

Blit horizontal scrollbar gfx to surface its on.

Definition at line 264 of file widget_scrollbar.c.

Referenced by create_horizontal(), and draw_horiz().

◆ redraw_vert()

static int redraw_vert ( struct widget vert)
static

◆ scroll_mouse_button_up()

static Uint16 scroll_mouse_button_up ( SDL_MouseButtonEvent button_event,
void data 
)
static

Callback for scrollbar event loops' mouse up events.

Definition at line 1045 of file widget_scrollbar.c.

Referenced by down_scroll_widget_list(), up_scroll_widget_list(), and vertic_scroll_widget_list().

◆ scroll_mouse_motion_handler()

static Uint16 scroll_mouse_motion_handler ( SDL_MouseMotionEvent motion_event,
void data 
)
static

Handle mouse motion events of the vertical scrollbar event loop.

Definition at line 957 of file widget_scrollbar.c.

Referenced by vertic_scroll_widget_list().

◆ setup_vertical_scrollbar_area()

void setup_vertical_scrollbar_area ( struct scroll_bar scroll,
Sint16  start_x,
Sint16  start_y,
Uint16  height,
bool  swap_start_x 
)

◆ setup_vertical_scrollbar_default_callbacks()

void setup_vertical_scrollbar_default_callbacks ( struct scroll_bar scroll)

Set default vertical scrollbar handling for scrollbar.

Definition at line 1522 of file widget_scrollbar.c.

◆ std_down_advanced_dlg_callback()

static int std_down_advanced_dlg_callback ( struct widget pwidget)
static

User interacted with down button of advanced dialog.

Definition at line 432 of file widget_scrollbar.c.

Referenced by create_vertical_scrollbar(), and setup_vertical_scrollbar_default_callbacks().

◆ std_up_advanced_dlg_callback()

static int std_up_advanced_dlg_callback ( struct widget pwidget)
static

User interacted with up button of advanced dialog.

Definition at line 405 of file widget_scrollbar.c.

Referenced by create_vertical_scrollbar(), and setup_vertical_scrollbar_default_callbacks().

◆ std_vscroll_advanced_dlg_callback()

static int std_vscroll_advanced_dlg_callback ( struct widget pscroll_bar)
static

FIXME : fix main funct : vertic_scroll_widget_list(...)

Definition at line 459 of file widget_scrollbar.c.

Referenced by create_vertical_scrollbar(), and setup_vertical_scrollbar_default_callbacks().

◆ up_scroll_widget_list()

static struct widget * up_scroll_widget_list ( struct scroll_bar vscroll,
struct widget begin_active_widget_list,
struct widget begin_widget_list,
struct widget end_widget_list 
)
static

Scroll widgets up.

Definition at line 1083 of file widget_scrollbar.c.

Referenced by std_up_advanced_dlg_callback().

◆ vertic_scroll_widget_list()

static struct widget * vertic_scroll_widget_list ( struct scroll_bar vscroll,
struct widget begin_active_widget_list,
struct widget begin_widget_list,
struct widget end_widget_list 
)
static

Scroll vertical widget list with the mouse movement.

Definition at line 1105 of file widget_scrollbar.c.

Referenced by std_vscroll_advanced_dlg_callback().

◆ vertical_scroll_widget_list()

static struct widget * vertical_scroll_widget_list ( struct widget active_widget_list,
struct widget begin_widget_list,
struct widget end_widget_list,
int  active,
int  step,
int  dir 
)
static

Scroll pointers on list. dir == directions: up == -1, down == 1.

Definition at line 633 of file widget_scrollbar.c.

Referenced by inside_scroll_down_loop(), inside_scroll_up_loop(), and scroll_mouse_motion_handler().

Variable Documentation

◆ baseclass_redraw

int(* baseclass_redraw) (struct widget *pwidget) ( struct widget pwidget)
static

Definition at line 62 of file widget_scrollbar.c.

Referenced by create_horizontal(), and create_vertical().