Module: ui.widgets.checkbox

Source: ./ui/widgets/checkbox.reef


Overview

ui/widgets/checkbox.reef - Boolean toggle control Part of reef-stdlib UI module

The Checkbox widget provides a toggleable boolean control. It displays a box that can be checked or unchecked, with an optional text label.

Checkboxes support:

  • Checked/unchecked states
  • Optional indeterminate state
  • Text labels
  • Focus and disabled states
  • Keyboard activation (Space to toggle)

Types

CheckState (enum)

Variants:

  • Unchecked
  • Checked
  • Indeterminate

CheckboxEventResultKind (enum)

Variants:

  • Ignored
  • Handled
  • Toggled

CheckboxEventResult

Fields:

Name Type
kind CheckboxEventResultKind
checkbox Checkbox

Objects

Checkbox

Extends: widget.Widget

Fields:

Name Type
label string
check_state CheckState
focused bool
hovered bool

proc init(id: widget.WidgetId, label: string)

Methods:

override shared fn kind(): string

override exclusive proc paint(surf: surface.Surface, th: theme.Theme)


Functions

fn check_unchecked(): CheckState

fn check_checked(): CheckState

fn check_indeterminate(): CheckState

fn is_unchecked(s: CheckState): bool

fn is_checked(s: CheckState): bool

fn is_indeterminate(s: CheckState): bool

fn checkbox(label: string): Checkbox

fn checkbox_checked(label: string, checked: bool): Checkbox

fn checkbox_label(c: Checkbox): string

fn checkbox_state(c: Checkbox): CheckState

fn checkbox_is_checked(c: Checkbox): bool

fn checkbox_is_focused(c: Checkbox): bool

fn checkbox_is_enabled(c: Checkbox): bool

fn checkbox_set_label(c: Checkbox, label: string): Checkbox

fn checkbox_set_checked(c: Checkbox, checked: bool): Checkbox

fn checkbox_set_state(c: Checkbox, state: CheckState): Checkbox

fn checkbox_set_enabled(c: Checkbox, enabled: bool): Checkbox

fn checkbox_toggle(c: Checkbox): Checkbox

fn checkbox_with_hover(c: Checkbox, hovered: bool): Checkbox

fn checkbox_with_focus(c: Checkbox, focused: bool): Checkbox

fn checkbox_get_id(c: Checkbox): widget.WidgetId

fn checkbox_get_widget_state(c: Checkbox): widget.WidgetState

fn checkbox_get_bounds(c: Checkbox): core.Rect

fn checkbox_preferred_size(c: Checkbox, th: theme.Theme): core.Size

fn checkbox_layout(c: Checkbox, constraints: layout.Constraints, th: theme.Theme): Checkbox

fn checkbox_handle_event(c: Checkbox, e: event.Event): CheckboxEventResult

fn checkbox_result_ignored(): CheckboxEventResult

fn checkbox_result_handled(c: Checkbox): CheckboxEventResult

fn checkbox_result_toggled(c: Checkbox): CheckboxEventResult

fn is_checkbox_toggled(r: CheckboxEventResult): bool

fn checkbox_result_checkbox(r: CheckboxEventResult): Checkbox

fn checkbox_result_to_widget_result(r: CheckboxEventResult): widget.EventResult

fn handle_mouse_event(c: Checkbox, me: event.MouseEvent, bounds: core.Rect): CheckboxEventResult

fn handle_key_event(c: Checkbox, ke: event.KeyEvent): CheckboxEventResult

fn handle_focus_event(c: Checkbox, fe: event.FocusEvent): CheckboxEventResult

fn get_box_background(c: Checkbox, colors: theme.ThemeColors): core.Color

fn get_box_border(c: Checkbox, colors: theme.ThemeColors): core.Color

fn get_text_color(c: Checkbox, colors: theme.ThemeColors): core.Color

fn point_in_rect(px: float, py: float, r: core.Rect): bool

fn string_length(s: string): int

fn keys_equal(a: event.KeyCode, b: event.KeyCode): bool


Procedures

proc checkbox_paint(c: Checkbox, surf: surface.Surface, th: theme.Theme)

proc draw_checkmark(surf: surface.Surface, x: float, y: float, size: float, colors: theme.ThemeColors)

proc draw_dash(surf: surface.Surface, x: float, y: float, size: float, colors: theme.ThemeColors)

proc draw_rect_border(surf: surface.Surface, x: float, y: float, w: float, h: float, color: core.Color, width: float)


Generated by reefc doc