Ejemplo n.º 1
0
void RichEdit::SetObjectPos(int pos)
{
	Rect r = GetObjectRect(cursor);
	Rect rr = r.Offseted(GetTextRect().left, -sb);
	objectrect = GetObjectRect(pos);
	objectpos = cursor;
	PlaceCaret();
	Refresh(rr);
	ReadFormat();
}
Ejemplo n.º 2
0
void CUIEditBox::OnMouseMove(POINT pt)
{
    if(IsPressed())
    {
        screenToClient(pt);
        // Determine the character corresponding to the coordinates.
        int nCP, nX1st;
        bool bTrail;
        m_Buffer.CPtoX(m_nFirstVisible, FALSE, nX1st);  // X offset of the 1st visible char
        if(m_Buffer.XtoCP(pt.x - m_rcText.left + nX1st, nCP, bTrail))
        {
            // Cap at the NULL character.
            if(bTrail && nCP < m_Buffer.GetTextSize())
                PlaceCaret(nCP + 1);
            else
                PlaceCaret(nCP);
        }
    }
}
Ejemplo n.º 3
0
void LineEdit::LeftRepeat(Point p, dword flags) {
	if(HasCapture()) {
		int c = GetMousePos(p);
		if(mpos != c) {
			dorectsel = flags & K_ALT;
			PlaceCaret(c, true);
			dorectsel = false;
		}
	}
}
Ejemplo n.º 4
0
void LineEdit::RightDown(Point p, dword flags)
{
	mpos = GetMousePos(p);
	SetFocus();
	int l, h;
	GetSelection(l, h);
	if(!IsAnySelection() || !(mpos >= l && mpos < h))
		PlaceCaret(mpos, false);
	MenuBar::Execute(WhenBar);
}
Ejemplo n.º 5
0
void LineEdit::LeftUp(Point p, dword flags)
{
	if(!HasCapture() && selclick && !IsDragAndDropSource()) {
		mpos = GetMousePos(p);
		PlaceCaret(mpos, flags & K_SHIFT);
		SetFocus();
	}
	selclick = false;
	ReleaseCapture();
}
Ejemplo n.º 6
0
void DocEdit::LeftUp(Point p, dword flags)
{
	if(!HasCapture() && selclick) {
		int c = GetMousePos(p);
		PlaceCaret(c, flags & K_SHIFT);
		SetFocus();
	}
	selclick = false;
	ReleaseCapture();
}
Ejemplo n.º 7
0
void DocEdit::LeftDown(Point p, dword flags) {
	SetFocus();
	int c = GetMousePos(p);
	int l, h;
	if(GetSelection(l, h) && c >= l && c < h) {
		selclick = true;
		return;
	}
	PlaceCaret(c, flags & K_SHIFT);
	SetCapture();
}
Ejemplo n.º 8
0
void LineEdit::LeftDown(Point p, dword flags) {
	mpos = GetMousePos(p);
	int l, h;
	if(GetSelection(l, h) && mpos >= l && mpos < h) {
		selclick = true;
		return;
	}
	PlaceCaret(mpos, flags & K_SHIFT);
	SetWantFocus();
	SetCapture();
}
Ejemplo n.º 9
0
void CGUITextBox::PlaceCaret(POINT _cursor){
	float dx=m_pos.x;
	float dy=m_pos.y;
	CGUIBase* p=m_pParent;
	while(p!=NULL){
		dx+=p->GetPos().x;
		dy+=p->GetPos().y;
		p=p->GetParent();
	}
	PlaceCaret((int)((float)(_cursor.x-dx-m_border-2)/(float)8+0.5f)+m_Scrollx, (int)((float)(_cursor.y-dy-m_border-2)/(float)13)+m_Scrolly);
}
Ejemplo n.º 10
0
void CUIEditBox::OnLButtonDown(POINT point)
{
    screenToClient(point);
    SetFocus();
    SetPressed(true);
    //SetCapture(UIGetHWND());
    // Determine the character corresponding to the coordinates.
    int nCP, nX1st;
    bool bTrail;
    m_Buffer.CPtoX(m_nFirstVisible, FALSE, nX1st);  // X offset of the 1st visible char
    if(m_Buffer.XtoCP(point.x - m_rcText.left + nX1st, nCP, bTrail))
    {
        // Cap at the NULL character.
        if(bTrail && nCP < m_Buffer.GetTextSize())
            PlaceCaret(nCP + 1);
        else
            PlaceCaret(nCP);
        m_nSelStart = m_nCaret;
        ResetCaretBlink();
    }
}
Ejemplo n.º 11
0
void LineEdit::DeleteLine()
{
	int b, e;
	if(GetSelection(b, e) && GetLine(b) != GetLine(e)) {
		RemoveSelection();
		return;
	}
	int i = GetLine(cursor);
	int p = GetPos(i);
	Remove(p, line[i].GetLength() + 1);
	PlaceCaret(p);
	Action();
}
Ejemplo n.º 12
0
void LineEdit::LeftDown(Point p, dword flags) {
	mpos = GetMousePos(p);
	int l, h;
	if(GetSelection(l, h) && mpos >= l && mpos < h) {
		selclick = true;
		return;
	}
	dorectsel = flags & K_ALT;
	PlaceCaret(mpos, (flags & K_SHIFT) || dorectsel);
	dorectsel = false;
	SetFocus();
	SetCapture();
}
Ejemplo n.º 13
0
void CUIEditBox::DeleteSelectionText()
{
    int nFirst = __min(m_nCaret, m_nSelStart);
    int nLast = __max(m_nCaret, m_nSelStart);
    // Update caret and selection
    PlaceCaret(nFirst);
    m_nSelStart = m_nCaret;
    // Remove the characters
    if (m_bPassword)
    {
        m_wstrPassword.erase(nFirst,nLast-nFirst);
    }
    m_Buffer.RemoveChar(nFirst,nLast-nFirst);
}
Ejemplo n.º 14
0
void DocEdit::VertMove(int delta, bool select, bool scs) {
	int hy = GetY(para.GetCount());
	Point p = GetCaret(cursor);
	int yy = p.y;
	for(;;) {
		p.y += delta;
		if(p.y > hy) p.y = hy - 1;
		if(p.y < 0) p.y = 0;
		int q = GetCursorPos(p);
		if(q >= 0 && q != cursor && (delta < 0) == (q < cursor) && GetCaret(q).y != yy) {
			PlaceCaret(q, select);
			break;
		}
		if(p.y == 0 || p.y >= hy - 1) {
			PlaceCaret(delta > 0 ? total : 0, select);
			break;
		}
		delta = sgn(delta) * 4;
	}
	if(scs)
		sb = GetCaret(cursor).y - (yy - sb);
	PlaceCaret(true);
}
Ejemplo n.º 15
0
void CUIEditBox::SetText(const wchar_t* wcsText, bool bSelected)
{
    if (m_bPassword)
    {
        m_wstrPassword = wcsText;
        std::wstring wstrPassword(m_wstrPassword.length(),L'*');
        m_Buffer.SetText(wstrPassword.c_str());
    }
    else
    {
        m_Buffer.SetText(wcsText);
    }
    m_nFirstVisible = 0;
    // Move the caret to the end of the text
    PlaceCaret(m_Buffer.GetTextSize());
    m_nSelStart = bSelected ? 0 : m_nCaret;
}
Ejemplo n.º 16
0
void CGUITextBox::AddLine(std::wstring _text){
	if(m_Text.size()==1 && m_Text[0]==L"")
		m_Text[0]=_text;
	else{
		m_MaxCarety++;
		if(m_pVSB!=NULL && m_MaxCarety>=((int)(m_height/13)))
			m_pVSB->SetMaxValue(m_pVSB->GetMaxValue()+1);
		m_Text.push_back(_text);

		if(m_MaxCarety>=((int)(m_height/13))){
			m_Scrolly++;
			if(m_pVSB!=NULL)
				m_pVSB->SetValue(m_Scrolly);
		}
	}
	PlaceCaret(m_Text[m_MaxCarety].length(),m_MaxCarety);
	SyncSelStart();
}
Ejemplo n.º 17
0
int LineEdit::PasteRectSelection(const WString& s)
{
	Vector<WString> cl = Split(s, '\n', false);
	Rect rect = GetRectSelection();
	int pos = cursor;
	int n = 0;
	for(int i = 0; i < cl.GetCount() && rect.top + i <= rect.bottom; i++) {
		int l, h;
		CacheLinePos(i);
		GetRectSelection(rect, i + rect.top, l, h);
		Remove(l, h - l);
		int nn = Insert(l, cl[i]);
		n += nn;
		pos = l + nn;
	}
	PlaceCaret(pos);
	return n;
}
Ejemplo n.º 18
0
void DocEdit::PlaceCaret(int newpos, bool select) {
	if(newpos > GetLength())
		newpos = GetLength();
	int z = GetLine(newpos);
	if(select) {
		if(anchor < 0) {
			anchor = cursor;
		}
		RefreshLines(z, GetLine(cursor));
	}
	else
		if(anchor >= 0) {
			RefreshLines(GetLine(cursor), GetLine(anchor));
			anchor = -1;
		}
	cursor = newpos;
	PlaceCaret(true);
	SelectionChanged();
	if(IsSelection())
		SetSelectionSource(ClipFmtsText());
}
Ejemplo n.º 19
0
void LineEdit::PasteColumn(const WString& text)
{
	Vector<WString> cl = Split(text, '\n', false);
	if(cl.GetCount() && cl.Top().IsEmpty())
		cl.Drop();
	if(cl.GetCount() == 0)
		return;
	int pos;
	if(IsRectSelection()) {
		Rect t = GetRectSelection();
		RemoveSelection();
		Point p = t.TopLeft();
		pos = cursor;
		for(int i = 0; i < t.bottom - t.top + 1; i++) {
			CacheLinePos(i + p.y);
			int l = GetGPos(i + p.y, p.x);
			pos = l + Insert(l, cl[i % cl.GetCount()]);
		}
	}
	else {
		RemoveSelection();
		Point p = GetColumnLine(cursor);
		pos = cursor;
		for(int i = 0; i < cl.GetCount(); i++) {
			CacheLinePos(i + p.y);
			int li = p.y + i;
			if(li < line.GetCount()) {
				int l = GetGPos(i + p.y, p.x);
				pos = l + Insert(l, cl[i]);
			}
			else {
				Insert(GetLength(), cl[i] + "\n");
				pos = GetLength();
			}
		}
	}
	PlaceCaret(pos);
}
Ejemplo n.º 20
0
void CGUITextBox::Step(){
	if(m_CaretBlink>0)
		m_CaretBlink--;
	else{
		m_CaretBlink=30;
		m_bCaretOn=!m_bCaretOn;
	}
	if(m_bButtonDown)
		PlaceCaret(m_MousePos);
	if(m_pVSB!=NULL){
		m_pVSB->Step();
		if(m_Scrolly!=(int)m_pVSB->GetValue()){
			m_Scrolly=(int)m_pVSB->GetValue();
			SetTextDraw();
		}
	}
	if(m_pHSB!=NULL){
		m_pHSB->Step();
		if(m_Scrollx!=(int)m_pHSB->GetValue()){
			m_Scrollx=(int)m_pHSB->GetValue();
			SetTextDraw();
		}
	}
}
Ejemplo n.º 21
0
bool LineEdit::InsertChar(dword key, int count, bool canow) {
	if(key == K_TAB && !processtab)
		return false;
	if(filter && key >= 32 && key < 65535)
		key = (*filter)(key);
	if(!IsReadOnly() && (key >= 32 && key < 65536 || key == '\t' || key == '\n' ||
	   key == K_ENTER && processenter || key == K_SHIFT_SPACE)) {
		if(key >= 128 && key < 65536 && (charset != CHARSET_UNICODE && charset != CHARSET_UTF8_BOM)
		   && FromUnicode((wchar)key, charset) == DEFAULTCHAR)
			return true;
		if(!RemoveSelection() && overwrite && key != '\n' && key != K_ENTER && canow) {
			int q = cursor;
			int i = GetLinePos(q);
			if(q + count - 1 < GetLineLength(i))
				Remove(cursor, count);
		}
		WString text(key == K_ENTER ? '\n' : key == K_SHIFT_SPACE ? ' ' : key, count);
		Insert(cursor, text, true);
		PlaceCaret(cursor + count);
		Action();
		return true;
	}
	return false;
}
Ejemplo n.º 22
0
bool LineEdit::Key(dword key, int count) {
	NextUndo();
	switch(key) {
	case K_CTRL_UP:
		ScrollUp();
		return true;
	case K_CTRL_DOWN:
		ScrollDown();
		return true;
	case K_INSERT:
		OverWriteMode(!IsOverWriteMode());
		break;
	}
	bool sel = key & K_SHIFT;
	switch(key & ~K_SHIFT) {
	case K_CTRL_LEFT:
		{
			PlaceCaret(GetPrevWord(cursor), sel);
			break;
		}
	case K_CTRL_RIGHT:
		{
			PlaceCaret(GetNextWord(cursor), sel);
			break;
		}
	case K_LEFT:
		MoveLeft(sel);
		break;
	case K_RIGHT:
		MoveRight(sel);
		break;
	case K_HOME:
		MoveHome(sel);
		break;
	case K_END:
		MoveEnd(sel);
		break;
	case K_UP:
		MoveUp(sel);
		break;
	case K_DOWN:
		MoveDown(sel);
		break;
	case K_PAGEUP:
		MovePageUp(sel);
		break;
	case K_PAGEDOWN:
		MovePageDown(sel);
		break;
	case K_CTRL_PAGEUP:
	case K_CTRL_HOME:
		MoveTextBegin(sel);
		break;
	case K_CTRL_PAGEDOWN:
	case K_CTRL_END:
		MoveTextEnd(sel);
		break;
	case K_CTRL_C:
	case K_CTRL_INSERT:
		Copy();
		break;
	case K_CTRL_A:
		SelectAll();
		break;
	default:
		if(IsReadOnly())
			return MenuBar::Scan(WhenBar, key);
		switch(key) {
		case K_DELETE:
			DeleteChar();
			break;
		case K_BACKSPACE:
		case K_SHIFT|K_BACKSPACE:
			Backspace();
			break;
	   	case K_SHIFT_TAB:
			AlignChar();
			break;
		case K_CTRL_Y:
		case K_CTRL_L:
			if(cutline) {
				CutLine();
				break;
			}
		default:
			if(InsertChar(key, count, true))
				return true;
			return MenuBar::Scan(WhenBar, key);
		}
		return true;
	}
	Sync();
	return true;
}
Ejemplo n.º 23
0
void LineEdit::MoveTextEnd(bool sel) {
	PlaceCaret(total, sel);
}
Ejemplo n.º 24
0
void LineEdit::MoveTextBegin(bool sel) {
	PlaceCaret(0, sel);
}
Ejemplo n.º 25
0
void LineEdit::MoveEnd(bool sel) {
	int i = GetLine(cursor);
	PlaceCaret(GetPos(i, line[i].GetLength()), sel);
}
Ejemplo n.º 26
0
void LineEdit::MoveRight(bool sel) {
	if(cursor < total)
		PlaceCaret(cursor + 1, sel);
}
Ejemplo n.º 27
0
void LineEdit::MoveLeft(bool sel) {
	if(cursor)
		PlaceCaret(cursor - 1, sel);
}
Ejemplo n.º 28
0
void LineEdit::MouseMove(Point p, dword flags) {
	if((flags & K_MOUSELEFT) && HasFocus() && HasCapture()) {
		int c = GetMousePos(p);
		PlaceCaret(c, mpos != c || HasCapture());
	}
}
Ejemplo n.º 29
0
void DocEdit::Invalidate()
{
	for(int i = 0; i < para.GetCount(); i++)
		para[i].cx = -1;
	PlaceCaret(false);
}
Ejemplo n.º 30
0
void DocEdit::Scroll()
{
	PlaceCaret(false);
	Refresh();
}