13
0

Add text control type for LuaDialog, based on Gtk::TextView

This commit is contained in:
Zabooma 2024-11-01 13:53:58 -04:00 committed by Robin Gareus
parent a76d4b4c82
commit 1155da84dd
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -591,6 +591,35 @@ protected:
Gtk::FileChooserWidget _fc; Gtk::FileChooserWidget _fc;
}; };
class LuaDialogText : public LuaDialogWidget
{
public:
LuaDialogText (std::string const& key, std::string const& title, std::string const& dflt)
: LuaDialogWidget (key, title)
{
_text_view.set_wrap_mode (Gtk::WRAP_WORD);
_text_view.get_buffer()->set_text (dflt);
_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
_scrolled_window.add(_text_view);
}
Gtk::Widget* widget ()
{
return &_scrolled_window;
}
void assign (luabridge::LuaRef* rv) const
{
(*rv)[_key] = std::string (_text_view.get_buffer()->get_text());
}
protected:
Gtk::TextView _text_view;
Gtk::ScrolledWindow _scrolled_window;
};
/* ***************************************************************************** /* *****************************************************************************
* Lua Parameter Dialog * Lua Parameter Dialog
*/ */
@ -659,6 +688,12 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
dflt = i.value ()["default"].cast<std::string> (); dflt = i.value ()["default"].cast<std::string> ();
} }
w = new LuaDialogEntry (key, title, dflt); w = new LuaDialogEntry (key, title, dflt);
} else if (type == "textarea") {
std::string dflt;
if (i.value ()["default"].isString ()) {
dflt = i.value ()["default"].cast<std::string> ();
}
w = new LuaDialogText (key, title, dflt);
} else if (type == "radio") { } else if (type == "radio") {
std::string dflt; std::string dflt;
if (!i.value ()["values"].isTable ()) { if (!i.value ()["values"].isTable ()) {