summaryrefslogtreecommitdiff
path: root/NxWidgets
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-11-09 14:54:29 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-11-09 14:54:29 +0000
commit42a56e78dda5561d301ec2e61a0bac17e7342525 (patch)
tree5dec10051ddb12ddf1d6d7f02c69d09ad2a27895 /NxWidgets
parent2b35c03044dc6acfe720522f943ee07df1b65897 (diff)
downloadpx4-nuttx-42a56e78dda5561d301ec2e61a0bac17e7342525.tar.gz
px4-nuttx-42a56e78dda5561d301ec2e61a0bac17e7342525.tar.bz2
px4-nuttx-42a56e78dda5561d301ec2e61a0bac17e7342525.zip
Several patches from Petteri Aimonen (mostly NxWidgets)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5324 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets')
-rw-r--r--NxWidgets/ChangeLog.txt19
-rw-r--r--NxWidgets/Kconfig16
-rw-r--r--NxWidgets/nxwm/src/capplicationwindow.cxx30
-rw-r--r--NxWidgets/nxwm/src/chexcalculator.cxx2
-rw-r--r--NxWidgets/nxwm/src/cstartwindow.cxx2
-rw-r--r--NxWidgets/nxwm/src/ctaskbar.cxx19
-rwxr-xr-xNxWidgets/tools/README.txt51
-rwxr-xr-xNxWidgets/tools/bitmap_converter.py148
-rwxr-xr-xNxWidgets/tools/install.sh2
9 files changed, 276 insertions, 13 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt
index f4aedd828..113945f2f 100644
--- a/NxWidgets/ChangeLog.txt
+++ b/NxWidgets/ChangeLog.txt
@@ -182,4 +182,21 @@
* libnxwidgets/src/cnxserver.cxx: Reduce delay to allow NX server
to start. One second was un-necessarily long. Reduced to 50 MS.
Reduction suggested by Petteri Aimonen.
-
+* tools/bitmap_converter.py: This script converts from any image type
+ supported by Python imaging library to the RLE-encoded format used by
+ NxWidgets.
+* NxWidgets/nxwm/src/capplicationwindow.cxx: If the "desktop" is empty,
+ users have no need to minimize any windows. If the buttons are small,
+ it's easy to hit minimize button accidentally when trying to close an
+ application. Contributed by Petteri Aimonen.
+* NxWidgets/nxwm/src/ctaskbar.cxx: Add an option to eliminate the
+ background image. Contributed by Petteri Aimonen.
+* NxWidgets/nxwm/src/chexcalculator.cxx and NxWidgets/nxwm/src/cstartwindow.cxx:
+ The config settings CONFIG_NXWM_STARTWINDOW_ICON and CONFIG_NXWM_HEXCALCULATOR_ICON
+ allow changing the icons used for these applications. However, to declare symbols
+ for these icons user would need to modify NxWidgets header files.
+ This commit adds a simple forward declaration to the relevant files, based on the
+ configured icon. If the icon does not exist, linker will give an error about it.
+ Contributed by Petteri Aimonen.
+* NxWidgets/nxwm/src/ctaskbar.cxx: Highlight the current window in the task bar.
+ Contributed by Petteri Aimonen.
diff --git a/NxWidgets/Kconfig b/NxWidgets/Kconfig
index 6befd1ace..59d8856bc 100644
--- a/NxWidgets/Kconfig
+++ b/NxWidgets/Kconfig
@@ -308,6 +308,14 @@ config NXWM_TASKBAR_WIDTH
---help---
Task bar thickness (either vertical or horizontal). Default: 25 + 2*spacing
+config NXWM_DISABLE_MINIMIZE
+ bool "Disable Minimize Button"
+ default n
+ ---help---
+ If the "desktop" is empty, users have no need to minimize any windows. If the buttons
+ are small, it's easy to hit minimize button accidentally when trying to close an
+ application.
+
comment "Tool Bar Configuration"
config NXWM_TOOLBAR_HEIGHT
@@ -319,8 +327,16 @@ config NXWM_TOOLBAR_HEIGHT
comment "Background Image"
+config NXWM_DISABLE_BACKGROUND_IMAGE
+ bool "Disable Background Image"
+ default n if !NXWM_DISABLE_MINIMIZE
+ default y if NXWM_DISABLE_MINIMIZE
+ ---help---
+ Disable support for the "Desktop" background image.
+
config NXWM_BACKGROUND_IMAGE
string "Background Image"
+ depends on !NXWM_DISABLE_BACKGROUND_IMAGE
---help---
The name of the image to use in the background window. Default:
NXWidgets::g_nuttxBitmap
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx
index 65de1b1a4..d2e044298 100644
--- a/NxWidgets/nxwm/src/capplicationwindow.cxx
+++ b/NxWidgets/nxwm/src/capplicationwindow.cxx
@@ -241,6 +241,7 @@ bool CApplicationWindow::open(void)
m_stopImage->addWidgetEventHandler(this);
}
+#ifndef CONFIG_NXWM_DISABLE_MINIMIZE
// Create MINIMIZE application bitmap container
m_minimizeBitmap = new NXWidgets::CRlePaletteBitmap(&g_minimizeBitmap);
@@ -289,6 +290,7 @@ bool CApplicationWindow::open(void)
m_minimizeImage->setBorderless(true);
m_minimizeImage->addWidgetEventHandler(this);
+#endif
// The rest of the toolbar will hold the left-justified application label
// Create the default font instance
@@ -364,12 +366,16 @@ void CApplicationWindow::redraw(void)
m_stopImage->setRaisesEvents(true);
}
- // Draw the minimize image
-
- m_minimizeImage->enableDrawing();
- m_minimizeImage->redraw();
- m_minimizeImage->setRaisesEvents(true);
+ // Draw the minimize image (which may not be present if this is a
+ // mimimization is disabled)
+ if (m_minimizeImage)
+ {
+ m_minimizeImage->enableDrawing();
+ m_minimizeImage->redraw();
+ m_minimizeImage->setRaisesEvents(true);
+ }
+
// And finally draw the window label
m_windowLabel->enableDrawing();
@@ -392,11 +398,15 @@ void CApplicationWindow::hide(void)
m_stopImage->setRaisesEvents(false);
}
- // Disable the minimize image
-
- m_minimizeImage->disableDrawing();
- m_minimizeImage->setRaisesEvents(false);
+ // Disable the minimize image(which may not be present if this is a
+ // mimimization is disabled)
+ if (m_minimizeImage)
+ {
+ m_minimizeImage->disableDrawing();
+ m_minimizeImage->setRaisesEvents(false);
+ }
+
// Disable the window label
m_windowLabel->disableDrawing();
@@ -570,7 +580,7 @@ void CApplicationWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
// Check the minimize image (only if the stop application image is not pressed)
- else if (m_minimizeImage->isClicked())
+ else if (m_minimizeImage && m_minimizeImage->isClicked())
{
// Notify the controlling logic that the application should be miminsed
diff --git a/NxWidgets/nxwm/src/chexcalculator.cxx b/NxWidgets/nxwm/src/chexcalculator.cxx
index f8f1bb246..eeb0b1d1d 100644
--- a/NxWidgets/nxwm/src/chexcalculator.cxx
+++ b/NxWidgets/nxwm/src/chexcalculator.cxx
@@ -191,6 +191,8 @@ namespace NxWM
* CHexCalculator Method Implementations
********************************************************************************************/
+extern const struct NXWidgets::SRlePaletteBitmap CONFIG_NXWM_HEXCALCULATOR_ICON;
+
using namespace NxWM;
/**
diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx
index 5c54cba3a..a99e81d88 100644
--- a/NxWidgets/nxwm/src/cstartwindow.cxx
+++ b/NxWidgets/nxwm/src/cstartwindow.cxx
@@ -71,6 +71,8 @@ FAR const char *NxWM::g_startWindowMqName = CONFIG_NXWM_STARTWINDOW_MQNAME;
* CStartWindow Method Implementations
********************************************************************************************/
+extern const struct NXWidgets::SRlePaletteBitmap CONFIG_NXWM_STARTWINDOW_ICON;
+
using namespace NxWM;
/**
diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx
index c494fcba3..23d2d23b5 100644
--- a/NxWidgets/nxwm/src/ctaskbar.cxx
+++ b/NxWidgets/nxwm/src/ctaskbar.cxx
@@ -991,6 +991,7 @@ bool CTaskbar::createBackgroundWindow(void)
bool CTaskbar::createBackgroundImage(void)
{
+#ifndef CONFIG_NXWM_DISABLE_BACKGROUND_IMAGE
// Get the size of the display
struct nxgl_size_s windowSize;
@@ -1054,6 +1055,8 @@ bool CTaskbar::createBackgroundImage(void)
m_backImage->setBorderless(true);
m_backImage->setRaisesEvents(false);
+#endif
+
return true;
}
@@ -1128,6 +1131,10 @@ bool CTaskbar::redrawTaskbarWindow(void)
image->disableDrawing();
image->setRaisesEvents(false);
+ // Highlight the icon for the top-most window
+
+ image->highlight(m_slots.at(i).app == m_topApp);
+
// Get the size of the icon image
NXWidgets::CRect rect;
@@ -1302,8 +1309,12 @@ bool CTaskbar::redrawBackgroundWindow(void)
// Then re-draw the background image on the window
- m_backImage->enableDrawing();
- m_backImage->redraw();
+ if (m_backImage)
+ {
+ m_backImage->enableDrawing();
+ m_backImage->redraw();
+ }
+
return true;
}
@@ -1330,6 +1341,10 @@ bool CTaskbar::redrawApplicationWindow(IApplication *app)
raiseTopApplication();
+ // Redraw taskbar
+
+ redrawTaskbarWindow();
+
// Every application provides a method to obtain its application window
IApplicationWindow *appWindow = app->getWindow();
diff --git a/NxWidgets/tools/README.txt b/NxWidgets/tools/README.txt
new file mode 100755
index 000000000..22b2bf2a9
--- /dev/null
+++ b/NxWidgets/tools/README.txt
@@ -0,0 +1,51 @@
+NxWidgets/tools README File
+===========================
+
+addobjs.sh
+----------
+
+ $0 will add all object (.o) files in directory to an archive.
+
+ Usage: tools/addobjs.sh [OPTIONS] <lib-path> <obj-dir>
+
+ Where:
+ <lib-path> is the full, absolute path to the library to use
+ <obj-dir> is full path to the directory containing the object files to be added
+ OPTIONS include:
+ -p Prefix to use. For example, to use arm-elf-ar, add '-p arm-elf-'
+ -w Use Windows style paths insted of POSIX paths
+ -d Enable script debug
+ -h Show this usage information
+
+bitmap_converter.py
+-------------------
+
+ This script converts from any image type supported by Python imaging library to
+ the RLE-encoded format used by NxWidgets.
+
+indent.sh
+---------
+
+ This script uses the Linux 'indent' utility to re-format C source files
+ to match the coding style that I use. It differs from my coding style in that
+
+ - I normally put the traiing */ of a multi-line comment on a separate line,
+ - I usually align things vertically (like '='in assignments.
+
+install.sh
+----------
+
+ Install a unit test in the NuttX source tree"
+
+ USAGE: tools/install.sh <apps-directory-path> <test-sub-directory>
+
+ Where:
+ <apps-directory-path> is the full, absolute path to the NuttX apps/ directory
+ <test-sub-directory> is the name of a sub-directory in the UnitTests directory
+
+zipme.sh
+--------
+
+ Pack up the NxWidgets tarball for release.
+
+ USAGE: tools/zipme.sh <version>
diff --git a/NxWidgets/tools/bitmap_converter.py b/NxWidgets/tools/bitmap_converter.py
new file mode 100755
index 000000000..2cb7e8869
--- /dev/null
+++ b/NxWidgets/tools/bitmap_converter.py
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+
+'''This script converts from any image type supported by
+Python imaging library to the RLE-encoded format used by
+NxWidgets.
+'''
+
+from PIL import Image
+
+def get_palette(img, maxcolors = 255):
+ '''Returns a list of colors. If there are too many colors in the image,
+ the least used are removed.
+ '''
+ img = img.convert("RGB")
+ colors = img.getcolors(65536)
+ colors.sort(key = lambda c: -c[0])
+ return [c[1] for c in colors[:maxcolors]]
+
+def write_palette(outfile, palette):
+ '''Write the palette (normal and hilight) to the output file.'''
+
+ outfile.write('static const NXWidgets::nxwidget_pixel_t palette[BITMAP_PALETTESIZE] =\n');
+ outfile.write('{\n')
+
+ for i in range(0, len(palette), 4):
+ outfile.write(' ');
+ for r, g, b in palette[i:i+4]:
+ outfile.write('MKRGB(%3d,%3d,%3d), ' % (r, g, b))
+ outfile.write('\n');
+
+ outfile.write('};\n\n')
+
+ outfile.write('static const NXWidgets::nxwidget_pixel_t hilight_palette[BITMAP_PALETTESIZE] =\n');
+ outfile.write('{\n')
+
+ for i in range(0, len(palette), 4):
+ outfile.write(' ');
+ for r, g, b in palette[i:i+4]:
+ r = min(255, r + 50)
+ g = min(255, g + 50)
+ b = min(255, b + 50)
+ outfile.write('MKRGB(%3d,%3d,%3d), ' % (r, g, b))
+ outfile.write('\n');
+
+ outfile.write('};\n\n')
+
+
+def quantize(color, palette):
+ '''Return the color index to closest match in the palette.'''
+ try:
+ return palette.index(color)
+ except ValueError:
+ # No exact match, search for the closest
+ def distance(color2):
+ return sum([(a - b)**2 for a, b in zip(color, color2)])
+
+ return palette.index(min(palette, key = distance));
+
+def encode_row(img, palette, y):
+ '''RLE-encode one row of image data.'''
+ entries = []
+ color = None
+ repeats = 0
+
+ for x in range(0, img.size[0]):
+ c = quantize(img.getpixel((x, y)), palette)
+ if c == color:
+ repeats += 1
+ else:
+ if color is not None:
+ entries.append((repeats, color))
+
+ repeats = 1
+ color = c
+
+ if color is not None:
+ entries.append((repeats, color))
+
+ return entries
+
+def write_image(outfile, img, palette):
+ '''Write the image contents to the output file.'''
+
+ outfile.write('static const NXWidgets::SRlePaletteBitmapEntry bitmap[] =\n');
+ outfile.write('{\n');
+
+ for y in range(0, img.size[1]):
+ entries = encode_row(img, palette, y)
+ row = ""
+ for r, c in entries:
+ if len(row) > 60:
+ outfile.write(' ' + row + '\n')
+ row = ""
+
+ row += '{%3d, %3d}, ' % (r, c)
+
+ row += ' ' * (73 - len(row))
+ outfile.write(' ' + row + '/* Row %d */\n' % y)
+
+ outfile.write('};\n\n');
+
+def write_descriptor(outfile, name):
+ '''Write the public descriptor structure for the image.'''
+
+ outfile.write('extern const struct NXWidgets::SRlePaletteBitmap g_%s =\n' % name)
+ outfile.write('{\n')
+ outfile.write(' CONFIG_NXWIDGETS_BPP,\n')
+ outfile.write(' CONFIG_NXWIDGETS_FMT,\n')
+ outfile.write(' BITMAP_PALETTESIZE,\n')
+ outfile.write(' BITMAP_WIDTH,\n')
+ outfile.write(' BITMAP_HEIGHT,\n')
+ outfile.write(' {palette, hilight_palette},\n')
+ outfile.write(' bitmap\n')
+ outfile.write('};\n')
+
+if __name__ == '__main__':
+ import sys
+ import os.path
+
+ if len(sys.argv) != 3:
+ print "Usage: bitmap_converter.py source.png output.cxx"
+ sys.exit(1)
+
+ img = Image.open(sys.argv[1])
+ outfile = open(sys.argv[2], 'w')
+ palette = get_palette(img)
+
+ outfile.write(
+'''
+/* Automatically NuttX bitmap file. */
+/* Generated from %(src)s by bitmap_converter.py. */
+
+#include <nxconfig.hxx>
+#include <crlepalettebitmap.hxx>
+
+#define BITMAP_WIDTH %(width)s
+#define BITMAP_HEIGHT %(height)s
+#define BITMAP_PALETTESIZE %(palettesize)s
+
+''' % {'src': sys.argv[1], 'width': img.size[0], 'height': img.size[1],
+ 'palettesize': len(palette)}
+ )
+
+ name = os.path.splitext(os.path.basename(sys.argv[1]))[0]
+
+ write_palette(outfile, palette)
+ write_image(outfile, img, palette)
+ write_descriptor(outfile, name)
diff --git a/NxWidgets/tools/install.sh b/NxWidgets/tools/install.sh
index 6917b4b03..dd212b5a6 100755
--- a/NxWidgets/tools/install.sh
+++ b/NxWidgets/tools/install.sh
@@ -40,6 +40,8 @@
function ShowUsage()
{
echo ""
+ echo "Install a unit test in the NuttX source tree"
+ echo ""
echo "USAGE: $0 <apps-directory-path> <test-sub-directory>"
echo ""
echo "Where:"