FxLibcTest/include/ft/widgets/flog.h

48 lines
1.2 KiB
C

//---
// ft.widgets.flog: A scrollable log based on a string
//---
#ifndef _FT_WIDGETS_FLOG_H
#define _FT_WIDGETS_FLOG_H
#include <justui/jwidget.h>
#include <gint/display.h>
/* flog: A scrollable log with line wrapping
This widget displays long strings with newlines in a scrollable region. */
typedef struct {
jwidget widget;
/* Log to display and its size */
char const *log;
int log_size;
/* Total number of lines, and number of visible lines */
int lines;
int visible;
/* Current scroll offset */
int top;
/* Font and extra line spacing */
font_t const *font;
int line_spacing;
} flog;
/* flog_create(): Create a log browser */
flog *flog_create(void *parent);
/* flog_set_log(): Set the log string
If size is set to -1, strlen(string) is used instead. */
void flog_set_log(flog *l, char const *string, int size);
//---
// Display properties
//---
/* The default font is dfont_default() */
font_t const *flog_font(flog *l);
void flog_set_font(flog *l, font_t const *font);
/* Extra vertical spacing between lines. The default line spacing is 1. */
int flog_line_spacing(flog *l);
void flog_set_line_spacing(flog *l, int line_spacing);
#endif /* _FT_WIDGETS_FLOG_H */