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
This commit is contained in:
Manolo Gouy
2016-03-23 17:13:09 +00:00
parent 6608db0b0c
commit e3ee1e7b81
10 changed files with 68 additions and 63 deletions
+3 -49
View File
@@ -22,8 +22,8 @@
#ifndef Fl_Window_H
#define Fl_Window_H
#include "Fl_Group.H"
#include "Fl_Bitmap.H"
#include <FL/Fl_Group.H>
#include <FL/Fl_Bitmap.H>
#include <stdlib.h>
#define FL_WINDOW 0xF0 ///< window type id all subclasses have type() >= this
@@ -80,7 +80,6 @@ class FL_EXPORT Fl_Window : public Fl_Group {
private:
void size_range_();
void _Fl_Window(); // constructor innards
// unimplemented copy ctor and assignment operator
@@ -324,52 +323,7 @@ public:
\deprecated please use force_position(0) instead
*/
void free_position() {clear_flag(FORCE_POSITION);}
/**
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 size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0) {
this->minw = minw;
this->minh = minh;
this->maxw = maxw;
this->maxh = maxh;
this->dw = dw;
this->dh = dh;
this->aspect = aspect;
size_range_();
}
void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0);
/** See void Fl_Window::label(const char*) */
const char* label() const {return Fl_Widget::label();}
+1
View File
@@ -94,6 +94,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();
// --- window shape stuff
void shape_pixmap_(Fl_Image* pixmap); // TODO: check
+47
View File
@@ -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$".
//
+4
View File
@@ -204,6 +204,10 @@ void Fl_Window_Driver::use_border() {
}
}
void Fl_Window_Driver::size_range() {
pWindow->size_range_set = 1;
}
//
// End of "$Id$".
//
+6 -5
View File
@@ -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];
-4
View File
@@ -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;
-5
View File
@@ -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;
@@ -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
+1
View File
@@ -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);
+5
View File
@@ -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$".
//