From 9f5c1f4bd691037cb7e658586ca8afad031653ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Mon, 19 May 2014 16:00:32 +0000 Subject: [PATCH] [GB.GTK] * BUG: Embedded windows can now be reparented to NULL to become top-level again. * BUG: Showing a top-level window now raises it automatically. git-svn-id: svn://localhost/gambas/trunk@6280 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.gtk/src/CMenu.cpp | 6 +++--- gb.gtk/src/CWidget.cpp | 11 +++++++---- gb.gtk/src/CWindow.cpp | 2 +- gb.gtk/src/gmainwindow.cpp | 20 +++++++++++++++++--- gb.gtk/src/gmainwindow.h | 4 +++- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gb.gtk/src/CMenu.cpp b/gb.gtk/src/CMenu.cpp index 8024869b1..366fb56a3 100644 --- a/gb.gtk/src/CMenu.cpp +++ b/gb.gtk/src/CMenu.cpp @@ -137,12 +137,12 @@ static void cb_hide(gMenu *sender) GB.Raise(THIS, EVENT_Hide, 0); } -BEGIN_METHOD_VOID(CMENU_init) +/*BEGIN_METHOD_VOID(CMENU_init) CLASS_Menu = GB.FindClass("Menu"); CLASS_Window = GB.FindClass("Window"); -END_METHOD +END_METHOD*/ BEGIN_METHOD(CMENU_new, GB_OBJECT parent; GB_BOOLEAN hidden) @@ -463,7 +463,7 @@ GB_DESC CMenuDesc[] = GB_DECLARE("Menu", sizeof(CMENU)), GB_HOOK_CHECK(CMENU_check), - GB_STATIC_METHOD("_init", 0, CMENU_init, 0), + //GB_STATIC_METHOD("_init", 0, CMENU_init, 0), GB_METHOD("_new", 0, CMENU_new, "(Parent)o[(Hidden)b]"), GB_METHOD("_free", 0, CMENU_free, 0), diff --git a/gb.gtk/src/CWidget.cpp b/gb.gtk/src/CWidget.cpp index f24b9e5e9..b58b06357 100644 --- a/gb.gtk/src/CWidget.cpp +++ b/gb.gtk/src/CWidget.cpp @@ -622,11 +622,14 @@ END_METHOD BEGIN_METHOD(CWIDGET_reparent, GB_OBJECT parent; GB_INTEGER x; GB_INTEGER y) - CCONTAINER *parent=(CCONTAINER*)VARG(parent); + CCONTAINER *parent = (CCONTAINER*)VARG(parent); int x, y; - if (GB.CheckObject(parent)) - return; + if (parent || !GB.Is(THIS, CLASS_Window)) + { + if (GB.CheckObject(parent)) + return; + } x = CONTROL->x(); y = CONTROL->y(); @@ -637,7 +640,7 @@ BEGIN_METHOD(CWIDGET_reparent, GB_OBJECT parent; GB_INTEGER x; GB_INTEGER y) y = VARG(y); } - CONTROL->reparent((gContainer*)parent->ob.widget, x, y); + CONTROL->reparent(parent ? (gContainer*)parent->ob.widget : NULL, x, y); END_METHOD diff --git a/gb.gtk/src/CWindow.cpp b/gb.gtk/src/CWindow.cpp index 59bfd0901..9edbb6372 100644 --- a/gb.gtk/src/CWindow.cpp +++ b/gb.gtk/src/CWindow.cpp @@ -395,7 +395,7 @@ END_METHOD BEGIN_METHOD_VOID(CWINDOW_show) - WINDOW->show(); + WINDOW->showActivate(); END_METHOD diff --git a/gb.gtk/src/gmainwindow.cpp b/gb.gtk/src/gmainwindow.cpp index 17c5bae52..4ed5ac808 100644 --- a/gb.gtk/src/gmainwindow.cpp +++ b/gb.gtk/src/gmainwindow.cpp @@ -787,6 +787,15 @@ void gMainWindow::showPopup(int x, int y) } } +void gMainWindow::showActivate() +{ + bool v = isTopLevel() && isVisible(); + + show(); + if (v) + gtk_window_present(GTK_WINDOW(border)); +} + void gMainWindow::showPopup() { int x, y; @@ -1163,6 +1172,7 @@ void gMainWindow::reparent(gContainer *newpr, int x, int y) w = width(); h = height(); bufW = bufH = -1; + gtk_widget_set_size_request(border, 1, 1); resize(w, h); hideHiddenChildren(); @@ -1307,9 +1317,9 @@ void gMainWindow::setActiveWindow(gControl *control) } #ifdef GDK_WINDOWING_X11 -bool gMainWindow::isUtility() +bool gMainWindow::isUtility() const { - return gtk_window_get_type_hint(GTK_WINDOW(border)) == GDK_WINDOW_TYPE_HINT_UTILITY; + return _utility; } void gMainWindow::setUtility(bool v) @@ -1317,16 +1327,20 @@ void gMainWindow::setUtility(bool v) if (!isTopLevel()) return; + // TODO: works only if the window is not mapped! + + _utility = v; gtk_window_set_type_hint(GTK_WINDOW(border), v ? GDK_WINDOW_TYPE_HINT_UTILITY : GDK_WINDOW_TYPE_HINT_NORMAL); } #else bool gMainWindow::isUtility() { - return false; + return _utility; } void gMainWindow::setUtility(bool v) { + _utility = v; } #endif diff --git a/gb.gtk/src/gmainwindow.h b/gb.gtk/src/gmainwindow.h index 2edee6198..50a149d4a 100644 --- a/gb.gtk/src/gmainwindow.h +++ b/gb.gtk/src/gmainwindow.h @@ -36,7 +36,7 @@ public: //"Properties" bool hasBorder(); bool isResizable(); - bool isUtility(); + bool isUtility() const; gPicture *icon() { return _icon; } gPicture *picture() { return _picture; } bool mask() { return _mask; } @@ -100,6 +100,7 @@ public: //"Methods" void center(); + void showActivate(); void showModal(); void showPopup(); void showPopup(int x, int y); @@ -182,6 +183,7 @@ public: unsigned _maximized : 1; unsigned _minimized : 1; unsigned _fullscreen : 1; + unsigned _utility : 1; }; #endif