/// <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.FieldWorks.Common.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));
            }
        }
		/// --------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="cch"></param>
		/// <param name="_rgchw"></param>
		/// <param name="uOptions"></param>
		/// <param name="_rect"></param>
		/// <param name="_rgdx"></param>
		/// --------------------------------------------------------------------------------
		public void DrawTextExt(int x, int y, int cch, string _rgchw, uint uOptions, ref Rect _rect, int _rgdx)
		{
			CheckDisposed();

			// TODO:  Add DummyGraphics.DrawTextExt implementation
		}
		/// --------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="_pic"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="cx"></param>
		/// <param name="cy"></param>
		/// <param name="xSrc"></param>
		/// <param name="ySrc"></param>
		/// <param name="cxSrc"></param>
		/// <param name="cySrc"></param>
		/// <param name="_rcWBounds"></param>
		/// --------------------------------------------------------------------------------
		public void RenderPicture(stdole.IPicture _pic, int x, int y, int cx, int cy, int xSrc, int ySrc, int cxSrc, int cySrc, ref Rect _rcWBounds)
		{
			CheckDisposed();

			// TODO:  Add DummyGraphics.RenderPicture implementation
		}
		/// --------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="_rcClip"></param>
		/// --------------------------------------------------------------------------------
		public void SetClipRect(ref Rect _rcClip)
		{
			CheckDisposed();

			// TODO:  Add DummyGraphics.SetClipRect implementation
		}
		/// --------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="rcClip"></param>
		/// --------------------------------------------------------------------------------
		public void PushClipRect(Rect rcClip)
		{
			CheckDisposed();

			// TODO:  Add DummyGraphics.PushClipRect implementation
		}
Beispiel #6
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.FieldWorks.Common.Utils.Rect clipRect = new SIL.FieldWorks.Common.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 #7
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.FieldWorks.Common.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.FieldWorks.Common.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(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.
					}
				}
			}
		}