summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2004-11-23 01:48:25 +0000
committerMatthias Melcher <fltk@matthiasm.com>2004-11-23 01:48:25 +0000
commit7ca20dcd4a1aab740635a9e5150f051a98ca8c0d (patch)
tree74205a6093b7255d49634e4196429c918660788b
parent8a5fcb11b5a1aba6fbe8b490a754e017003afb31 (diff)
STR#628: fixed almost all instances where the popup menu would
jump to the main screen. Very few extremes do not work 100%, but that would require much more information in the menu calls. Nothing to worry about. Anyway, jumping menus are fixed on the Mac. Linux and Windows may require similar solutions, however, setups with two different screen size are rare on those systems. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3914 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_Menu.cxx53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index 3d0359af2..7ac765b8a 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.34 2004/10/18 20:22:23 easysw Exp $"
+// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.35 2004/11/23 01:48:25 matthiaswm Exp $"
//
// Menu code for the Fast Light Tool Kit (FLTK).
//
@@ -35,6 +35,10 @@
#include <FL/fl_draw.H>
#include <stdio.h>
+#ifdef __APPLE__
+# include <Carbon/Carbon.H>
+#endif
+
int Fl_Menu_Item::size() const {
const Fl_Menu_Item* m = this;
int nest = 0;
@@ -234,7 +238,27 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
int menubar, int menubar_title, int right_edge)
: Fl_Menu_Window(X, Y, Wp, Hp, 0)
{
- if (!right_edge) right_edge = Fl::w();
+ int scr_right = Fl::x() + Fl::w();
+ int scr_x = Fl::x();
+#ifdef __APPLE__
+ GDHandle gd = 0L;
+ for ( gd = GetDeviceList(); gd; gd = GetNextDevice(gd) ) {
+ GDPtr gp = *gd;
+ if ( X >= gp->gdRect.left && X <= gp->gdRect.right
+ && Y >= gp->gdRect.top && Y <= gp->gdRect.bottom)
+ break;
+ }
+ if ( !gd ) gd = GetMainDevice();
+ if ( gd ) {
+ // since the menu pops over everything, we use the screen
+ // bounds, right across the dock and menu bar
+ GDPtr gp = *gd;
+ scr_right = gp->gdRect.right;
+ scr_x = gp->gdRect.left;
+ }
+#endif
+
+ if (!right_edge) right_edge = scr_right;
end();
set_modal();
@@ -290,7 +314,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
if (Wp > W) W = Wp;
if (Wtitle > W) W = Wtitle;
- if (!Wp) {if (X < 0) X = 0; if (X > Fl::w()-W) X= right_edge-W;}
+ if (!Wp) {if (X < scr_x) X = scr_x; if (X > scr_right-W) X= right_edge-W;}
x(X); w(W);
h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+3);
if (selected >= 0)
@@ -319,10 +343,27 @@ void menuwindow::position(int X, int Y) {
// scroll so item i is visible on screen
void menuwindow::autoscroll(int n) {
+ int scr_y = Fl::y(), scr_h = Fl::h();
int Y = y()+Fl::box_dx(box())+2+n*itemheight;
- if (Y <= Fl::y()) Y = Fl::y()-Y+10;
+#ifdef __APPLE__
+ GDHandle gd = 0L;
+ for ( gd = GetDeviceList(); gd; gd = GetNextDevice(gd) ) {
+ GDPtr gp = *gd;
+ if ( x() >= gp->gdRect.left && x() <= gp->gdRect.right
+ && Y >= gp->gdRect.top && Y <= gp->gdRect.bottom)
+ break;
+ }
+ if ( !gd ) gd = GetMainDevice();
+ if ( gd ) {
+ // since the menu pops over everything, we use the screen
+ // bounds, right across the dock and menu bar
+ GDPtr gp = *gd;
+ scr_y = gp->gdRect.top; scr_h = gp->gdRect.bottom - gp->gdRect.top + 1;
+ }
+#endif
+ if (Y <= scr_y) Y = scr_y-Y+10;
else {
- Y = Y+itemheight-Fl::h()-Fl::y();
+ Y = Y+itemheight-scr_h-scr_y;
if (Y < 0) return;
Y = -Y-10;
}
@@ -791,5 +832,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
}
//
-// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.34 2004/10/18 20:22:23 easysw Exp $".
+// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.35 2004/11/23 01:48:25 matthiaswm Exp $".
//