diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-10-15 14:29:06 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-10-15 14:29:06 -0600 |
commit | 7ef1ad19448670543bece35c3a6119e6a440c778 (patch) | |
tree | 79292d132ebcbe2141042217e3bad7342e22e162 /NxWidgets/nxwm | |
parent | 24ee5014675d43c80c0580882fe5cc24ca17e7a8 (diff) | |
download | nuttx-7ef1ad19448670543bece35c3a6119e6a440c778.tar.gz nuttx-7ef1ad19448670543bece35c3a6119e6a440c778.tar.bz2 nuttx-7ef1ad19448670543bece35c3a6119e6a440c778.zip |
Use NxWidgets::CScaledBitmap to scale icons in the NxWM taskbar
Diffstat (limited to 'NxWidgets/nxwm')
-rw-r--r-- | NxWidgets/nxwm/include/ctaskbar.hxx | 4 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/nxwmconfig.hxx | 24 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/ctaskbar.cxx | 38 |
3 files changed, 60 insertions, 6 deletions
diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx index 84c7b28f4..cbd35b52f 100644 --- a/NxWidgets/nxwm/include/ctaskbar.hxx +++ b/NxWidgets/nxwm/include/ctaskbar.hxx @@ -92,8 +92,8 @@ namespace NxWM struct STaskbarSlot { - IApplication *app; /**< A reference to the icon */ - NXWidgets::CImage *image; /**< The icon image that goes with the application */ + IApplication *app; /**< A reference to the application */ + NXWidgets::CImage *image; /**< The icon image for the application */ }; /** diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx index 6e540fefc..7715224e2 100644 --- a/NxWidgets/nxwm/include/nxwmconfig.hxx +++ b/NxWidgets/nxwm/include/nxwmconfig.hxx @@ -223,6 +223,24 @@ # define CONFIG_NXWM_TASKBAR_TOP 1 #endif +// Taskbar ICON scaling + +#ifdef CONFIG_NXWM_TASKBAR_ICONSCALE +# ifndef CONFIG_NXWM_TASKBAR_ICONWIDTH +# error Scaling requires CONFIG_NXWM_TASKBAR_ICONWIDTH +# define CONFIG_NXWM_TASKBAR_ICONWIDTH 50 +# endif +# ifndef CONFIG_NXWM_TASKBAR_ICONHEIGHT +# error Scaling requires CONFIG_NXWM_TASKBAR_ICONHEIGHT +# define CONFIG_NXWM_TASKBAR_ICONHEIGHT 42 +# endif +#else +# undef CONFIG_NXWM_TASKBAR_ICONWIDTH +# define CONFIG_NXWM_TASKBAR_ICONWIDTH 25 // Used below +# undef CONFIG_NXWM_TASKBAR_ICONHEIGHT +# define CONFIG_NXWM_TASKBAR_ICONHEIGHT 21 // Used below (NOT) +#endif + /** * At present, all icons are 25 pixels in "width" and, hence require a * task bar of at least that size. @@ -230,9 +248,11 @@ #ifndef CONFIG_NXWM_TASKBAR_WIDTH # if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM) -# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*CONFIG_NXWM_TASKBAR_HSPACING) +# define CONFIG_NXWM_TASKBAR_WIDTH \ + (CONFIG_NXWM_TASKBAR_ICONWIDTH+2*CONFIG_NXWM_TASKBAR_HSPACING) # else -# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*CONFIG_NXWM_TASKBAR_VSPACING) +# define CONFIG_NXWM_TASKBAR_WIDTH \ + (CONFIG_NXWM_TASKBAR_ICONWIDTH+2*CONFIG_NXWM_TASKBAR_VSPACING) # endif #endif diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx index 226ebe7bb..3a5e44aec 100644 --- a/NxWidgets/nxwm/src/ctaskbar.cxx +++ b/NxWidgets/nxwm/src/ctaskbar.cxx @@ -46,6 +46,7 @@ #include "crect.hxx" #include "cwidgetcontrol.hxx" #include "cnxtkwindow.hxx" +#include "cscaledbitmap.hxx" #include "cwindowmessenger.hxx" #include "ctaskbar.hxx" @@ -456,12 +457,43 @@ bool CTaskbar::startApplication(IApplication *app, bool minimized) NXWidgets::IBitmap *bitmap = app->getIcon(); +#ifdef CONFIG_NXWM_TASKBAR_ICONSCALE + // Create a CScaledBitmap to scale the bitmap icon + + NXWidgets::CScaledBitmap *scaler = (NXWidgets::CScaledBitmap *)0; + if (bitmap) + { + // Create a CScaledBitmap to scale the bitmap icon + + struct nxgl_size_s iconSize; + iconSize.w = CONFIG_NXWM_TASKBAR_ICONWIDTH; + iconSize.h = CONFIG_NXWM_TASKBAR_ICONHEIGHT; + + scaler = new NXWidgets::CScaledBitmap(bitmap, iconSize); + if (!scaler) + { + return false; + } + } +#endif + // Create a CImage instance to manage the applications icon. Assume the // minimum size in case no bitmap is provided (bitmap == NULL) int w = 1; int h = 1; +#ifdef CONFIG_NXWM_TASKBAR_ICONSCALE + if (scaler) + { + w = scaler->getWidth(); + h = scaler->getHeight(); + } + + NXWidgets::CImage *image = + new NXWidgets::CImage(control, 0, 0, w, h, scaler, 0); + +#else if (bitmap) { w = bitmap->getWidth(); @@ -471,6 +503,8 @@ bool CTaskbar::startApplication(IApplication *app, bool minimized) NXWidgets::CImage *image = new NXWidgets::CImage(control, 0, 0, w, h, bitmap, 0); +#endif + if (!image) { return false; @@ -490,8 +524,8 @@ bool CTaskbar::startApplication(IApplication *app, bool minimized) // the task bar struct STaskbarSlot slot; - slot.app = app; - slot.image = image; + slot.app = app; + slot.image = image; m_slots.push_back(slot); // Initialize the application states |