apps/graphics/twm4nx: Trying (unsuccessfully so far) to get events from iconified windows.

This commit is contained in:
Gregory Nutt 2019-05-05 11:50:08 -06:00
parent 64cf50e2eb
commit 1e4dfd7193
4 changed files with 43 additions and 37 deletions

View File

@ -181,7 +181,12 @@ bool CIconWidget::initialize(FAR NXWidgets::IBitmap *ibitmap,
return false; return false;
} }
// Configure the image
image->setBorderless(true); image->setBorderless(true);
image->disable();
image->disableDrawing();
image->setRaisesEvents(true);
// Get the position icon text, centering horizontally if the image // Get the position icon text, centering horizontally if the image
// width is larger than the text width // width is larger than the text width
@ -208,7 +213,13 @@ bool CIconWidget::initialize(FAR NXWidgets::IBitmap *ibitmap,
return false; return false;
} }
// Configure the icon label
label->setFont(iconFont);
label->setBorderless(true); label->setBorderless(true);
label->disable();
label->disableDrawing();
label->setRaisesEvents(true);
// Add the CImage to to the containing widget // Add the CImage to to the containing widget
@ -578,16 +589,3 @@ bool CIconWidget::iconUngrab(FAR struct SEventMsg *eventmsg)
m_twm4nx->setCursorImage(&CONFIG_TWM4NX_CURSOR_IMAGE); m_twm4nx->setCursorImage(&CONFIG_TWM4NX_CURSOR_IMAGE);
return false; return false;
} }
/**
* Draw the area of this widget that falls within the clipping region.
* Called by the redraw() function to draw all visible regions.
* @param port The NXWidgets::CGraphicsPort to draw to.
* @see redraw()
*/
void CIconWidget::drawContents(NXWidgets::CGraphicsPort *port)
{
port->drawFilledRect(getX(), getY(), getWidth(), getHeight(),
getBackgroundColor());
}

View File

@ -332,7 +332,15 @@ bool CWindow::initialize(FAR const char *name,
return false; return false;
} }
enableWidgets(); // Initialize the icon widget
m_iconWidget->disable();
m_iconWidget->disableDrawing();
m_iconWidget->setRaisesEvents(true);
// Re-enable toolbar widgets
enableToolbarWidgets();
return true; return true;
} }
@ -473,11 +481,16 @@ void CWindow::iconify(void)
m_modal = false; m_modal = false;
m_nxWin->modal(false); m_nxWin->modal(false);
// Raise the icon window and lower the main window // Enable and redraw the icon widget and lower the main window
m_iconified = true; m_iconified = true;
m_nxWin->lower(); m_nxWin->lower();
m_iconOn = true; m_iconOn = true;
m_iconWidget->enable();
m_iconWidget->enableDrawing();
m_iconWidget->redraw();
m_nxWin->synchronize(); m_nxWin->synchronize();
} }
} }
@ -488,11 +501,15 @@ void CWindow::deIconify(void)
if (isIconified()) if (isIconified())
{ {
// Raise the main window and lower the icon window // Raise the main window and hide the icon width
m_iconified = false; m_iconified = false;
m_nxWin->raise(); m_nxWin->raise();
m_iconOn = false; m_iconOn = false;
m_iconWidget->disableDrawing();
m_iconWidget->disable();
m_nxWin->synchronize(); m_nxWin->synchronize();
} }
} }
@ -769,9 +786,9 @@ bool CWindow::createToolbar(void)
bool CWindow::updateToolbarLayout(void) bool CWindow::updateToolbarLayout(void)
{ {
// Disable widget drawing and events while we do this // Disable toolbar widget drawing and events while we do this
disableWidgets(); disableToolbarWidgets();
// Reposition all right buttons. Change the width of the // Reposition all right buttons. Change the width of the
// toolbar does not effect the left side spacing. // toolbar does not effect the left side spacing.
@ -819,15 +836,15 @@ bool CWindow::updateToolbarLayout(void)
titleSize.w = m_tbRightX - m_tbLeftX - CONFIG_TWM4NX_FRAME_VSPACING + 1; titleSize.w = m_tbRightX - m_tbLeftX - CONFIG_TWM4NX_FRAME_VSPACING + 1;
bool success = m_tbTitle->resize(titleSize.w, titleSize.h); bool success = m_tbTitle->resize(titleSize.w, titleSize.h);
enableWidgets(); enableToolbarWidgets();
return success; return success;
} }
/** /**
* Disable widget drawing and widget events. * Disable toolbar widget drawing and widget events.
*/ */
bool CWindow::disableWidgets(void) bool CWindow::disableToolbarWidgets(void)
{ {
for (int btindex = 0; btindex < NTOOLBAR_BUTTONS; btindex++) for (int btindex = 0; btindex < NTOOLBAR_BUTTONS; btindex++)
{ {
@ -845,10 +862,10 @@ bool CWindow::disableWidgets(void)
} }
/** /**
* Enable widget drawing and widget events. * Enable toolbar widget drawing and widget events.
*/ */
bool CWindow::enableWidgets(void) bool CWindow::enableToolbarWidgets(void)
{ {
for (int btindex = 0; btindex < NTOOLBAR_BUTTONS; btindex++) for (int btindex = 0; btindex < NTOOLBAR_BUTTONS; btindex++)
{ {
@ -1434,7 +1451,7 @@ bool CWindow::toolbarUngrab(FAR struct SEventMsg *eventmsg)
// Restore the normal cursor image // Restore the normal cursor image
m_twm4nx->setCursorImage(&CONFIG_TWM4NX_CURSOR_IMAGE); m_twm4nx->setCursorImage(&CONFIG_TWM4NX_CURSOR_IMAGE);
return false; return true;
} }
/** /**

View File

@ -187,15 +187,6 @@ namespace Twm4Nx
bool iconUngrab(FAR struct SEventMsg *eventmsg); bool iconUngrab(FAR struct SEventMsg *eventmsg);
/**
* Draw the area of this widget that falls within the clipping region.
* Called by the redraw() function to draw all visible regions.
* @param port The NXWidgets::CGraphicsPort to draw to.
* @see redraw()
*/
void drawContents(NXWidgets::CGraphicsPort* port);
/** /**
* Copy constructor is protected to prevent usage. * Copy constructor is protected to prevent usage.
*/ */

View File

@ -214,16 +214,16 @@ namespace Twm4Nx
bool updateToolbarLayout(void); bool updateToolbarLayout(void);
/** /**
* Disable widget drawing and widget events. * Disable toolbar widget drawing and widget events.
*/ */
bool disableWidgets(void); bool disableToolbarWidgets(void);
/** /**
* Enable widget drawing and widget events. * Enable toolbar widget drawing and widget events.
*/ */
bool enableWidgets(void); bool enableToolbarWidgets(void);
/** /**
* After the toolbar was grabbed, it may be dragged then dropped, or it * After the toolbar was grabbed, it may be dragged then dropped, or it