public override void DrawMaximizedButtons(object sender, PaintEventArgs pe) { Size_ bs = ThemeEngine.Current.ManagedWindowGetMenuButtonSize(this); Point_ pnt = XplatUI.GetMenuOrigin(mdi_container.ParentForm.Handle); int bw = ThemeEngine.Current.ManagedWindowBorderWidth(this); TitleButtons buttons = MaximizedTitleButtons; buttons.Visible = true; TitleButtons.Visible = false; buttons.CloseButton.Rectangle = new Rectangle_(mdi_container.ParentForm.Size.Width - 1 - bw - bs.Width - 2, pnt.Y + 2, bs.Width, bs.Height); buttons.RestoreButton.Rectangle = new Rectangle_(buttons.CloseButton.Rectangle.Left - 2 - bs.Width, pnt.Y + 2, bs.Width, bs.Height); buttons.MinimizeButton.Rectangle = new Rectangle_(buttons.RestoreButton.Rectangle.Left - bs.Width, pnt.Y + 2, bs.Width, bs.Height); DrawTitleButton(pe.Graphics, buttons.MinimizeButton, pe.ClipRectangle); DrawTitleButton(pe.Graphics, buttons.RestoreButton, pe.ClipRectangle); DrawTitleButton(pe.Graphics, buttons.CloseButton, pe.ClipRectangle); buttons.MinimizeButton.Rectangle.Y -= pnt.Y; buttons.RestoreButton.Rectangle.Y -= pnt.Y; buttons.CloseButton.Rectangle.Y -= pnt.Y; }
static TextBoxTextRenderer() { // On Windows, we want to use TextRenderer (GDI) // On Linux, we want to use DrawString (GDI+) // TextRenderer provides translation from TextRenderer to // DrawString, but I doubt it's exact enough. // Another option would be to put Pango here for Linux. int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128 || platform == 6) { use_textrenderer = false; } else { use_textrenderer = true; } // windows 2000 doesn't draw with gdi if bounds are In32.MaxValue max_size = new Size_(Int16.MaxValue, Int16.MaxValue); sf_nonprinting = new StringFormat(StringFormat.GenericTypographic); sf_nonprinting.Trimming = StringTrimming.None; sf_nonprinting.FormatFlags = StringFormatFlags.DisplayFormatControl; sf_nonprinting.HotkeyPrefix = HotkeyPrefix.None; sf_printing = StringFormat.GenericTypographic; sf_printing.HotkeyPrefix = HotkeyPrefix.None; measure_cache = new Hashtable(); }
protected override void OnMouseMove(MouseEventArgs args) { base.OnMouseMove(args); if (resizing) { Point_ mouse_loc = Control.MousePosition; Point_ ctrl_loc = PointToScreen(Point_.Empty); Size_ new_size = new Size_(mouse_loc.X - ctrl_loc.X, mouse_loc.Y - ctrl_loc.Y); if (new_size.Height < item_height) { new_size.Height = item_height; } if (new_size.Width < item_height) { new_size.Width = item_height; } Size = new_size; return; } Cursor = resizer_bounds.Contains(args.Location) ? Cursors.SizeNWSE : Cursors.Default; int item_idx = GetItemAt(args.Location); if (item_idx != -1) { HighlightedIndex = item_idx; } }
internal virtual Size_ InternalGetPreferredSize(Size_ proposed) { Size_ size; if (Text == string.Empty) { size = new Size_(0, Font.Height); } else { size = Size_.Ceiling(TextRenderer.MeasureString(Text, Font, req_witdthsize, string_format)); size.Width += 3; } size.Width += Padding.Horizontal; size.Height += Padding.Vertical; if (!use_compatible_text_rendering) { return(size); } if (border_style == BorderStyle.None) { size.Height += 3; } else { size.Height += 6; } return(size); }
internal static void SetWindowMinMax(IntPtr handle, Rectangle_ maximized, Size_ min, Size_ max) { #if DriverDebug || DriverDebugState Console.WriteLine("SetWindowMinMax ({0}, {1}, {2}, {3}): Called", Window(handle), maximized, min, max); #endif driver.SetWindowMinMax(handle, maximized, min, max); }
public TabControlPainter() { defaultItemSize = new Size_(42, 16); defaultPadding = new Point_(6, 3); selectedTabDelta = new Rectangle_(2, 2, 4, 3); selectedSpacing = 0; rowSpacingNormal = new Size_(0, 0); rowSpacingButtons = new Size_(3, 3); rowSpacingFlatButtons = new Size_(9, 3); colSpacing = 0; minimumTabWidth = 42; scrollerWidth = 17; focusRectSpacing = new Point_(2, 2); tabPanelOffset = new Point_(4, 0); flatButtonSpacing = 8; tabPageSpacing = new Rectangle_(4, 2, 3, 4); imagePadding = new Point_(2, 3); defaultFormatting = new StringFormat(); // Horizontal Alignment is handled in the Draw method defaultFormatting.Alignment = StringAlignment.Near; defaultFormatting.LineAlignment = StringAlignment.Center; defaultFormatting.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.NoClip; defaultFormatting.HotkeyPrefix = HotkeyPrefix.Show; borderThickness = new Rectangle_(1, 1, 2, 2); }
internal override Size_ GetPreferredSizeCore(Size_ proposedSize) { Size_ retsize = Size_.Empty; foreach (Control child in Controls) { if (child.Dock == DockStyle.Fill) { if (child.Bounds.Right > retsize.Width) { retsize.Width = child.Bounds.Right; } } else if (child.Dock != DockStyle.Top && child.Dock != DockStyle.Bottom && (child.Anchor & AnchorStyles.Right) == 0 && (child.Bounds.Right + child.Margin.Right) > retsize.Width) { retsize.Width = child.Bounds.Right + child.Margin.Right; } if (child.Dock == DockStyle.Fill) { if (child.Bounds.Bottom > retsize.Height) { retsize.Height = child.Bounds.Bottom; } } else if (child.Dock != DockStyle.Left && child.Dock != DockStyle.Right && (child.Anchor & AnchorStyles.Bottom) == 0 && (child.Bounds.Bottom + child.Margin.Bottom) > retsize.Height) { retsize.Height = child.Bounds.Bottom + child.Margin.Bottom; } } return(retsize); }
public void SetToolTip(Control control, string caption) { // UIA Framework OnUIAToolTipHookUp(this, new ControlEventArgs(control)); tooltip_strings[control] = caption; // no need for duplicates if (!controls.Contains(control)) { control.MouseEnter += new EventHandler(control_MouseEnter); control.MouseMove += new MouseEventHandler(control_MouseMove); control.MouseLeave += new EventHandler(control_MouseLeave); control.MouseDown += new MouseEventHandler(control_MouseDown); controls.Add(control); } // if SetToolTip is called from a control and the mouse is currently over that control, // make sure that tooltip_window.Text gets updated if it's being shown, // or show the tooltip for it if is not if (active_control == control && caption != null && state == TipState.Show) { Size_ size = ThemeEngine.Current.ToolTipSize(tooltip_window, caption); tooltip_window.Width = size.Width; tooltip_window.Height = size.Height; tooltip_window.Text = caption; timer.Stop(); timer.Start(); } else if (control.IsHandleCreated && MouseInControl(control, false)) { ShowTooltip(control); } }
public virtual void UpdateWindowState(FormWindowState old_window_state, FormWindowState new_window_state, bool force) { if (old_window_state == FormWindowState.Normal) { NormalBounds = form.Bounds; } else if (old_window_state == FormWindowState.Minimized) { IconicBounds = form.Bounds; } switch (new_window_state) { case FormWindowState.Minimized: if (IconicBounds == Rectangle_.Empty) { Size_ size = IconicSize; Point_ location = new Point_(0, Form.Parent.ClientSize.Height - size.Height); IconicBounds = new Rectangle_(location, size); } form.Bounds = IconicBounds; break; case FormWindowState.Maximized: form.Bounds = MaximizedBounds; break; case FormWindowState.Normal: form.Bounds = NormalBounds; break; } UpdateWindowDecorations(new_window_state); form.ResetCursor(); }
public PopupEventArgs(IWin32Window associatedWindow, Control associatedControl, bool isBalloon, Size_ size) : base() { this.associated_window = associatedWindow; this.associated_control = associatedControl; this.is_balloon = isBalloon; this.tool_tip_size = size; }
void LayoutAutoSizedChildren(Control parent, Control[] controls) { for (int i = 0; i < controls.Length; i++) { int left; int top; Control child = controls[i]; if (!child.VisibleInternal || child.ControlLayoutType == Control.LayoutType.Dock || !child.AutoSize) { continue; } AnchorStyles anchor = child.Anchor; left = child.Left; top = child.Top; Size_ preferredsize = GetPreferredControlSize(child); if (((anchor & AnchorStyles.Left) != 0) || ((anchor & AnchorStyles.Right) == 0)) { child.dist_right += child.Width - preferredsize.Width; } if (((anchor & AnchorStyles.Top) != 0) || ((anchor & AnchorStyles.Bottom) == 0)) { child.dist_bottom += child.Height - preferredsize.Height; } child.SetBoundsInternal(left, top, preferredsize.Width, preferredsize.Height, BoundsSpecified.None); } }
public void Inflate(Size_ size) { left += size.Width; right += size.Width; top += size.Height; bottom += size.Height; }
void LayoutAutoSizeContainer(Control container) { int left; int top; int width; int height; if (!container.VisibleInternal || container.ControlLayoutType == Control.LayoutType.Dock || !container.AutoSize) { return; } left = container.Left; top = container.Top; Size_ preferredsize = container.PreferredSize; if (container.GetAutoSizeMode() == AutoSizeMode.GrowAndShrink) { width = preferredsize.Width; height = preferredsize.Height; } else { width = container.ExplicitBounds.Width; height = container.ExplicitBounds.Height; if (preferredsize.Width > width) { width = preferredsize.Width; } if (preferredsize.Height > height) { height = preferredsize.Height; } } // Sanity if (width < container.MinimumSize.Width) { width = container.MinimumSize.Width; } if (height < container.MinimumSize.Height) { height = container.MinimumSize.Height; } if (container.MaximumSize.Width != 0 && width > container.MaximumSize.Width) { width = container.MaximumSize.Width; } if (container.MaximumSize.Height != 0 && height > container.MaximumSize.Height) { height = container.MaximumSize.Height; } container.SetBoundsInternal(left, top, width, height, BoundsSpecified.None); }
protected internal override Size_ GetPreferredSize(Graphics g, object value) { string text = GetFormattedValue(value); Size_ s = Size_.Ceiling(g.MeasureString(text, this.DataGridTableStyle.DataGrid.Font)); s.Width += 4; return(s); }
protected override void OnLayout(LayoutEventArgs e) { // Find the widest menu item, so we know how wide to make our dropdown int widest = 0; foreach (ToolStripItem tsi in this.Items) { if (!tsi.Available) { continue; } tsi.SetPlacement(ToolStripItemPlacement.Main); widest = Math.Max(widest, tsi.GetPreferredSize(Size_.Empty).Width + tsi.Margin.Horizontal); } // Add any padding our dropdown has set widest += this.Padding.Horizontal; int x = this.Padding.Left; int y = this.Padding.Top; foreach (ToolStripItem tsi in this.Items) { if (!tsi.Available) { continue; } y += tsi.Margin.Top; int height = 0; Size_ preferred_size = tsi.GetPreferredSize(Size_.Empty); if (preferred_size.Height > 22) { height = preferred_size.Height; } else if (tsi is ToolStripSeparator) { height = 7; } else { height = 22; } tsi.SetBounds(new Rectangle_(x, y, preferred_size.Width, height)); y += height + tsi.Margin.Bottom; } this.Size = new Size_(widest, y + this.Padding.Bottom); this.SetDisplayedItems(); this.OnLayoutCompleted(EventArgs.Empty); this.Invalidate(); }
public DataGridBoolColumn(PropertyDescriptor prop, bool isDefault) : base(prop) { false_value = false; null_value = null; true_value = true; allow_null = true; is_default = isDefault; checkbox_size = new Size_(ThemeEngine.Current.DataGridMinimumColumnCheckBoxWidth, ThemeEngine.Current.DataGridMinimumColumnCheckBoxHeight); }
internal override Size_ GetPreferredSizeCore(Size_ proposedSize) { if (this.AutoSize) { return(ThemeEngine.Current.CalculateCheckBoxAutoSize(this)); } return(base.GetPreferredSizeCore(proposedSize)); }
public static Image GetIconForMimeTypeAndSize(string mime_type, Size_ size) { lock (lock_object) { object oindex = GetIconIndex(mime_type); Bitmap bmp = new Bitmap(LargeIcons.Images [(int)oindex], size); return(bmp); } }
internal void HandleMouseMove(object sender, MouseEventArgs e) { Control ctrl = (Control)sender; Rectangle_ rect = GetDefaultRectangle(ctrl); if (rect.Contains(e.X, e.Y)) { ctrl.Cursor = Cursors.SizeNWSE; } else { ctrl.Cursor = Cursors.Default; } if (captured) { int delta_x; int delta_y; Point_ current_point; current_point = Control.MousePosition; delta_x = current_point.X - capture_point.X; delta_y = current_point.Y - capture_point.Y; Control parent = CapturedControl; Form form_parent = parent as Form; Size_ new_size = new Size_(window_w + delta_x, window_h + delta_y); Size_ max_size = form_parent != null ? form_parent.MaximumSize : Size_.Empty; Size_ min_size = form_parent != null ? form_parent.MinimumSize : Size_.Empty; if (new_size.Width > max_size.Width && max_size.Width > 0) { new_size.Width = max_size.Width; } else if (new_size.Width < min_size.Width) { new_size.Width = min_size.Width; } if (new_size.Height > max_size.Height && max_size.Height > 0) { new_size.Height = max_size.Height; } else if (new_size.Height < min_size.Height) { new_size.Height = min_size.Height; } if (new_size != parent.Size) { parent.Size = new_size; } } }
private void CalcAutoSize() { if (!AutoSize) { return; } Size_ s = InternalGetPreferredSize(Size_.Empty); SetBounds(Left, Top, s.Width, s.Height, BoundsSpecified.Size); }
internal override Size_ GetPreferredSizeCore(Size_ proposedSize) { if (image == null) { return(base.GetPreferredSizeCore(proposedSize)); } else { return(image.Size); } }
internal override Size_ CalculatePreferredSize(Size_ constrainingSize) { Size_ preferred_size = base.CalculatePreferredSize(constrainingSize); if (this.ShowDropDownArrow) { preferred_size.Width += 9; } return(preferred_size); }
public override Size_ GetPreferredSize(Size_ constrainingSize) { Size_ retval = base.GetPreferredSize(constrainingSize); if (retval.Width < 23) { retval.Width = 23; } return(retval); }
protected override Rectangle_ GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) { if (DataGridView == null) { return(Rectangle_.Empty); } Size_ s = new Size_(11, 18); return(new Rectangle_(24, (OwningRow.Height - s.Height) / 2, s.Width, s.Height)); }
protected override Rectangle_ GetErrorIconBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) { if (DataGridView == null || string.IsNullOrEmpty(ErrorText)) { return(Rectangle_.Empty); } Size_ error_icon = new Size_(12, 11); return(new Rectangle_(new Point_(Size.Width - error_icon.Width - 5, (Size.Height - error_icon.Height) / 2), error_icon)); }
protected override Rectangle_ GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) { if (DataGridView == null) { return(Rectangle_.Empty); } Size_ s = new Size_(36, 13); return(new Rectangle_(2, (DataGridView.ColumnHeadersHeight - s.Height) / 2, s.Width, s.Height)); }
internal override void PaintPartContent(Graphics graphics, Rectangle_ cellBounds, int rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, object formattedValue) { Image i; if (formattedValue == null) { i = missing_image; } else { i = (Image)formattedValue; } Rectangle_ image_bounds = Rectangle_.Empty; switch (imageLayout) { case DataGridViewImageCellLayout.NotSet: case DataGridViewImageCellLayout.Normal: image_bounds = AlignInRectangle(new Rectangle_(2, 2, cellBounds.Width - 4, cellBounds.Height - 4), i.Size, cellStyle.Alignment); break; case DataGridViewImageCellLayout.Stretch: image_bounds = new Rectangle_(Point_.Empty, cellBounds.Size); break; case DataGridViewImageCellLayout.Zoom: Size_ image_size; if (((float)i.Width / (float)i.Height) >= ((float)Size.Width / (float)Size.Height)) { image_size = new Size_(Size.Width, (i.Height * Size.Width) / i.Width); } else { image_size = new Size_((i.Width * Size.Height) / i.Height, Size.Height); } image_bounds = new Rectangle_((Size.Width - image_size.Width) / 2, (Size.Height - image_size.Height) / 2, image_size.Width, image_size.Height); break; default: break; } image_bounds.X += cellBounds.Left; image_bounds.Y += cellBounds.Top; graphics.DrawImage(i, image_bounds); }
public static dynamic GetTSObject(Size[] dynArray) { if (dynArray is null) { return(null); } var list = new System.Collections.Generic.List <dynamic>(); foreach (var dynItem in dynArray) { list.Add(Size_.GetTSObject(dynItem)); } return(list.ToArray()); }
public static Size[] FromTSObject(dynamic[] tsArray) { if (tsArray is null) { return(null); } var list = new System.Collections.Generic.List <Size>(); foreach (var tsItem in tsArray) { list.Add(Size_.FromTSObject(tsItem)); } return(list.ToArray()); }
public void Present(Control control, string text) { if (IsDisposed) { return; } Size_ display_size; XplatUI.GetDisplaySize(out display_size); associated_control = control; Text = text; PopupEventArgs pea = new PopupEventArgs(control, control, false, Size_.Empty); OnPopup(pea); if (pea.Cancel) { return; } Size_ size = pea.ToolTipSize; Width = size.Width; Height = size.Height; int cursor_w, cursor_h, hot_x, hot_y; XplatUI.GetCursorInfo(control.Cursor.Handle, out cursor_w, out cursor_h, out hot_x, out hot_y); Point_ loc = Control.MousePosition; loc.Y += (cursor_h - hot_y); if ((loc.X + Width) > display_size.Width) { loc.X = display_size.Width - Width; } if ((loc.Y + Height) > display_size.Height) { loc.Y = Control.MousePosition.Y - Height - hot_y; } Location = loc; Visible = true; }