Esempio n. 1
0
void EditTextTask::DeleteBack()
{
    m_posb = m_posa;
    DecrementPosition(m_posa);
    if(HasSelection())DeleteSelection();

}
Esempio n. 2
0
void wxTextCtrl::DoWriteText(const wxString& value, int flags)
{
    bool selectionOnly = (flags & SetValue_SelectionOnly) != 0;
    wxString valueDos;
    if ( m_windowStyle & wxTE_MULTILINE )
        valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
    else
        valueDos = value;

    // in some cases we get 2 EN_CHANGE notifications after the SendMessage
    // call below which is confusing for the client code and so should be
    // avoided
    //
    if ( selectionOnly && HasSelection() )
    {
        m_suppressNextUpdate = true;
    }

    ::SendMessage(GetBuddyHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
                  0, (LPARAM)valueDos.c_str());

    if ( !selectionOnly && !( flags & SetValue_SendEvent ) )
    {
        // Windows already sends an update event for single-line
        // controls.
        if ( m_windowStyle & wxTE_MULTILINE )
            SendUpdateEvent();
    }

    AdjustSpaceLimit();
}
Esempio n. 3
0
void EditTextTask::OnKeyDown(wxKeyEvent &event)
{
    if ( m_done ) return;

    int code = event.GetKeyCode();
    event.Skip(true);

    if ( code == WXK_ESCAPE )
    {
        CloseTask();
        event.Skip(false);
    }
    if ( code == WXK_DELETE || code == WXK_NUMPAD_DELETE || code == WXK_BACK )
    {
        if ( HasSelection() )
            DeleteSelection();
        else
            if ( code == WXK_BACK )
                DeleteBack();
            else
                Delete();
        event.Skip(false);
    }
    if ( code == WXK_RETURN || code == WXK_NUMPAD_ENTER )
    {
        InsertText(_T("\n"));
        event.Skip(false);
    }
    if ( code == WXK_TAB )
    {
        InsertText(_T("\t"));
        event.Skip(false);
    }
}
Esempio n. 4
0
void
TextDocumentView::Copy(BClipboard* clipboard)
{
	if (!HasSelection() || fTextDocument.Get() == NULL) {
		// Nothing to copy, don't clear clipboard contents for now reason.
		return;
	}

	if (clipboard == NULL || !clipboard->Lock())
		return;

	clipboard->Clear();

	BMessage* clip = clipboard->Data();
	if (clip != NULL) {
		int32 start;
		int32 end;
		GetSelection(start, end);

		BString text = fTextDocument->Text(start, end - start);
		clip->AddData("text/plain", B_MIME_TYPE, text.String(),
			text.Length());

		// TODO: Support for "application/x-vnd.Be-text_run_array"

		clipboard->Commit();
	}

	clipboard->Unlock();
}
Esempio n. 5
0
GLboolean drimi::Gui::Container::HandleTextUnicode ( const char cUnicode ) {
  // If a child is selected then give it text unicode.
  if (HasSelection () && m_oChildren[m_iSelectedChild]->IsActive ()) {
    m_oChildren[m_iSelectedChild]->HandleTextUnicode (cUnicode);
  }

  return GL_FALSE;
}
Esempio n. 6
0
void drimi::Gui::Container::Pack ( Component::Ptr pComponent ) {
  m_oChildren.push_back (pComponent);

  // If container has no selection and the component
  // is selectable then select it.
  if (!HasSelection () && pComponent->IsSelectable ())
    Select (m_oChildren.size ()-1);
}
Esempio n. 7
0
void drimi::Gui::Container::Select ( std::size_t iIndex ) {
	if (m_oChildren[iIndex]->IsSelectable ()) {
    // Deselect the current selected component.
		if (HasSelection ())
			m_oChildren[m_iSelectedChild]->Deselect ();
    // Select the new component.
		m_oChildren[iIndex]->Select ();
		m_iSelectedChild = iIndex;
	}
}
Esempio n. 8
0
	void Container::Impl::Select( std::size_t index )
	{
		if( mChildren[ index ]->IsSelectable() )
		{
			if( HasSelection() )
			{
				mChildren[ mSelectedChild ]->Deselect();
			}

			mChildren[ index ]->Select();
			mSelectedChild = index;
		}
	}
Esempio n. 9
0
void CBottomView::AddContextItems(CIconMenu& popup, DiffStates state)
{
    const bool bShow = HasSelection() && (state != DIFFSTATE_UNKNOWN);
    if (!bShow)
        return;

    popup.AppendMenuIcon(POPUPCOMMAND_USETHEIRBLOCK, IDS_VIEWCONTEXTMENU_USETHEIRBLOCK);
    popup.AppendMenuIcon(POPUPCOMMAND_USEYOURBLOCK, IDS_VIEWCONTEXTMENU_USEYOURBLOCK);
    popup.AppendMenuIcon(POPUPCOMMAND_USEYOURANDTHEIRBLOCK, IDS_VIEWCONTEXTMENU_USEYOURANDTHEIRBLOCK);
    popup.AppendMenuIcon(POPUPCOMMAND_USETHEIRANDYOURBLOCK, IDS_VIEWCONTEXTMENU_USETHEIRANDYOURBLOCK);

    CBaseView::AddContextItems(popup, state);
}
Esempio n. 10
0
void drimi::Gui::Container::SelectPrevious ( void ) {
  // If container has no selection, break.
	if (!HasSelection ())
		return;

	// Search previous component that is selectable, wrap around if necessary.
	GLint iPrevious = m_iSelectedChild;
	do {
		iPrevious = (iPrevious+m_oChildren.size ()-1) % m_oChildren.size ();
	} while (!m_oChildren[iPrevious]->IsSelectable());

	// Select that component.
	Select (iPrevious);
}
Esempio n. 11
0
wxString EditTextTask::GetSelectedText()
{
    if ( !m_textgraph || !HasSelection() ) return wxEmptyString;

    wxString s( *( m_textgraph->m_brick->GetTextByNumber(m_textgraph->m_nmbr) ) );
    wxString res;

    wxInt32 pos;
    wxUint32 line = 0;
    do{
        pos = s.Find('\n');
        wxString te = s;
        if ( pos != -1 )
        {
            te = s.SubString(0, pos-1);
            s = s.SubString(pos+1, s.Length() );
        }
        if ( line >= m_posa.line && line <= m_posb.line )
        {
            if ( m_posa.line == m_posb.line )
            {
                res = te.SubString(m_posa.column, m_posb.column);
                break;
            }
            else
            {
                if ( line == m_posa.line )
                    res = te.SubString(m_posa.column, te.Length());
                else
                {
                    res += _T('\n');
                    if ( line == m_posb.line)
                    {
                        res += te.SubString(0, m_posb.column);
                        break;
                    }
                    else
                        res += te;
                }
            }
        }
        else if (line > m_posb.line )
            break;

        ++line;
    }
    while ( pos != -1);

    return res;
}
Esempio n. 12
0
void FB_Frame::OnMenuOpen ( wxMenuEvent& event )
{
    if ( event.GetMenu() == m_EditMenu )
    {
        FB_STC * stc = 0;
        if( m_Code_areaTab != 0 )
            stc = reinterpret_cast<FB_STC *>( m_Code_areaTab->GetCurrentPage() );

        #define _ENABLE( id, func ) m_EditMenu->Enable( id, ( stc != 0 ) ? stc -> func : false )
            _ENABLE( wxID_UNDO,                 CanUndo() );
            _ENABLE( wxID_REDO,                 CanRedo() );
            _ENABLE( wxID_COPY,                 HasSelection() );
            _ENABLE( wxID_CUT,                  HasSelection() );
            _ENABLE( wxID_PASTE,                CanPaste() );
            _ENABLE( wxID_SELECTALL,            GetLength() );
            _ENABLE( fbideID_SelectLine,        GetLength() );
            _ENABLE( fbideID_CommentBlock,      CanComment() );
            _ENABLE( fbideID_UncommentBlock,    CanComment() );
        #undef _ENABLE
        m_EditMenu->Enable(wxID_JUSTIFY_RIGHT,    ( stc ) ? true : false );
        m_EditMenu->Enable(wxID_JUSTIFY_LEFT,     ( stc ) ? true : false );
    }
}
Esempio n. 13
0
void drimi::Gui::Container::SelectNext ( void ) {
  // If container has no selection, break.
	if (!HasSelection ())
		return;

	// Search next component that is selectable, wrap around if necessary.
	GLint iNext = m_iSelectedChild;
	do {
		iNext = (iNext+1) % m_oChildren.size ();
	} while (!m_oChildren[iNext]->IsSelectable());

	// Select that component.
	Select (iNext);
}
Esempio n. 14
0
GLboolean drimi::Gui::Container::HandleEvent ( const drimi::Event::Type eEventType, const sf::Keyboard::Key sfKeyCode ) {
  // If a child is selected then give it events.
  if (HasSelection ()) {
    m_oChildren[m_iSelectedChild]->HandleEvent (eEventType, sfKeyCode);
  }
  if (eEventType == drimi::Event::Type::KeyPressed) {
    if (sfKeyCode == sf::Keyboard::Up)
			SelectPrevious ();
		else if (sfKeyCode == sf::Keyboard::Down)
			SelectNext ();
  }

  return GL_FALSE;
}
Esempio n. 15
0
	void Container::Impl::SelectPrevious()
	{
		if( !HasSelection() )
		{
			return;
		}

		int prev = mSelectedChild;
		do
		{
			prev = ( prev + mChildren.size() - 1 ) % mChildren.size();
		}
		while( !mChildren[ prev ]->IsSelectable() );

		Select( prev );
	}
Esempio n. 16
0
	void Container::Impl::SelectNext()
	{
		if( !HasSelection() )
		{
			return;
		}

		int next = mSelectedChild;
		do
		{
			next = ( next + 1 ) % mChildren.size();
		}
		while( !mChildren[ next ]->IsSelectable() );

		Select( next );
	}
Esempio n. 17
0
void MyFrame::OnFind (wxCommandEvent& WXUNUSED(event)) {
    if (stc==0)
        return;
    if (FindDialog != NULL || ReplaceDialog != NULL)
        return;

    if (HasSelection())
        FindData->SetFindString(stc->GetSelectedText());

    else
        FindData->SetFindString(GetTextUnderCursor());

    FindDialog = new wxFindReplaceDialog(this, FindData, _(Lang[219]), 0); //Find text
    FindDialog->Show();
    return;
}
Esempio n. 18
0
void MyFrame::OnReplace (wxCommandEvent& WXUNUSED(event)) {
    if (stc==0)
        return;
    if (FindDialog != NULL || ReplaceDialog != NULL)
        return;

    if (HasSelection())
        ReplaceData->SetFindString(stc->GetSelectedText());
    else
        ReplaceData->SetFindString(GetTextUnderCursor());

    ReplaceDialog = new wxFindReplaceDialog(this, ReplaceData,
                                            _(Lang[220]), wxFR_REPLACEDIALOG); //Replace text

    ReplaceDialog->Show();
    return;
}
Esempio n. 19
0
void DataModelListCtrl::OnKeyDown(wxKeyEvent& event)
{
    switch (event.GetKeyCode())
    {
      case WXK_DELETE:
         if (m_id_delete)
         {
            if (HasSelection())
                wxPostMenuCommand(GetParent(), m_id_delete);
         }
         else
             event.Skip();
         break;
      default:
         event.Skip();
         break;
   }
}
Esempio n. 20
0
void CLeftView::AddContextItems(CIconMenu& popup, DiffStates state)
{
    const bool bShow = HasSelection() && (state != DIFFSTATE_UNKNOWN);

    if (IsBottomViewGood())
    {
        if (bShow)
            popup.AppendMenuIcon(POPUPCOMMAND_USETHEIRBLOCK, IDS_VIEWCONTEXTMENU_USETHISBLOCK);
        popup.AppendMenuIcon(POPUPCOMMAND_USETHEIRFILE, IDS_VIEWCONTEXTMENU_USETHISFILE);
        if (bShow)
        {
            popup.AppendMenuIcon(POPUPCOMMAND_USEYOURANDTHEIRBLOCK, IDS_VIEWCONTEXTMENU_USEYOURANDTHEIRBLOCK);
            popup.AppendMenuIcon(POPUPCOMMAND_USETHEIRANDYOURBLOCK, IDS_VIEWCONTEXTMENU_USETHEIRANDYOURBLOCK);
        }
    }
    else
    {
        if (bShow)
        {
            popup.AppendMenuIcon(POPUPCOMMAND_USELEFTBLOCK, IDS_VIEWCONTEXTMENU_USETHISBLOCK);
            popup.AppendMenuIcon(POPUPCOMMAND_USEBOTHLEFTFIRST, IDS_VIEWCONTEXTMENU_USEBOTHTHISFIRST);
            popup.AppendMenuIcon(POPUPCOMMAND_USEBOTHRIGHTFIRST, IDS_VIEWCONTEXTMENU_USEBOTHTHISLAST);
            if (IsLeftViewGood() && !m_pwndLeft->IsReadonly())
            {
                popup.AppendMenu(MF_SEPARATOR, NULL);
                popup.AppendMenuIcon(POPUPCOMMAND_PREPENDFROMRIGHT, IDS_VIEWCONTEXTMENU_PREPENDRIGHT);
                popup.AppendMenuIcon(POPUPCOMMAND_REPLACEBYRIGHT, IDS_VIEWCONTEXTMENU_USERIGHT);
                popup.AppendMenuIcon(POPUPCOMMAND_APPENDFROMRIGHT, IDS_VIEWCONTEXTMENU_APPENDRIGHT);
            }
            popup.AppendMenu(MF_SEPARATOR, NULL);
        }
        popup.AppendMenuIcon(POPUPCOMMAND_USELEFTFILE, IDS_VIEWCONTEXTMENU_USETHISFILE);
        if (IsLeftViewGood() && !m_pwndLeft->IsReadonly())
        {
            popup.AppendMenuIcon(POPUPCOMMAND_USERIGHTFILE, IDS_VIEWCONTEXTMENU_USEOTHERFILE);
        }
    }

    CBaseView::AddContextItems(popup, state);
}
void
JXInputField::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	if (itsTable != NULL && itsTable->WantsInputFieldKey(key, modifiers))
		{
		itsTable->HandleKeyPress(key, modifiers);
		return;
		}
	else if (itsTable != NULL)
		{
		JPoint cell;
		const JBoolean ok = itsTable->GetEditedCell(&cell);
		assert( ok );
		itsTable->TableScrollToCell(cell);
		}

	if (key == JXCtrl('K') && modifiers.control() && HasSelection())
		{
		Cut();
		}
	else if (key == JXCtrl('K') && modifiers.control())
		{
		JIndex i;
		const JBoolean ok = GetCaretLocation(&i);
		assert( ok );
		SetSelection(i, GetTextLength());
		Cut();
		}

	else
		{
		JXTEBase::HandleKeyPress(key, modifiers);
		}
}
void
CBShellEditor::HandleKeyPress
	(
	const int				key,
	const JXKeyModifiers&	modifiers
	)
{
	const JBoolean controlOn = modifiers.control();
	const JBoolean metaOn    = modifiers.meta();
	const JBoolean shiftOn   = modifiers.shift();
	if ((key == kJLeftArrow && metaOn && !controlOn && !shiftOn) ||
		(key == JXCtrl('A') && controlOn && !metaOn && !shiftOn))
		{
		const JIndex index            = GetInsertionIndex();
		const JRunArray<Font>& styles = GetStyles();
		if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
			{
			JIndex runIndex, firstIndexInRun;
			const JBoolean ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);
			SetCaretLocation(firstIndexInRun);
			return;
			}
		}

	if (key == kJReturnKey)
		{
		SetCurrentFont(itsInsertFont);
		}
	else
		{
		SetCurrentFont(GetDefaultFont());
		}

	JBoolean sentCmd = kJFalse;
	if (key == kJReturnKey && !modifiers.shift() && !HasSelection())
		{
		JIndex index;
		JBoolean ok = GetCaretLocation(&index);
		assert( ok );

		JString cmd;
		const JRunArray<Font>& styles = GetStyles();
		if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
			{
			JIndex runIndex, firstIndexInRun;
			ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);

			const JIndex endIndex = firstIndexInRun + styles.GetRunLength(runIndex);
			cmd = (GetText()).GetSubstring(firstIndexInRun, endIndex - 1);
			SetCaretLocation(endIndex);

			if (cmd.BeginsWith("man "))
				{
				cmd.ReplaceSubstring(1, 4, "jcc --man ");
				}
			else if (cmd.BeginsWith("apropos "))
				{
				cmd.ReplaceSubstring(1, 8, "jcc --apropos ");
				}
			else if (cmd.BeginsWith("vi "))
				{
				cmd.ReplaceSubstring(1, 3, "jcc ");
				}
			else if (cmd.BeginsWith("less ") || cmd.BeginsWith("more "))
				{
				cmd.ReplaceSubstring(1, 5, "jcc ");
				}
			else if (cmd == "more" || cmd == "less" || cmd == "vi")
				{
				cmd = "jcc";
				}
			}

		cmd += "\n";
		itsShellDoc->SendCommand(cmd);

		sentCmd = kJTrue;
		}

	CBTextEditor::HandleKeyPress(key, modifiers);

	if (sentCmd)
		{
		itsInsertIndex = GetInsertionIndex();
		}
}
Esempio n. 23
0
void DataModelListCtrl::OnUpdateNeedSel(wxUpdateUIEvent& event)
{
    event.Enable(GetModel() && GetModel()->IsOpen() && HasSelection());
}
Esempio n. 24
0
void DataModelListCtrl::OnSelectionChanged(wxListEvent& event)
{
    if (m_id_selchange && HasSelection())
        wxPostMenuCommand(GetParent(), m_id_selchange);
    event.Skip();
}
Esempio n. 25
0
void DataModelListCtrl::OnItemActivated(wxListEvent& event)
{
    if (m_id_edit && HasSelection())
        wxPostMenuCommand(GetParent(), m_id_edit);
    event.Skip();
}
Esempio n. 26
0
bool wxComboBox::CanCopy() const
{
    // Can copy if there's a selection
    return HasSelection();
}
Esempio n. 27
0
bool wxTextCtrl::CanCopy() const
{
    // Can copy if there's a selection
    return HasSelection();
}
void wxSymbolPickerDialog::OnOkUpdate( wxUpdateUIEvent& event )
{
    event.Enable(HasSelection());
}
Esempio n. 29
0
void drimi::Gui::Container::Update ( void ) {
  // If a child is selected then update it.
  if (HasSelection () && m_oChildren[m_iSelectedChild]->IsActive ()) {
    m_oChildren[m_iSelectedChild]->Update ();
  }
}
Esempio n. 30
0
void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event)
{
    event.Enable(HasSelection() && IsEditable()) ;
}