diff options
Diffstat (limited to 'NxWidgets/libnxwidgets')
-rw-r--r-- | NxWidgets/libnxwidgets/include/cgraphicsport.hxx | 30 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/cbuttonarray.cxx | 18 |
2 files changed, 47 insertions, 1 deletions
diff --git a/NxWidgets/libnxwidgets/include/cgraphicsport.hxx b/NxWidgets/libnxwidgets/include/cgraphicsport.hxx index 8eea3d689..b9fbc4d41 100644 --- a/NxWidgets/libnxwidgets/include/cgraphicsport.hxx +++ b/NxWidgets/libnxwidgets/include/cgraphicsport.hxx @@ -152,6 +152,36 @@ namespace NXWidgets const nxgl_coord_t getY(void) const; /** + * Get the background color that will be used to fill in the spaces + * when rendering fonts. This background color is ONLY used if the + * LCD device does not support reading GRAM contents. + * + * @return. The current background color being used. + */ + +#ifdef CONFIG_NX_WRITEONLY + nxgl_mxpixel_t getBackColor(void) const + { + return m_backColor; + } +#endif + + /** + * Set the background color that will be used to fill in the spaces + * when rendering fonts. This background color is ONLY used if the + * LCD device does not support reading GRAM contents. + * + * @return. The current background color being used. + */ + +#ifdef CONFIG_NX_WRITEONLY + void setBackColor(nxgl_mxpixel_t backColor) + { + m_backColor = backColor; + } +#endif + + /** * Draw a pixel into the window. * * @param x The window-relative x coordinate of the pixel. diff --git a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx index 642a0a562..28f14062b 100644 --- a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx +++ b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx @@ -519,9 +519,25 @@ void CButtonArray::drawButton(CGraphicsPort *port, int column, int row, bool use pos.x = x + alignX; pos.y = y + alignY; - // And draw the button text + // Set the CGraphicsControl background to match the selected background color. + // This is only necessary if we cannot read from the LCD. If we cannot read + // from then the font background is set to this background color. + // REVISIT: This begs for a more generalized solution. + +#ifdef CONFIG_NX_WRITEONLY + nxgl_mxpixel_t saveColor = port->getBackColor(); + port->setBackColor(backColor); +#endif + + // And draw the button text. port->drawText(&pos, &rect, getFont(), *text, 0, text->getLength(), textColor); + + // Restore the default background color + +#ifdef CONFIG_NX_WRITEONLY + port->setBackColor(saveColor); +#endif } /** |