[scribus-dev] Question about frame/text manipulation
Elvis Stansvik
elvstone at gmail.com
Sun Aug 14 09:02:33 UTC 2011
Hello all,
I have a bit of a conceptual question now.
As it is, during table editing, the selected item is naturally the table.
This means that to get text editing operations such as cut/copy/paste,
positioning the text cursor with the mouse, text selection et.c. to
work on cell text, all places that has code of this type:
PageItem *item = <get the selected item>
if (item->isTextFrame())
{
// Do stuff with the item text.
}
must be changed to something like:
if (item->isTextFrame())
{
// Do stuff with the item text.
}
else if (item->isTable())
{
// Get the text frame of the active cell and do stuff with its text.
}
Another thing that must be taken into account is that the text frames
of the table cells have coordinates that are relative to the table
grid, so functions that that do things like e.g:
FPoint p = m_canvas->globalToCanvas(point);
if (m_canvas->frameHitTest(p, frame))
{
// Do stuff depending on the hit point.
}
must now take care to map the point to table grid coordinates first, e.g:
FPoint p;
if (item->asTable())
{
// Map the point to table grid coordinates.
PageItem_Table* item->asTable();
p = table->getTransform().inverted().map(m_canvas->globalToCanvas(point).toQPointF())
- table->gridOffset();
}
else
{
p = m_canvas->globalToCanvas(point);
}
Now there are quite a few places that has code of this nature. At the
moment I've only modified ScribusView::slotSetCurs(), in order to get
positioning of the text cursor with the mouse to work on table cells.
There will be more places that needs modifications, and I guess that
along the way I'll make it more general so that functions that follow
this pattern can call a common function, and avoid code duplication.
I just wanted to throw this out there in case you think I'm going
about it in the wrong way, or if you have suggestions for a better
approach that will not require so many modifications to existing code.
I'll end with a more specific question: Why is the
ScribusView::slotSetCurs(...) returning true for image frames? Why
does it care about image frames at all?
I'll send a report on the work I've been doing on text editing later today.
Regards,
Elvis
More information about the scribus-dev
mailing list