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/cimage.cxx | |
parent | dd5155bc0f4765ad35cb485fb4eb9930ae365a7d (diff) | |
download | nuttx-fbfd97c209f99cf1a9e8190ba835c1b3bef64c2a.tar.gz nuttx-fbfd97c209f99cf1a9e8190ba835c1b3bef64c2a.tar.bz2 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/cimage.cxx')
-rw-r--r-- | NxWidgets/libnxwidgets/src/cimage.cxx | 64 |
1 files changed, 55 insertions, 9 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); } /** |