}
}
- Widget root{ui::null};
-
#define IMPL(T, F) template<> _IMPL(T, F)
-#define _IMPL(T, F) struct verify<T *> { using self = T; static self test(self it) { return self(F(it)); } }
+#define _IMPL(T, F) struct verify<T *> { using self = T; static self test(self it) { return self::from(F(it)); } }
template<class T>
struct verify;
template<class T> _IMPL(T,);
-#define this (verify<self>::test(*static_cast<self>(this)))
+ template<class T>
+ using pointer_remove_const = std::add_pointer<
+ typename std::remove_const<
+ typename std::remove_pointer<T>::type
+ >::type
+ >;
+
+WARNING_SUPPRESS_CLANG(keyword-macro)
+#define this (verify<self>::test(*static_cast<self>(const_cast<pointer_remove_const<decltype(this)>::type>(this))))
+WARNING_RESTORE_CLANG(keyword-macro)
IMPL(Editable, GTK_EDITABLE);
void IEditable::editable(bool value)
{
- gtk_editable_set_editable(GTK_EDITABLE(this), value);
+ gtk_editable_set_editable(this, value);
}
IMPL(TreeModel, GTK_TREE_MODEL);
)))
{}
- alert_response IWindow::alert(std::string text, std::string title, alert_type type, alert_icon icon)
- {
- auto ret = gtk_MessageBox(this, text.c_str(),
- title.c_str(),
- type == alert_type::OK ? eMB_OK :
- type == alert_type::OKCANCEL ? eMB_OKCANCEL :
- type == alert_type::YESNO ? eMB_YESNO :
- type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL :
- type == alert_type::NOYES ? eMB_NOYES :
- eMB_OK,
- icon == alert_icon::Default ? eMB_ICONDEFAULT :
- icon == alert_icon::Error ? eMB_ICONERROR :
- icon == alert_icon::Warning ? eMB_ICONWARNING :
- icon == alert_icon::Question ? eMB_ICONQUESTION :
- icon == alert_icon::Asterisk ? eMB_ICONASTERISK :
- eMB_ICONDEFAULT
- );
- return
- ret == eIDOK ? alert_response::OK :
- ret == eIDCANCEL ? alert_response::CANCEL :
- ret == eIDYES ? alert_response::YES :
- ret == eIDNO ? alert_response::NO :
- alert_response::OK;
- }
-
Window IWindow::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h)
{
return Window(::create_dialog_window(this, title, func, data, default_w, default_h));
delete data;
};
auto func = [](_GtkWidget *widget, GdkEventKey *event, user_data *args) -> bool {
- return args->f(Widget(widget), event, args->extra);
+ return args->f(Widget::from(widget), event, args->extra);
};
auto clos = g_cclosure_new(G_CALLBACK(+func), pass, reinterpret_cast<GClosureNotify>(+dtor));
return g_signal_connect_closure(G_OBJECT(this), "key-press-event", clos, false);
gtk_window_add_accel_group(this, group);
}
+ WARNING_SUPPRESS(deprecated-declarations)
IMPL(Alignment, GTK_ALIGNMENT);
Alignment::Alignment(float xalign, float yalign, float xscale, float yscale)
: Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale)))
{}
+ WARNING_RESTORE(deprecated-declarations)
IMPL(Frame, GTK_FRAME);
IMPL(ToggleButton, GTK_TOGGLE_BUTTON);
- bool IToggleButton::active()
+ bool IToggleButton::active() const
{
- return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(this)) != 0;
+ return gtk_toggle_button_get_active(this) != 0;
+ }
+
+ void IToggleButton::active(bool value)
+ {
+ gtk_toggle_button_set_active(this, value);
}
IMPL(CheckButton, GTK_CHECK_BUTTON);
GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label)))
{}
+ WARNING_SUPPRESS(deprecated-declarations)
IMPL(TearoffMenuItem, GTK_TEAROFF_MENU_ITEM);
TearoffMenuItem::TearoffMenuItem(ui::New_t) : TearoffMenuItem(GTK_TEAROFF_MENU_ITEM(gtk_tearoff_menu_item_new()))
{}
+ WARNING_RESTORE(deprecated-declarations)
IMPL(ComboBoxText, GTK_COMBO_BOX_TEXT);
gtk_box_pack_end(this, child, expand, fill, padding);
}
+ WARNING_SUPPRESS(deprecated-declarations)
IMPL(VBox, GTK_VBOX);
VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing)))
VPaned::VPaned(ui::New_t) : VPaned(GTK_VPANED(gtk_vpaned_new()))
{}
+ WARNING_RESTORE(deprecated-declarations)
IMPL(Menu, GTK_MENU);
Menu::Menu(ui::New_t) : Menu(GTK_MENU(gtk_menu_new()))
{}
+ WARNING_SUPPRESS(deprecated-declarations)
IMPL(Table, GTK_TABLE);
Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table(
padding.x, padding.y
);
}
+ WARNING_RESTORE(deprecated-declarations)
IMPL(TextView, GTK_TEXT_VIEW);
GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits)))
{}
+ WARNING_SUPPRESS(deprecated-declarations)
IMPL(HScale, GTK_HSCALE);
HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment)))
HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step)))
{}
+ WARNING_RESTORE(deprecated-declarations)
IMPL(Adjustment, GTK_ADJUSTMENT);
// Custom
+#if GTK_TARGET == 3
+
+ IMPL(GLArea, (void *));
+
+#elif GTK_TARGET == 2
+
+ IMPL(GLArea, GTK_DRAWING_AREA);
+
+#endif
+
guint IGLArea::on_render(GCallback pFunction, void *data)
{
#if GTK_TARGET == 3
#endif
}
+ // global
+
+ Window root{ui::null};
+
+ alert_response alert(Window parent, std::string text, std::string title, alert_type type, alert_icon icon)
+ {
+ auto ret = gtk_MessageBox(parent, text.c_str(),
+ title.c_str(),
+ type == alert_type::OK ? eMB_OK :
+ type == alert_type::OKCANCEL ? eMB_OKCANCEL :
+ type == alert_type::YESNO ? eMB_YESNO :
+ type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL :
+ type == alert_type::NOYES ? eMB_NOYES :
+ eMB_OK,
+ icon == alert_icon::Default ? eMB_ICONDEFAULT :
+ icon == alert_icon::Error ? eMB_ICONERROR :
+ icon == alert_icon::Warning ? eMB_ICONWARNING :
+ icon == alert_icon::Question ? eMB_ICONQUESTION :
+ icon == alert_icon::Asterisk ? eMB_ICONASTERISK :
+ eMB_ICONDEFAULT
+ );
+ return
+ ret == eIDOK ? alert_response::OK :
+ ret == eIDCANCEL ? alert_response::CANCEL :
+ ret == eIDYES ? alert_response::YES :
+ ret == eIDNO ? alert_response::NO :
+ alert_response::OK;
+ }
+
}