Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQDirectPainter Class Reference

The TQDirectPainter class provides direct access to the video hardware. More...

`#include <qdirectpainter_qws.h>`

Inherits TQPainter.

List of all member functions.

## Public Members

- TQDirectPainter ( const TQWidget * w )
- ~TQDirectPainter ()
- uchar * frameBuffer ()
- int lineStep ()
- int transformOrientation ()
- int numRects () const
- const TQRect & rect ( int i ) const
- TQRegion region () const
- int depth () const
- int width () const
- int height () const
- int xOffset () const
- int yOffset () const
- TQPoint offset () const
- TQSize size () const
- void setAreaChanged ( const TQRect & r )

## Detailed Description

The TQDirectPainter class provides direct access to the video hardware.

Only available in TQt/Embedded.

When the hardware is known and well defined, as is often the case with software for embedded devices, it may be useful to manipulate the underlying video hardware directly. In order to do this in a way that is co-operative with other applications, you must lock the video hardware for exclusive use for a small time while you write to it, and you must know the clipping region which is allocated to a widget.

TQDirectPainter provides this functionality.

In the simplest case, you make a TQDirectPainter on a widget and then, observing the clip region, perform some platform-specific operation. For example:

            void MyWidget::updatePlatformGraphics()
            {
                TQDirectPainter dp( this );
                for ( int i = 0; i < dp.numRects; i++ ) {
                    const TQRect& clip = dp.rect(i);
                    ... // platform specific operation
                }
            }

The platform-specific code has access to the display, but should only modify graphics in the rectangles specified by numRects() and rect(). Note that these rectangles are relative to the entire display.

The offset() function returns the position of the widget relative to the entire display, allowing you to offset platform-specific operations appropriately. The xOffset() and yOffset() functions merely return the component values of offset().

For simple frame-buffer hardware, the frameBuffer(), lineStep(), and depth() functions provide basic access, though some hardware configurations are insufficiently specified by such simple parameters.

Note that while a TQDirectPainter exists, the entire TQt/Embedded window system is locked from use by other applications. Always construct the TQDirectPainter as an auto (stack) variable, and be very careful to write robust and stable code within its scope.

See also Graphics Classes.

## Member Function Documentation

### TQDirectPainter::TQDirectPainter ( const TQWidget * w )

Construct a direct painter on w. The display is locked and the mouse cursor is hidden if it is above w.

### TQDirectPainter::~TQDirectPainter ()

Destroys the direct painter. The mouse cursor is revealed if necessary and the display is unlocked.

### int TQDirectPainter::depth () const

Returns the bit-depth of the display.

### uchar * TQDirectPainter::frameBuffer ()

Returns a pointer to the framebuffer memory if available.

### int TQDirectPainter::height () const

Returns the height of the widget drawn upon.

### int TQDirectPainter::lineStep ()

Returns the spacing in bytes from one framebuffer line to the next.

### int TQDirectPainter::numRects () const

Returns the number of rectangles in the drawable region.

See also rect() and region().

### TQPoint TQDirectPainter::offset () const

Returns the position of the widget relative to the entire display.

### const TQRect & TQDirectPainter::rect ( int i ) const

Returns a reference to rectangle i of the drawable region. Valid values for i are 0..numRects()-1.

See also region().

### TQRegion TQDirectPainter::region () const

Returns the region of the framebuffer which represents the exposed area of the widget being painted on. Note that this may be a sub-area of the clip region, because of child widgets and overlapping cousin widgets.

See also numRects() and rect().

### void TQDirectPainter::setAreaChanged ( const TQRect & r )

Sets the area changed by the transaction to r. By default, the entire widget is assumed to have changed. The area changed is only used by some graphics drivers, so often calling this function for a smaller area will make no difference to performance.

### TQSize TQDirectPainter::size () const

Returns the size of the widget drawn upon.

See also width() and height().

### int TQDirectPainter::transformOrientation ()

Returns a number that signifies the orientation of the framebuffer.

0 | no rotation
1 | 90 degrees rotation
2 | 180 degrees rotation
3 | 270 degrees rotation

### int TQDirectPainter::width () const

Returns the width of the widget drawn upon.

### int TQDirectPainter::xOffset () const

Returns the X-position of the widget relative to the entire display.

### int TQDirectPainter::yOffset () const

Returns the Y-position of the widget relative to the entire display.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.