X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=libs%2Fuilib%2Fuilib.cpp;h=cb44edb24f992e62462592535524947987fb3abb;hp=c2c24c50454ce1bc552105665ca6992926bbeb67;hb=f0350b355f68497312c517c1bfd1fc216c722992;hpb=69b4f74e6c95e22d6c6ce10d0e137c875fd83cc4 diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index c2c24c50..cb44edb2 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -60,36 +60,16 @@ namespace ui { Widget::Widget(ui::New_t) : Widget(nullptr) {} - alert_response IWidget::alert(std::string text, std::string title, alert_type type, alert_icon icon) + Window IWidget::window() { - 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; + return Window::from(gtk_widget_get_toplevel(this)); } const char * IWidget::file_dialog(bool open, const char *title, const char *path, const char *pattern, bool want_load, bool want_import, bool want_save) { - return ::file_dialog(this, open, title, path, pattern, want_load, want_import, want_save); + return ::file_dialog(this.window(), open, title, path, pattern, want_load, want_import, want_save); } bool IWidget::visible() @@ -156,6 +136,31 @@ namespace ui { ))) {} + 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));