PartitioningTextImager
is based on the idea that a entire text buffer can be layed out
by first breaking the text into special chunks, and then laying out those chunks.
We use Marker
s (or more specificly Partition::PartitionMarker
) to delimit
the chunks (refered to as partition elements).
Note that it doesn't really matter much what the rule is for breaking text into chunks, except that the rule should be chosen to make the drawing of those chunks easier, and to fit in well with logical clipping.
So for example, the most common rule for breaking text into partitions would be to look for LF chraracters, and consider each "line" to be a separate partition element.
Partition [public]
virtual MarkerOwner
PartitioningTextImager is a TextImager which implements imaging by partitioning the text into stable regions, called Partitions.
A partition is logically very similar to a MarkerCover
. But we
don't directly use that class because it is not an abstract class, but rather a utility template. And that utility
has very different performance considerations than we require. Also, that class is used to associate a MARKERINFO
with a particular partition element. There is nothing we here associate with the partition element.
For more information, see DesignManual/TextImagers.html (NB: This code has changed ALOT between Led 2.2 and 2.3, and so this doc really needs to be rewritten!).
Member Details |
---|
Wrap |
Associate the given |
Coalece the given PartitionMarker with the one which follows it (if any exists). If coalesced
with the following element, the given 'pm' is deleted. Frequently this doesn't happen immediately (mainly
for performance reasons, but possibly also to avoid bugs where the marker is still in some list being iterated over
and having DidUpdate() etc methods called on it). It is accumulated for later deletion using
This method is typically called by Partition subclasses override of Partition::UpdatePartitions. |
Calls the associated |
Logically this should be part of the constructor. But since it needs to call a method (Partition::MakeNewPartitionMarker ()) which is virtual, and must be bound in the final complete class. So it must be done as a separate call. It is illegal to call this more than once, or to call any of the other class methods without having called it. These errors will be detected (in debug builds) where possible. |
Return the associated |
Finds the PartitioningTextImager::PartitionMarker which contains the given character#. Note, the use of 'charPosition' rather than markerpos is to disambiguiate the case where we are at the boundary between two partition elements. |
Method which is called to construct new partition elements. Override this if you subclass
|
Remove the given |
Split the given PartitionMarker at position 'at' - which must fall within the partition element. This method always produces a new partition element, and inserts it appropriately into the partition, adjusting the sizes of surrounding elements appropriately. This method is typically called by Partition subclasses override of Partition::UpdatePartitions. |
Partition::PartitionMarker [public]
Marker
This class is the building block of a partition. It is used to keep track of a single partition element.
Subclassing Caution: Since we provide operator new/delete overrides, you must be careful building any subclasses which have a different size than this class. You must provide your own overrides of operator new/delete todo so.
Member Details |
---|
Return a reference to the partition markers owner. Note - since this returns a refernece, we assert that the owner is non-null. Also note that this routine intentionally hides the base-class Marker::GetOwner() method. Use that if the owner could be NULL. But note that the owner will never be NULL if the marker has been added (and not yet removed) from the TextStore. |
Partition::PartitionWatcher [public]
Some programs may need to keep track of when a partition changes. For example, an Imager will likely want to redisplay
itself. Perhaps even do some more elaborate computation. Things like paragraph-based marker-covers (MarkerCover
)
may need to adjust their boundaries to correspond to the new paragraph boundaries
(e.g. WordProcessor::ParagraphDatabaseRep
).
You get notified just before, and after partition markers are split, and/or coalesced. The untyped 'info' records are used to pass arbitrary bits of info from the 'about' call to the 'did' call.
PartitioningTextImager [public]
virtual TextImager
PartitioningTextImager is a TextImager which implements imaging by partitioning the text into stable regions, called Partitions.
For more information, see DesignManual/TextImagers.html.
Member Details |
---|
This is typically called from PartitioningTextImager::CalcSegmentSize, which first grabs the text
from the buffer, and then measures the text width. And it does the same thing, except that this routine is optimized
so it doesn't lookup the text, and requires you to pass it in (avoids extra copying out of text from This routine was renamed from and overloaded PartitioningTextImager::CalcSegmentSize between Led 2.2 and Led 2.3. |
Simple wrapper on |
Finds the PartitioningTextImager::PartitionMarker which contains the given character#. Note, the use of 'charPosition' rather than markerpos is to disambiguiate the case where we are at the boundary between two partition elements. |
Simple wrapper on |
Patch the charLocations for tab-stop locations, now that we know our previous wrap point. Returns index of last tab found (allows for optimizations). Returns a number <= from if no tabs found. 'from' defines where in the 'textStore' all these things are being measured relative to (typically the start of a partition). 'text' is the text starting in the partition at position 'from', and extending 'nTChars' Led_tChars in length. 'charLocations' is a vector - of the widths, measured from TextImager::MeasureSegmentWidth. As such, it measures distances from 'from' to a position 'i' after from, with the distance of from..from being implied zero, so the first elt of the array left out (in other words to find distance from..i, you say charLocations[i-from-1]). 'startSoFar' is an arg so you can only reset the tabstops for a given subset of the text - ignoring the initial portion. So, if startSoFar==0, then it is assumed we are starting at the beginning of the charLocations array, but if startSoFar != 0, we assume we can (and must) snag our starting width from what is already in the array at charLocations[startSoFar-1]. |
Associates the given parition (PartitionPtr) with this The method is virtual, in case you need to hook partition changes by updating other derived/cached information. But if overridding, be sure to always call the inherited version. |