Rewrite Fl_Window::resize() under the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11401 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
6ec8ebc4f8
commit
bf7e4de688
@ -58,6 +58,9 @@ public:
|
||||
int maxw();
|
||||
int maxh();
|
||||
unsigned char size_range_set();
|
||||
void force_position(int c);
|
||||
void x(int X);
|
||||
void y(int Y);
|
||||
|
||||
// --- window data
|
||||
virtual int decorated_w() = 0;
|
||||
@ -79,6 +82,7 @@ public:
|
||||
virtual void destroy_double_buffer(); // TODO: check
|
||||
virtual void show();
|
||||
virtual void show_menu();
|
||||
virtual void resize(int X,int Y,int W,int H) {}
|
||||
|
||||
// --- window shape stuff
|
||||
void shape_pixmap_(Fl_Image* pixmap); // TODO: check
|
||||
|
@ -51,11 +51,6 @@ void Fl_Double_Window::show() {
|
||||
}
|
||||
|
||||
|
||||
/*char fl_can_do_alpha_blending() {
|
||||
return Fl_Display_Device::display_device()->driver()->can_do_alpha_blending();
|
||||
}*/
|
||||
|
||||
|
||||
void Fl_Double_Window::resize(int X,int Y,int W,int H) {
|
||||
int ow = w();
|
||||
int oh = h();
|
||||
@ -65,6 +60,7 @@ void Fl_Double_Window::resize(int X,int Y,int W,int H) {
|
||||
driver()->destroy_double_buffer();
|
||||
}
|
||||
|
||||
|
||||
void Fl_Double_Window::hide() {
|
||||
Fl_X *myi = Fl_X::i(this);
|
||||
if (myi && myi->other_xid) {
|
||||
@ -89,9 +85,6 @@ Fl_Double_Window::~Fl_Double_Window() {
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -506,6 +506,10 @@ void Fl_Window::show() {
|
||||
pWindowDriver->show();
|
||||
}
|
||||
|
||||
void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
pWindowDriver->resize(X, Y, W, H);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -38,6 +38,10 @@ int Fl_Window_Driver::minw() {return pWindow->minw;}
|
||||
int Fl_Window_Driver::minh() {return pWindow->minh;}
|
||||
int Fl_Window_Driver::maxw() {return pWindow->maxw;}
|
||||
int Fl_Window_Driver::maxh() {return pWindow->maxh;}
|
||||
void Fl_Window_Driver::force_position(int c) { pWindow->force_position(c); }
|
||||
void Fl_Window_Driver::x(int X) {pWindow->x(X); }
|
||||
void Fl_Window_Driver::y(int Y) {pWindow->y(Y); }
|
||||
|
||||
unsigned char Fl_Window_Driver::size_range_set() {return pWindow->size_range_set;}
|
||||
|
||||
void Fl_Window_Driver::flush_single() { pWindow->Fl_Window::flush(); }
|
||||
|
@ -3169,60 +3169,61 @@ void Fl_Cocoa_Window_Driver::show() {
|
||||
/*
|
||||
* resize a window
|
||||
*/
|
||||
void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
void Fl_Cocoa_Window_Driver::resize(int X,int Y,int W,int H) {
|
||||
int bx, by, bt;
|
||||
Fl_Window *parent;
|
||||
if (W<=0) W = 1; // OS X does not like zero width windows
|
||||
if (H<=0) H = 1;
|
||||
int is_a_resize = (W != w() || H != h());
|
||||
int is_a_resize = (W != pWindow->w() || H != pWindow->h());
|
||||
// printf("Fl_Window::resize(X=%d, Y=%d, W=%d, H=%d), is_a_resize=%d, resize_from_system=%p, this=%p\n",
|
||||
// X, Y, W, H, is_a_resize, resize_from_system, this);
|
||||
if (X != x() || Y != y()) set_flag(FORCE_POSITION);
|
||||
if (X != pWindow->x() || Y != pWindow->y()) force_position(1);
|
||||
else if (!is_a_resize) {
|
||||
resize_from_system = 0;
|
||||
return;
|
||||
}
|
||||
if ( (resize_from_system!=this) && shown()) {
|
||||
if ( (resize_from_system != pWindow) && pWindow->shown()) {
|
||||
if (is_a_resize) {
|
||||
if (resizable()) {
|
||||
if (W<minw) minw = W; // user request for resize takes priority
|
||||
if (maxw && W>maxw) maxw = W; // over a previously set size_range
|
||||
if (H<minh) minh = H;
|
||||
if (maxh && H>maxh) maxh = H;
|
||||
size_range(minw, minh, maxw, maxh);
|
||||
if (pWindow->resizable()) {
|
||||
int min_w = minw(), max_w = maxw(), min_h = minh(), max_h = maxh();
|
||||
if (W<min_w) min_w = W; // user request for resize takes priority
|
||||
if (max_w && W>max_w) max_w = W; // over a previously set size_range
|
||||
if (H<min_h) min_h = H;
|
||||
if (max_h && H>max_h) max_h = H;
|
||||
pWindow->size_range(min_w, min_h, max_w, max_h);
|
||||
} else {
|
||||
size_range(W, H, W, H);
|
||||
pWindow->size_range(W, H, W, H);
|
||||
}
|
||||
Fl_Group::resize(X,Y,W,H);
|
||||
pWindow->Fl_Group::resize(X,Y,W,H);
|
||||
// transmit changes in FLTK coords to cocoa
|
||||
get_window_frame_sizes(bx, by, bt);
|
||||
bx = X; by = Y;
|
||||
parent = window();
|
||||
parent = pWindow->window();
|
||||
while (parent) {
|
||||
bx += parent->x();
|
||||
by += parent->y();
|
||||
parent = parent->window();
|
||||
}
|
||||
NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + (border()?bt:0));
|
||||
if (visible_r()) [fl_xid(this) setFrame:r display:YES];
|
||||
NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + (pWindow->border()?bt:0));
|
||||
if (pWindow->visible_r()) [fl_xid(pWindow) setFrame:r display:YES];
|
||||
} else {
|
||||
bx = X; by = Y;
|
||||
parent = window();
|
||||
parent = pWindow->window();
|
||||
while (parent) {
|
||||
bx += parent->x();
|
||||
by += parent->y();
|
||||
parent = parent->window();
|
||||
}
|
||||
NSPoint pt = NSMakePoint(bx, main_screen_height - (by + H));
|
||||
if (visible_r()) [fl_xid(this) setFrameOrigin:pt]; // set cocoa coords to FLTK position
|
||||
if (pWindow->visible_r()) [fl_xid(pWindow) setFrameOrigin:pt]; // set cocoa coords to FLTK position
|
||||
}
|
||||
}
|
||||
else {
|
||||
resize_from_system = 0;
|
||||
if (is_a_resize) {
|
||||
Fl_Group::resize(X,Y,W,H);
|
||||
if (shown()) {
|
||||
redraw();
|
||||
pWindow->Fl_Group::resize(X,Y,W,H);
|
||||
if (pWindow->shown()) {
|
||||
pWindow->redraw();
|
||||
}
|
||||
} else {
|
||||
x(X); y(Y);
|
||||
|
@ -1560,24 +1560,25 @@ int Fl_X::fake_X_wm(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by)
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
void Fl_WinAPI_Window_Driver::resize(int X,int Y,int W,int H) {
|
||||
UINT flags = SWP_NOSENDCHANGING | SWP_NOZORDER
|
||||
| SWP_NOACTIVATE | SWP_NOOWNERZORDER;
|
||||
int is_a_resize = (W != w() || H != h());
|
||||
int resize_from_program = (this != resize_bug_fix);
|
||||
int is_a_resize = (W != pWindow->w() || H != pWindow->h());
|
||||
int resize_from_program = (pWindow != resize_bug_fix);
|
||||
if (!resize_from_program) resize_bug_fix = 0;
|
||||
if (X != x() || Y != y()) {
|
||||
if (X != pWindow->x() || Y != pWindow->y()) {
|
||||
force_position(1);
|
||||
} else {
|
||||
if (!is_a_resize) return;
|
||||
flags |= SWP_NOMOVE;
|
||||
}
|
||||
if (is_a_resize) {
|
||||
Fl_Group::resize(X,Y,W,H);
|
||||
if (visible_r()) {
|
||||
redraw();
|
||||
pWindow->Fl_Group::resize(X,Y,W,H);
|
||||
if (pWindow->visible_r()) {
|
||||
pWindow->redraw();
|
||||
// only wait for exposure if this window has a size - a window
|
||||
// with no width or height will never get an exposure event
|
||||
Fl_X *i = Fl_X::i(pWindow);
|
||||
if (i && W>0 && H>0)
|
||||
i->wait_for_expose = 1;
|
||||
}
|
||||
@ -1585,13 +1586,13 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
x(X); y(Y);
|
||||
flags |= SWP_NOSIZE;
|
||||
}
|
||||
if (!border()) flags |= SWP_NOACTIVATE;
|
||||
if (resize_from_program && shown()) {
|
||||
if (!resizable()) size_range(w(),h(),w(),h());
|
||||
if (!pWindow->border()) flags |= SWP_NOACTIVATE;
|
||||
if (resize_from_program && pWindow->shown()) {
|
||||
if (!pWindow->resizable()) pWindow->size_range(pWindow->w(), pWindow->h(), pWindow->w(), pWindow->h());
|
||||
int dummy_x, dummy_y, bt, bx, by;
|
||||
//Ignore window managing when resizing, so that windows (and more
|
||||
//specifically menus) can be moved offscreen.
|
||||
if (Fl_X::fake_X_wm(this, dummy_x, dummy_y, bt, bx, by)) {
|
||||
if (Fl_X::fake_X_wm(pWindow, dummy_x, dummy_y, bt, bx, by)) {
|
||||
X -= bx;
|
||||
Y -= by+bt;
|
||||
W += 2*bx;
|
||||
@ -1601,7 +1602,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
// will cause continouly new redraw events.
|
||||
if (W<=0) W = 1;
|
||||
if (H<=0) H = 1;
|
||||
SetWindowPos(i->xid, 0, X, Y, W, H, flags);
|
||||
SetWindowPos(fl_xid(pWindow), 0, X, Y, W, H, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
28
src/Fl_x.cxx
28
src/Fl_x.cxx
@ -2124,34 +2124,34 @@ fprintf(stderr,"\n");*/
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void Fl_Window::resize(int X,int Y,int W,int H) {
|
||||
int is_a_move = (X != x() || Y != y());
|
||||
int is_a_resize = (W != w() || H != h());
|
||||
int resize_from_program = (this != resize_bug_fix);
|
||||
void Fl_X11_Window_Driver::resize(int X,int Y,int W,int H) {
|
||||
int is_a_move = (X != pWindow->x() || Y != pWindow->y());
|
||||
int is_a_resize = (W != pWindow->w() || H != pWindow->h());
|
||||
int resize_from_program = (pWindow != resize_bug_fix);
|
||||
if (!resize_from_program) resize_bug_fix = 0;
|
||||
if (is_a_move && resize_from_program) set_flag(FORCE_POSITION);
|
||||
if (is_a_move && resize_from_program) force_position(1);
|
||||
else if (!is_a_resize && !is_a_move) return;
|
||||
if (is_a_resize) {
|
||||
Fl_Group::resize(X,Y,W,H);
|
||||
if (shown()) {redraw();}
|
||||
pWindow->Fl_Group::resize(X,Y,W,H);
|
||||
if (pWindow->shown()) {pWindow->redraw();}
|
||||
} else {
|
||||
x(X); y(Y);
|
||||
}
|
||||
|
||||
if (resize_from_program && is_a_resize && !resizable()) {
|
||||
size_range(w(), h(), w(), h());
|
||||
if (resize_from_program && is_a_resize && !pWindow->resizable()) {
|
||||
pWindow->size_range(pWindow->w(), pWindow->h(), pWindow->w(), pWindow->h());
|
||||
}
|
||||
|
||||
if (resize_from_program && shown()) {
|
||||
if (resize_from_program && pWindow->shown()) {
|
||||
if (is_a_resize) {
|
||||
if (!resizable()) size_range(w(),h(),w(),h());
|
||||
if (!pWindow->resizable()) pWindow->size_range(pWindow->w(), pWindow->h(), pWindow->w(), pWindow->h());
|
||||
if (is_a_move) {
|
||||
XMoveResizeWindow(fl_display, i->xid, X, Y, W>0 ? W : 1, H>0 ? H : 1);
|
||||
XMoveResizeWindow(fl_display, fl_xid(pWindow), X, Y, W>0 ? W : 1, H>0 ? H : 1);
|
||||
} else {
|
||||
XResizeWindow(fl_display, i->xid, W>0 ? W : 1, H>0 ? H : 1);
|
||||
XResizeWindow(fl_display, fl_xid(pWindow), W>0 ? W : 1, H>0 ? H : 1);
|
||||
}
|
||||
} else
|
||||
XMoveWindow(fl_display, i->xid, X, Y);
|
||||
XMoveWindow(fl_display, fl_xid(pWindow), X, Y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
virtual void make_current();
|
||||
virtual void label(const char *name, const char *mininame);
|
||||
virtual void show();
|
||||
virtual void resize(int X,int Y,int W,int H);
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
// that one is implemented in Fl_Cocoa.mm because it uses Objective-c
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
virtual void make_current();
|
||||
virtual void show();
|
||||
virtual void label(const char *name,const char *iname);
|
||||
virtual void resize(int X,int Y,int W,int H);
|
||||
|
||||
virtual void shape(const Fl_Image* img);
|
||||
virtual void icons(const Fl_RGB_Image *icons[], int count);
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
virtual void make_current();
|
||||
virtual void show();
|
||||
virtual void show_menu();
|
||||
virtual void resize(int X,int Y,int W,int H);
|
||||
virtual void label(const char *name, const char *mininame);
|
||||
virtual void destroy_double_buffer();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user