diff options
Diffstat (limited to 'NxWidgets/nxwm/src/capplicationwindow.cxx')
-rw-r--r-- | NxWidgets/nxwm/src/capplicationwindow.cxx | 158 |
1 files changed, 155 insertions, 3 deletions
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx index 0fb6f387a..ad57ba4b2 100644 --- a/NxWidgets/nxwm/src/capplicationwindow.cxx +++ b/NxWidgets/nxwm/src/capplicationwindow.cxx @@ -62,8 +62,7 @@ /** * CApplicationWindow Constructor * - * @param taskbar. A pointer to the parent task bar instance - * @param window. The window to be used by this application. + * @param taskbar. A pointer to the parent task bar instance. */ CApplicationWindow::CApplicationWindow(NXWidgets::CNxTkWindow *window) @@ -134,7 +133,7 @@ CApplicationWindow::~CApplicationWindow(void) } // We didn't create the window. That was done by the task bar, - // Be we will handle destruction of with window as a courtesy. + // But we will handle destruction of with window as a courtesy. if (m_window) { @@ -314,6 +313,14 @@ bool CApplicationWindow::open(void) m_windowLabel->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_LEFT); m_windowLabel->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER); m_windowLabel->setRaisesEvents(false); + + // Get the window control + + NXWidgets::CWidgetControl *windowControl = m_window->getWidgetControl(); + + // Register to receive callbacks on a few select window events + + windowControl->addWindowEventHandler(this); return true; } @@ -381,6 +388,151 @@ void CApplicationWindow::hide(void) } /** + * Recover the contained NXTK window instance + * + * @return. The window used by this application + */ + +NXWidgets::INxWindow *CApplicationWindow::getWindow(void) const +{ + return static_cast<NXWidgets::INxWindow*>(m_window); +} + +/** + * Set the window label + * + * @param appname. The name of the application to place on the window + */ + +void CApplicationWindow::setWindowLabel(NXWidgets::CNxString &appname) +{ + m_windowLabel->setText(appname); +} + +/** + * Register to receive callbacks when toolbar icons are selected + */ + +void CApplicationWindow::registerCallbacks(IApplicationCallback *callback) +{ + m_callback = callback; +} + +/** + * Simulate a mouse click on the minimize icon. This method is only + * used during automated testing of NxWM. + */ + +#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN) +void CApplicationWindow::clickMinimizeIcon(int index) +{ + // Get the size and position of the widget + + struct nxgl_size_s imageSize; + m_minimizeImage->getSize(imageSize); + + struct nxgl_point_s imagePos; + m_minimizeImage->getPos(imagePos); + + // And click the image at its center + + m_minimizeImage->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1)); +} +#endif + +/** + * Simulate a mouse click on the stop applicaiton icon. This method is only + * used during automated testing of NxWM. + */ + +#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN) +void CApplicationWindow::clickStopIcon(int index) +{ + // Get the size and position of the widget + + struct nxgl_size_s imageSize; + m_stopImage->getSize(imageSize); + + struct nxgl_point_s imagePos; + m_stopImage->getPos(imagePos); + + // And click the image at its center + + m_stopImage->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1)); +} +#endif + +/** + * Handle an NX window mouse input event. + * + * @param e The event data. + */ + +#ifdef CONFIG_NX_MOUSE +void CApplicationWindow::handleMouseEvent(void) +{ + // The logic path here is tortuous but flexible: + // + // 1. A listener thread receives mouse input and injects that into NX + // 2. In the multi-user mode, this will send a message to the NX server + // 3. The NX server will determine which window gets the mouse input + // and send a message to the listener. + // 4. The listener will call the NX message dispatcher will will do the + // message callback. + // 5. The callback goes into an instance of NXWidgets::CCallback that is + // part of the CWidget control. + // 6. That callback will update mouse information then raise the + // mouse event, + // 7. Which will finally call this function -- still running deep on the + // stack in the listener thread. + // 8. This function will then call back into the wiget control to process + // the mouse input. + + // Get the CWidgetControl associated with the window + + NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); + + // And perform a poll + + control->pollEvents(); +} +#endif + +/** + * Handle a NX window keyboard input event. + */ + +#ifdef CONFIG_NX_KBD +void CApplicationWindow::handleKeyboardEvent(void) +{ + // The logic path here is tortuous but flexible: + // + // 1. A listener thread receives keyboard input and injects that into NX + // 2. In the multi-user mode, this will send a message to the NX server + // 3. The NX server will determine which window gets the keyboard input + // and send a message to the listener. + // 4. The listener will call the NX message dispatcher will will do the + // message callback. + // 5. The callback goes into an instance of NXWidgets::CCallback that is + // part of the CWidget control. + // 6. That callback will update keyboard information then raise the + // keyboard event, + // 7. Which will finally call this function -- still running deep on the + // stack in the listener thread. + // 8. This function will then call back into the wiget control to process + // the keyboard input. + + // Get the CWidgetControl associated with the window + + NXWidgets::CWidgetControl *control = m_window->getWidgetControl(); + + // And perform a poll + + control->pollEvents(); +} +#endif + +/** * Handle a mouse button click event. * * @param e The event data. |