diff --git a/crates/lightgui-designer/src/selftest.rs b/crates/lightgui-designer/src/selftest.rs index 8274c02..b07a5cf 100644 --- a/crates/lightgui-designer/src/selftest.rs +++ b/crates/lightgui-designer/src/selftest.rs @@ -22,7 +22,9 @@ use crate::canvas::{ use crate::palette_ui::palette_write_dump; use crate::state::Shared; use gtk::prelude::*; -use lightgui_core::{load_from_str, load_project_file, save_project_file, save_to_string}; +use lightgui_core::{ + load_from_str, load_project_file, save_project_file, save_to_string, set_widget_signal, +}; use std::io::Write; /// `LIGHTGUI_SELFTEST=1` step. Runs once from the idle loop, after the @@ -107,6 +109,379 @@ pub fn selftest_step(app: &Shared) { } } + // Phase 2 (§2.1–§2.10 + CheckListBox): per-widget custom props, + // live on the widget through the same set_prop the Inspector uses, + // plus generator emission of the new setters and event stubs. + { + // Read helpers: widget state / model storage for one id. + let wtext = |id: u64| -> String { + let a = app.borrow(); + a.find_index(id) + .map(|i| a.items[i].wdg.text().to_string()) + .unwrap_or_default() + }; + let wval = |id: u64| -> f64 { + let a = app.borrow(); + a.find_index(id).map(|i| a.items[i].wdg.value()).unwrap_or(-1.0) + }; + let wmin = |id: u64| -> f64 { + let a = app.borrow(); + a.find_index(id).map(|i| a.items[i].wdg.min()).unwrap_or(-1.0) + }; + let wmax = |id: u64| -> f64 { + let a = app.borrow(); + a.find_index(id).map(|i| a.items[i].wdg.max()).unwrap_or(-1.0) + }; + let wchecked = |id: u64| -> bool { + let a = app.borrow(); + a.find_index(id) + .map(|i| a.items[i].wdg.checked()) + .unwrap_or(false) + }; + let witems = |id: u64| -> Vec { + let a = app.borrow(); + a.find_index(id) + .map(|i| a.items[i].wdg.items().to_vec()) + .unwrap_or_default() + }; + let wsel = |id: u64| -> Option { + let a = app.borrow(); + a.find_index(id).and_then(|i| a.items[i].wdg.selected()) + }; + let mprop = |id: u64, name: &str| -> Option { + let a = app.borrow(); + a.find_index(id) + .and_then(|i| a.items[i].model.props.get(name).cloned()) + }; + + // Button (§2.1): kind applies caption + modal result. + check(set_prop(app, btn_id, "kind", "1").is_ok(), "Button kind set"); + check(wtext(btn_id) == "OK", "Button kind=OK live caption"); + check( + mprop(btn_id, "label").as_deref() == Some("OK"), + "Button kind syncs model label", + ); + check( + mprop(btn_id, "modal-result").as_deref() == Some("1"), + "Button kind syncs modal-result", + ); + check( + set_prop(app, btn_id, "default", "true").is_ok(), + "Button default set", + ); + + let mut p2: Vec = Vec::new(); + macro_rules! add { + ($what:expr) => {{ + let id = add_widget(app, $what); + check(id.is_some(), &format!("add {} (Phase 2)", $what)); + id + }}; + } + + // Entry (§2.2). + let entry_id = add!("GtkEntry").unwrap(); + p2.push(entry_id); + check( + set_prop(app, entry_id, "text", "hello").is_ok(), + "Entry text set", + ); + check(wtext(entry_id) == "hello", "Entry text live"); + check( + set_prop(app, entry_id, "alignment", "1").is_ok(), + "Entry alignment set", + ); + check( + mprop(entry_id, "alignment").as_deref() == Some("1"), + "Entry alignment stored", + ); + check( + set_prop(app, entry_id, "numbers-only", "true").is_ok(), + "Entry numbers-only set", + ); + + // Label (§2.3). + let label_id = add!("GtkLabel").unwrap(); + p2.push(label_id); + check( + set_prop(app, label_id, "yalign", "0.25").is_ok(), + "Label yalign set", + ); + check( + mprop(label_id, "yalign").as_deref() == Some("0.25"), + "Label yalign stored", + ); + check( + set_prop(app, label_id, "transparent", "true").is_ok(), + "Label transparent set", + ); + check( + set_prop(app, label_id, "show-accel-char", "false").is_ok(), + "Label show-accel-char set", + ); + + // CheckBox (§2.4). + let cb_id = add!("GtkCheckButton").unwrap(); + p2.push(cb_id); + check( + set_prop(app, cb_id, "allow-grayed", "true").is_ok(), + "CheckBox allow-grayed set", + ); + check( + set_prop(app, cb_id, "active", "true").is_ok(), + "CheckBox active set", + ); + check(wchecked(cb_id), "CheckBox checked live"); + check( + set_prop(app, cb_id, "value-checked", "yes").is_ok(), + "CheckBox value-checked set", + ); + check( + mprop(cb_id, "value-checked").as_deref() == Some("yes"), + "CheckBox value-checked stored", + ); + + // RadioButton (§2.5): two buttons, same group id. + let rb1 = add!("GtkRadioButton").unwrap(); + let rb2 = add!("GtkRadioButton").unwrap(); + p2.push(rb1); + p2.push(rb2); + check( + set_prop(app, rb1, "group", "3").is_ok() + && set_prop(app, rb2, "group", "3").is_ok(), + "RadioButton group set", + ); + check( + mprop(rb1, "group").as_deref() == Some("3"), + "RadioButton group stored", + ); + check( + set_prop(app, rb1, "active", "true").is_ok(), + "RadioButton active set", + ); + check(wchecked(rb1), "RadioButton checked live"); + + // ComboBox (§2.6). + let combo_id = add!("GtkComboBoxText").unwrap(); + p2.push(combo_id); + check( + set_prop(app, combo_id, "items", "C|A|B").is_ok(), + "ComboBox items set", + ); + check(witems(combo_id).len() == 3, "ComboBox items live"); + check( + set_prop(app, combo_id, "sorted", "true").is_ok(), + "ComboBox sorted set", + ); + check( + witems(combo_id) == vec!["A".to_string(), "B".to_string(), "C".to_string()], + "ComboBox sorted live", + ); + check( + set_prop(app, combo_id, "active", "1").is_ok(), + "ComboBox active set", + ); + check(wsel(combo_id) == Some(1), "ComboBox selection live"); + check(wtext(combo_id) == "B", "ComboBox text follows selection"); + check( + set_prop(app, combo_id, "drop-down-count", "5").is_ok(), + "ComboBox drop-down-count set", + ); + + // ListBox (§2.7). + let list_id = add!("GtkListBox").unwrap(); + p2.push(list_id); + check( + set_prop(app, list_id, "items", "One|Two|Three").is_ok(), + "ListBox items set", + ); + check(witems(list_id).len() == 3, "ListBox items live"); + check( + set_prop(app, list_id, "item-index", "2").is_ok(), + "ListBox item-index set", + ); + check(wsel(list_id) == Some(2), "ListBox selection live"); + check( + set_prop(app, list_id, "item-height", "30").is_ok(), + "ListBox item-height set", + ); + + // ScrollBar (§2.8). + let scroll_id = add!("GtkScrollbar").unwrap(); + p2.push(scroll_id); + check( + set_prop(app, scroll_id, "lower", "10").is_ok(), + "ScrollBar lower set", + ); + check( + set_prop(app, scroll_id, "upper", "90").is_ok(), + "ScrollBar upper set", + ); + check(wmin(scroll_id) == 10.0, "ScrollBar lower live"); + check(wmax(scroll_id) == 90.0, "ScrollBar upper live"); + check( + set_prop(app, scroll_id, "value", "50").is_ok(), + "ScrollBar value set", + ); + check(wval(scroll_id) == 50.0, "ScrollBar value live"); + check( + set_prop(app, scroll_id, "orientation", "1").is_ok(), + "ScrollBar orientation set", + ); + check( + set_prop(app, scroll_id, "large-change", "20").is_ok(), + "ScrollBar large-change set", + ); + + // Scale / TrackBar (§2.9). + let scale_id = add!("GtkScale").unwrap(); + p2.push(scale_id); + check( + set_prop(app, scale_id, "minimum", "10").is_ok(), + "Scale minimum set", + ); + check( + set_prop(app, scale_id, "maximum", "90").is_ok(), + "Scale maximum set", + ); + check(wmin(scale_id) == 10.0, "Scale minimum live"); + check(wmax(scale_id) == 90.0, "Scale maximum live"); + check( + set_prop(app, scale_id, "value", "42").is_ok(), + "Scale value set", + ); + check(wval(scale_id) == 42.0, "Scale value live"); + check( + set_prop(app, scale_id, "tick-marks", "3").is_ok(), + "Scale tick-marks set", + ); + check( + set_prop(app, scale_id, "frequency", "20").is_ok(), + "Scale frequency set", + ); + check( + set_prop(app, scale_id, "page-step", "5").is_ok(), + "Scale page-step set", + ); + check( + mprop(scale_id, "page-step").as_deref() == Some("5"), + "Scale page-step stored", + ); + + // Text (§2.10). + let text_id = add!("GtkTextView").unwrap(); + p2.push(text_id); + check( + set_prop(app, text_id, "text", "Hello").is_ok(), + "Text text set", + ); + check(wtext(text_id) == "Hello", "Text text live"); + check( + set_prop(app, text_id, "max-length", "10").is_ok(), + "Text max-length set", + ); + check( + set_prop(app, text_id, "want-tabs", "false").is_ok(), + "Text want-tabs set", + ); + + // Memo (§2.10). + let memo_id = add!("TMemo").unwrap(); + p2.push(memo_id); + check( + set_prop(app, memo_id, "text", "Memo text").is_ok(), + "Memo text set", + ); + check(wtext(memo_id) == "Memo text", "Memo text live"); + check( + set_prop(app, memo_id, "cursor-visible", "false").is_ok(), + "Memo cursor-visible set", + ); + check( + set_prop(app, memo_id, "scroll-bars", "1").is_ok(), + "Memo scroll-bars set", + ); + + // CheckListBox (Flag 8): per-item checked state. + let clb_id = add!("TCheckListBox").unwrap(); + p2.push(clb_id); + check( + set_prop(app, clb_id, "items", "Red|Green|Blue").is_ok(), + "CheckListBox items set", + ); + check(witems(clb_id).len() == 3, "CheckListBox items live"); + check( + set_prop(app, clb_id, "checked-items", "0,2").is_ok(), + "CheckListBox checked-items set", + ); + check( + mprop(clb_id, "checked-items").as_deref() == Some("0,2"), + "CheckListBox checked-items stored", + ); + check( + set_prop(app, clb_id, "item-index", "1").is_ok(), + "CheckListBox item-index set", + ); + check(wsel(clb_id) == Some(1), "CheckListBox selection live"); + + // Events (Flag 10): Lazarus names, stub + connection in output. + { + let mut a = app.borrow_mut(); + if let Some(i) = a.find_index(btn_id) { + check( + set_widget_signal(&mut a.items[i].model, "clicked", true), + "Button clicked signal set", + ); + check( + set_widget_signal(&mut a.items[i].model, "button-press", true), + "Button button-press signal set", + ); + } else { + check(false, "Button still present for event test"); + } + } + let tmp2 = std::env::temp_dir() + .join(format!("lightgui-designer-selftest-p2-{}", std::process::id())); + let _ = std::fs::create_dir_all(&tmp2); + { + let (project, widgets) = { + let a = app.borrow(); + (a.project.clone(), a.model_widgets()) + }; + let mut project = project; + project.widgets = widgets; + let gen_dir = tmp2.join("gen"); + let res = lightgui_gen::generate_project(&project, &project.widgets, &gen_dir); + check(res.ok, &format!("Phase 2 generate ok ({})", res.error)); + match std::fs::read_to_string(gen_dir.join("main.cpp")) { + Ok(main) => { + for want in [ + "set_kind(1)", + "set_checked_items(\"0,2\")", + "set_group(&radio_group_3)", + "set_orientation_vertical(true)", + "set_marks({10.0, 30.0, 50.0, 70.0, 90.0})", + "set_value_checked(\"yes\")", + "add_item(\"Red\")", + "set_drop_down_count(5)", + "on_GtkButton_001_clicked", + "GtkButton_001.w.on_click", + "GtkButton_001.on_mouse_down", + ] { + check(main.contains(want), &format!("generated main.cpp has {want}")); + } + } + Err(e) => check(false, &format!("read generated main.cpp: {e}")), + } + } + + // Leave the canvas as the later checks expect it: one Button. + for id in p2 { + delete_item(app, id); + } + check(app.borrow().items.len() == 1, "canvas back to 1 widget (Phase 2)"); + } + // Save / load round-trip (string + file), through lightgui-core. let tmp = std::env::temp_dir().join(format!("lightgui-designer-selftest-{}", std::process::id())); diff --git a/crates/lightgui-gen/tests/fixtures/02_all_types/README.md b/crates/lightgui-gen/tests/fixtures/02_all_types/README.md index 504be7a..ab2735a 100644 --- a/crates/lightgui-gen/tests/fixtures/02_all_types/README.md +++ b/crates/lightgui-gen/tests/fixtures/02_all_types/README.md @@ -30,7 +30,7 @@ Close the window (or its close button) to quit. ## Notes -- Widgets: 36 placed. Each is constructed +- Widgets: 37 placed. Each is constructed as its XFrame class (e.g. `GtkButton`) with the geometry and properties from the design; colours and state use the widgets' getter/setter API where one exists, otherwise a per-widget diff --git a/crates/lightgui-gen/tests/fixtures/02_all_types/main.cpp b/crates/lightgui-gen/tests/fixtures/02_all_types/main.cpp index aa25740..9f9250d 100644 --- a/crates/lightgui-gen/tests/fixtures/02_all_types/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/02_all_types/main.cpp @@ -4,7 +4,7 @@ // or the generated Makefile (make). Both need the XFrame widget // sources; see LIGHTGUI_WIDGETS_DIR in CMakeLists.txt / Makefile. // -// The window is "Main Window" (800x600) with 36 widget(s). +// The window is "Main Window" (800x600) with 37 widget(s). #include "common/registry.h" @@ -38,8 +38,10 @@ int main() { lg::Holder Label_001(display, screen, window, gc, &styles, 200, 10, 100, 24); Label_001.w.set_text("Label_001"); Label_001.w.set_xalign(0.5); + Label_001.w.set_yalign(0.5); Label_001.w.set_wrap(false); Label_001.w.set_selectable(false); + Label_001.w.set_transparent(false); lg::Holder Entry_001(display, screen, window, gc, &styles, 390, 10, 160, 28); Entry_001.w.set_max_length(0); Entry_001.w.set_editable(true); @@ -61,86 +63,94 @@ int main() { Listbox_001.w.add_row("Item 1"); Listbox_001.w.add_row("Item 2"); Listbox_001.w.add_row("Item 3"); - lg::Holder Menubutton_001(display, screen, window, gc, &styles, 10, 270, 110, 30); + lg::Holder CheckListBox_001(display, screen, window, gc, &styles, 10, 270, 180, 110); + CheckListBox_001.w.add_item("Item 1"); + CheckListBox_001.w.add_item("Item 2"); + CheckListBox_001.w.add_item("Item 3"); + lg::Holder Menubutton_001(display, screen, window, gc, &styles, 200, 270, 110, 30); Menubutton_001.w.set_text("Menubutton_001"); - lg::Holder Canvas_001(display, screen, window, gc, &styles, 200, 270, 200, 140); + lg::Holder Canvas_001(display, screen, window, gc, &styles, 390, 270, 200, 140); // NOTE: Canvas has no XFrame counterpart; drawn as a plain area. - lg::Holder Scale_001(display, screen, window, gc, &styles, 390, 270, 160, 28); + lg::Holder Scale_001(display, screen, window, gc, &styles, 580, 270, 160, 28); + Scale_001.w.set_range(0.0, 100.0); Scale_001.w.set_value(0.0); Scale_001.w.set_draw_value(true); - lg::Holder Scrollbar_001(display, screen, window, gc, &styles, 580, 270, 160, 18); + lg::Holder Scrollbar_001(display, screen, window, gc, &styles, 10, 400, 160, 18); Scrollbar_001.w.set_upper(100.0); Scrollbar_001.w.set_page_size(10.0); Scrollbar_001.w.set_step(1.0); Scrollbar_001.w.set_value(0.0); - lg::Holder Text_001(display, screen, window, gc, &styles, 10, 400, 220, 120); + lg::Holder Text_001(display, screen, window, gc, &styles, 200, 400, 220, 120); Text_001.w.set_editable(true); Text_001.w.set_wrap_mode(false); - lg::Holder Toplevel_001(display, screen, window, gc, &styles, 200, 400, 300, 200); + lg::Holder Toplevel_001(display, screen, window, gc, &styles, 390, 400, 300, 200); Toplevel_001.w.set_title("Toplevel_001"); Toplevel_001.w.set_resizable(true); - lg::Holder Spreadsheet_001(display, screen, window, gc, &styles, 390, 400, 320, 180); + lg::Holder Spreadsheet_001(display, screen, window, gc, &styles, 580, 400, 320, 180); Spreadsheet_001.w.set_size(4, 5); - lg::Holder StockChart_001(display, screen, window, gc, &styles, 580, 400, 320, 200); + // NOTE (model-only, no XFrame setter): columns=4 + lg::Holder StockChart_001(display, screen, window, gc, &styles, 10, 530, 320, 200); StockChart_001.w.set_up_color(Srgb{0, 200, 0}); StockChart_001.w.set_down_color(Srgb{220, 0, 0}); // NOTE: StockChart design data not representable through the StockCandlestickChart API: // scale-mode: 0 (0 = price, 1 = percent) - lg::Holder Memo_001(display, screen, window, gc, &styles, 10, 530, 220, 120); + lg::Holder Memo_001(display, screen, window, gc, &styles, 200, 530, 220, 120); + Memo_001.w.set_editable(true); Memo_001.w.set_wordwrap(false); - lg::Holder GroupBox_001(display, screen, window, gc, &styles, 200, 530, 200, 120); + lg::Holder GroupBox_001(display, screen, window, gc, &styles, 390, 530, 200, 120); GroupBox_001.w.set_label("GroupBox_001"); - lg::Holder Panel_001(display, screen, window, gc, &styles, 390, 530, 200, 120); + lg::Holder Panel_001(display, screen, window, gc, &styles, 580, 530, 200, 120); Panel_001.w.set_label("Panel_001"); - lg::Holder Image_001(display, screen, window, gc, &styles, 580, 530, 160, 120); + lg::Holder Image_001(display, screen, window, gc, &styles, 10, 660, 160, 120); Image_001.w.set_pixel_size(-1); - lg::Holder Shape_001(display, screen, window, gc, &styles, 10, 660, 160, 120); + lg::Holder Shape_001(display, screen, window, gc, &styles, 200, 660, 160, 120); // NOTE: Shape ("0", fill "rgb(53,132,228)") has no XFrame counterpart; drawn as a plain area. - lg::Holder Notebook_001(display, screen, window, gc, &styles, 200, 660, 320, 200); + lg::Holder Notebook_001(display, screen, window, gc, &styles, 390, 660, 320, 200); Notebook_001.w.append_page("Tab 1"); Notebook_001.w.append_page("Tab 2"); Notebook_001.w.append_page("Tab 3"); Notebook_001.w.set_current_page(0); - lg::Holder ScrollBox_001(display, screen, window, gc, &styles, 390, 660, 240, 160); + lg::Holder ScrollBox_001(display, screen, window, gc, &styles, 580, 660, 240, 160); ScrollBox_001.w.set_text("ScrollBox_001"); - lg::Holder Splitter_001(display, screen, window, gc, &styles, 580, 660, 280, 160); + lg::Holder Splitter_001(display, screen, window, gc, &styles, 10, 790, 280, 160); Splitter_001.w.set_position(100); Splitter_001.w.set_orientation(0); - lg::Holder StatusBar_001(display, screen, window, gc, &styles, 10, 790, 320, 24); - lg::Holder ToolBar_001(display, screen, window, gc, &styles, 200, 790, 320, 36); + lg::Holder StatusBar_001(display, screen, window, gc, &styles, 200, 790, 320, 24); + lg::Holder ToolBar_001(display, screen, window, gc, &styles, 390, 790, 320, 36); ToolBar_001.w.set_items({"New", "Open", "Save"}); - lg::Holder MenuBar_001(display, screen, window, gc, &styles, 390, 790, 320, 28); + lg::Holder MenuBar_001(display, screen, window, gc, &styles, 580, 790, 320, 28); MenuBar_001.w.set_items({"File", "Edit", "Help"}); - lg::Holder SpinEdit_001(display, screen, window, gc, &styles, 580, 790, 120, 28); + lg::Holder SpinEdit_001(display, screen, window, gc, &styles, 10, 920, 120, 28); SpinEdit_001.w.set_range(0.0, 100.0); SpinEdit_001.w.set_increments(1.0, 10.0); SpinEdit_001.w.set_value(0.0); SpinEdit_001.w.set_digits(0); SpinEdit_001.w.set_wrap(false); - lg::Holder TrackBar_001(display, screen, window, gc, &styles, 10, 920, 160, 28); + lg::Holder TrackBar_001(display, screen, window, gc, &styles, 200, 920, 160, 28); TrackBar_001.w.set_range(0.0, 100.0); TrackBar_001.w.set_step(1.0); TrackBar_001.w.set_value(0.0); TrackBar_001.w.set_draw_value(true); TrackBar_001.w.set_orientation_vertical(false); - lg::Holder ProgressBar_001(display, screen, window, gc, &styles, 200, 920, 200, 24); + lg::Holder ProgressBar_001(display, screen, window, gc, &styles, 390, 920, 200, 24); ProgressBar_001.w.set_fraction(0.0); ProgressBar_001.w.set_show_text(false); - lg::Holder DateTimePicker_001(display, screen, window, gc, &styles, 390, 920, 240, 200); + lg::Holder DateTimePicker_001(display, screen, window, gc, &styles, 580, 920, 240, 200); DateTimePicker_001.w.set_show_heading(true); DateTimePicker_001.w.set_show_day_names(true); - lg::Holder ColorBox_001(display, screen, window, gc, &styles, 580, 920, 120, 28); + lg::Holder ColorBox_001(display, screen, window, gc, &styles, 10, 1050, 120, 28); ColorBox_001.w.set_color_rgb(53, 132, 228); - lg::Holder ListView_001(display, screen, window, gc, &styles, 10, 1050, 240, 140); + lg::Holder ListView_001(display, screen, window, gc, &styles, 200, 1050, 240, 140); ListView_001.w.add_item("Row 1,Value 1"); ListView_001.w.add_item("Row 2,Value 2"); - lg::Holder TreeView_001(display, screen, window, gc, &styles, 200, 1050, 240, 140); + lg::Holder TreeView_001(display, screen, window, gc, &styles, 390, 1050, 240, 140); TreeView_001.w.set_roots({GtkTreeView::Node{{"Root"}, {GtkTreeView::Node{{"Child 1"}, {}, true}}, true}, GtkTreeView::Node{{"Root"}, {GtkTreeView::Node{{"Child 2"}, {}, true}}, true}, GtkTreeView::Node{{"Other"}, {}, true}}); - lg::Holder StringGrid_001(display, screen, window, gc, &styles, 390, 1050, 280, 160); + lg::Holder StringGrid_001(display, screen, window, gc, &styles, 580, 1050, 280, 160); StringGrid_001.w.set_size(4, 5); - lg::Holder Plot_001(display, screen, window, gc, &styles, 580, 1050, 280, 180); + // NOTE (model-only, no XFrame setter): columns=4 + lg::Holder Plot_001(display, screen, window, gc, &styles, 10, 1180, 280, 180); // NOTE: Plot line colour "rgb(220,0,0)" is not representable through the XGraph API. - std::vector widgets = { &Button_001, &Label_001, &Entry_001, &Checkbutton_001, &Radiobutton_001, &Frame_001, &Combobox_001, &Listbox_001, &Menubutton_001, &Canvas_001, &Scale_001, &Scrollbar_001, &Text_001, &Toplevel_001, &Spreadsheet_001, &StockChart_001, &Memo_001, &GroupBox_001, &Panel_001, &Image_001, &Shape_001, &Notebook_001, &ScrollBox_001, &Splitter_001, &StatusBar_001, &ToolBar_001, &MenuBar_001, &SpinEdit_001, &TrackBar_001, &ProgressBar_001, &DateTimePicker_001, &ColorBox_001, &ListView_001, &TreeView_001, &StringGrid_001, &Plot_001 }; + std::vector widgets = { &Button_001, &Label_001, &Entry_001, &Checkbutton_001, &Radiobutton_001, &Frame_001, &Combobox_001, &Listbox_001, &CheckListBox_001, &Menubutton_001, &Canvas_001, &Scale_001, &Scrollbar_001, &Text_001, &Toplevel_001, &Spreadsheet_001, &StockChart_001, &Memo_001, &GroupBox_001, &Panel_001, &Image_001, &Shape_001, &Notebook_001, &ScrollBox_001, &Splitter_001, &StatusBar_001, &ToolBar_001, &MenuBar_001, &SpinEdit_001, &TrackBar_001, &ProgressBar_001, &DateTimePicker_001, &ColorBox_001, &ListView_001, &TreeView_001, &StringGrid_001, &Plot_001 }; auto redraw_all = [&]() { XClearWindow(display, window); for (lg::IWidget* wd : widgets) wd->draw(); diff --git a/crates/lightgui-gen/tests/fixtures/03_all_props/README.md b/crates/lightgui-gen/tests/fixtures/03_all_props/README.md index 504be7a..ab2735a 100644 --- a/crates/lightgui-gen/tests/fixtures/03_all_props/README.md +++ b/crates/lightgui-gen/tests/fixtures/03_all_props/README.md @@ -30,7 +30,7 @@ Close the window (or its close button) to quit. ## Notes -- Widgets: 36 placed. Each is constructed +- Widgets: 37 placed. Each is constructed as its XFrame class (e.g. `GtkButton`) with the geometry and properties from the design; colours and state use the widgets' getter/setter API where one exists, otherwise a per-widget diff --git a/crates/lightgui-gen/tests/fixtures/03_all_props/main.cpp b/crates/lightgui-gen/tests/fixtures/03_all_props/main.cpp index e342393..78fd4d4 100644 --- a/crates/lightgui-gen/tests/fixtures/03_all_props/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/03_all_props/main.cpp @@ -4,7 +4,7 @@ // or the generated Makefile (make). Both need the XFrame widget // sources; see LIGHTGUI_WIDGETS_DIR in CMakeLists.txt / Makefile. // -// The window is "Main Window" (800x600) with 36 widget(s). +// The window is "Main Window" (800x600) with 37 widget(s). #include "common/registry.h" @@ -123,6 +123,7 @@ int main() { styles.add_style_ex("Frame_001_style", Srgb{51, 102, 153}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); styles.add_style_ex("Combobox_001_style", Srgb{51, 102, 153}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); styles.add_style_ex("Listbox_001_style", Srgb{225, 225, 225}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); + styles.add_style_ex("CheckListBox_001_style", Srgb{51, 102, 153}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); styles.add_style_ex("Menubutton_001_style", Srgb{51, 102, 153}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); styles.add_style_ex("Canvas_001_style", Srgb{51, 102, 153}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); styles.add_style_ex("Scale_001_style", Srgb{51, 102, 153}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); @@ -153,21 +154,28 @@ int main() { styles.add_style_ex("Plot_001_style", Srgb{225, 225, 225}, Srgb{120, 120, 120}, Srgb{51, 102, 153}, Srgb{255, 255, 255}, 6, 1, lightgui_pick_font(display, "Test value", 13, true, true)); lg::Holder Button_001(display, screen, window, gc, &styles, 10, 10, 100, 30); Button_001.w.set_text("Test value"); + Button_001.w.set_default(true); + Button_001.w.set_cancel(true); + Button_001.w.set_kind(9); + Button_001.w.set_layout(3); Button_001.w.set_style_name("Button_001_style"); Button_001.set_enabled(false); Button_001.set_visible(false); - // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true + // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true, glyph="Test value" apply_autosize(&Button_001, styles, "Button_001_style", 10, 10, 0, 0, 0, 0); lg::Holder Label_001(display, screen, window, gc, &styles, 200, 10, 100, 24); Label_001.w.set_text("Test value"); Label_001.w.set_xalign(1.0); + Label_001.w.set_yalign(1.0); Label_001.w.set_wrap(true); Label_001.w.set_selectable(true); + Label_001.w.set_transparent(true); + Label_001.w.set_show_accel_char(false); Label_001.w.set_fill_color_rgb(51, 102, 153); Label_001.w.set_style_name("Label_001_style"); Label_001.set_enabled(false); Label_001.set_visible(false); - // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true + // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true, focus-control="Test value" apply_autosize(&Label_001, styles, "Label_001_style", 200, 10, 0, 0, 0, 0); lg::Holder Entry_001(display, screen, window, gc, &styles, 390, 10, 160, 28); Entry_001.w.set_text("Test value"); @@ -176,6 +184,11 @@ int main() { Entry_001.w.set_editable(false); Entry_001.w.set_password(true); Entry_001.w.set_show_password(true); + Entry_001.w.set_alignment(2); + Entry_001.w.set_char_case(2); + Entry_001.w.set_numbers_only(true); + Entry_001.w.set_hide_selection(true); + Entry_001.w.set_auto_select(true); Entry_001.w.set_fill_color_rgb(51, 102, 153); Entry_001.w.set_style_name("Entry_001_style"); Entry_001.set_enabled(false); @@ -184,8 +197,12 @@ int main() { apply_autosize(&Entry_001, styles, "Entry_001_style", 390, 10, 0, 0, 0, 0); lg::Holder Checkbutton_001(display, screen, window, gc, &styles, 580, 10, 120, 26); Checkbutton_001.w.set_text("Test value"); + Checkbutton_001.w.set_allow_grayed(true); Checkbutton_001.w.set_active(true); Checkbutton_001.w.set_inconsistent(true); + Checkbutton_001.w.set_alignment(1); + Checkbutton_001.w.set_value_checked("Test value"); + Checkbutton_001.w.set_value_unchecked("Test value"); Checkbutton_001.w.set_style_name("Checkbutton_001_style"); Checkbutton_001.set_enabled(false); Checkbutton_001.set_visible(false); @@ -207,8 +224,14 @@ int main() { // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true apply_autosize(&Frame_001, styles, "Frame_001_style", 200, 140, 0, 0, 0, 0); lg::Holder Combobox_001(display, screen, window, gc, &styles, 390, 140, 160, 28); + Combobox_001.w.set_text("Test value"); Combobox_001.w.append_text("Test value"); Combobox_001.w.set_active(0); + Combobox_001.w.set_style(2); + Combobox_001.w.set_sorted(true); + Combobox_001.w.set_read_only(true); + Combobox_001.w.set_auto_complete(true); + Combobox_001.w.set_char_case(2); Combobox_001.w.set_style_name("Combobox_001_style"); Combobox_001.set_enabled(false); Combobox_001.set_visible(false); @@ -216,75 +239,98 @@ int main() { apply_autosize(&Combobox_001, styles, "Combobox_001_style", 390, 140, 0, 0, 0, 0); lg::Holder Listbox_001(display, screen, window, gc, &styles, 580, 140, 180, 110); Listbox_001.w.add_row("Test value"); + Listbox_001.w.set_multi_select(true); + Listbox_001.w.set_sorted(true); Listbox_001.w.set_frame_background_color_rgb(51, 102, 153); Listbox_001.w.set_style_name("Listbox_001_style"); Listbox_001.set_enabled(false); Listbox_001.set_visible(false); - // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true + // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true, integral-height=true apply_autosize(&Listbox_001, styles, "Listbox_001_style", 580, 140, 0, 0, 0, 0); - lg::Holder Menubutton_001(display, screen, window, gc, &styles, 10, 270, 110, 30); + lg::Holder CheckListBox_001(display, screen, window, gc, &styles, 10, 270, 180, 110); + CheckListBox_001.w.add_item("Test value"); + CheckListBox_001.w.set_sorted(true); + CheckListBox_001.w.set_checked_items("Test value"); + CheckListBox_001.w.set_style_name("CheckListBox_001_style"); + CheckListBox_001.set_enabled(false); + CheckListBox_001.set_visible(false); + // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true + apply_autosize(&CheckListBox_001, styles, "CheckListBox_001_style", 10, 270, 0, 0, 0, 0); + lg::Holder Menubutton_001(display, screen, window, gc, &styles, 200, 270, 110, 30); Menubutton_001.w.set_text("Test value"); - Menubutton_001.w.set_direction(0); + Menubutton_001.w.set_direction(4); Menubutton_001.w.set_style_name("Menubutton_001_style"); Menubutton_001.set_enabled(false); Menubutton_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Menubutton_001, styles, "Menubutton_001_style", 10, 270, 0, 0, 0, 0); - lg::Holder Canvas_001(display, screen, window, gc, &styles, 200, 270, 200, 140); + apply_autosize(&Menubutton_001, styles, "Menubutton_001_style", 200, 270, 0, 0, 0, 0); + lg::Holder Canvas_001(display, screen, window, gc, &styles, 390, 270, 200, 140); // NOTE: Canvas has no XFrame counterpart; drawn as a plain area. Canvas_001.w.set_style_name("Canvas_001_style"); Canvas_001.set_enabled(false); Canvas_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Canvas_001, styles, "Canvas_001_style", 200, 270, 0, 0, 0, 0); - lg::Holder Scale_001(display, screen, window, gc, &styles, 390, 270, 160, 28); + apply_autosize(&Canvas_001, styles, "Canvas_001_style", 390, 270, 0, 0, 0, 0); + lg::Holder Scale_001(display, screen, window, gc, &styles, 580, 270, 160, 28); + Scale_001.w.set_range(42.5, 42.5); Scale_001.w.set_value(42.5); Scale_001.w.set_draw_value(false); + Scale_001.w.set_page_step(42.5); + Scale_001.w.set_show_sel_range(true); + Scale_001.w.set_sel_start(42.5); + Scale_001.w.set_sel_end(42.5); Scale_001.w.set_style_name("Scale_001_style"); Scale_001.set_enabled(false); Scale_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Scale_001, styles, "Scale_001_style", 390, 270, 0, 0, 0, 0); - lg::Holder Scrollbar_001(display, screen, window, gc, &styles, 580, 270, 160, 18); + apply_autosize(&Scale_001, styles, "Scale_001_style", 580, 270, 0, 0, 0, 0); + lg::Holder Scrollbar_001(display, screen, window, gc, &styles, 10, 400, 160, 18); Scrollbar_001.w.set_lower(42.5); Scrollbar_001.w.set_upper(42.5); Scrollbar_001.w.set_page_size(42.5); Scrollbar_001.w.set_step(42.5); Scrollbar_001.w.set_page_increment(42.5); Scrollbar_001.w.set_value(42.5); + Scrollbar_001.w.set_orientation_vertical(true); + Scrollbar_001.w.set_page_increment(42.5); Scrollbar_001.w.set_style_name("Scrollbar_001_style"); Scrollbar_001.set_enabled(false); Scrollbar_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Scrollbar_001, styles, "Scrollbar_001_style", 580, 270, 0, 0, 0, 0); - lg::Holder Text_001(display, screen, window, gc, &styles, 10, 400, 220, 120); + apply_autosize(&Scrollbar_001, styles, "Scrollbar_001_style", 10, 400, 0, 0, 0, 0); + lg::Holder Text_001(display, screen, window, gc, &styles, 200, 400, 220, 120); Text_001.w.set_text("Test value"); Text_001.w.set_editable(false); - Text_001.w.set_wrap_mode(false); + Text_001.w.set_wrap_mode(true); Text_001.w.set_cursor_visible(false); + Text_001.w.set_scroll_bars(3); + Text_001.w.set_want_tabs(false); + Text_001.w.set_want_returns(false); + Text_001.w.set_hide_selection(true); + Text_001.w.set_alignment(2); Text_001.w.set_fill_color_rgb(51, 102, 153); Text_001.w.set_style_name("Text_001_style"); Text_001.set_enabled(false); Text_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Text_001, styles, "Text_001_style", 10, 400, 0, 0, 0, 0); - lg::Holder Toplevel_001(display, screen, window, gc, &styles, 200, 400, 300, 200); + apply_autosize(&Text_001, styles, "Text_001_style", 200, 400, 0, 0, 0, 0); + lg::Holder Toplevel_001(display, screen, window, gc, &styles, 390, 400, 300, 200); Toplevel_001.w.set_title("Test value"); Toplevel_001.w.set_resizable(false); Toplevel_001.w.set_style_name("Toplevel_001_style"); Toplevel_001.set_enabled(false); Toplevel_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Toplevel_001, styles, "Toplevel_001_style", 200, 400, 0, 0, 0, 0); - lg::Holder Spreadsheet_001(display, screen, window, gc, &styles, 390, 400, 320, 180); + apply_autosize(&Toplevel_001, styles, "Toplevel_001_style", 390, 400, 0, 0, 0, 0); + lg::Holder Spreadsheet_001(display, screen, window, gc, &styles, 580, 400, 320, 180); Spreadsheet_001.w.set_size(4, 5); Spreadsheet_001.w.set_white_color_rgb(51, 102, 153); Spreadsheet_001.w.set_style_name("Spreadsheet_001_style"); Spreadsheet_001.set_enabled(false); Spreadsheet_001.set_visible(false); - // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Spreadsheet_001, styles, "Spreadsheet_001_style", 390, 400, 0, 0, 0, 0); - lg::Holder StockChart_001(display, screen, window, gc, &styles, 580, 400, 320, 200); + // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true, columns=4 + apply_autosize(&Spreadsheet_001, styles, "Spreadsheet_001_style", 580, 400, 0, 0, 0, 0); + lg::Holder StockChart_001(display, screen, window, gc, &styles, 10, 530, 320, 200); StockChart_001.w.set_up_color(Srgb{51, 102, 153}); StockChart_001.w.set_down_color(Srgb{51, 102, 153}); // NOTE: StockChart design data not representable through the StockCandlestickChart API: @@ -292,97 +338,103 @@ int main() { // indicators: "Test value" // drawings: "Test value" // compare-files: "Test value" - // scale-mode: 0 (0 = price, 1 = percent) + // scale-mode: 1 (0 = price, 1 = percent) StockChart_001.w.set_bg_color(Srgb{51, 102, 153}); StockChart_001.w.set_style_name("StockChart_001_style"); StockChart_001.set_enabled(false); StockChart_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&StockChart_001, styles, "StockChart_001_style", 580, 400, 0, 0, 0, 0); - lg::Holder Memo_001(display, screen, window, gc, &styles, 10, 530, 220, 120); + apply_autosize(&StockChart_001, styles, "StockChart_001_style", 10, 530, 0, 0, 0, 0); + lg::Holder Memo_001(display, screen, window, gc, &styles, 200, 530, 220, 120); Memo_001.w.set_text("Test value"); - Memo_001.w.set_wordwrap(false); + Memo_001.w.set_editable(false); + Memo_001.w.set_cursor_visible(false); + Memo_001.w.set_want_tabs(false); + Memo_001.w.set_want_returns(false); + Memo_001.w.set_hide_selection(true); + Memo_001.w.set_alignment(2); + Memo_001.w.set_wordwrap(true); Memo_001.w.set_fill_color_rgb(51, 102, 153); Memo_001.w.set_style_name("Memo_001_style"); Memo_001.set_enabled(false); Memo_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Memo_001, styles, "Memo_001_style", 10, 530, 0, 0, 0, 0); - lg::Holder GroupBox_001(display, screen, window, gc, &styles, 200, 530, 200, 120); + apply_autosize(&Memo_001, styles, "Memo_001_style", 200, 530, 0, 0, 0, 0); + lg::Holder GroupBox_001(display, screen, window, gc, &styles, 390, 530, 200, 120); GroupBox_001.w.set_label("Test value"); GroupBox_001.w.set_style_name("GroupBox_001_style"); GroupBox_001.set_enabled(false); GroupBox_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&GroupBox_001, styles, "GroupBox_001_style", 200, 530, 0, 0, 0, 0); - lg::Holder Panel_001(display, screen, window, gc, &styles, 390, 530, 200, 120); + apply_autosize(&GroupBox_001, styles, "GroupBox_001_style", 390, 530, 0, 0, 0, 0); + lg::Holder Panel_001(display, screen, window, gc, &styles, 580, 530, 200, 120); Panel_001.w.set_label("Test value"); Panel_001.w.set_style_name("Panel_001_style"); Panel_001.set_enabled(false); Panel_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Panel_001, styles, "Panel_001_style", 390, 530, 0, 0, 0, 0); - lg::Holder Image_001(display, screen, window, gc, &styles, 580, 530, 160, 120); + apply_autosize(&Panel_001, styles, "Panel_001_style", 580, 530, 0, 0, 0, 0); + lg::Holder Image_001(display, screen, window, gc, &styles, 10, 660, 160, 120); Image_001.w.set_filename("Test value"); Image_001.w.set_pixel_size(-1); Image_001.w.set_style_name("Image_001_style"); Image_001.set_enabled(false); Image_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Image_001, styles, "Image_001_style", 580, 530, 0, 0, 0, 0); - lg::Holder Shape_001(display, screen, window, gc, &styles, 10, 660, 160, 120); - // NOTE: Shape ("0", fill "#336699") has no XFrame counterpart; drawn as a plain area. + apply_autosize(&Image_001, styles, "Image_001_style", 10, 660, 0, 0, 0, 0); + lg::Holder Shape_001(display, screen, window, gc, &styles, 200, 660, 160, 120); + // NOTE: Shape ("3", fill "#336699") has no XFrame counterpart; drawn as a plain area. Shape_001.w.set_style_name("Shape_001_style"); Shape_001.set_enabled(false); Shape_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Shape_001, styles, "Shape_001_style", 10, 660, 0, 0, 0, 0); - lg::Holder Notebook_001(display, screen, window, gc, &styles, 200, 660, 320, 200); + apply_autosize(&Shape_001, styles, "Shape_001_style", 200, 660, 0, 0, 0, 0); + lg::Holder Notebook_001(display, screen, window, gc, &styles, 390, 660, 320, 200); Notebook_001.w.append_page("Test value"); Notebook_001.w.set_current_page(0); Notebook_001.w.set_style_name("Notebook_001_style"); Notebook_001.set_enabled(false); Notebook_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Notebook_001, styles, "Notebook_001_style", 200, 660, 0, 0, 0, 0); - lg::Holder ScrollBox_001(display, screen, window, gc, &styles, 390, 660, 240, 160); + apply_autosize(&Notebook_001, styles, "Notebook_001_style", 390, 660, 0, 0, 0, 0); + lg::Holder ScrollBox_001(display, screen, window, gc, &styles, 580, 660, 240, 160); ScrollBox_001.w.set_text("Test value"); ScrollBox_001.w.set_viewport_background_color_rgb(51, 102, 153); ScrollBox_001.w.set_style_name("ScrollBox_001_style"); ScrollBox_001.set_enabled(false); ScrollBox_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&ScrollBox_001, styles, "ScrollBox_001_style", 390, 660, 0, 0, 0, 0); - lg::Holder Splitter_001(display, screen, window, gc, &styles, 580, 660, 280, 160); + apply_autosize(&ScrollBox_001, styles, "ScrollBox_001_style", 580, 660, 0, 0, 0, 0); + lg::Holder Splitter_001(display, screen, window, gc, &styles, 10, 790, 280, 160); Splitter_001.w.set_position(100); - Splitter_001.w.set_orientation(0); + Splitter_001.w.set_orientation(1); Splitter_001.w.set_style_name("Splitter_001_style"); Splitter_001.set_enabled(false); Splitter_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Splitter_001, styles, "Splitter_001_style", 580, 660, 0, 0, 0, 0); - lg::Holder StatusBar_001(display, screen, window, gc, &styles, 10, 790, 320, 24); + apply_autosize(&Splitter_001, styles, "Splitter_001_style", 10, 790, 0, 0, 0, 0); + lg::Holder StatusBar_001(display, screen, window, gc, &styles, 200, 790, 320, 24); StatusBar_001.w.set_text("Test value"); StatusBar_001.w.set_style_name("StatusBar_001_style"); StatusBar_001.set_enabled(false); StatusBar_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&StatusBar_001, styles, "StatusBar_001_style", 10, 790, 0, 0, 0, 0); - lg::Holder ToolBar_001(display, screen, window, gc, &styles, 200, 790, 320, 36); + apply_autosize(&StatusBar_001, styles, "StatusBar_001_style", 200, 790, 0, 0, 0, 0); + lg::Holder ToolBar_001(display, screen, window, gc, &styles, 390, 790, 320, 36); ToolBar_001.w.set_items({"Test value"}); ToolBar_001.w.set_style_name("ToolBar_001_style"); ToolBar_001.set_enabled(false); ToolBar_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&ToolBar_001, styles, "ToolBar_001_style", 200, 790, 0, 0, 0, 0); - lg::Holder MenuBar_001(display, screen, window, gc, &styles, 390, 790, 320, 28); + apply_autosize(&ToolBar_001, styles, "ToolBar_001_style", 390, 790, 0, 0, 0, 0); + lg::Holder MenuBar_001(display, screen, window, gc, &styles, 580, 790, 320, 28); MenuBar_001.w.set_items({"Test value"}); MenuBar_001.w.set_style_name("MenuBar_001_style"); MenuBar_001.set_enabled(false); MenuBar_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&MenuBar_001, styles, "MenuBar_001_style", 390, 790, 0, 0, 0, 0); - lg::Holder SpinEdit_001(display, screen, window, gc, &styles, 580, 790, 120, 28); + apply_autosize(&MenuBar_001, styles, "MenuBar_001_style", 580, 790, 0, 0, 0, 0); + lg::Holder SpinEdit_001(display, screen, window, gc, &styles, 10, 920, 120, 28); SpinEdit_001.w.set_range(0.0, 100.0); SpinEdit_001.w.set_increments(1.0, 10.0); SpinEdit_001.w.set_value(42.5); @@ -393,19 +445,24 @@ int main() { SpinEdit_001.set_enabled(false); SpinEdit_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&SpinEdit_001, styles, "SpinEdit_001_style", 580, 790, 0, 0, 0, 0); - lg::Holder TrackBar_001(display, screen, window, gc, &styles, 10, 920, 160, 28); + apply_autosize(&SpinEdit_001, styles, "SpinEdit_001_style", 10, 920, 0, 0, 0, 0); + lg::Holder TrackBar_001(display, screen, window, gc, &styles, 200, 920, 160, 28); TrackBar_001.w.set_range(0.0, 100.0); TrackBar_001.w.set_step(1.0); TrackBar_001.w.set_value(42.5); TrackBar_001.w.set_draw_value(false); - TrackBar_001.w.set_orientation_vertical(false); + TrackBar_001.w.set_orientation_vertical(true); + TrackBar_001.w.set_page_step(42.5); + TrackBar_001.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + TrackBar_001.w.set_show_sel_range(true); + TrackBar_001.w.set_sel_start(42.5); + TrackBar_001.w.set_sel_end(42.5); TrackBar_001.w.set_style_name("TrackBar_001_style"); TrackBar_001.set_enabled(false); TrackBar_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&TrackBar_001, styles, "TrackBar_001_style", 10, 920, 0, 0, 0, 0); - lg::Holder ProgressBar_001(display, screen, window, gc, &styles, 200, 920, 200, 24); + apply_autosize(&TrackBar_001, styles, "TrackBar_001_style", 200, 920, 0, 0, 0, 0); + lg::Holder ProgressBar_001(display, screen, window, gc, &styles, 390, 920, 200, 24); ProgressBar_001.w.set_text("Test value"); ProgressBar_001.w.set_fraction(1.0); ProgressBar_001.w.set_show_text(true); @@ -413,375 +470,384 @@ int main() { ProgressBar_001.set_enabled(false); ProgressBar_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&ProgressBar_001, styles, "ProgressBar_001_style", 200, 920, 0, 0, 0, 0); - lg::Holder DateTimePicker_001(display, screen, window, gc, &styles, 390, 920, 240, 200); + apply_autosize(&ProgressBar_001, styles, "ProgressBar_001_style", 390, 920, 0, 0, 0, 0); + lg::Holder DateTimePicker_001(display, screen, window, gc, &styles, 580, 920, 240, 200); DateTimePicker_001.w.set_show_heading(false); DateTimePicker_001.w.set_show_day_names(false); DateTimePicker_001.w.set_style_name("DateTimePicker_001_style"); DateTimePicker_001.set_enabled(false); DateTimePicker_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&DateTimePicker_001, styles, "DateTimePicker_001_style", 390, 920, 0, 0, 0, 0); - lg::Holder ColorBox_001(display, screen, window, gc, &styles, 580, 920, 120, 28); + apply_autosize(&DateTimePicker_001, styles, "DateTimePicker_001_style", 580, 920, 0, 0, 0, 0); + lg::Holder ColorBox_001(display, screen, window, gc, &styles, 10, 1050, 120, 28); ColorBox_001.w.set_color_rgb(51, 102, 153); ColorBox_001.w.set_style_name("ColorBox_001_style"); ColorBox_001.set_enabled(false); ColorBox_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&ColorBox_001, styles, "ColorBox_001_style", 580, 920, 0, 0, 0, 0); - lg::Holder ListView_001(display, screen, window, gc, &styles, 10, 1050, 240, 140); + apply_autosize(&ColorBox_001, styles, "ColorBox_001_style", 10, 1050, 0, 0, 0, 0); + lg::Holder ListView_001(display, screen, window, gc, &styles, 200, 1050, 240, 140); ListView_001.w.add_item("Test value"); ListView_001.w.set_style_name("ListView_001_style"); ListView_001.set_enabled(false); ListView_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&ListView_001, styles, "ListView_001_style", 10, 1050, 0, 0, 0, 0); - lg::Holder TreeView_001(display, screen, window, gc, &styles, 200, 1050, 240, 140); + apply_autosize(&ListView_001, styles, "ListView_001_style", 200, 1050, 0, 0, 0, 0); + lg::Holder TreeView_001(display, screen, window, gc, &styles, 390, 1050, 240, 140); TreeView_001.w.set_roots({GtkTreeView::Node{{"Test value"}, {}, true}}); TreeView_001.w.set_style_name("TreeView_001_style"); TreeView_001.set_enabled(false); TreeView_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&TreeView_001, styles, "TreeView_001_style", 200, 1050, 0, 0, 0, 0); - lg::Holder StringGrid_001(display, screen, window, gc, &styles, 390, 1050, 280, 160); + apply_autosize(&TreeView_001, styles, "TreeView_001_style", 390, 1050, 0, 0, 0, 0); + lg::Holder StringGrid_001(display, screen, window, gc, &styles, 580, 1050, 280, 160); StringGrid_001.w.set_size(4, 5); StringGrid_001.w.set_white_color_rgb(51, 102, 153); StringGrid_001.w.set_style_name("StringGrid_001_style"); StringGrid_001.set_enabled(false); StringGrid_001.set_visible(false); - // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&StringGrid_001, styles, "StringGrid_001_style", 390, 1050, 0, 0, 0, 0); - lg::Holder Plot_001(display, screen, window, gc, &styles, 580, 1050, 280, 180); + // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true, columns=4 + apply_autosize(&StringGrid_001, styles, "StringGrid_001_style", 580, 1050, 0, 0, 0, 0); + lg::Holder Plot_001(display, screen, window, gc, &styles, 10, 1180, 280, 180); // NOTE: Plot line colour "#336699" is not representable through the XGraph API. Plot_001.w.set_white_color_rgb(51, 102, 153); Plot_001.w.set_style_name("Plot_001_style"); Plot_001.set_enabled(false); Plot_001.set_visible(false); // NOTE (model-only, no XFrame setter): hint="Test value", tooltip-text="tip with \"quotes\" and \\ slash", cursor="Test value", tab-stop=false, show-hint=true, font-underline=true, font-strikeout=true - apply_autosize(&Plot_001, styles, "Plot_001_style", 580, 1050, 0, 0, 0, 0); - std::vector widgets = { &Button_001, &Label_001, &Entry_001, &Checkbutton_001, &Radiobutton_001, &Frame_001, &Combobox_001, &Listbox_001, &Menubutton_001, &Canvas_001, &Scale_001, &Scrollbar_001, &Text_001, &Toplevel_001, &Spreadsheet_001, &StockChart_001, &Memo_001, &GroupBox_001, &Panel_001, &Image_001, &Shape_001, &Notebook_001, &ScrollBox_001, &Splitter_001, &StatusBar_001, &ToolBar_001, &MenuBar_001, &SpinEdit_001, &TrackBar_001, &ProgressBar_001, &DateTimePicker_001, &ColorBox_001, &ListView_001, &TreeView_001, &StringGrid_001, &Plot_001 }; + apply_autosize(&Plot_001, styles, "Plot_001_style", 10, 1180, 0, 0, 0, 0); + std::vector widgets = { &Button_001, &Label_001, &Entry_001, &Checkbutton_001, &Radiobutton_001, &Frame_001, &Combobox_001, &Listbox_001, &CheckListBox_001, &Menubutton_001, &Canvas_001, &Scale_001, &Scrollbar_001, &Text_001, &Toplevel_001, &Spreadsheet_001, &StockChart_001, &Memo_001, &GroupBox_001, &Panel_001, &Image_001, &Shape_001, &Notebook_001, &ScrollBox_001, &Splitter_001, &StatusBar_001, &ToolBar_001, &MenuBar_001, &SpinEdit_001, &TrackBar_001, &ProgressBar_001, &DateTimePicker_001, &ColorBox_001, &ListView_001, &TreeView_001, &StringGrid_001, &Plot_001 }; // Anchors (Phase 1, Flag 1): minimal anchor layout. Each anchored widget is repositioned/resized from its design geometry when the window resizes; top+left alone is static and needs no code. auto apply_anchors = [&](int new_w, int new_h) { - { // Button_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 10 + (new_h - 600); - int _w = 100; - int _h = 30; + { // Button_001: anchors top, left, right, bottom + int _x = 10; + int _y = 10; + int _w = 100 + (new_w - 800); + int _h = 30 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Button_001.set_bounds(_x, _y, _w, _h); } - { // Label_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 10 + (new_h - 600); - int _w = 100; - int _h = 24; + { // Label_001: anchors top, left, right, bottom + int _x = 200; + int _y = 10; + int _w = 100 + (new_w - 800); + int _h = 24 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Label_001.set_bounds(_x, _y, _w, _h); } - { // Entry_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 10 + (new_h - 600); - int _w = 160; - int _h = 28; + { // Entry_001: anchors top, left, right, bottom + int _x = 390; + int _y = 10; + int _w = 160 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Entry_001.set_bounds(_x, _y, _w, _h); } - { // Checkbutton_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 10 + (new_h - 600); - int _w = 120; - int _h = 26; + { // Checkbutton_001: anchors top, left, right, bottom + int _x = 580; + int _y = 10; + int _w = 120 + (new_w - 800); + int _h = 26 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Checkbutton_001.set_bounds(_x, _y, _w, _h); } - { // Radiobutton_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 140 + (new_h - 600); - int _w = 120; - int _h = 26; + { // Radiobutton_001: anchors top, left, right, bottom + int _x = 10; + int _y = 140; + int _w = 120 + (new_w - 800); + int _h = 26 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Radiobutton_001.set_bounds(_x, _y, _w, _h); } - { // Frame_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 140 + (new_h - 600); - int _w = 200; - int _h = 120; + { // Frame_001: anchors top, left, right, bottom + int _x = 200; + int _y = 140; + int _w = 200 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Frame_001.set_bounds(_x, _y, _w, _h); } - { // Combobox_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 140 + (new_h - 600); - int _w = 160; - int _h = 28; + { // Combobox_001: anchors top, left, right, bottom + int _x = 390; + int _y = 140; + int _w = 160 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Combobox_001.set_bounds(_x, _y, _w, _h); } - { // Listbox_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 140 + (new_h - 600); - int _w = 180; - int _h = 110; + { // Listbox_001: anchors top, left, right, bottom + int _x = 580; + int _y = 140; + int _w = 180 + (new_w - 800); + int _h = 110 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Listbox_001.set_bounds(_x, _y, _w, _h); } - { // Menubutton_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 270 + (new_h - 600); - int _w = 110; - int _h = 30; + { // CheckListBox_001: anchors top, left, right, bottom + int _x = 10; + int _y = 270; + int _w = 180 + (new_w - 800); + int _h = 110 + (new_h - 600); + if (_w < 24) _w = 24; + if (_h < 16) _h = 16; + CheckListBox_001.set_bounds(_x, _y, _w, _h); + } + { // Menubutton_001: anchors top, left, right, bottom + int _x = 200; + int _y = 270; + int _w = 110 + (new_w - 800); + int _h = 30 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Menubutton_001.set_bounds(_x, _y, _w, _h); } - { // Canvas_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 270 + (new_h - 600); - int _w = 200; - int _h = 140; + { // Canvas_001: anchors top, left, right, bottom + int _x = 390; + int _y = 270; + int _w = 200 + (new_w - 800); + int _h = 140 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Canvas_001.set_bounds(_x, _y, _w, _h); } - { // Scale_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 270 + (new_h - 600); - int _w = 160; - int _h = 28; + { // Scale_001: anchors top, left, right, bottom + int _x = 580; + int _y = 270; + int _w = 160 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Scale_001.set_bounds(_x, _y, _w, _h); } - { // Scrollbar_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 270 + (new_h - 600); - int _w = 160; - int _h = 18; + { // Scrollbar_001: anchors top, left, right, bottom + int _x = 10; + int _y = 400; + int _w = 160 + (new_w - 800); + int _h = 18 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Scrollbar_001.set_bounds(_x, _y, _w, _h); } - { // Text_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 400 + (new_h - 600); - int _w = 220; - int _h = 120; + { // Text_001: anchors top, left, right, bottom + int _x = 200; + int _y = 400; + int _w = 220 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Text_001.set_bounds(_x, _y, _w, _h); } - { // Toplevel_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 400 + (new_h - 600); - int _w = 300; - int _h = 200; + { // Toplevel_001: anchors top, left, right, bottom + int _x = 390; + int _y = 400; + int _w = 300 + (new_w - 800); + int _h = 200 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Toplevel_001.set_bounds(_x, _y, _w, _h); } - { // Spreadsheet_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 400 + (new_h - 600); - int _w = 320; - int _h = 180; + { // Spreadsheet_001: anchors top, left, right, bottom + int _x = 580; + int _y = 400; + int _w = 320 + (new_w - 800); + int _h = 180 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Spreadsheet_001.set_bounds(_x, _y, _w, _h); } - { // StockChart_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 400 + (new_h - 600); - int _w = 320; - int _h = 200; + { // StockChart_001: anchors top, left, right, bottom + int _x = 10; + int _y = 530; + int _w = 320 + (new_w - 800); + int _h = 200 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; StockChart_001.set_bounds(_x, _y, _w, _h); } - { // Memo_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 530 + (new_h - 600); - int _w = 220; - int _h = 120; + { // Memo_001: anchors top, left, right, bottom + int _x = 200; + int _y = 530; + int _w = 220 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Memo_001.set_bounds(_x, _y, _w, _h); } - { // GroupBox_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 530 + (new_h - 600); - int _w = 200; - int _h = 120; + { // GroupBox_001: anchors top, left, right, bottom + int _x = 390; + int _y = 530; + int _w = 200 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; GroupBox_001.set_bounds(_x, _y, _w, _h); } - { // Panel_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 530 + (new_h - 600); - int _w = 200; - int _h = 120; + { // Panel_001: anchors top, left, right, bottom + int _x = 580; + int _y = 530; + int _w = 200 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Panel_001.set_bounds(_x, _y, _w, _h); } - { // Image_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 530 + (new_h - 600); - int _w = 160; - int _h = 120; + { // Image_001: anchors top, left, right, bottom + int _x = 10; + int _y = 660; + int _w = 160 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Image_001.set_bounds(_x, _y, _w, _h); } - { // Shape_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 660 + (new_h - 600); - int _w = 160; - int _h = 120; + { // Shape_001: anchors top, left, right, bottom + int _x = 200; + int _y = 660; + int _w = 160 + (new_w - 800); + int _h = 120 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Shape_001.set_bounds(_x, _y, _w, _h); } - { // Notebook_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 660 + (new_h - 600); - int _w = 320; - int _h = 200; + { // Notebook_001: anchors top, left, right, bottom + int _x = 390; + int _y = 660; + int _w = 320 + (new_w - 800); + int _h = 200 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Notebook_001.set_bounds(_x, _y, _w, _h); } - { // ScrollBox_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 660 + (new_h - 600); - int _w = 240; - int _h = 160; + { // ScrollBox_001: anchors top, left, right, bottom + int _x = 580; + int _y = 660; + int _w = 240 + (new_w - 800); + int _h = 160 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; ScrollBox_001.set_bounds(_x, _y, _w, _h); } - { // Splitter_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 660 + (new_h - 600); - int _w = 280; - int _h = 160; + { // Splitter_001: anchors top, left, right, bottom + int _x = 10; + int _y = 790; + int _w = 280 + (new_w - 800); + int _h = 160 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Splitter_001.set_bounds(_x, _y, _w, _h); } - { // StatusBar_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 790 + (new_h - 600); - int _w = 320; - int _h = 24; + { // StatusBar_001: anchors top, left, right, bottom + int _x = 200; + int _y = 790; + int _w = 320 + (new_w - 800); + int _h = 24 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; StatusBar_001.set_bounds(_x, _y, _w, _h); } - { // ToolBar_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 790 + (new_h - 600); - int _w = 320; - int _h = 36; + { // ToolBar_001: anchors top, left, right, bottom + int _x = 390; + int _y = 790; + int _w = 320 + (new_w - 800); + int _h = 36 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; ToolBar_001.set_bounds(_x, _y, _w, _h); } - { // MenuBar_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 790 + (new_h - 600); - int _w = 320; - int _h = 28; + { // MenuBar_001: anchors top, left, right, bottom + int _x = 580; + int _y = 790; + int _w = 320 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; MenuBar_001.set_bounds(_x, _y, _w, _h); } - { // SpinEdit_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 790 + (new_h - 600); - int _w = 120; - int _h = 28; + { // SpinEdit_001: anchors top, left, right, bottom + int _x = 10; + int _y = 920; + int _w = 120 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; SpinEdit_001.set_bounds(_x, _y, _w, _h); } - { // TrackBar_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 920 + (new_h - 600); - int _w = 160; - int _h = 28; + { // TrackBar_001: anchors top, left, right, bottom + int _x = 200; + int _y = 920; + int _w = 160 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; TrackBar_001.set_bounds(_x, _y, _w, _h); } - { // ProgressBar_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 920 + (new_h - 600); - int _w = 200; - int _h = 24; + { // ProgressBar_001: anchors top, left, right, bottom + int _x = 390; + int _y = 920; + int _w = 200 + (new_w - 800); + int _h = 24 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; ProgressBar_001.set_bounds(_x, _y, _w, _h); } - { // DateTimePicker_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 920 + (new_h - 600); - int _w = 240; - int _h = 200; + { // DateTimePicker_001: anchors top, left, right, bottom + int _x = 580; + int _y = 920; + int _w = 240 + (new_w - 800); + int _h = 200 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; DateTimePicker_001.set_bounds(_x, _y, _w, _h); } - { // ColorBox_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 920 + (new_h - 600); - int _w = 120; - int _h = 28; + { // ColorBox_001: anchors top, left, right, bottom + int _x = 10; + int _y = 1050; + int _w = 120 + (new_w - 800); + int _h = 28 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; ColorBox_001.set_bounds(_x, _y, _w, _h); } - { // ListView_001: anchors right, bottom - int _x = 10 + (new_w - 800); - int _y = 1050 + (new_h - 600); - int _w = 240; - int _h = 140; + { // ListView_001: anchors top, left, right, bottom + int _x = 200; + int _y = 1050; + int _w = 240 + (new_w - 800); + int _h = 140 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; ListView_001.set_bounds(_x, _y, _w, _h); } - { // TreeView_001: anchors right, bottom - int _x = 200 + (new_w - 800); - int _y = 1050 + (new_h - 600); - int _w = 240; - int _h = 140; + { // TreeView_001: anchors top, left, right, bottom + int _x = 390; + int _y = 1050; + int _w = 240 + (new_w - 800); + int _h = 140 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; TreeView_001.set_bounds(_x, _y, _w, _h); } - { // StringGrid_001: anchors right, bottom - int _x = 390 + (new_w - 800); - int _y = 1050 + (new_h - 600); - int _w = 280; - int _h = 160; + { // StringGrid_001: anchors top, left, right, bottom + int _x = 580; + int _y = 1050; + int _w = 280 + (new_w - 800); + int _h = 160 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; StringGrid_001.set_bounds(_x, _y, _w, _h); } - { // Plot_001: anchors right, bottom - int _x = 580 + (new_w - 800); - int _y = 1050 + (new_h - 600); - int _w = 280; - int _h = 180; + { // Plot_001: anchors top, left, right, bottom + int _x = 10; + int _y = 1180; + int _w = 280 + (new_w - 800); + int _h = 180 + (new_h - 600); if (_w < 24) _w = 24; if (_h < 16) _h = 16; Plot_001.set_bounds(_x, _y, _w, _h); diff --git a/crates/lightgui-gen/tests/fixtures/04_enum_values/README.md b/crates/lightgui-gen/tests/fixtures/04_enum_values/README.md index d496c83..7d00760 100644 --- a/crates/lightgui-gen/tests/fixtures/04_enum_values/README.md +++ b/crates/lightgui-gen/tests/fixtures/04_enum_values/README.md @@ -30,7 +30,7 @@ Close the window (or its close button) to quit. ## Notes -- Widgets: 21 placed. Each is constructed +- Widgets: 64 placed. Each is constructed as its XFrame class (e.g. `GtkButton`) with the geometry and properties from the design; colours and state use the widgets' getter/setter API where one exists, otherwise a per-widget diff --git a/crates/lightgui-gen/tests/fixtures/04_enum_values/main.cpp b/crates/lightgui-gen/tests/fixtures/04_enum_values/main.cpp index 305da00..d01e233 100644 --- a/crates/lightgui-gen/tests/fixtures/04_enum_values/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/04_enum_values/main.cpp @@ -4,7 +4,7 @@ // or the generated Makefile (make). Both need the XFrame widget // sources; see LIGHTGUI_WIDGETS_DIR in CMakeLists.txt / Makefile. // -// The window is "Main Window" (800x600) with 21 widget(s). +// The window is "Main Window" (800x600) with 64 widget(s). #include "common/registry.h" @@ -92,7 +92,182 @@ int main() { lg::Holder Txt_wrap_3(display, screen, window, gc, &styles, 2610, 10, 220, 120); Txt_wrap_3.w.set_editable(true); Txt_wrap_3.w.set_wrap_mode(true); - std::vector widgets = { &Btn_relief_0, &Btn_relief_1, &Btn_relief_2, &Frm_shadow_0, &Frm_shadow_1, &Frm_shadow_2, &Frm_shadow_3, &Frm_shadow_4, &Lst_sel_0, &Lst_sel_1, &Lst_sel_2, &Lst_sel_3, &Mnu_dir_0, &Mnu_dir_1, &Mnu_dir_2, &Mnu_dir_3, &Mnu_dir_4, &Txt_wrap_0, &Txt_wrap_1, &Txt_wrap_2, &Txt_wrap_3 }; + lg::Holder Btn_kind_0(display, screen, window, gc, &styles, 2740, 10, 100, 30); + Btn_kind_0.w.set_text("Btn_kind_0"); + lg::Holder Btn_kind_1(display, screen, window, gc, &styles, 2870, 10, 100, 30); + Btn_kind_1.w.set_text("Btn_kind_1"); + Btn_kind_1.w.set_kind(1); + lg::Holder Btn_kind_2(display, screen, window, gc, &styles, 3000, 10, 100, 30); + Btn_kind_2.w.set_text("Btn_kind_2"); + Btn_kind_2.w.set_kind(2); + lg::Holder Btn_kind_3(display, screen, window, gc, &styles, 3130, 10, 100, 30); + Btn_kind_3.w.set_text("Btn_kind_3"); + Btn_kind_3.w.set_kind(3); + lg::Holder Btn_kind_4(display, screen, window, gc, &styles, 3260, 10, 100, 30); + Btn_kind_4.w.set_text("Btn_kind_4"); + Btn_kind_4.w.set_kind(4); + lg::Holder Btn_kind_5(display, screen, window, gc, &styles, 3390, 10, 100, 30); + Btn_kind_5.w.set_text("Btn_kind_5"); + Btn_kind_5.w.set_kind(5); + lg::Holder Btn_kind_6(display, screen, window, gc, &styles, 3520, 10, 100, 30); + Btn_kind_6.w.set_text("Btn_kind_6"); + Btn_kind_6.w.set_kind(6); + lg::Holder Btn_kind_7(display, screen, window, gc, &styles, 3650, 10, 100, 30); + Btn_kind_7.w.set_text("Btn_kind_7"); + Btn_kind_7.w.set_kind(7); + lg::Holder Btn_kind_8(display, screen, window, gc, &styles, 3780, 10, 100, 30); + Btn_kind_8.w.set_text("Btn_kind_8"); + Btn_kind_8.w.set_kind(8); + lg::Holder Btn_kind_9(display, screen, window, gc, &styles, 3910, 10, 100, 30); + Btn_kind_9.w.set_text("Btn_kind_9"); + Btn_kind_9.w.set_kind(9); + lg::Holder Btn_layout_0(display, screen, window, gc, &styles, 4040, 10, 100, 30); + Btn_layout_0.w.set_text("Btn_layout_0"); + lg::Holder Btn_layout_1(display, screen, window, gc, &styles, 4170, 10, 100, 30); + Btn_layout_1.w.set_text("Btn_layout_1"); + Btn_layout_1.w.set_layout(1); + lg::Holder Btn_layout_2(display, screen, window, gc, &styles, 4300, 10, 100, 30); + Btn_layout_2.w.set_text("Btn_layout_2"); + Btn_layout_2.w.set_layout(2); + lg::Holder Btn_layout_3(display, screen, window, gc, &styles, 4430, 10, 100, 30); + Btn_layout_3.w.set_text("Btn_layout_3"); + Btn_layout_3.w.set_layout(3); + lg::Holder Ent_align_0(display, screen, window, gc, &styles, 4560, 10, 160, 28); + Ent_align_0.w.set_max_length(0); + Ent_align_0.w.set_editable(true); + lg::Holder Ent_align_1(display, screen, window, gc, &styles, 4690, 10, 160, 28); + Ent_align_1.w.set_max_length(0); + Ent_align_1.w.set_editable(true); + Ent_align_1.w.set_alignment(1); + lg::Holder Ent_align_2(display, screen, window, gc, &styles, 4820, 10, 160, 28); + Ent_align_2.w.set_max_length(0); + Ent_align_2.w.set_editable(true); + Ent_align_2.w.set_alignment(2); + lg::Holder Ent_case_0(display, screen, window, gc, &styles, 4950, 10, 160, 28); + Ent_case_0.w.set_max_length(0); + Ent_case_0.w.set_editable(true); + lg::Holder Ent_case_1(display, screen, window, gc, &styles, 5080, 10, 160, 28); + Ent_case_1.w.set_max_length(0); + Ent_case_1.w.set_editable(true); + Ent_case_1.w.set_char_case(1); + lg::Holder Ent_case_2(display, screen, window, gc, &styles, 5210, 10, 160, 28); + Ent_case_2.w.set_max_length(0); + Ent_case_2.w.set_editable(true); + Ent_case_2.w.set_char_case(2); + lg::Holder Chk_align_0(display, screen, window, gc, &styles, 5340, 10, 120, 26); + Chk_align_0.w.set_text("Chk_align_0"); + Chk_align_0.w.set_active(false); + Chk_align_0.w.set_inconsistent(false); + lg::Holder Chk_align_1(display, screen, window, gc, &styles, 5470, 10, 120, 26); + Chk_align_1.w.set_text("Chk_align_1"); + Chk_align_1.w.set_active(false); + Chk_align_1.w.set_inconsistent(false); + Chk_align_1.w.set_alignment(1); + lg::Holder Cmb_style_0(display, screen, window, gc, &styles, 5600, 10, 160, 28); + Cmb_style_0.w.append_text("Item 1"); + Cmb_style_0.w.append_text("Item 2"); + Cmb_style_0.w.append_text("Item 3"); + Cmb_style_0.w.set_active(0); + lg::Holder Cmb_style_1(display, screen, window, gc, &styles, 5730, 10, 160, 28); + Cmb_style_1.w.append_text("Item 1"); + Cmb_style_1.w.append_text("Item 2"); + Cmb_style_1.w.append_text("Item 3"); + Cmb_style_1.w.set_active(0); + Cmb_style_1.w.set_style(1); + lg::Holder Cmb_style_2(display, screen, window, gc, &styles, 5860, 10, 160, 28); + Cmb_style_2.w.append_text("Item 1"); + Cmb_style_2.w.append_text("Item 2"); + Cmb_style_2.w.append_text("Item 3"); + Cmb_style_2.w.set_active(0); + Cmb_style_2.w.set_style(2); + lg::Holder Scl_ticks_0(display, screen, window, gc, &styles, 5990, 10, 160, 28); + Scl_ticks_0.w.set_range(0.0, 100.0); + Scl_ticks_0.w.set_value(0.0); + Scl_ticks_0.w.set_draw_value(true); + lg::Holder Scl_ticks_1(display, screen, window, gc, &styles, 6120, 10, 160, 28); + Scl_ticks_1.w.set_range(0.0, 100.0); + Scl_ticks_1.w.set_value(0.0); + Scl_ticks_1.w.set_draw_value(true); + Scl_ticks_1.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + lg::Holder Scl_ticks_2(display, screen, window, gc, &styles, 6250, 10, 160, 28); + Scl_ticks_2.w.set_range(0.0, 100.0); + Scl_ticks_2.w.set_value(0.0); + Scl_ticks_2.w.set_draw_value(true); + Scl_ticks_2.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + lg::Holder Scl_ticks_3(display, screen, window, gc, &styles, 6380, 10, 160, 28); + Scl_ticks_3.w.set_range(0.0, 100.0); + Scl_ticks_3.w.set_value(0.0); + Scl_ticks_3.w.set_draw_value(true); + Scl_ticks_3.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + lg::Holder Scr_orient_0(display, screen, window, gc, &styles, 6510, 10, 160, 18); + Scr_orient_0.w.set_upper(100.0); + Scr_orient_0.w.set_page_size(10.0); + Scr_orient_0.w.set_step(1.0); + Scr_orient_0.w.set_value(0.0); + lg::Holder Scr_orient_1(display, screen, window, gc, &styles, 6640, 10, 160, 18); + Scr_orient_1.w.set_upper(100.0); + Scr_orient_1.w.set_page_size(10.0); + Scr_orient_1.w.set_step(1.0); + Scr_orient_1.w.set_value(0.0); + Scr_orient_1.w.set_orientation_vertical(true); + lg::Holder Txt_scroll_0(display, screen, window, gc, &styles, 6770, 10, 220, 120); + Txt_scroll_0.w.set_editable(true); + Txt_scroll_0.w.set_wrap_mode(false); + lg::Holder Txt_scroll_1(display, screen, window, gc, &styles, 6900, 10, 220, 120); + Txt_scroll_1.w.set_editable(true); + Txt_scroll_1.w.set_wrap_mode(false); + Txt_scroll_1.w.set_scroll_bars(1); + lg::Holder Txt_scroll_2(display, screen, window, gc, &styles, 7030, 10, 220, 120); + Txt_scroll_2.w.set_editable(true); + Txt_scroll_2.w.set_wrap_mode(false); + Txt_scroll_2.w.set_scroll_bars(2); + lg::Holder Txt_scroll_3(display, screen, window, gc, &styles, 7160, 10, 220, 120); + Txt_scroll_3.w.set_editable(true); + Txt_scroll_3.w.set_wrap_mode(false); + Txt_scroll_3.w.set_scroll_bars(3); + lg::Holder Mem_scroll_0(display, screen, window, gc, &styles, 7290, 10, 220, 120); + Mem_scroll_0.w.set_editable(true); + Mem_scroll_0.w.set_scroll_bars(0); + Mem_scroll_0.w.set_wordwrap(false); + lg::Holder Mem_scroll_1(display, screen, window, gc, &styles, 7420, 10, 220, 120); + Mem_scroll_1.w.set_editable(true); + Mem_scroll_1.w.set_scroll_bars(1); + Mem_scroll_1.w.set_wordwrap(false); + lg::Holder Mem_scroll_2(display, screen, window, gc, &styles, 7550, 10, 220, 120); + Mem_scroll_2.w.set_editable(true); + Mem_scroll_2.w.set_scroll_bars(2); + Mem_scroll_2.w.set_wordwrap(false); + lg::Holder Mem_scroll_3(display, screen, window, gc, &styles, 7680, 10, 220, 120); + Mem_scroll_3.w.set_editable(true); + Mem_scroll_3.w.set_wordwrap(false); + lg::Holder Trk_ticks_0(display, screen, window, gc, &styles, 7810, 10, 160, 28); + Trk_ticks_0.w.set_range(0.0, 100.0); + Trk_ticks_0.w.set_step(1.0); + Trk_ticks_0.w.set_value(0.0); + Trk_ticks_0.w.set_draw_value(true); + Trk_ticks_0.w.set_orientation_vertical(false); + lg::Holder Trk_ticks_1(display, screen, window, gc, &styles, 7940, 10, 160, 28); + Trk_ticks_1.w.set_range(0.0, 100.0); + Trk_ticks_1.w.set_step(1.0); + Trk_ticks_1.w.set_value(0.0); + Trk_ticks_1.w.set_draw_value(true); + Trk_ticks_1.w.set_orientation_vertical(false); + Trk_ticks_1.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + lg::Holder Trk_ticks_2(display, screen, window, gc, &styles, 8070, 10, 160, 28); + Trk_ticks_2.w.set_range(0.0, 100.0); + Trk_ticks_2.w.set_step(1.0); + Trk_ticks_2.w.set_value(0.0); + Trk_ticks_2.w.set_draw_value(true); + Trk_ticks_2.w.set_orientation_vertical(false); + Trk_ticks_2.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + lg::Holder Trk_ticks_3(display, screen, window, gc, &styles, 8200, 10, 160, 28); + Trk_ticks_3.w.set_range(0.0, 100.0); + Trk_ticks_3.w.set_step(1.0); + Trk_ticks_3.w.set_value(0.0); + Trk_ticks_3.w.set_draw_value(true); + Trk_ticks_3.w.set_orientation_vertical(false); + Trk_ticks_3.w.set_marks({0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}); + std::vector widgets = { &Btn_relief_0, &Btn_relief_1, &Btn_relief_2, &Frm_shadow_0, &Frm_shadow_1, &Frm_shadow_2, &Frm_shadow_3, &Frm_shadow_4, &Lst_sel_0, &Lst_sel_1, &Lst_sel_2, &Lst_sel_3, &Mnu_dir_0, &Mnu_dir_1, &Mnu_dir_2, &Mnu_dir_3, &Mnu_dir_4, &Txt_wrap_0, &Txt_wrap_1, &Txt_wrap_2, &Txt_wrap_3, &Btn_kind_0, &Btn_kind_1, &Btn_kind_2, &Btn_kind_3, &Btn_kind_4, &Btn_kind_5, &Btn_kind_6, &Btn_kind_7, &Btn_kind_8, &Btn_kind_9, &Btn_layout_0, &Btn_layout_1, &Btn_layout_2, &Btn_layout_3, &Ent_align_0, &Ent_align_1, &Ent_align_2, &Ent_case_0, &Ent_case_1, &Ent_case_2, &Chk_align_0, &Chk_align_1, &Cmb_style_0, &Cmb_style_1, &Cmb_style_2, &Scl_ticks_0, &Scl_ticks_1, &Scl_ticks_2, &Scl_ticks_3, &Scr_orient_0, &Scr_orient_1, &Txt_scroll_0, &Txt_scroll_1, &Txt_scroll_2, &Txt_scroll_3, &Mem_scroll_0, &Mem_scroll_1, &Mem_scroll_2, &Mem_scroll_3, &Trk_ticks_0, &Trk_ticks_1, &Trk_ticks_2, &Trk_ticks_3 }; auto redraw_all = [&]() { XClearWindow(display, window); for (lg::IWidget* wd : widgets) wd->draw(); diff --git a/crates/lightgui-gen/tests/fixtures/06_hostile_strings/main.cpp b/crates/lightgui-gen/tests/fixtures/06_hostile_strings/main.cpp index efa914b..83c604e 100644 --- a/crates/lightgui-gen/tests/fixtures/06_hostile_strings/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/06_hostile_strings/main.cpp @@ -50,8 +50,10 @@ int main() { lg::Holder Label_001(display, screen, window, gc, &styles, 10, 60, 100, 24); Label_001.w.set_text("café — ☕\t tabbed"); Label_001.w.set_xalign(0.5); + Label_001.w.set_yalign(0.5); Label_001.w.set_wrap(false); Label_001.w.set_selectable(false); + Label_001.w.set_transparent(false); lg::Holder Entry_001(display, screen, window, gc, &styles, 10, 110, 160, 28); Entry_001.w.set_text("a\"b\\c\nd"); Entry_001.w.set_placeholder_text("type \"here\""); diff --git a/crates/lightgui-gen/tests/fixtures/08_class_digit/main.cpp b/crates/lightgui-gen/tests/fixtures/08_class_digit/main.cpp index b7c31a3..2f9bc40 100644 --- a/crates/lightgui-gen/tests/fixtures/08_class_digit/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/08_class_digit/main.cpp @@ -36,8 +36,10 @@ int main() { lg::Holder Label_001(display, screen, window, gc, &styles, 10, 10, 100, 24); Label_001.w.set_text("Label_001"); Label_001.w.set_xalign(0.5); + Label_001.w.set_yalign(0.5); Label_001.w.set_wrap(false); Label_001.w.set_selectable(false); + Label_001.w.set_transparent(false); std::vector widgets = { &Label_001 }; auto redraw_all = [&]() { XClearWindow(display, window); diff --git a/crates/lightgui-gen/tests/fixtures/10_spreadsheet_toplevels/main.cpp b/crates/lightgui-gen/tests/fixtures/10_spreadsheet_toplevels/main.cpp index 41354f7..144beb5 100644 --- a/crates/lightgui-gen/tests/fixtures/10_spreadsheet_toplevels/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/10_spreadsheet_toplevels/main.cpp @@ -35,6 +35,7 @@ int main() { styles.set_active_style_byName("default"); lg::Holder Spreadsheet_001(display, screen, window, gc, &styles, 10, 10, 900, 500); Spreadsheet_001.w.set_size(26, 50); + // NOTE (model-only, no XFrame setter): columns=26 lg::Holder Spreadsheet_002(display, screen, window, gc, &styles, 10, 520, 320, 180); Spreadsheet_002.w.set_size(1, 1); lg::Holder Toplevel_001(display, screen, window, gc, &styles, 100, 100, 300, 200); diff --git a/crates/lightgui-gen/tests/fixtures/11_forty_widgets/main.cpp b/crates/lightgui-gen/tests/fixtures/11_forty_widgets/main.cpp index 98ee84c..37bc800 100644 --- a/crates/lightgui-gen/tests/fixtures/11_forty_widgets/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/11_forty_widgets/main.cpp @@ -38,8 +38,10 @@ int main() { lg::Holder Label_002(display, screen, window, gc, &styles, 180, 10, 100, 24); Label_002.w.set_text("Label_002"); Label_002.w.set_xalign(0.5); + Label_002.w.set_yalign(0.5); Label_002.w.set_wrap(false); Label_002.w.set_selectable(false); + Label_002.w.set_transparent(false); lg::Holder Entry_003(display, screen, window, gc, &styles, 350, 10, 160, 28); Entry_003.w.set_max_length(0); Entry_003.w.set_editable(true); @@ -55,6 +57,7 @@ int main() { Combobox_006.w.append_text("Item 3"); Combobox_006.w.set_active(0); lg::Holder Scale_007(display, screen, window, gc, &styles, 180, 80, 160, 28); + Scale_007.w.set_range(0.0, 100.0); Scale_007.w.set_value(0.0); Scale_007.w.set_draw_value(true); lg::Holder Text_008(display, screen, window, gc, &styles, 350, 80, 220, 120); @@ -65,8 +68,10 @@ int main() { lg::Holder Label_010(display, screen, window, gc, &styles, 690, 80, 100, 24); Label_010.w.set_text("Label_010"); Label_010.w.set_xalign(0.5); + Label_010.w.set_yalign(0.5); Label_010.w.set_wrap(false); Label_010.w.set_selectable(false); + Label_010.w.set_transparent(false); lg::Holder Entry_011(display, screen, window, gc, &styles, 10, 150, 160, 28); Entry_011.w.set_max_length(0); Entry_011.w.set_editable(true); @@ -82,6 +87,7 @@ int main() { Combobox_014.w.append_text("Item 3"); Combobox_014.w.set_active(0); lg::Holder Scale_015(display, screen, window, gc, &styles, 690, 150, 160, 28); + Scale_015.w.set_range(0.0, 100.0); Scale_015.w.set_value(0.0); Scale_015.w.set_draw_value(true); lg::Holder Text_016(display, screen, window, gc, &styles, 10, 220, 220, 120); @@ -92,8 +98,10 @@ int main() { lg::Holder Label_018(display, screen, window, gc, &styles, 350, 220, 100, 24); Label_018.w.set_text("Label_018"); Label_018.w.set_xalign(0.5); + Label_018.w.set_yalign(0.5); Label_018.w.set_wrap(false); Label_018.w.set_selectable(false); + Label_018.w.set_transparent(false); lg::Holder Entry_019(display, screen, window, gc, &styles, 520, 220, 160, 28); Entry_019.w.set_max_length(0); Entry_019.w.set_editable(true); @@ -109,6 +117,7 @@ int main() { Combobox_022.w.append_text("Item 3"); Combobox_022.w.set_active(0); lg::Holder Scale_023(display, screen, window, gc, &styles, 350, 290, 160, 28); + Scale_023.w.set_range(0.0, 100.0); Scale_023.w.set_value(0.0); Scale_023.w.set_draw_value(true); lg::Holder Text_024(display, screen, window, gc, &styles, 520, 290, 220, 120); @@ -119,8 +128,10 @@ int main() { lg::Holder Label_026(display, screen, window, gc, &styles, 10, 360, 100, 24); Label_026.w.set_text("Label_026"); Label_026.w.set_xalign(0.5); + Label_026.w.set_yalign(0.5); Label_026.w.set_wrap(false); Label_026.w.set_selectable(false); + Label_026.w.set_transparent(false); lg::Holder Entry_027(display, screen, window, gc, &styles, 180, 360, 160, 28); Entry_027.w.set_max_length(0); Entry_027.w.set_editable(true); @@ -136,6 +147,7 @@ int main() { Combobox_030.w.append_text("Item 3"); Combobox_030.w.set_active(0); lg::Holder Scale_031(display, screen, window, gc, &styles, 10, 430, 160, 28); + Scale_031.w.set_range(0.0, 100.0); Scale_031.w.set_value(0.0); Scale_031.w.set_draw_value(true); lg::Holder Text_032(display, screen, window, gc, &styles, 180, 430, 220, 120); @@ -146,8 +158,10 @@ int main() { lg::Holder Label_034(display, screen, window, gc, &styles, 520, 430, 100, 24); Label_034.w.set_text("Label_034"); Label_034.w.set_xalign(0.5); + Label_034.w.set_yalign(0.5); Label_034.w.set_wrap(false); Label_034.w.set_selectable(false); + Label_034.w.set_transparent(false); lg::Holder Entry_035(display, screen, window, gc, &styles, 690, 430, 160, 28); Entry_035.w.set_max_length(0); Entry_035.w.set_editable(true); @@ -163,6 +177,7 @@ int main() { Combobox_038.w.append_text("Item 3"); Combobox_038.w.set_active(0); lg::Holder Scale_039(display, screen, window, gc, &styles, 520, 500, 160, 28); + Scale_039.w.set_range(0.0, 100.0); Scale_039.w.set_value(0.0); Scale_039.w.set_draw_value(true); lg::Holder Text_040(display, screen, window, gc, &styles, 690, 500, 220, 120); diff --git a/crates/lightgui-gen/tests/fixtures/12_window_huge/main.cpp b/crates/lightgui-gen/tests/fixtures/12_window_huge/main.cpp index 3459340..ed5b486 100644 --- a/crates/lightgui-gen/tests/fixtures/12_window_huge/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/12_window_huge/main.cpp @@ -36,8 +36,10 @@ int main() { lg::Holder Label_001(display, screen, window, gc, &styles, 10, 10, 100, 24); Label_001.w.set_text("Label_001"); Label_001.w.set_xalign(0.5); + Label_001.w.set_yalign(0.5); Label_001.w.set_wrap(false); Label_001.w.set_selectable(false); + Label_001.w.set_transparent(false); std::vector widgets = { &Label_001 }; auto redraw_all = [&]() { XClearWindow(display, window); diff --git a/crates/lightgui-gen/tests/fixtures/14_stockchart/main.cpp b/crates/lightgui-gen/tests/fixtures/14_stockchart/main.cpp index c919f18..e75f9b1 100644 --- a/crates/lightgui-gen/tests/fixtures/14_stockchart/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/14_stockchart/main.cpp @@ -37,13 +37,15 @@ int main() { StockChart_001.w.set_up_color(Srgb{0, 200, 0}); StockChart_001.w.set_down_color(Srgb{220, 0, 0}); // NOTE: StockChart design data not representable through the StockCandlestickChart API: - // data-file: "/tmp/genprobe3/14_stockchart/SPY_fake.csv" + // data-file: "/opt/lightgui/tests/out/14_stockchart/SPY_fake.csv" // scale-mode: 0 (0 = price, 1 = percent) lg::Holder Label_001(display, screen, window, gc, &styles, 10, 340, 100, 24); Label_001.w.set_text("Label_001"); Label_001.w.set_xalign(0.5); + Label_001.w.set_yalign(0.5); Label_001.w.set_wrap(false); Label_001.w.set_selectable(false); + Label_001.w.set_transparent(false); std::vector widgets = { &StockChart_001, &Label_001 }; auto redraw_all = [&]() { XClearWindow(display, window); diff --git a/crates/lightgui-gen/tests/fixtures/15_stockchart_indicators/main.cpp b/crates/lightgui-gen/tests/fixtures/15_stockchart_indicators/main.cpp index 682e0bf..cfbffb7 100644 --- a/crates/lightgui-gen/tests/fixtures/15_stockchart_indicators/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/15_stockchart_indicators/main.cpp @@ -37,7 +37,7 @@ int main() { StockChart_001.w.set_up_color(Srgb{0, 200, 0}); StockChart_001.w.set_down_color(Srgb{220, 0, 0}); // NOTE: StockChart design data not representable through the StockCandlestickChart API: - // data-file: "/tmp/genprobe3/15_stockchart_indicators/SPY_fake_long.csv" + // data-file: "/opt/lightgui/tests/out/15_stockchart_indicators/SPY_fake_long.csv" // indicators: "SMA(20), EMA(50), Bollinger Bands, RSI, MACD, Engulfing" // scale-mode: 0 (0 = price, 1 = percent) std::vector widgets = { &StockChart_001 }; diff --git a/crates/lightgui-gen/tests/fixtures/16_stockchart_pro/main.cpp b/crates/lightgui-gen/tests/fixtures/16_stockchart_pro/main.cpp index 4c594e5..0b79629 100644 --- a/crates/lightgui-gen/tests/fixtures/16_stockchart_pro/main.cpp +++ b/crates/lightgui-gen/tests/fixtures/16_stockchart_pro/main.cpp @@ -37,10 +37,10 @@ int main() { StockChart_001.w.set_up_color(Srgb{0, 200, 0}); StockChart_001.w.set_down_color(Srgb{220, 0, 0}); // NOTE: StockChart design data not representable through the StockCandlestickChart API: - // data-file: "/tmp/genprobe3/16_stockchart_pro/SPY_fake_long.csv" + // data-file: "/opt/lightgui/tests/out/16_stockchart_pro/SPY_fake_long.csv" // indicators: "SMA(20), RSI" // drawings: "trend 790 676 1150 690 red; hline 688 blue; fib 800 674 1000 692 purple; text 830 691 orange Resistance zone; rect 860 678 960 684 teal; arrow 920 690 1090 680 magenta; measure 840 677 1010 689 black" - // compare-files: "/tmp/genprobe3/16_stockchart_pro/QQQ_fake_long.csv" + // compare-files: "/opt/lightgui/tests/out/16_stockchart_pro/QQQ_fake_long.csv" // scale-mode: 1 (0 = price, 1 = percent) std::vector widgets = { &StockChart_001 }; auto redraw_all = [&]() { diff --git a/crates/lightgui-gen/tests/fixtures_test.rs b/crates/lightgui-gen/tests/fixtures_test.rs index 05d5530..9966d0a 100644 --- a/crates/lightgui-gen/tests/fixtures_test.rs +++ b/crates/lightgui-gen/tests/fixtures_test.rs @@ -118,9 +118,13 @@ fn build_cases() -> Vec<(String, Project)> { } fmt_g(v) } - // The C++ loop `for (k = 0; values[k]; ++k)` never - // runs: every table starts with 0 — so this is "0". - PropKind::Enum => "0".to_string(), + // Last value in the table (the values array is + // not 0-terminated; every table starts at 0). + PropKind::Enum => d + .enum_values + .and_then(|v| v.last()) + .map(|v| v.to_string()) + .unwrap_or_else(|| "0".to_string()), PropKind::Color => "#336699".to_string(), }; w.props.insert(d.name.to_string(), v); @@ -197,6 +201,100 @@ fn build_cases() -> Vec<(String, Project)> { &v.to_string(), ); } + // Phase 2 enums: every value of every new enum prop. + for v in 0..=9 { + add(&mut p, "Button", format!("Btn_kind_{v}"), "kind", &v.to_string()); + } + for v in 0..=3 { + add( + &mut p, + "Button", + format!("Btn_layout_{v}"), + "layout", + &v.to_string(), + ); + } + for v in 0..=2 { + add( + &mut p, + "Entry", + format!("Ent_align_{v}"), + "alignment", + &v.to_string(), + ); + } + for v in 0..=2 { + add( + &mut p, + "Entry", + format!("Ent_case_{v}"), + "char-case", + &v.to_string(), + ); + } + for v in 0..=1 { + add( + &mut p, + "Checkbutton", + format!("Chk_align_{v}"), + "alignment", + &v.to_string(), + ); + } + for v in 0..=2 { + add( + &mut p, + "Combobox", + format!("Cmb_style_{v}"), + "style", + &v.to_string(), + ); + } + for v in 0..=3 { + add( + &mut p, + "Scale", + format!("Scl_ticks_{v}"), + "tick-marks", + &v.to_string(), + ); + } + for v in 0..=1 { + add( + &mut p, + "Scrollbar", + format!("Scr_orient_{v}"), + "orientation", + &v.to_string(), + ); + } + for v in 0..=3 { + add( + &mut p, + "Text", + format!("Txt_scroll_{v}"), + "scroll-bars", + &v.to_string(), + ); + } + for v in 0..=3 { + add( + &mut p, + "Memo", + format!("Mem_scroll_{v}"), + "scroll-bars", + &v.to_string(), + ); + } + for v in 0..=3 { + add( + &mut p, + "TrackBar", + format!("Trk_ticks_{v}"), + "tick-marks", + &v.to_string(), + ); + } cases.push(("04_enum_values".to_string(), p)); }