把 includes 下 64 个 .vp 的文件头注释(含 traceback.vp 第 13-427 行的整块文件级说明)以及 2 处漏网的正文中文注释(ast/lexer.vp、json/__writer.vp)与 1 处中文 docstring(memhub.vp)逐行译为英文;同步把 fltk/gen_ffi.py 的生成模板与其自身注释英文化,使重新生成仍为英文。 只改注释/文档串文字:行数与代码逐字节不变(骨架比对 140 文件漂移 0),运行时中文字符串字面量 305 处保持原样。验证:三重重编 SUCCESS(170.21s)+ 全量 77/77 顺序回归通过 + VET 编译 SUCCESS / --search-paths 7 条 exit 0。
1328 lines
39 KiB
Plaintext
1328 lines
39 KiB
Plaintext
# ============================================================
|
|
# fltk — Viper FLTK GUI binding package (wraps the cfltk C API)
|
|
#
|
|
# Usage:
|
|
# import fltk
|
|
# win = fltk.Fl_Window(400, 300, "Hello")
|
|
# box = fltk.Fl_Box(10, 10, 380, 40, "Hello, World!")
|
|
# btn = fltk.Fl_Button(150, 100, 100, 30, "Click")
|
|
# win.end()
|
|
# win.show()
|
|
# fltk.Fl.run()
|
|
#
|
|
# Notes:
|
|
# * This package only provides extern FFI (the fltk._cfl* modules) + a few Pythonic wrapper classes;
|
|
# all FLTK objects are opaque pointers; methods map to cfltk's Fl_<Class>_<action>.
|
|
# * The full C API is directly available via `from fltk._cfl import *` etc.
|
|
# * Callback support: a Viper module-level function can be passed to FLTK directly as an Fl_Callback--
|
|
# TPV auto-bitcasts the function name into a function pointer (e.g. CreateThread passes a function).
|
|
# Callback signature convention: def cb(w: bytes, data: bytes): ... (w=widget pointer, data=user data)
|
|
# def on_click(w: bytes, data: bytes):
|
|
# Fl_Widget_set_label(w, "Clicked!")
|
|
# btn.set_callback(on_click, 0)
|
|
# Fl.add_timeout(1.0, on_tick, 0)
|
|
# * Event-driven code may also poll with Fl.check()/Fl.event*().
|
|
# ============================================================
|
|
|
|
import t, c
|
|
from fltk._types import *
|
|
from fltk._enums import *
|
|
from fltk._cfl import *
|
|
from fltk._cfl_widget import *
|
|
from fltk._cfl_box import *
|
|
from fltk._cfl_button import *
|
|
from fltk._cfl_window import *
|
|
from fltk._cfl_input import *
|
|
from fltk._cfl_text import *
|
|
from fltk._cfl_group import *
|
|
from fltk._cfl_valuator import *
|
|
from fltk._cfl_menu import *
|
|
from fltk._cfl_dialog import *
|
|
from fltk._cfl_image import *
|
|
from fltk._cfl_draw import *
|
|
from fltk._cfl_misc import *
|
|
from fltk._cfl_browser import *
|
|
from fltk._cfl_table import *
|
|
from fltk._cfl_tree import *
|
|
from fltk._cfl_term import *
|
|
from fltk._cfl_prefs import *
|
|
from fltk._cfl_printer import *
|
|
from fltk._cfl_surface import *
|
|
from fltk._cfl_utils import *
|
|
from fltk._cfl_lock import *
|
|
from fltk._cfl_theme import *
|
|
|
|
|
|
# ============================================================
|
|
# Fl — FLTK global static class (event loop / events / colors)
|
|
# ============================================================
|
|
novirtual class Fl:
|
|
"""FLTK global function collection (static methods)."""
|
|
|
|
@staticmethod
|
|
def run() -> int:
|
|
return Fl_run()
|
|
|
|
@staticmethod
|
|
def check() -> int:
|
|
return Fl_check()
|
|
|
|
@staticmethod
|
|
def wait() -> int:
|
|
return Fl_wait()
|
|
|
|
@staticmethod
|
|
def wait_for(timeout: double) -> double:
|
|
return Fl_wait_for(timeout)
|
|
|
|
@staticmethod
|
|
def flush():
|
|
Fl_flush()
|
|
|
|
@staticmethod
|
|
def redraw():
|
|
Fl_redraw()
|
|
|
|
@staticmethod
|
|
def lock() -> int:
|
|
return Fl_lock()
|
|
|
|
@staticmethod
|
|
def unlock():
|
|
Fl_unlock()
|
|
|
|
@staticmethod
|
|
def event() -> int:
|
|
return Fl_event()
|
|
|
|
@staticmethod
|
|
def event_x() -> int:
|
|
return Fl_event_x()
|
|
|
|
@staticmethod
|
|
def event_y() -> int:
|
|
return Fl_event_y()
|
|
|
|
@staticmethod
|
|
def event_button() -> int:
|
|
return Fl_event_button()
|
|
|
|
@staticmethod
|
|
def event_key() -> int:
|
|
return Fl_event_key()
|
|
|
|
@staticmethod
|
|
def event_text() -> str:
|
|
return Fl_event_text()
|
|
|
|
@staticmethod
|
|
def event_length() -> int:
|
|
return Fl_event_length()
|
|
|
|
@staticmethod
|
|
def event_state() -> int:
|
|
return Fl_event_state()
|
|
|
|
@staticmethod
|
|
def event_inside(x: int, y: int, w: int, h: int) -> int:
|
|
return Fl_event_inside(x, y, w, h)
|
|
|
|
@staticmethod
|
|
def set_scheme(scheme: str) -> int:
|
|
"""Switch the global style scheme.
|
|
|
|
Built-in: 'base' / 'plastic' / 'gtk+' / 'gleam' / 'oxy'; FLTK reloads and
|
|
redraws all windows afterwards. Usage: fltk.Fl.set_scheme("plastic")"""
|
|
return Fl_set_scheme(scheme)
|
|
|
|
@staticmethod
|
|
def visible_focus() -> int:
|
|
return Fl_visible_focus()
|
|
|
|
@staticmethod
|
|
def set_visible_focus(v: int):
|
|
Fl_set_visible_focus(v)
|
|
|
|
@staticmethod
|
|
def get_rgb_color(r: uint8, g: uint8, b: uint8) -> uint32:
|
|
return Fl_get_rgb_color(r, g, b)
|
|
|
|
@staticmethod
|
|
def set_color(c: uint32, r: uint8, g: uint8, b: uint8):
|
|
Fl_set_color(c, r, g, b)
|
|
|
|
@staticmethod
|
|
def first_window() -> Fl_WindowPtr:
|
|
return Fl_first_window()
|
|
|
|
@staticmethod
|
|
def next_window(win: Fl_WindowPtr) -> Fl_WindowPtr:
|
|
return Fl_next_window(win)
|
|
|
|
@staticmethod
|
|
def set_font_size(size: int):
|
|
Fl_set_font_size(size)
|
|
|
|
@staticmethod
|
|
def font_size() -> int:
|
|
return Fl_font_size()
|
|
|
|
@staticmethod
|
|
def set_scrollbar_size(sz: int):
|
|
Fl_set_scrollbar_size(sz)
|
|
|
|
@staticmethod
|
|
def scrollbar_size() -> int:
|
|
return Fl_scrollbar_size()
|
|
|
|
@staticmethod
|
|
def scheme() -> int:
|
|
return Fl_scheme()
|
|
|
|
@staticmethod
|
|
def scheme_string() -> str:
|
|
"""Current scheme name ('base'/'plastic'/'gtk+'/'gleam'/'oxy')."""
|
|
return Fl_scheme_string()
|
|
|
|
@staticmethod
|
|
def reload_scheme() -> int:
|
|
"""Reload the current scheme (call after changing background/foreground colors)."""
|
|
return Fl_reload_scheme()
|
|
|
|
@staticmethod
|
|
def set_background(r: int, g: int, b: int):
|
|
"""Set the global background color (0~255); call Fl.reload_scheme() afterwards."""
|
|
Fl_background(r, g, b)
|
|
|
|
@staticmethod
|
|
def set_background2(r: int, g: int, b: int):
|
|
"""Set the global secondary background color (0~255)."""
|
|
Fl_background2(r, g, b)
|
|
|
|
@staticmethod
|
|
def set_foreground(r: int, g: int, b: int):
|
|
"""Set the global foreground (text) color (0~255)."""
|
|
Fl_foreground(r, g, b)
|
|
|
|
# ----- Fl_Theme theme (C++ theme library, libfltk_theme.a) -----
|
|
@staticmethod
|
|
def set_theme_dark():
|
|
"""Apply the Fl_Theme dark theme (flat widgets + BLACK palette + dark-gray bg / white fg)."""
|
|
Fl_Theme_apply_dark()
|
|
|
|
@staticmethod
|
|
def set_theme_metro():
|
|
"""Apply the Fl_Theme Metro theme (metro widgets + blue-gray palette)."""
|
|
Fl_Theme_apply_metro()
|
|
|
|
@staticmethod
|
|
def set_border_radius(r: int):
|
|
"""Set the flat widget corner radius (default 5; call before applying a theme)."""
|
|
Fl_Theme_set_border_radius(r)
|
|
|
|
@staticmethod
|
|
def apply_flat_scheme():
|
|
"""Apply only the flat widget drawing scheme (colors unchanged)."""
|
|
Fl_Theme_apply_flat_scheme()
|
|
|
|
@staticmethod
|
|
def apply_metro_scheme():
|
|
"""Apply only the metro widget drawing scheme (colors unchanged)."""
|
|
Fl_Theme_apply_metro_scheme()
|
|
|
|
# ----- Timers / thread wakeup -----
|
|
@staticmethod
|
|
def add_timeout(seconds: double, cb: bytes, data: bytes = 0):
|
|
"""Register a one-shot timer callback (fires after seconds). cb(w: bytes, data: bytes)."""
|
|
Fl_add_timeout(seconds, cb, data)
|
|
|
|
@staticmethod
|
|
def repeat_timeout(seconds: double, cb: bytes, data: bytes = 0):
|
|
"""Register a repeating timer callback (every seconds; call repeat_timeout again inside to keep it)."""
|
|
Fl_repeat_timeout(seconds, cb, data)
|
|
|
|
@staticmethod
|
|
def awake():
|
|
"""Wake up the Fl.run/Fl.wait event loop in another thread."""
|
|
Fl_awake()
|
|
|
|
@staticmethod
|
|
def awake_callback(handler: bytes, data: bytes = 0) -> int:
|
|
"""Register a cross-thread wakeup callback (the main loop calls handler after another thread's Fl.awake())."""
|
|
return Fl_awake_callback(handler, data)
|
|
|
|
# ----- Additional event queries -----
|
|
@staticmethod
|
|
def event_original_key() -> int:
|
|
return Fl_event_original_key()
|
|
|
|
@staticmethod
|
|
def event_clicks() -> int:
|
|
return Fl_event_clicks()
|
|
|
|
@staticmethod
|
|
def event_x_root() -> int:
|
|
return Fl_event_x_root()
|
|
|
|
@staticmethod
|
|
def event_y_root() -> int:
|
|
return Fl_event_y_root()
|
|
|
|
@staticmethod
|
|
def event_dx() -> int:
|
|
return Fl_event_dx()
|
|
|
|
@staticmethod
|
|
def event_dy() -> int:
|
|
return Fl_event_dy()
|
|
|
|
@staticmethod
|
|
def event_is_click() -> int:
|
|
return Fl_event_is_click()
|
|
|
|
@staticmethod
|
|
def event_key_down(k: int) -> int:
|
|
return Fl_event_key_down(k)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Widget — widget base class wrapper
|
|
# ============================================================
|
|
novirtual class Fl_Widget:
|
|
"""FLTK widget base class (opaque pointer wrapper)."""
|
|
_ptr: Fl_WidgetPtr
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Widget_new(x, y, w, h, label)
|
|
|
|
def x(self) -> int:
|
|
return Fl_Widget_x(self._ptr)
|
|
|
|
def y(self) -> int:
|
|
return Fl_Widget_y(self._ptr)
|
|
|
|
def width(self) -> int:
|
|
return Fl_Widget_width(self._ptr)
|
|
|
|
def height(self) -> int:
|
|
return Fl_Widget_height(self._ptr)
|
|
|
|
def label(self) -> str:
|
|
return Fl_Widget_label(self._ptr)
|
|
|
|
def set_label(self, label: str):
|
|
Fl_Widget_set_label(self._ptr, label)
|
|
|
|
def show(self):
|
|
Fl_Widget_show(self._ptr)
|
|
|
|
def hide(self):
|
|
Fl_Widget_hide(self._ptr)
|
|
|
|
def activate(self):
|
|
Fl_Widget_activate(self._ptr)
|
|
|
|
def deactivate(self):
|
|
Fl_Widget_deactivate(self._ptr)
|
|
|
|
def redraw(self):
|
|
Fl_Widget_redraw(self._ptr)
|
|
|
|
def resize(self, x: int, y: int, w: int, h: int):
|
|
Fl_Widget_resize(self._ptr, x, y, w, h)
|
|
|
|
def set_color(self, color: uint32):
|
|
Fl_Widget_set_color(self._ptr, color)
|
|
|
|
def color(self) -> uint32:
|
|
return Fl_Widget_color(self._ptr)
|
|
|
|
def set_box(self, box: int):
|
|
Fl_Widget_set_box(self._ptr, box)
|
|
|
|
def box(self) -> int:
|
|
return Fl_Widget_box(self._ptr)
|
|
|
|
def set_align(self, align: int):
|
|
Fl_Widget_set_align(self._ptr, align)
|
|
|
|
def align(self) -> int:
|
|
return Fl_Widget_align(self._ptr)
|
|
|
|
def set_tooltip(self, tip: str):
|
|
Fl_Widget_set_tooltip(self._ptr, tip)
|
|
|
|
def tooltip(self) -> str:
|
|
return Fl_Widget_tooltip(self._ptr)
|
|
|
|
def parent(self) -> Fl_WidgetPtr:
|
|
return Fl_Widget_parent(self._ptr)
|
|
|
|
def window(self) -> Fl_WindowPtr:
|
|
return Fl_Widget_window(self._ptr)
|
|
|
|
def visible(self) -> int:
|
|
return Fl_Widget_visible(self._ptr)
|
|
|
|
def active(self) -> int:
|
|
return Fl_Widget_active(self._ptr)
|
|
|
|
def delete(self):
|
|
Fl_Widget_delete(self._ptr)
|
|
|
|
# ----- Callbacks -----
|
|
def set_callback(self, cb: bytes, data: bytes = 0):
|
|
"""Register a widget callback (e.g. click/change). cb is a Viper module-level
|
|
function name auto-cast to a function pointer: cb(w: bytes, data: bytes).
|
|
Trigger time is controlled by set_when (default Fl_WHEN_RELEASE)."""
|
|
Fl_Widget_set_callback(self._ptr, cb, data)
|
|
|
|
def callback(self) -> bytes:
|
|
return Fl_Widget_callback(self._ptr)
|
|
|
|
def do_callback(self):
|
|
"""Manually invoke this widget's callback (bypassing the event loop)."""
|
|
Fl_Widget_do_callback(self._ptr)
|
|
|
|
def set_when(self, when: int):
|
|
"""Set the callback trigger condition (Fl_WHEN_* constants in _enums.vp)."""
|
|
Fl_Widget_set_when(self._ptr, when)
|
|
|
|
def when(self) -> int:
|
|
return Fl_Widget_when(self._ptr)
|
|
|
|
def set_user_data(self, data: bytes):
|
|
"""Set the callback user data (the callback's second argument data)."""
|
|
Fl_Widget_set_user_data(self._ptr, data)
|
|
|
|
def user_data(self) -> bytes:
|
|
return Fl_Widget_user_data(self._ptr)
|
|
|
|
def set_image(self, img: bytes):
|
|
"""Set the widget image (pass the _ptr of an image object such as Fl_PNG_Image)."""
|
|
Fl_Widget_set_image(self._ptr, img)
|
|
|
|
def image(self) -> bytes:
|
|
return Fl_Widget_image(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Window — window wrapper
|
|
# ============================================================
|
|
novirtual class Fl_Window(Fl_Widget):
|
|
"""FLTK window."""
|
|
|
|
def __init__(self, w: int, h: int, title: str = ""):
|
|
self._ptr = Fl_Window_new(0, 0, w, h, title)
|
|
|
|
def begin(self):
|
|
Fl_Window_begin(self._ptr)
|
|
|
|
def end(self):
|
|
Fl_Window_end(self._ptr)
|
|
|
|
def set_modal(self, flag: uint32):
|
|
Fl_Window_make_modal(self._ptr, flag)
|
|
|
|
def fullscreen(self, flag: uint32):
|
|
Fl_Window_fullscreen(self._ptr, flag)
|
|
|
|
def make_current(self):
|
|
Fl_Window_make_current(self._ptr)
|
|
|
|
def set_border(self, flag: int):
|
|
Fl_Window_set_border(self._ptr, flag)
|
|
|
|
def border(self) -> int:
|
|
return Fl_Window_border(self._ptr)
|
|
|
|
def iconize(self):
|
|
Fl_Window_iconize(self._ptr)
|
|
|
|
def free_position(self):
|
|
Fl_Window_free_position(self._ptr)
|
|
|
|
def shown(self) -> int:
|
|
return Fl_Window_shown(self._ptr)
|
|
|
|
def set_xclass(self, xc: str):
|
|
Fl_Window_set_xclass(self._ptr, xc)
|
|
|
|
def x_root(self) -> int:
|
|
return Fl_Window_x_root(self._ptr)
|
|
|
|
def y_root(self) -> int:
|
|
return Fl_Window_y_root(self._ptr)
|
|
|
|
def size_range(self, minw: int, minh: int, maxw: int, maxh: int):
|
|
Fl_Window_size_range(self._ptr, minw, minh, maxw, maxh)
|
|
|
|
def set_cursor(self, cursor: int):
|
|
Fl_Window_set_cursor(self._ptr, cursor)
|
|
|
|
def resize(self, x: int, y: int, w: int, h: int):
|
|
Fl_Window_resize(self._ptr, x, y, w, h)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Box — static text/decorative box
|
|
# ============================================================
|
|
novirtual class Fl_Box(Fl_Widget):
|
|
"""FLTK text/decorative box."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Box_new(x, y, w, h, label)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Button — button wrapper
|
|
# ============================================================
|
|
novirtual class Fl_Button(Fl_Widget):
|
|
"""FLTK button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Button_new(x, y, w, h, label)
|
|
|
|
def value(self) -> int:
|
|
return Fl_Button_value(self._ptr)
|
|
|
|
def set_value(self, v: int):
|
|
Fl_Button_set_value(self._ptr, v)
|
|
|
|
def set(self):
|
|
Fl_Button_set_value(self._ptr, 1)
|
|
|
|
def clear(self) -> int:
|
|
return Fl_Button_clear(self._ptr)
|
|
|
|
def set_shortcut(self, s: int):
|
|
Fl_Button_set_shortcut(self._ptr, s)
|
|
|
|
def shortcut(self) -> int:
|
|
return Fl_Button_shortcut(self._ptr)
|
|
|
|
def set_down_box(self, box: int):
|
|
Fl_Button_set_down_box(self._ptr, box)
|
|
|
|
def down_box(self) -> int:
|
|
return Fl_Button_down_box(self._ptr)
|
|
|
|
|
|
novirtual class Fl_Check_Button(Fl_Button):
|
|
"""FLTK check button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Check_Button_new(x, y, w, h, label)
|
|
|
|
def is_checked(self) -> int:
|
|
return Fl_Check_Button_is_checked(self._ptr)
|
|
|
|
def set_checked(self, checked: int):
|
|
Fl_Check_Button_set_checked(self._ptr, checked)
|
|
|
|
|
|
novirtual class Fl_Radio_Button(Fl_Button):
|
|
"""FLTK radio button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Radio_Button_new(x, y, w, h, label)
|
|
|
|
def is_toggled(self) -> int:
|
|
return Fl_Radio_Button_is_toggled(self._ptr)
|
|
|
|
def toggle(self, v: int):
|
|
Fl_Radio_Button_toggle(self._ptr, v)
|
|
|
|
|
|
novirtual class Fl_Repeat_Button(Fl_Button):
|
|
"""FLTK repeat button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Repeat_Button_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Return_Button(Fl_Button):
|
|
"""FLTK return button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Return_Button_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Light_Button(Fl_Button):
|
|
"""FLTK light button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Light_Button_new(x, y, w, h, label)
|
|
|
|
def is_on(self) -> int:
|
|
return Fl_Light_Button_is_on(self._ptr)
|
|
|
|
def turn_on(self, v: int):
|
|
Fl_Light_Button_turn_on(self._ptr, v)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Input / Fl_Output — text input/output
|
|
# ============================================================
|
|
novirtual class Fl_Input(Fl_Widget):
|
|
"""FLTK single-line text input."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Input_new(x, y, w, h, label)
|
|
|
|
def value(self) -> str:
|
|
return Fl_Input_value(self._ptr)
|
|
|
|
def set_value(self, text: str):
|
|
Fl_Input_set_value(self._ptr, text)
|
|
|
|
def set_maximum_size(self, m: int):
|
|
Fl_Input_set_maximum_size(self._ptr, m)
|
|
|
|
def maximum_size(self) -> int:
|
|
return Fl_Input_maximum_size(self._ptr)
|
|
|
|
def set_readonly(self, v: int):
|
|
Fl_Input_set_readonly(self._ptr, v)
|
|
|
|
def readonly(self) -> int:
|
|
return Fl_Input_readonly(self._ptr)
|
|
|
|
|
|
novirtual class Fl_Output(Fl_Widget):
|
|
"""FLTK single-line text output."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Output_new(x, y, w, h, label)
|
|
|
|
def value(self) -> str:
|
|
return Fl_Output_value(self._ptr)
|
|
|
|
def set_value(self, text: str) -> int:
|
|
return Fl_Output_set_value(self._ptr, text)
|
|
|
|
|
|
novirtual class Fl_Int_Input(Fl_Input):
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Int_Input_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Float_Input(Fl_Input):
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Float_Input_new(x, y, w, h, label)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Text_Buffer / Fl_Text_Display — multi-line text
|
|
# ============================================================
|
|
novirtual class Fl_Text_Buffer:
|
|
"""FLTK text buffer."""
|
|
|
|
_ptr: Fl_Text_BufferPtr
|
|
|
|
def __init__(self):
|
|
self._ptr = Fl_Text_Buffer_new()
|
|
|
|
def text(self) -> str:
|
|
return Fl_Text_Buffer_text(self._ptr)
|
|
|
|
def set_text(self, text: str):
|
|
Fl_Text_Buffer_set_text(self._ptr, text)
|
|
|
|
def append(self, text: str):
|
|
Fl_Text_Buffer_append(self._ptr, text)
|
|
|
|
def length(self) -> int:
|
|
return Fl_Text_Buffer_length(self._ptr)
|
|
|
|
def insert(self, pos: int, text: str):
|
|
Fl_Text_Buffer_insert(self._ptr, pos, text)
|
|
|
|
def remove(self, start: int, end: int):
|
|
Fl_Text_Buffer_remove(self._ptr, start, end)
|
|
|
|
def save_file(self, path: str) -> int:
|
|
return Fl_Text_Buffer_save_file(self._ptr, path)
|
|
|
|
def load_file(self, path: str) -> int:
|
|
return Fl_Text_Buffer_load_file(self._ptr, path)
|
|
|
|
def free(self):
|
|
Fl_Text_Buffer_delete(self._ptr)
|
|
|
|
|
|
novirtual class Fl_Text_Display(Fl_Widget):
|
|
"""FLTK multi-line text display."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Text_Display_new(x, y, w, h, label)
|
|
|
|
def set_buffer(self, buf: Fl_Text_BufferPtr):
|
|
Fl_Text_Display_set_buffer(self._ptr, buf)
|
|
|
|
def set_text_font(self, font: int):
|
|
Fl_Text_Display_set_text_font(self._ptr, font)
|
|
|
|
def set_text_size(self, size: int):
|
|
Fl_Text_Display_set_text_size(self._ptr, size)
|
|
|
|
def set_text_color(self, color: uint32):
|
|
Fl_Text_Display_set_text_color(self._ptr, color)
|
|
|
|
def set_scrollbar_size(self, size: int):
|
|
Fl_Text_Display_set_scrollbar_size(self._ptr, size)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Group — container wrapper
|
|
# ============================================================
|
|
novirtual class Fl_Group(Fl_Widget):
|
|
"""FLTK widget group."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Group_new(x, y, w, h, label)
|
|
|
|
def begin(self):
|
|
Fl_Group_begin(self._ptr)
|
|
|
|
def end(self):
|
|
Fl_Group_end(self._ptr)
|
|
|
|
def add(self, wid: Fl_WidgetPtr):
|
|
Fl_Group_add(self._ptr, wid)
|
|
|
|
def remove(self, wid: Fl_WidgetPtr):
|
|
Fl_Group_remove(self._ptr, wid)
|
|
|
|
def clear(self):
|
|
Fl_Group_clear(self._ptr)
|
|
|
|
def children(self) -> int:
|
|
return Fl_Group_children(self._ptr)
|
|
|
|
def child(self, index: int) -> Fl_WidgetPtr:
|
|
return Fl_Group_child(self._ptr, index)
|
|
|
|
def set_resizable(self, wid: Fl_WidgetPtr):
|
|
Fl_Group_resizable(self._ptr, wid)
|
|
|
|
|
|
novirtual class Fl_Scroll(Fl_Group):
|
|
"""FLTK scroll container."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Scroll_new(x, y, w, h, label)
|
|
|
|
def set_scrollbar_size(self, size: int):
|
|
Fl_Scroll_set_scrollbar_size(self._ptr, size)
|
|
|
|
def scrollbar_size(self) -> int:
|
|
return Fl_Scroll_scrollbar_size(self._ptr)
|
|
|
|
def scroll_to(self, x: int, y: int):
|
|
Fl_Scroll_scroll_to(self._ptr, x, y)
|
|
|
|
def xposition(self) -> int:
|
|
return Fl_Scroll_xposition(self._ptr)
|
|
|
|
def yposition(self) -> int:
|
|
return Fl_Scroll_yposition(self._ptr)
|
|
|
|
|
|
novirtual class Fl_Tabs(Fl_Group):
|
|
"""FLTK tab container."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Tabs_new(x, y, w, h, label)
|
|
|
|
def value(self) -> Fl_WidgetPtr:
|
|
return Fl_Tabs_value(self._ptr)
|
|
|
|
def set_value(self, wid: Fl_WidgetPtr):
|
|
Fl_Tabs_set_value(self._ptr, wid)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Slider / Fl_Value_Input / Fl_Value_Output — numeric widgets
|
|
# ============================================================
|
|
novirtual class Fl_Slider(Fl_Widget):
|
|
"""FLTK slider."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Slider_new(x, y, w, h, label)
|
|
|
|
def value(self) -> double:
|
|
return Fl_Slider_value(self._ptr)
|
|
|
|
def set_value(self, v: double):
|
|
Fl_Slider_set_value(self._ptr, v)
|
|
|
|
def minimum(self) -> double:
|
|
return Fl_Slider_minimum(self._ptr)
|
|
|
|
def set_minimum(self, v: double):
|
|
Fl_Slider_set_minimum(self._ptr, v)
|
|
|
|
def maximum(self) -> double:
|
|
return Fl_Slider_maximum(self._ptr)
|
|
|
|
def set_maximum(self, v: double):
|
|
Fl_Slider_set_maximum(self._ptr, v)
|
|
|
|
def step(self) -> double:
|
|
return Fl_Slider_step(self._ptr)
|
|
|
|
def set_step(self, v: double):
|
|
Fl_Slider_set_step(self._ptr, v)
|
|
|
|
def set_bounds(self, a: double, b: double):
|
|
Fl_Slider_set_bounds(self._ptr, a, b)
|
|
|
|
|
|
novirtual class Fl_Value_Input(Fl_Widget):
|
|
"""FLTK numeric input."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Value_Input_new(x, y, w, h, label)
|
|
|
|
def value(self) -> double:
|
|
return Fl_Value_Input_value(self._ptr)
|
|
|
|
def set_value(self, v: double):
|
|
Fl_Value_Input_set_value(self._ptr, v)
|
|
|
|
def set_bounds(self, a: double, b: double):
|
|
Fl_Value_Input_set_bounds(self._ptr, a, b)
|
|
|
|
|
|
novirtual class Fl_Value_Output(Fl_Widget):
|
|
"""FLTK numeric output."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Value_Output_new(x, y, w, h, label)
|
|
|
|
def value(self) -> double:
|
|
return Fl_Value_Output_value(self._ptr)
|
|
|
|
def set_value(self, v: double):
|
|
Fl_Value_Output_set_value(self._ptr, v)
|
|
|
|
|
|
novirtual class Fl_Progress(Fl_Widget):
|
|
"""FLTK progress bar."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Progress_new(x, y, w, h, label)
|
|
|
|
def value(self) -> double:
|
|
return Fl_Progress_value(self._ptr)
|
|
|
|
def set_value(self, v: double):
|
|
Fl_Progress_set_value(self._ptr, v)
|
|
|
|
def set_minimum(self, v: double):
|
|
Fl_Progress_set_minimum(self._ptr, v)
|
|
|
|
def set_maximum(self, v: double):
|
|
Fl_Progress_set_maximum(self._ptr, v)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Choice — drop-down choice
|
|
# ============================================================
|
|
novirtual class Fl_Choice(Fl_Widget):
|
|
"""FLTK drop-down choice box."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Choice_new(x, y, w, h, label)
|
|
|
|
def add(self, text: str):
|
|
Fl_Choice_add_choice(self._ptr, text)
|
|
|
|
def value(self) -> int:
|
|
return Fl_Choice_value(self._ptr)
|
|
|
|
def set_value(self, v: int):
|
|
Fl_Choice_set_value(self._ptr, v)
|
|
|
|
def text(self, idx: int) -> str:
|
|
return Fl_Choice_text(self._ptr, idx)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Menu_Bar — menu bar
|
|
# ============================================================
|
|
novirtual class Fl_Menu_Bar(Fl_Widget):
|
|
"""FLTK menu bar.
|
|
|
|
add uses the full cfltk 6-arg signature (name/shortcut/cb/data/flags); cb may be
|
|
a Viper module-level function name (cb(w: bytes, data: bytes)). Default: no action.
|
|
For simple drop-downs prefer add_choice."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Menu_Bar_new(x, y, w, h, label)
|
|
|
|
def add(self, path: str, shortcut: int, flags: int, cb: bytes = 0):
|
|
Fl_Menu_Bar_add(self._ptr, path, shortcut, cb, t.CPtr(0), flags)
|
|
|
|
def add_choice(self, text: str) -> int:
|
|
return Fl_Menu_Bar_add_choice(self._ptr, text)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Native_File_Chooser — native file dialog
|
|
# ============================================================
|
|
novirtual class Fl_Native_File_Chooser:
|
|
"""FLTK native file dialog.
|
|
|
|
The constructor takes a dialog-type constant (BROWSE_FILE / BROWSE_DIRECTORY /
|
|
BROWSE_MULTI_FILE / BROWSE_MULTI_DIRECTORY / BROWSE_SAVE_FILE; see _enums.vp)."""
|
|
_ptr: Fl_Native_File_ChooserPtr
|
|
|
|
def __init__(self, type_: int):
|
|
self._ptr = Fl_Native_File_Chooser_new(type_)
|
|
|
|
def set_title(self, title: str):
|
|
Fl_Native_File_Chooser_set_title(self._ptr, title)
|
|
|
|
def set_filter(self, filter_: str):
|
|
Fl_Native_File_Chooser_set_filter(self._ptr, filter_)
|
|
|
|
def filter(self) -> str:
|
|
return Fl_Native_File_Chooser_filter(self._ptr)
|
|
|
|
def set_directory(self, dir_: str):
|
|
Fl_Native_File_Chooser_set_directory(self._ptr, dir_)
|
|
|
|
def directory(self) -> str:
|
|
return Fl_Native_File_Chooser_directory(self._ptr)
|
|
|
|
def set_preset_file(self, path: str):
|
|
Fl_Native_File_Chooser_set_preset_file(self._ptr, path)
|
|
|
|
def set_option(self, opt: int):
|
|
Fl_Native_File_Chooser_set_option(self._ptr, opt)
|
|
|
|
def set_type(self, type_: int):
|
|
Fl_Native_File_Chooser_set_type(self._ptr, type_)
|
|
|
|
def show(self) -> int:
|
|
return Fl_Native_File_Chooser_show(self._ptr)
|
|
|
|
def count(self) -> int:
|
|
return Fl_Native_File_Chooser_count(self._ptr)
|
|
|
|
def filename(self) -> str:
|
|
return Fl_Native_File_Chooser_filename(self._ptr)
|
|
|
|
def filenames(self, index: int) -> str:
|
|
return Fl_Native_File_Chooser_filenames(self._ptr, index)
|
|
|
|
def filter_value(self) -> int:
|
|
return Fl_Native_File_Chooser_filter_value(self._ptr)
|
|
|
|
def set_filter_value(self, v: int):
|
|
Fl_Native_File_Chooser_set_filter_value(self._ptr, v)
|
|
|
|
def errmsg(self) -> str:
|
|
return Fl_Native_File_Chooser_errmsg(self._ptr)
|
|
|
|
def delete(self):
|
|
Fl_Native_File_Chooser_delete(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Common aliases
|
|
# ============================================================
|
|
def fltk_init():
|
|
"""Initialize FLTK (in multithreaded environments call Fl_lock before init_all)."""
|
|
Fl_init_all()
|
|
|
|
|
|
# ============================================================
|
|
# Additional button classes
|
|
# ============================================================
|
|
novirtual class Fl_Toggle_Button(Fl_Button):
|
|
"""FLTK toggle button (stays pressed)."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Toggle_Button_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Round_Button(Fl_Button):
|
|
"""FLTK round button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Round_Button_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Radio_Round_Button(Fl_Button):
|
|
"""FLTK round radio button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Radio_Round_Button_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Radio_Light_Button(Fl_Button):
|
|
"""FLTK radio light button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Radio_Light_Button_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Shortcut_Button(Fl_Button):
|
|
"""FLTK shortcut button."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Shortcut_Button_new(x, y, w, h, label)
|
|
|
|
|
|
# ============================================================
|
|
# Additional input classes
|
|
# ============================================================
|
|
novirtual class Fl_Multiline_Input(Fl_Input):
|
|
"""FLTK multi-line text input."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Multiline_Input_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Secret_Input(Fl_Input):
|
|
"""FLTK password input (shown as *)."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Secret_Input_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_File_Input(Fl_Input):
|
|
"""FLTK file-path input."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_File_Input_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Multiline_Output(Fl_Output):
|
|
"""FLTK multi-line text output."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Multiline_Output_new(x, y, w, h, label)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Nice_Slider / Fl_Spinner / Fl_Clock
|
|
# ============================================================
|
|
novirtual class Fl_Nice_Slider(Fl_Slider):
|
|
"""FLTK nice slider."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Nice_Slider_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Spinner(Fl_Widget):
|
|
"""FLTK spinner."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Spinner_new(x, y, w, h, label)
|
|
|
|
def value(self) -> double:
|
|
return Fl_Spinner_value(self._ptr)
|
|
|
|
def set_value(self, v: double):
|
|
Fl_Spinner_set_value(self._ptr, v)
|
|
|
|
def minimum(self) -> double:
|
|
return Fl_Spinner_minimum(self._ptr)
|
|
|
|
def set_minimum(self, v: double):
|
|
Fl_Spinner_set_minimum(self._ptr, v)
|
|
|
|
def maximum(self) -> double:
|
|
return Fl_Spinner_maximum(self._ptr)
|
|
|
|
def set_maximum(self, v: double):
|
|
Fl_Spinner_set_maximum(self._ptr, v)
|
|
|
|
def step(self) -> double:
|
|
return Fl_Spinner_step(self._ptr)
|
|
|
|
def set_step(self, v: double):
|
|
Fl_Spinner_set_step(self._ptr, v)
|
|
|
|
|
|
novirtual class Fl_Clock(Fl_Widget):
|
|
"""FLTK clock (analog dial)."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Clock_new(x, y, w, h, label)
|
|
|
|
|
|
# ============================================================
|
|
# Additional container classes
|
|
# ============================================================
|
|
novirtual class Fl_Pack(Fl_Group):
|
|
"""FLTK auto-layout container (children laid out in order)."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Pack_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Tile(Fl_Group):
|
|
"""FLTK resizable-splitter container."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Tile_new(x, y, w, h, label)
|
|
|
|
|
|
novirtual class Fl_Flex(Fl_Group):
|
|
"""FLTK flex layout container."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Flex_new(x, y, w, h, label)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Menu_Button — popup menu button
|
|
# ============================================================
|
|
novirtual class Fl_Menu_Button(Fl_Widget):
|
|
"""FLTK popup menu button (shown on right-click / long-press)."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Menu_Button_new(x, y, w, h, label)
|
|
|
|
def add_choice(self, text: str) -> int:
|
|
return Fl_Menu_Button_add_choice(self._ptr, text)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Browser — list browser
|
|
# ============================================================
|
|
novirtual class Fl_Browser(Fl_Widget):
|
|
"""FLTK list browser."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Browser_new(x, y, w, h, label)
|
|
|
|
def value(self) -> int:
|
|
"""Current selected line number (1-based; 0=unselected)."""
|
|
return Fl_Browser_value(self._ptr)
|
|
|
|
def add(self, newtext: str):
|
|
Fl_Browser_add(self._ptr, newtext)
|
|
|
|
def clear(self):
|
|
Fl_Browser_clear(self._ptr)
|
|
|
|
def text(self, line: int) -> str:
|
|
return Fl_Browser_text(self._ptr, line)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Tree — tree widget
|
|
# ============================================================
|
|
novirtual class Fl_Tree(Fl_Widget):
|
|
"""FLTK tree widget."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Tree_new(x, y, w, h, label)
|
|
|
|
def add(self, name: str) -> Fl_Tree_ItemPtr:
|
|
"""Add a node ('a/b/c' path builds parent/child levels automatically)."""
|
|
return Fl_Tree_add(self._ptr, name)
|
|
|
|
def clear(self):
|
|
Fl_Tree_clear(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Text_Editor / Fl_Terminal
|
|
# ============================================================
|
|
novirtual class Fl_Text_Editor(Fl_Text_Display):
|
|
"""FLTK text editor."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Text_Editor_new(x, y, w, h, label)
|
|
|
|
def insert(self, text: str):
|
|
"""Insert text at the cursor."""
|
|
Fl_Text_Editor_insert(self._ptr, text)
|
|
|
|
def overstrike(self, text: str):
|
|
"""Overwrite text at the cursor."""
|
|
Fl_Text_Editor_overstrike(self._ptr, text)
|
|
|
|
|
|
novirtual class Fl_Terminal(Fl_Widget):
|
|
"""FLTK terminal emulation widget (ANSI escape support)."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Terminal_new(x, y, w, h, label)
|
|
|
|
def append(self, txt: str):
|
|
Fl_Terminal_append(self._ptr, txt)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_File_Chooser — file dialog
|
|
# ============================================================
|
|
novirtual class Fl_File_Chooser:
|
|
"""FLTK file dialog (cfltk wrapper, not native).
|
|
|
|
new(directory, pattern, type, title); type uses Fl_File_Chooser_* constants
|
|
(see _enums.vp: SINGLE/MULTI/DIRECTORY/CREATE/SAVE, etc.)."""
|
|
|
|
_ptr: Fl_File_ChooserPtr
|
|
|
|
def __init__(self, d: str, p: str, t: int, title: str):
|
|
self._ptr = Fl_File_Chooser_new(d, p, t, title)
|
|
|
|
def set_callback(self, cb: bytes, data: bytes = 0):
|
|
Fl_File_Chooser_set_callback(self._ptr, cb, data)
|
|
|
|
def count(self) -> int:
|
|
return Fl_File_Chooser_count(self._ptr)
|
|
|
|
def set_directory(self, d: str):
|
|
Fl_File_Chooser_set_directory(self._ptr, d)
|
|
|
|
def directory(self) -> str:
|
|
return Fl_File_Chooser_directory(self._ptr)
|
|
|
|
def set_filter(self, p: str):
|
|
Fl_File_Chooser_set_filter(self._ptr, p)
|
|
|
|
def filter(self) -> str:
|
|
return Fl_File_Chooser_filter(self._ptr)
|
|
|
|
def filter_value(self) -> int:
|
|
return Fl_File_Chooser_filter_value(self._ptr)
|
|
|
|
def set_filter_value(self, f: int):
|
|
Fl_File_Chooser_set_filter_value(self._ptr, f)
|
|
|
|
def set_type(self, t: int):
|
|
Fl_File_Chooser_set_type(self._ptr, t)
|
|
|
|
def set_label(self, l: str):
|
|
Fl_File_Chooser_set_label(self._ptr, l)
|
|
|
|
def set_ok_label(self, l: str):
|
|
Fl_File_Chooser_set_ok_label(self._ptr, l)
|
|
|
|
def show(self):
|
|
Fl_File_Chooser_show(self._ptr)
|
|
|
|
def shown(self) -> int:
|
|
return Fl_File_Chooser_shown(self._ptr)
|
|
|
|
def hide(self):
|
|
Fl_File_Chooser_hide(self._ptr)
|
|
|
|
def value(self, f: int) -> str:
|
|
"""Selected filename at index f (0-based; iterate with count for multi-select)."""
|
|
return Fl_File_Chooser_value(self._ptr, f)
|
|
|
|
def delete(self):
|
|
Fl_File_Chooser_delete(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Help_Dialog — HTML help dialog
|
|
# ============================================================
|
|
novirtual class Fl_Help_Dialog:
|
|
"""FLTK HTML help dialog."""
|
|
|
|
_ptr: Fl_Help_DialogPtr
|
|
|
|
def __init__(self):
|
|
self._ptr = Fl_Help_Dialog_new()
|
|
|
|
def load(self, f: str) -> int:
|
|
"""Load an HTML file."""
|
|
return Fl_Help_Dialog_load(self._ptr, f)
|
|
|
|
def set_value(self, f: str):
|
|
"""Set HTML content directly."""
|
|
Fl_Help_Dialog_set_value(self._ptr, f)
|
|
|
|
def value(self) -> str:
|
|
return Fl_Help_Dialog_value(self._ptr)
|
|
|
|
def show(self):
|
|
Fl_Help_Dialog_show(self._ptr)
|
|
|
|
def set_text_size(self, s: int):
|
|
Fl_Help_Dialog_set_text_size(self._ptr, s)
|
|
|
|
def hide(self):
|
|
Fl_Help_Dialog_hide(self._ptr)
|
|
|
|
def visible(self) -> int:
|
|
return Fl_Help_Dialog_visible(self._ptr)
|
|
|
|
def delete(self):
|
|
Fl_Help_Dialog_delete(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Input_Choice — input + drop-down combo
|
|
# ============================================================
|
|
novirtual class Fl_Input_Choice(Fl_Group):
|
|
"""FLTK text input + drop-down choice combo widget."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Input_Choice_new(x, y, w, h, label)
|
|
|
|
def add(self, s: str):
|
|
Fl_Input_Choice_add(self._ptr, s)
|
|
|
|
def value(self) -> str:
|
|
"""Current input box text."""
|
|
return Fl_Input_Choice_value(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Fl_Color_Chooser — color chooser
|
|
# ============================================================
|
|
novirtual class Fl_Color_Chooser(Fl_Group):
|
|
"""FLTK color chooser."""
|
|
|
|
def __init__(self, x: int, y: int, w: int, h: int, label: str = ""):
|
|
self._ptr = Fl_Color_Chooser_new(x, y, w, h, label)
|
|
|
|
def set_rgb(self, r: double, g: double, b: double) -> int:
|
|
"""Set RGB values (0.0~1.0); returns 1 if the value changed."""
|
|
return Fl_Color_Chooser_set_rgb(self._ptr, r, g, b)
|
|
|
|
def show(self):
|
|
Fl_Color_Chooser_show(self._ptr)
|
|
|
|
|
|
# ============================================================
|
|
# Image classes
|
|
# ============================================================
|
|
novirtual class Fl_PNG_Image:
|
|
"""FLTK PNG image (loaded from a file)."""
|
|
|
|
_ptr: Fl_PNG_ImagePtr
|
|
|
|
def __init__(self, filename: str):
|
|
self._ptr = Fl_PNG_Image_new(filename)
|
|
|
|
|
|
novirtual class Fl_JPEG_Image:
|
|
"""FLTK JPEG image."""
|
|
|
|
_ptr: Fl_JPEG_ImagePtr
|
|
|
|
def __init__(self, filename: str):
|
|
self._ptr = Fl_JPEG_Image_new(filename)
|
|
|
|
|
|
novirtual class Fl_GIF_Image:
|
|
"""FLTK GIF image."""
|
|
|
|
_ptr: Fl_GIF_ImagePtr
|
|
|
|
def __init__(self, filename: str):
|
|
self._ptr = Fl_GIF_Image_new(filename)
|