libhpdftbl 1.5.0
Table construction library for Haru PDF library
Loading...
Searching...
No Matches
hpdftbl_widget.c File Reference

Support for drawing widgets. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <hpdf.h>
#include <string.h>
#include <math.h>
#include "hpdftbl.h"

Macros

#define TRUE   1
 
#define FALSE   0
 

Functions

void hpdftbl_table_widget_letter_buttons (HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, const HPDF_RGBColor on_color, const HPDF_RGBColor off_color, const HPDF_RGBColor on_background, const HPDF_RGBColor off_background, const HPDF_REAL fsize, const char *letters, _Bool *state)
 Display an array of letters as a table where each letter is its own "mini" cell
and sorrounded by a frame. Each boxed letter can be in an "on" state or "off" state which is illustrated with different font and fac colors. More...
 
void hpdftbl_widget_slide_button (HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, _Bool state)
 Table widget that draws a sliding on/off switch. Meant to be used in a canvas callback to display a boolean value. More...
 
void hpdftbl_widget_hbar (const HPDF_Doc doc, const HPDF_Page page, const HPDF_REAL xpos, const HPDF_REAL ypos, const HPDF_REAL width, const HPDF_REAL height, const HPDF_RGBColor color, const float val, const _Bool hide_val)
 Draw a horizontal partially filled bar to indicate an analog (percentage) value. More...
 
void hpdftbl_widget_segment_hbar (const HPDF_Doc doc, const HPDF_Page page, const HPDF_REAL xpos, const HPDF_REAL ypos, const HPDF_REAL width, const HPDF_REAL height, const size_t num_segments, const HPDF_RGBColor on_color, const double val_percent, const _Bool hide_val)
 Draw a horizontal segment meter that can be used to visualize a discrete value. More...
 
void hpdftbl_widget_strength_meter (const HPDF_Doc doc, const HPDF_Page page, const HPDF_REAL xpos, const HPDF_REAL ypos, const HPDF_REAL width, const HPDF_REAL height, const size_t num_segments, const HPDF_RGBColor on_color, const size_t num_on_segments)
 Draw a phone strength meter. More...
 

Detailed Description

Support for drawing widgets.

Macro Definition Documentation

◆ FALSE

#define FALSE   0

C Boolean false value

◆ TRUE

#define TRUE   1

C Boolean truth value

Function Documentation

◆ hpdftbl_table_widget_letter_buttons()

void hpdftbl_table_widget_letter_buttons ( HPDF_Doc  doc,
HPDF_Page  page,
HPDF_REAL  xpos,
HPDF_REAL  ypos,
HPDF_REAL  width,
HPDF_REAL  height,
const HPDF_RGBColor  on_color,
const HPDF_RGBColor  off_color,
const HPDF_RGBColor  on_background,
const HPDF_RGBColor  off_background,
const HPDF_REAL  fsize,
const char *  letters,
_Bool *  state 
)

Display an array of letters as a table where each letter is its own "mini" cell
and sorrounded by a frame. Each boxed letter can be in an "on" state or "off" state which is illustrated with different font and fac colors.

Parameters
docHPDF document handle
pageHPDF page handle
xposX-öosition of cell
yposY-Position of cell
widthWidth of cell
heightHeight of cell
on_colorThe font color in "on" state
off_colorThe font color in "off" state
on_backgroundThe face color in "on" state
off_backgroundThe face color in "off" state
fsizeThe font size
lettersWhat letters to have in the boxes
stateWhat state each boxed letter should be (0=off, 1=pn)

◆ hpdftbl_widget_hbar()

void hpdftbl_widget_hbar ( const HPDF_Doc  doc,
const HPDF_Page  page,
const HPDF_REAL  xpos,
const HPDF_REAL  ypos,
const HPDF_REAL  width,
const HPDF_REAL  height,
const HPDF_RGBColor  color,
const float  val,
const _Bool  hide_val 
)

Draw a horizontal partially filled bar to indicate an analog (percentage) value.

This function can not be used directly as a canvas callback since it needs additional parameters. Instead create a simple canvas callback that gives the additional parameters.

Parameters
docHPDF Document handle
pageHPDF Page handle
xposLower left x
yposLower left y
widthWidth of meter
heightHeight of meter
colorFill color for bar
valPercentage fill in range [0.0, 100.0]
hide_valTRUE to hide the value (in percent) at the right end of the entire bar

◆ hpdftbl_widget_segment_hbar()

void hpdftbl_widget_segment_hbar ( const HPDF_Doc  doc,
const HPDF_Page  page,
const HPDF_REAL  xpos,
const HPDF_REAL  ypos,
const HPDF_REAL  width,
const HPDF_REAL  height,
const size_t  num_segments,
const HPDF_RGBColor  on_color,
const double  val_percent,
const _Bool  hide_val 
)

Draw a horizontal segment meter that can be used to visualize a discrete value.

This function can not be used directly as a canvas callback since it needs additional parameters. Instead create a simple canvas callback that gives the additional parameters.

Parameters
docHPDF Document handle
pageHPDF Page handle
xposLower left x
yposLower left y
widthWidth of meter
heightHeight of meter
num_segmentsTotal number of segments
on_colorColor for "on" segment
val_percentTo what extent should the bars be filled (as a value 0.0 - 1.0)
hide_valTRUE to hide the value (in percent) at the right end of the entire bar

◆ hpdftbl_widget_slide_button()

void hpdftbl_widget_slide_button ( HPDF_Doc  doc,
HPDF_Page  page,
HPDF_REAL  xpos,
HPDF_REAL  ypos,
HPDF_REAL  width,
HPDF_REAL  height,
_Bool  state 
)

Table widget that draws a sliding on/off switch. Meant to be used in a canvas callback to display a boolean value.

This function can not be used directly as a canvas callback since it needs the state of the button as an argument. Instead create a simple canvas callback that determines the wanted state and then just passes on all argument to this widget function.

Parameters
docHPDF document handle
pageHPDF page handle
xposX-öosition of cell
yposY-Position of cell
widthWidth of cell
heightHeight of cell
stateState of button On/Off

◆ hpdftbl_widget_strength_meter()

void hpdftbl_widget_strength_meter ( const HPDF_Doc  doc,
const HPDF_Page  page,
const HPDF_REAL  xpos,
const HPDF_REAL  ypos,
const HPDF_REAL  width,
const HPDF_REAL  height,
const size_t  num_segments,
const HPDF_RGBColor  on_color,
const size_t  num_on_segments 
)

Draw a phone strength meter.

This function can not be used directly as a canvas callback since it needs additional parameters. Instead create a simple canvas callback that gives the additional parameters.

Parameters
docHPDF Document handle
pageHPDF Page handle
xposLower left x
yposLower left y
widthWidth of meter
heightHeight of meter
num_segmentsTotal number of segments
on_colorColor for "on" segment
num_on_segmentsNumber of on segments