//---------------------------------------------------------
void CINFO_Messages::On_Copy(wxCommandEvent &WXUNUSED(event))
{
	if( GetStringSelection().IsEmpty() )
	{
		SelectAll();
		Copy();
		SetSelection(GetLastPosition(), GetLastPosition());
	}
	else
	{
		Copy();
	}
}
Esempio n. 2
0
void wxTextCtrl::SetInsertionPointEnd()
{
    wxTextPos                       lPos = GetLastPosition();

    //
    // We must not do anything if the caret is already there because calling
    // SetInsertionPoint() thaws the controls if Freeze() had been called even
    // if it doesn't actually move the caret anywhere and so the simple fact of
    // doing it results in horrible flicker when appending big amounts of text
    // to the control in a few chunks (see DoAddText() test in the text sample)
    //
    if (GetInsertionPoint() == GetLastPosition())
        return;
    SetInsertionPoint(lPos);
} // end of wxTextCtrl::SetInsertionPointEnd
Esempio n. 3
0
void Edit::OnGoto (wxCommandEvent &WXUNUSED(event)) {
  const int lastLine = LineFromPosition(GetLastPosition());
  long line = wxGetNumberFromUser(wxT(""), wxT("Goto line:"), wxT("Goto Line"), 1, 1, 1000000, this);
  if(line <= lastLine) {
    GotoLine(line - 1);
  }
}
Esempio n. 4
0
void IRCTextCtrl::postAddMessage()
{
	// eventsCtrl->ShowPosition in alcune circostanze non funziona
	ScrollIntoView(GetLastPosition(), WXK_DOWN);

	limitLines();
}
Esempio n. 5
0
void IRCTextCtrl::preAddMessage()
{
	SetInsertionPointEnd();

	if(GetLastPosition() > 0)
		Newline();
}
Esempio n. 6
0
void psLinearMovement::SetSoftDRData (bool on_ground,
	csVector3& pos, float yrot, iSector *sector, csVector3& vel,
	csVector3& worldVel, float ang_vel)
{
  if (colldet)
    colldet->SetOnGround (on_ground);

  csVector3 cur_pos;
  float cur_rot;
  iSector *cur_sect;
  GetLastPosition (cur_pos, cur_rot, cur_sect);
  if (cur_sect == sector)
  {
    offset_err = pos - cur_pos;
    // Check for NaN conditions:
    if (offset_err.x != offset_err.x) offset_err.x = 0.0f;
    if (offset_err.y != offset_err.y) offset_err.y = 0.0f;
    if (offset_err.z != offset_err.z) offset_err.z = 0.0f;
    offset_rate = offset_err;
    SetPosition (cur_pos, yrot, sector);
  }
  else
  {
    offset_rate = offset_err = csVector3 (0.0f, 0.0f ,0.0f);
    SetPosition (pos, yrot, sector);
  }

  SetVelocity (vel);
  ClearWorldVelocity ();
  AddVelocity (worldVel);
  csVector3 rot (0.0f, ang_vel, 0.0f);
  SetAngularVelocity (rot);
  lastDRUpdate = csGetTicks ();
}
Esempio n. 7
0
long luConsoleEdit::getLastPromptPos()
{
	long x = 0, y = 0;
	long last = GetLastPosition();
	if (!PositionToXY(last, &x, &y))
		return 0;

	return XYToPosition(0, y);
}
Esempio n. 8
0
void wxComboBox::SetInsertionPointEnd()
{
    // setting insertion point doesn't make sense for read only comboboxes
    if ( !(GetWindowStyle() & wxCB_READONLY) )
    {
        wxTextPos pos = GetLastPosition();
        SetInsertionPoint(pos);
    }
}
Esempio n. 9
0
void psLinearMovement::GetDRData (bool& on_ground,
	csVector3& pos, float& yrot, iSector*& sector, csVector3& vel,
	csVector3& worldVel, float& ang_vel)
{
  on_ground = IsOnGround ();
  GetLastPosition (pos, yrot, sector);
  vel = velBody;
  ang_vel = angularVelocity.y;
  worldVel = this->velWorld;
}
Esempio n. 10
0
void wxComboBox::SetInsertionPoint( long pos )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );

    if ( pos == GetLastPosition() )
        pos = -1;

    GtkWidget *entry = GTK_COMBO(m_widget)->entry;
    gtk_entry_set_position( GTK_ENTRY(entry), (int)pos );
}
Esempio n. 11
0
void wxTextEntry::SetInsertionPoint(long pos)
{
    // calling DoSetSelection(-1, -1) would select everything which is not what
    // we want here
    if ( pos == -1 )
        pos = GetLastPosition();

    // be careful to call DoSetSelection() which is overridden in wxTextCtrl
    // and not just SetSelection() here
    DoSetSelection(pos, pos);
}
void PythonIOCtrl::OnUserInput(wxKeyEvent& ke)
{
    if(ke.GetModifiers()==wxMOD_CONTROL)
    {
//        wxMessageBox(_T("control pressed"));
//        wxMessageBox(wxString::Format(_("Key: %i"),ke.GetKeyCode()));
//        if(ke.GetKeyCode()==4)
//        {
//            m_pyctrl->DispatchCode(GetValue()); // would need to retrieve the code control's value
////            if(m_pyctrl->DispatchCode(GetValue()))
////                ChangeValue(_T(""));
//            return;
//        }
        if(ke.GetKeyCode()==5)
        {
            m_pyctrl->BreakCode();
            return;
        }
    }
    if(ke.GetKeyCode()==WXK_RETURN)
    {
        if(!ke.ShiftDown() && !ke.ControlDown())
        {
            if(m_line_entry_mode)
            {
                m_line_entry_mode=false;
                SetEditable(false);
                wxString line;
                if(m_line_entry_point<GetLastPosition())
                    line=GetRange(m_line_entry_point,GetLastPosition());
                line.Replace(_T("\n"),_T("")); //will cause major problems if there is more than one line feed returned here, so we remove them (TODO: fix on server side?? server should treat buffered lines as new input without errors)
                line.Replace(_T("\r"),_T(""));
                line.Append(_T("\n"));
                AppendText(_T("\n"));
                m_pyctrl->stdin_append(line);
                m_pyctrl->Continue();
            }
        }
    }
    ke.Skip();
}
SharedCaretState TextFormulaNode::GetPreviousPosition(SharedCaretState& relativeState)
{
	if (relativeState && relativeState->CheckInNode(this))
	{
		int pos = relativeState->GetPos();
		if (pos > 0)
			return SharedCaretState(new CaretState(this, pos - 1));
		return parent->GetPreviousPosition(relativeState);
	}
	
	return GetLastPosition();
}
Esempio n. 14
0
	void AppendText(const wxString& text, int lineCount, const CHARFORMAT2& cf)
	{
		HWND hwnd = (HWND)GetHWND();

		CHARRANGE range;
		range.cpMin = GetLastPosition();
		range.cpMax = range.cpMin;
		::SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&range);
		::SendMessage(hwnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
		m_updatesCount = -2; // suppress any update event
		::SendMessage(hwnd, EM_REPLACESEL, 0, (LPARAM)text.c_str());
		::SendMessage(hwnd, EM_LINESCROLL, (WPARAM)0, (LPARAM)lineCount);
	}
Esempio n. 15
0
void console::ted_log::OnLOGMessage(wxCommandEvent& evt) {
   wxColour logColour;
   long int startPos = GetLastPosition();
   switch (evt.GetInt())
   {
      case    MT_INFO:
         *this << rply_mark << evt.GetString() << wxT("\n");
         logColour = *wxBLACK;
//         logColour = *wxGREEN;
         break;
      case   MT_ERROR:
         *this << rply_mark << evt.GetString() << wxT("\n");
         logColour = *wxRED;
         break;
      case MT_COMMAND:
         *this << cmd_mark << evt.GetString() << wxT("\n");
         break;
      case MT_GUIPROMPT:
         *this << gui_mark; break;
      case MT_GUIINPUT:
         *this << evt.GetString();break;
      case MT_EOL:
         *this << wxT("\n"); break;
      case MT_WARNING:
         *this << rply_mark << evt.GetString() << wxT("\n");
         logColour = *wxBLUE;
         break;
      case MT_CELLNAME:
         *this << rply_mark << wxT(" Cell ") << evt.GetString() << wxT("\n");
         break;
      case MT_DESIGNNAME:
         *this << rply_mark << wxT(" Design ") << evt.GetString() << wxT("\n");
         break;
      default:
         assert(false);/*wxLogTextCtrl::DoLog(evt.GetInt(), evt.GetString(), evt.GetExtraLong());*/
   }   
   long int endPos = GetLastPosition();
   SetStyle(startPos,endPos,wxTextAttr(logColour));
}
Esempio n. 16
0
bool CHttpRanges::GetTotalRange(CHttpRange& range) const
{
  if (m_ranges.empty())
    return false;

  uint64_t firstPosition, lastPosition;
  if (!GetFirstPosition(firstPosition) || !GetLastPosition(lastPosition))
    return false;

  range.SetFirstPosition(firstPosition);
  range.SetLastPosition(lastPosition);

  return range.IsValid();
}
Esempio n. 17
0
void moLogTextCtrl::LogError( moText p_message ) {

    wxString  w = moText2Wx( p_message );

    if (GetNumberOfLines()>10000) {
        Clear();
    }

    SetDefaultStyle( wxTextAttr( wxColour(255,0,0) ) );
    AppendText(w + wxT("\n"));

    ShowPosition( GetLastPosition() );

}
Esempio n. 18
0
void Edit::OnFindReplaceDialog(wxFindDialogEvent& event)
{
  const wxEventType type = event.GetEventType();
  const wxString find_string = m_FindData.GetFindString();
  int found_start, found_end;

  if (type == wxEVT_FIND || type == wxEVT_FIND_NEXT) {
    // search
    if (FindText(found_start, found_end, type == wxEVT_FIND_NEXT)) {
      SetSelection(found_start, found_end);
    }
    else {
      wxMessageDialog dialog(this, wxT("Cannot find the text \"" + find_string + "\" from current position"), wxT("Find"));
      dialog.ShowModal();
    }
  }
  else if (type == wxEVT_FIND_REPLACE) {
    ReplaceText(find_string);
  }
  else if (type == wxEVT_FIND_REPLACE_ALL) {
    const wxString replace_string = m_FindData.GetReplaceString();
    int start_index = 0;
    bool found = true;
    int found_count = 0;
    do {
      // set search area
      SetTargetStart(start_index); SetTargetEnd(GetLastPosition());

      // search and replace
      found_start = SearchInTarget(find_string);
      if (found_start > -1) {
        found_end = found_start + find_string.size();
        SetTargetStart(found_start);
        SetTargetEnd(found_end);
        ReplaceTarget(replace_string);
        start_index = found_start + replace_string.size();
        found_count++;
      }
      else {
        found = false;
      }
    }
    while (found);

    const wxString message = wxString::Format(wxT("%d occurrence(s) of \"%s\" were replaced with \"%s\"."), 
      found_count, find_string, replace_string);
    wxMessageDialog replace_dialog(this, message, wxT("Replaced Text"));
    replace_dialog.ShowModal();
  }
}
SharedCaretState RootFormulaNode::GetNextPosition(SharedCaretState& relativeState)
{
	SharedCaretState res;
	
	if (!relativeState)
		res = GetFirstPosition();
	else
	{
		int i = -1;
		FormulaNode* node = relativeState->GetNode();
		if (!relativeState->CheckAtLast(this))
		{
			if (node == this)
			{
				i = relativeState->GetPos();
				FormulaNode* n = (*this)[i == childNodes->Count() ? i - 1 : i];
				res = n->GetNextPosition(relativeState);
				if (res)
					return res;
				if (i == childNodes->Count() - 1 && !dynamic_cast<EmptyFormulaNode*>(n))
					return SharedCaretState(new CaretState(this, i + 1));
			}
			else
				i = GetFirstLevelChildPos(node);
		}
		else if (node == this && parent)
			res = parent->GetNextPosition(relativeState);
		else
			i = GetFirstLevelChildPos(node);

		if (i != -1)
		{		
			if (i + 1 < childNodes->Count())
			{
				FormulaNode* n = (*this)[i + 1];
				res = n->GetNextPosition(relativeState);
				if (!res && n->CanSetCaret())
					res = SharedCaretState(new CaretState(this, i + 1));
			}
			else if (!IsEmptySymbol() && i == childNodes->Count() - 1 && *relativeState != *GetLastPosition())
				return SharedCaretState(new CaretState(this, i + 1));
		}
		
		if (!res && parent)
			return parent->GetNextPosition(relativeState);
	}
	
	return res;
}
Esempio n. 20
0
void moLogTextCtrl::Log( moText p_message ) {

    wxString  w = moText2Wx( p_message );

    ///cada 10000 lineas publicadas, limpia el buffer completo
    if (GetNumberOfLines()>10000) {
        Clear();
    }

    SetDefaultStyle( wxTextAttr( wxColour( 50, 255, 50 )) );
    AppendText(w + wxT("\n"));

    ShowPosition( GetLastPosition() );

}
void PythonIOCtrl::LineInputRequest()
{
    if(!m_line_entry_mode)
    {
        m_line_entry_mode=true;
        m_line_entry_point=GetLastPosition();
        SetSelection(m_line_entry_point,m_line_entry_point);
        SetEditable(true);
        SetFocus();

        InfoWindow::Display(_("Python Interpreter Input Requested"),
                            _("An interpreter has needs keyboard input in its I/O window to proceed"), 8000);

    }
}
//---------------------------------------------------------
void CINFO_Messages::_Add_Text(wxString Text)
{
	int		i, n;

	if( m_MaxLength <= (int)(GetLastPosition() + Text.Length()) )
	{
		for(i=0, n=0; i<GetNumberOfLines() && n<(int)Text.Length(); i++)
		{
			n	+= 1 + GetLineLength(i);
		}

		Remove(0, n + 1);
	}

	AppendText(Text);
}
Esempio n. 23
0
void wxComboBox::SetInsertionPoint( long pos )
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );

    if ( pos == GetLastPosition() )
        pos = -1;

    GtkEntry *entry = NULL;
#ifdef __WXGTK24__
    if (!gtk_check_version(2,4,0))
        entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
    else
#endif
        entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );

    gtk_entry_set_position( entry, (int)pos );
}
SharedCaretState CompoundFormulaNode::GetPreviousPosition(SharedCaretState& relativeState)
{
	SharedCaretState res;
	
	if (!relativeState)
		res = GetLastPosition();
	else
	{
		if (relativeState->CheckInNode(this))
		{
			int i;
			FormulaNode* n;
			FormulaNode* node = relativeState->GetNode();
			if (!relativeState->CheckAtLast(this))
			{
				if (node == this)
				{
					i = relativeState->GetPos();
					n = (*this)[i == childNodes->Count() ? i - 1 : i];
					res = n->GetPreviousPosition(relativeState);
					if (res)
						return res;
				}
				else
					i = GetFirstLevelChildPos(node);
			}
			else
				i = childNodes->Count();
			
			for (int pos = i - 1; pos >= 0; --pos)
			{
				n = (*this)[pos];
				res = n->GetPreviousPosition();
				if (res)
					break;
			}
			
			if (!res)
				res = SharedCaretState(new CaretState(parent, parent->GetChildPos(this)));
		}
	}
	
	return res;
}
SharedCaretState RootFormulaNode::GetPreviousPosition(SharedCaretState& relativeState)
{
	SharedCaretState res;
	
	if (!relativeState)
		res = GetLastPosition();
	else
	{
		int i;
		FormulaNode* n;
		FormulaNode* node = relativeState->GetNode();
		if (node == this)
		{
			i = relativeState->GetPos();
			n = (*this)[i == childNodes->Count() ? i - 1 : i];
			res = n->GetPreviousPosition(relativeState);
			if (res)
				return res;
		}
		else
			i = GetFirstLevelChildPos(node);
		
		for (int pos = i - 1; pos >= 0; --pos)
		{
			n = (*this)[pos];
			res = n->GetPreviousPosition();
			if (res)
				break;
		}

		if (!res && parent)
			return parent->GetPreviousPosition(relativeState);
	}
	
	return res;
}
Esempio n. 26
0
void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
{
    event.Enable(GetLastPosition() > 0);
}
Esempio n. 27
0
void wxTextCtrl::SetInsertionPointEnd()
{
    if ( GetInsertionPoint() != GetLastPosition() )
        SetInsertionPoint(GetLastPosition());
}
Esempio n. 28
0
bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
{
    // we have a native implementation for Win32 and so don't need this one
#ifndef __WIN32__
    wxChar ch = 0;
    int keycode = event.GetKeyCode();
    switch ( keycode )
    {
        case WXK_NUMPAD0:
        case WXK_NUMPAD1:
        case WXK_NUMPAD2:
        case WXK_NUMPAD3:
        case WXK_NUMPAD4:
        case WXK_NUMPAD5:
        case WXK_NUMPAD6:
        case WXK_NUMPAD7:
        case WXK_NUMPAD8:
        case WXK_NUMPAD9:
            ch = (wxChar)(_T('0') + keycode - WXK_NUMPAD0);
            break;

        case WXK_MULTIPLY:
        case WXK_NUMPAD_MULTIPLY:
            ch = _T('*');
            break;

        case WXK_ADD:
        case WXK_NUMPAD_ADD:
            ch = _T('+');
            break;

        case WXK_SUBTRACT:
        case WXK_NUMPAD_SUBTRACT:
            ch = _T('-');
            break;

        case WXK_DECIMAL:
        case WXK_NUMPAD_DECIMAL:
            ch = _T('.');
            break;

        case WXK_DIVIDE:
        case WXK_NUMPAD_DIVIDE:
            ch = _T('/');
            break;

        case WXK_DELETE:
        case WXK_NUMPAD_DELETE:
            // delete the character at cursor
            {
                const long pos = GetInsertionPoint();
                if ( pos < GetLastPosition() )
                    Remove(pos, pos + 1);
            }
            break;

        case WXK_BACK:
            // delete the character before the cursor
            {
                const long pos = GetInsertionPoint();
                if ( pos > 0 )
                    Remove(pos - 1, pos);
            }
            break;

        default:
#if wxUSE_UNICODE
            if ( event.GetUnicodeKey() )
            {
                ch = event.GetUnicodeKey();
            }
            else
#endif
            if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
            {
                // FIXME this is not going to work for non letters...
                if ( !event.ShiftDown() )
                {
                    keycode = wxTolower(keycode);
                }

                ch = (wxChar)keycode;
            }
            else
            {
                ch = _T('\0');
            }
    }

    if ( ch )
    {
        WriteText(ch);

        return true;
    }
#else // __WIN32__
    wxUnusedVar(event);
#endif // !__WIN32__/__WIN32__

    return false;
}
Esempio n. 29
0
void wxComboBox::SelectAll()
{
    SetSelection(0, GetLastPosition());
}
Esempio n. 30
0
void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event)
{
    event.Enable(GetLastPosition() > 0);
}