23 #ifndef GNC_OPTION_GTK_UI_HPP 24 #define GNC_OPTION_GTK_UI_HPP 27 #include <glib/gi18n.h> 31 #include <gnc-option-ui.hpp> 45 typedef void (*WidgetCreateFunc)(
GncOption&, GtkGrid*, int);
67 static std::vector<WidgetCreateFunc> s_registry;
68 static bool s_initialized;
85 void set_widget(GtkWidget* widget);
86 virtual GtkWidget* get_widget()
const {
return m_widget; }
87 virtual SCM get_widget_scm_value(
const GncOption&)
const;
92 void gnc_option_changed_widget_cb (GtkWidget *widget,
GncOption *option);
93 void gnc_option_changed_option_cb (GtkWidget *dummy,
GncOption *option);
95 template<GncOptionUIType type>
void 96 create_option_widget(
GncOption& option, GtkGrid*,
int row);
102 template <
typename Instance>
inline const QofInstance*
103 qof_instance_cast(Instance inst)
105 static_assert(std::is_pointer_v<Instance>,
"Pointers Only!");
110 align_label (GtkLabel *name_label)
114 gtk_widget_set_valign (GTK_WIDGET(name_label), GTK_ALIGN_START);
115 gtk_widget_set_margin_top (GTK_WIDGET(name_label), 6);
119 set_name_label(
const GncOption& option, GtkGrid* page_box,
int row,
bool align)
121 auto name{option.get_name().c_str()};
124 auto label{gtk_label_new(_(name))};
126 align_label(GTK_LABEL(label));
127 gtk_widget_set_halign (GTK_WIDGET(label), GTK_ALIGN_END);
128 gtk_grid_attach(GTK_GRID(page_box), label, 0, row, 1, 1);
133 set_tool_tip(
const GncOption& option, GtkWidget* box)
135 auto documentation{option.get_docstring().c_str()};
136 if (documentation && *documentation)
137 gtk_widget_set_tooltip_text(box, _(documentation));
141 grid_attach_widget(GtkGrid* grid, GtkWidget* widget,
int row)
144 gtk_grid_attach (grid, widget, 1, row, 1, 1);
149 wrap_widget (
const GncOption& option, GtkWidget* widget, GtkGrid* page_box,
int row)
151 auto enclosing{gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5)};
152 gtk_box_set_homogeneous (GTK_BOX (enclosing), FALSE);
153 gtk_box_pack_start(GTK_BOX(enclosing), widget, FALSE, FALSE, 0);
154 set_name_label(option, page_box, row,
false);
155 set_tool_tip(option, enclosing);
156 gtk_widget_show_all(enclosing);
157 grid_attach_widget(page_box, enclosing, row);
159 #endif //GNC_OPTION_GTK_UI_HPP static void set_func(GncOptionUIType type, WidgetCreateFunc func)
Register a WidgetCreateFunc.
Factory class that keeps track of which GncOptionValueType needs which WidgetCreateFunc and calls the...
Represents the public interface for an option.
C++ Public interface for individual options.
virtual void set_selectable(bool) const noexcept override
Control wether the widget is sensitive.
void clear_ui_item() override
Clear the data from the widget.
Holds a pointer to the UI item which will control the option and an enum representing the type of the...
static void create(GncOption &option, GtkGrid *page, int row)
Create a widget.
class GncOptionGtkUIItem Gtk-specific Interface class for Option Widget
GncOptionUIType
Used by GncOptionClassifier to indicate to dialog-options what control should be displayed for the op...