SLGuiWindow.sleela
lib/gui/version-thual/SLGuiWindow.sleela · 139 line(s) · sleela
<< lib/gui/version-thual/SLGuiWindow.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLGuiWindow — a toolkit-neutral window intent. Mirrors the
SleelaGui contract in gui/: show(title, width, height), setText(text), and
refresh(documentId, revision). SLeeLa describes the window; the backend
(Swing/JavaFX/native) renders it and marshals updates onto the toolkit
thread. >>
#sleela 2.5
material;
< SLeeLa gui front-end contract — a window the host renders. >
< Family: gui. State transitions and the meaning of events stay in SLeeLa; the >
< backend owns presentation and desktop lifecycle. >
class SLGuiWindow {
< ---- 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 = 11423;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-20";
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; }
< Shared chrome colour defaults for every SLeeLa GUI variant. >
static final String TITLE_BAR_BACKGROUND = "#1d2025";
static final String MENU_BAR_BACKGROUND = "#1d2025";
static final String URL_BAR_BACKGROUND = "#383c47";
String title;
int width;
int height;
String text;
< 1 once show() has been requested >
int shown;
< 2.0 window settings (defaults match SLGuiSettings; applySettings adopts a >
< configured SLGuiSettings so a window honors the package's operating knobs). >
int minWidth; int minHeight;
< 0 = unbounded >
int maxWidth; int maxHeight;
int resizable;
int decorated;
void configure(String t, int w, int h) {
title = t; width = w; height = h; text = ""; shown = 0;
minWidth = 320; minHeight = 240; maxWidth = 0; maxHeight = 0;
resizable = 1; decorated = 1;
clampExtent();
}
< Adopt presentation/window settings from a configured SLGuiSettings, then >
< clamp the current extent into the new min/max window. >
void applySettings(SLGuiSettings s) {
if (s == null) { return; }
minWidth = s.getMinWidth(); minHeight = s.getMinHeight();
maxWidth = s.getMaxWidth(); maxHeight = s.getMaxHeight();
resizable = s.resizableOn() ? 1 : 0;
decorated = s.decoratedOn() ? 1 : 0;
clampExtent();
}
< Keep width/height within [min, max] (max 0 = unbounded). >
void clampExtent() {
if (width < minWidth) { width = minWidth; }
if (height < minHeight) { height = minHeight; }
if (maxWidth > 0 && width > maxWidth) { width = maxWidth; }
if (maxHeight > 0 && height > maxHeight) { height = maxHeight; }
}
< Resize request, honored only when the window is resizable, then clamped. >
boolean resize(int w, int h) {
if (resizable == 0) { return false; }
if (w > 0) { width = w; }
if (h > 0) { height = h; }
clampExtent();
return true;
}
< Request the window be shown at its configured size. >
void show() { shown = 1; }
boolean visible() { return shown == 1; }
< A window is valid once it has a title, a positive extent within its bounds, >
< and (when bounded) a max not below its min. >
boolean valid() {
boolean base = title != null && width > 0 && height > 0;
boolean wOk = maxWidth == 0 || maxWidth >= minWidth;
boolean hOk = maxHeight == 0 || maxHeight >= minHeight;
return base && wOk && hOk;
}
String getTitle() { return title; }
int getWidth() { return width; }
int getHeight() { return height; }
int getMinWidth() { return minWidth; }
int getMinHeight() { return minHeight; }
int getMaxWidth() { return maxWidth; }
int getMaxHeight() { return maxHeight; }
boolean resizableOn() { return resizable == 1; }
boolean decoratedOn() { return decorated == 1; }
< Set the window's text (the SleelaGui.setText sink). >
void setText(String value) { text = value; }
String getText() { return text; }
< The document-change refresh sink: SleelaGui.refresh(id, revision). The >
< default publishes a short status line, exactly like the Java default. >
void refresh(String documentId, String revision) {
text = "Document '" + documentId + "' changed (" + revision + ")";
}
}