Exemple #1
0
        static void GetMenuPosition(Gtk.Menu menu,
                                    out int x,
                                    out int y,
                                    out bool push_in)
        {
            if (menu.AttachWidget == null ||
                menu.AttachWidget.GdkWindow == null)
            {
                // Prevent null exception in weird cases
                x       = 0;
                y       = 0;
                push_in = true;
                return;
            }

            menu.AttachWidget.GdkWindow.GetOrigin(out x, out y);
            x += menu.AttachWidget.Allocation.X;

            Gtk.Requisition menu_req = menu.SizeRequest();
            if (y + menu_req.Height >= menu.AttachWidget.Screen.Height)
            {
                y -= menu_req.Height;
            }
            else
            {
                y += menu.AttachWidget.Allocation.Height;
            }

            push_in = true;
        }
Exemple #2
0
        public static void GetMenuPosition(Gtk.Menu menu,
                                           out int x,
                                           out int y,
                                           out bool push_in)
        {
            Gtk.Requisition menu_req = menu.SizeRequest();

            menu.AttachWidget.GdkWindow.GetOrigin(out x, out y);

            if (y + menu_req.Height >= menu.AttachWidget.Screen.Height)
            {
                y -= menu_req.Height;
            }
            else
            {
                y += menu.AttachWidget.Allocation.Height;
            }

            push_in = true;
        }
Exemple #3
0
        void PositionFunc(Gtk.Menu mn, out int x, out int y, out bool push_in)
        {
            this.GdkWindow.GetOrigin(out x, out y);
            Gdk.Rectangle rect = this.Allocation;
            x += rect.X;
            y += rect.Y + rect.Height;

            //if the menu would be off the bottom of the screen, "drop" it upwards
            if (y + mn.Requisition.Height > this.Screen.Height)
            {
                y -= mn.Requisition.Height;
                y -= rect.Height;
            }
            if (mn.SizeRequest().Width < rect.Width)
            {
                mn.WidthRequest = rect.Width;
            }

            //let GTK reposition the button if it still doesn't fit on the screen
            push_in = true;
        }
Exemple #4
0
        public void GetTrayMenuPosition(Gtk.Menu menu,
                                        out int x,
                                        out int y,
                                        out bool push_in)
        {
            // some default values in case something goes wrong
            push_in = true;
            x       = 0;
            y       = 0;

            Gdk.Screen    screen;
            Gdk.Rectangle area;
            try {
#if WIN32 || MAC
                menu.Screen.Display.GetPointer(out x, out y);
                screen      = menu.Screen;
                area.Height = 0;
#else
                Gtk.Orientation orientation;
                GetGeometry(out screen, out area, out orientation);
                x = area.X;
                y = area.Y;
#endif

                Gtk.Requisition menu_req = menu.SizeRequest();
                if (y + menu_req.Height >= screen.Height)
                {
                    y -= menu_req.Height;
                }
                else
                {
                    y += area.Height;
                }
            } catch (Exception e) {
                Logger.Error("Exception in GetTrayMenuPosition: " + e.ToString());
            }
        }