diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-04-28 17:36:53 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-04-28 17:36:53 +0000 |
commit | fbfd97c209f99cf1a9e8190ba835c1b3bef64c2a (patch) | |
tree | ab42679f8868bdeaa101f569dab7500e2206ddf7 /NxWidgets/libnxwidgets/src | |
parent | dd5155bc0f4765ad35cb485fb4eb9930ae365a7d (diff) | |
download | px4-nuttx-fbfd97c209f99cf1a9e8190ba835c1b3bef64c2a.tar.gz px4-nuttx-fbfd97c209f99cf1a9e8190ba835c1b3bef64c2a.tar.bz2 px4-nuttx-fbfd97c209f99cf1a9e8190ba835c1b3bef64c2a.zip |
A few pieces of what may become an NX window manager
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4669 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets/src')
-rw-r--r-- | NxWidgets/libnxwidgets/src/cimage.cxx | 64 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx | 17 | ||||
-rw-r--r-- | NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx | 5 |
3 files changed, 74 insertions, 12 deletions
diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx index 5e46b801b..c905737fd 100644 --- a/NxWidgets/libnxwidgets/src/cimage.cxx +++ b/NxWidgets/libnxwidgets/src/cimage.cxx @@ -156,7 +156,7 @@ void CImage::getPreferredDimensions(CRect &rect) const * @param port The CGraphicsPort to draw to. * @see redraw() */ - + void CImage::drawContents(CGraphicsPort *port) { // Get the the drawable region @@ -178,6 +178,10 @@ void CImage::drawContents(CGraphicsPort *port) bitmap.stride = (rect.getWidth() * m_bitmap->getBitsPerPixel()) >> 3; bitmap.data = buffer; + // Select the correct colorization + + m_bitmap->setSelected(isClicked() || m_highlighted); + // This is the number of rows that we can draw at the top of the display nxgl_coord_t nTopRows = m_bitmap->getHeight() - m_origin.y; @@ -261,12 +265,21 @@ void CImage::drawContents(CGraphicsPort *port) // And put these on the display - port->drawBitmap(rect.getX(), displayRow, rect.getWidth(), 1, - &bitmap, 0, 0); + if (isEnabled()) + { + port->drawBitmap(rect.getX(), displayRow, rect.getWidth(), 1, + &bitmap, 0, 0); + } + else + { + port->drawBitmapGreyScale(rect.getX(),displayRow, + rect.getWidth(), 1, + &bitmap, 0, 0); + } } } - // Are we going to draw any rows at the top of the display? + // Are we going to draw any rows at the bottom of the display? if (nTopRows < rect.getHeight()) { @@ -286,8 +299,18 @@ void CImage::drawContents(CGraphicsPort *port) { // Put the padded row on the display - port->drawBitmap(rect.getX(), displayRow, rect.getWidth(), 1, - &bitmap, 0, 0); + if (isEnabled()) + { + port->drawBitmap(rect.getX(), displayRow, + rect.getWidth(), 1, + &bitmap, 0, 0); + } + else + { + port->drawBitmapGreyScale(rect.getX(),displayRow, + rect.getWidth(), 1, + &bitmap, 0, 0); + } } } @@ -304,11 +327,34 @@ void CImage::drawContents(CGraphicsPort *port) void CImage::drawBorder(CGraphicsPort *port) { - if (!isBorderless()) + // Stop drawing if the widget indicates it should not have an outline + + if (isBorderless()) + { + return; + } + + // Work out which colors to use + + nxgl_coord_t color1; + nxgl_coord_t color2; + + if (isClicked()) + { + // Bevelled into the screen + + color1 = getShadowEdgeColor(); + color2 = getShineEdgeColor(); + } + else { - port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), - getShadowEdgeColor(), getShineEdgeColor()); + // Bevelled out of the screen + + color1 = getShineEdgeColor(); + color2 = getShadowEdgeColor(); } + + port->drawBevelledRect(getX(), getY(), getWidth(), getHeight(), color1, color2); } /** diff --git a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx index 25e9473ed..79a614349 100644 --- a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx +++ b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx @@ -101,6 +101,7 @@ using namespace NXWidgets; CRlePaletteBitmap::CRlePaletteBitmap(const struct SRlePaletteBitmap *bitmap) { m_bitmap = bitmap; + m_lut = bitmap->lut[0]; startOfImage(); } @@ -162,7 +163,19 @@ const nxgl_coord_t CRlePaletteBitmap::getStride(void) const } /** - * Get one row from the bit map image. + * Use the colors associated with a selected image. + * + * @param selected. true: Use colors for a selected widget, + * false: Use normal (default) colors. + */ + +void CRlePaletteBitmap::setSelected(bool selected) +{ + m_lut = m_bitmap->lut[selected ? 1 : 0]; +} + +/** + * Get one row from the bit map image using the selected LUT. * * @param x The offset into the row to get * @param y The row number to get @@ -337,7 +350,7 @@ void CRlePaletteBitmap::copyColor(nxgl_coord_t npixels, FAR void *data) { // Right now, only a single pixel depth is supported - nxwidget_pixel_t *nxlut = (nxwidget_pixel_t *)m_bitmap->lut; + nxwidget_pixel_t *nxlut = (nxwidget_pixel_t *)m_lut; nxwidget_pixel_t color = nxlut[m_rle->lookup]; // Copy the requested pixels diff --git a/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx b/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx index 1b3aab143..5f1bd7dbf 100644 --- a/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx +++ b/NxWidgets/libnxwidgets/src/glyph_nxlogo.cxx @@ -3445,6 +3445,9 @@ const struct SRlePaletteBitmap NXWidgets::g_nuttxBitmap = BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT) 160, // width - Width in pixels 160, // height - Height in rows - g_nuttxLut, // lut - Pointer to the beginning of the Look-Up Table (LUT) + { // lut - Pointer to the beginning of the Look-Up Table (LUT) + g_nuttxLut, // Index 0: Unselected LUT + g_nuttxLut, // Index 1: Selected LUT + }, g_nuttxRleEntries // data - Pointer to the beginning of the RLE data }; |