core.py: per-widget Cairo drawing inside the 14 archetypes, ported from Rust archetypes.rs / C widget draws -- buttons (incl. link, colour-swatch, lock, glyph, MenuButton direction arrow), toggles (check/radio/switch/toggle-button/menu-check), labels (xalign/yalign, wrap, accel stripping), entries (password masking, placeholder, alignment, search/calc variants), text views (wrap modes, scrollbars, cursor), ranges (scale with ticks/sel-range, scrollbar with thumb + arrows, progress, spin, level bar), lists (combo, colour box, listbox, checklistbox, tree, listview incl. icon style, menubar/menu, toolbar, stack switcher), containers (frame/groupbox, notebook, calendar grid, splitter, scrolled window, header/action bar, statusbar, window), display (image scene, shape 0-9, separator, spinner, video, drawing area), dialogs (title bar, file/color/about variants), charts (line/bars/candles), spreadsheet grid. Drawings honour background/foreground/border/font props; invisible draws nothing, disabled dims. Pixel parity with C is NOT required. Live-apply: Widget.set_prop validates against lightgui.props (raises ValueError on unknown/bad/out-of-range props), updates Name/geometry fields or props, marks the widget dirty and calls on_change; CanvasState wires widget.on_change and clears dirty after drawing. Widget setters: set_items (ComboBox/ListBox, prunes CheckListBox checked-items), get/set_checked_items, set_item_checked, set_password/set_show_password (masked until revealed), set_direction (MenuButton), set_cursor_visible (TextView), set_lower/set_page_increment (ScrollBar), set_value (clamped), set_active, set_text (canonical caption prop). model.py: caption seeding now uses the table's canonical prop (label for Button/CheckBox, text for Entry); kinds with neither get no seed. tests: test_props.py (generic set on all 547 kinds, SS2.1-SS2.10 lists, validation, live-apply/dirty, setters, model-only flags) and test_draw.py (headless Cairo smoke: every kind draws without crashing and paints something; prop-driven branches). Five Phase 1 tests updated to the Phase 2 set_prop contract (label, not text, for Button/Label; no arbitrary props). Full suite: 107 tests OK.
761 lines
45 KiB
Python
761 lines
45 KiB
Python
"""Property tables for the LightGUI Python port.
|
|
|
|
GENERATED -- do not edit by hand. Run tools/gen_props.py
|
|
to regenerate from /opt/lightgui/src/props.h (C tables,
|
|
canonical) and lightgui/xframe/palette.py (the 547 kinds).
|
|
Curated mappings (kind -> C table, Lazarus display names,
|
|
model-only flags) live in tools/gen_props.py.
|
|
|
|
Every palette kind gets the generic set (Name, geometry,
|
|
Color, Font, Border, Enabled, Visible, Hint, ShowHint,
|
|
Cursor, TabOrder, TabStop, Constraints, BorderSpacing,
|
|
AutoSize, Tag, Align, Anchors) plus its family custom
|
|
props from proposal SS2.1-SS2.21. Stock / Instrumentation
|
|
kinds get the generic set only in Phase 2; Phase 6 adds
|
|
their tables via register_custom_table().
|
|
|
|
Internal names stay the C/GTK-era names (proposal SS5.3);
|
|
`display` is the Lazarus name shown in the Inspector.
|
|
`model_only` props are stored on the widget and emitted
|
|
by the generator as comments; they do not change the live
|
|
canvas widget. Note `editable` is inverted ReadOnly
|
|
(ReadOnly = not editable, proposal SS2.2) and `foreground`
|
|
is the font/text colour.
|
|
"""
|
|
|
|
import re
|
|
from collections import namedtuple
|
|
|
|
|
|
PropDef = namedtuple(
|
|
"PropDef",
|
|
"name kind default lo hi enum_labels enum_values "
|
|
"display model_only")
|
|
|
|
EVENTS = ("OnClick", "OnChange", "OnKeyPress", "OnKeyDown", "OnKeyUp", "OnMouseDown", "OnMouseUp", "OnMouseMove", "OnDblClick", "OnEnter", "OnExit", "OnResize", "OnChangeBounds", "OnMouseEnter", "OnMouseLeave", "OnMouseWheel", "OnContextPopup")
|
|
|
|
GENERIC_PROPS = (
|
|
PropDef("name", "Str", "", 0, 0, (), (), "Name", False),
|
|
PropDef("left", "Int", "0", 0, 0, (), (), "Left", False),
|
|
PropDef("top", "Int", "0", 0, 0, (), (), "Top", False),
|
|
PropDef("width", "Int", "100", 0, 0, (), (), "Width", False),
|
|
PropDef("height", "Int", "30", 0, 0, (), (), "Height", False),
|
|
PropDef("background", "Color", "", 0, 0, (), (), "Color", False),
|
|
PropDef("foreground", "Color", "", 0, 0, (), (), "Font.Color", False),
|
|
PropDef("border-width", "Int", "0", 0, 100, (), (), "Border.Width", False),
|
|
PropDef("border-color", "Color", "", 0, 0, (), (), "Border.Color", False),
|
|
PropDef("border-radius", "Int", "0", 0, 1000, (), (), "Border.Radius", False),
|
|
PropDef("tooltip-text", "Str", "", 0, 0, (), (), "Hint", True),
|
|
PropDef("enabled", "Bool", "true", 0, 0, (), (), "Enabled", False),
|
|
PropDef("visible", "Bool", "true", 0, 0, (), (), "Visible", False),
|
|
PropDef("font-name", "Str", "", 0, 0, (), (), "Font.Name", False),
|
|
PropDef("font-size", "Int", "13", 6, 72, (), (), "Font.Size", False),
|
|
PropDef("font-bold", "Bool", "false", 0, 0, (), (), "Font.Style.Bold", False),
|
|
PropDef("font-italic", "Bool", "false", 0, 0, (), (), "Font.Style.Italic", False),
|
|
PropDef("font-underline", "Bool", "false", 0, 0, (), (), "Font.Style.Underline", True),
|
|
PropDef("font-strikeout", "Bool", "false", 0, 0, (), (), "Font.Style.StrikeOut", True),
|
|
PropDef("hint", "Str", "", 0, 0, (), (), "Hint", True),
|
|
PropDef("show-hint", "Bool", "false", 0, 0, (), (), "ShowHint", True),
|
|
PropDef("cursor", "Str", "", 0, 0, (), (), "Cursor", True),
|
|
PropDef("tab-order", "Int", "0", 0, 100000, (), (), "TabOrder", True),
|
|
PropDef("tab-stop", "Bool", "true", 0, 0, (), (), "TabStop", True),
|
|
PropDef("min-width", "Int", "0", 0, 100000, (), (), "Constraints.MinWidth", False),
|
|
PropDef("min-height", "Int", "0", 0, 100000, (), (), "Constraints.MinHeight", False),
|
|
PropDef("max-width", "Int", "0", 0, 100000, (), (), "Constraints.MaxWidth", False),
|
|
PropDef("max-height", "Int", "0", 0, 100000, (), (), "Constraints.MaxHeight", False),
|
|
PropDef("margin-left", "Int", "0", 0, 100000, (), (), "BorderSpacing.Left", True),
|
|
PropDef("margin-top", "Int", "0", 0, 100000, (), (), "BorderSpacing.Top", True),
|
|
PropDef("margin-right", "Int", "0", 0, 100000, (), (), "BorderSpacing.Right", True),
|
|
PropDef("margin-bottom", "Int", "0", 0, 100000, (), (), "BorderSpacing.Bottom", True),
|
|
PropDef("margin-around", "Int", "0", 0, 100000, (), (), "BorderSpacing.Around", True),
|
|
PropDef("autosize", "Bool", "false", 0, 0, (), (), "AutoSize", True),
|
|
PropDef("tag", "Int", "0", -1000000, 1000000, (), (), "Tag", True),
|
|
PropDef("anchor-top", "Bool", "true", 0, 0, (), (), "Anchors.Top", True),
|
|
PropDef("anchor-left", "Bool", "true", 0, 0, (), (), "Anchors.Left", True),
|
|
PropDef("anchor-right", "Bool", "false", 0, 0, (), (), "Anchors.Right", True),
|
|
PropDef("anchor-bottom", "Bool", "false", 0, 0, (), (), "Anchors.Bottom", True),
|
|
PropDef("align", "Enum", "0", 0, 0, ("None", "Top", "Bottom", "Left", "Right", "Client"), (0, 1, 2, 3, 4, 5), "Align", True),
|
|
PropDef("inner-border", "Int", "0", 0, 100000, (), (), "BorderSpacing.InnerBorder", True),
|
|
PropDef("cell-align-horizontal", "Enum", "0", 0, 0, ("Left", "Center", "Right"), (), "BorderSpacing.CellAlignHorizontal", True),
|
|
PropDef("cell-align-vertical", "Enum", "0", 0, 0, ("Top", "Center", "Bottom"), (), "BorderSpacing.CellAlignVertical", True),
|
|
)
|
|
|
|
GENERIC_NAMES = frozenset(p.name for p in GENERIC_PROPS)
|
|
|
|
DIALOG_PROPS = (
|
|
PropDef("title", "Str", "", 0, 0, (), (), "Title", False),
|
|
)
|
|
|
|
LABEL_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("xalign", "Double", "0.5", 0, 1, (), (), "Alignment", False),
|
|
PropDef("yalign", "Double", "0.5", 0, 1, (), (), "Layout", False),
|
|
PropDef("selectable", "Bool", "false", 0, 0, (), (), "Selectable", True),
|
|
PropDef("wrap", "Bool", "false", 0, 0, (), (), "WordWrap", False),
|
|
PropDef("transparent", "Bool", "false", 0, 0, (), (), "Transparent", False),
|
|
PropDef("show-accel-char", "Bool", "true", 0, 0, (), (), "ShowAccelChar", False),
|
|
PropDef("focus-control", "Str", "", 0, 0, (), (), "FocusControl", True),
|
|
)
|
|
|
|
BUTTON_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("relief", "Enum", "0", 0, 0, ("Normal", "Half", "None"), (0, 1, 2), "Relief", True),
|
|
PropDef("focus-on-click", "Bool", "true", 0, 0, (), (), "FocusOnClick", True),
|
|
PropDef("default", "Bool", "false", 0, 0, (), (), "Default", True),
|
|
PropDef("cancel", "Bool", "false", 0, 0, (), (), "Cancel", True),
|
|
PropDef("kind", "Enum", "0", 0, 0, ("None", "OK", "Cancel", "Yes", "No", "Close", "Help", "Retry", "Ignore", "Abort"), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), "Kind", True),
|
|
PropDef("modal-result", "Int", "0", 0, 100, (), (), "ModalResult", True),
|
|
PropDef("layout", "Enum", "0", 0, 0, ("Left", "Right", "Top", "Bottom"), (0, 1, 2, 3), "Layout", True),
|
|
PropDef("glyph", "Str", "", 0, 0, (), (), "Glyph", True),
|
|
)
|
|
|
|
TOPLEVEL_PROPS = (
|
|
PropDef("title", "Str", "", 0, 0, (), (), "Title", True),
|
|
PropDef("resizable", "Bool", "true", 0, 0, (), (), "Resizable", True),
|
|
PropDef("border-style", "Enum", "0", 0, 0, ("Default", "None", "Single", "Dialog"), (0, 1, 2, 3), "BorderStyle", True),
|
|
PropDef("icon", "Str", "", 0, 0, (), (), "Icon", True),
|
|
PropDef("position", "Enum", "0", 0, 0, ("Default", "Center", "ScreenCenter", "MainFormCenter", "Designed"), (0, 1, 2, 3, 4), "Position", True),
|
|
PropDef("window-state", "Enum", "0", 0, 0, ("Normal", "Minimized", "Maximized", "Fullscreen"), (0, 1, 2, 3), "WindowState", True),
|
|
)
|
|
|
|
FRAME_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("label-xalign", "Double", "0", 0, 1, (), (), "Alignment", False),
|
|
PropDef("inset", "Int", "8", 0, 1000, (), (), "Inset", False),
|
|
PropDef("top-inset", "Int", "14", 0, 1000, (), (), "TopInset", False),
|
|
PropDef("shadow-type", "Enum", "3", 0, 0, ("None", "In", "Out", "Etched in", "Etched out"), (0, 1, 2, 3, 4), "Bevel", False),
|
|
)
|
|
|
|
DATETIMEPICKER_PROPS = (
|
|
PropDef("date", "Str", "", 0, 0, (), (), "Date", False),
|
|
PropDef("show-heading", "Bool", "true", 0, 0, (), (), "ShowHeading", False),
|
|
PropDef("show-day-names", "Bool", "true", 0, 0, (), (), "ShowDayNames", False),
|
|
PropDef("show-week-numbers", "Bool", "false", 0, 0, (), (), "ShowWeekNumbers", False),
|
|
PropDef("grid-color", "Color", "rgb(205,205,205)", 0, 0, (), (), "GridColor", False),
|
|
PropDef("selected-fill-color", "Color", "rgb(52,101,164)", 0, 0, (), (), "SelectedFillColor", False),
|
|
PropDef("selected-text-color", "Color", "rgb(255,255,255)", 0, 0, (), (), "SelectedTextColor", False),
|
|
PropDef("today-color", "Color", "rgb(200,50,50)", 0, 0, (), (), "TodayColor", False),
|
|
PropDef("dim-text-color", "Color", "rgb(110,110,110)", 0, 0, (), (), "DimTextColor", False),
|
|
PropDef("weekends-color", "Color", "rgb(170,60,60)", 0, 0, (), (), "WeekendsColor", False),
|
|
PropDef("disabled-color", "Color", "rgb(150,150,150)", 0, 0, (), (), "DisabledColor", False),
|
|
)
|
|
|
|
CHECKBUTTON_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("active", "Bool", "false", 0, 0, (), (), "Checked", False),
|
|
PropDef("inconsistent", "Bool", "false", 0, 0, (), (), "State", False),
|
|
PropDef("allow-grayed", "Bool", "false", 0, 0, (), (), "AllowGrayed", False),
|
|
PropDef("alignment", "Enum", "0", 0, 0, ("Left", "Right"), (0, 1), "Alignment", False),
|
|
PropDef("value-checked", "Str", "", 0, 0, (), (), "ValueChecked", True),
|
|
PropDef("value-unchecked", "Str", "", 0, 0, (), (), "ValueUnchecked", True),
|
|
)
|
|
|
|
COLORBOX_PROPS = (
|
|
PropDef("color", "Color", "rgb(53,132,228)", 0, 0, (), (), "Selected", False),
|
|
PropDef("style", "Enum", "0", 0, 0, ("Standard", "Extended", "System", "Custom"), (0, 1, 2, 3), "Style", True),
|
|
PropDef("default-color", "Color", "rgb(255,255,255)", 0, 0, (), (), "DefaultColor", False),
|
|
PropDef("none-color", "Color", "rgb(0,0,0)", 0, 0, (), (), "NoneColor", False),
|
|
PropDef("use-alpha", "Bool", "false", 0, 0, (), (), "UseAlpha", False),
|
|
PropDef("title", "Str", "", 0, 0, (), (), "Title", False),
|
|
)
|
|
|
|
LISTVIEW_PROPS = (
|
|
PropDef("columns", "Str", "Name|Value", 0, 0, (), (), "Columns", True),
|
|
PropDef("items", "Str", "Row 1,Value 1;Row 2,Value 2", 0, 0, (), (), "Items", False),
|
|
PropDef("headers-visible", "Bool", "true", 0, 0, (), (), "HeadersVisible", False),
|
|
PropDef("item-index", "Int", "-1", -1, 100000, (), (), "ItemIndex", False),
|
|
PropDef("item-height", "Int", "0", 0, 1000, (), (), "ItemHeight", False),
|
|
PropDef("view-style", "Enum", "0", 0, 0, ("Report", "Icon", "SmallIcon", "List"), (0, 1, 2, 3), "ViewStyle", True),
|
|
PropDef("grid-lines", "Bool", "false", 0, 0, (), (), "GridLines", False),
|
|
PropDef("row-select", "Bool", "true", 0, 0, (), (), "RowSelect", False),
|
|
PropDef("multi-select", "Bool", "false", 0, 0, (), (), "MultiSelect", False),
|
|
PropDef("sort-type", "Enum", "0", 0, 0, ("None", "Ascending", "Descending"), (0, 1, 2), "SortType", True),
|
|
)
|
|
|
|
COMBOBOX_PROPS = (
|
|
PropDef("items", "Str", "Item 1|Item 2|Item 3", 0, 0, (), (), "Items", False),
|
|
PropDef("active", "Int", "0", -1, 1000, (), (), "ItemIndex", False),
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Text", False),
|
|
PropDef("style", "Enum", "0", 0, 0, ("DropDown", "Simple", "DropDownList"), (0, 1, 2), "Style", True),
|
|
PropDef("drop-down-count", "Int", "8", 1, 100, (), (), "DropDownCount", True),
|
|
PropDef("drop-down-width", "Int", "0", 0, 10000, (), (), "DropDownWidth", True),
|
|
PropDef("sorted", "Bool", "false", 0, 0, (), (), "Sorted", True),
|
|
PropDef("read-only", "Bool", "false", 0, 0, (), (), "ReadOnly", False),
|
|
PropDef("max-length", "Int", "0", 0, 100000, (), (), "MaxLength", True),
|
|
PropDef("auto-complete", "Bool", "false", 0, 0, (), (), "AutoComplete", True),
|
|
PropDef("char-case", "Enum", "0", 0, 0, ("Normal", "Upper", "Lower"), (0, 1, 2), "CharCase", True),
|
|
)
|
|
|
|
ENTRY_PROPS = (
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Text", False),
|
|
PropDef("placeholder-text", "Str", "", 0, 0, (), (), "TextHint", False),
|
|
PropDef("max-length", "Int", "0", 0, 100000, (), (), "MaxLength", True),
|
|
PropDef("width-chars", "Int", "-1", -1, 1000, (), (), "WidthChars", True),
|
|
PropDef("editable", "Bool", "true", 0, 0, (), (), "ReadOnly", False),
|
|
PropDef("password", "Bool", "false", 0, 0, (), (), "PasswordChar", False),
|
|
PropDef("show-password", "Bool", "false", 0, 0, (), (), "ShowPassword", False),
|
|
PropDef("alignment", "Enum", "0", 0, 0, ("Left", "Center", "Right"), (0, 1, 2), "Alignment", False),
|
|
PropDef("char-case", "Enum", "0", 0, 0, ("Normal", "Upper", "Lower"), (0, 1, 2), "CharCase", True),
|
|
PropDef("numbers-only", "Bool", "false", 0, 0, (), (), "NumbersOnly", True),
|
|
PropDef("hide-selection", "Bool", "false", 0, 0, (), (), "HideSelection", True),
|
|
PropDef("auto-select", "Bool", "false", 0, 0, (), (), "AutoSelect", True),
|
|
)
|
|
|
|
LISTBOX_PROPS = (
|
|
PropDef("items", "Str", "Item 1|Item 2|Item 3", 0, 0, (), (), "Items", False),
|
|
PropDef("selection-mode", "Enum", "1", 0, 0, ("None", "Single", "Browse", "Multiple"), (0, 1, 2, 3), "SelectionMode", False),
|
|
PropDef("item-index", "Int", "-1", -1, 100000, (), (), "ItemIndex", False),
|
|
PropDef("sorted", "Bool", "false", 0, 0, (), (), "Sorted", True),
|
|
PropDef("columns", "Int", "1", 1, 100, (), (), "Columns", True),
|
|
PropDef("item-height", "Int", "0", 0, 1000, (), (), "ItemHeight", False),
|
|
PropDef("integral-height", "Bool", "false", 0, 0, (), (), "IntegralHeight", True),
|
|
)
|
|
|
|
IMAGE_PROPS = (
|
|
PropDef("file", "Str", "", 0, 0, (), (), "Picture", False),
|
|
PropDef("pixel-size", "Int", "-1", -1, 512, (), (), "PixelSize", False),
|
|
PropDef("stretch", "Bool", "false", 0, 0, (), (), "Stretch", False),
|
|
PropDef("proportional", "Bool", "true", 0, 0, (), (), "Proportional", False),
|
|
PropDef("center", "Bool", "true", 0, 0, (), (), "Center", False),
|
|
PropDef("transparent", "Bool", "false", 0, 0, (), (), "Transparent", False),
|
|
)
|
|
|
|
SCALE_PROPS = (
|
|
PropDef("value", "Double", "0", 0, 100, (), (), "Position", False),
|
|
PropDef("minimum", "Double", "0", -1000000, 1000000, (), (), "Min", False),
|
|
PropDef("maximum", "Double", "100", -1000000, 1000000, (), (), "Max", False),
|
|
PropDef("digits", "Int", "1", -1, 10, (), (), "DecimalPlaces", False),
|
|
PropDef("draw-value", "Bool", "true", 0, 0, (), (), "DrawValue", False),
|
|
PropDef("inverted", "Bool", "false", 0, 0, (), (), "Inverted", False),
|
|
PropDef("page-step", "Double", "10", 0, 1000000, (), (), "PageSize", False),
|
|
PropDef("tick-marks", "Enum", "0", 0, 0, ("None", "TopLeft", "BottomRight", "Both"), (0, 1, 2, 3), "TickMarks", False),
|
|
PropDef("frequency", "Int", "10", 1, 1000000, (), (), "Frequency", False),
|
|
PropDef("show-sel-range", "Bool", "false", 0, 0, (), (), "ShowSelRange", False),
|
|
PropDef("sel-start", "Double", "0", -1000000, 1000000, (), (), "SelStart", False),
|
|
PropDef("sel-end", "Double", "0", -1000000, 1000000, (), (), "SelEnd", False),
|
|
)
|
|
|
|
MENUBAR_PROPS = (
|
|
PropDef("menus", "Str", "File|Edit|Help", 0, 0, (), (), "Menus", False),
|
|
)
|
|
|
|
MENUBUTTON_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("direction", "Enum", "1", 0, 0, ("Up", "Down", "Left", "Right", "None"), (0, 1, 2, 3, 4), "Direction", False),
|
|
)
|
|
|
|
MENUITEM_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
)
|
|
|
|
NOTEBOOK_PROPS = (
|
|
PropDef("pages", "Str", "Tab 1|Tab 2|Tab 3", 0, 0, (), (), "Pages", False),
|
|
PropDef("page", "Int", "0", 0, 100, (), (), "ActivePage", False),
|
|
PropDef("tab-height", "Int", "26", 0, 1000, (), (), "TabHeight", False),
|
|
PropDef("tab-position", "Enum", "0", 0, 0, ("Top", "Bottom", "Left", "Right"), (0, 1, 2, 3), "TabPosition", False),
|
|
PropDef("tab-width", "Int", "0", 0, 1000, (), (), "TabWidth", False),
|
|
)
|
|
|
|
SPLITTER_PROPS = (
|
|
PropDef("position", "Int", "100", 0, 10000, (), (), "Position", False),
|
|
PropDef("orientation", "Enum", "0", 0, 0, ("Horizontal", "Vertical"), (0, 1), "Kind", False),
|
|
PropDef("min-size", "Int", "0", 0, 10000, (), (), "MinSize", True),
|
|
PropDef("resize-style", "Enum", "0", 0, 0, ("Update", "Line"), (0, 1), "ResizeStyle", True),
|
|
PropDef("auto-snap", "Bool", "false", 0, 0, (), (), "AutoSnap", True),
|
|
)
|
|
|
|
PROGRESSBAR_PROPS = (
|
|
PropDef("fraction", "Double", "0", 0, 1, (), (), "Fraction", False),
|
|
PropDef("position", "Double", "45", -1000000, 1000000, (), (), "Position", False),
|
|
PropDef("minimum", "Double", "0", -1000000, 1000000, (), (), "Min", False),
|
|
PropDef("maximum", "Double", "100", -1000000, 1000000, (), (), "Max", False),
|
|
PropDef("step", "Double", "1", 0, 1000000, (), (), "Step", False),
|
|
PropDef("show-text", "Bool", "false", 0, 0, (), (), "BarShowText", False),
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Text", False),
|
|
PropDef("pulsing", "Bool", "false", 0, 0, (), (), "Style", False),
|
|
PropDef("inverted", "Bool", "false", 0, 0, (), (), "Inverted", False),
|
|
PropDef("bar-color", "Color", "rgb(52,101,164)", 0, 0, (), (), "BarColor", False),
|
|
PropDef("trough-color", "Color", "rgb(225,225,225)", 0, 0, (), (), "TroughColor", False),
|
|
)
|
|
|
|
RADIOBUTTON_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("active", "Bool", "false", 0, 0, (), (), "Checked", False),
|
|
PropDef("group", "Int", "0", 0, 100000, (), (), "Group", True),
|
|
)
|
|
|
|
SCROLLBAR_PROPS = (
|
|
PropDef("value", "Double", "0", 0, 100, (), (), "Position", False),
|
|
PropDef("lower", "Double", "0", -1000000, 1000000, (), (), "Min", False),
|
|
PropDef("upper", "Double", "100", -1000000, 1000000, (), (), "Max", False),
|
|
PropDef("step-increment", "Double", "1", 0, 1000000, (), (), "SmallChange", False),
|
|
PropDef("page-increment", "Double", "10", 0, 1000000, (), (), "LargeChange", False),
|
|
PropDef("page-size", "Double", "10", 0, 1000000, (), (), "PageSize", False),
|
|
PropDef("inverted", "Bool", "false", 0, 0, (), (), "Inverted", False),
|
|
PropDef("orientation", "Enum", "0", 0, 0, ("Horizontal", "Vertical"), (0, 1), "Kind", False),
|
|
PropDef("large-change", "Double", "10", 0, 1000000, (), (), "large-change", False),
|
|
)
|
|
|
|
SCROLLBOX_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
)
|
|
|
|
SPINEDIT_PROPS = (
|
|
PropDef("minimum", "Int", "0", -1000000, 1000000, (), (), "Min", False),
|
|
PropDef("maximum", "Int", "100", -1000000, 1000000, (), (), "Max", False),
|
|
PropDef("step", "Int", "1", 1, 1000, (), (), "Increment", False),
|
|
PropDef("value", "Double", "0", -1000000, 1000000, (), (), "Value", False),
|
|
PropDef("digits", "Int", "0", 0, 10, (), (), "DecimalPlaces", False),
|
|
PropDef("numeric", "Bool", "true", 0, 0, (), (), "numeric", True),
|
|
PropDef("wrap", "Bool", "false", 0, 0, (), (), "WordWrap", False),
|
|
PropDef("editor-enabled", "Bool", "true", 0, 0, (), (), "editor-enabled", True),
|
|
)
|
|
|
|
STATUSBAR_PROPS = (
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Text", False),
|
|
PropDef("panels", "Str", "", 0, 0, (), (), "Panels", False),
|
|
PropDef("size-grip", "Bool", "true", 0, 0, (), (), "SizeGrip", False),
|
|
)
|
|
|
|
TOGGLEBUTTON_PROPS = (
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("active", "Bool", "false", 0, 0, (), (), "Down", False),
|
|
PropDef("group-index", "Int", "0", 0, 100000, (), (), "GroupIndex", True),
|
|
PropDef("allow-all-up", "Bool", "false", 0, 0, (), (), "AllowAllUp", True),
|
|
PropDef("flat", "Bool", "false", 0, 0, (), (), "Flat", False),
|
|
PropDef("glyph", "Str", "", 0, 0, (), (), "Glyph", True),
|
|
)
|
|
|
|
TEXT_PROPS = (
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Text", False),
|
|
PropDef("editable", "Bool", "true", 0, 0, (), (), "ReadOnly", False),
|
|
PropDef("cursor-visible", "Bool", "true", 0, 0, (), (), "CursorVisible", False),
|
|
PropDef("wrap-mode", "Enum", "0", 0, 0, ("None", "Char", "Word", "Word-char"), (0, 1, 2, 3), "WordWrap", False),
|
|
PropDef("max-length", "Int", "0", 0, 100000, (), (), "MaxLength", True),
|
|
PropDef("scroll-bars", "Enum", "0", 0, 0, ("None", "Horizontal", "Vertical", "Both"), (0, 1, 2, 3), "ScrollBars", False),
|
|
PropDef("want-tabs", "Bool", "true", 0, 0, (), (), "WantTabs", True),
|
|
PropDef("want-returns", "Bool", "true", 0, 0, (), (), "WantReturns", True),
|
|
PropDef("hide-selection", "Bool", "false", 0, 0, (), (), "HideSelection", True),
|
|
PropDef("alignment", "Enum", "0", 0, 0, ("Left", "Center", "Right"), (0, 1, 2), "Alignment", False),
|
|
)
|
|
|
|
TOOLBAR_PROPS = (
|
|
PropDef("items", "Str", "New|Open|Save", 0, 0, (), (), "Items", False),
|
|
PropDef("toolbar-style", "Enum", "2", 0, 0, ("Icons", "Text", "Both", "Both horizontal"), (0, 1, 2, 3), "Style", False),
|
|
PropDef("show-captions", "Bool", "true", 0, 0, (), (), "ShowCaptions", False),
|
|
PropDef("flat", "Bool", "false", 0, 0, (), (), "Flat", False),
|
|
PropDef("button-width", "Int", "0", 0, 1000, (), (), "ButtonWidth", False),
|
|
PropDef("button-height", "Int", "0", 0, 1000, (), (), "ButtonHeight", False),
|
|
)
|
|
|
|
TREEVIEW_PROPS = (
|
|
PropDef("items", "Str", "Root/Child 1;Root/Child 2;Other", 0, 0, (), (), "Items", False),
|
|
PropDef("headers-visible", "Bool", "true", 0, 0, (), (), "HeadersVisible", False),
|
|
PropDef("item-index", "Int", "-1", -1, 100000, (), (), "ItemIndex", False),
|
|
PropDef("item-height", "Int", "0", 0, 1000, (), (), "ItemHeight", False),
|
|
PropDef("header-height", "Int", "22", 0, 1000, (), (), "HeaderHeight", False),
|
|
PropDef("grid-lines", "Bool", "false", 0, 0, (), (), "GridLines", False),
|
|
PropDef("row-select", "Bool", "true", 0, 0, (), (), "RowSelect", False),
|
|
PropDef("multi-select", "Bool", "false", 0, 0, (), (), "MultiSelect", False),
|
|
PropDef("sort-type", "Enum", "0", 0, 0, ("None", "Ascending", "Descending"), (0, 1, 2), "SortType", True),
|
|
PropDef("indent", "Int", "16", 0, 1000, (), (), "Indent", False),
|
|
PropDef("show-buttons", "Bool", "true", 0, 0, (), (), "ShowButtons", False),
|
|
PropDef("show-lines", "Bool", "true", 0, 0, (), (), "ShowLines", False),
|
|
PropDef("show-root", "Bool", "true", 0, 0, (), (), "ShowRoot", False),
|
|
)
|
|
|
|
PANEL_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("label-xalign", "Double", "0", 0, 1, (), (), "Alignment", False),
|
|
PropDef("inset", "Int", "8", 0, 1000, (), (), "Inset", False),
|
|
PropDef("top-inset", "Int", "14", 0, 1000, (), (), "TopInset", False),
|
|
PropDef("shadow-type", "Enum", "3", 0, 0, ("None", "In", "Out", "Etched in", "Etched out"), (0, 1, 2, 3, 4), "Bevel", False),
|
|
)
|
|
|
|
CHECKLISTBOX_PROPS = (
|
|
PropDef("items", "Str", "Item 1|Item 2|Item 3", 0, 0, (), (), "Items", False),
|
|
PropDef("checked-items", "Str", "", 0, 0, (), (), "Checked", False),
|
|
PropDef("item-index", "Int", "-1", -1, 100000, (), (), "ItemIndex", False),
|
|
PropDef("item-height", "Int", "0", 0, 1000, (), (), "ItemHeight", False),
|
|
PropDef("sorted", "Bool", "false", 0, 0, (), (), "Sorted", True),
|
|
)
|
|
|
|
STRINGGRID_PROPS = (
|
|
PropDef("rows", "Int", "5", 1, 50, (), (), "RowCount", False),
|
|
PropDef("columns", "Int", "4", 1, 26, (), (), "Columns", True),
|
|
PropDef("headers-visible", "Bool", "true", 0, 0, (), (), "HeadersVisible", False),
|
|
PropDef("fixed-cols", "Int", "0", 0, 26, (), (), "FixedCols", False),
|
|
PropDef("fixed-rows", "Int", "0", 0, 50, (), (), "FixedRows", False),
|
|
PropDef("default-col-width", "Int", "84", 1, 1000, (), (), "DefaultColWidth", False),
|
|
PropDef("default-row-height", "Int", "20", 1, 1000, (), (), "DefaultRowHeight", False),
|
|
PropDef("grid-line-width", "Int", "1", 0, 100, (), (), "GridLineWidth", False),
|
|
)
|
|
|
|
GROUPBOX_PROPS = (
|
|
PropDef("label", "Str", "", 0, 0, (), (), "Caption", False),
|
|
PropDef("label-xalign", "Double", "0", 0, 1, (), (), "Alignment", False),
|
|
PropDef("inset", "Int", "8", 0, 1000, (), (), "Inset", False),
|
|
PropDef("top-inset", "Int", "14", 0, 1000, (), (), "TopInset", False),
|
|
PropDef("shadow-type", "Enum", "3", 0, 0, ("None", "In", "Out", "Etched in", "Etched out"), (0, 1, 2, 3, 4), "Bevel", False),
|
|
)
|
|
|
|
MEMO_PROPS = (
|
|
PropDef("text", "Str", "", 0, 0, (), (), "Text", False),
|
|
PropDef("editable", "Bool", "true", 0, 0, (), (), "ReadOnly", False),
|
|
PropDef("cursor-visible", "Bool", "true", 0, 0, (), (), "CursorVisible", False),
|
|
PropDef("wrap-mode", "Enum", "0", 0, 0, ("None", "Char", "Word", "Word-char"), (0, 1, 2, 3), "WordWrap", False),
|
|
PropDef("max-length", "Int", "0", 0, 100000, (), (), "MaxLength", True),
|
|
PropDef("scroll-bars", "Enum", "3", 0, 0, ("None", "Horizontal", "Vertical", "Both"), (0, 1, 2, 3), "ScrollBars", False),
|
|
PropDef("want-tabs", "Bool", "true", 0, 0, (), (), "WantTabs", True),
|
|
PropDef("want-returns", "Bool", "true", 0, 0, (), (), "WantReturns", True),
|
|
PropDef("hide-selection", "Bool", "false", 0, 0, (), (), "HideSelection", True),
|
|
PropDef("alignment", "Enum", "0", 0, 0, ("Left", "Center", "Right"), (0, 1, 2), "Alignment", False),
|
|
)
|
|
|
|
SHAPE_PROPS = (
|
|
PropDef("shape", "Enum", "0", 0, 0, ("Rectangle", "Square", "RoundRect", "RoundSquare", "Ellipse", "Circle", "Triangle", "Diamond", "Pentagon", "Hexagon"), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), "Shape", False),
|
|
PropDef("fill-color", "Color", "rgb(70,130,200)", 0, 0, (), (), "FillColor", False),
|
|
PropDef("pen-color", "Color", "rgb(20,40,80)", 0, 0, (), (), "PenColor", False),
|
|
PropDef("pen-width", "Int", "2", 1, 100, (), (), "PenWidth", False),
|
|
)
|
|
|
|
TRACKBAR_PROPS = (
|
|
PropDef("minimum", "Int", "0", -1000000, 1000000, (), (), "Min", False),
|
|
PropDef("maximum", "Int", "100", -1000000, 1000000, (), (), "Max", False),
|
|
PropDef("step", "Int", "1", 1, 1000, (), (), "Step", False),
|
|
PropDef("value", "Double", "0", 0, 100, (), (), "Position", False),
|
|
PropDef("digits", "Int", "1", 0, 10, (), (), "DecimalPlaces", False),
|
|
PropDef("draw-value", "Bool", "true", 0, 0, (), (), "DrawValue", False),
|
|
PropDef("inverted", "Bool", "false", 0, 0, (), (), "Inverted", False),
|
|
PropDef("orientation", "Enum", "0", 0, 0, ("Horizontal", "Vertical"), (0, 1), "Kind", False),
|
|
PropDef("page-step", "Double", "10", 0, 1000000, (), (), "PageSize", False),
|
|
PropDef("tick-marks", "Enum", "0", 0, 0, ("None", "TopLeft", "BottomRight", "Both"), (0, 1, 2, 3), "TickMarks", False),
|
|
PropDef("frequency", "Int", "10", 1, 1000000, (), (), "Frequency", False),
|
|
PropDef("show-sel-range", "Bool", "false", 0, 0, (), (), "ShowSelRange", False),
|
|
PropDef("sel-start", "Double", "0", -1000000, 1000000, (), (), "SelStart", False),
|
|
PropDef("sel-end", "Double", "0", -1000000, 1000000, (), (), "SelEnd", False),
|
|
)
|
|
|
|
PLOT_PROPS = (
|
|
PropDef("title", "Str", "", 0, 0, (), (), "Title", False),
|
|
PropDef("line-color", "Color", "rgb(220,0,0)", 0, 0, (), (), "LineColor", False),
|
|
)
|
|
|
|
SPREADSHEET_PROPS = (
|
|
PropDef("rows", "Int", "5", 1, 50, (), (), "RowCount", False),
|
|
PropDef("columns", "Int", "4", 1, 26, (), (), "Columns", True),
|
|
PropDef("fixed-cols", "Int", "0", 0, 26, (), (), "FixedCols", False),
|
|
PropDef("fixed-rows", "Int", "0", 0, 50, (), (), "FixedRows", False),
|
|
PropDef("default-col-width", "Int", "84", 1, 1000, (), (), "DefaultColWidth", False),
|
|
PropDef("default-row-height", "Int", "20", 1, 1000, (), (), "DefaultRowHeight", False),
|
|
PropDef("grid-line-width", "Int", "1", 0, 100, (), (), "GridLineWidth", False),
|
|
)
|
|
|
|
# palette kind -> custom (non-generic) props tuple
|
|
CUSTOM_PROPS = {
|
|
"AboutDialog": DIALOG_PROPS,
|
|
"AccelLabel": LABEL_PROPS,
|
|
"AppChooserButton": BUTTON_PROPS,
|
|
"AppChooserDialog": DIALOG_PROPS,
|
|
"ApplicationWindow": TOPLEVEL_PROPS,
|
|
"AspectFrame": FRAME_PROPS,
|
|
"Assistant": DIALOG_PROPS,
|
|
"Button": BUTTON_PROPS,
|
|
"Calendar": DATETIMEPICKER_PROPS,
|
|
"CheckButton": CHECKBUTTON_PROPS,
|
|
"CheckMenuItem": CHECKBUTTON_PROPS,
|
|
"ColorButton": COLORBOX_PROPS,
|
|
"ColorChooserDialog": DIALOG_PROPS,
|
|
"ColorChooserWidget": COLORBOX_PROPS,
|
|
"ColorDialogButton": COLORBOX_PROPS,
|
|
"ColumnView": LISTVIEW_PROPS,
|
|
"ComboBox": COMBOBOX_PROPS,
|
|
"ComboBoxText": COMBOBOX_PROPS,
|
|
"Dialog": DIALOG_PROPS,
|
|
"DropDown": COMBOBOX_PROPS,
|
|
"EditableLabel": ENTRY_PROPS,
|
|
"Entry": ENTRY_PROPS,
|
|
"EntryCompletion": COMBOBOX_PROPS,
|
|
"FileChooserButton": BUTTON_PROPS,
|
|
"FileChooserDialog": DIALOG_PROPS,
|
|
"FlowBox": LISTBOX_PROPS,
|
|
"FontButton": BUTTON_PROPS,
|
|
"FontChooserDialog": DIALOG_PROPS,
|
|
"Frame": FRAME_PROPS,
|
|
"GridView": LISTVIEW_PROPS,
|
|
"IconView": LISTVIEW_PROPS,
|
|
"Image": IMAGE_PROPS,
|
|
"Inscription": LABEL_PROPS,
|
|
"Label": LABEL_PROPS,
|
|
"LevelBar": SCALE_PROPS,
|
|
"LinkButton": BUTTON_PROPS,
|
|
"ListBox": LISTBOX_PROPS,
|
|
"ListView": LISTVIEW_PROPS,
|
|
"LockButton": BUTTON_PROPS,
|
|
"Menu": MENUBAR_PROPS,
|
|
"MenuBar": MENUBAR_PROPS,
|
|
"MenuButton": MENUBUTTON_PROPS,
|
|
"MenuItem": MENUITEM_PROPS,
|
|
"MessageDialog": DIALOG_PROPS,
|
|
"ModelButton": BUTTON_PROPS,
|
|
"Notebook": NOTEBOOK_PROPS,
|
|
"Paned": SPLITTER_PROPS,
|
|
"PasswordEntry": ENTRY_PROPS,
|
|
"Picture": IMAGE_PROPS,
|
|
"PlacesSidebar": LISTBOX_PROPS,
|
|
"PrintUnixDialog": DIALOG_PROPS,
|
|
"ProgressBar": PROGRESSBAR_PROPS,
|
|
"RadioButton": RADIOBUTTON_PROPS,
|
|
"RadioMenuItem": RADIOBUTTON_PROPS,
|
|
"Scale": SCALE_PROPS,
|
|
"ScaleButton": SCALE_PROPS,
|
|
"Scrollbar": SCROLLBAR_PROPS,
|
|
"ScrolledWindow": SCROLLBOX_PROPS,
|
|
"SearchEntry": ENTRY_PROPS,
|
|
"ShortcutsWindow": DIALOG_PROPS,
|
|
"SpinButton": SPINEDIT_PROPS,
|
|
"StackSidebar": LISTBOX_PROPS,
|
|
"StackSwitcher": LISTBOX_PROPS,
|
|
"Statusbar": STATUSBAR_PROPS,
|
|
"Switch": TOGGLEBUTTON_PROPS,
|
|
"TextView": TEXT_PROPS,
|
|
"ToggleButton": TOGGLEBUTTON_PROPS,
|
|
"ToggleToolButton": BUTTON_PROPS,
|
|
"ToolButton": BUTTON_PROPS,
|
|
"Toolbar": TOOLBAR_PROPS,
|
|
"TreeView": TREEVIEW_PROPS,
|
|
"VolumeButton": BUTTON_PROPS,
|
|
"Window": TOPLEVEL_PROPS,
|
|
"BitBtn": BUTTON_PROPS,
|
|
"Button": BUTTON_PROPS,
|
|
"ButtonPanel": PANEL_PROPS,
|
|
"CalcEdit": ENTRY_PROPS,
|
|
"CalculatorDialog": DIALOG_PROPS,
|
|
"Calendar": DATETIMEPICKER_PROPS,
|
|
"CalendarDialog": DIALOG_PROPS,
|
|
"CheckBox": CHECKBUTTON_PROPS,
|
|
"CheckComboBox": COMBOBOX_PROPS,
|
|
"CheckGroup": LISTBOX_PROPS,
|
|
"CheckListBox": CHECKLISTBOX_PROPS,
|
|
"ColorBox": COLORBOX_PROPS,
|
|
"ColorButton": COLORBOX_PROPS,
|
|
"ColorDialog": DIALOG_PROPS,
|
|
"ColorListBox": COLORBOX_PROPS,
|
|
"ComboBox": COMBOBOX_PROPS,
|
|
"ComboBoxEx": COMBOBOX_PROPS,
|
|
"ControlBar": TOOLBAR_PROPS,
|
|
"CoolBar": TOOLBAR_PROPS,
|
|
"DateEdit": ENTRY_PROPS,
|
|
"DateTimePicker": DATETIMEPICKER_PROPS,
|
|
"DirectoryEdit": ENTRY_PROPS,
|
|
"DrawGrid": STRINGGRID_PROPS,
|
|
"Edit": ENTRY_PROPS,
|
|
"EditButton": BUTTON_PROPS,
|
|
"FileListBox": LISTBOX_PROPS,
|
|
"FileNameEdit": ENTRY_PROPS,
|
|
"FilterComboBox": COMBOBOX_PROPS,
|
|
"FindDialog": DIALOG_PROPS,
|
|
"FloatSpinEdit": SPINEDIT_PROPS,
|
|
"FontDialog": DIALOG_PROPS,
|
|
"Form": TOPLEVEL_PROPS,
|
|
"Frame": FRAME_PROPS,
|
|
"GroupBox": GROUPBOX_PROPS,
|
|
"HeaderControl": TOOLBAR_PROPS,
|
|
"Image": IMAGE_PROPS,
|
|
"Label": LABEL_PROPS,
|
|
"LabeledEdit": ENTRY_PROPS,
|
|
"ListBox": LISTBOX_PROPS,
|
|
"ListView": LISTVIEW_PROPS,
|
|
"MainMenu": MENUBAR_PROPS,
|
|
"MaskEdit": ENTRY_PROPS,
|
|
"Memo": MEMO_PROPS,
|
|
"Notebook": NOTEBOOK_PROPS,
|
|
"OpenDialog": DIALOG_PROPS,
|
|
"OpenPictureDialog": DIALOG_PROPS,
|
|
"PageControl": NOTEBOOK_PROPS,
|
|
"PageSetupDialog": DIALOG_PROPS,
|
|
"PairSplitter": SPLITTER_PROPS,
|
|
"Panel": PANEL_PROPS,
|
|
"PopupMenu": MENUBAR_PROPS,
|
|
"PrintDialog": DIALOG_PROPS,
|
|
"PrinterSetupDialog": DIALOG_PROPS,
|
|
"ProgressBar": PROGRESSBAR_PROPS,
|
|
"RadioButton": RADIOBUTTON_PROPS,
|
|
"RadioGroup": LISTBOX_PROPS,
|
|
"ReplaceDialog": DIALOG_PROPS,
|
|
"SaveDialog": DIALOG_PROPS,
|
|
"SavePictureDialog": DIALOG_PROPS,
|
|
"ScrollBar": SCROLLBAR_PROPS,
|
|
"ScrollBox": SCROLLBOX_PROPS,
|
|
"SelectDirectoryDialog": DIALOG_PROPS,
|
|
"Shape": SHAPE_PROPS,
|
|
"ShellListView": LISTVIEW_PROPS,
|
|
"ShellTreeView": TREEVIEW_PROPS,
|
|
"SpeedButton": TOGGLEBUTTON_PROPS,
|
|
"SpinEdit": SPINEDIT_PROPS,
|
|
"Splitter": SPLITTER_PROPS,
|
|
"StaticText": LABEL_PROPS,
|
|
"StatusBar": STATUSBAR_PROPS,
|
|
"StringGrid": STRINGGRID_PROPS,
|
|
"TabControl": NOTEBOOK_PROPS,
|
|
"TaskDialog": DIALOG_PROPS,
|
|
"TimeEdit": ENTRY_PROPS,
|
|
"ToggleBox": TOGGLEBUTTON_PROPS,
|
|
"ToolBar": TOOLBAR_PROPS,
|
|
"TrackBar": TRACKBAR_PROPS,
|
|
"TreeView": TREEVIEW_PROPS,
|
|
"UpDown": SPINEDIT_PROPS,
|
|
"ValueListEditor": STRINGGRID_PROPS,
|
|
"XGraph": PLOT_PROPS,
|
|
"XSpreadsheet": SPREADSHEET_PROPS,
|
|
}
|
|
|
|
# Registry names (GtkButton, TButton, ...) resolve through
|
|
# the palette; this is the kind-level custom table only.
|
|
_CUSTOM_BY_KIND = dict(CUSTOM_PROPS)
|
|
|
|
|
|
def props_for(kind_or_name):
|
|
"""Full table (generic + custom) for a palette kind or
|
|
a registry name (e.g. "GtkButton" or "Button").
|
|
Unknown names get the generic set only."""
|
|
kind = _resolve_kind(kind_or_name)
|
|
custom = _CUSTOM_BY_KIND.get(kind, ())
|
|
seen = {p.name for p in custom}
|
|
return tuple(p for p in GENERIC_PROPS
|
|
if p.name not in seen) + tuple(custom)
|
|
|
|
|
|
def custom_props_for(kind_or_name):
|
|
"""Custom (non-generic) props only, or () if none."""
|
|
return _CUSTOM_BY_KIND.get(_resolve_kind(kind_or_name), ())
|
|
|
|
|
|
def prop_names(kind_or_name):
|
|
return frozenset(p.name for p in props_for(kind_or_name))
|
|
|
|
|
|
def find_prop(kind_or_name, name):
|
|
for prop in props_for(kind_or_name):
|
|
if prop.name == name:
|
|
return prop
|
|
return None
|
|
|
|
|
|
def is_model_only(kind_or_name, name):
|
|
prop = find_prop(kind_or_name, name)
|
|
return bool(prop.model_only) if prop is not None else False
|
|
|
|
|
|
def register_custom_table(kind, props):
|
|
"""Add/replace the custom table for one palette kind.
|
|
Phase 6 uses this for the Stock / Instrumentation
|
|
families; it never touches the generated tables."""
|
|
_CUSTOM_BY_KIND[str(kind)] = tuple(props)
|
|
|
|
|
|
def _resolve_kind(kind_or_name):
|
|
name = str(kind_or_name)
|
|
if name in _CUSTOM_BY_KIND or name in _ALL_KINDS:
|
|
return name
|
|
try:
|
|
from lightgui.xframe import palette as _palette
|
|
entry = _palette.find(name)
|
|
if entry is not None:
|
|
return entry.kind
|
|
except Exception:
|
|
pass
|
|
return name
|
|
|
|
|
|
def validate(kind_or_name, name, value):
|
|
"""Validate *value* against the table for *kind* and
|
|
return its canonical string form. Raises ValueError
|
|
for an unknown prop, a bad bool/int/double, an enum
|
|
label or value outside its range."""
|
|
prop = find_prop(kind_or_name, name)
|
|
if prop is None:
|
|
raise ValueError("unknown property %r for %r"
|
|
% (name, kind_or_name))
|
|
return _canonical(prop, value)
|
|
|
|
|
|
def _canonical(prop, value):
|
|
kind = prop.kind
|
|
if kind == "Bool":
|
|
if isinstance(value, bool):
|
|
return "true" if value else "false"
|
|
text = str(value).strip().lower()
|
|
if text in ("true", "1", "yes", "on"):
|
|
return "true"
|
|
if text in ("false", "0", "no", "off"):
|
|
return "false"
|
|
raise ValueError("not a bool: %r" % (value,))
|
|
if kind == "Int":
|
|
try:
|
|
number = int(str(value).strip())
|
|
except (TypeError, ValueError):
|
|
raise ValueError("not an int: %r" % (value,))
|
|
if prop.lo or prop.hi:
|
|
if number < prop.lo or number > prop.hi:
|
|
raise ValueError(
|
|
"%s out of range %d..%d: %r"
|
|
% (prop.name, prop.lo, prop.hi, value))
|
|
return str(number)
|
|
if kind == "Double":
|
|
try:
|
|
number = float(str(value).strip())
|
|
except (TypeError, ValueError):
|
|
raise ValueError("not a number: %r" % (value,))
|
|
if prop.lo or prop.hi:
|
|
if number < prop.lo or number > prop.hi:
|
|
raise ValueError(
|
|
"%s out of range %s..%s: %r"
|
|
% (prop.name, prop.lo, prop.hi, value))
|
|
return "%g" % number
|
|
if kind == "Enum":
|
|
text = str(value).strip()
|
|
if prop.enum_labels and text in prop.enum_labels:
|
|
return str(prop.enum_values[
|
|
prop.enum_labels.index(text)]
|
|
if prop.enum_values else text)
|
|
try:
|
|
number = int(text)
|
|
except ValueError:
|
|
raise ValueError("not an enum value: %r" % (value,))
|
|
if prop.enum_values and number not in prop.enum_values:
|
|
raise ValueError("enum value out of range: %r"
|
|
% (value,))
|
|
return str(number)
|
|
if kind == "Color":
|
|
return _canonical_color(str(value))
|
|
return "" if value is None else str(value)
|
|
|
|
|
|
def _canonical_color(text):
|
|
text = text.strip()
|
|
if not text:
|
|
return ""
|
|
if text.startswith("#") and len(text) in (4, 7, 9):
|
|
digits = text[1:]
|
|
if all(c in "0123456789abcdefABCDEF" for c in digits):
|
|
return text.lower()
|
|
match = re.match(r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)",
|
|
text)
|
|
if match:
|
|
r, g, b = (int(v) for v in match.groups())
|
|
if max(r, g, b) <= 255:
|
|
return "rgb(%d,%d,%d)" % (r, g, b)
|
|
if text.lower() in _NAMED_COLORS:
|
|
return text.lower()
|
|
raise ValueError("not a color: %r" % (text,))
|
|
|
|
|
|
_NAMED_COLORS = frozenset([
|
|
"black", "white", "red", "green", "blue", "yellow",
|
|
"orange", "purple", "teal", "magenta", "brown", "gray",
|
|
"grey", "pink", "cyan", "transparent"])
|
|
|
|
_ALL_KINDS = frozenset(("AboutDialog", "AccelLabel", "ActionBar", "AppChooserButton", "AppChooserDialog", "AppChooserWidget", "ApplicationWindow", "AspectFrame", "Assistant", "Box", "Button", "ButtonBox", "Calendar", "CellView", "CenterBox", "CheckButton", "CheckMenuItem", "ColorButton", "ColorChooserDialog", "ColorChooserWidget", "ColorDialogButton", "ColumnView", "ComboBox", "ComboBoxText", "Dialog", "DrawingArea", "DropDown", "EditableLabel", "Entry", "EntryCompletion", "EventBox", "Expander", "FileChooserButton", "FileChooserDialog", "FileChooserWidget", "Fixed", "FlowBox", "FontButton", "FontChooserDialog", "FontChooserWidget", "Frame", "GLArea", "Grid", "GridView", "HeaderBar", "IconView", "Image", "InfoBar", "Inscription", "Invisible", "Label", "Layout", "LevelBar", "LinkButton", "ListBox", "ListView", "LockButton", "MediaControls", "Menu", "MenuBar", "MenuButton", "MenuItem", "MessageDialog", "ModelButton", "Notebook", "Overlay", "Paned", "PasswordEntry", "Picture", "PlacesSidebar", "Popover", "PrintUnixDialog", "ProgressBar", "RadioButton", "RadioMenuItem", "Revealer", "Scale", "ScaleButton", "Scrollbar", "ScrolledWindow", "SearchBar", "SearchEntry", "Separator", "SeparatorMenuItem", "ShortcutsWindow", "SpinButton", "Spinner", "Stack", "StackSidebar", "StackSwitcher", "Statusbar", "Switch", "TextView", "ToggleButton", "ToggleToolButton", "ToolButton", "Toolbar", "TreeView", "Video", "Viewport", "VolumeButton", "Window", "ADX", "ADXR", "ALMA", "APO", "ATR", "Accelerator Oscillator", "A/D Line", "Accumulative Swing Index", "Cyber Cycle", "RSI", "Alligator", "Alligator", "Alligator", "VWAP", "Aroon", "Aroon Oscillator", "Aroon", "autocorrelation", "Awesome Oscillator", "Balance of Power", "Bear Power", "Bollinger Bands", "Bollinger Bandwidth", "Bollinger %B", "Bull Power", "CCI", "Pivot Points Camarilla", "CG Oscillator", "Chaikin Money Flow", "Chaikin Oscillator", "Chaikin Volatility", "Forecast Oscillator", "chande_kroll_stop", "CMO", "Chandelier Exit", "Chandelier Exit", "Chandelier Exit", "Ichimoku", "Choppiness Index", "close_volatility", "Connors RSI", "Coppock Curve", "correlation", "correlation_coefficient", "covariance", "cumulative_volume_delta", "RSI", "Cyber Cycle", "DEMA", "DPO", "d_s_s", "DX", "DeMarker", "Decycler", "Demand Index", "DPO", "Disparity Index", "Cyber Cycle", "HT DC Period", "Donchian Channels", "Donchian Channels", "Donchian Channels", "Donchian Channels", "double_stochastic", "Momentum", "EMA", "Ease of Movement", "Efficiency Ratio", "Decycler", "RSI", "Super Smoother", "HT Trendline", "Force Index", "Elder Impulse", "Bear Power", "Bull Power", "elder_safe_zone", "TSI", "even_better_sine_wave", "FAMA", "FRAMA", "Pivot Points Fibonacci", "Fisher Transform", "fractal_dimension", "Polarized Fractal Efficiency", "Williams Fractals", "Williams Fractals", "gann_hi_lo_activator", "gann_swing_oscillator", "Garman-Klass Volatility", "Gator Oscillator", "Gaussian Filter", "gopalakrishnan_range_index", "Guppy MMA", "HMA", "half_trend", "high_low_range", "Historical Volatility", "hurst_exponent", "inertia", "Intraday Intensity", "Momentum", "Fisher Transform", "Jurik MA", "jurik_velocity", "KAMA", "k_d_j", "KST", "kairi", "keltner_bandwidth", "Keltner Channels", "Ichimoku", "Klinger Oscillator", "Kurtosis", "LSMA", "Laguerre Filter", "Laguerre RSI", "TSF", "Linear Regression Angle", "Linear Regression Intercept", "Linear Regression Slope", "TSF", "Linear Regression Intercept", "Forecast Oscillator", "Linear Regression Slope", "MACD", "MACD Histogram", "RSI", "MA Envelope", "MA Envelope", "MAMA", "Mass Index", "McGinley Dynamic", "median_m_a", "Median Price", "Minus DI", "Momentum", "MFI", "money_flow_volume", "moving_average_ribbon", "NATR", "NVI", "ROC", "OBV", "PPO", "Parabolic SAR", "Parkinson Volatility", "percent_rank", "Volume", "percentile_rank", "Pivot Points Standard", "Plus DI", "PVI", "pretty_good_oscillator", "Momentum", "Qstick", "SMMA", "ROC", "ROC", "RSI", "RSI", "R-Squared", "Random Walk Index", "Random Walk Index", "rainbow_oscillator", "range_expansion_index", "reflex", "Linear Regression Channel", "RMI", "Relative Vigor Index", "Relative Volatility Index", "Volume", "Rogers-Satchell Volatility", "Roofing Filter", "SMA", "SMI", "SMMA", "s_s_l_channel", "Schaff Trend Cycle", "Ichimoku", "Ichimoku", "shannon_entropy", "WMA", "HT Sine", "Skewness", "ROC", "spearman_rank", "special_k", "Standard Error", "Pivot Points Standard", "Standard Deviation", "Stochastic RSI", "Stochastic Fast", "Stochastic Full", "stochastic_pop", "Stochastic Slow", "Super Smoother", "Supertrend", "swenlin_trading_oscillator", "Swing Index", "T3", "t_d_sequential", "TEMA", "TRIMA", "TRIX", "TSF", "TSI", "t_s_m_a", "Squeeze Momentum", "Ichimoku", "trend_flex", "Trend Intensity Index", "True Range", "Twiggs Money Flow", "Typical Price", "u_t_bot", "Ulcer Index", "Ultimate Oscillator", "up_down_ratio", "up_down_volume_ratio", "VHF", "VIDYA", "VWAP", "VWAP Bands", "v_w_e_m_a", "VWMA", "Variance", "volatility_ratio", "volatility_stop", "Volume MA", "volume_delta", "Volume Oscillator", "Price Volume Trend", "Volume ROC", "VWMA", "volume_zone_oscillator", "Vortex Indicator", "WMA", "WaveTrend", "Weighted Close", "wilder_volatility_system", "SMMA", "Williams A/D", "Williams %R", "Pivot Points Woodie", "Yang-Zhang Volatility", "ZLEMA", "Z-Score", "MACD", "ZigZag", "AnalogGauge", "BarMeter", "Beacon", "Bezel", "CircuitBreaker", "ControlPanel", "DigitalReadout", "EmergencyStop", "FlowMeter", "HorizontalTankLevel", "KeySwitch", "LampTestButton", "LedBlue", "LedDigits1", "LedDigits2", "LedDigits3", "LedDigits4", "LedDigits5", "LedDigits6", "LedGreen", "LedRed", "LevelColumnGauge", "LevelTransmitter", "Manometer", "Nameplate", "NeedleEdgewise", "NeedleKnifeEdge", "NeedleTapered", "NeedleVu", "OpenChannelLevel", "PanelLampAmber", "PanelLampBlue", "PanelLampGreen", "PanelLampRed", "PanelLampWhite", "PanelPlate", "PressureGauge", "PushButton", "PushButtonLatching", "RgbStatusLed", "RockerSwitch", "RockerSwitchDouble", "RockerSwitchIlluminated", "Rotary", "Seg14Display1", "Seg14Display2", "Seg14Display3", "Seg14Display4", "Seg14Display5", "Seg14Display6", "Seg16Display1", "Seg16Display2", "Seg16Display3", "Seg16Display4", "Seg16Display5", "Seg16Display6", "SightGlassLevel", "SlideSwitch", "SphericalTankLevel", "StackLight", "TankLevelAlarms", "TemperatureGauge", "ToggleSwitch", "ToggleSwitchIlluminated", "VerticalTankLevel", "VuMeter", "AccumulationDistribution", "AreaChart", "Arrow", "BaselineChart", "Brush", "CandlestickChart", "CorrelationView", "Ellipse", "FibExtension", "FibRetracement", "HeikinAshi", "HollowCandles", "HorizontalLine", "IndexedComparison", "LineChart", "MeasureTool", "MoneyFlowChart", "MultiSymbolChart", "OBVChart", "OHLCBarChart", "OverlayChart", "ParallelChannel", "Pitchfork", "Price", "RatioChart", "Rectangle", "RelativePerformance", "Renko", "SectorComparison", "SpreadChart", "TextAnnotation", "Trendline", "VWAP", "VerticalLine", "VolumeBars", "VolumeCandles", "VolumeProfile", "ActionList", "ApplicationProperties", "Arrow", "Bevel", "BitBtn", "Button", "ButtonPanel", "CalcEdit", "CalculatorDialog", "Calendar", "CalendarDialog", "CheckBox", "CheckComboBox", "CheckGroup", "CheckListBox", "ColorBox", "ColorButton", "ColorDialog", "ColorListBox", "ComboBox", "ComboBoxEx", "ControlBar", "CoolBar", "DateEdit", "DateTimePicker", "DirectoryEdit", "DrawGrid", "Edit", "EditButton", "FileListBox", "FileNameEdit", "FilterComboBox", "FindDialog", "FloatSpinEdit", "FlowPanel", "FontDialog", "Form", "Frame", "GroupBox", "HeaderControl", "Image", "ImageList", "Label", "LabeledEdit", "ListBox", "ListView", "MainMenu", "MaskEdit", "Memo", "Notebook", "OpenDialog", "OpenPictureDialog", "PageControl", "PageSetupDialog", "PaintBox", "PairSplitter", "Panel", "PopupMenu", "PopupNotifier", "PrintDialog", "PrinterSetupDialog", "ProgressBar", "RadioButton", "RadioGroup", "ReplaceDialog", "SaveDialog", "SavePictureDialog", "ScrollBar", "ScrollBox", "SelectDirectoryDialog", "Shape", "ShellListView", "ShellTreeView", "SpeedButton", "SpinEdit", "Splitter", "StaticText", "StatusBar", "StringGrid", "TabControl", "TaskDialog", "TimeEdit", "Timer", "ToggleBox", "ToolBar", "TrackBar", "TrayIcon", "TreeView", "UpDown", "ValueListEditor", "XGraph", "XSpreadsheet"))
|
|
|