コード例 #1
0
/**
 * Move the selection end to the buffer offset physically below
 * the current selection end.
 */
Boolean Selection::ExtendDown(
    /* [in] */ ISpannable* text,
    /* [in] */ ILayout* layout)
{
    Int32 end = GetSelectionEnd(text);
    Int32 line;
    layout->GetLineForOffset(end, &line);
    Int32 len;
    Int32 lineCount;
    layout->GetLineCount(&lineCount);
    if (line < lineCount - 1) {
        Int32 move;
        Int32 direction1, direction2;
        layout->GetParagraphDirection(line, &direction1);
        layout->GetParagraphDirection(line + 1, &direction2);
        if (direction1 == direction2) {
            Float h;
            layout->GetPrimaryHorizontal(end, &h);
            layout->GetOffsetForHorizontal(line + 1, h, &move);
        }
        else {
            layout->GetLineStart(line + 1, &move);
        }

        ExtendSelection(text, move);
        return TRUE;
    }
    else if (end != (text->GetLength(&len), len)) {
        ExtendSelection(text, len);
        return TRUE;
    }

    return TRUE;
}
コード例 #2
0
/**
 * Move the selection end to the buffer offset physically above
 * the current selection end.
 */
Boolean Selection::ExtendUp(
    /* [in] */ ISpannable* text,
    /* [in] */ ILayout* layout)
{
    Int32 end = GetSelectionEnd(text);
    Int32 line;
    layout->GetLineForOffset(end, &line);

    if (line > 0) {
        Int32 move;
        Int32 direction1, direction2;
        layout->GetParagraphDirection(line, &direction1);
        layout->GetParagraphDirection(line - 1, &direction2);
        if (direction1 == direction2) {
            Float h;
            layout->GetPrimaryHorizontal(end, &h);
            layout->GetOffsetForHorizontal(line - 1, h, &move);
        }
        else {
            layout->GetLineStart(line - 1, &move);
        }

        ExtendSelection(text, move);
        return TRUE;
    }
    else if (end != 0) {
        ExtendSelection(text, 0);
        return TRUE;
    }

    return TRUE;
}
コード例 #3
0
void DisplayDirector::MouseDown(int x, int y)
{
	BPoint mousePoint(x, y);
	View* view = WindowView();

	// hit the hotspot
	if (hotspot && hotspot->ContainsPoint(ViewToDoc(mousePoint)))
		hotspot->Clicked(this);

	// extend the selection
	else if ((view->CurModifiers() & B_SHIFT_KEY) != 0)
		ExtendSelection();

	// promote or drag the selection
	else if (selection && selection->ContainsPoint(ViewToDoc(mousePoint))) {
		if (view->CurClicks() > 1) {
			StartRefreshCycle();
			selection->Promote(this);
			FinishRefreshCycle();
			ExtendSelection();
			}
		else
			DragSelection(mousePoint);
		}

	// otherwise find a new selection
	else {
		if (DocRect().Contains(mousePoint))
			FindSelection();
		else
			SetSelection(NULL);
		}
}
コード例 #4
0
Boolean Selection::ExtendToRightEdge(
    /* [in] */ ISpannable* text,
    /* [in] */ ILayout* layout)
{
    Int32 where = FindEdge(text, layout, 1);
    ExtendSelection(text, where);
    return TRUE;
}
コード例 #5
0
/**
 * Move the selection end to the buffer offset physically to the right of
 * the current selection end.
 */
Boolean Selection::ExtendRight(
    /* [in] */ ISpannable* text,
    /* [in] */ ILayout* layout)
{
    Int32 end = GetSelectionEnd(text);
    Int32 to;
    layout->GetOffsetToRightOf(end, &to);

    if (to != end) {
        ExtendSelection(text, to);
        return TRUE;
    }

    return TRUE;
}
コード例 #6
0
ファイル: selectionapi.c プロジェクト: ArcScofield/Amaya
/*----------------------------------------------------------------------
  TtaExtendSelection

  Extends the current selection to a given element.
  Parameters:
  document: the document for which the selection must be extended.
  element: the element to which the selection must be extended.
  lastCharacter: position within this element of the last character
  to be selected. 0 if the whole element must be selected.
  ----------------------------------------------------------------------*/
void TtaExtendSelection (Document document, Element element, int lastCharacter)
{
  PtrDocument         pDoc;
  PtrElement          firstSelection, lastSelection;
  DisplayMode         dispMode;
  int                 firstChar, lastChar;
  ThotBool            ok;
  ThotBool            abort;

  UserErrorCode = 0;
  if (element == NULL)
    TtaError (ERR_invalid_parameter);
  else if (((PtrElement) element)->ElParent == NULL)
    TtaError (ERR_invalid_parameter);
  /* Checks the parameter document */
  else if (document < 1 || document > MAX_DOCUMENTS)
    TtaError (ERR_invalid_document_parameter);
  else if (LoadedDocument[document - 1] == NULL)
    TtaError (ERR_invalid_document_parameter);
  else
    /* Parameter document is correct */
    {
      /* verifies if there is a selection */
      ok = GetCurrentSelection (&pDoc, &firstSelection, &lastSelection,
                                &firstChar, &lastChar);
      dispMode = TtaGetDisplayMode (document);
      if (dispMode == DisplayImmediately)
        /* The command can be executed */
        {
          if (ok)
            /* verifies that the selection is into the document */
            ok = (pDoc == LoadedDocument[document - 1]);
        }
      /* verifies if a selection is applied */
      else if (IsSelectionRegistered (document, &abort))
        /* There is an application, the extension is accepted if there is 
           a request which is not for aborting */
        ok = !abort;
      
      if (!ok)
        /* Error: no selection */
        TtaError (ERR_no_selection_in_document);
      else if (dispMode == DisplayImmediately)
        ExtendSelection ((PtrElement) element, lastCharacter, TRUE, FALSE, FALSE);
      else
        NewSelectionExtension (document, element, lastCharacter);
    }
}
コード例 #7
0
/** {@hide} */
Boolean Selection::MoveToFollowing(
    /* [in] */ ISpannable* text,
    /* [in] */ ISelectionPositionIterator* iter,
    /* [in] */ Boolean extendSelection)
{
    assert(iter != NULL);

    Int32 offset;
    iter->Following(GetSelectionEnd(text), &offset);
//    if (offset != ISelectionPositionIterator::DONE) {
        if (extendSelection) {
            ExtendSelection(text, offset);
        } else {
            SetSelection(text, offset);
        }
//    }
    return TRUE;
}
コード例 #8
0
ファイル: clipbrd.c プロジェクト: mingpen/OpenNT
VOID
ScrollIfNecessary(
    IN PCONSOLE_INFORMATION Console,
    IN PSCREEN_INFORMATION ScreenInfo
    )
{
    POINT CursorPos;
    RECT ClientRect;
    COORD MousePosition;

    if (Console->Flags & CONSOLE_SELECTING &&
        Console->SelectionFlags & CONSOLE_MOUSE_DOWN) {
        if (!GetCursorPos(&CursorPos)) {
            return;
        }
        if (!GetClientRect(Console->hWnd,&ClientRect)) {
            return;
        }
        MapWindowPoints(Console->hWnd,NULL,(LPPOINT)&ClientRect,2);
        if (!(PtInRect(&ClientRect,CursorPos))) {
            ScreenToClient(Console->hWnd,&CursorPos);
            MousePosition.X = (SHORT)CursorPos.x;
            MousePosition.Y = (SHORT)CursorPos.y;
            if (ScreenInfo->Flags & CONSOLE_TEXTMODE_BUFFER) {
                MousePosition.X /= ScreenInfo->BufferInfo.TextInfo.FontSize.X;
                MousePosition.Y /= ScreenInfo->BufferInfo.TextInfo.FontSize.Y;
            }
            MousePosition.X += ScreenInfo->Window.Left;
            MousePosition.Y += ScreenInfo->Window.Top;

            ExtendSelection(Console,
                            MousePosition
                           );
        }
    }
}
コード例 #9
0
/*
   The numArg here is the listbox item index while the strArg is used
   differently for the different actions:

   a) for wxACTION_LISTBOX_FIND it has the natural meaning: this is the string
      to find

   b) for wxACTION_LISTBOX_SELECT and wxACTION_LISTBOX_EXTENDSEL it is used
      to decide if the listbox should send the notification event (it is empty)
      or not (it is not): this allows us to reuse the same action for when the
      user is dragging the mouse when it has been released although in the
      first case no notification is sent while in the second it is sent.
 */
bool wxListBox::PerformAction(const wxControlAction& action,
                              long numArg,
                              const wxString& strArg)
{
    int item = (int)numArg;

    if ( action == wxACTION_LISTBOX_SETFOCUS )
    {
        SetCurrentItem(item);
    }
    else if ( action == wxACTION_LISTBOX_ACTIVATE )
    {
        Activate(item);
    }
    else if ( action == wxACTION_LISTBOX_TOGGLE )
    {
        if ( item == -1 )
            item = m_current;

        if ( IsSelected(item) )
            DoUnselect(item);
        else
            SelectAndNotify(item);
    }
    else if ( action == wxACTION_LISTBOX_SELECT )
    {
        DeselectAll(item);

        if ( strArg.empty() )
            SelectAndNotify(item);
        else
            DoSelect(item);
    }
    else if ( action == wxACTION_LISTBOX_SELECTADD )
        DoSelect(item);
    else if ( action == wxACTION_LISTBOX_UNSELECT )
        DoUnselect(item);
    else if ( action == wxACTION_LISTBOX_MOVEDOWN )
        ChangeCurrent(1);
    else if ( action == wxACTION_LISTBOX_MOVEUP )
        ChangeCurrent(-1);
    else if ( action == wxACTION_LISTBOX_PAGEDOWN )
        ChangeCurrent(GetItemsPerPage());
    else if ( action == wxACTION_LISTBOX_PAGEUP )
        ChangeCurrent(-GetItemsPerPage());
    else if ( action == wxACTION_LISTBOX_START )
        SetCurrentItem(0);
    else if ( action == wxACTION_LISTBOX_END )
        SetCurrentItem(GetCount() - 1);
    else if ( action == wxACTION_LISTBOX_UNSELECTALL )
        DeselectAll(item);
    else if ( action == wxACTION_LISTBOX_EXTENDSEL )
        ExtendSelection(item);
    else if ( action == wxACTION_LISTBOX_FIND )
        FindNextItem(strArg);
    else if ( action == wxACTION_LISTBOX_ANCHOR )
        AnchorSelection(item == -1 ? m_current : item);
    else if ( action == wxACTION_LISTBOX_SELECTALL ||
              action == wxACTION_LISTBOX_SELTOGGLE )
        wxFAIL_MSG(_T("unimplemented yet"));
    else
        return wxControl::PerformAction(action, numArg, strArg);

    return true;
}