Exemple #1
0
 protected override void OnSizeRequested(ref Requisition requisition)
 {
     if (child != null)
     {
         requisition         = child.SizeRequest();
         requisition.Width  += leftMargin + rightMargin + leftPadding + rightPadding;
         requisition.Height += topMargin + bottomMargin + topPadding + bottomPadding;
     }
     else
     {
         requisition.Width  = 0;
         requisition.Height = 0;
     }
 }
Exemple #2
0
        void PositionWidget(Gtk.Widget widget)
        {
            if (!(widget is Gtk.Window))
            {
                return;
            }
            int ox, oy;

            ParentWindow.GetOrigin(out ox, out oy);
            int w;
            int itemXPosition = GetHoverXPosition(out w);
            int dx            = ox + this.Allocation.X + itemXPosition;
            int dy            = oy + this.Allocation.Bottom;

            var req = widget.SizeRequest();

            Xwt.Rectangle geometry  = IdeServices.DesktopService.GetUsableMonitorGeometry(Screen.Number, Screen.GetMonitorAtPoint(dx, dy));
            int           geomWidth = (int)geometry.Width;
            int           geomLeft  = (int)geometry.Left;
            int           geomRight = (int)geometry.Right;
            int           width     = System.Math.Max(req.Width, w);

            if (width >= geomWidth - spacing * 2)
            {
                width = geomWidth - spacing * 2;
                dx    = geomLeft + spacing;
            }
            widget.WidthRequest = width;
            if (dy + req.Height > geometry.Bottom)
            {
                dy = oy + this.Allocation.Y - req.Height;
            }
            if (dx + width > geomRight)
            {
                dx = geomRight - width;
            }
            (widget as Gtk.Window).Move(dx, dy);
            (widget as Gtk.Window).Resize(width, req.Height);
            widget.GrabFocus();
        }
		bool CalcWidgetPosition (TopLevelWidgetExtension widgetExtension, Widget w, out int x, out int y)
		{
			DocumentLine line = widget.TextEditor.Document.GetLine (widgetExtension.Line);
			if (line == null) {
				x = y = 0;
				return false;
			}

			int lw, lh;
			var tmpWrapper = widget.TextEditor.TextViewMargin.GetLayout (line);
			tmpWrapper.Layout.GetPixelSize (out lw, out lh);
			if (tmpWrapper.IsUncached)
				tmpWrapper.Dispose ();
			lh = (int) TextEditor.TextViewMargin.GetLineHeight (widgetExtension.Line);
			x = (int)widget.TextEditor.TextViewMargin.XOffset + lw + 4;
			y = (int)widget.TextEditor.LineToY (widgetExtension.Line);
			int lineStart = (int)widget.TextEditor.TextViewMargin.XOffset;
			var size = w.SizeRequest ();

			switch (widgetExtension.HorizontalAlignment) {
			case HorizontalAlignment.LineLeft:
				x = (int)widget.TextEditor.TextViewMargin.XOffset;
				break;
			case HorizontalAlignment.LineRight:
				x = lineStart + lw + 4;
				break;
			case HorizontalAlignment.LineCenter:
				x = lineStart + (lw - size.Width) / 2;
				if (x < lineStart)
					x = lineStart;
				break;
			case HorizontalAlignment.Left:
				x = 0;
				break;
			case HorizontalAlignment.Right:
				break;
			case HorizontalAlignment.Center:
				break;
			case HorizontalAlignment.ViewLeft:
				break;
			case HorizontalAlignment.ViewRight:
				break;
			case HorizontalAlignment.ViewCenter:
				break;
			}

			switch (widgetExtension.VerticalAlignment) {
			case VerticalAlignment.LineTop:
				break; // the default
			case VerticalAlignment.LineBottom:
				y += lh - size.Height;
				break;
			case VerticalAlignment.LineCenter:
				y = y + (lh - size.Height) / 2;
				break;
			case VerticalAlignment.AboveLine:
				y -= size.Height;
				break;
			case VerticalAlignment.BelowLine:
				y += lh;
				break;
			}
			x += widgetExtension.OffsetX;
			y += widgetExtension.OffsetY;

			//We don't want Widget to appear outside TextArea(cut off)...
			x = Math.Max (0, x);
			y = Math.Max (0, y);
			return true;
		}
        private bool PositionWidget (Widget widget, out int x, out int y, int yPadding)
        {
            int button_y, panel_width, panel_height;
            Gtk.Requisition requisition = widget.SizeRequest ();

            event_box.GdkWindow.GetOrigin (out x, out button_y);
            (event_box.Toplevel as Gtk.Window).GetSize (out panel_width, out panel_height);

            bool on_bottom = button_y + panel_height + requisition.Height >= event_box.Screen.Height;

            y = on_bottom
                ? button_y - requisition.Height - yPadding
                : button_y + panel_height + yPadding;

            return on_bottom;
        }
Exemple #5
0
        void SizeRequestGrid(Grid grid, ref Gtk.Requisition req)
        {
            bool visible = true;

            req.Width = req.Height = 0;
            foreach (object obj in grid.lines)
            {
                if (obj is Expander)
                {
                    Gtk.Widget      w = (Gtk.Widget)obj;
                    Gtk.Requisition childreq;

                    childreq = w.SizeRequest();
                    if (req.Width < childreq.Width)
                    {
                        req.Width = childreq.Width;
                    }
                    req.Height += groupPad + childreq.Height;

                    visible = ((Gtk.Expander)obj).Expanded;

                    if (indent == -1)
                    {
                        // Seems like there should be an easier way...
                        int focusWidth      = (int)w.StyleGetProperty("focus-line-width");
                        int focusPad        = (int)w.StyleGetProperty("focus-padding");
                        int expanderSize    = (int)w.StyleGetProperty("expander-size");
                        int expanderSpacing = (int)w.StyleGetProperty("expander-spacing");
                        indent = focusWidth + focusPad + expanderSize + 2 * expanderSpacing;
                    }
                }
                else if (obj is Widget)
                {
                    Gtk.Widget      w = (Gtk.Widget)obj;
                    Gtk.Requisition childreq;

                    childreq = w.SizeRequest();
                    if (lwidth < childreq.Width)
                    {
                        lwidth = childreq.Width;
                    }
                    if (visible)
                    {
                        req.Height += linePad + childreq.Height;
                    }
                }
                else if (obj is Pair)
                {
                    Pair            p = (Pair)obj;
                    Gtk.Requisition lreq, ereq;

                    lreq = p.Label.SizeRequest();
                    ereq = p.Editor.SizeRequest();

                    if (lineHeight == -1)
                    {
                        lineHeight = (int)(1.5 * lreq.Height);
                    }

                    if (lreq.Width > lwidth)
                    {
                        lwidth = lreq.Width;
                    }
                    if (ereq.Width > ewidth)
                    {
                        ewidth = ereq.Width;
                    }

                    if (visible)
                    {
                        req.Height += Math.Max(lineHeight, ereq.Height) + linePad;
                    }
                }
            }

            req.Width   = Math.Max(req.Width, indent + lwidth + hPad + ewidth);
            req.Height += 2 * (int)BorderWidth;
            req.Width  += 2 * (int)BorderWidth;
        }
        private void SetColumnWidth(int index, Widget widget, int width, bool? visible = null)
        {
            Column c = mColumns[widget];
             if (c != null)
             {
            if (visible != null)
               c.Visible = visible.Value;
            int dx = width - c.Width;
            c.Width += dx;
            Requisition r = widget.SizeRequest();
            widget.SetSizeRequest(c.Width, r.Height);
            this.Move(widget, c.X - mCurrentScollOffset, TopOffset); // move to same position, helper to redraw parent

            // move all following
            for (int i = index + 1; i < mColumns.Count; i++)
            {
               var kvp = mColumns.ElementAt(i);
               c = kvp.Value;
               if (c.Visible)
               {
                  widget = kvp.Key;
                  c.X += dx;
                  this.Move(widget, c.X - mCurrentScollOffset, TopOffset);
               }
            }
             }
        }
Exemple #7
0
		public void add_tool(Widget w) {
			if(w is Button || w is ToggleButton) {
				w.HeightRequest = 30;
				((Button)w).Relief = ReliefStyle.None;
			} else if (w is ComboBox || w is ComboBoxEntry) {
				w.WidthRequest = 200;
				w.HeightRequest = 30;
			} else if (w is Label) {
				w.HeightRequest = 30;
			} else if (w is VSeparator) {
				w.HeightRequest = 30;
				w.WidthRequest = 5;
			}
			this.fixed1.Add(w);
			this.fixed1.Move(w,_nextx,_y);
			_nextx = _nextx + w.SizeRequest().Width + _spacing;
			w.ShowAll();
			w.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) {
				this.image1.TooltipText = ((Widget)o).TooltipText;
			};
			w.LeaveNotifyEvent += delegate(object o, LeaveNotifyEventArgs args) {
				this.image1.TooltipText = "";
			};
		}