|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: Fl_Window_hotspot.cxx 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // Common hotspot routines for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 #include <FL/Fl.H> 00029 #include <FL/Fl_Window.H> 00030 #include <FL/x.H> 00031 #include <stdio.h> 00032 00033 void Fl_Window::hotspot(int X, int Y, int offscreen) { 00034 int mx,my; 00035 00036 // Update the screen position based on the mouse position. 00037 Fl::get_mouse(mx,my); 00038 X = mx-X; Y = my-Y; 00039 00040 // If offscreen is 0 (the default), make sure that the window 00041 // stays on the screen, if possible. 00042 if (!offscreen) { 00043 int scr_x, scr_y, scr_w, scr_h; 00044 Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h); 00045 00046 int top = 0; 00047 int left = 0; 00048 int right = 0; 00049 int bottom = 0; 00050 00051 if (border()) { 00052 #ifdef WIN32 00053 if (size_range_set && (maxw != minw || maxh != minh)) { 00054 left = right = GetSystemMetrics(SM_CXSIZEFRAME); 00055 top = bottom = GetSystemMetrics(SM_CYSIZEFRAME); 00056 } else { 00057 left = right = GetSystemMetrics(SM_CXFIXEDFRAME); 00058 top = bottom = GetSystemMetrics(SM_CYFIXEDFRAME); 00059 } 00060 top += GetSystemMetrics(SM_CYCAPTION); 00061 #elif defined(__APPLE__) 00062 top = 24; 00063 left = 2; 00064 right = 2; 00065 bottom = 2; 00066 #else 00067 // Ensure border is on screen; these values are generic enough 00068 // to work with many window managers, and are based on KDE defaults. 00069 top = 20; 00070 left = 4; 00071 right = 4; 00072 bottom = 8; 00073 #endif 00074 } 00075 // now insure contents are on-screen (more important than border): 00076 if (X+w()+right > scr_w-scr_x) X = scr_w-scr_x-right-w(); 00077 if (X-left < scr_x) X = left; 00078 if (Y+h()+bottom > scr_h-scr_y) Y = scr_h-scr_y-bottom-h(); 00079 if (Y-top < scr_y) Y = top; 00080 // make sure that we will force this position 00081 if (X==x()) x(X-1); 00082 } 00083 00084 position(X,Y); 00085 } 00086 00087 void Fl_Window::hotspot(const Fl_Widget *o, int offscreen) { 00088 int X = o->w()/2; 00089 int Y = o->h()/2; 00090 while (o != this && o) { 00091 X += o->x(); Y += o->y(); 00092 o = o->window(); 00093 } 00094 hotspot(X,Y,offscreen); 00095 } 00096 00097 00098 // 00099 // End of "$Id: Fl_Window_hotspot.cxx 7903 2010-11-28 21:06:39Z matt $". 00100 //