Commit 2980bef4 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

Window: MinWidth and MinHeight are two new properties that allow to define the...

Window: MinWidth and MinHeight are two new properties that allow to define the minimum size of a resizable window.

[GB.GTK]
* NEW: Window: MinWidth and MinHeight are two new properties that allow to define the minimum size of a resizable window.

[GB.GTK3]
* NEW: Window: MinWidth and MinHeight are two new properties that allow to define the minimum size of a resizable window.

[GB.QT4]
* NEW: Window: MinWidth and MinHeight are two new properties that allow to define the minimum size of a resizable window.

[GB.QT5]
* NEW: Window: MinWidth and MinHeight are two new properties that allow to define the minimum size of a resizable window.
parent 494ccf6e
......@@ -760,6 +760,30 @@ BEGIN_METHOD_VOID(Window_Activate)
END_METHOD
BEGIN_PROPERTY(Window_MinWidth)
int w, h;
WINDOW->getCustomMinimumSize(&w, &h);
if (READ_PROPERTY)
GB.ReturnInteger(w);
else
WINDOW->setCustomMinimumSize(VPROP(GB_INTEGER), h);
END_PROPERTY
BEGIN_PROPERTY(Window_MinHeight)
int w, h;
WINDOW->getCustomMinimumSize(&w, &h);
if (READ_PROPERTY)
GB.ReturnInteger(h);
else
WINDOW->setCustomMinimumSize(w, VPROP(GB_INTEGER));
END_PROPERTY
//-------------------------------------------------------------------------
BEGIN_METHOD_VOID(Form_new)
......@@ -867,6 +891,11 @@ GB_DESC CWindowDesc[] =
GB_PROPERTY("Opacity", "i", Window_Opacity),
GB_PROPERTY("Transparent", "b", Window_Transparent),
GB_PROPERTY("TakeFocus", "b", Window_TakeFocus),
GB_PROPERTY("MinWidth", "i", Window_MinWidth),
GB_PROPERTY("MinHeight", "i", Window_MinHeight),
GB_PROPERTY("MinW", "i", Window_MinWidth),
GB_PROPERTY("MinH", "i", Window_MinHeight),
ARRANGEMENT_PROPERTIES,
......
......@@ -721,12 +721,6 @@ bool gMainWindow::emitOpen()
_closed = false;
//_no_resize_event = true; // If the event loop is run during emitOpen(), some spurious configure events are received.
if (!_min_w && !_min_h)
{
_min_w = width();
_min_h = height();
}
updateSize();
gtk_widget_realize(border);
......@@ -1904,22 +1898,27 @@ void gMainWindow::emitResizeLater()
void gMainWindow::setGeometryHints()
{
GdkGeometry geometry;
int min_w, min_h;
if (isTopLevel())
{
min_w = _min_w;
min_h = _min_h;
if (isResizable())
{
if (isModal() || isUtility())
{
geometry.min_width = _min_w;
geometry.min_height = _min_h;
}
else
{
geometry.min_width = 0;
geometry.min_height = 0;
if (!min_w && !min_h)
{
min_w = width();
min_h = height();
}
}
geometry.min_width = min_w;
geometry.min_height = min_h;
geometry.max_width = 32767;
geometry.max_height = 32767;
}
......@@ -2064,3 +2063,20 @@ void gMainWindow::destroy()
doClose(true);
gControl::destroy();
}
void gMainWindow::setCustomMinimumSize(int w, int h)
{
w = Max(0, w);
h = Max(0, h);
if (w == _min_w && h == _min_h)
return;
_min_w = w;
_min_h = h;
updateSize();
}
void gMainWindow::getCustomMinimumSize(int *w, int *h) const
{
*w = _min_w;
*h = _min_h;
}
......@@ -80,6 +80,9 @@ public:
void setPersistent(bool vl);
void setTransparent(bool vl);
void setNoTakeFocus(bool vl);
void setCustomMinimumSize(int w, int h);
void getCustomMinimumSize(int *w, int *h) const;
virtual void setVisible(bool vl);
virtual void setBackground(gColor vl);
......
......@@ -217,11 +217,6 @@ static bool emit_open_event(void *_object)
THIS->closed = false;
THIS->opened = true;
if (!THIS->minw && !THIS->minh)
{
THIS->minw = THIS->w;
THIS->minh = THIS->h;
}
#if DEBUG_WINDOW
qDebug("emit_open_event: %s %p", GB.GetClassName(THIS), THIS);
#endif
......@@ -1331,6 +1326,30 @@ BEGIN_METHOD_VOID(Window_Activate)
END_METHOD
BEGIN_PROPERTY(Window_MinWidth)
if (READ_PROPERTY)
GB.ReturnInteger(THIS->minw);
else
{
THIS->minw = Max(0, VPROP(GB_INTEGER));
WINDOW->setGeometryHints();
}
END_PROPERTY
BEGIN_PROPERTY(Window_MinHeight)
if (READ_PROPERTY)
GB.ReturnInteger(THIS->minh);
else
{
THIS->minh = Max(0, VPROP(GB_INTEGER));
WINDOW->setGeometryHints();
}
END_PROPERTY
/***************************************************************************/
......@@ -1432,6 +1451,11 @@ GB_DESC CWindowDesc[] =
GB_PROPERTY("Transparent", "b", Window_Transparent),
GB_PROPERTY("TakeFocus", "b", Window_TakeFocus),
GB_PROPERTY("MinWidth", "i", Window_MinWidth),
GB_PROPERTY("MinHeight", "i", Window_MinHeight),
GB_PROPERTY("MinW", "i", Window_MinWidth),
GB_PROPERTY("MinH", "i", Window_MinHeight),
ARRANGEMENT_PROPERTIES,
//GB_PROPERTY("Type", "i", CWINDOW_type),
......@@ -1667,6 +1691,41 @@ void MyMainWindow::setEventLoop()
THIS->loopLevel = CWINDOW_Current ? CWINDOW_Current->loopLevel : 0;
}
void MyMainWindow::setGeometryHints()
{
CWIDGET *_object = CWidget::get(this);
int minw, minh;
if (!THIS->toplevel)
{
setMinimumSize(0, 0);
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
return;
}
minw = THIS->minw;
minh = THIS->minh;
if (_resizable)
{
if (isModal() || isUtility())
{
if (!minw && !minh)
{
minw = width();
minh = height();
}
}
setMinimumSize(minw, minh);
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
}
else
{
setMinimumSize(width(), height());
setMaximumSize(width(), height());
}
}
void MyMainWindow::present(QWidget *parent)
{
/*CWIDGET *_object = CWidget::get(this);
......@@ -1683,8 +1742,7 @@ void MyMainWindow::present(QWidget *parent)
{
//X11_window_startup(WINDOW->effectiveWinId(), THIS->x, THIS->y, THIS->w, THIS->h);
if (isUtility() && _resizable)
setMinimumSize(THIS->minw, THIS->minh);
setGeometryHints();
setAttribute(Qt::WA_ShowWithoutActivating, THIS->noTakeFocus);
......@@ -1851,10 +1909,7 @@ void MyMainWindow::doShowModal(bool popup, const QPoint *pos)
else
{
if (_resizable && _border)
{
setMinimumSize(THIS->minw, THIS->minh);
setSizeGrip(true);
}
parent = CWINDOW_Current;
if (!parent)
......
......@@ -258,6 +258,8 @@ public:
virtual void resize(int w, int h);
virtual void setGeometry(int x, int y, int w, int h);
void setGeometryHints();
friend void on_error_show_modal(MODAL_INFO *info);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment