From e325c2e4a0a927f0b70c7f71da02065019c020ef Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 26 May 2024 17:50:40 +0200 Subject: Adding new call `Fl_Window::get_size_range()`, #981 --- FL/Fl_Window.H | 2 ++ src/Fl_Window.cxx | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H index adf0aa44c..6c6e26493 100644 --- a/FL/Fl_Window.H +++ b/FL/Fl_Window.H @@ -347,6 +347,8 @@ public: void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0); + uchar get_size_range(int *minw, int *minh, int *maxw=NULL, int *maxh=NULL, int *dw=NULL, int *dh=NULL, int *aspect=NULL); + /** See void Fl_Window::label(const char*) */ const char* label() const {return Fl_Widget::label();} /** See void Fl_Window::iconlabel(const char*) */ diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 38b3da521..e2e0f8237 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -606,7 +606,7 @@ int Fl_Window::handle(int ev) } /** - Sets the allowable range the user can resize this window to. + Sets the allowable range to which the user can resize this window. We recommend to call size_range() if you have a resizable() widget in a main window, and to call it after setting the resizable() and @@ -677,6 +677,30 @@ void Fl_Window::size_range(int minWidth, int minHeight, pWindowDriver->size_range(); // platform specific stuff } +/** + Gets the allowable range to which the user can resize this window. + + \param[out] minWidth, minHeight, maxWidth, maxHeight, deltaX, deltaY, aspectRatio + are all pointers to integers that will receive the current respective value + during the call. Every pointer can be NULL if that value is not needed. + \retval 0 if size range not set + \retval 1 if the size range was explicitly set by a call to Fl_Window::size_range() + or has been calculated + \see Fl_Window::size_range(int minWidth, int minHeight, int maxWidth, int maxHeight, int deltaX, int deltaY, int aspectRatio) + */ +uchar Fl_Window::get_size_range(int *minWidth, int *minHeight, + int *maxWidth, int *maxHeight, + int *deltaX, int *deltaY, int *aspectRatio) { + if (minWidth) *minWidth = minw_; + if (minHeight) *minHeight = minh_; + if (maxWidth) *maxWidth = maxw_; + if (maxHeight) *maxHeight = maxh_; + if (deltaX) *deltaX = dw_; + if (deltaY) *deltaY = dh_; + if (aspectRatio) *aspectRatio = aspect_; + return size_range_set_; +} + /** Protected method to calculate the default size range of a window. -- cgit v1.2.3