Qt:Документация 4.3.2/qscreen

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QScreen Class Reference
[модуль QtGui ]

The QScreen class is a base class for screen drivers in Qtopia Core. Далее...

 #include <QScreen>

[править] Открытые типы

[править] Открытые функции

[править] Статические открытые члены

[править] Защищенные функции


[править] Подробное описание

The QScreen class is a base class for screen drivers in Qtopia Core.

Note that this class is only available in Qtopia Core.

Qtopia Core provides ready-made drivers for several screen protocols, see the display management documentation for details. Custom screen drivers can be implemented by subclassing the QScreen class and creating a screen driver plugin (derived from QScreenDriverPlugin). Qtopia Core's implementation of the QScreenDriverFactory class will automatically detect the plugin, and load the driver into the server application at runtime using Qt's plugin system.

When rendering, Qtopia Core's default behavior is for each client to render its widgets as well as its decorations into memory, while the server copies the memory content to the device's framebuffer using the screen driver. See the Qtopia Core Architecture overview for details (note that it is possible for the clients to manipulate and control the underlying hardware directly as well).

Starting with Qtopia Core 4.2, it is also possible to add an accelerated graphics driver to take advantage of available hardware resources. See the Adding an Accelerated Graphics Driver in Qtopia Core documentation for details.

[править] Framebuffer Management

When a Qtopia Core application starts running, it calls the screen driver's connect() function to map into the framebuffer and the accelerated drivers that the graphics card control registers. Note that if the application acts as the server, the application will call the initDevice() function prior to the connect() function, to initialize the framebuffer. The initDevice() function can be reimplemented to set up the graphics card (note that the default implementation does nothing).

Likewise, just before a Qtopia Core application exits, it calls the screen driver's disconnect() function. The server application will in addition call the shutdownDevice() function before it calls disconnect(). Note that the default implementation of the shutdownDevice() function only hides the mouse cursor.

QScreen also provides the save() and restore() functions, making it possible to save and restore the state of the graphics card. Note that the default implementations do nothing. Hardware screen drivers should reimplement these functions to save (and restore) its registers, enabling swintching between virtual consoles.

In additon, you can use the base() function to retrieve a pointer to the beginning of the framebuffer, and the region() function to retrieve the framebuffer's region. Use the onCard() function to determine whether the framebuffer is within the graphics card's memory, and the totalSize() function to determine the size of the available graphics card memory (including the screen). Finally, you can use the offset() function to retrieve the offset between the framebuffer's coordinates and the application's coordinate system.

[править] Palette Management

QScreen provides several functions to retrieve information about the color palette: The clut() function returns a pointer to the color lookup table (i.e. its color palette). Use the numCols() function to determine the number of entries in this table, and the alloc() function to retrieve the palette index of the color that is the closest match to a given RGB value.

To determine if the screen driver supports a given color depth, use the supportsDepth() function that returns true of the specified depth is supported.

[править] Drawing on Screen

When a screen update is required, the Qtopia Core server runs through all the top-level windows that intersect with the region that is about to be updated, and ensures that the associated clients have updated their memory buffer. Then the server calls the exposeRegion() function that composes the window surfaces and copies the content of memory to screen by calling the blit() and solidFill() functions.

The blit() function copies a given region in a given image to a specified point using device coordinates, while the solidFill() function fills the given region of the screen with the specified color. Note that normally there is no need to call either of these functions explicitly.

In addition, QScreen provides the blank() function that can be reimplemented to prevent any contents from being displayed on the screen, and the setDirty() function that can be reimplemented to indicate that a given rectangle of the screen has been altered. Note that the default implementations of these functions do nothing.

Reimplement the the mapFromDevice() and mapToDevice() functions to map objects from the framebuffer coordinate system to the coordinate space used by the application, and vice versa. Be aware that the default implementations simply return the given objects as they are.

[править] Свойства

Property Функции
Size The size of the screen can be retrieved using the screenSize() function. The size is returned in bytes.

The framebuffer's logical width and height can be retrieved using width() and height(), respectively. These functions return values are given in pixels. Alternatively, the physicalWidth() and physicalHeight() function returns the same metrics in millimeters. QScreen also provides the deviceWidth() and deviceHeight() functions returning the physical width and height of the device in pixels. Note that the latter metrics can differ from the ones used if the display is centered within the framebuffer.

Resolution Reimplement the setMode() function to be able to set the framebuffer to a new resolution (width and height) and bit depth.

The current depth of the framebuffer can be always be retrieved using the depth() function. Use the pixmapDepth() function to obtain the preferred depth for pixmaps.

Pixmap Alignment Use the pixmapOffsetAlignment() function to retrieve the value to which the start address of pixmaps held in the graphics card's memory, should be aligned.

Use the pixmapLinestepAlignment() to retrieve the value to which the individual scanlines of pixmaps should be aligned.

Image Display The isInterlaced() function tells whether the screen is displaying images progressively, and the isTransformed() function whether it is rotated. The transformOrientation() function can be reimplemented to return the current rotation.
Scanlines Use the linestep() function to retrieve the length of each scanline of the framebuffer.
Pixel Type The pixelType() function returns the screen's pixel storage format as described by the PixelType enum.

See also QScreenDriverPlugin, QScreenDriverFactory, and Qtopia Core Display Management.


[править] Описание типов

[править]
enum QScreen::PixelType

This enum describes the pixel storage format of the screen, i.e. the order of the red (R), green (G) and blue (B) components of a pixel.


Константа Значение Описание
QScreen::NormalPixel 0 Red-green-blue (RGB)
QScreen::BGRPixel 1 Blue-green-red (BGR)

See also pixelType().


[править] Описание функций-членов

[править]
QScreen::QScreen ( int displayId )

Constructs a new screen driver.

The displayId identifies the Qtopia Core server to connect to.

[править]
QScreen::~QScreen () [virtual]

Destroys this screen driver.

[править]
int QScreen::alloc ( unsigned int red, unsigned int green, unsigned int blue ) [virtual]

Returns the index in the screen's palette which is the closest match to the given RGB value (red, green, blue).

Note that this function only apply in paletted modes like 8-bit, i.e. in modes where only the palette indexes (and not the actual color values) are stored in memory.

See also clut() and numCols().

[править]
uchar * QScreen::base () const

Returns a pointer to the beginning of the framebuffer.

See also onCard(), region(), and totalSize().

[править]
void QScreen::blank ( bool on ) [virtual]

Prevents the screen driver form displaying any content on the screen.

Note that the default implementation does nothing.

Reimplement this function to prevent the screen driver from displaying any contents on the screen if on is true; otherwise the contents is expected to be shown.

See also blit().

[править]
void QScreen::blit ( const QImage & image, const QPoint & topLeft, const QRegion & region ) [virtual]

Copies the given region in the given image to the point specified by topLeft using device coordinates.

This function is called from the exposeRegion() function; it is not intended to be called explicitly.

Reimplement this function to make use of accelerated hardware. Note that this function must be reimplemented if the framebuffer format is not supported by Qtopia Core (See the Display Management documentation for more details).

See also exposeRegion(), solidFill(), and blank().

[править]
QRgb * QScreen::clut ()

Returns a pointer to the screen's color lookup table (i.e. its color palette).

Note that this function only apply in paletted modes like 8-bit, i.e. in modes where only the palette indexes (and not the actual color values) are stored in memory.

See also alloc(), depth(), and numCols().

[править]
bool QScreen::connect ( const QString & displaySpec ) [pure virtual]

This function is called by every Qtopia Core application on startup, and must be implemented to map in the framebuffer and the accelerated drivers that the graphics card control registers. Note that it is called before the initDevice() function.

Ensure that the function returns true if a connection to the screen device can be made; otherwise return false.

The displaySpec argument is passed by the QWS_DISPLAY environment variable or the -display command line parameter, and has the following syntax:

 [screen driver][:driver specific options][:display number]

For example, to use the mach64 driver on fb1 as display 2:

 Mach64:/dev/fb1:2

See Qtopia Core Display Management for more details.

See also disconnect(), initDevice(), and Running Qtopia Core Applications.

[править]
QWSWindowSurface * QScreen::createSurface ( const QString & key ) const [virtual]

Creates and returns a new window surface matching the given key. Possible keys include OnScreen for an on-screen surface, mem for a surface constructed from local memory, shm for a surface constructed from shared memory, Yellow for a yellow surface, and DirectPainter for a direct painter surface.

The server application will call this function whenever it needs to create a server side representation of a window, e.g. when copying the content of memory to the screen using the screen driver.

Note that this function must be reimplemented when adding an accelerated graphics driver. See the Adding an Accelerated Graphics Driver documentation for details.

Эта функция была введена в Qt 4.2.

See also Qtopia Core Architecture.

[править]
QWSWindowSurface * QScreen::createSurface ( QWidget * widget ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Creates and returns a new window surface for the given widget.

[править]
int QScreen::depth () const

Returns the depth of the framebuffer, in bits per pixel.

Note that the returned depth is the number of bits each pixel fills rather than the number of significant bits, so 24bpp and 32bpp express the same range of colors (8 bits of red, green and blue).

See also clut() and pixmapDepth().

[править]
int QScreen::deviceHeight () const

Returns the full height of the framebuffer device in pixels.

Note that the returned height can differ from the height which Qtopia Core will actually use, that is if the display is centered within the framebuffer.

See also height(), physicalHeight(), and deviceWidth().

[править]
int QScreen::deviceWidth () const

Returns the physical width of the framebuffer device in pixels.

Note that the returned width can differ from the width which Qtopia Core will actually use, that is if the display is centered within the framebuffer.

See also width(), physicalWidth(), and deviceHeight().

[править]
void QScreen::disconnect () [pure virtual]

This function is called by every Qtopia Core application before exiting, and must be implemented to unmap the framebuffer. Note that a server application will call the shutdownDevice() function prior to this function.

See also connect(), shutdownDevice(), and Running Qtopia Core Applications.

[править]
void QScreen::exposeRegion ( QRegion region, int windowIndex ) [virtual]

This function is called by the Qtopia Core server whenever a screen update is required. region is the area on the screen that must be updated, and windowIndex is the index into QWSServer::clientWindows() of the window that required the update. QWSWindow::state() gives more information about the cause.

The default implementation composes the affected windows and paints the given region on screen by calling the blit() and solidFill() functions

This function can be reimplemented to perform composition in hardware, or to perform transition effects. For simpler hardware acceleration, or to interface with this is typically done by reimplementing the blit() and solidFill() functions instead.

Note that there is no need to call this function explicitly.

See also blit(), solidFill(), and blank().

[править]
int QScreen::height () const

Returns the logical height of the framebuffer in pixels.

See also deviceHeight(), physicalHeight(), and width().

[править]
bool QScreen::initDevice () [pure virtual]

This function is called by the Qtopia Core server to initialize the framebuffer. Note that a server application will call the connect() function prior to this function.

Implement this function to make accelerated drivers set up the graphics card. Return true to indicate success and false to indicate failure.

See also shutdownDevice() and connect().

[править]
QScreen * QScreen::instance () [static]

Returns a pointer to the application's QScreen instance.

If this screen consists of several subscreens, operations to the returned instance will affect all its subscreens. Use the subscreens() function to retrieve access to a particular subscreen.

See also subScreens() and subScreenIndexAt().

[править]
bool QScreen::isInterlaced () const [virtual]

Returns true if the display is interlaced (i.e. is displaying images progressively like a television screen); otherwise returns false.

If the display is interlaced, the drawing is altered to look better.

See also isTransformed() and linestep().

[править]
bool QScreen::isTransformed () const [virtual]

Returns true if the screen is transformed (for instance, rotated 90 degrees); otherwise returns false.

See also transformOrientation() and isInterlaced().

[править]
int QScreen::linestep () const

Returns the length of each scanline of the framebuffer in bytes.

See also isInterlaced().

[править]
QSize QScreen::mapFromDevice ( const QSize & size ) const [virtual]

Maps the given size from the framebuffer coordinate system to the coordinate space used by the application. Note that the default implementation simply returns the given size as it is.

Reimplement this function to use the given device's coordinate system when mapping.

See also mapToDevice().

[править]
QPoint QScreen::mapFromDevice ( const QPoint & point, const QSize & screenSize ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given point from the framebuffer coordinate system to the coordinate space used by the application, passing the device's screenSize as argument. Note that the default implementation simply returns the given point as it is.

[править]
QRect QScreen::mapFromDevice ( const QRect & rectangle, const QSize & screenSize ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given rectangle from the framebuffer coordinate system to the coordinate space used by the application, passing the device's screenSize as argument. Note that the default implementation simply returns the given rectangle as it is.

[править]
QImage QScreen::mapFromDevice ( const QImage & image ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given image from the framebuffer coordinate system to the coordinate space used by the application. Note that the default implementation simply returns the given image as it is.

[править]
QRegion QScreen::mapFromDevice ( const QRegion & region, const QSize & screenSize ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given region from the framebuffer coordinate system to the coordinate space used by the application, passing the device's screenSize as argument. Note that the default implementation simply returns the given region as it is.

[править]
QSize QScreen::mapToDevice ( const QSize & size ) const [virtual]

Maps the given size from the coordinate space used by the application to the framebuffer coordinate system. Note that the default implementation simply returns the given size as it is.

Reimplement this function to use the given device's coordinate system when mapping.

See also mapFromDevice().

[править]
QPoint QScreen::mapToDevice ( const QPoint & point, const QSize & screenSize ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given point from the coordinate space used by the application to the framebuffer coordinate system, passing the device's screenSize as argument. Note that the default implementation returns the given point as it is.

[править]
QRect QScreen::mapToDevice ( const QRect & rectangle, const QSize & screenSize ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given rectangle from the coordinate space used by the application to the framebuffer coordinate system, passing the device's screenSize as argument. Note that the default implementation returns the given rectangle as it is.

[править]
QImage QScreen::mapToDevice ( const QImage & image ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given image from the coordinate space used by the application to the framebuffer coordinate system. Note that the default implementation returns the given image as it is.

[править]
QRegion QScreen::mapToDevice ( const QRegion & region, const QSize & screenSize ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

Maps the given region from the coordinate space used by the application to the framebuffer coordinate system, passing the device's screenSize as argument. Note that the default implementation returns the given region as it is.

[править]
int QScreen::numCols ()

Returns the number of entries in the screen's color lookup table (i.e. its color palette). A pointer to the color table can be retrieved using the clut() function.

See also clut() and alloc().

[править]
QPoint QScreen::offset () const

Returns the logical offset of the screen, i.e., the offset between (0,0) in screen coordinates and the application coordinate system.

Эта функция была введена в Qt 4.2.

[править]
bool QScreen::onCard ( const unsigned char * buffer ) const [virtual]

Returns true if the specified buffer is within the graphics card's memory; otherwise returns false (i.e. if it's in main RAM).

See also base() and totalSize().

[править]
bool QScreen::onCard ( const unsigned char * buffer, ulong & offset ) const [virtual]

Эта перегруженная функция предоставлена для удобства.

If the specified buffer is within the graphics card's memory, this function stores the offset from the start of graphics card memory (in bytes), in the location specified by the offset parameter.

[править]
int QScreen::physicalHeight () const

Returns the physical height of the screen in millimeters.

Эта функция была введена в Qt 4.2.

See also height(), deviceHeight(), and physicalWidth().

[править]
int QScreen::physicalWidth () const

Returns the physical width of the screen in millimeters.

Эта функция была введена в Qt 4.2.

See also width(), deviceWidth(), and physicalHeight().

[править]
QImage::Format QScreen::pixelFormat () const

Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a supported image format.

See also setPixelFormat().

[править]
PixelType QScreen::pixelType () const

Returns the pixel storage format of the screen.

[править]
int QScreen::pixmapDepth () const [virtual]

Returns the preferred depth for pixmaps, in bits per pixel.

See also depth().

[править]
int QScreen::pixmapLinestepAlignment () [virtual]

Returns the value (in bits) to which individual scanlines of pixmaps held in the graphics card's memory, should be aligned.

Note that the default implementation returns 64; reimplement this function to override the return value, e.g., when implementing an accelerated driver (see the Adding an Accelerated Graphics Driver documentation for details).

See also pixmapOffsetAlignment().

[править]
int QScreen::pixmapOffsetAlignment () [virtual]

Returns the value (in bits) to which the start address of pixmaps held in the graphics card's memory, should be aligned.

Note that the default implementation returns 64; reimplement this function to override the return value, e.g., when implementing an accelerated driver (see the Adding an Accelerated Graphics Driver documentation for details).

See also pixmapLinestepAlignment().

[править]
QRegion QScreen::region () const [virtual]

Returns the region covered by this screen driver.

Эта функция была введена в Qt 4.2.

See also base() and screenSize().

[править]
void QScreen::restore () [virtual]

Restores the previously saved state of the graphics card.

For example, hardware screen drivers should reimplement the save() and restore() functions to save and restore its registers, enabling swintching between virtual consoles.

Note that the default implementation does nothing.

See also save().

[править]
void QScreen::save () [virtual]

Saves the current state of the graphics card.

For example, hardware screen drivers should reimplement the save() and restore() functions to save and restore its registers, enabling swintching between virtual consoles.

Note that the default implementation does nothing.

See also restore().

[править]
int QScreen::screenSize () const

Returns the size of the screen in bytes.

The screen size is always located at the beginning of framebuffer memory, i.e. it can also be retrieved using the base() function.

See also base() and region().

[править]
void QScreen::setDirty ( const QRect & rectangle ) [virtual]

Marks the given rectangle as dirty.

Note that the default implementation does nothing; reimplement this function to indicate that the given rectangle has been altered.

[править]
void QScreen::setMode ( int width, int height, int depth ) [pure virtual]

Implement this function to reset the framebuffer's resolution (width and height) and bit depth.

After the resolution has been set, existing paint engines will be invalid and the framebuffer should be completely redrawn. In a multiple-process situation, all other applications must be notified to reset their mode and update themselves accordingly.

[править]
void QScreen::setPixelFormat ( QImage::Format format ) [protected]

Sets the screen's pixel format to format.

See also pixelFormat().

[править]
void QScreen::shutdownDevice () [virtual]

This function is called by the Qtopia Core server before it calls the disconnect() function when exiting.

Note that the default implementation only hides the mouse cursor; reimplement this function to do the necessary graphics card specific cleanup.

See also initDevice() and disconnect().

[править]
void QScreen::solidFill ( const QColor & color, const QRegion & region ) [virtual]

Fills the given region of the screen with the specified color.

This function is called from the exposeRegion() function; it is not intended to be called explicitly.

Reimplement this function to make use of accelerated hardware. Note that this function must be reimplemented if the framebuffer format is not supported by Qtopia Core (See the Display Management documentation for more details).

See also exposeRegion(), blit(), and blank().

[править]
int QScreen::subScreenIndexAt ( const QPoint & position ) const

Returns the index of the subscreen at the given position; returns -1 if no screen is found.

The index identifies the subscreen in the list of pointers returned by the subScreens() function.

Эта функция была введена в Qt 4.2.

See also instance() and subScreens().

[править]
QList<QScreen *> QScreen::subScreens () const [virtual]

Returns a list of this screen's subscreens. Use the subScreenIndexAt() function to retrieve the index of a screen at a given position.

Note that if this screen consists of several subscreens, operations to this instance will affect all subscreens by default.

Эта функция была введена в Qt 4.2.

See also instance() and subScreenIndexAt().

[править]
bool QScreen::supportsDepth ( int depth ) const [virtual]

Returns true if the screen supports the specified color depth; otherwise returns false.

See also clut().

[править]
int QScreen::totalSize () const

Returns the size of the available graphics card memory (including the screen) in bytes.

See also onCard().

[править]
int QScreen::transformOrientation () const [virtual]

Returns the current rotation as an integer value.

Note that the default implementation returns 0; reimplement this function to override this value.

See also isTransformed().

[править]
int QScreen::width () const

Returns the logical width of the framebuffer in pixels.

See also deviceWidth(), physicalWidth(), and height().



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2