GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
gp_widget_size_units.h File Reference

A widget size units. More...

#include <widgets/gp_widget_types.h>
#include <widgets/gp_widget_render.h>

Go to the source code of this file.

Data Structures

struct  gp_widget_size
 A compound size. More...
 

Macros

#define GP_WIDGET_SIZE(px_val, pad_val, asc_val)    ((gp_widget_size){.px = px_val, .pad = pad_val, .asc = asc_val})
 An initializer for gp_widget_size.
 
#define GP_WIDGET_SIZE_DEFAULT   ((gp_widget_size){0xffff, 0xff, 0xff})
 An default size initializer.
 
#define GP_WIDGET_SIZE_EQ(a, b)
 A gp_widget_size comparsion.
 

Functions

static unsigned int gp_widget_size_units_get (gp_widget_size *size, const gp_widget_render_ctx *ctx)
 Returns size in pixel given gp_widget_size and rendering context.
 
int gp_widget_size_units_parse (const char *size, gp_widget_size *ret)
 Parses widget size from a string.
 

Detailed Description

A widget size units.

Definition in file gp_widget_size_units.h.

Macro Definition Documentation

◆ GP_WIDGET_SIZE

#define GP_WIDGET_SIZE (   px_val,
  pad_val,
  asc_val 
)     ((gp_widget_size){.px = px_val, .pad = pad_val, .asc = asc_val})

An initializer for gp_widget_size.

Could be used to construct function parameters on the fly such as:

w = gp_pixmap_create(GP_WIDGET_SIZE(100, 0, 0), GP_WIDGET_SIZE(100, 0, 0), callback, NULL);

Definition at line 74 of file gp_widget_size_units.h.

◆ GP_WIDGET_SIZE_DEFAULT

#define GP_WIDGET_SIZE_DEFAULT   ((gp_widget_size){0xffff, 0xff, 0xff})

An default size initializer.

Special value used in widget constructors. When size is set to this value the min size is set to a default for a given widget type.

Definition at line 83 of file gp_widget_size_units.h.

◆ GP_WIDGET_SIZE_EQ

#define GP_WIDGET_SIZE_EQ (   a,
 
)
Value:
(((a).px == (b).px) && \
((a).pad == (b).pad) && \
((a).asc == (b).asc))

A gp_widget_size comparsion.

Parameters
aA gp_widget_size.
bA gp_widget_size.
Returns
True if sizes a and b are equal.

Definition at line 93 of file gp_widget_size_units.h.

Function Documentation

◆ gp_widget_size_units_get()

static unsigned int gp_widget_size_units_get ( gp_widget_size size,
const gp_widget_render_ctx ctx 
)
inlinestatic

Returns size in pixel given gp_widget_size and rendering context.

Parameters
sizeA gp_widget_size size.
ctxA render context.
Returns
A size in pixels.

Definition at line 48 of file gp_widget_size_units.h.

References gp_widget_size::asc, gp_widget_render_ctx::font, gp_text_ascent(), gp_widget_size::pad, gp_widget_render_ctx::padd, and gp_widget_size::px.

◆ gp_widget_size_units_parse()

int gp_widget_size_units_parse ( const char *  size,
gp_widget_size ret 
)

Parses widget size from a string.

Parameters
sizeA widget size string e.g. "10px 2pad 1asc"
retA gp_widget_size to store the result to.
Returns
Zero on success non-zero otherwise.