SLGuiNode.sleela
lib/gui/version-mual/SLGuiNode.sleela · 185 line(s) · sleela
<< lib/gui/version-mual/SLGuiNode.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLGuiNode โ a DHTML-style element node in the /lib/gui
document model. Like a DOM element it has a tag (e.g. "window", "box",
"button", "label", "entry"), a unique id, text content, a parent id, an
ordered list of child ids, a flat attribute map, a flat style map, and a
visibility/enabled state. SLeeLa code (or a script) manipulates the tree
through these โ setAttribute, setStyle, show/hide, enable/disable,
setText โ and the host reflects the node onto a real SleelaUI widget. A node
carries an optional widget handle so a change can be pushed to the live
control, but the node itself is the SLeeLa-owned source of truth.
Family: gui. The DOM is SLeeLa-owned; the host mirrors it onto widgets. >>
#sleela 2.5
material;
class SLGuiNode {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 11244;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-16";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
static final int MAX_CHILDREN = 4096;
< attributes / style entries per node >
static final int MAX_PAIRS = 64;
String id;
String tag;
String textContent;
< "" for the root >
String parentId;
String[] childIds;
int childCount;
< Attribute map (name -> value). >
String[] attrNames;
String[] attrValues;
int attrCount;
< Style map (property -> value), the DHTML inline-style equivalent. >
String[] styleProps;
String[] styleValues;
int styleCount;
< 1 = shown >
int visible;
< 1 = sensitive >
int enabled;
< live SleelaUI widget handle (-1 = not mounted) >
int widget;
< 1 when the host must re-sync this node >
int dirty;
void configure(String nodeId, String nodeTag, String parent) {
id = nodeId; tag = nodeTag; parentId = (parent == null) ? "" : parent;
textContent = "";
childIds = new String[MAX_CHILDREN]; childCount = 0;
attrNames = new String[MAX_PAIRS]; attrValues = new String[MAX_PAIRS]; attrCount = 0;
styleProps = new String[MAX_PAIRS]; styleValues = new String[MAX_PAIRS]; styleCount = 0;
visible = 1; enabled = 1; widget = -1; dirty = 1;
}
String getId() { return id; }
String getTag() { return tag; }
String getParent() { return parentId; }
void setParent(String p) { parentId = (p == null) ? "" : p; }
< ---- children ----------------------------------------------------------- >
boolean appendChild(String childId) {
if (childCount >= MAX_CHILDREN) { return false; }
childIds[childCount] = childId; childCount = childCount + 1;
dirty = 1;
return true;
}
boolean removeChild(String childId) {
for (int i = 0; i < childCount; i = i + 1) {
if (childIds[i] == childId) {
for (int j = i; j < childCount - 1; j = j + 1) { childIds[j] = childIds[j + 1]; }
childCount = childCount - 1;
childIds[childCount] = null;
dirty = 1;
return true;
}
}
return false;
}
int children() { return childCount; }
String childAt(int i) {
if (i < 0 || i >= childCount) { return null; }
return childIds[i];
}
< ---- text --------------------------------------------------------------- >
void setText(String t) { textContent = (t == null) ? "" : t; dirty = 1; }
String text() { return textContent; }
< ---- attributes --------------------------------------------------------- >
void setAttribute(String name, String value) {
int i = attrIndex(name);
if (i >= 0) { attrValues[i] = value; dirty = 1; return; }
if (attrCount >= MAX_PAIRS) { return; }
attrNames[attrCount] = name; attrValues[attrCount] = value;
attrCount = attrCount + 1; dirty = 1;
}
String getAttribute(String name) {
int i = attrIndex(name);
if (i < 0) { return null; }
return attrValues[i];
}
boolean hasAttribute(String name) { return attrIndex(name) >= 0; }
int attrIndex(String name) {
for (int i = 0; i < attrCount; i = i + 1) { if (attrNames[i] == name) { return i; } }
return -1;
}
< ---- style (DHTML inline style) ----------------------------------------- >
void setStyle(String prop, String value) {
int i = styleIndex(prop);
if (i >= 0) { styleValues[i] = value; dirty = 1; return; }
if (styleCount >= MAX_PAIRS) { return; }
styleProps[styleCount] = prop; styleValues[styleCount] = value;
styleCount = styleCount + 1; dirty = 1;
}
String getStyle(String prop) {
int i = styleIndex(prop);
if (i < 0) { return null; }
return styleValues[i];
}
int styleIndex(String prop) {
for (int i = 0; i < styleCount; i = i + 1) { if (styleProps[i] == prop) { return i; } }
return -1;
}
int styleEntries() { return styleCount; }
< ---- visibility / enabled ----------------------------------------------- >
void show() { visible = 1; dirty = 1; }
void hide() { visible = 0; dirty = 1; }
boolean isVisible() { return visible == 1; }
void setEnabled(boolean on) { enabled = on ? 1 : 0; dirty = 1; }
boolean isEnabled() { return enabled == 1; }
< ---- host mount --------------------------------------------------------- >
void mount(int widgetHandle) { widget = widgetHandle; dirty = 1; }
int widgetHandle() { return widget; }
boolean mounted() { return widget >= 0; }
boolean isDirty() { return dirty == 1; }
void clearDirty() { dirty = 0; }
}