Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

oofTextSizer Class Reference
[Macintosh Report renderingMS Windows Report rendering]

#include <oofdraw.h>

List of all members.


Detailed Description

Cross-platform sizer which wraps to multiple rows.


Public Member Functions

 oofTextSizer ()
virtual ~oofTextSizer ()
virtual void CalculateWrapping (const char *inValue, unsigned long inItemSize, unsigned long inColWidth, bool inTruncWords=true)
 Produce two arrays of line start (offset of character from start of string) and line length (pixels).

virtual void describe (std::ostream &) const
const unsigned long * GetLineStarts () const
const unsigned long * GetLineLengths () const
unsigned short GetNumRows () const

Protected Member Functions

void StoreLineStart (unsigned long inLineStart)
void StoreLineLength (unsigned long inLineStart)
void SkipWhiteForward (const char *inValue, unsigned long &ioWordStart, unsigned long &ioCharsLeft) const
unsigned long TruncateTrailingWord (const char *inValue, unsigned long inEndWord, unsigned long &outNextWordStart) const


Constructor & Destructor Documentation

oofTextSizer::oofTextSizer  ) 
 

oofTextSizer::~oofTextSizer  )  [virtual]
 


Member Function Documentation

void oofTextSizer::CalculateWrapping const char *  inValue,
unsigned long  inItemSize,
unsigned long  inColWidth,
bool  inWillTruncWords = true
[virtual]
 

Produce two arrays of line start (offset of character from start of string) and line length (pixels).

Each line is terminated at an embedded CR or LF (CRLF counts as one break) or wraps at the nearest word boundary. Word gaps detected as spaces and tabs.

Line separator characters (CR etc) are skipped by adjustment of the line start positions. An empty line will create an entry with a length of 0 and a line start of the terminator.

Calling StoreLineStart will expand both arrays as suited, it must therefore be called first. This updates the mNumRows member which is used (via GetNumRows()) by all clients.

Note that each time we start a line we must re-measure it as proportional fonts will vary width depending on context. We avoid remeasuring to the end of a very large block by making an assumption that a line will exceed a threshold of 500 characters in a single line. (kMaxCharsInSingleLine defined below)

We also pre-scan for terminators as it is more likely that typical text will have lines much shorter than kMaxCharsInSingleLine.

Todo:
Could make it smarter when we have to wrap inside a terminator by looping up until that terminator rather than going to the top of the main loop again.
MAIN ALGORITHM Repeat if starts with terminator skip terminator make entry for blank line else pre-scan forward for line terminators, up to kMaxCharsInSingleLine if no terminators in this limit, measure up to kMaxCharsInSingleLine else measure up to terminator scan array of sizes to see if fits in fixed line length (pixels, not number of chars) if line too long scan backwards from stopping point to first word break finish line entry

void oofTextSizer::describe std::ostream &   )  const [virtual]
 

const unsigned long * oofTextSizer::GetLineLengths  )  const [inline]
 

const unsigned long * oofTextSizer::GetLineStarts  )  const [inline]
 

unsigned short oofTextSizer::GetNumRows  )  const [inline]
 

void oofTextSizer::SkipWhiteForward const char *  inValue,
unsigned long &  ioWordStart,
unsigned long &  ioCharsLeft
const [protected]
 

void oofTextSizer::StoreLineLength unsigned long  inLineStart  )  [protected]
 

void oofTextSizer::StoreLineStart unsigned long  inLineStart  )  [protected]
 

unsigned long oofTextSizer::TruncateTrailingWord const char *  inValue,
unsigned long  inEndWord,
unsigned long &  outNextWordStart
const [protected]
 


The documentation for this class was generated from the following files:
Generated on Thu Jan 1 22:06:53 2004 for OOFILE by doxygen 1.3.5