Phase 3: ToggleButton type, window-level Project fields (border-style, icon, position, window-state), Lazarus togglebutton events
This commit is contained in:
1 parent
af5af872bd
commit
bf430db324
3 files changed
+27
-2
No files matched your search
+6
-1
@@ -91,7 +91,7 @@ inline std::string xframe_type_key(const std::string& cls) {
|
||||
if (l == "spinbutton") return "SpinEdit";
|
||||
if (l == "comboboxtext") return "Combobox";
|
||||
if (l == "passwordentry" || l == "searchentry") return "Entry";
|
||||
if (l == "togglebutton") return "Checkbutton";
|
||||
if (l == "togglebutton" || l == "speedbutton") return "ToggleButton";
|
||||
for (const TypeInfo& t : kTypes) {
|
||||
std::string k;
|
||||
for (const char* p = t.key; *p; ++p)
|
||||
@@ -121,6 +121,10 @@ inline const std::vector<EventDef>& events_for(const std::string& type) {
|
||||
static const std::vector<EventDef> checkbutton = {
|
||||
{"toggled", "on_toggled", "Toggled", K::Simple, false, "OnClick"},
|
||||
};
|
||||
// Phase 3 (§2.21): ToggleButton/SpeedButton — same toggle event.
|
||||
static const std::vector<EventDef> togglebutton = {
|
||||
{"toggled", "on_toggled", "Toggled", K::Simple, false, "OnClick"},
|
||||
};
|
||||
static const std::vector<EventDef> radiobutton = {
|
||||
{"toggled", "on_toggled", "Toggled", K::Simple, false, "OnClick"},
|
||||
};
|
||||
@@ -229,6 +233,7 @@ inline const std::vector<EventDef>& events_for(const std::string& type) {
|
||||
if (t == "Button") return button;
|
||||
if (t == "Entry") return entry;
|
||||
if (t == "Checkbutton") return checkbutton;
|
||||
if (t == "ToggleButton") return togglebutton;
|
||||
if (t == "Radiobutton") return radiobutton;
|
||||
if (t == "Combobox") return combobox;
|
||||
if (t == "Listbox") return listbox;
|
||||
|
||||
@@ -22,6 +22,14 @@ struct Project {
|
||||
std::string class_name = "MyWindow";
|
||||
int win_width = 800;
|
||||
int win_height = 600;
|
||||
// Phase 3 (§2.20): window-level props — border style (0 default,
|
||||
// 1 none, 2 single, 3 dialog), icon file, position (0 default,
|
||||
// 1 center, 2 screen center, 3 main-form center, 4 designed),
|
||||
// state (0 normal, 1 minimized, 2 maximized, 3 fullscreen).
|
||||
int border_style = 0;
|
||||
std::string icon;
|
||||
int position = 0;
|
||||
int window_state = 0;
|
||||
std::string background; // window background colour, "" = default
|
||||
// Menu bar spec, one menu per line: "File: New | Open | - | Quit"
|
||||
// ("-" is a separator). Empty = no menu bar.
|
||||
@@ -44,6 +52,7 @@ inline const TypeInfo kTypes[] = {
|
||||
{"Label", "pal_label", 100, 24, true },
|
||||
{"Entry", "pal_entry", 160, 28, true },
|
||||
{"Checkbutton", "pal_checkbutton", 120, 26, true },
|
||||
{"ToggleButton", "pal_togglebutton", 110, 30, true },
|
||||
{"Radiobutton", "pal_radiobutton", 120, 26, true },
|
||||
{"Frame", "pal_frame", 200, 120, true },
|
||||
{"Combobox", "pal_combobox", 160, 28, true },
|
||||
|
||||
+12
-1
@@ -47,7 +47,11 @@ bool save_project_file(const std::string& path, const Project& p,
|
||||
<< " \"width\": " << p.win_width << ",\n"
|
||||
<< " \"height\": " << p.win_height << ",\n"
|
||||
<< " \"background\": \"" << json_escape(p.background) << "\",\n"
|
||||
<< " \"menubar\": \"" << json_escape(p.menubar) << "\"\n"
|
||||
<< " \"menubar\": \"" << json_escape(p.menubar) << "\",\n"
|
||||
<< " \"border_style\": " << p.border_style << ",\n"
|
||||
<< " \"icon\": \"" << json_escape(p.icon) << "\",\n"
|
||||
<< " \"position\": " << p.position << ",\n"
|
||||
<< " \"window_state\": " << p.window_state << "\n"
|
||||
<< " },\n"
|
||||
<< " \"widgets\": [";
|
||||
for (size_t i = 0; i < p.widgets.size(); ++i) {
|
||||
@@ -333,9 +337,16 @@ bool load_project_file(const std::string& path, Project& out,
|
||||
p.win_height = jint(win->find("height"), p.win_height);
|
||||
p.background = jstr(win->find("background"), "");
|
||||
p.menubar = jstr(win->find("menubar"), "");
|
||||
p.border_style = jint(win->find("border_style"), p.border_style);
|
||||
p.icon = jstr(win->find("icon"), "");
|
||||
p.position = jint(win->find("position"), p.position);
|
||||
p.window_state = jint(win->find("window_state"), p.window_state);
|
||||
}
|
||||
if (p.win_width < 50 || p.win_width > 20000) p.win_width = 800;
|
||||
if (p.win_height < 50 || p.win_height > 20000) p.win_height = 600;
|
||||
if (p.border_style < 0 || p.border_style > 3) p.border_style = 0;
|
||||
if (p.position < 0 || p.position > 4) p.position = 0;
|
||||
if (p.window_state < 0 || p.window_state > 3) p.window_state = 0;
|
||||
|
||||
if (const Json* widgets = root.find("widgets");
|
||||
widgets && widgets->type == Json::Arr) {
|
||||
|
||||
Reference in new issue
Block a user