Phase 3: generator emits new props (Shape as TShape, ToggleButton, root window position/state/border-style)
This commit is contained in:
1 parent
bd620a41d9
commit
bffb69b18f
1 file changed
+589
-10
+589
-10
@@ -343,6 +343,14 @@ static K_XFRAME_MAP: &[XFrameMap] = &[
|
||||
fill_srgb: false,
|
||||
text_srgb: false,
|
||||
},
|
||||
XFrameMap {
|
||||
key: "ToggleButton",
|
||||
cls: "GtkToggleButton",
|
||||
fill: "",
|
||||
text: "",
|
||||
fill_srgb: false,
|
||||
text_srgb: false,
|
||||
},
|
||||
XFrameMap {
|
||||
key: "Radiobutton",
|
||||
cls: "GtkRadioButton",
|
||||
@@ -481,7 +489,7 @@ static K_XFRAME_MAP: &[XFrameMap] = &[
|
||||
},
|
||||
XFrameMap {
|
||||
key: "Shape",
|
||||
cls: "GtkDrawingArea",
|
||||
cls: "TShape",
|
||||
fill: "",
|
||||
text: "",
|
||||
fill_srgb: false,
|
||||
@@ -853,6 +861,24 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
esc_c(&prop_or(w, "label", ""))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("label-xalign") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_label_xalign({});\n",
|
||||
fmt_double(&prop_or(w, "label-xalign", "0"))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("inset") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_inset({});\n",
|
||||
prop_int(w, "inset", 8)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("top-inset") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_top_inset({});\n",
|
||||
prop_int(w, "top-inset", 14)
|
||||
));
|
||||
}
|
||||
} else if t == "StatusBar" {
|
||||
if has("text") {
|
||||
o.push_str(&format!(
|
||||
@@ -860,6 +886,22 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
esc_c(&prop_or(w, "text", ""))
|
||||
));
|
||||
}
|
||||
if has("panels") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_items(\"{}\");\n",
|
||||
esc_c(&prop_or(w, "panels", ""))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("size-grip") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_size_grip({});\n",
|
||||
if prop_bool(w, "size-grip", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if has("label") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_text(\"{}\");\n",
|
||||
@@ -1039,6 +1081,43 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
esc_c(&prop_or(w, "value-unchecked", ""))
|
||||
));
|
||||
}
|
||||
} else if t == "ToggleButton" {
|
||||
if w.props.contains_key("active") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_active({});\n",
|
||||
if prop_bool(w, "active", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("group-index") && prop_int(w, "group-index", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_group_index({});\n",
|
||||
prop_int(w, "group-index", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("allow-all-up") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_allow_all_up({});\n",
|
||||
if prop_bool(w, "allow-all-up", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("flat") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_flat({});\n",
|
||||
if prop_bool(w, "flat", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if t == "Radiobutton" {
|
||||
let grp = prop_int(w, "group", 0);
|
||||
if grp != 0 {
|
||||
@@ -1388,6 +1467,24 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
prop_int(w, "page", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("tab-height") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_tab_height({});\n",
|
||||
prop_int(w, "tab-height", 26)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("tab-position") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_tab_position({});\n",
|
||||
prop_int(w, "tab-position", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("tab-width") && prop_int(w, "tab-width", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_tab_width({});\n",
|
||||
prop_int(w, "tab-width", 0)
|
||||
));
|
||||
}
|
||||
} else if t == "Splitter" {
|
||||
if w.props.contains_key("position") {
|
||||
o.push_str(&format!(
|
||||
@@ -1401,6 +1498,28 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
prop_int(w, "orientation", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("min-size") && prop_int(w, "min-size", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_min_size({});\n",
|
||||
prop_int(w, "min-size", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("resize-style") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_resize_style({});\n",
|
||||
prop_int(w, "resize-style", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("auto-snap") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_auto_snap({});\n",
|
||||
if prop_bool(w, "auto-snap", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if t == "ToolBar" {
|
||||
if has("items") {
|
||||
o.push_str(&format!(" {var}.w.set_items({{"));
|
||||
@@ -1414,6 +1533,38 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
o.push_str("});\n");
|
||||
}
|
||||
if w.props.contains_key("show-captions") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_show_captions({});\n",
|
||||
if prop_bool(w, "show-captions", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("flat") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_flat({});\n",
|
||||
if prop_bool(w, "flat", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("button-width") && prop_int(w, "button-width", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_button_width({});\n",
|
||||
prop_int(w, "button-width", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("button-height") && prop_int(w, "button-height", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_button_height({});\n",
|
||||
prop_int(w, "button-height", 0)
|
||||
));
|
||||
}
|
||||
} else if t == "MenuBar" {
|
||||
if has("menus") {
|
||||
o.push_str(&format!(" {var}.w.set_items({{"));
|
||||
@@ -1465,6 +1616,16 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("editor-enabled") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_editable({});\n",
|
||||
if prop_bool(w, "editor-enabled", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if t == "TrackBar" {
|
||||
let lo = prop_int(w, "minimum", 0);
|
||||
let hi = prop_int(w, "maximum", 100);
|
||||
@@ -1542,12 +1703,37 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
));
|
||||
}
|
||||
} else if t == "ProgressBar" {
|
||||
if w.props.contains_key("fraction") {
|
||||
if w.props.contains_key("minimum") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_min({});\n",
|
||||
fmt_double(&prop_or(w, "minimum", "0"))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("maximum") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_max({});\n",
|
||||
fmt_double(&prop_or(w, "maximum", "100"))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("position") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_position({});\n",
|
||||
fmt_double(&prop_or(w, "position", "45"))
|
||||
));
|
||||
} else if w.props.contains_key("fraction") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_fraction({});\n",
|
||||
fmt_double(&prop_or(w, "fraction", "0"))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("step")
|
||||
&& prop_or(w, "step", "1").parse::<f64>().unwrap_or(1.0) != 1.0
|
||||
{
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_step({});\n",
|
||||
fmt_double(&prop_or(w, "step", "1"))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("show-text") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_show_text({});\n",
|
||||
@@ -1558,6 +1744,34 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("pulsing") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_pulsing({});\n",
|
||||
if prop_bool(w, "pulsing", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("inverted") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_inverted({});\n",
|
||||
if prop_bool(w, "inverted", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
let bar = prop_rgb_args(w, "bar-color");
|
||||
if !bar.is_empty() {
|
||||
emit_color_call(o, var, "set_bar_color_rgb", false, &bar);
|
||||
}
|
||||
let trough = prop_rgb_args(w, "trough-color");
|
||||
if !trough.is_empty() {
|
||||
emit_color_call(o, var, "set_trough_color_rgb", false, &trough);
|
||||
}
|
||||
} else if t == "DateTimePicker" {
|
||||
if has("date") {
|
||||
let date = prop_or(w, "date", "");
|
||||
@@ -1592,17 +1806,123 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("show-week-numbers") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_show_week_numbers({});\n",
|
||||
if prop_bool(w, "show-week-numbers", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
let gc = prop_rgb_args(w, "grid-color");
|
||||
if !gc.is_empty() {
|
||||
emit_color_call(o, var, "set_grid_color_rgb", false, &gc);
|
||||
}
|
||||
let sf = prop_rgb_args(w, "selected-fill-color");
|
||||
if !sf.is_empty() {
|
||||
emit_color_call(o, var, "set_selected_fill_color_rgb", false, &sf);
|
||||
}
|
||||
let st = prop_rgb_args(w, "selected-text-color");
|
||||
if !st.is_empty() {
|
||||
emit_color_call(o, var, "set_selected_text_color_rgb", false, &st);
|
||||
}
|
||||
let tc = prop_rgb_args(w, "today-color");
|
||||
if !tc.is_empty() {
|
||||
emit_color_call(o, var, "set_today_color_rgb", false, &tc);
|
||||
}
|
||||
let dc = prop_rgb_args(w, "dim-text-color");
|
||||
if !dc.is_empty() {
|
||||
emit_color_call(o, var, "set_dim_text_color_rgb", false, &dc);
|
||||
}
|
||||
let wc = prop_rgb_args(w, "weekends-color");
|
||||
if !wc.is_empty() {
|
||||
emit_color_call(o, var, "set_weekends_color_rgb", false, &wc);
|
||||
}
|
||||
let xc = prop_rgb_args(w, "disabled-color");
|
||||
if !xc.is_empty() {
|
||||
emit_color_call(o, var, "set_disabled_color_rgb", false, &xc);
|
||||
}
|
||||
} else if t == "ColorBox" {
|
||||
let rgb = prop_rgb_args(w, "color");
|
||||
if !rgb.is_empty() {
|
||||
emit_color_call(o, var, "set_color_rgb", false, &rgb);
|
||||
}
|
||||
if w.props.contains_key("style") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_style({});\n",
|
||||
prop_int(w, "style", 0)
|
||||
));
|
||||
}
|
||||
let dcrgb = prop_rgb_args(w, "default-color");
|
||||
if !dcrgb.is_empty() {
|
||||
emit_color_call(o, var, "set_default_color_rgb", false, &dcrgb);
|
||||
}
|
||||
let ncrgb = prop_rgb_args(w, "none-color");
|
||||
if !ncrgb.is_empty() {
|
||||
emit_color_call(o, var, "set_none_color_rgb", false, &ncrgb);
|
||||
}
|
||||
} else if t == "ListView" {
|
||||
if has("items") {
|
||||
for row in split_on(';', &prop_or(w, "items", "")) {
|
||||
o.push_str(&format!(" {var}.w.add_item(\"{}\");\n", esc_c(&row)));
|
||||
}
|
||||
}
|
||||
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)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("view-style") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_view_style({});\n",
|
||||
prop_int(w, "view-style", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("grid-lines") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_grid_lines({});\n",
|
||||
if prop_bool(w, "grid-lines", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("row-select") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_row_select({});\n",
|
||||
if prop_bool(w, "row-select", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("multi-select") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_multi_select({});\n",
|
||||
if prop_bool(w, "multi-select", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("sort-type") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_sort_type({});\n",
|
||||
prop_int(w, "sort-type", 0)
|
||||
));
|
||||
}
|
||||
} else if t == "TreeView" {
|
||||
if has("items") {
|
||||
let mut roots: Vec<String> = Vec::new();
|
||||
@@ -1623,12 +1943,142 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
o.push_str("});\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 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)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("header-height") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_header_height({});\n",
|
||||
prop_int(w, "header-height", 22)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("headers-visible") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_headers_visible({});\n",
|
||||
if prop_bool(w, "headers-visible", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("grid-lines") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_grid_lines({});\n",
|
||||
if prop_bool(w, "grid-lines", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("row-select") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_row_select({});\n",
|
||||
if prop_bool(w, "row-select", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("multi-select") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_multi_select({});\n",
|
||||
if prop_bool(w, "multi-select", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("sort-type") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_sort_type({});\n",
|
||||
prop_int(w, "sort-type", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("indent") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_indent({});\n",
|
||||
prop_int(w, "indent", 16)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("show-buttons") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_show_buttons({});\n",
|
||||
if prop_bool(w, "show-buttons", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("show-lines") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_show_lines({});\n",
|
||||
if prop_bool(w, "show-lines", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("show-root") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_show_root({});\n",
|
||||
if prop_bool(w, "show-root", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if t == "Spreadsheet" || t == "StringGrid" {
|
||||
let cols = prop_int(w, "columns", 4);
|
||||
let rows = prop_int(w, "rows", 5);
|
||||
if w.props.contains_key("columns") || w.props.contains_key("rows") {
|
||||
o.push_str(&format!(" {var}.w.set_size({cols}, {rows});\n"));
|
||||
}
|
||||
if w.props.contains_key("fixed-cols") && prop_int(w, "fixed-cols", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_frozen_cols({});\n",
|
||||
prop_int(w, "fixed-cols", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("fixed-rows") && prop_int(w, "fixed-rows", 0) != 0 {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_frozen_rows({});\n",
|
||||
prop_int(w, "fixed-rows", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("default-col-width") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_default_col_width({});\n",
|
||||
prop_int(w, "default-col-width", 84)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("default-row-height") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_row_height({});\n",
|
||||
prop_int(w, "default-row-height", 20)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("grid-line-width") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_grid_line_width({});\n",
|
||||
prop_int(w, "grid-line-width", 1)
|
||||
));
|
||||
}
|
||||
} else if t == "Toplevel" {
|
||||
if has("title") {
|
||||
o.push_str(&format!(
|
||||
@@ -1648,6 +2098,30 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("border-style") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_border_style({});\n",
|
||||
prop_int(w, "border-style", 0)
|
||||
));
|
||||
}
|
||||
if has("icon") {
|
||||
o.push_str(&format!(
|
||||
" // NOTE: icon \"{}\" is not loaded by the generated app.\n",
|
||||
esc_c(&prop_or(w, "icon", ""))
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("position") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_position({});\n",
|
||||
prop_int(w, "position", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("window-state") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_window_state({});\n",
|
||||
prop_int(w, "window-state", 0)
|
||||
));
|
||||
}
|
||||
} else if t == "Image" {
|
||||
if has("file") {
|
||||
o.push_str(&format!(
|
||||
@@ -1661,6 +2135,46 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
prop_int(w, "pixel-size", -1)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("stretch") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_stretch({});\n",
|
||||
if prop_bool(w, "stretch", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("proportional") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_proportional({});\n",
|
||||
if prop_bool(w, "proportional", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("center") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_center({});\n",
|
||||
if prop_bool(w, "center", true) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("transparent") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_transparent({});\n",
|
||||
if prop_bool(w, "transparent", false) {
|
||||
"true"
|
||||
} else {
|
||||
"false"
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if t == "StockChart" {
|
||||
// StockCandlestickChart draws its seeded preview series; the old
|
||||
// GTK chart's CSV/indicator/drawing engine has no counterpart in
|
||||
@@ -1713,11 +2227,26 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
}
|
||||
}
|
||||
} else if t == "Shape" {
|
||||
o.push_str(&format!(
|
||||
" // NOTE: Shape (\"{}\", fill \"{}\") has no XFrame counterpart; drawn as a plain area.\n",
|
||||
esc_c(&prop_or(w, "shape", "0")),
|
||||
esc_c(&prop_or(w, "fill-color", ""))
|
||||
));
|
||||
if w.props.contains_key("shape") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_shape({});\n",
|
||||
prop_int(w, "shape", 0)
|
||||
));
|
||||
}
|
||||
let sfill = prop_rgb_args(w, "fill-color");
|
||||
if !sfill.is_empty() {
|
||||
emit_color_call(o, var, "set_fill_color", true, &sfill);
|
||||
}
|
||||
let spen = prop_rgb_args(w, "pen-color");
|
||||
if !spen.is_empty() {
|
||||
emit_color_call(o, var, "set_pen_color", true, &spen);
|
||||
}
|
||||
if w.props.contains_key("pen-width") {
|
||||
o.push_str(&format!(
|
||||
" {var}.w.set_pen_width({});\n",
|
||||
prop_int(w, "pen-width", 2)
|
||||
));
|
||||
}
|
||||
} else if t == "Canvas" {
|
||||
o.push_str(" // NOTE: Canvas has no XFrame counterpart; drawn as a plain area.\n");
|
||||
} else if t == "Plot" {
|
||||
@@ -1800,6 +2329,18 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind:
|
||||
esc_c(&prop_or(w, "focus-control", ""))
|
||||
));
|
||||
}
|
||||
if t == "ListView" && w.props.contains_key("headers-visible") && !prop_bool(w, "headers-visible", true) {
|
||||
notes.push("headers-visible=false (no ListView header API)".to_string());
|
||||
}
|
||||
if t == "StringGrid" && w.props.contains_key("headers-visible") && !prop_bool(w, "headers-visible", true) {
|
||||
notes.push("headers-visible=false (grid headers always shown)".to_string());
|
||||
}
|
||||
if t == "ToggleButton" && prop_int(w, "group-index", 0) != 0 {
|
||||
notes.push(format!(
|
||||
"group-index={} (no cross-widget group yet)",
|
||||
prop_int(w, "group-index", 0)
|
||||
));
|
||||
}
|
||||
if w.props.contains_key("columns") && prop_int(w, "columns", 1) != 1 {
|
||||
notes.push(format!("columns={}", prop_int(w, "columns", 1)));
|
||||
}
|
||||
@@ -2323,9 +2864,30 @@ fn emit_main_cpp(project: &Project, widgets: &[Widget]) -> String {
|
||||
);
|
||||
o.push_str(" int screen = DefaultScreen(display);\n");
|
||||
o.push_str(" Window root = RootWindow(display, screen);\n");
|
||||
o.push_str(&format!(
|
||||
" Window window = XCreateSimpleWindow(display, root, 100, 100, {win_w}, {win_h}, 1, BlackPixel(display, screen), "
|
||||
));
|
||||
// Phase 3 (§2.20): window position / border style / state from
|
||||
// the project. Defaults (0) emit the old fixed behaviour.
|
||||
if project.position != 0 {
|
||||
o.push_str(&format!(
|
||||
" int win_x = (DisplayWidth(display, screen) - {win_w}) / 2;\n"
|
||||
));
|
||||
o.push_str(&format!(
|
||||
" int win_y = (DisplayHeight(display, screen) - {win_h}) / 2;\n"
|
||||
));
|
||||
}
|
||||
if project.window_state == 2 {
|
||||
o.push_str(" int create_w = DisplayWidth(display, screen);\n");
|
||||
o.push_str(" int create_h = DisplayHeight(display, screen);\n");
|
||||
}
|
||||
if project.position != 0 {
|
||||
o.push_str(" Window window = XCreateSimpleWindow(display, root, win_x, win_y, ");
|
||||
} else {
|
||||
o.push_str(" Window window = XCreateSimpleWindow(display, root, 100, 100, ");
|
||||
}
|
||||
if project.window_state == 2 {
|
||||
o.push_str("create_w, create_h, 1, BlackPixel(display, screen), ");
|
||||
} else {
|
||||
o.push_str(&format!("{win_w}, {win_h}, 1, BlackPixel(display, screen), "));
|
||||
}
|
||||
if has_bg {
|
||||
o.push_str(&format!(
|
||||
"alloc_rgb(display, screen, {bg_r}, {bg_g}, {bg_b})"
|
||||
@@ -2338,6 +2900,23 @@ fn emit_main_cpp(project: &Project, widgets: &[Widget]) -> String {
|
||||
" XStoreName(display, window, \"{}\");\n",
|
||||
esc_c(&project.title)
|
||||
));
|
||||
if project.border_style == 1 {
|
||||
o.push_str(" // Border style None: undecorated window.\n");
|
||||
o.push_str(" { XSetWindowAttributes attrs{}; attrs.override_redirect = True; XChangeWindowAttributes(display, window, CWOverrideRedirect, &attrs); }\n");
|
||||
}
|
||||
if project.border_style == 2 || project.border_style == 3 {
|
||||
o.push_str(&format!(
|
||||
" // NOTE: border style {} (single/dialog) has no X11 equivalent here; the window manager draws the frame.\n",
|
||||
project.border_style
|
||||
));
|
||||
}
|
||||
if project.window_state == 1 {
|
||||
o.push_str(" XIconifyWindow(display, window, screen);\n");
|
||||
}
|
||||
if project.window_state == 3 {
|
||||
o.push_str(" // Fullscreen: ask the window manager.\n");
|
||||
o.push_str(" { Atom wm_state = XInternAtom(display, \"_NET_WM_STATE\", False); Atom fs = XInternAtom(display, \"_NET_WM_STATE_FULLSCREEN\", False); XEvent ev{}; ev.type = ClientMessage; ev.xclient.window = window; ev.xclient.message_type = wm_state; ev.xclient.format = 32; ev.xclient.data.l[0] = 1; ev.xclient.data.l[1] = (long)fs; XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &ev); }\n");
|
||||
}
|
||||
o.push_str(" XSelectInput(display, window, ExposureMask | KeyPressMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask);\n");
|
||||
o.push_str(" Atom delete_window = XInternAtom(display, \"WM_DELETE_WINDOW\", False);\n");
|
||||
o.push_str(" XSetWMProtocols(display, window, &delete_window, 1);\n");
|
||||
|
||||
Reference in new issue
Block a user