• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

Public Types | Public Member Functions | Static Public Member Functions | List of all members
KWordWrap Class Reference

#include <kwordwrap.h>

Public Types

enum  { FadeOut = 0x10000000 , Truncate = 0x20000000 }
 

Public Member Functions

TQRect boundingRect () const
 
TQString wrappedString () const
 
TQString truncatedString (bool dots=true) const
 
void drawText (TQPainter *painter, int x, int y, int flags=TQt::AlignAuto) const
 
 ~KWordWrap ()
 

Static Public Member Functions

static KWordWrap * formatText (TQFontMetrics &fm, const TQRect &r, int flags, const TQString &str, int len=-1)
 
static void drawFadeoutText (TQPainter *p, int x, int y, int maxW, const TQString &t)
 
static void drawTruncateText (TQPainter *p, int x, int y, int maxW, const TQString &t)
 

Detailed Description

Word-wrap algorithm that takes into account beautifulness ;)

That means:

  • not letting a letter alone on the last line,
  • breaking at punctuation signs (not only at spaces)
  • improved handling of (), [] and {}
  • improved handling of '/' (e.g. for paths)

Usage: call the static method, formatText, with the text to wrap and the constraining rectangle etc., it will return an instance of KWordWrap containing internal data, result of the word-wrapping. From that instance you can retrieve the boundingRect, and invoke drawing.

This design allows to call the word-wrap algorithm only when the text changes and not every time we want to know the bounding rect or draw the text.

Author
David Faure faure.nosp@m.@kde.nosp@m..org

Definition at line 48 of file kwordwrap.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Use this flag in drawText() if you want to fade out the text if it does not fit into the constraining rectangle.

Since
3.2

Definition at line 56 of file kwordwrap.h.

Constructor & Destructor Documentation

◆ ~KWordWrap()

KWordWrap::~KWordWrap ( )

Destructor.

Definition at line 144 of file kwordwrap.cpp.

Member Function Documentation

◆ boundingRect()

TQRect KWordWrap::boundingRect ( ) const
inline
Returns
the bounding rect, calculated by formatText. The width is the width of the widest text line, and never wider than the rectangle given to formatText. The height is the text block. X and Y are always 0.

Definition at line 77 of file kwordwrap.h.

◆ drawFadeoutText()

void KWordWrap::drawFadeoutText ( TQPainter *  p,
int  x,
int  y,
int  maxW,
const TQString &  t 
)
static

Draws the string t at the given coordinates, if it does not fit into maxW the text will be faded out.

Parameters
pthe painter to use. Must have set the pen for the text color and the background for the color to fade out
xthe horizontal position of the text
ythe vertical position of the text
maxWthe maximum width of the text (including the fade-out effect)
tthe text to draw
Since
3.2

Definition at line 181 of file kwordwrap.cpp.

◆ drawText()

void KWordWrap::drawText ( TQPainter *  painter,
int  x,
int  y,
int  flags = TQt::AlignAuto 
) const

Draw the text that has been previously wrapped, at position x,y.

Flags are for alignment, e.g. TQt::AlignHCenter. Default is TQt::AlignAuto.

Parameters
painterthe TQPainter to use.
xthe horizontal position of the text
ythe vertical position of the text
flagsthe ORed text alignment flags from the Qt namespace, ORed with FadeOut if you want the text to fade out if it does not fit (the painter's background must be set accordingly)

Definition at line 219 of file kwordwrap.cpp.

◆ drawTruncateText()

void KWordWrap::drawTruncateText ( TQPainter *  p,
int  x,
int  y,
int  maxW,
const TQString &  t 
)
static

Draws the string t at the given coordinates, if it does not fit into maxW the text will be truncated.

Parameters
pthe painter to use
xthe horizontal position of the text
ythe vertical position of the text
maxWthe maximum width of the text (including the '...')
tthe text to draw
Since
3.3

Definition at line 213 of file kwordwrap.cpp.

◆ formatText()

KWordWrap * KWordWrap::formatText ( TQFontMetrics &  fm,
const TQRect &  r,
int  flags,
const TQString &  str,
int  len = -1 
)
static

Main method for wrapping text.

Parameters
fmFont metrics, for the chosen font. Better cache it, creating a TQFontMetrics is expensive.
rConstraining rectangle. Only the width and height matter. With negative height the complete text will be rendered
flagscurrently unused
strThe text to be wrapped.
lenLength of text to wrap (default is -1 for all).
Returns
a KWordWrap instance. The caller is responsible for storing and deleting the result.

Definition at line 34 of file kwordwrap.cpp.

◆ truncatedString()

TQString KWordWrap::truncatedString ( bool  dots = true) const
Returns
the original string, truncated to the first line. If dots was set, '...' is appended in case the string was truncated. Bug: Note that the '...' come out of the bounding rect.

Definition at line 164 of file kwordwrap.cpp.

◆ wrappedString()

TQString KWordWrap::wrappedString ( ) const
Returns
the original string, with '
' inserted where the text is broken by the wordwrap algorithm.

Definition at line 148 of file kwordwrap.cpp.


The documentation for this class was generated from the following files:
  • kwordwrap.h
  • kwordwrap.cpp

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.