2 Home
liquibyte edited this page 2026-11-27 16:51:41 -06:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

xtk API reference

Xtk is a small widget toolkit for X11, written in C on Xlib, Xft and the X extensions. Each header is a page here: what it is for, how to make and use it, its types, constants and functions, with what every parameter and return value means, and the theme keys a widget reads.

The guide explains how the parts fit together: Overview (what is in the toolkit, the rules every widget follows, building and installing), First Program, The Event Loop (events, callbacks, timers, keyboard focus, input methods, the clipboard), Themes (the theme file, the role colors and every section and key of the settings file), Drawing and Safety (the jail and the jailed worker).

These pages are generated from the Doxygen comments in Xtk's headers (src/*.h).

Version 1.13.

Widgets

  • xtk_button.h - A push button with a text label
  • xtk_checkbox.h - A check box with a text label
  • xtk_radiobutton.h - Radio buttons: one choice out of a group
  • xtk_label.h - A line of text, with an optional border, that the user cannot edit
  • xtk_entry.h - A single-line text field, for text, whole numbers, decimals or hex colors
  • xtk_textview.h - A multi-line plain text editor, with the features of a code editor
  • xtk_edit_history.h - An undo and redo history for a text buffer, which also knows whether the text is saved
  • xtk_spinbutton.h - A number entry with + and − buttons
  • xtk_slider.h - A slider for choosing a number in a range by dragging a handle
  • xtk_progressbar.h - A progress bar that shows how much of a task is done, or that work is going on
  • xtk_combobox.h - A drop-down list for choosing one item out of several
  • xtk_scrollbar.h - A vertical or horizontal scrollbar for content the program scrolls itself
  • xtk_swatch.h - A color well that shows one color and can be dragged to drop it somewhere
  • xtk_panel.h - A scrolling color-map list: each row maps an original color to a palette color
  • xtk_statusbar.h - A thin bar that shows one line of status text
  • xtk_tooltip.h - A small window of help text that shows beside a widget, plain or rich
  • xtk_toolbar.h - A row of icon buttons for a program's most used actions
  • xtk_icongrid.h - A search box over a scrolling grid of icons, for picking one
  • xtk_iconview.h - A grid of icons with their names under them, to select and open
  • xtk_pathbar.h - A folder's path as breadcrumbs: a click on a folder goes there, a click elsewhere types a path
  • xtk_treeview.h - A tree of rows that expand and collapse, with children loaded on demand
  • xtk_datagrid.h - A small table of editable text cells, with a header row and an Add Row button
  • xtk_graph.h - A view of labeled nodes joined by lines, which the user can drag about
  • xtk_scheme_wheel.h - A hue ring with draggable markers and a saturation/value triangle, for choosing colors and color schemes
  • xtk_zoom.h - A screen magnifier that picks the color of a pixel anywhere on the screen
  • xtk_tray.h - An icon in the desktop's system tray, with a tooltip, a context menu and notifications

Containers and menus

  • xtk_grid.h - A layout helper that places widgets in the cells of rows and columns
  • xtk_frame.h - A titled group box: a border around a group of widgets, with a title in its top edge
  • xtk_notebook.h - A tabbed container: a strip of tabs over a stack of pages, one shown at a time
  • xtk_splitpane.h - A container that shows two windows side by side or one above the other, with a divider the user drags to share the space
  • xtk_dockframe.h - A docking layout: panels (tool windows) arranged at the left, right, bottom and center of a window, which the user can drag, float, stack, hide and resize
  • xtk_toolwindow.h - A dockable panel: a header with a title and buttons over a scrollable content area, docked in a container or floating
  • xtk_menu.h - A menu bar: a row of titles, each opening a drop-down menu
  • xtk_popup_menu.h - A pop-up menu of items: context menus, drop-down menus and flyouts

Dialogs

  • xtk_filedialog.h - A dialog window for choosing a file to open or save, or a folder
  • xtk_colorpicker.h - A color chooser dialog with a hue wheel, a hex entry and a row of saved colors

Rich text

  • xtk_richtext.h - A rich text editor that reads and writes Markdown, and can also show its Markdown source
  • xtk_richtext_toolbar.h - A formatting toolbar for an XtkRichText editor
  • xtk_markdown.h - A CommonMark parser that reports a document's blocks, spans and text through callbacks
  • xtk_mathtext.h - Lays out and draws one LaTeX math formula

Drawing and images

  • xtk_draw.h - Drawing shapes for widgets: rounded rectangles, circles, window shapes, smooth lines
  • xtk_paint.h - Gradient fills and bevel edges that a theme can give a widget
  • xtk_surface.h - Where a widget paints one window: a back buffer, a pixmap or the window itself
  • xtk_dbe.h - Back buffers for windows through the X Double Buffer Extension (DBE)
  • xtk_vector.h - A small 2D vector rasterizer that draws paths into an RGBA8 buffer
  • xtk_svg.h - Renders SVG documents, such as icons, into RGBA8 images
  • xtk_image.h - Loads PNG, JPEG, GIF, BMP and XPM images as pixmaps, alpha pictures or raw pixels
  • xtk_shape.h - Text shaping: the glyphs a font gives for a run of characters
  • xtk_icon.h - Named icons for rows, buttons and menus, drawn in one color at any size
  • xtk_icon_theme.h - The user's icon theme: which one it is, and the file of an icon in it

Color

  • xtk_color_space.h - Color conversions between sRGB and many other color spaces, color differences, contrast and color blindness simulation
  • xtk_gradient.h - A color gradient: its stops, its colors at any point, pixel previews and text exports

Configuration and themes

  • xtk_config.h - The look of every widget (XtkConfig), and the config file it is read from
  • xtk_config_registry.h - The list of config file sections that widgets read and write themselves
  • xtk_theme.h - Themes: a few role colors that set every widget's colors, plus overrides for single keys
  • xtk_version.h - The version of the toolkit, as a string

Input and the X server

  • xtk_clipboard.h - Copy and paste text through the X CLIPBOARD and PRIMARY selections
  • xtk_ime.h - Input method support, so text widgets can take Chinese, Japanese and Korean input
  • xtk_focus.h - A focus manager: Ctrl+Tab and Ctrl+Shift+Tab move keyboard focus between widgets
  • xtk_xerror.h - Catch the X errors of a few requests on windows of other programs

Safety

  • xtk_sandbox.h - A jail, enforced by the Linux kernel, for a process that reads untrusted files
  • xtk_worker.h - One jailed worker process for each program, which takes apart untrusted data for it

Data formats

  • xtk_json.h - Reads JSON text into a tree of values
  • xtk_xml.h - Reads XML or HTML text into a tree of elements and text
  • xtk_csv.h - Reads CSV text into a table of rows and fields
  • xtk_md5.h - The MD5 digest (RFC 1321), for names and keys other programs make with it