* BUG: Moving a modal form during the Open event handler now prevents the
  form to be centered, as with gb.gtk.


git-svn-id: svn://localhost/gambas/trunk@4043 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-08-26 21:13:02 +00:00
parent 5e45ac3545
commit 3460dd0e6c
3 changed files with 37 additions and 22 deletions

View file

@ -417,6 +417,14 @@ void CWIDGET_move(void *_object, int x, int y)
{
QWidget *wid = get_widget(THIS);
if (GB.Is(THIS, CLASS_Window))
{
CWINDOW *win = (CWINDOW *)_object;
win->x = x;
win->y = y;
win->mustCenter = false;
}
if (wid)
{
if (x == wid->x() && y == wid->y())
@ -425,15 +433,10 @@ void CWIDGET_move(void *_object, int x, int y)
wid->move(x, y);
}
if (GB.Is(THIS, CLASS_Window))
{
((CWINDOW *)_object)->x = x;
((CWINDOW *)_object)->y = y;
}
CWIDGET_after_geometry_change(THIS, false);
}
/*
void CWIDGET_move_cached(void *_object, int x, int y)
{
if (GB.Is(THIS, CLASS_Window))
@ -444,6 +447,7 @@ void CWIDGET_move_cached(void *_object, int x, int y)
CWIDGET_after_geometry_change(THIS, false);
}
*/
void CWIDGET_resize(void *_object, int w, int h)
{
@ -492,6 +496,7 @@ void CWIDGET_resize(void *_object, int w, int h)
CWIDGET_after_geometry_change(THIS, true);
}
/*
void CWIDGET_resize_cached(void *_object, int w, int h)
{
if (GB.Is(THIS, CLASS_Window))
@ -502,12 +507,31 @@ void CWIDGET_resize_cached(void *_object, int w, int h)
CWIDGET_after_geometry_change(THIS, true);
}
*/
void CWIDGET_move_resize(void *_object, int x, int y, int w, int h)
{
QWidget *wid = get_widget(THIS);
if (wid)
{
if (w < 0)
w = wid->width();
if (h < 0)
h = wid->height();
}
if (GB.Is(THIS, CLASS_Window))
{
CWINDOW *win = (CWINDOW *)_object;
win->x = x;
win->y = y;
win->w = w;
win->h = h;
win->mustCenter = false;
}
if (wid)
{
if (w < 0)
@ -528,14 +552,6 @@ void CWIDGET_move_resize(void *_object, int x, int y, int w, int h)
wid->setGeometry(x, y, qMax(0, w), qMax(0, h));
}
if (GB.Is(THIS, CLASS_Window))
{
((CWINDOW *)_object)->x = x;
((CWINDOW *)_object)->y = y;
((CWINDOW *)_object)->w = w;
((CWINDOW *)_object)->h = h;
}
CWIDGET_after_geometry_change(THIS, true);
}
@ -577,6 +593,7 @@ void CWIDGET_move_resize(void *_object, int x, int y, int w, int h)
}
#endif
/*
void CWIDGET_move_resize_cached(void *_object, int x, int y, int w, int h)
{
if (GB.Is(THIS, CLASS_Window))
@ -589,6 +606,7 @@ void CWIDGET_move_resize_cached(void *_object, int x, int y, int w, int h)
CWIDGET_after_geometry_change(THIS, true);
}
*/
void CWIDGET_check_hovered()
{

View file

@ -698,6 +698,7 @@ END_METHOD
BEGIN_METHOD_VOID(CWINDOW_show_modal)
THIS->ret = 0;
THIS->mustCenter = true;
if (!emit_open_event(THIS))
{
@ -1574,7 +1575,6 @@ MyMainWindow::MyMainWindow(QWidget *parent, const char *name, bool embedded) :
_border = true;
_resizable = true;
//state = StateNormal;
mustCenter = false;
_deleted = false;
_type = _NET_WM_WINDOW_TYPE_NORMAL;
_enterLoop = false;
@ -1828,8 +1828,6 @@ void MyMainWindow::showModal(void)
old = MyApplication::eventLoop;
MyApplication::eventLoop = &eventLoop;
mustCenter = true;
#ifndef NO_X_WINDOW
if (CWINDOW_Active)
X11_set_transient_for(winId(), CWINDOW_Active->widget.widget->winId());
@ -2466,10 +2464,10 @@ void MyMainWindow::center(bool force = false)
QPoint p;
QRect r;
if (!force && !mustCenter)
if (!force && !THIS->mustCenter)
return;
mustCenter = false;
THIS->mustCenter = false;
r = QApplication::desktop()->availableGeometry(QApplication::desktop()->screenNumber(this));

View file

@ -80,11 +80,11 @@ typedef
unsigned minsize : 1;
unsigned title : 1;
unsigned stateChange : 1;
//unsigned opening : 1;
unsigned closing : 1;
unsigned hideMenuBar : 1;
unsigned showMenuBar : 1;
unsigned sticky : 1;
unsigned mustCenter : 1;
}
CWINDOW;
@ -156,7 +156,6 @@ private:
QSizeGrip *sg;
QMenuBar *mb;
bool mustCenter;
bool _activate;
bool _border;
bool _resizable;