diff options
| author | Manolo Gouy <Manolo> | 2016-03-23 17:13:09 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-23 17:13:09 +0000 |
| commit | e3ee1e7b81c9b1a8806b80cd69c66eeccc679bf9 (patch) | |
| tree | 60f70f3960bb65296b42884bed91f8a165ee9f3f /src | |
| parent | 6608db0b0c88fb01a903c47b9e1bbed477766ec2 (diff) | |
Rewrite Fl_Window::size_range_() under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11410 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Window.cxx | 47 | ||||
| -rw-r--r-- | src/Fl_Window_Driver.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 11 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 5 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.cxx | 5 |
8 files changed, 64 insertions, 14 deletions
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 8cf091427..70701bab6 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -554,6 +554,53 @@ int Fl_Window::handle(int ev) return Fl_Group::handle(ev); } +/** + Sets the allowable range the user can resize this window to. + This only works for top-level windows. + <UL> + <LI>\p minw and \p minh are the smallest the window can be. + Either value must be greater than 0.</LI> + <LI>\p maxw and \p maxh are the largest the window can be. If either is + <I>equal</I> to the minimum then you cannot resize in that direction. + If either is zero then FLTK picks a maximum size in that direction + such that the window will fill the screen.</LI> + <LI>\p dw and \p dh are size increments. The window will be constrained + to widths of minw + N * dw, where N is any non-negative integer. + If these are less or equal to 1 they are ignored (this is ignored + on WIN32).</LI> + <LI>\p aspect is a flag that indicates that the window should preserve its + aspect ratio. This only works if both the maximum and minimum have + the same aspect ratio (ignored on WIN32 and by many X window managers). + </LI> + </UL> + + If this function is not called, FLTK tries to figure out the range + from the setting of resizable(): + <UL> + <LI>If resizable() is NULL (this is the default) then the window cannot + be resized and the resize border and max-size control will not be + displayed for the window.</LI> + <LI>If either dimension of resizable() is less than 100, then that is + considered the minimum size. Otherwise the resizable() has a minimum + size of 100.</LI> + <LI>If either dimension of resizable() is zero, then that is also the + maximum size (so the window cannot resize in that direction).</LI> + </UL> + + It is undefined what happens if the current size does not fit in the + constraints passed to size_range(). + */ +void Fl_Window::size_range(int minw, int minh, int maxw, int maxh, int dw, int dh, int aspect) { + this->minw = minw; + this->minh = minh; + this->maxw = maxw; + this->maxh = maxh; + this->dw = dw; + this->dh = dh; + this->aspect = aspect; + pWindowDriver->size_range(); +} + // // End of "$Id$". // diff --git a/src/Fl_Window_Driver.cxx b/src/Fl_Window_Driver.cxx index ef6c49c3b..6627ed069 100644 --- a/src/Fl_Window_Driver.cxx +++ b/src/Fl_Window_Driver.cxx @@ -204,6 +204,10 @@ void Fl_Window_Driver::use_border() { } } +void Fl_Window_Driver::size_range() { + pWindow->size_range_set = 1; +} + // // End of "$Id$". // diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 88199d9bc..5a29767ac 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3036,7 +3036,7 @@ void Fl_X::make(Fl_Window* w) // Install DnD handlers [myview registerForDraggedTypes:[NSArray arrayWithObjects:UTF8_pasteboard_type, NSFilenamesPboardType, nil]]; - if (w->size_range_set) w->size_range_(); + if (w->size_range_set) w->pWindowDriver->size_range(); if ( w->border() || (!w->modal() && !w->tooltip_window()) ) { Fl_Tooltip::enter(0); @@ -3077,12 +3077,13 @@ void Fl_X::make(Fl_Window* w) /* * Tell the OS what window sizes we want to allow */ -void Fl_Window::size_range_() { +void Fl_Cocoa_Window_Driver::size_range() { int bx, by, bt; get_window_frame_sizes(bx, by, bt); - size_range_set = 1; - NSSize minSize = NSMakeSize(minw, minh + bt); - NSSize maxSize = NSMakeSize(maxw?maxw:32000, maxh?maxh + bt:32000); + Fl_Window_Driver::size_range(); + NSSize minSize = NSMakeSize(minw(), minh() + bt); + NSSize maxSize = NSMakeSize(maxw() ? maxw():32000, maxh() ? maxh() + bt:32000); + Fl_X *i = Fl_X::i(pWindow); if (i && i->xid) { [i->xid setMinSize:minSize]; [i->xid setMaxSize:maxSize]; diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index a2940940b..ef83d833e 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1878,10 +1878,6 @@ Fl_X* Fl_X::make(Fl_Window* w) { HINSTANCE fl_display = GetModuleHandle(NULL); -void Fl_Window::size_range_() { - size_range_set = 1; -} - void Fl_X::set_minmax(LPMINMAXINFO minmax) { int td, wd, hd, dummy_x, dummy_y; diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index b88393fd9..9e73011a9 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2656,11 +2656,6 @@ void Fl_X::sendxjunk() { XFree(hints); } -void Fl_Window::size_range_() { - size_range_set = 1; - if (shown()) i->sendxjunk(); -} - //////////////////////////////////////////////////////////////// static unsigned long *default_net_wm_icons = 0L; diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H index 7bb5b370f..f3d8a85be 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H @@ -82,6 +82,7 @@ public: virtual void unmap(); virtual void fullscreen_on(); virtual void fullscreen_off(int X, int Y, int W, int H); + virtual void size_range(); virtual void shape(const Fl_Image* img); // that one is implemented in Fl_Cocoa.mm because it uses Objective-c diff --git a/src/drivers/X11/Fl_X11_Window_Driver.H b/src/drivers/X11/Fl_X11_Window_Driver.H index 95508a7cd..47272a834 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.H +++ b/src/drivers/X11/Fl_X11_Window_Driver.H @@ -97,6 +97,7 @@ public: virtual void fullscreen_on(); virtual void fullscreen_off(int X, int Y, int W, int H); virtual void use_border(); + virtual void size_range(); virtual void shape(const Fl_Image* img); virtual void icons(const Fl_RGB_Image *icons[], int count); diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 7beb6d9af..2daf3f347 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -499,6 +499,11 @@ void Fl_X11_Window_Driver::use_border() { if (pWindow->shown()) Fl_X::i(pWindow)->sendxjunk(); } +void Fl_X11_Window_Driver::size_range() { + Fl_Window_Driver::size_range(); + if (pWindow->shown()) Fl_X::i(pWindow)->sendxjunk(); +} + // // End of "$Id$". // |
