Example #1
0
void TextRenderer::OnButtonPressEvent(GdkEventButton* event)
{
    if( event->type != GDK_BUTTON_PRESS || !IsLeftButton(event) )
        return;

    Point lct((int)event->x, (int)event->y);
    lct = GetTransition().DevToRel(lct);
    if( CalcTextPlc().Contains(lct) )
    {
        double x = lct.x, y = lct.y;
        {
            CairoStateSave save(caiCont);
            ApplyTextTrans();

            caiCont->device_to_user(x, y);
        }

        int idx, trail;
        utf8::trans tr(GetText());
        if( panLay->xy_to_index(pango_units_from_double(x), pango_units_from_double(y), idx, trail) )
        {
            int new_pos = tr.to_offset(idx);
            // видимо в случае "сложных" букв trail может принимать и отличные от
            // {0, 1} значения (восточные иероглифы?), но нам требуется точность до целого символа
            if( trail )
                new_pos++;

            MoveCursor( new_pos );
        }
        else
            MoveCursor( tr.length() );
    }
}
Example #2
0
void View::MouseDown(int x, int y, int info)
{
	if (!IsLeftButton(info))
		return;

	if (_selected != NULL)
		if (_selected->HitTest(x, y))
		{
			_selected->OnMouseDown(x, y, info);
			
			OnMouse(_selected->GetParamIndex(), 
				MOUSE_DOWN, 
				x - _selected->GetX(), 
				y - _selected->GetY(), info);

			if (_selected->_repaint)
				Redraw(_selected);
			return;
		}

	ControlPtr newsel = NULL;
	for (ClstPtr c = _cl.begin(); c != _cl.end(); c++)
		if ((*c)->HitTest(x, y))
		{   
			newsel = (*c);
			break;
		}

	if (newsel != _selected 
		&& _selected != NULL)
	{
		_selected->OnLostFocus();
		if (_selected->_repaint)
			Redraw(_selected);			
	}

	_selected = newsel;
	if (_selected != NULL)
	{
		_selected->OnMouseDown(x, y, info);

		OnMouse(_selected->GetParamIndex(), 
			MOUSE_DOWN, 
				x - _selected->GetX(), 
				y - _selected->GetY(), info);

		if (_selected->_repaint)
			Redraw(_selected);
	}
}
Example #3
0
void View::MouseUp(int x, int y, int info)
{
	if (_selected == NULL)
		return;

	_selected->OnMouseUp(x, y, IsLeftButton(info));

	OnMouse(_selected->GetParamIndex(), 
		MOUSE_UP, 
				x - _selected->GetX(), 
				y - _selected->GetY(), info);

	if (_selected->_repaint)
		Redraw(_selected);
	//_selected = NULL;   
}
Example #4
0
void View::MouseMove(int x, int y, int info)
{
	if (IsLeftButton(info) && _selected != NULL)
	{
		if (_selected != NULL)
		{
			_selected->OnMouseMove(x, y, info);

			OnMouse(_selected->GetParamIndex(), 
				MOUSE_MOVE, 
				x - _selected->GetX(), 
				y - _selected->GetY(), info);


			if (_selected->_repaint)
				Redraw(_selected);
		}
	}
}