Phase 2 per-widget props (Rust): Inspector tables for Button/Entry/Label/CheckBox/RadioButton/ComboBox/ListBox/ScrollBar/Scale/TrackBar/Text/Memo + CheckListBox; live-apply in canvas apply_prop (kind syncs label/modal-result, active syncs ComboBox text, integral-height snap, scale marks from tick-marks/frequency); generator emits all new setters incl. radio_group vectors, CheckListBox branch, scale marks; trait set_orientation_vertical; ListSel text() returns selected row; gen prop_int matches C++ stoi (default on no numeric prefix)

This commit is contained in:
cnmcdee committed 2026-11-30 10:56:07 +00:00
1 parent f4f060416c
commit d3be0782df
5 files changed
+1490 -4

No files matched your search

+617 -3
View File
@@ -43,6 +43,13 @@ pub const ORIENTATION_VALUES: &[i32] = &[0, 1]; // HORIZONTAL, VERTICAL
pub const TOOLBAR_STYLE_VALUES: &[i32] = &[0, 1, 2, 3]; // ICONS, TEXT, BOTH, BOTH_HORIZ
pub const SHAPE_VALUES: &[i32] = &[0, 1, 2, 3]; // RECTANGLE, ELLIPSE, LINE, TRIANGLE
pub const ALIGN_VALUES: &[i32] = &[0, 1, 2, 3, 4, 5]; // NONE, TOP, BOTTOM, LEFT, RIGHT, CLIENT
pub const BUTTON_KIND_VALUES: &[i32] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; // NONE, OK, CANCEL, ABORT, RETRY, IGNORE, YES, NO, CLOSE, HELP
pub const BUTTON_LAYOUT_VALUES: &[i32] = &[0, 1, 2, 3]; // LEFT, RIGHT, TOP, BOTTOM
pub const TEXT_ALIGN_VALUES: &[i32] = &[0, 1, 2]; // LEFT, CENTER, RIGHT
pub const CHAR_CASE_VALUES: &[i32] = &[0, 1, 2]; // NORMAL, UPPER, LOWER
pub const COMBO_STYLE_VALUES: &[i32] = &[0, 1, 2]; // DROPDOWN, SIMPLE, DROPDOWNLIST
pub const TICK_MARKS_VALUES: &[i32] = &[0, 1, 2, 3]; // NONE, TOPLEFT, BOTTOMRIGHT, BOTH
pub const SCROLL_BARS_VALUES: &[i32] = &[0, 1, 2, 3]; // NONE, HORIZONTAL, VERTICAL, BOTH
use PropKind as K;
@@ -423,6 +430,60 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "default",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "cancel",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "kind",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("None|OK|Cancel|Yes|No|Close|Help|Retry|Ignore|Abort"),
enum_values: Some(BUTTON_KIND_VALUES),
},
PropDef {
name: "modal-result",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 100.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "layout",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Left|Right|Top|Bottom"),
enum_values: Some(BUTTON_LAYOUT_VALUES),
},
PropDef {
name: "glyph",
kind: K::Str,
def: "",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Label" => &[
PropDef {
@@ -461,6 +522,42 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "yalign",
kind: K::Double,
def: "0.5",
lo: 0.0,
hi: 1.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "transparent",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "show-accel-char",
kind: K::Bool,
def: "true",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "focus-control",
kind: K::Str,
def: "",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Entry" => &[
PropDef {
@@ -526,6 +623,51 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "alignment",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Left|Center|Right"),
enum_values: Some(TEXT_ALIGN_VALUES),
},
PropDef {
name: "char-case",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Normal|Upper|Lower"),
enum_values: Some(CHAR_CASE_VALUES),
},
PropDef {
name: "numbers-only",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "hide-selection",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "auto-select",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Checkbutton" => &[
PropDef {
@@ -555,6 +697,42 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "allow-grayed",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "alignment",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Left|Right"),
enum_values: Some(ORIENTATION_VALUES),
},
PropDef {
name: "value-checked",
kind: K::Str,
def: "",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "value-unchecked",
kind: K::Str,
def: "",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Radiobutton" => &[
PropDef {
@@ -575,6 +753,15 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "group",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 100.0,
enum_labels: None,
enum_values: None,
},
],
"Frame" => &[
PropDef {
@@ -614,7 +801,89 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
hi: 1000.0,
enum_labels: None,
enum_values: None,
}],
},
PropDef {
name: "text",
kind: K::Str,
def: "",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "style",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("DropDown|Simple|DropDownList"),
enum_values: Some(COMBO_STYLE_VALUES),
},
PropDef {
name: "drop-down-count",
kind: K::Int,
def: "8",
lo: 1.0,
hi: 100.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "drop-down-width",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 10000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sorted",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "read-only",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "max-length",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "auto-complete",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "char-case",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Normal|Upper|Lower"),
enum_values: Some(CHAR_CASE_VALUES),
},
],
"Listbox" => &[
PropDef {
name: "items",
@@ -633,7 +902,53 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
hi: 0.0,
enum_labels: Some("None|Single|Browse|Multiple"),
enum_values: Some(SEL_MODE_VALUES),
}],
},
PropDef {
name: "item-index",
kind: K::Int,
def: "-1",
lo: -1.0,
hi: 10000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sorted",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "columns",
kind: K::Int,
def: "1",
lo: 1.0,
hi: 100.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "item-height",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 1000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "integral-height",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Menubutton" => &[
PropDef {
name: "label",
@@ -654,6 +969,53 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_values: Some(ARROW_VALUES),
},
],
"CheckListBox" => &[
PropDef {
name: "items",
kind: K::Str,
def: "Item 1|Item 2|Item 3",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "checked-items",
kind: K::Str,
def: "",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "item-index",
kind: K::Int,
def: "-1",
lo: -1.0,
hi: 10000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "item-height",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 1000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sorted",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Scale" => &[
PropDef {
name: "value",
@@ -691,6 +1053,78 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "minimum",
kind: K::Double,
def: "0",
lo: -100000.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "maximum",
kind: K::Double,
def: "100",
lo: -100000.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "page-step",
kind: K::Double,
def: "10",
lo: 0.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "tick-marks",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("None|TopLeft|BottomRight|Both"),
enum_values: Some(TICK_MARKS_VALUES),
},
PropDef {
name: "frequency",
kind: K::Int,
def: "10",
lo: 0.0,
hi: 10000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "show-sel-range",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sel-start",
kind: K::Double,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sel-end",
kind: K::Double,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"Scrollbar" => &[
PropDef {
@@ -756,6 +1190,24 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: None,
enum_values: None,
},
PropDef {
name: "orientation",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Horizontal|Vertical"),
enum_values: Some(ORIENTATION_VALUES),
},
PropDef {
name: "large-change",
kind: K::Double,
def: "10",
lo: 0.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
],
"Text" => &[
PropDef {
@@ -794,6 +1246,60 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: Some("None|Char|Word|Word-char"),
enum_values: Some(WRAP_VALUES),
},
PropDef {
name: "max-length",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "scroll-bars",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("None|Horizontal|Vertical|Both"),
enum_values: Some(SCROLL_BARS_VALUES),
},
PropDef {
name: "want-tabs",
kind: K::Bool,
def: "true",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "want-returns",
kind: K::Bool,
def: "true",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "hide-selection",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "alignment",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Left|Center|Right"),
enum_values: Some(TEXT_ALIGN_VALUES),
},
],
"Memo" => &[
PropDef {
@@ -832,6 +1338,60 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: Some("None|Char|Word|Word-char"),
enum_values: Some(WRAP_VALUES),
},
PropDef {
name: "max-length",
kind: K::Int,
def: "0",
lo: 0.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "scroll-bars",
kind: K::Enum,
def: "3",
lo: 0.0,
hi: 0.0,
enum_labels: Some("None|Horizontal|Vertical|Both"),
enum_values: Some(SCROLL_BARS_VALUES),
},
PropDef {
name: "want-tabs",
kind: K::Bool,
def: "true",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "want-returns",
kind: K::Bool,
def: "true",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "hide-selection",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "alignment",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("Left|Center|Right"),
enum_values: Some(TEXT_ALIGN_VALUES),
},
],
"GroupBox" => &[
PropDef {
@@ -1138,6 +1698,60 @@ pub fn props_for(widget_type: &str) -> &'static [PropDef] {
enum_labels: Some("Horizontal|Vertical"),
enum_values: Some(ORIENTATION_VALUES),
},
PropDef {
name: "page-step",
kind: K::Double,
def: "10",
lo: 0.0,
hi: 100000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "tick-marks",
kind: K::Enum,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: Some("None|TopLeft|BottomRight|Both"),
enum_values: Some(TICK_MARKS_VALUES),
},
PropDef {
name: "frequency",
kind: K::Int,
def: "10",
lo: 0.0,
hi: 10000.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "show-sel-range",
kind: K::Bool,
def: "false",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sel-start",
kind: K::Double,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
PropDef {
name: "sel-end",
kind: K::Double,
def: "0",
lo: 0.0,
hi: 0.0,
enum_labels: None,
enum_values: None,
},
],
"ProgressBar" => &[
PropDef {
@@ -1491,7 +2105,7 @@ mod tests {
#[test]
fn spot_tables() {
assert_eq!(props_for("Button").len(), 3);
assert_eq!(props_for("Button").len(), 9);
assert_eq!(props_for("SpinEdit").len(), 7);
assert_eq!(props_for("StockChart").len(), 8);
let xalign = find_prop("Label", "xalign").unwrap();
+464
View File
@@ -1355,6 +1355,45 @@ fn refresh_item_style(app: &Shared, id: u64) {
/// Apply one validated property value to the live widget. Properties
/// with no live effect (layout-only, or consumed by the generator)
/// stay model-only — the generator still emits them.
/// Recompute a Scale/TrackBar's tick marks from the model
/// (tick-marks mode, frequency, minimum, maximum) and push them
/// through set_marks. Mirrors C++ refresh_scale_marks.
fn refresh_range_marks(app: &Shared, id: u64) {
let mut a = app.borrow_mut();
let Some(i) = a.find_index(id) else {
return;
};
let props = &a.items[i].model.props;
let mode: i32 = props
.get("tick-marks")
.and_then(|v| v.parse().ok())
.unwrap_or(0);
let freq: i32 = props
.get("frequency")
.and_then(|v| v.parse().ok())
.unwrap_or(10);
let mn: f64 = props
.get("minimum")
.and_then(|v| v.parse().ok())
.unwrap_or(0.0);
let mx: f64 = props
.get("maximum")
.and_then(|v| v.parse().ok())
.unwrap_or(100.0);
let mut marks: Vec<f64> = Vec::new();
if mode != 0 && freq > 0 && mx > mn {
let mut v = mn;
while v <= mx {
marks.push(v);
v += freq as f64;
}
if marks.is_empty() || marks[marks.len() - 1] != mx {
marks.push(mx);
}
}
a.items[i].wdg.set_marks(&marks);
}
pub fn apply_prop(app: &Shared, id: u64, name: &str, value: &str) {
if name == "background"
|| name == "foreground"
@@ -1432,6 +1471,8 @@ pub fn apply_prop(app: &Shared, id: u64, name: &str, value: &str) {
if let Ok(idx) = value.parse::<i32>() {
if idx >= 0 {
a.items[i].wdg.select(idx as usize);
let text = a.items[i].wdg.text().to_string();
a.items[i].model.props.insert("text".to_string(), text);
}
}
} else {
@@ -1573,6 +1614,429 @@ pub fn apply_prop(app: &Shared, id: u64, name: &str, value: &str) {
}
return;
}
if name == "default" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_default(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "cancel" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_cancel(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "kind" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_kind(v);
// Keep the model label + modal-result in sync with the
// kind (Button set_kind applies the kind's caption).
let text = a.items[i].wdg.text().to_string();
a.items[i].model.props.insert("label".to_string(), text);
let results = [0, 1, 2, 6, 7, 8, 9, 4, 5, 3];
if (1..=9).contains(&v) {
a.items[i]
.model
.props
.insert("modal-result".to_string(), results[v as usize].to_string());
}
}
drop(a);
redraw_canvas(app);
return;
}
if name == "modal-result" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_modal_result(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "layout" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_layout(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "yalign" {
let v = value.parse::<f64>().unwrap_or(0.5);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_yalign(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "transparent" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_transparent(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "show-accel-char" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_show_accel_char(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "alignment" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_alignment(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "char-case" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_char_case(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "numbers-only" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_numbers_only(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "hide-selection" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_hide_selection(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "auto-select" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_auto_select(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "allow-grayed" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_allow_grayed(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "value-checked" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_value_checked(value);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "value-unchecked" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_value_unchecked(value);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "group" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_group_id(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "style" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_style(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "drop-down-count" {
let v = value.parse::<i32>().unwrap_or(8);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_drop_down_count(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "drop-down-width" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_drop_down_width(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "sorted" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_sorted(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "read-only" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_read_only(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "max-length" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_max_length(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "auto-complete" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_auto_complete(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "item-index" {
let v = value.parse::<i32>().unwrap_or(-1);
if v >= 0 {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_selected_row(v);
}
drop(a);
redraw_canvas(app);
}
return;
}
if name == "item-height" {
let v = value.parse::<i32>().unwrap_or(0);
if v > 0 {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_row_height(v);
}
drop(a);
redraw_canvas(app);
}
return;
}
if name == "integral-height" {
if value == "true" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
let ih: i32 = a.items[i]
.model
.props
.get("item-height")
.and_then(|v| v.parse().ok())
.unwrap_or(0);
let kind =
lightgui_core::class_kind(&a.items[i].model.widget_type).unwrap_or("");
let rh = if ih > 0 {
ih
} else if kind == "CheckListBox" {
18
} else {
24
};
let h = a.items[i].model.height;
let rows = ((h - 4) / rh).max(1);
let nh = rows * rh + 4;
let (x, y, w) = (
a.items[i].model.x,
a.items[i].model.y,
a.items[i].model.width,
);
a.items[i].model.height = nh;
a.items[i].wdg.set_bounds(x, y, w, nh);
write_state(&a);
}
drop(a);
}
redraw_canvas(app);
return;
}
if name == "minimum" || name == "maximum" {
let v = value.parse::<f64>().unwrap_or(0.0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
let (mn, mx) = (a.items[i].wdg.min(), a.items[i].wdg.max());
if name == "minimum" {
a.items[i].wdg.set_range(v, mx);
} else {
a.items[i].wdg.set_range(mn, v);
}
}
drop(a);
refresh_range_marks(app, id);
redraw_canvas(app);
return;
}
if name == "page-step" {
let v = value.parse::<f64>().unwrap_or(10.0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_page_step(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "tick-marks" || name == "frequency" {
refresh_range_marks(app, id);
redraw_canvas(app);
return;
}
if name == "show-sel-range" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_show_sel_range(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "sel-start" {
let v = value.parse::<f64>().unwrap_or(0.0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_sel_start(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "sel-end" {
let v = value.parse::<f64>().unwrap_or(0.0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_sel_end(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "orientation" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_orientation_vertical(value != "0");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "large-change" {
let v = value.parse::<f64>().unwrap_or(10.0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_page_increment(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "scroll-bars" {
let v = value.parse::<i32>().unwrap_or(0);
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_scroll_bars(v);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "want-tabs" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_want_tabs(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "want-returns" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_want_returns(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
if name == "checked-items" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_checked_items(value);
}
drop(a);
redraw_canvas(app);
return;
}
if name == "inconsistent" {
let mut a = app.borrow_mut();
if let Some(i) = a.find_index(id) {
a.items[i].wdg.set_inconsistent(value == "true");
}
drop(a);
redraw_canvas(app);
return;
}
// StockChart data-file, Shape/Plot draw params, anchors, align,
// tab order, cursor, tag, margins, hints and font underline /
// strikeout are model-only at design time; the generator emits
+393 -1
View File
@@ -99,7 +99,19 @@ fn prop_bool(w: &Widget, name: &str, dflt: bool) -> bool {
fn prop_int(w: &Widget, name: &str, dflt: i32) -> i32 {
match w.props.get(name) {
None => dflt,
Some(v) => atoi_c(v),
// std::stoi semantics (the C++ side): a value with no numeric
// prefix throws and the caller gets dflt. atoi_c would return
// 0 for such a value (e.g. ListView columns "Name|Value"),
// which wrongly emits a `columns=0` model-only note.
Some(v) => {
let t = v.trim_start();
let digits = t.strip_prefix(['+', '-']).unwrap_or(t);
if digits.chars().next().is_some_and(|c| c.is_ascii_digit()) {
atoi_c(v)
} else {
dflt
}
}
}
}
@@ -363,6 +375,14 @@ static K_XFRAME_MAP: &[XFrameMap] = &[
fill_srgb: false,
text_srgb: false,
},
XFrameMap {
key: "CheckListBox",
cls: "TCheckListBox",
fill: "",
text: "",
fill_srgb: false,
text_srgb: false,
},
XFrameMap {
key: "Menubutton",
cls: "GtkMenuButton",
@@ -797,6 +817,29 @@ fn tree_node_expr(segs: &[String], i: usize) -> String {
o
}
// Emit set_marks({v, v, ...}) for a Scale/TrackBar from tick-marks +
// frequency over [mn, mx] (mirrors refresh_range_marks in the canvas).
fn emit_scale_marks(o: &mut String, w: &Widget, var: &str, mn: f64, mx: f64) {
if prop_int(w, "tick-marks", 0) == 0 {
return;
}
let freq = prop_int(w, "frequency", 10);
if freq <= 0 || mx <= mn {
return;
}
let mut marks: Vec<f64> = Vec::new();
let mut v = mn;
while v <= mx {
marks.push(v);
v += freq as f64;
}
if marks.is_empty() || marks[marks.len() - 1] != mx {
marks.push(mx);
}
let lit: Vec<String> = marks.iter().map(|v| fmt_double(&v.to_string())).collect();
o.push_str(&format!(" {var}.w.set_marks({{{}}});\n", lit.join(", ")));
}
fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind: &str) {
let t = kind;
let has = |n: &str| w.props.get(n).is_some_and(|v| !v.is_empty());
@@ -862,6 +905,44 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
}
));
}
if w.props.contains_key("transparent") {
o.push_str(&format!(
" {var}.w.set_transparent({});\n",
if prop_bool(w, "transparent", false) {
"true"
} else {
"false"
}
));
}
if w.props.contains_key("show-accel-char") && !prop_bool(w, "show-accel-char", true) {
o.push_str(&format!(" {var}.w.set_show_accel_char(false);\n"));
}
} else if t == "Button" {
if prop_bool(w, "default", false) {
o.push_str(&format!(" {var}.w.set_default(true);\n"));
}
if prop_bool(w, "cancel", false) {
o.push_str(&format!(" {var}.w.set_cancel(true);\n"));
}
if w.props.contains_key("kind") && prop_int(w, "kind", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_kind({});\n",
prop_int(w, "kind", 0)
));
}
if w.props.contains_key("modal-result") && prop_int(w, "modal-result", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_modal_result({});\n",
prop_int(w, "modal-result", 0)
));
}
if w.props.contains_key("layout") && prop_int(w, "layout", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_layout({});\n",
prop_int(w, "layout", 0)
));
}
} else if t == "Entry" {
if has("placeholder-text") {
o.push_str(&format!(
@@ -898,7 +979,31 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
if prop_bool(w, "show-password", false) {
o.push_str(&format!(" {var}.w.set_show_password(true);\n"));
}
if w.props.contains_key("alignment") && prop_int(w, "alignment", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_alignment({});\n",
prop_int(w, "alignment", 0)
));
}
if w.props.contains_key("char-case") && prop_int(w, "char-case", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_char_case({});\n",
prop_int(w, "char-case", 0)
));
}
if prop_bool(w, "numbers-only", false) {
o.push_str(&format!(" {var}.w.set_numbers_only(true);\n"));
}
if prop_bool(w, "hide-selection", false) {
o.push_str(&format!(" {var}.w.set_hide_selection(true);\n"));
}
if prop_bool(w, "auto-select", false) {
o.push_str(&format!(" {var}.w.set_auto_select(true);\n"));
}
} else if t == "Checkbutton" {
if prop_bool(w, "allow-grayed", false) {
o.push_str(&format!(" {var}.w.set_allow_grayed(true);\n"));
}
if w.props.contains_key("active") {
o.push_str(&format!(
" {var}.w.set_active({});\n",
@@ -919,7 +1024,27 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
}
));
}
if w.props.contains_key("alignment") && prop_int(w, "alignment", 0) != 0 {
o.push_str(&format!(" {var}.w.set_alignment(1);\n"));
}
if has("value-checked") {
o.push_str(&format!(
" {var}.w.set_value_checked(\"{}\");\n",
esc_c(&prop_or(w, "value-checked", ""))
));
}
if has("value-unchecked") {
o.push_str(&format!(
" {var}.w.set_value_unchecked(\"{}\");\n",
esc_c(&prop_or(w, "value-unchecked", ""))
));
}
} else if t == "Radiobutton" {
let grp = prop_int(w, "group", 0);
if grp != 0 {
o.push_str(&format!(" {var}.w.set_group_id({grp});\n"));
o.push_str(&format!(" {var}.w.set_group(&radio_group_{grp});\n"));
}
if w.props.contains_key("active") {
o.push_str(&format!(
" {var}.w.set_active({});\n",
@@ -942,6 +1067,45 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
prop_int(w, "active", 0)
));
}
if w.props.contains_key("style") && prop_int(w, "style", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_style({});\n",
prop_int(w, "style", 0)
));
}
if w.props.contains_key("drop-down-count") && prop_int(w, "drop-down-count", 8) != 8 {
o.push_str(&format!(
" {var}.w.set_drop_down_count({});\n",
prop_int(w, "drop-down-count", 8)
));
}
if w.props.contains_key("drop-down-width") && prop_int(w, "drop-down-width", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_drop_down_width({});\n",
prop_int(w, "drop-down-width", 0)
));
}
if prop_bool(w, "sorted", false) {
o.push_str(&format!(" {var}.w.set_sorted(true);\n"));
}
if prop_bool(w, "read-only", false) {
o.push_str(&format!(" {var}.w.set_read_only(true);\n"));
}
if w.props.contains_key("max-length") && prop_int(w, "max-length", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_max_length({});\n",
prop_int(w, "max-length", 0)
));
}
if prop_bool(w, "auto-complete", false) {
o.push_str(&format!(" {var}.w.set_auto_complete(true);\n"));
}
if w.props.contains_key("char-case") && prop_int(w, "char-case", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_char_case({});\n",
prop_int(w, "char-case", 0)
));
}
} else if t == "Listbox" {
if has("items") {
for item in split_on('|', &prop_or(w, "items", "")) {
@@ -951,6 +1115,48 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
if w.props.contains_key("selection-mode") && prop_int(w, "selection-mode", 1) == 3 {
o.push_str(&format!(" {var}.w.set_multi_select(true);\n"));
}
if w.props.contains_key("item-index") && prop_int(w, "item-index", -1) >= 0 {
o.push_str(&format!(
" {var}.w.set_selected_row({});\n",
prop_int(w, "item-index", -1)
));
}
if prop_bool(w, "sorted", false) {
o.push_str(&format!(" {var}.w.set_sorted(true);\n"));
}
if w.props.contains_key("item-height") && prop_int(w, "item-height", 0) > 0 {
o.push_str(&format!(
" {var}.w.set_row_height({});\n",
prop_int(w, "item-height", 0)
));
}
} else if t == "CheckListBox" {
if has("items") {
for item in split_on('|', &prop_or(w, "items", "")) {
o.push_str(&format!(" {var}.w.add_item(\"{}\");\n", esc_c(&item)));
}
}
if prop_bool(w, "sorted", false) {
o.push_str(&format!(" {var}.w.set_sorted(true);\n"));
}
if has("checked-items") {
o.push_str(&format!(
" {var}.w.set_checked_items(\"{}\");\n",
esc_c(&prop_or(w, "checked-items", ""))
));
}
if w.props.contains_key("item-index") && prop_int(w, "item-index", -1) >= 0 {
o.push_str(&format!(
" {var}.w.set_selected_row({});\n",
prop_int(w, "item-index", -1)
));
}
if w.props.contains_key("item-height") && prop_int(w, "item-height", 0) > 0 {
o.push_str(&format!(
" {var}.w.set_row_height({});\n",
prop_int(w, "item-height", 0)
));
}
} else if t == "Menubutton" {
if w.props.contains_key("direction") && prop_int(w, "direction", 1) != 1 {
o.push_str(&format!(
@@ -959,6 +1165,13 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
));
}
} else if t == "Scale" {
if w.props.contains_key("minimum") || w.props.contains_key("maximum") {
o.push_str(&format!(
" {var}.w.set_range({}, {});\n",
fmt_double(&prop_or(w, "minimum", "0")),
fmt_double(&prop_or(w, "maximum", "100"))
));
}
if w.props.contains_key("value") {
o.push_str(&format!(
" {var}.w.set_value({});\n",
@@ -975,6 +1188,40 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
}
));
}
if w.props.contains_key("page-step")
&& prop_or(w, "page-step", "10").parse::<f64>().unwrap_or(10.0) != 10.0
{
o.push_str(&format!(
" {var}.w.set_page_step({});\n",
fmt_double(&prop_or(w, "page-step", "10"))
));
}
emit_scale_marks(
o,
w,
var,
prop_or(w, "minimum", "0").parse::<f64>().unwrap_or(0.0),
prop_or(w, "maximum", "100").parse::<f64>().unwrap_or(100.0),
);
if prop_bool(w, "show-sel-range", false) {
o.push_str(&format!(" {var}.w.set_show_sel_range(true);\n"));
}
if w.props.contains_key("sel-start")
&& prop_or(w, "sel-start", "0").parse::<f64>().unwrap_or(0.0) != 0.0
{
o.push_str(&format!(
" {var}.w.set_sel_start({});\n",
fmt_double(&prop_or(w, "sel-start", "0"))
));
}
if w.props.contains_key("sel-end")
&& prop_or(w, "sel-end", "0").parse::<f64>().unwrap_or(0.0) != 0.0
{
o.push_str(&format!(
" {var}.w.set_sel_end({});\n",
fmt_double(&prop_or(w, "sel-end", "0"))
));
}
} else if t == "Scrollbar" {
if w.props.contains_key("lower")
&& prop_or(w, "lower", "0").parse::<f64>().unwrap_or(0.0) != 0.0
@@ -1016,6 +1263,17 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
fmt_double(&prop_or(w, "value", "0"))
));
}
if w.props.contains_key("orientation") && prop_int(w, "orientation", 0) != 0 {
o.push_str(&format!(" {var}.w.set_orientation_vertical(true);\n"));
}
if w.props.contains_key("large-change")
&& prop_or(w, "large-change", "10").parse::<f64>().unwrap_or(10.0) != 10.0
{
o.push_str(&format!(
" {var}.w.set_page_increment({});\n",
fmt_double(&prop_or(w, "large-change", "10"))
));
}
} else if t == "Text" {
if w.props.contains_key("editable") {
o.push_str(&format!(
@@ -1040,7 +1298,74 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
if w.props.contains_key("cursor-visible") && !prop_bool(w, "cursor-visible", true) {
o.push_str(&format!(" {var}.w.set_cursor_visible(false);\n"));
}
if w.props.contains_key("max-length") && prop_int(w, "max-length", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_max_length({});\n",
prop_int(w, "max-length", 0)
));
}
if w.props.contains_key("scroll-bars") && prop_int(w, "scroll-bars", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_scroll_bars({});\n",
prop_int(w, "scroll-bars", 0)
));
}
if w.props.contains_key("want-tabs") && !prop_bool(w, "want-tabs", true) {
o.push_str(&format!(" {var}.w.set_want_tabs(false);\n"));
}
if w.props.contains_key("want-returns") && !prop_bool(w, "want-returns", true) {
o.push_str(&format!(" {var}.w.set_want_returns(false);\n"));
}
if prop_bool(w, "hide-selection", false) {
o.push_str(&format!(" {var}.w.set_hide_selection(true);\n"));
}
if w.props.contains_key("alignment") && prop_int(w, "alignment", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_alignment({});\n",
prop_int(w, "alignment", 0)
));
}
} else if t == "Memo" {
if w.props.contains_key("editable") {
o.push_str(&format!(
" {var}.w.set_editable({});\n",
if prop_bool(w, "editable", true) {
"true"
} else {
"false"
}
));
}
if w.props.contains_key("cursor-visible") && !prop_bool(w, "cursor-visible", true) {
o.push_str(&format!(" {var}.w.set_cursor_visible(false);\n"));
}
if w.props.contains_key("max-length") && prop_int(w, "max-length", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_max_length({});\n",
prop_int(w, "max-length", 0)
));
}
if w.props.contains_key("scroll-bars") && prop_int(w, "scroll-bars", 3) != 3 {
o.push_str(&format!(
" {var}.w.set_scroll_bars({});\n",
prop_int(w, "scroll-bars", 3)
));
}
if w.props.contains_key("want-tabs") && !prop_bool(w, "want-tabs", true) {
o.push_str(&format!(" {var}.w.set_want_tabs(false);\n"));
}
if w.props.contains_key("want-returns") && !prop_bool(w, "want-returns", true) {
o.push_str(&format!(" {var}.w.set_want_returns(false);\n"));
}
if prop_bool(w, "hide-selection", false) {
o.push_str(&format!(" {var}.w.set_hide_selection(true);\n"));
}
if w.props.contains_key("alignment") && prop_int(w, "alignment", 0) != 0 {
o.push_str(&format!(
" {var}.w.set_alignment({});\n",
prop_int(w, "alignment", 0)
));
}
if w.props.contains_key("wrap-mode") {
o.push_str(&format!(
" {var}.w.set_wordwrap({});\n",
@@ -1182,6 +1507,40 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
}
));
}
if w.props.contains_key("page-step")
&& prop_or(w, "page-step", "10").parse::<f64>().unwrap_or(10.0) != 10.0
{
o.push_str(&format!(
" {var}.w.set_page_step({});\n",
fmt_double(&prop_or(w, "page-step", "10"))
));
}
emit_scale_marks(
o,
w,
var,
prop_int(w, "minimum", 0) as f64,
prop_int(w, "maximum", 100) as f64,
);
if prop_bool(w, "show-sel-range", false) {
o.push_str(&format!(" {var}.w.set_show_sel_range(true);\n"));
}
if w.props.contains_key("sel-start")
&& prop_or(w, "sel-start", "0").parse::<f64>().unwrap_or(0.0) != 0.0
{
o.push_str(&format!(
" {var}.w.set_sel_start({});\n",
fmt_double(&prop_or(w, "sel-start", "0"))
));
}
if w.props.contains_key("sel-end")
&& prop_or(w, "sel-end", "0").parse::<f64>().unwrap_or(0.0) != 0.0
{
o.push_str(&format!(
" {var}.w.set_sel_end({});\n",
fmt_double(&prop_or(w, "sel-end", "0"))
));
}
} else if t == "ProgressBar" {
if w.props.contains_key("fraction") {
o.push_str(&format!(
@@ -1432,6 +1791,21 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
if prop_bool(w, "font-strikeout", false) {
notes.push("font-strikeout=true".to_string());
}
if has("glyph") {
notes.push(format!("glyph=\"{}\"", esc_c(&prop_or(w, "glyph", ""))));
}
if has("focus-control") {
notes.push(format!(
"focus-control=\"{}\"",
esc_c(&prop_or(w, "focus-control", ""))
));
}
if w.props.contains_key("columns") && prop_int(w, "columns", 1) != 1 {
notes.push(format!("columns={}", prop_int(w, "columns", 1)));
}
if prop_bool(w, "integral-height", false) {
notes.push("integral-height=true".to_string());
}
if !notes.is_empty() {
o.push_str(&format!(
" // NOTE (model-only, no XFrame setter): {}\n",
@@ -2014,6 +2388,24 @@ fn emit_main_cpp(project: &Project, widgets: &[Widget]) -> String {
o.push_str(" };\n");
}
// RadioButton groups (Phase 2): one shared vector per group id;
// each button in the group calls set_group on it, so turning one
// on turns the others off (GtkRadioButton::set_active).
{
let mut groups: Vec<i32> = Vec::new();
for r in &resolved {
if r.kind == "Radiobutton" {
let g = prop_int(r.w, "group", 0);
if g != 0 && !groups.contains(&g) {
groups.push(g);
}
}
}
for g in &groups {
o.push_str(&format!(" std::vector<GtkRadioButton*> radio_group_{g};\n"));
}
}
// Widgets, in design order (later = on top for event dispatch).
for r in &resolved {
let w = r.w;
+15
View File
@@ -997,6 +997,9 @@ archetype_impl!(RangeWidget, Archetype::Range,
fn set_page_step(&mut self, v: f64) {
self.page_step = v;
}
fn set_orientation_vertical(&mut self, v: bool) {
self.set_orientation(if v { "vertical" } else { "horizontal" });
}
fn set_marks(&mut self, v: &[f64]) {
self.marks = v.to_vec();
}
@@ -1322,6 +1325,18 @@ archetype_impl!(ListSelWidget, Archetype::ListSel,
fn selected(&self) -> Option<usize> {
self.selected
}
// A ComboBox's text is its selected row's text (the widget has no
// text editing); a ListBox/CheckListBox keeps the stored text.
fn text(&self) -> &str {
if self.is_combo() {
match self.selected {
Some(i) => &self.items[i],
None => "",
}
} else {
&self.state.text
}
}
fn select(&mut self, i: usize) {
if i < self.items.len() {
self.selected = Some(i);
+1
View File
@@ -239,6 +239,7 @@ pub trait Widget {
fn set_selected_row(&mut self, _v: i32) {}
fn set_row_height(&mut self, _v: i32) {}
fn set_page_step(&mut self, _v: f64) {}
fn set_orientation_vertical(&mut self, _v: bool) {}
fn set_marks(&mut self, _v: &[f64]) {}
fn set_show_sel_range(&mut self, _v: bool) {}
fn set_sel_start(&mut self, _v: f64) {}