Atrinik Client  4.0
Functions | Variables
scrollbar.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

void scrollbar_init ()
 
static void scrollbar_element_init (scrollbar_element *elem, int x, int y, int w, int h)
 
static void scrollbar_element_render_background (SDL_Surface *surface, SDL_Rect *box, scrollbar_element *elem, uint8_t horizontal)
 
static void scrollbar_element_render_arrow_up (SDL_Surface *surface, SDL_Rect *box, scrollbar_element *elem, uint8_t horizontal)
 
static void scrollbar_element_render_arrow_down (SDL_Surface *surface, SDL_Rect *box, scrollbar_element *elem, uint8_t horizontal)
 
static void scrollbar_element_render_slider (SDL_Surface *surface, SDL_Rect *box, scrollbar_element *elem, uint8_t horizontal)
 
static int scrollbar_element_highlight_check (scrollbar_struct *scrollbar, scrollbar_element *elem, int mx, int my)
 
static void scrollbar_element_render (scrollbar_struct *scrollbar, scrollbar_element *elem, SDL_Surface *surface)
 
static int scrollbar_click_scroll (scrollbar_struct *scrollbar, int test)
 
int scrollbar_need_redraw (scrollbar_struct *scrollbar)
 
static int scrollbar_slider_startx (scrollbar_struct *scrollbar)
 
static int scrollbar_slider_starty (scrollbar_struct *scrollbar)
 
static int scrollbar_slider_width (scrollbar_struct *scrollbar)
 
static int scrollbar_slider_height (scrollbar_struct *scrollbar)
 
void scrollbar_create (scrollbar_struct *scrollbar, int w, int h, uint32_t *scroll_offset, uint32_t *num_lines, uint32_t max_lines)
 
void scrollbar_info_create (scrollbar_info_struct *info)
 
void scrollbar_scroll_to (scrollbar_struct *scrollbar, int scroll)
 
void scrollbar_scroll_adjust (scrollbar_struct *scrollbar, int adjust)
 
void scrollbar_show (scrollbar_struct *scrollbar, SDL_Surface *surface, int x, int y)
 
int scrollbar_event (scrollbar_struct *scrollbar, SDL_Event *event)
 
int scrollbar_get_width (scrollbar_struct *scrollbar)
 

Variables

static SDL_Color scrollbar_color_bg
 
static SDL_Color scrollbar_color_fg
 
static SDL_Color scrollbar_color_highlight
 

Detailed Description

Scrollbar API.

Author
Alex Tokar

Definition in file scrollbar.c.

Function Documentation

static int scrollbar_click_scroll ( scrollbar_struct scrollbar,
int  test 
)
static

Handle clicking an element in scrollbar.

Parameters
scrollbarThe scrollbar.
testIf 1, only test whether anything can be clicked.
Returns
1 if the click was handled, 0 otherwise.

Definition at line 218 of file scrollbar.c.

void scrollbar_create ( scrollbar_struct scrollbar,
int  w,
int  h,
uint32_t *  scroll_offset,
uint32_t *  num_lines,
uint32_t  max_lines 
)

Initialize a single scrollbar structure.

Parameters
scrollbarStructure to initialize.
wWidth of the scrollbar. Should be an odd number, otherwise the arrow calculations will not work correctly.
hHeight of the scrollbar.

Definition at line 350 of file scrollbar.c.

static int scrollbar_element_highlight_check ( scrollbar_struct scrollbar,
scrollbar_element elem,
int  mx,
int  my 
)
static

Check if scrollbar element should be highlighted.

Parameters
scrollbarThe scrollbar.
elemThe element.
mxMouse X.
myMouse Y.
Returns
1 if the element is highlighted, 0 otherwise.

Definition at line 158 of file scrollbar.c.

static void scrollbar_element_init ( scrollbar_element elem,
int  x,
int  y,
int  w,
int  h 
)
static

Initialize a single scrollbar element.

Parameters
elemElement to initialize.
xX position.
yY position.
wWidth of the element.
hHeight of the element.

Definition at line 66 of file scrollbar.c.

static void scrollbar_element_render ( scrollbar_struct scrollbar,
scrollbar_element elem,
SDL_Surface *  surface 
)
static

Render a single scrollbar element.

Parameters
scrollbarThe scrollbar.
elemThe element.
surfaceThe surface to draw on.

Definition at line 185 of file scrollbar.c.

static void scrollbar_element_render_arrow_down ( SDL_Surface *  surface,
SDL_Rect *  box,
scrollbar_element elem,
uint8_t  horizontal 
)
static

Rendering function of this element.

Parameters
surfaceSurface to render on.
boxWhere to draw.
elemThe element.
horizontalWhether the scrollbar is horizontal.

Definition at line 108 of file scrollbar.c.

static void scrollbar_element_render_arrow_up ( SDL_Surface *  surface,
SDL_Rect *  box,
scrollbar_element elem,
uint8_t  horizontal 
)
static

Rendering function of this element.

Parameters
surfaceSurface to render on.
boxWhere to draw.
elemThe element.
horizontalWhether the scrollbar is horizontal.

Definition at line 84 of file scrollbar.c.

static void scrollbar_element_render_background ( SDL_Surface *  surface,
SDL_Rect *  box,
scrollbar_element elem,
uint8_t  horizontal 
)
static

Rendering function of this element.

Parameters
surfaceSurface to render on.
boxWhere to draw.
elemThe element.
horizontalWhether the scrollbar is horizontal.

Definition at line 75 of file scrollbar.c.

static void scrollbar_element_render_slider ( SDL_Surface *  surface,
SDL_Rect *  box,
scrollbar_element elem,
uint8_t  horizontal 
)
static

Rendering function of this element.

Parameters
surfaceSurface to render on.
boxWhere to draw.
elemThe element.
horizontalWhether the scrollbar is horizontal.

Definition at line 132 of file scrollbar.c.

int scrollbar_event ( scrollbar_struct scrollbar,
SDL_Event *  event 
)

Try to handle a scrollbar event.

Parameters
scrollbarScrollbar to handle the event for.
eventThe event.
Returns
1 if the event was handled, 0 otherwise.

Definition at line 529 of file scrollbar.c.

int scrollbar_get_width ( scrollbar_struct scrollbar)

Get the scrollbar's width.

Parameters
scrollbarThe scrollbar to get width of.
Returns
The width.

Definition at line 630 of file scrollbar.c.

void scrollbar_info_create ( scrollbar_info_struct info)

Initialize scrollbar information structure.

Parameters
infoThe structure to initialize.

Definition at line 382 of file scrollbar.c.

void scrollbar_init ( void  )

Initialize the scrollbar API.

Definition at line 44 of file scrollbar.c.

int scrollbar_need_redraw ( scrollbar_struct scrollbar)

Check whether scrollbar needs redrawing.

Parameters
scrollbarScrollbar to check.
Returns
1 if the scrollbar needs redrawing, 0 otherwise.

Definition at line 267 of file scrollbar.c.

void scrollbar_scroll_adjust ( scrollbar_struct scrollbar,
int  adjust 
)

Scroll the scrollbar by the specified amount.

If the scroll offset has changed at all, value of the scrollbar_struct::redraw pointer will be set to 1.

Parameters
scrollbarThe scrollbar to scroll.
adjustHow much to scroll by.

Definition at line 427 of file scrollbar.c.

void scrollbar_scroll_to ( scrollbar_struct scrollbar,
int  scroll 
)

Scroll the specified scrollbar to the specified offset.

If the scroll offset has changed at all, value of the scrollbar_struct::redraw pointer will be set to 1.

Parameters
scrollbarThe scrollbar.
scrollOffset to scroll to.

Definition at line 397 of file scrollbar.c.

void scrollbar_show ( scrollbar_struct scrollbar,
SDL_Surface *  surface,
int  x,
int  y 
)

Render a scrollbar.

Parameters
scrollbarThe scrollbar to render.
surfaceSurface to render on.
xX position on the surface.
yY position on the surface.

Definition at line 443 of file scrollbar.c.

static int scrollbar_slider_height ( scrollbar_struct scrollbar)
static

Calculate scrollbar's slider height.

Parameters
scrollbarThe scrollbar.
Returns
Slider's height.

Definition at line 331 of file scrollbar.c.

static int scrollbar_slider_startx ( scrollbar_struct scrollbar)
static

Calculate scrollbar's slider X position.

Parameters
scrollbarThe scrollbar.
Returns
Slider's X position.

Definition at line 283 of file scrollbar.c.

static int scrollbar_slider_starty ( scrollbar_struct scrollbar)
static

Calculate scrollbar's slider Y position.

Parameters
scrollbarThe scrollbar.
Returns
Slider's Y position.

Definition at line 299 of file scrollbar.c.

static int scrollbar_slider_width ( scrollbar_struct scrollbar)
static

Calculate scrollbar's slider width.

Parameters
scrollbarThe scrollbar.
Returns
Slider's width.

Definition at line 315 of file scrollbar.c.

Variable Documentation

SDL_Color scrollbar_color_bg
static

Scrollbar background color.

Definition at line 35 of file scrollbar.c.

SDL_Color scrollbar_color_fg
static

Scrollbar foreground color.

Definition at line 37 of file scrollbar.c.

SDL_Color scrollbar_color_highlight
static

Highlight color.

Definition at line 39 of file scrollbar.c.