2012-03-22 22:22:59 +01:00
|
|
|
/****************************************************************************
|
2018-09-17 01:23:45 +02:00
|
|
|
* apps/include/graphics/nxwidgets/ckeypad.hxx
|
2012-03-22 22:22:59 +01:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2012-03-22 22:22:59 +01:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-03-22 22:22:59 +01:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2012-03-22 22:22:59 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2018-09-17 01:23:45 +02:00
|
|
|
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
|
|
|
|
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
|
2012-03-22 22:22:59 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
2014-04-14 00:26:44 +02:00
|
|
|
|
2012-03-22 22:22:59 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <nuttx/nx/nxglib.h>
|
|
|
|
|
2018-09-17 01:23:45 +02:00
|
|
|
#include "graphics/nxwidgets/cbuttonarray.hxx"
|
2012-03-22 22:22:59 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-Processor Definitions
|
|
|
|
****************************************************************************/
|
2014-04-14 00:26:44 +02:00
|
|
|
|
2012-03-22 22:22:59 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Implementation Classes
|
|
|
|
****************************************************************************/
|
2014-04-14 00:26:44 +02:00
|
|
|
|
2012-03-22 22:22:59 +01:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
|
|
|
namespace NXWidgets
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Forward references
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CWidgetControl;
|
|
|
|
class CWidgetStyle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extends the CButtonArray class to support a alphanumeric keypad.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CKeypad : public CButtonArray
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
NXHANDLE m_hNxServer; /**< NX server handle */
|
|
|
|
bool m_numeric; /**< True: Numeric keypad, False: Alpha */
|
|
|
|
|
|
|
|
/**
|
2020-02-22 19:52:12 +01:00
|
|
|
* Configure the keypad for the currently selected display mode.
|
2012-03-22 22:22:59 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
void configureKeypadMode(void);
|
2014-04-14 00:26:44 +02:00
|
|
|
|
2012-03-22 22:22:59 +01:00
|
|
|
/**
|
|
|
|
* Copy constructor is protected to prevent usage.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline CKeypad(const CKeypad &keypad) : CButtonArray(keypad) { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor for buttons that display a string.
|
|
|
|
*
|
|
|
|
* @param pWidgetControl The widget control for the display.
|
|
|
|
* @param hNxServer The NX server that will receive the keyboard input
|
|
|
|
* @param x The x coordinate of the keypad, relative to its parent.
|
|
|
|
* @param y The y coordinate of the keypad, relative to its parent.
|
|
|
|
* @param width The width of the keypad
|
|
|
|
* @param height The height of the keypad
|
|
|
|
* @param style The style that the button should use. If this is not
|
|
|
|
* specified, the button will use the global default widget
|
|
|
|
* style.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CKeypad(CWidgetControl *pWidgetControl, NXHANDLE hNxServer,
|
|
|
|
nxgl_coord_t x, nxgl_coord_t y,
|
|
|
|
nxgl_coord_t width, nxgl_coord_t height,
|
2022-10-15 19:55:16 +02:00
|
|
|
CWidgetStyle *style = NULL);
|
2012-03-22 22:22:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CKeypad Destructor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline ~CKeypad(void) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current keypad display mode
|
|
|
|
*
|
|
|
|
* @return True: keypad is in numeric mode. False: alphanumeric.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline const bool isNumericKeypad(void) const
|
|
|
|
{
|
|
|
|
return m_numeric;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current keypad display mode
|
|
|
|
*
|
|
|
|
* @param mode True: put keypad in numeric mode. False: in alphanumeric.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inline void setKeypadMode(bool numeric)
|
|
|
|
{
|
|
|
|
m_numeric = numeric;
|
|
|
|
configureKeypadMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Catch button clicks.
|
|
|
|
*
|
|
|
|
* @param x The x coordinate of the click.
|
|
|
|
* @param y The y coordinate of the click.
|
|
|
|
*/
|
|
|
|
|
|
|
|
virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __cplusplus
|
|
|
|
|
2018-09-17 01:23:45 +02:00
|
|
|
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
|