public static Gdi::Point CoordTransf(this ILayoutNode self, Gdi::Point pos, RectCoord before, RectCoord after) { Gdi::Point ret = pos; self.CoordTransf(ref ret, before, after); return(ret); }
//-------------------------------------------------------------------------- public static void CoordTransf(this ILayoutNode self, ref Gdi::Point pos, RectCoord before, RectCoord after) { Gdi::Point delta = self.GetLocation(before, after); pos.X += delta.X; pos.Y += delta.Y; }
private static Gdi::Point GetLocation(ILayoutNode self, int lvEnd, int lvSta) { Gdi::Point ret = new Gdi::Point(); if (lvSta > lvEnd) { ret = GetLocation(self, lvSta, lvEnd); ret.X = -ret.X; ret.Y = -ret.Y; return(ret); } switch (lvSta) { case 0: if (lvEnd == 0) { return(ret); } ret.X -= self.DesiredLeft; ret.Y -= self.DesiredTop; goto case 1; case 1: if (lvEnd == 1) { return(ret); } ret.X += self.BoundingLeft; ret.Y += self.BoundingTop; goto case 2; case 2: return(ret); default: throw new System.InvalidProgramException(); } }
private void SetRevert(TreeNode node, TreeNodeDragEventArgs e) { switch (GetTarget(node, e)) { case TreeNodeDDTarget.Self: { Gdi::Rectangle rect = new Gdi::Rectangle(node.ClientPosition, node.ContentSize); rect.X += node.ContentOffsetX; node.View.dropArea.RevertRect(rect); break; } case TreeNodeDDTarget.Prev: { Gdi::Point p = node.ClientPosition; p.X += node.ContentOffsetX; node.View.dropArea.RevertLine(p); break; } case TreeNodeDDTarget.Next: { Gdi::Point p = node.ClientPosition; p.X += node.ContentOffsetX; p.Y += node.ContentSize.Height; node.View.dropArea.RevertLine(p); break; } case TreeNodeDDTarget.Child: { Gdi::Point p = node.ClientPosition; p.X += node.ContentOffsetX + node.ChildIndent.Width; p.Y += node.ContentSize.Height; node.View.dropArea.RevertLine(p); break; } } }
/// <summary> /// 指定した点から右へ線を引きます。 /// </summary> /// <param name="pt">線の開始点を指定します。</param> public void RevertLine(Gdi::Point pt) { Gdi::Rectangle rect = new Gdi::Rectangle( pt.X, pt.Y - 1, this.ctrl.ClientRectangle.Width - pt.X, 3 ); this.RevertRect(rect); }
/// <summary> /// <ja>指定した点が、何行目・何列目の文字境界に対応するかを計算します。</ja> /// </summary> /// <param name="clientPoint"><ja>コントロールのクライアント座標で点を指定します。</ja></param> /// <returns><ja>指定した点が、何行何列目の文字境界に最も近いかを返します。 /// 最も左上の境界が (0,0) に対応します。</ja></returns> protected Gdi::Point ClientPointToCharBorder(Gdi::Point clientPoint) { RenderProfile prof = this.GetRenderProfile(); SizeF pitch = prof.Pitch; float x = (clientPoint.X - BORDER) / pitch.Width; float y = (clientPoint.Y - BORDER) / (pitch.Height + prof.LineSpacing); return(new Gdi::Point( ((int)(x + 0.5f)).Clamp(0, Int32.MaxValue), ((int)y).Clamp(0, Int32.MaxValue))); }
protected override void OnMouseUp(MouseEventArgs e) { if (this.IsAcceptableUserInput()) { if (terminalMouseState == 0) { goto skip; } // 位置・ボタン情報 Keys flags = KeyboardInfo.GetModifierState(); Gdi::Point pos = base.ClientPointToCharBorder(e.Location); pos.X++; pos.Y++; //Gdi::Point pos=base.ClientPointToTextPosition(e.Location); //pos.X++; //pos.Y++; // MouseTracking "Button Released" int f = 0; if (UpdateMouseButtonState(e, MouseButtons.Left, flags | Keys.LButton, pos, true)) { f++; } if (UpdateMouseButtonState(e, MouseButtons.Right, flags | Keys.RButton, pos, true)) { f++; } if (UpdateMouseButtonState(e, MouseButtons.Middle, flags | Keys.MButton, pos, true)) { f++; } if (f != 0) { return; } // MouseTracking "Release-Button Pressed" terminalMouseState &= ~e.Button; if (terminalMouseState == 0) { if (UpdateMouseButtonState(e, 0, flags, pos, false)) { return; } } } skip: base.OnMouseUp(e); }
internal Gdi::Point Node2LogicalPosition(TreeNode node) { if (node.view != this) { throw new System.InvalidOperationException("指定したノードはこの TreeView に属するノードではありません。"); } _todo.ExamineTreeView(); Gdi::Point p = Gdi::Point.Empty; while (node.parent != null) { p = node.LocalPos2ParentLocalPos(p); node = node.parent; } Diag::Debug.Assert(node == this.root); return(p); }
protected override void OnMouseDown(MouseEventArgs e) { if (this.IsAcceptableUserInput()) { Keys flags = KeyboardInfo.GetModifierState(); //if((flags&Keys.Shift)==0){ if (Control.IsKeyLocked(Keys.Scroll)) { Gdi::Point pos = base.ClientPointToCharBorder(e.Location); pos.X++; pos.Y++; //Gdi::Point pos=base.ClientPointToTextPosition(e.Location); //pos.X++; //pos.Y++; int f = 0; if (UpdateMouseButtonState(e, MouseButtons.Left, flags | Keys.LButton, pos, false)) { f++; } if (UpdateMouseButtonState(e, MouseButtons.Right, flags | Keys.RButton, pos, false)) { f++; } if (UpdateMouseButtonState(e, MouseButtons.Middle, flags | Keys.MButton, pos, false)) { f++; } if (f != 0) { return; } } } base.OnMouseDown(e); }
private bool UpdateMouseButtonState(MouseEventArgs e, MouseButtons button, Keys key, Gdi::Point pos, bool release) { if ((e.Button & button) != button) { return(false); } // 状態変化がなければ無視 bool released = (terminalMouseState & button) == 0; if (released == release) { return(false); } byte[] seq; int len = GetTerminal().EncodeInputMouse(key, pos.X, pos.Y, out seq, release); if (len <= 0) { return(false); } mwgSendBytes(seq, len); if (release) { terminalMouseState &= ~button; } else { terminalMouseState |= button; } return(true); }
protected override void OnMouseWheel(MouseEventArgs e) { //base.OnMouseWheel(e); //CharacaterDocumentViewerは無視してよい if (!this.EnabledEx) { return; } #if MWG_MOUSE if (this.IsAcceptableUserInput()) { Keys flags = KeyboardInfo.GetModifierState(); //if((flags&Keys.Shift)==0){ // shift は poderosa で処理。 if (Control.IsKeyLocked(Keys.Scroll)) // shift は poderosa で処理。 // 便宜上 [↑]を XButton1 に [↓]を XButton2 に割り当てる。 { Keys buttons = e.Delta > 0?Keys.XButton1:Keys.XButton2; buttons |= flags; //Gdi::Point pos=base.ClientPointToTextPosition(e.Location); //pos.X++; //pos.Y++; Gdi::Point pos = base.ClientPointToCharBorder(e.Location); pos.X++; pos.Y++; byte[] seq; int len = GetTerminal().EncodeInputMouse(buttons, pos.X, pos.Y, out seq, false); if (len > 0) { mwgSendBytes(seq, len); return; } } } #endif //アプリケーションモードでは通常処理をやめてカーソル上下と同等の処理にする if (_session != null && !GEnv.Options.AllowsScrollInAppMode && GetTerminal().TerminalMode == TerminalMode.Application) { int m = GEnv.Options.WheelAmount; for (int i = 0; i < m; i++) { mwgSendKey(Keys.None | (e.Delta > 0? Keys.Up : Keys.Down)); } return; } if (_VScrollBar.Enabled) { int d = e.Delta / 120; //開発環境だとDeltaに120。これで1か-1が入るはず d *= GEnv.Options.WheelAmount; int newval = _VScrollBar.Value - d; if (newval < 0) { newval = 0; } if (newval > _VScrollBar.Maximum - _VScrollBar.LargeChange) { newval = _VScrollBar.Maximum - _VScrollBar.LargeChange + 1; } _VScrollBar.Value = newval; } }
//------------------------------------------------------------------------ // 座標処理 //------------------------------------------------------------------------ /// <summary> /// 指定した位置にある子孫ノードを取得します。 /// </summary> /// <param name="self">コンテナノードを指定します。</param> /// <param name="position">位置を Bounding 座標で指定します。</param> /// <returns>指定した位置に子孫ノードが存在した場合にそれを返します。 /// 指定した位置に子孫ノードが存在しなかった場合は null を返します。 /// </returns> public static ILayoutNode GetNodeAt(this IContainerNode self, Gdi::Point position) { HitValue dummy; return(self.GetNodeAt(position, out dummy)); }