Redefine Rect structure.
We can't simply use Rectangle, because the struct layout is different (Rect uses left, top, right, bottom, whereas Rectangle uses x, y, width, height).
Beispiel #1
0
		public void GetClientRectangle(out Rect clientRectangle)
		{
			if ( m_control == null)
				throw new ApplicationException("Window not set");

			clientRectangle.top = m_control.ClientRectangle.Top;
			clientRectangle.left = m_control.ClientRectangle.Left;
			clientRectangle.right = m_control.ClientRectangle.Right;
			clientRectangle.bottom = m_control.ClientRectangle.Bottom;
		}
        /// <summary>
        /// Display the combo box at the specified location, or the list box pulled down from the specified location.
        /// </summary>
        /// <param name="loc"></param>
        public void Activate(SIL.Utils.Rect loc)
        {
            CheckDisposed();

            FwComboBox combo = m_combo as FwComboBox;

            if (combo != null)
            {
                combo.Location = new System.Drawing.Point(loc.left, loc.top);
                // 21 is the default height of a combo, the smallest reasonable size.
                combo.Size = new System.Drawing.Size(Math.Max(loc.right - loc.left + 30, 200), Math.Max(loc.bottom - loc.top, 50));
                if (!m_owner.Controls.Contains(combo))
                {
                    m_owner.Controls.Add(combo);
                }
            }
            else
            {
                ComboListBox c = (m_combo as ComboListBox);
                c.AdjustSize(500, 400);                 // these are maximums!
                c.Launch(m_owner.RectangleToScreen(loc), Screen.GetWorkingArea(m_owner));
            }
        }
		public void GetParaLocation(out Rect _rdLoc)
		{
			throw new NotImplementedException();
		}
		public void Location(IVwGraphics _vg, Rect rcSrc, Rect rcDst, out Rect _rdPrimary, out Rect _rdSecondary, out bool _fSplit, out bool _fEndBeforeAnchor)
		{
			throw new NotImplementedException();
		}
Beispiel #5
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Scroll to the bottom. This is somewhat tricky because after scrolling to the bottom of
		/// the range as we currently estimate it, expanding a closure may change things.
		/// <seealso cref="GoToEnd"/>
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public virtual void ScrollToEnd()
		{
			CheckDisposed();
			if (DoingScrolling && !DesignMode)
			{
				// dy gets added to the scroll offset. This means a positive dy causes there to be more
				// of the view hidden above the top of the screen. This is the same effect as clicking a
				// down arrow, which paradoxically causes the window contents to move up.
				int dy = 0;
				int ydCurr = -ScrollPosition.Y; // Where the window thinks it is now.

				using (new HoldGraphics(this))
				{
					// This loop repeats until we have figured out a scroll distance AND confirmed
					// that we can draw that location without messing things up.
					for (; ; )
					{
						int ydMax = DisplayRectangle.Height - ClientHeight + 1;
						dy = ydMax - ydCurr;
						// OK, we need to move by dy. But, we may have to expand a lazy box there in order
						// to display a whole screen full. If the size estimate is off (which it usually is),
						// that would affect the scroll position we need to be at the very bottom.
						// To avoid this, we make the same PrepareToDraw call
						// that the rendering code will make before drawing after the scroll.
						Rectangle rcSrcRoot;
						Rectangle rcDstRoot;
						GetCoordRects(out rcSrcRoot, out rcDstRoot);
						rcDstRoot.Offset(0, -dy);

						int dyRange = m_rootb.Height;
						Rectangle r = AdjustedClientRectangle;
						SIL.Utils.Rect clipRect = new SIL.Utils.Rect(r.Left, r.Top, r.Right, r.Bottom);

						if (m_graphicsManager.VwGraphics is IVwGraphicsWin32)
							((IVwGraphicsWin32)m_graphicsManager.VwGraphics).SetClipRect(ref clipRect);

						if (m_rootb != null && (m_dxdLayoutWidth > 0))
							PrepareToDraw(rcSrcRoot, rcDstRoot);

						ydCurr = -ScrollPosition.Y; // Where the window thinks it is now. (May have changed expanding.)
						// If PrepareToDraw didn't change the scroll range, it didn't mess anything up and we
						// can use the dy we figured. Otherwise, loop and figure it again with more complete
						// information, because something at a relevant point has been expanded to real boxes.
						if (m_rootb.Height == dyRange)
							break;
						dy = 0; // Back to initial state.
					}

					if (dy != 0)
					{
						// Update the scroll bar.
						// We have to pass a positive value, although ScrollPosition
						// returns a negative one
						ScrollPosition = new Point(-ScrollPosition.X, ydCurr + dy);
					}
				}
			}
		}
Beispiel #6
0
		/// <summary>
		/// Make a combo box appropriate for the specified selection. If fMouseDown is true,
		/// do so unconditionally...otherwise (mousemove) only if the new selection is on a different thing.
		/// </summary>
		/// <param name="vwselNew"></param>
		/// <param name="fForce"></param>
		private void ShowComboForSelection(IVwSelection vwselNew, bool fMouseDown)
		{
			// It's a good idea to get this first...it's possible for MakeCombo to leave the selection invalid.
			SIL.Utils.Rect loc;
			vwselNew.GetParaLocation(out loc);
			if (!fMouseDown)
			{
				// It's a mouse move.
				// If we've moved to somewhere outside any paragraph get rid of the combos.
				// But, allow somewhere close, since otherwise it's almost impossible to get
				// a combo on an empty string.
				SIL.Utils.Rect locExpanded = loc;
				locExpanded.right += 50;
				locExpanded.left -= 5;
				locExpanded.top -= 2;
				locExpanded.bottom += 2;
				if (!locExpanded.Contains(m_LastMouseMovePos))
				{
					HideCombos();
					return;
				}
				// Don't do anything if the current mouse position is in the same paragraph
				// as before. Things tend to flicker if we continually create and remove it.
				// But, if we've hidden all the combos, go ahead even if at the same position as before...
				// otherwise, when we drag off outside the text and return, we may not get any combo.
				if (loc.Equals(m_locLastShowCombo) && FirstLineHandler != null)
				{
					return;
				}
			}
			FinishUpOk(); // Just like OK, if there are pending edits in the combo, do them.
			// Changing a different item may result in changes to this one also. This could invalidate
			// the selection, in which case, we can't use it.
			// Enhance JohnT: might consider trying the current selection, if any, if called from
			// MouseDown...that would not be useful if called from hover. But there probably isn't
			// a current selection in that case. Could try a selection at the saved mouse position.
			if (!vwselNew.IsValid)
				return;

			m_locLastShowCombo = loc;

			m_fMakingCombo = true;
			HideCombos();
			// No matter what, we are fixin to get rid of the old value.
			DisposeComboHandler();
			if (!m_fInMouseDrag)
			{
				m_ComboHandler = InterlinComboHandler.MakeCombo(m_mediator.HelpTopicProvider,
					vwselNew, this, fMouseDown);
			}
			else
			{
				m_ComboHandler = null;
			}
			m_fMakingCombo = false;
			m_fLockCombo = false; // nothing typed in it yet.
			if (m_ComboHandler != null)
			{
				// Set the position of the combo and display it. Do this before synchronizing
				// the LexEntry display, which can take a while.
				m_ComboHandler.Activate(loc);
				m_fMouseDownActivatedCombo = true;
				// If the selection moved to a different morpheme, and we know a corresponding
				// LexEntry, switch to it.
				if (m_ComboHandler.SelectedMorphHvo != 0)
				{
					int hvoSbEntry = m_caches.DataAccess.get_ObjectProp(
						m_ComboHandler.SelectedMorphHvo, ktagSbMorphEntry);
					if (hvoSbEntry != 0)
					{
						//SetSelectedEntry(m_caches.RealHvo(hvoSbEntry)); // seems to be buggy.
					}
				}
			}
		}
			public void Activate(Rect loc) { }