Table of Contents
- xtk_config.h
- Types
- ConfigColor
- BorderMode
- ZoomHexPosition
- XtkConfig
- XtkConfig::EntryBlock
- XtkConfig::MenuBlock
- XtkConfig::ButtonBlock
- XtkConfig::LabelBlock
- XtkConfig::SpinButtonBlock
- XtkConfig::SliderBlock
- XtkConfig::CheckboxBlock
- XtkConfig::RadioButtonBlock
- XtkConfig::ComboBoxBlock
- XtkConfig::NotebookBlock
- XtkConfig::TextViewBlock
- XtkConfig::TooltipBlock
- XtkConfig::TrayMenuBlock
- XtkConfig::SplitPaneBlock
- XtkConfig::ToolWindowBlock
- XtkConfig::DockFrameBlock
- XtkConfig::TreeViewBlock
- XtkConfig::ProgressBarBlock
- XtkConfig::ScrollbarBlock
- XtkConfig::StatusbarBlock
- XtkConfig::PathBarBlock
- XtkConfig::IconViewBlock
- XtkConfig::DataGridBlock
- XtkConfig::GraphBlock
- XtkConfig::FrameBlock
- XtkConfig::ZoomHexBlock
- ButtonBlock
- EntryBlock
- MenuBlock
- LabelBlock
- SpinButtonBlock
- SliderBlock
- CheckboxBlock
- RadioButtonBlock
- ComboBoxBlock
- NotebookBlock
- TextViewBlock
- TooltipBlock
- TrayMenuBlock
- SplitPaneBlock
- ToolWindowBlock
- DockFrameBlock
- TreeViewBlock
- ProgressBarBlock
- PathBarBlock
- IconViewBlock
- ScrollbarBlock
- StatusbarBlock
- DataGridBlock
- GraphBlock
- FrameBlock
- ZoomHexBlock
- XtkConfigKeyCallback
- Constants
- Functions
- xtk_config_init
- xtk_config_load
- xtk_config_load_from_home
- xtk_config_write_defaults
- xtk_config_write_defaults_with_values
- xtk_config_init_defaults
- xtk_config_set
- xtk_config_parse_color
- xtk_config_parse_file
- xtk_config_write_color
- xtk_config_color_key_count
- xtk_config_color_key_at
- xtk_config_color_field
- xtk_config_mark_changed
- xtk_config_mark_saved
- xtk_config_has_unsaved_changes
- xtk_config_get_border_mode
- xtk_config_set_border_mode
- xtk_config_color_to_pixel
- xtk_config_pixel_to_color
- xtk_config_color_to_xft
- xtk_config_blend_color
- xtk_config_open_font
- xtk_config_covering_font
- xtk_config_emoji_font
xtk_config.h
The look of every widget (XtkConfig), and the config file it is read from.
An XtkConfig holds the colors, fonts and sizes of all the widgets: one style block per widget (for example config.button, a ButtonBlock), one geometry block for some of them (for example config.button_widget), and a few settings shared by all (cursor blink, undo depth, the selection colors). A widget's create call takes its block, so the program fills one XtkConfig at startup and passes pointers into it.
The header also has the color type ConfigColor and the helpers the widgets share: reading a color, turning it into an X pixel or an XftColor, mixing two colors, and opening fonts, including fonts for characters the main font lacks and color fonts for emoji.
Filling a config.
xtk_config_init_defaults()clears the struct and sets the built-in defaults. The defaults of each widget's blocks come from that widget's own file (see xtk_config_registry.h): a widget that is not linked into the program leaves its blocks at zero.- Optionally, a theme sets the colors over the defaults (xtk_theme.h).
- Optionally,
xtk_config_load()reads a config file over that. Each line goes throughxtk_config_set(), which a program can also call itself.
xtk_config_write_defaults_with_values() writes a config back as a complete file. The changed field and xtk_config_mark_changed(), xtk_config_mark_saved() and xtk_config_has_unsaved_changes() track whether a program's settings need saving; nothing in the toolkit sets them itself.
Example.
XtkConfig config;
xtk_config_init_defaults(&config);
XtkTheme *theme = xtk_theme_new();
if (theme && xtk_theme_builtin("Dark", theme)) xtk_theme_apply(&config, theme);
xtk_theme_free(theme);
xtk_config_load(&config, "/home/me/.config/myprogram/myprogram.conf"); // 0 if missing
XtkButton *button = xtk_button_create(display, window, &config.button,
config.button_widget.width, config.button_widget.height,
config.button_widget.padding, config.button_widget.border_width,
config.button_widget.hover_border_width, config.button_widget.active_border_width,
config.button_widget.border_radius);
*
File format. A config file is plain text, one setting per line:
[section]starts a section; the keys below it belong to it.key = valuesets a key. Spaces around the key and the value are removed. There are no comments at the end of a line: everything after=is the value.- A line that starts with
#or;is a comment; empty lines are ignored. - Colors take every form of
xtk_paint_parse_color():#RRGGBB,#RRGGBBAAwith alpha,#RGB,#RGBA,rgb(),rgba(),white,blackandtransparent; six or eight hex digits without the#are read too. A color that cannot be read gives opaque black. A key in the color table (below) can also hold a CSS gradient (see xtk_paint.h). A bevel color (highlight,shade) that cannot be read is ignored. Numbers are decimal integers. Switches are on fortrueor1, off for anything else. - A line can be of any length. Section names are cut to 63 characters.
- Keys and sections the toolkit does not know are ignored, so a program can keep its own sections in the same file and read them with
xtk_config_parse_file().
Sections read by xtk_config.c itself. Every other section belongs to a widget and is read by that widget's handler (see xtk_config_registry.h and the widget's own header). The defaults are the built-in ones.
[main]: the main window and shared colors.background(window background, default#2E2E2E),color(body text,#E6E6EB),fontorfont-family(DejaVu Sans),font-size(14),link-color(#598CE6),link-underline(true: underline links; likelink-color, it is kept for the program, and no widget of the toolkit reads it),selection(selected text background,#598CE6),selection-text(selected text,#FFFFFF),cursor-color(text cursor,#E6E6EB),theme(the name of the theme to apply, seextk_theme_load_named(); empty by default).[behavior]: text editing.cursor-blink-ms(blink interval, 600),cursor-color(the same setting as in [main]; read here, but written only in [main]),cursor-width(cursor thickness in pixels, 1),hex-case(upperorlower: how hex entries type digits, upper),undo-depth(the most undo steps kept, 64).[clipboard]:auto-copy-primary(selecting text in an entry also sets the PRIMARY selection, false).[sizes]:swatch-widthandswatch-height(a swatch's size, 74 and 74),menubar-width(278). These defaults come from the swatch and menu widgets.[zoom]:crosshair-color(#00C000) andsquare-color(#C00000), the zoom overlay's colors.[zoom-widget]:crosshair-show(true),square-show(true),crosshair-show-after-pick(false),square-show-after-pick(false).[zoom-hex]: the zoom widget's color readout.background(#101020CC),color(text,#FFFFFF),border(#000000),border-show(false),border-width(1),fontorfont-family(monospace),font-size(12),position(bottom-right,bottom-left,top-rightortop-left; bottom-right),show(true).
In any widget section, highlight and shade set the section's bevel colors (see xtk_paint.h), except where they are already one of the section's color keys (as highlight is in [textview]).
The color table. xtk_config.c lists every color of the toolkit that a config or theme file can set, as a section and key: 196 keys, in [main] and every widget section (for example [button] color, background, border, hover-border, hover-background, active-border, active-background, focus-border). xtk_config_set() reads these keys before the widget's own handler, so each of them can hold a gradient, and xtk_config_registry_write_all() writes each one, even where a widget's handler does not. xtk_config_color_key_count(), xtk_config_color_key_at() and xtk_config_color_field() list and look up the table. The [zoom] and [zoom-hex] colors are not in it.
Font sizes (font-size, and the font_size fields) are in pixels in every widget, the tooltip's too.
#include "xtk_config.h"
Types: ConfigColor, BorderMode, ZoomHexPosition, XtkConfig, XtkConfig::EntryBlock, XtkConfig::MenuBlock, XtkConfig::ButtonBlock, XtkConfig::LabelBlock, XtkConfig::SpinButtonBlock, XtkConfig::SliderBlock, XtkConfig::CheckboxBlock, XtkConfig::RadioButtonBlock, XtkConfig::ComboBoxBlock, XtkConfig::NotebookBlock, XtkConfig::TextViewBlock, XtkConfig::TooltipBlock, XtkConfig::TrayMenuBlock, XtkConfig::SplitPaneBlock, XtkConfig::ToolWindowBlock, XtkConfig::DockFrameBlock, XtkConfig::TreeViewBlock, XtkConfig::ProgressBarBlock, XtkConfig::ScrollbarBlock, XtkConfig::StatusbarBlock, XtkConfig::PathBarBlock, XtkConfig::IconViewBlock, XtkConfig::DataGridBlock, XtkConfig::GraphBlock, XtkConfig::FrameBlock, XtkConfig::ZoomHexBlock, ButtonBlock, EntryBlock, MenuBlock, LabelBlock, SpinButtonBlock, SliderBlock, CheckboxBlock, RadioButtonBlock, ComboBoxBlock, NotebookBlock, TextViewBlock, TooltipBlock, TrayMenuBlock, SplitPaneBlock, ToolWindowBlock, DockFrameBlock, TreeViewBlock, ProgressBarBlock, PathBarBlock, IconViewBlock, ScrollbarBlock, StatusbarBlock, DataGridBlock, GraphBlock, FrameBlock, ZoomHexBlock, XtkConfigKeyCallback
Constants: XTK_CONFIG_FOCUS_BORDER_DEFAULT
Functions: xtk_config_init, xtk_config_load, xtk_config_load_from_home, xtk_config_write_defaults, xtk_config_write_defaults_with_values, xtk_config_init_defaults, xtk_config_set, xtk_config_parse_color, xtk_config_parse_file, xtk_config_write_color, xtk_config_color_key_count, xtk_config_color_key_at, xtk_config_color_field, xtk_config_mark_changed, xtk_config_mark_saved, xtk_config_has_unsaved_changes, xtk_config_get_border_mode, xtk_config_set_border_mode, xtk_config_color_to_pixel, xtk_config_pixel_to_color, xtk_config_color_to_xft, xtk_config_blend_color, xtk_config_open_font, xtk_config_covering_font, xtk_config_emoji_font
Types
ConfigColor
A color: red, green, blue and alpha, each from 0.0 to 1.0.
| Field | Type | Description |
|---|---|---|
r |
double |
Red channel. |
g |
double |
Green channel. |
b |
double |
Blue channel. |
a |
double |
Alpha channel (0.0 transparent - 1.0 opaque) |
BorderMode
How a color swatch works out its border color from its own color (see xtk_swatch.h).
| Name | Value | Description |
|---|---|---|
BORDER_MODE_COMPLEMENTARY |
0 |
Border is the complementary color of the swatch. |
BORDER_MODE_INVERSE |
Border is the swatch color inverted. | |
BORDER_MODE_CONTRAST |
Border is a fixed high-contrast light/dark color. | |
BORDER_MODE_TRIADIC |
Border is a triadic-scheme color of the swatch. |
ZoomHexPosition
The corner of the zoom widget where its color readout sits ([zoom-hex] position).
The values match XtkZoomHexPosition in xtk_zoom.h one for one, so a value can be cast to it.
| Name | Value | Description |
|---|---|---|
ZOOM_HEX_POS_BOTTOM_RIGHT |
0 |
Bottom-right corner (default) |
ZOOM_HEX_POS_BOTTOM_LEFT |
Bottom-left corner. | |
ZOOM_HEX_POS_TOP_RIGHT |
Top-right corner. | |
ZOOM_HEX_POS_TOP_LEFT |
Top-left corner. |
XtkConfig
The look of every widget: one style block per widget, geometry blocks and shared settings.
Fill it with xtk_config_init_defaults(), then optionally a theme and a config file (see the top of this page). The fields of each block are read from the config file section named in its description. The struct is about 10 KB; a program usually keeps one for its whole run.
| Field | Type | Description |
|---|---|---|
entry_text |
struct XtkConfig::EntryBlock |
Free-text entry styling. |
entry_int |
struct XtkConfig::EntryBlock |
Integer entry styling. |
entry_float |
struct XtkConfig::EntryBlock |
Floating-point entry styling. |
entry_hex |
struct XtkConfig::EntryBlock |
Hex color entry styling. |
menu |
struct XtkConfig::MenuBlock |
Popup/context menu styling. |
menubar |
struct XtkConfig::MenuBlock |
Menu bar styling. |
button |
struct XtkConfig::ButtonBlock |
Button widget theme. |
label |
struct XtkConfig::LabelBlock |
Label widget theme. |
spinbutton |
struct XtkConfig::SpinButtonBlock |
Spin-button widget theme. |
slider |
struct XtkConfig::SliderBlock |
Slider widget theme. |
checkbox |
struct XtkConfig::CheckboxBlock |
Checkbox widget theme. |
radiobutton |
struct XtkConfig::RadioButtonBlock |
Radio-button widget theme. |
combobox |
struct XtkConfig::ComboBoxBlock |
Combo box widget theme. |
notebook |
struct XtkConfig::NotebookBlock |
Notebook widget theme. |
width |
int |
Widget width in pixels. |
height |
int |
Widget dimensions in pixels. Default widget height in pixels. Widget height in pixels. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in normal state. Outer border width in pixels; 0 disables it. Chrome border width in pixels (floating mode only) Border width in pixels. |
hover_border_width |
int |
Border width while hovered. |
active_border_width |
int |
Border width while pressed. |
border_radius |
int |
Border corner radius in pixels. |
button_widget |
struct XtkConfig |
A button's size and border widths, passed to xtk_button_create() ([button-widget]). |
entry_widget |
struct XtkConfig |
An entry's geometry. |
border_enabled |
int |
Non-zero to draw the border. |
label_widget |
struct XtkConfig |
A label's geometry. |
swatch_widget |
struct XtkConfig |
A color swatch's geometry ([swatch-widget]; the size also in [sizes]). |
menubar_widget |
struct XtkConfig |
The menu bar's geometry ([menubar-widget]; the width also in [sizes]). |
button_width |
int |
Increment/decrement button width in pixels. |
spinbutton_widget |
struct XtkConfig |
A spin button's geometry ([spinbutton-widget]). |
slider_widget |
struct XtkConfig |
A slider's size ([slider-widget]). |
combobox_widget |
struct XtkConfig |
A combo box's geometry ([combobox-widget]). |
tab_height |
int |
Tab height in pixels. |
tab_padding |
int |
Internal padding within each tab. |
tab_min_width |
int |
Minimum tab width in pixels. |
notebook_widget |
struct XtkConfig |
A notebook's tab geometry ([notebook-widget]). |
textview |
struct XtkConfig::TextViewBlock |
Text view widget theme. |
tooltip |
struct XtkConfig::TooltipBlock |
Tooltip widget theme. |
tray_menu |
struct XtkConfig::TrayMenuBlock |
Tray menu widget theme. |
splitpane |
struct XtkConfig::SplitPaneBlock |
Split-pane widget theme. |
divider_thickness |
int |
Divider width/height in pixels. |
min_size |
int |
Default minimum size per slot in pixels. |
splitpane_widget |
struct XtkConfig |
A split pane's geometry ([splitpane-widget]). |
toolwindow |
struct XtkConfig::ToolWindowBlock |
Tool-window widget theme. |
header_height |
int |
Header bar height in pixels. |
icon_size |
int |
Header icon glyph size in pixels. |
icon_padding |
int |
Padding around each header icon hit-region. |
toolwindow_widget |
struct XtkConfig |
A tool window's geometry ([toolwindow-widget]). |
dockframe |
struct XtkConfig::DockFrameBlock |
Dock-frame widget theme. |
drop_zone_alpha |
int |
Drop-zone highlight alpha, 0-255. |
dockframe_widget |
struct XtkConfig |
A dock frame's settings ([dockframe-widget]). |
treeview |
struct XtkConfig::TreeViewBlock |
Tree-view widget theme. |
row_height |
int |
Row height in pixels. |
indent_width |
int |
Horizontal indent per depth level in pixels. |
twisty_size |
int |
Expand/collapse triangle size in pixels. |
treeview_widget |
struct XtkConfig |
A tree view's geometry ([treeview-widget]). |
progressbar |
struct XtkConfig::ProgressBarBlock |
Progress-bar widget theme. |
progressbar_widget |
struct XtkConfig |
A progress bar's geometry ([progressbar-widget]). |
scrollbar |
struct XtkConfig::ScrollbarBlock |
Scrollbar widget theme. |
statusbar |
struct XtkConfig::StatusbarBlock |
Status bar widget theme. |
pathbar |
struct XtkConfig::PathBarBlock |
Path bar widget theme. |
iconview |
struct XtkConfig::IconViewBlock |
Icon view widget theme. |
datagrid |
struct XtkConfig::DataGridBlock |
Data grid widget theme. |
graph |
struct XtkConfig::GraphBlock |
Graph widget theme. |
thickness |
int |
Track width (vertical) / height (horizontal) in pixels. |
min_thumb_length |
int |
Thumb never shrinks below this along its own axis. |
scrollbar_widget |
struct XtkConfig |
A scrollbar's geometry ([scrollbar-widget]). |
frame |
struct XtkConfig::FrameBlock |
Frame widget theme. |
title_gap |
int |
Horizontal gap on each side of the title where it breaks the top border line. |
title_indent |
int |
Horizontal offset of the title's own left edge from the frame's left border. |
frame_widget |
struct XtkConfig |
A frame's geometry ([frame-widget]). |
crosshair_color |
ConfigColor |
The zoom overlay's crosshair color ([zoom] crosshair-color) |
square_color |
ConfigColor |
The zoom overlay's square color ([zoom] square-color) |
crosshair_show |
int |
Non-zero to show the crosshair. |
square_show |
int |
Non-zero to show the selection square. |
crosshair_show_after_pick |
int |
Non-zero to keep showing the crosshair after a pick. |
square_show_after_pick |
int |
Non-zero to keep showing the square after a pick. |
zoom_widget |
struct XtkConfig |
What the zoom overlay shows ([zoom-widget]). |
zoom_hex |
struct XtkConfig::ZoomHexBlock |
Zoom hex-readout theme. |
background |
ConfigColor |
Window background color. |
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
text_color |
ConfigColor |
Body text color. |
link_color |
ConfigColor |
Hyperlink text color. |
link_underline |
int |
Non-zero to underline links; kept for the program, no widget reads it. |
theme[64] |
char |
The theme applied over this config (xtk_theme.h), by name; "" = none. |
main |
struct XtkConfig |
The main window's look ([main]). |
swatch_border_mode |
BorderMode |
How swatches work out their border color (the swatch section's border-mode). Reading the key from a file also makes it the shared mode of xtk_config_set_border_mode(); xtk_swatch_set_theme() gives it to one swatch. |
border |
ConfigColor |
Swatch border color. |
swatch |
struct XtkConfig |
A color swatch's colors ([swatch]). |
cursor_blink_ms |
int |
The text cursor's blink interval in milliseconds ([behavior] cursor-blink-ms) |
cursor_color |
ConfigColor |
The text cursor's color ([main] or [behavior] cursor-color) |
cursor_thickness |
int |
The text cursor's thickness in pixels ([behavior] cursor-width) |
selection_color |
ConfigColor |
The background of selected text ([main] selection) |
selection_text_color |
ConfigColor |
The color of selected text ([main] selection-text) |
undo_depth |
int |
The most undo steps kept ([behavior] undo-depth) |
text |
int |
Max length for free-text entries. |
integer |
int |
Max length for integer entries. |
floating |
int |
Max length for floating-point entries. |
hex |
int |
Max length for hex color entries. |
max_length |
struct XtkConfig |
The most characters each kind of entry accepts (defaults 1024, 11, 32 and 8; not read from a config file). |
hex_uppercase |
int |
1 if hex entries type digits in uppercase, 0 for lowercase ([behavior] hex-case) |
auto_copy_primary |
int |
1 if selecting text in an entry also sets the PRIMARY selection ([clipboard] auto-copy-primary) |
changed |
int |
1 if the program has marked unsaved changes (xtk_config_mark_changed()), 0 if not |
XtkConfig::EntryBlock
An entry's style ([entry-text], [entry-int], [entry-float], [entry-hex]; see xtk_entry.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Text color. |
background |
ConfigColor |
Field background color. |
border |
ConfigColor |
Default border color. |
hover_border |
ConfigColor |
Border color while hovered. |
focus_border |
ConfigColor |
Border color while focused. |
valid_border |
ConfigColor |
Border color when input passes validation. |
invalid_border |
ConfigColor |
Border color when input fails validation. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
height |
int |
Auto-calculated height; internal use. |
XtkConfig::MenuBlock
A menu's style ([menu], also read from [context-menu], and [menubar]; see xtk_menu.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Text color. |
background |
ConfigColor |
Background color. |
border |
ConfigColor |
Border color. |
hover_border |
ConfigColor |
Border color while hovered. |
hover_background |
ConfigColor |
Background color while hovered. |
hover_foreground |
ConfigColor |
Text color while hovered (unset - alpha 0 - the text color) |
active_background |
ConfigColor |
Background color of the active/selected item. |
rail_background |
ConfigColor |
Menu bar: its rail pill's background (messages such as "copied") |
rail_foreground |
ConfigColor |
Menu bar: its rail pill's text. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
XtkConfig::ButtonBlock
A button's style ([button]; see xtk_button.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Label text color. |
background |
ConfigColor |
Background color. |
border |
ConfigColor |
Border color in normal state. |
hover_border |
ConfigColor |
Border color while hovered. |
hover_background |
ConfigColor |
Background color while hovered. |
active_border |
ConfigColor |
Border color while pressed. |
active_background |
ConfigColor |
Background color while pressed. |
focus_border |
ConfigColor |
Border color while keyboard-focused. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in normal state. |
hover_border_width |
int |
Border width while hovered. |
active_border_width |
int |
Border width while pressed. |
border_radius |
int |
Border corner radius in pixels. |
XtkConfig::LabelBlock
A label's style ([label]; see xtk_label.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Text color. |
background |
ConfigColor |
Background color. |
border |
ConfigColor |
Border color. |
padding |
int |
Internal padding in pixels, for a label made with padding -1 ([label] padding) |
border_width |
int |
Border width in pixels, for a label made with border_width -1 ([label] border-width) |
border_radius |
int |
Border corner radius in pixels, for a label made with border_radius -1 ([label] border-radius) |
border_enabled |
int |
Non-zero to draw the border, for a label made with border_enabled -1 ([label] border-enabled) |
XtkConfig::SpinButtonBlock
A spin button's style ([spinbutton]; see xtk_spinbutton.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Text color. |
background |
ConfigColor |
Field background color. |
border |
ConfigColor |
Border color in normal state. |
hover_border |
ConfigColor |
Border color while hovered. |
hover_background |
ConfigColor |
Background color while hovered. |
focus_border |
ConfigColor |
Border color while focused. |
button_foreground |
ConfigColor |
Increment/decrement button glyph color. |
button_hover_background |
ConfigColor |
Increment/decrement button background while hovered. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
button_width |
int |
Width of the increment/decrement buttons. |
XtkConfig::SliderBlock
A slider's style ([slider]; see xtk_slider.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Not used: the slider draws no text (kept so the struct stays the same) |
font_size |
int |
Not used: the slider draws no text. |
foreground |
ConfigColor |
Tick mark color. |
background |
ConfigColor |
Widget window background (the margin outside the track); also the base disabled colors blend toward. |
border |
ConfigColor |
The frame around the slider (border_width pixels; none when 0) |
track_background |
ConfigColor |
Track background color. |
track_border |
ConfigColor |
Track border color. |
fill_background |
ConfigColor |
Filled (traversed) portion of the track. |
handle_foreground |
ConfigColor |
The grip: a line across the handle ("handle-foreground") |
handle_background |
ConfigColor |
The handle's fill ("handle-background") |
handle_border |
ConfigColor |
Handle border color. |
handle_hover_background |
ConfigColor |
The handle's fill while hovered ("handle-hover-background") |
handle_hover_border |
ConfigColor |
Handle border color while hovered. |
handle_focus_border |
ConfigColor |
Handle border color while keyboard-focused. |
border_width |
int |
The frame's width in pixels ("border-width", default 1) |
border_radius |
int |
The frame's corner radius in pixels ("border-radius") |
track_height |
int |
Track thickness in pixels ("track-height"); 0 = a third of the slider's thickness. |
handle_width |
int |
Handle size along the track in pixels ("handle-width"); 0 = automatic. |
handle_height |
int |
Handle size across the track in pixels ("handle-height"); 0 = half the slider's thickness. |
XtkConfig::CheckboxBlock
A checkbox's style ([checkbox]; see xtk_checkbox.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Label text color. |
background |
ConfigColor |
Checkbox box background color. |
border |
ConfigColor |
Box border color. |
hover_border |
ConfigColor |
Box border color while hovered. |
focus_border |
ConfigColor |
Box border color while keyboard-focused. |
check_foreground |
ConfigColor |
Checkmark color. |
box_size |
int |
Box side length in pixels. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
label_gap |
int |
Gap in pixels between box and label. |
XtkConfig::RadioButtonBlock
A radio button's style ([radiobutton]; see xtk_radiobutton.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Label text color. |
background |
ConfigColor |
Circle background color. |
border |
ConfigColor |
Circle border color. |
hover_border |
ConfigColor |
Circle border color while hovered. |
focus_border |
ConfigColor |
Circle border color while keyboard-focused. |
fill_foreground |
ConfigColor |
Selected-state dot color. |
circle_size |
int |
Circle diameter in pixels. |
border_width |
int |
Border width in pixels. |
label_gap |
int |
Gap in pixels between circle and label. |
XtkConfig::ComboBoxBlock
A combo box's style ([combobox]; see xtk_combobox.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Text color. |
background |
ConfigColor |
Field background color. |
border |
ConfigColor |
Border color in normal state. |
hover_border |
ConfigColor |
Border color while hovered. |
hover_background |
ConfigColor |
Background color while hovered. |
focus_border |
ConfigColor |
Border color while focused. |
active_background |
ConfigColor |
Background color while dropdown is open. |
dropdown_background |
ConfigColor |
Dropdown list background color. |
dropdown_hover_background |
ConfigColor |
Dropdown item background while hovered. |
dropdown_hover_foreground |
ConfigColor |
Dropdown item text color while hovered. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
XtkConfig::NotebookBlock
A notebook's style ([notebook]; see xtk_notebook.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Tab label text color. |
background |
ConfigColor |
Inactive tab background color. |
border |
ConfigColor |
Tab border and separator color. |
hover_background |
ConfigColor |
Tab background color while hovered. |
active_background |
ConfigColor |
Active tab background color. |
active_border |
ConfigColor |
Active tab border accent color. |
focus_border |
ConfigColor |
Active tab's extra border ring while the tab strip holds keyboard focus. |
tab_bar_background |
ConfigColor |
Tab bar background beyond the tabs themselves. |
content_background |
ConfigColor |
Content area background color. |
content_foreground |
ConfigColor |
Content area text color. |
tab_height |
int |
Tab height in pixels; a copy of [notebook-widget] tab-height (the notebook draws with notebook_widget) |
tab_padding |
int |
Internal padding within each tab; a copy of [notebook-widget] tab-padding. |
tab_min_width |
int |
Minimum tab width in pixels; a copy of [notebook-widget] tab-min-width. |
border_width |
int |
Border width in pixels; a copy of [notebook-widget] border-width. |
border_radius |
int |
Border corner radius in pixels; a copy of [notebook-widget] border-radius. |
XtkConfig::TextViewBlock
A text view's colors, including the syntax colors for config text ([textview]; XtkTextViewTheme in xtk_textview.h).
| Field | Type | Description |
|---|---|---|
text |
ConfigColor |
Default text color. |
background |
ConfigColor |
Background color. |
selection |
ConfigColor |
Selection background color. |
selection_text |
ConfigColor |
Selected text color. |
line_numbers |
ConfigColor |
Line number gutter text color. |
line_numbers_background |
ConfigColor |
Line number gutter background color. |
cursor |
ConfigColor |
Cursor color. |
section |
ConfigColor |
[section] header highlight color |
key |
ConfigColor |
key = value: the key part's color |
value |
ConfigColor |
key = value: the value part's color |
comment |
ConfigColor |
#### comment highlight color |
hex_color |
ConfigColor |
Hex color literal (#RRGGBB) highlight color. |
number |
ConfigColor |
Numeric literal highlight color. |
border |
ConfigColor |
Widget border color. |
focus_border |
ConfigColor |
Border color when the widget has keyboard focus. |
link |
ConfigColor |
xtk_richtext LINK span color (underlined text) |
scrollbar_thumb |
ConfigColor |
Vertical/horizontal scrollbar thumb color (unhovered) — deliberately separate from border, which a resize/dock divider also uses. |
highlight |
ConfigColor |
xtk_richtext ==highlighted== text's background |
cursor_blink_ms |
int |
The caret's blink interval in milliseconds; a copy of [behavior] cursor-blink-ms (0 or less: 600) |
XtkConfig::TooltipBlock
A tooltip's colors, geometry and delay ([tooltip]; XtkTooltipTheme in xtk_tooltip.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Background color. |
foreground |
ConfigColor |
Text color. |
border |
ConfigColor |
Border color. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
padding |
int |
Internal padding in pixels. |
font_size |
int |
Font size in pixels. |
delay_ms |
int |
Delay before showing, in milliseconds. |
arrow_size |
int |
Arrow pointer size in pixels (0 = no arrow). App-set behavior, not a config file key. |
font_family[64] |
char |
Font family name. |
XtkConfig::TrayMenuBlock
The tray icon menu's style ([tray-menu]; see xtk_tray.h).
| Field | Type | Description |
|---|---|---|
font_family[64] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
foreground |
ConfigColor |
Text color. |
background |
ConfigColor |
Background color. |
hover_background |
ConfigColor |
Background color while hovered. |
hover_foreground |
ConfigColor |
Text color while hovered (unset - alpha 0 - the text color) |
border |
ConfigColor |
Border color. |
padding |
int |
Internal padding in pixels. |
border_width |
int |
Border width in pixels. |
border_radius |
int |
Border corner radius in pixels. |
XtkConfig::SplitPaneBlock
A split pane's colors ([splitpane]; see xtk_splitpane.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Fallback background behind children. |
divider_background |
ConfigColor |
Divider color (draw_divider()'s own grip dots are derived from this, not a separate field) |
XtkConfig::ToolWindowBlock
A tool window's style ([toolwindow]; see xtk_toolwindow.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Header title font family name. |
font_size |
int |
Header title font size in pixels. |
header_background |
ConfigColor |
Header bar background color. |
header_foreground |
ConfigColor |
Header title text color. |
header_border |
ConfigColor |
Header bar border color. |
titlebar_border |
ConfigColor |
The titlebar's own top and side edges. |
content_background |
ConfigColor |
Content area fallback background color. |
icon_foreground |
ConfigColor |
Header icon color in normal state. |
icon_hover_foreground |
ConfigColor |
Header icon color while hovered. |
icon_hover_background |
ConfigColor |
Header icon hit-region background while hovered. |
scrollbar_track |
ConfigColor |
Vertical/horizontal scrollbar track color. |
scrollbar_thumb |
ConfigColor |
Scrollbar thumb color (brightens on hover/drag) |
badge_background |
ConfigColor |
The header's badge pill (messages such as "copied") |
badge_foreground |
ConfigColor |
The badge's text. |
XtkConfig::DockFrameBlock
A dock frame's colors ([dockframe]; see xtk_dockframe.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Frame background behind all regions. |
drop_zone_highlight |
ConfigColor |
Drag drop-zone highlight color. |
XtkConfig::TreeViewBlock
A tree view's style ([treeview]; see xtk_treeview.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Row label font family name. |
font_size |
int |
Row label font size in pixels. |
background |
ConfigColor |
Background behind all rows. |
foreground |
ConfigColor |
Row label text color. |
selected_background |
ConfigColor |
Selected row background color. |
selected_foreground |
ConfigColor |
Selected row label text color. |
hover_background |
ConfigColor |
Hovered (not selected) row background color. |
branch_line |
ConfigColor |
Expand/collapse twisty color. |
border |
ConfigColor |
Outer border color (see treeview_widget.border_width) |
focus_border |
ConfigColor |
Outer border color while keyboard-focused. |
unsaved_foreground |
ConfigColor |
Row label text color for a node created this session and not yet saved (drawn bold too, not just this color) |
inactive_selected_background |
ConfigColor |
Selected row background while the tree hasn't keyboard focus. |
inactive_selected_foreground |
ConfigColor |
Selected row label text color while the tree hasn't keyboard focus. |
XtkConfig::ProgressBarBlock
A progress bar's style ([progressbar]; see xtk_progressbar.h).
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Overlay-text font family name. |
font_size |
int |
Overlay-text font size in pixels. |
background |
ConfigColor |
Track (unfilled) background color. |
border |
ConfigColor |
Track border color. |
fill |
ConfigColor |
Filled/progress portion color. |
fill_pulse |
ConfigColor |
Indeterminate-mode moving block color. |
text |
ConfigColor |
Overlay percentage/status text color, over the empty track. |
fill_text |
ConfigColor |
The overlay text where it crosses the filled part. |
XtkConfig::ScrollbarBlock
A scrollbar's colors ([scrollbar]; see xtk_scrollbar.h).
| Field | Type | Description |
|---|---|---|
track |
ConfigColor |
Track (unfilled) background color. |
thumb |
ConfigColor |
Thumb color, unhovered/undragged. |
thumb_hover |
ConfigColor |
Thumb color while hovered or dragged. |
XtkConfig::StatusbarBlock
The status bar's colors ([statusbar]; see xtk_statusbar.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Bar background. |
foreground |
ConfigColor |
Status text color. |
border |
ConfigColor |
Separator line along its top. |
message_background |
ConfigColor |
The pill on its right (a drop indicator) |
message_foreground |
ConfigColor |
The pill's text. |
XtkConfig::PathBarBlock
A path bar's colors ([pathbar]; see xtk_pathbar.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
The box. |
foreground |
ConfigColor |
The names and the separators. |
hover_background |
ConfigColor |
The pill under the pointer. |
hover_foreground |
ConfigColor |
The name in the pill. |
border |
ConfigColor |
The box's edge. |
XtkConfig::IconViewBlock
An icon view's colors ([iconview]; see xtk_iconview.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Behind the items. |
foreground |
ConfigColor |
The names. |
selected_background |
ConfigColor |
Behind a selected item's icon and name. |
selected_foreground |
ConfigColor |
A selected item's name. |
hover_background |
ConfigColor |
Behind the item under the pointer. |
focus_border |
ConfigColor |
The frame of the keyboard's item. |
rubber_band |
ConfigColor |
The rectangle dragged to select. |
muted |
ConfigColor |
The text an empty view shows. |
XtkConfig::DataGridBlock
A data grid's colors ([datagrid]; see xtk_datagrid.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Cell background (even rows) and the area below the rows. |
foreground |
ConfigColor |
Cell text color. |
alternate_background |
ConfigColor |
Odd rows' background. |
header_background |
ConfigColor |
Header row background. |
header_foreground |
ConfigColor |
Header row text color. |
selected_background |
ConfigColor |
Selected cell background. |
selected_foreground |
ConfigColor |
Selected cell text color. |
XtkConfig::GraphBlock
A graph view's colors ([graph]; see xtk_graph.h).
| Field | Type | Description |
|---|---|---|
background |
ConfigColor |
Canvas background. |
node_background |
ConfigColor |
A node's fill. |
node_foreground |
ConfigColor |
A node's label. |
edge |
ConfigColor |
Edges between untinted nodes. |
selected_background |
ConfigColor |
The selected node's fill. |
neighbor_background |
ConfigColor |
Fill of the selected node's neighbors. |
hub_background |
ConfigColor |
Tint of the most connected nodes. |
focus_border |
ConfigColor |
The node with keyboard focus. |
XtkConfig::FrameBlock
A frame's style ([frame]; see xtk_frame.h). The title is drawn in the label color, config.label.foreground.
| Field | Type | Description |
|---|---|---|
font_family[128] |
char |
Title text font family name. |
font_size |
int |
Title text font size in pixels. |
border |
ConfigColor |
Border line color. |
XtkConfig::ZoomHexBlock
The zoom widget's color readout ([zoom-hex]).
The zoom widget does not read XtkConfig; a program that wants the readout to follow the config passes these fields to xtk_zoom_set_hex_label_style(), xtk_zoom_set_hex_border_style(), xtk_zoom_set_hex_position() and xtk_zoom_set_hex_readout().
| Field | Type | Description |
|---|---|---|
foreground |
ConfigColor |
Readout text color. |
background |
ConfigColor |
Readout box background color. |
border |
ConfigColor |
Readout box border color. |
border_show |
int |
Non-zero to draw the border. |
border_width |
int |
Border width in pixels. |
font_family[128] |
char |
Font family name. |
font_size |
int |
Font size in pixels. |
position |
ZoomHexPosition |
Corner the readout is anchored to. |
show |
int |
Non-zero to show the readout at all. |
ButtonBlock
typedef struct ButtonBlock ButtonBlock;
See XtkConfig::ButtonBlock.
EntryBlock
typedef struct EntryBlock EntryBlock;
See XtkConfig::EntryBlock.
MenuBlock
typedef struct MenuBlock MenuBlock;
LabelBlock
typedef struct LabelBlock LabelBlock;
See XtkConfig::LabelBlock.
SpinButtonBlock
typedef struct SpinButtonBlock SpinButtonBlock;
See XtkConfig::SpinButtonBlock.
SliderBlock
typedef struct SliderBlock SliderBlock;
See XtkConfig::SliderBlock.
CheckboxBlock
typedef struct CheckboxBlock CheckboxBlock;
See XtkConfig::CheckboxBlock.
RadioButtonBlock
typedef struct RadioButtonBlock RadioButtonBlock;
See XtkConfig::RadioButtonBlock.
ComboBoxBlock
typedef struct ComboBoxBlock ComboBoxBlock;
See XtkConfig::ComboBoxBlock.
NotebookBlock
typedef struct NotebookBlock NotebookBlock;
See XtkConfig::NotebookBlock.
TextViewBlock
typedef struct TextViewBlock TextViewBlock;
See XtkConfig::TextViewBlock.
TooltipBlock
typedef struct TooltipBlock TooltipBlock;
See XtkConfig::TooltipBlock.
TrayMenuBlock
typedef struct TrayMenuBlock TrayMenuBlock;
See XtkConfig::TrayMenuBlock.
SplitPaneBlock
typedef struct SplitPaneBlock SplitPaneBlock;
See XtkConfig::SplitPaneBlock.
ToolWindowBlock
typedef struct ToolWindowBlock ToolWindowBlock;
See XtkConfig::ToolWindowBlock.
DockFrameBlock
typedef struct DockFrameBlock DockFrameBlock;
See XtkConfig::DockFrameBlock.
TreeViewBlock
typedef struct TreeViewBlock TreeViewBlock;
See XtkConfig::TreeViewBlock.
ProgressBarBlock
typedef struct ProgressBarBlock ProgressBarBlock;
See XtkConfig::ProgressBarBlock.
PathBarBlock
typedef struct PathBarBlock PathBarBlock;
See XtkConfig::PathBarBlock.
IconViewBlock
typedef struct IconViewBlock IconViewBlock;
See XtkConfig::IconViewBlock.
ScrollbarBlock
typedef struct ScrollbarBlock ScrollbarBlock;
See XtkConfig::ScrollbarBlock.
StatusbarBlock
typedef struct StatusbarBlock StatusbarBlock;
See XtkConfig::StatusbarBlock.
DataGridBlock
typedef struct DataGridBlock DataGridBlock;
See XtkConfig::DataGridBlock.
GraphBlock
typedef struct GraphBlock GraphBlock;
See XtkConfig::GraphBlock.
FrameBlock
typedef struct FrameBlock FrameBlock;
See XtkConfig::FrameBlock.
ZoomHexBlock
typedef struct ZoomHexBlock ZoomHexBlock;
See XtkConfig::ZoomHexBlock.
XtkConfigKeyCallback
typedef void (*XtkConfigKeyCallback)(const char *section, const char *key, const char *value, void *user_data);
Callback that gets each key = value line of a file read with xtk_config_parse_file().
A program keeps its own settings in its own struct and its own sections of the config file; this is how it reads them. The strings are only valid during the call.
Constants
XTK_CONFIG_FOCUS_BORDER_DEFAULT
#define XTK_CONFIG_FOCUS_BORDER_DEFAULT ((ConfigColor){0.50, 0.70, 1.0, 1.0})
The default color of a keyboard-focus border, #80B3FF, used by the focusable widgets.
Functions
xtk_config_init
void xtk_config_init(XtkConfig *config);
Set a config to the built-in defaults; the same as xtk_config_init_defaults().
| Parameter | Description |
|---|---|
config |
The configuration to fill; nothing happens when it is NULL |
xtk_config_load
int xtk_config_load(XtkConfig *config, const char *path);
Read a config file over a config.
Every key = value line goes through xtk_config_set(), so the file only changes the keys it has; everything else keeps its value. Lines the toolkit does not know are ignored. Call xtk_config_init_defaults() (and apply a theme, if any) first.
| Parameter | Description |
|---|---|
config |
The configuration to update |
path |
The file's path |
Returns: 1 if the file was read, 0 if config or path is NULL or the file could not be opened (config is then unchanged)
xtk_config_load_from_home
int xtk_config_load_from_home(XtkConfig *config, const char *home);
Read the toolkit's own config file in a home folder: home/.config/xtk/xtk.conf.
The same as xtk_config_load() with that path. A program that keeps its settings in a file of its own calls xtk_config_load() with that file's path instead.
| Parameter | Description |
|---|---|
config |
The configuration to update |
home |
The home folder's path, for example the value of HOME |
Returns: 1 if the file was read, 0 if an argument is NULL or empty or the file could not be opened (config is then unchanged)
xtk_config_write_defaults
int xtk_config_write_defaults(const char *path);
Write a config file with the built-in defaults.
Makes a config with xtk_config_init_defaults() and writes it with xtk_config_write_defaults_with_values(). An existing file is replaced.
| Parameter | Description |
|---|---|
path |
The file's path |
Returns: 1 when written, 0 if path is NULL or the file could not be opened
xtk_config_write_defaults_with_values
int xtk_config_write_defaults_with_values(FILE *file, XtkConfig *config);
Write a config as a complete config file.
Writes a short comment header, then [main], every widget section that is registered (see xtk_config_registry_write_all()), then [zoom], [behavior], [clipboard], [sizes], [zoom-widget] and [zoom-hex]. Colors are written as #RRGGBB, or #RRGGBBAA when not opaque; a gradient is written as its average color.
| Parameter | Description |
|---|---|
file |
The open file to write to |
config |
The configuration to write (it is not changed) |
Returns: 1 when written, 0 if file or config is NULL
xtk_config_init_defaults
void xtk_config_init_defaults(XtkConfig *config);
Clear a config and set the built-in defaults.
Every field is set to zero first. Then each registered widget section sets its defaults (see xtk_config_registry.h), and the sections of xtk_config.c get theirs (listed at the top of this page). Nothing happens when config is NULL.
| Parameter | Description |
|---|---|
config |
The configuration to fill |
xtk_config_set
int xtk_config_set(
XtkConfig *config,
const char *section,
const char *key,
const char *value);
Set one key, as a key = value line in a [section] of a config file does.
A key in the color table is set first, whatever its section: its value may be a color or a CSS gradient (the gradient goes into the paint table of xtk_paint.h, and the field gets its average color). The sections of xtk_config.c come next. For any other section, highlight and shade set the section's bevel (see xtk_paint.h); every other key goes to the section's handler (see xtk_config_registry.h), with a gradient given to it as its average color. Themes set their keys through this function too.
| Parameter | Description |
|---|---|
config |
The configuration to update |
section |
The section, for example "button" |
key |
The key, for example "background" |
value |
The value, as a config file writes it |
Returns: 0 if an argument is NULL, a gradient cannot be read or a bevel color cannot be read. For a key of a widget section, what the section's handler returned: 1 for a key it knows, 0 for one it does not (0 also when no handler is registered). 1 otherwise, including for a key that a section of xtk_config.c does not know.
xtk_config_parse_color
ConfigColor xtk_config_parse_color(const char *hex_string);
Read a color, in any form xtk_paint_parse_color() reads.
#RRGGBB, #RRGGBBAA, #RGB, #RGBA, rgb(), rgba(), white, black and transparent; also six or eight hex digits without the #. Without an alpha, alpha is 1.0 (opaque). Every digit is checked, so #ABCDEG is not a color.
| Parameter | Description |
|---|---|
hex_string |
The color as text |
Returns: The color; opaque black if hex_string is NULL or not a color
xtk_config_parse_file
int xtk_config_parse_file(
const char *path,
XtkConfigKeyCallback callback,
void *user_data);
Read a config file line by line, calling a function for each key.
The file format is the one at the top of this page. Comment lines, empty lines and lines without = are skipped.
| Parameter | Description |
|---|---|
path |
The file's path |
callback |
Called for every key = value line, with its section |
user_data |
Passed to callback |
Returns: 1 if the file was read, 0 if path or callback is NULL or the file could not be opened
xtk_config_write_color
void xtk_config_write_color(FILE *file, const char *key, ConfigColor color);
Write one color line: key = #RRGGBB, or key = #RRGGBBAA when the color is not opaque.
For a program that writes its own sections of the config file. Does nothing when file or key is NULL.
| Parameter | Description |
|---|---|
file |
The file to write to |
key |
The key |
color |
The color (components clamped to 0.0 to 1.0) |
xtk_config_color_key_count
int xtk_config_color_key_count(void);
How many keys the color table has.
Returns: The number of color keys
xtk_config_color_key_at
int xtk_config_color_key_at(int i, const char **section, const char **key);
One entry of the color table: its section and key.
| Parameter | Description |
|---|---|
i |
The index, from 0 to xtk_config_color_key_count() - 1 |
section |
Receives the section name; may be NULL |
key |
Receives the key; may be NULL |
Returns: 1 if i is an entry, 0 if it is out of range
xtk_config_color_field
ConfigColor *xtk_config_color_field(
XtkConfig *config,
const char *section,
const char *key);
The field of a config that a color key sets.
| Parameter | Description |
|---|---|
config |
The configuration |
section |
The section |
key |
The key |
Returns: A pointer to the color field in config, or NULL if the section and key are not in the color table (or an argument is NULL)
xtk_config_mark_changed
void xtk_config_mark_changed(XtkConfig *config);
Mark a config as changed since it was last saved (sets changed to 1).
| Parameter | Description |
|---|---|
config |
The configuration; nothing happens when it is NULL |
xtk_config_mark_saved
void xtk_config_mark_saved(XtkConfig *config);
Mark a config as just saved (sets changed to 0).
| Parameter | Description |
|---|---|
config |
The configuration; nothing happens when it is NULL |
xtk_config_has_unsaved_changes
int xtk_config_has_unsaved_changes(const XtkConfig *config);
Whether a config has been marked as changed since it was last saved.
| Parameter | Description |
|---|---|
config |
The configuration |
Returns: 1 if it has unsaved changes, 0 if not (or config is NULL)
xtk_config_get_border_mode
BorderMode xtk_config_get_border_mode(void);
How swatches work out their border color, for every swatch without a mode of its own.
The setting is global to the process. Its default is BORDER_MODE_COMPLEMENTARY.
Returns: The border mode
xtk_config_set_border_mode
void xtk_config_set_border_mode(BorderMode mode);
Set how swatches work out their border color, for every swatch without a mode of its own.
The setting is global to the process. A config or theme file's [swatch] border-mode sets it as it is read (xtk_config_set()).
| Parameter | Description |
|---|---|
mode |
The border mode |
xtk_config_color_to_pixel
unsigned long xtk_config_color_to_pixel(Display *display, int screen, ConfigColor color);
The X pixel value of a color.
On a TrueColor visual (every modern X server) the pixel is computed from the color with no round trip, which matters as widgets call this on every repaint. On other visuals it is allocated in the default colormap with XAllocColor(). Components are clamped to 0.0 to 1.0; alpha is ignored. The pixel needs no freeing.
| Parameter | Description |
|---|---|
display |
The X connection |
screen |
The screen number |
color |
The color |
Returns: The pixel value; the screen's black pixel if the allocation failed, and 0 if display is NULL
xtk_config_pixel_to_color
ConfigColor xtk_config_pixel_to_color(Display *display, int screen, unsigned long pixel);
The color of an X pixel value: the reverse of xtk_config_color_to_pixel().
For a widget that works with raw pixel values (for example xtk_zoom.h), where its value has to reach a widget that takes a ConfigColor. It asks the server (XQueryColor()), so where a ConfigColor is at hand, keep that instead.
| Parameter | Description |
|---|---|
display |
The X connection |
screen |
The screen number |
pixel |
The pixel value |
Returns: The pixel's color, opaque; all zero if display is NULL
xtk_config_color_to_xft
XftColor xtk_config_color_to_xft(Display *display, int screen, ConfigColor color);
An XftColor for a color, alpha included, for drawing text with Xft.
| Parameter | Description |
|---|---|
display |
The X connection |
screen |
The screen number |
color |
The color (components clamped to 0.0 to 1.0) |
Returns: The color; free it with XftColorFree(). All zero if display is NULL.
xtk_config_blend_color
ConfigColor xtk_config_blend_color(ConfigColor a, ConfigColor b, double fraction);
Mix two colors, alpha included.
| Parameter | Description |
|---|---|
a |
The first color |
b |
The second color |
fraction |
The share of a in the result, from 0.0 to 1.0; b gets the rest |
Returns: fraction * a + (1 - fraction) * b, channel by channel
xtk_config_open_font
XftFont *xtk_config_open_font(Display *display, int screen, const char *family, int size);
Open a font by family name and pixel size.
Fontconfig finds the best installed match for the family (with its aliases and substitutions). If nothing matches or the font cannot be opened, "sans-14" is opened instead. Close the font with XftFontClose().
| Parameter | Description |
|---|---|
display |
The X connection |
screen |
The screen number |
family |
The family name, for example "sans", "monospace" or "DejaVu Sans"; it may also hold fontconfig options, as in "monospace:bold". NULL or "" means "sans". |
size |
The size in pixels |
Returns: The font; NULL only if even the fallback font cannot be opened
xtk_config_covering_font
XftFont *xtk_config_covering_font(
Display *display,
XftFont *intended,
unsigned int codepoint);
The font to draw one character in, so that it does not show as a box.
Xft draws a run of text in one font and has no fallback of its own, so a widget that draws any text calls this for each character. The answer is intended when it has the character (always for ASCII). Otherwise it is the first installed font, most like intended and at its size, that has it (a CJK font for Chinese, say). For the characters U+1F000 to U+1FAFF, which are pictures by default, a color emoji font is tried first (see xtk_config_emoji_font()). When no installed font has the character, the answer is intended (which shows a box).
The fonts found are kept for the program's life and shared by all widgets (there is no limit on how many); do not close them. A character no font has is remembered, so it is not looked up again.
| Parameter | Description |
|---|---|
display |
The X connection |
intended |
The font the text is meant to be in |
codepoint |
The character (a Unicode code point) |
Returns: The font to draw the character in; intended when display or intended is NULL
xtk_config_emoji_font
XftFont *xtk_config_emoji_font(
Display *display,
XftFont *intended,
unsigned int codepoint);
A color font that has a character, at the size of intended: the picture form of an emoji.
xtk_config_covering_font() calls this itself for the characters that are pictures by default (U+1F000 to U+1FAFF). A widget calls it for a character that is a picture only when the emoji selector U+FE0F follows it (U+2764, the heart, for example), and for the first character of an emoji sequence. Only the first color font fontconfig finds for the family "emoji" is used. The fonts found are kept for the program's life and shared; do not close them. Fontconfig is asked once for each display and size, also when it has no color font.
| Parameter | Description |
|---|---|
display |
The X connection |
intended |
The font the text is meant to be in; its size is the size wanted |
codepoint |
The character (a Unicode code point) |
Returns: The color font, or NULL when no color font is installed, it lacks the character, or display or intended is NULL
xtk API
Widgets
- button
- checkbox
- radiobutton
- label
- entry
- textview
- edit_history
- spinbutton
- slider
- progressbar
- combobox
- scrollbar
- swatch
- panel
- statusbar
- tooltip
- toolbar
- icongrid
- iconview
- pathbar
- treeview
- datagrid
- graph
- scheme_wheel
- zoom
- tray
Containers and menus
Dialogs
Rich text
Drawing and images
Color
Configuration and themes
Input and the X server
Safety
Data formats