Esempio n. 1
0
        /// Clipping*のサイズ要素(Width/Height)の変更を試みる
        /// @warning boundは常に変わり続けている。
        ///          よって、Size入力中でもPositionを常に最新の値に更新しておく必要がある。
        /// @param original 変更前のClientRect
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param bound 境界を表すClientRect
        /// @param sizeLowerBound 訂正後のサイズ要素(Width/Height)の最小値
        /// @param[out] changed 変更後、制約を満たす形に訂正されたClientRect
        /// @return 試行結果(訂正箇所)
        private static TryResult TryChangeSize(ClientRect original,
                                               Names target, int value, ClientRect bound, int sizeLowerBound,
                                               out ClientRect changed)
        {
            Debug.Assert(target == Names.Width || target == Names.Height);

            // 準備
            var onX                = (target == Names.Width);
            var position           = onX ? original.X : original.Y;
            var size               = value;
            var positionLowerBound = onX ? bound.X : bound.Y;
            var positionUpperBound = onX ? bound.Right : bound.Bottom;
            var sizeUpperBound     = onX ? bound.Width : bound.Height;
            var result             = TryResult.NothingChanged;

            // 上限・下限の補正
            if (size < sizeLowerBound)
            {
                // Sizeは下限以上
                size    = sizeLowerBound;
                result |= TryResult.TargetChanged;
            }
            else if (sizeUpperBound < size)
            {
                // Sizeが大きすぎる場合はFitさせる
                position = positionLowerBound;
                size     = sizeUpperBound;
                result  |= TryResult.BothChanged;
            }

            // Positionの補正
            if (position < positionLowerBound)
            {
                // Positionが小さすぎる場合、Sizeは保持&Positionを増やす
                position = positionLowerBound;
                result  |= TryResult.DependentChanged;
            }
            else if (positionUpperBound < position + sizeLowerBound)
            {
                // Positionが大きすぎる場合、Positionを減らしてWidthを下限に
                position = positionUpperBound - sizeLowerBound;
                size     = sizeLowerBound;
                result  |= TryResult.BothChanged;
            }

            // 領域が境界内に収まらない場合、Sizeは保持&Positionを小さく
            if (positionUpperBound < position + size)
            {
                position = positionUpperBound - size;
                result  |= TryResult.DependentChanged;
            }

            Debug.Assert(positionLowerBound <= position &&
                         sizeLowerBound <= size &&
                         position + size <= positionUpperBound);
            changed = onX
        ? new ClientRect(position, original.Y, size, original.Height)
        : new ClientRect(original.X, position, original.Width, size);
            return(result);
        }
        /// レイアウト要素のClipping領域(Fitオプションなし)の変更を試みる
        /// @param layoutElement レイアウト要素
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param[out] changed 変更後、制約を満たす形に訂正されたClipping領域
        /// @return 試行結果(訂正箇所)
        public static TryResult TryChange(
            LayoutElement layoutElement, Names target, int value,
            out ClientRect changed)
        {
            Debug.Assert(layoutElement.IsWindowValid);
            Debug.Assert(!layoutElement.Fit);

            // 準備
            var original = ClippingInputCorrector.GetOriginal(layoutElement);
            var window = Utilities.GetWindowRect(layoutElement.WindowType, layoutElement.Window);

            // 訂正
            switch (target) {
              case Names.X:
              case Names.Y: {
            return ClippingInputCorrector.TryChangePosition(
            original, target, value, window,
            Constants.MinimumClippingSize, out changed);
              }
              case Names.Width:
              case Names.Height: {
            return ClippingInputCorrector.TryChangeSize(
            original, target, value, window,
            Constants.MinimumClippingSize, out changed);
              }
              default: Debug.Fail("switch"); throw new System.ArgumentException();
            }
        }
Esempio n. 3
0
        /// レイアウト要素のClipping領域(Fitオプションなし)の変更を試みる
        /// @param layoutElement レイアウト要素
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param[out] changed 変更後、制約を満たす形に訂正されたClipping領域
        /// @return 試行結果(訂正箇所)
        public static TryResult TryChange(
            LayoutElement layoutElement, Names target, int value,
            out ClientRect changed)
        {
            Debug.Assert(layoutElement.IsWindowValid);
            Debug.Assert(!layoutElement.Fit);

            // 準備
            var original = ClippingInputCorrector.GetOriginal(layoutElement);
            var window   = Utilities.GetWindowRect(layoutElement.WindowType, layoutElement.Window);

            // 訂正
            switch (target)
            {
            case Names.X:
            case Names.Y: {
                return(ClippingInputCorrector.TryChangePosition(
                           original, target, value, window,
                           Constants.MinimumClippingSize, out changed));
            }

            case Names.Width:
            case Names.Height: {
                return(ClippingInputCorrector.TryChangeSize(
                           original, target, value, window,
                           Constants.MinimumClippingSize, out changed));
            }

            default: Debug.Fail("switch"); throw new System.ArgumentException();
            }
        }
        protected bool IsEndOfSelectionInScreen()
        {
            var selInfo = SelectInfo;

            if (selInfo.IsTextSelectionValid() == false)
            {
                return(true);
            }

            var ti = Document
                     .Pages[selInfo.EndPage].Text
                     .GetTextInfo(Math.Max(0,
                                           selInfo.EndIndex - 1),
                                  1);

            if (ti?.Rects == null || ti.Rects.Count == 0)
            {
                return(true);
            }

            var topLeftPt = PageToClient(selInfo.EndPage,
                                         new Point(ti.Rects[0].left,
                                                   ti.Rects[0].top));

            return(ClientRect.Contains(topLeftPt));
        }
        private void SetMousePos(MouseEvent e)
        {
            ClientRect r = renderer.domElement.GetBoundingClientRect();

            // calculate mouse position in normalized device coordinates
            // (-1 to +1) for both components
            mouse.x = ((double)(e.ClientX - r.Left) / (double)Width) * 2 - 1;
            mouse.y = -((double)(e.ClientY - r.Top) / (double)Height) * 2 + 1;
        }
Esempio n. 6
0
        /// <summary>
        /// 描画。
        /// </summary>
        protected override void OnPreviewRender(Renderer renderer)
        {
            var color = IsDragging ? SharedInfo.Settings.ui_colors.scrollThumb_active : SharedInfo.Settings.ui_colors.scrollThumb;

            renderer.SetColor(color);

            var rect = IsHorizontal ? ClientRect.Inflate(0, -2) : ClientRect.Inflate(-2, 0);

            renderer.FillRect(rect);
        }
Esempio n. 7
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            CSharpToolBarButton button = ButtonFromPoint(e.X, e.Y);

            // セパレータの場合は何もしない
            if (button != null && button.Style == CSharpToolBarButtonStyle.Separator)
            {
                return;
            }

            // フラット形式の場合は、浮き出る境界線を描画
            if (e.Button == MouseButtons.None)
            {
                if (button == activeButton)
                {
                    return;
                }

                UpdateButton(activeButton);

                activeButton = button;

                if (appearance == CSharpToolBarAppearance.Flat &&
                    button != null)
                {
                    using (Graphics g = CreateGraphics())
                        ControlPaint.DrawBorder3D(g, button.Bounds, Border3DStyle.RaisedInner);
                }
                else if (appearance == CSharpToolBarAppearance.VisualStudio &&
                         button != null)
                {
                    using (Graphics g = CreateGraphics())
                        DrawButton(g, button, false, true);
                }
            }
            // ボタンのドラッグ操作
            else if (e.Button == MouseButtons.Left && allowDragButton)
            {
                if (ClientRect.Contains(e.X, e.Y))
                {
                    DrawHorzLine(GetDropButtonIndex(e.X, e.Y));
                    Cursor = Cursors.Default;
                }
                // クライアント領域から出ていればドラッグ操作を中止
                else
                {
                    DrawHorzLine(-1);
                    Cursor = Cursors.No;
                }
            }
        }
Esempio n. 8
0
        public override void Render(RenderContext ctx)
        {
            RenderBorderAndBackground(ctx);

            var clientRectInner = ClientRect.Substract(1);

            //var textY = (((-Paint.FontMetrics.Ascent + Paint.FontMetrics.Descent) / 2) - Paint.FontMetrics.Descent);

            //var fontHeight = Paint.FontMetrics.Descent - Paint.FontMetrics.Ascent;

            ctx.Commands.Add(new DrawActionCommand(x =>
            {
                x.Canvas.DrawText(Text, ClientRect.Left + DrawPosition.X, ClientRect.Top + DrawPosition.Y, Paint);
            }));
        }
Esempio n. 9
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            bool wasMouseOne = mouseOn;

            mouseOn = ClientRect.Contains(e.X, e.Y);
            if (!mouseOn)
            {
                mouseDown = false;
            }

            if (wasMouseOne != mouseOn)
            {
                Main.GetInstance().RequestRedraw();
            }
        }
Esempio n. 10
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            // ボタンが押されたように描画
            if (e.Button == MouseButtons.Left &&
                activeButton != null)
            {
                if (activeButton.Style == CSharpToolBarButtonStyle.Separator)
                {
                    return;
                }

                CSharpToolBarButton button = ButtonFromPoint(e.X, e.Y);

                UpdateButton(activeButton);
                DrawHorzLine(-1);

                // クリックされたボタンと現在のマウス座標にあるボタンが別の物であれば、
                // activeButtonsを移動
                if (activeButton != button)
                {
                    if (allowDragButton && ClientRect.Contains(e.X, e.Y))
                    {
                        int index = GetDropButtonIndex(e.X, e.Y);

                        if (index >= 0 && index <= buttons.Count)
                        {
                            buttons.ChangeIndex(activeButton, index);
                        }
                    }
                    Cursor = Cursors.Default;
                }
                else
                {
                    // クリックイベントを発生させる
                    OnButtonClick(new CSharpToolBarButtonEventArgs(activeButton));
                }

                activeButton = null;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Options"/> class.
        /// </summary>
        /// <param name="ini">The <see cref="IniFile"/> used to save all settings for DummyPos.</param>
        public Options(IniFile ini)
        {
            KeepOnTop      = ini.GetBoolean("GENERAL", "topmost", false);
            ConnectionId   = ini.GetInt("GENERAL", "connection");
            ConnectionName = ini.GetString(ConnSection(ConnectionId), "name");
            HardwareName   = Environment.MachineName;

            ClientRect = new ClientRect(ini.GetString("BROWSER", "size", "xga"));
            if (ClientRect.Id == "custom")
            {
                ClientRect.Width  = ini.GetInt("BROWSER", "width");
                ClientRect.Height = ini.GetInt("BROWSER", "height");
            }
            ClientRect.Left = ini.GetInt("BROWSER", "left", 0);
            ClientRect.Top  = ini.GetInt("BROWSER", "top", 0);

            PrintPreview          = ini.GetBoolean("PRINTER", "print_preview", true);
            PrintHtmlPrinter      = ini.GetBoolean("PRINTER", "html_printer", false);
            PrintHtmlPrompt       = ini.GetBoolean("PRINTER", "html_prompt", false);
            PrintEssentialPrinter = ini.GetBoolean("PRINTER", "essential_printer", false);
            PrintEssentialPrompt  = ini.GetBoolean("PRINTER", "essential_prompt", false);
        }
Esempio n. 12
0
        private void ShowFor(HTMLElement element, int distanceX, int distanceY, bool asSubMenu)
        {
            if (asSubMenu)
            {
                _popup       = Div(_("tss-contextmenu-popup"), _childContainer);
                _contentHtml = Div(_(), _modalOverlay, _popup);
            }
            else
            {
                if (_contentHtml == null)
                {
                    _modalOverlay = Div(_("tss-contextmenu-overlay"));
                    _modalOverlay.addEventListener("click", _ => Hide());
                    _popup       = Div(_("tss-contextmenu-popup"), _childContainer);
                    _contentHtml = Div(_(), _modalOverlay, _popup);
                }
            }

            _popup.style.height = "unset";
            _popup.style.left   = "-1000px";
            _popup.style.top    = "-1000px";

            base.Show();

            if (!_popup.classList.contains("tss-no-focus"))
            {
                _popup.classList.add("tss-no-focus");
            }

            ClientRect parentRect = (ClientRect)element.getBoundingClientRect();
            var        popupRect  = (ClientRect)_popup.getBoundingClientRect();

            var x = parentRect.left + distanceX;
            var y = parentRect.bottom + distanceY;

            _popup.style.left     = x + "px";
            _popup.style.top      = y + "px";
            _popup.style.minWidth = parentRect.width + "px";

            //TODO: CHECK THIS LOGIC

            if (window.innerHeight - parentRect.bottom - distanceY < popupRect.height)
            {
                var top = parentRect.top - popupRect.height;
                if (top < 0)
                {
                    if (parentRect.top > window.innerHeight - parentRect.bottom - distanceY)
                    {
                        _popup.style.top    = "1px";
                        _popup.style.height = parentRect.top - distanceY + "px";
                    }
                    else
                    {
                        _popup.style.height = window.innerHeight - parentRect.bottom - distanceY + "px";
                    }
                }
                else
                {
                    _popup.style.top = top + "px";
                }
            }

            if (window.innerWidth - parentRect.right - distanceX < popupRect.width)
            {
                var left = parentRect.right - popupRect.width;
                if (left < 0)
                {
                    if (parentRect.left > window.innerWidth - parentRect.right - distanceX)
                    {
                        _popup.style.left  = "1px";
                        _popup.style.width = parentRect.left - distanceX + "px";
                    }
                    else
                    {
                        _popup.style.width = window.innerWidth - parentRect.right - distanceX + "px";
                    }
                }
                else
                {
                    _popup.style.left = left + "px";
                }
            }

            window.setTimeout((e) =>
            {
                document.addEventListener("keydown", OnPopupKeyDown);
            }, 100);

            _extremeCoordsTopLeft.x     = x;
            _extremeCoordsTopLeft.y     = y;
            _extremeCoordsBottomRight.x = y + popupRect.width;
            _extremeCoordsBottomRight.y = y + popupRect.height;


            PossiblySetupSubMenuHooks();
        }
Esempio n. 13
0
        public void ShowFor(HTMLElement element)
        {
            if (_contentHtml == null)
            {
                _modalOverlay = Div(_("tss-contextmenu-overlay"));
                _modalOverlay.addEventListener("click", (_) => Hide());
                _popup       = Div(_("tss-contextmenu-popup"), _childContainer);
                _contentHtml = Div(_(), _modalOverlay, _popup);
            }

            _popup.style.height = "unset";
            _popup.style.left   = "-1000px";
            _popup.style.top    = "-1000px";

            base.Show();

            if (!_popup.classList.contains("tss-no-focus"))
            {
                _popup.classList.add("tss-no-focus");
            }

            ClientRect parentRect = (ClientRect)element.getBoundingClientRect();
            var        popupRect  = (ClientRect)_popup.getBoundingClientRect();

            _popup.style.left     = parentRect.left + "px";
            _popup.style.top      = parentRect.bottom - 1 + "px";
            _popup.style.minWidth = parentRect.width + "px";


            //TODO: CHECK THIS LOGIC

            if (window.innerHeight - parentRect.bottom - 1 < popupRect.height)
            {
                var top = parentRect.top - popupRect.height;
                if (top < 0)
                {
                    if (parentRect.top > window.innerHeight - parentRect.bottom - 1)
                    {
                        _popup.style.top    = "1px";
                        _popup.style.height = parentRect.top - 1 + "px";
                    }
                    else
                    {
                        _popup.style.height = window.innerHeight - parentRect.bottom - 1 + "px";
                    }
                }
                else
                {
                    _popup.style.top = top + "px";
                }
            }

            if (window.innerWidth - parentRect.right - 1 < popupRect.width)
            {
                var left = parentRect.left - popupRect.width;
                if (left < 0)
                {
                    if (parentRect.left > window.innerWidth - parentRect.right - 1)
                    {
                        _popup.style.left  = "1px";
                        _popup.style.width = parentRect.left - 1 + "px";
                    }
                    else
                    {
                        _popup.style.width = window.innerWidth - parentRect.right - 1 + "px";
                    }
                }
                else
                {
                    _popup.style.left = left + "px";
                }
            }

            window.setTimeout((e) =>
            {
                //document.addEventListener("click", OnWindowClick);
                //document.addEventListener("dblclick", OnWindowClick);
                //document.addEventListener("contextmenu", OnWindowClick);
                //document.addEventListener("wheel", OnWindowClick);
                document.addEventListener("keydown", OnPopupKeyDown);
            }, 100);
        }
        /// Clipping*のサイズ要素(Width/Height)の変更を試みる
        /// @warning boundは常に変わり続けている。
        ///          よって、Size入力中でもPositionを常に最新の値に更新しておく必要がある。
        /// @param original 変更前のClientRect
        /// @param target 変更箇所
        /// @param value 変更値
        /// @param bound 境界を表すClientRect
        /// @param sizeLowerBound 訂正後のサイズ要素(Width/Height)の最小値
        /// @param[out] changed 変更後、制約を満たす形に訂正されたClientRect
        /// @return 試行結果(訂正箇所)
        private static TryResult TryChangeSize(ClientRect original,
            Names target, int value, ClientRect bound, int sizeLowerBound,
            out ClientRect changed)
        {
            Debug.Assert(target == Names.Width || target == Names.Height);

            // 準備
            var onX = (target == Names.Width);
            var position = onX ? original.X : original.Y;
            var size = value;
            var positionLowerBound = onX ? bound.X : bound.Y;
            var positionUpperBound = onX ? bound.Right : bound.Bottom;
            var sizeUpperBound = onX ? bound.Width : bound.Height;
            var result = TryResult.NothingChanged;

            // 上限・下限の補正
            if (size < sizeLowerBound) {
              // Sizeは下限以上
              size = sizeLowerBound;
              result |= TryResult.TargetChanged;
            } else if (sizeUpperBound < size) {
              // Sizeが大きすぎる場合はFitさせる
              position = positionLowerBound;
              size = sizeUpperBound;
              result |= TryResult.BothChanged;
            }

            // Positionの補正
            if (position < positionLowerBound) {
              // Positionが小さすぎる場合、Sizeは保持&Positionを増やす
              position = positionLowerBound;
              result |= TryResult.DependentChanged;
            } else if (positionUpperBound < position + sizeLowerBound) {
              // Positionが大きすぎる場合、Positionを減らしてWidthを下限に
              position = positionUpperBound - sizeLowerBound;
              size = sizeLowerBound;
              result |= TryResult.BothChanged;
            }

            // 領域が境界内に収まらない場合、Sizeは保持&Positionを小さく
            if (positionUpperBound < position + size) {
              position = positionUpperBound - size;
              result |= TryResult.DependentChanged;
            }

            Debug.Assert(positionLowerBound <= position &&
                 sizeLowerBound <= size &&
                 position + size <= positionUpperBound);
            changed = onX
            ? new ClientRect(position, original.Y, size, original.Height)
            : new ClientRect(original.X, position, original.Width, size);
            return result;
        }
Esempio n. 15
0
        /// <summary>
        /// Draws the child.
        /// </summary>
        /// <param name="child">The child.</param>
        /// <param name="drawingTime">The drawing time.</param>
        /// <returns></returns>
        protected virtual bool DrawChild(Visual child, int drawingTime)
        {
            bool           more             = false;
            float          alpha            = 1.0f;
            Transformation transformToApply = null;
            bool           changeSize       = false;
            bool           changeAngle      = false;
            Animation      a = child.Animation;

            #region Animation present
            if (a != null)
            {
                bool initialized = a.IsInitialized();
                if (!initialized)
                {
                    a.Initialize(child.BoundsRect);
                }

                if (childTransformation == null)
                {
                    childTransformation = new Transformation();
                }
                else
                {
                    childTransformation.Clear();
                }

                more             = a.GetTransformation(drawingTime, childTransformation);
                transformToApply = childTransformation;
                changeSize       = a.WillChangeBounds();
            }
            #endregion

            if ((!changeSize) && (!ClientRect.IntersectsWith(child.BoundsRect)))
            {
                return(more);
            }

            if (transformToApply != null)
            {
                if (a.WillChangeBounds())
                {
                    Rectangle rt = transformToApply.TransformationBounds(a.BoundsRect);
                    child.SetBoundsInternal(rt);
                }
                else
                if (a.WillChangeOffset())
                {
                    child.MoveToInternal((int)transformToApply.OffsetX, (int)transformToApply.OffsetY);
                }


                if (a.WillChangeAlpha())
                {
                    alpha = transformToApply.Alpha;
                    byte multipliedAlpha = (byte)(alpha * 255);
                    child.Alpha = multipliedAlpha;
                }

                changeAngle = a.WillChangeAngle();
                if (changeAngle)
                {
                    Canvas.Transform = transformToApply.Matrix;
                }

                child.InternalPaint();
                Canvas.ResetTransform();
            }
            else
            {
                child.InternalPaint();
            }

            if (a != null && !more)
            {
                child.Alpha = 255;
                FinishAnimatingVisual(child, a);
            }

            return(more);
        }
Esempio n. 16
0
 /// <summary>
 ///
 /// </summary>
 protected virtual bool HitTest(Point2D location)
 {
     return(ClientRect.Contains(location));
 }
Esempio n. 17
0
        public SplitControlContainer() : base("splitcontrol")
        {
            Panel1 = new Control()
            {
                Location = new Vector2(0, 0)
            };
            Panel2 = new Control();
            Panel1.Style.overflow = "auto";
            Panel2.Style.overflow = "auto";

            Splitter = new Control("primary");
            Splitter.Style.cursor = "move";

            Splitter.Content.onmousedown = (ev) =>
            {
                if (!SplitterResizable)
                {
                    return;
                }
                IsMouseDown      = true;
                _mouseDownVector = Helper.GetClientMouseLocation(ev);
                var maxSize = GetMaxSplitterSize();
                _startingSplitterPos = _splitterPosition > maxSize ? maxSize : _splitterPosition;
                ev.stopImmediatePropagation();
            };

            OnResize = (ev) =>
            {
                if (this.LinkedForm != null)
                {
                    if (!this.LinkedForm.IsVisible())
                    {
                        return;
                    }
                }
                var clientRec = (ClientRect)this.Content.getBoundingClientRect();

                if (_prevClientRect == null)
                {
                    _prevClientRect = clientRec;
                }

                if (fixedSplitterPostion == FixedSplitterPosition.None)
                {
                    double V1    = 0;
                    double V2    = 0;
                    bool   dirty = false;

                    if (Horizontal)
                    {
                        if (clientRec.height != _prevClientRect.height)
                        {
                            V1    = clientRec.height;
                            V2    = _prevClientRect.height;
                            dirty = true;
                        }
                    }
                    else
                    {
                        if (clientRec.width != _prevClientRect.width)
                        {
                            V1    = clientRec.width;
                            V2    = _prevClientRect.width;
                            dirty = true;
                        }
                    }
                    if (dirty)
                    {
                        SplitterPosition = V1 == 0 || V2 == 0 ? 0 : (int)(SplitterPosition * (V1 / V2));
                    }
                }

                _prevClientRect = clientRec;

                RenderControls();

                ResizeChildren();
            };

            Content.onmousemove = (ev) =>
            {
                if (IsMouseDown)
                {
                    _currentMouseDownVector = Helper.GetClientMouseLocation(ev);
                    int x;
                    int m = horizontal ? (_mouseDownVector.Yi - _currentMouseDownVector.Yi) : (_mouseDownVector.Xi - _currentMouseDownVector.Xi);

                    var y = GetMaxSplitterSize();
                    if ((x = fixedSplitterPostion == FixedSplitterPosition.Panel2 ? _startingSplitterPos + m : _startingSplitterPos - m)
                        > y)
                    {
                        x = y;
                    }
                    SplitterPosition        = x;
                    _currentMouseDownVector = _mouseDownVector;

                    ResizeChildren();
                }
            };

            Content.onmouseup = (ev) =>
            {
                IsMouseDown = false;
                RenderControls();
            };

            this.AppendChildren(Panel1, Splitter, Panel2);
        }