forked from xuos/xiuos
Add nuttx to the system framework, which is 10.1.0
This commit is contained in:
112
Ubiquitous/Nuttx/apps/include/builtin/builtin.h
Normal file
112
Ubiquitous/Nuttx/apps/include/builtin/builtin.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/****************************************************************************
|
||||
* apps/include/builtin/builtin.h
|
||||
*
|
||||
* Originally by:
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Author: Uros Platise <uros.platise@isotel.eu>
|
||||
*
|
||||
* With subsequent updates, modifications, and general maintenance by:
|
||||
*
|
||||
* Copyright (C) 2012-2013, 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_BUILTIN_BUILTIN_H
|
||||
#define __APPS_INCLUDE_BUILTIN_BUILTIN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_builtin
|
||||
*
|
||||
* Description:
|
||||
* Executes builtin applications registered during 'make context' time.
|
||||
* New application is run in a separate task context (and thread).
|
||||
*
|
||||
* Input Parameter:
|
||||
* filename - Name of the linked-in binary to be started.
|
||||
* argv - Argument list
|
||||
* redirfile - If output if redirected, this parameter will be non-NULL
|
||||
* and will provide the full path to the file.
|
||||
* oflags - If output is redirected, this parameter will provide the
|
||||
* open flags to use. This will support file replacement
|
||||
* of appending to an existing file.
|
||||
*
|
||||
* Returned Value:
|
||||
* This is an end-user function, so it follows the normal convention:
|
||||
* Returns the PID of the exec'ed module. On failure, it.returns
|
||||
* -1 (ERROR) and sets errno appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
FAR const char *redirfile, int oflags);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_BUILTIN_BUILTIN_H */
|
||||
190
Ubiquitous/Nuttx/apps/include/canutils/canlib.h
Normal file
190
Ubiquitous/Nuttx/apps/include/canutils/canlib.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/****************************************************************************
|
||||
* apps/include/canutils/canlib.h
|
||||
* Various non-standard APIs to support canutils. All non-standard and
|
||||
* intended only for internal use.
|
||||
*
|
||||
* Copyright (C) 2016 Sebastien Lorquet Nutt. All rights reserved.
|
||||
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_CANUTILS_CANLIB_H
|
||||
#define __APPS_INCLUDE_CANUTILS_CANLIB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: canlib_setbaud
|
||||
*
|
||||
* Description:
|
||||
* Wrapper for CANIOC_SET_BITTIMING
|
||||
*
|
||||
* Input Parameter:
|
||||
* fd - file descriptor of an opened can device
|
||||
* baud - baud rate to use on the CAN bus
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canlib_setbaud(int fd, int bauds);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: canlib_getbaud
|
||||
*
|
||||
* Description:
|
||||
* Wrapper for CANIOC_GET_BITTIMING
|
||||
*
|
||||
* Input Parameter:
|
||||
* fd - file descriptor of an opened can device
|
||||
* baud - pointer to a buffer to store the current baud rate
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canlib_getbaud(int fd, FAR int *bauds);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: canlib_setloopback
|
||||
*
|
||||
* Description:
|
||||
* Wrapper for CANIOC_SET_CONNMODES. When loopback mode is enabled, the CAN
|
||||
* peripheral transmits on the bus, but only receives its own sent messages.
|
||||
*
|
||||
* Input Parameter:
|
||||
* fd - file descriptor of an opened can device
|
||||
* loopback - whether to use loopback mode.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: canlib_getloopback
|
||||
*
|
||||
* Description:
|
||||
* Wrapper for CANIOC_GET_CONNMODES.
|
||||
*
|
||||
* Input Parameter:
|
||||
* fd - file descriptor of an opened can device
|
||||
* loopback - pointer to a buffer to store the current loopback mode state.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canlib_setloopback(int fd, bool loop);
|
||||
|
||||
int canlib_getloopback(int fd, FAR bool *loop);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: canlib_setsilent
|
||||
*
|
||||
* Description:
|
||||
* Wrapper for CANIOC_SET_CONNMODES. When silent mode is enabled, the CAN
|
||||
* peripheral never transmits on the bus, but receives all bus traffic.
|
||||
*
|
||||
* Input Parameter:
|
||||
* fd - file descriptor of an opened can device
|
||||
* loopback - whether to use loopback mode.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canlib_setsilent(int fd, bool silent);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: canlib_getsilent
|
||||
*
|
||||
* Description:
|
||||
* Wrapper for CANIOC_GET_CONNMODES.
|
||||
*
|
||||
* Input Parameter:
|
||||
* fd - file descriptor of an opened can device
|
||||
* loopback - pointer to a buffer to store the current silent mode state.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. Otherwise -1 (ERROR)
|
||||
* is returned with the errno variable set to indicate the
|
||||
* nature of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canlib_getsilent(int fd, FAR bool *silent);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_CANUTILS_CANLIB_H */
|
||||
132
Ubiquitous/Nuttx/apps/include/canutils/obd.h
Normal file
132
Ubiquitous/Nuttx/apps/include/canutils/obd.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/****************************************************************************
|
||||
* include/canutils/obd.h
|
||||
*
|
||||
* Copyright (C) 2017 Alan Carvalho de Assis. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_CANUTILS_OBD_H
|
||||
#define __APPS_INCLUDE_CANUTILS_OBD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/can/can.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* CAN Modes */
|
||||
|
||||
enum
|
||||
{
|
||||
CAN_STD = 0,
|
||||
CAN_EXT,
|
||||
};
|
||||
|
||||
/* OBD-II structure */
|
||||
|
||||
struct obd_dev_s
|
||||
{
|
||||
struct can_msg_s can_txmsg; /* TX Message */
|
||||
struct can_msg_s can_rxmsg; /* RX Message */
|
||||
struct canioc_bittiming_s can_bt; /* Current bitrate */
|
||||
uint8_t can_mode; /* Current mode (Standard or Extended) */
|
||||
int can_fd; /* File Descriptor of CAN Device */
|
||||
#ifdef CONFIG_MULTIFRAME_SUPPORT
|
||||
uint8_t data[4096]; /* Up to 4096 bytes */
|
||||
#else
|
||||
uint8_t data[8]; /* Single Frame = 8 bytes */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Name: obd_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the OBD-II with initial baudrate
|
||||
*
|
||||
* Returns a obd_dev_s with initial values or NULL if error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct obd_dev_s *obd_init(FAR char *devfile, int baudate, int mode);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: obd_sent_request
|
||||
*
|
||||
* Description:
|
||||
* Send a "Request Message" to ECUs with requested PID.
|
||||
*
|
||||
* It will return an error case the message fails to be sent.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int obd_send_request(FAR struct obd_dev_s *dev, uint8_t opmode, uint8_t pid);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: obd_wait_response
|
||||
*
|
||||
* Description:
|
||||
* Wait for a message from ECUs with requested PID that was sent using
|
||||
* obd_send_request().
|
||||
*
|
||||
* It will return an error case it doesn't receive the msg after the elapsed
|
||||
* "timeout" time.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int obd_wait_response(FAR struct obd_dev_s *dev, uint8_t opmode, uint8_t pid,
|
||||
int timeout);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: obd_decode_pid
|
||||
*
|
||||
* Description:
|
||||
* Decode the value returned for a determined PID.
|
||||
*
|
||||
* It will return the decode PID as string or NULL if error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR char *obd_decode_pid(FAR struct obd_dev_s *dev, uint8_t pid);
|
||||
|
||||
#endif /*__APPS_INCLUDE_CANUTILS_OBD_H */
|
||||
73
Ubiquitous/Nuttx/apps/include/canutils/obd_frame.h
Normal file
73
Ubiquitous/Nuttx/apps/include/canutils/obd_frame.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* include/canutils/obd_frame.h
|
||||
*
|
||||
* Copyright (C) 2017 Alan Carvalho de Assis. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_CANUTILS_OBD_FRAME_H
|
||||
#define __APPS_INCLUDE_CANUTILS_OBD_FRAME_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Frame Type
|
||||
*
|
||||
* Bits 7-4 of CAN Data 0
|
||||
*
|
||||
*/
|
||||
|
||||
#define OBD_FRAME_TYPE(x) (x & 0xf0) /* Mask bits 4-7 */
|
||||
|
||||
#define OBD_SINGLE_FRAME (0 << 4) /* Single frame */
|
||||
#define OBD_FIRST_FRAME (1 << 4) /* First frame */
|
||||
#define OBD_CONSEC_FRAME (2 << 4) /* Consecutive frame */
|
||||
#define OBD_FLWCTRL_FRAME (3 << 4) /* Flow control frame */
|
||||
|
||||
/* Single Frame fields */
|
||||
|
||||
#define OBD_SF_DATA_LEN(x) (x & 0xf) /* Data Length of Single Frame */
|
||||
|
||||
/* First Frame fields */
|
||||
|
||||
#define OBD_FF_DATA_LEN_D0(x) ((x & 0xf) << 8) /* Data Length of First Frame D0 */
|
||||
#define OBD_FF_DATA_LEN_D1(x) (x & 0xff) /* Data Length of First Frame D1 */
|
||||
|
||||
/* Consecutive Frame fields */
|
||||
|
||||
#define OBD_CF_SEQ_NUM(x) (x & 0xf) /* Consecutive Sequence Number */
|
||||
|
||||
/* Flow Control Frame fields */
|
||||
|
||||
#define OBD_FC_FLOW_STATUS(x) (x & 0xf) /* Flow Control Status */
|
||||
|
||||
#endif /* __APPS_INCLUDE_CANUTILS_OBD_FRAME_H */
|
||||
138
Ubiquitous/Nuttx/apps/include/canutils/obd_pid.h
Normal file
138
Ubiquitous/Nuttx/apps/include/canutils/obd_pid.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/****************************************************************************
|
||||
* include/canutils/obd_pid.h
|
||||
*
|
||||
* Copyright (C) 2017 Alan Carvalho de Assis. All rights reserved.
|
||||
* Author: Alan Carvalho de Assis <acassis@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_CANUTILS_OBD_PID_H
|
||||
#define __APPS_INCLUDE_CANUTILS_OBD_PID_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* PID REQUEST */
|
||||
|
||||
#define OBD_PID_STD_REQUEST 0x7df /* Standard PID REQUEST Message ID = 0x7df or 0x7e0 */
|
||||
#define OBD_PID_EXT_REQUEST 0x18db33f1 /* Extended PID REQUEST Messaged ID = 0x18db33f1 */
|
||||
|
||||
/* PID RESPONSE */
|
||||
|
||||
#define OBD_PID_STD_RESPONSE 0x7e8 /* Standard PID RESPONSE Message ID = 0x7e8 */
|
||||
#define OBD_PID_EXT_RESPONSE 0x18daf110 /* Extended PID RESPONSE Message ID = 0x18daf111 or 0x18daf11d */
|
||||
|
||||
#define OBD_RESP_BASE 0x40 /* Response mode = (0x40 + OpMode) */
|
||||
|
||||
/* OBD Operation Modes */
|
||||
|
||||
#define OBD_SHOW_DATA 0x01 /* Used to read current data from vehicle */
|
||||
#define OBD_SHOW_FREEZED_DATA 0x02 /* Used to read freezed data from vehicle */
|
||||
#define OBD_SHOW_DTC 0x03 /* Show Diagnostic Trouble Codes */
|
||||
#define OBD_CLEAR_DTC 0x04 /* Clear Diagnostic Trouble Codes stored in the vehicle */
|
||||
#define OBD_TEST_RESULT1 0x05 /* Test Results */
|
||||
#define OBD_TEST_RESULT2 0x06 /* Test Results */
|
||||
#define OBD_SHOW_PEND_DTC 0x07 /* Show Pending Diagnostic Trouble Codes */
|
||||
#define OBD_CONTROL_OPERATION 0x08 /* Control Operation of on-board component/system */
|
||||
#define OBD_RQST_VEHICLE_INFO 0x09 /* Request vehicle information */
|
||||
#define OBD_PERMANENT_DTC 0x0a /* Permanent Diagnostic Trouble Codes */
|
||||
|
||||
/* Basic Standardized Sensor/Status */
|
||||
|
||||
#define OBD_PID_SUPPORTED 0x00 /* PIDs supported 00-20 */
|
||||
#define OBD_PID_STATUS 0x01 /* Monitor status since DTCs cleared */
|
||||
#define OBD_PID_STATUS_FREEZE_FRAME 0x02 /* DTC that caused required freeze frame data storage */
|
||||
#define OBD_PID_FUEL_SYSTEM 0x03 /* Fuel system 1 and 2 status */
|
||||
#define OBD_PID_ENGINE_LOAD 0x04 /* Calculated ENGINE LOAD Value */
|
||||
#define OBD_PID_ENGINE_TEMPERATURE 0x05 /* Engine Coolant Temperature */
|
||||
#define OBD_PID_SHORT_TERM_FUEL_TRIM13 0x06 /* Short Term Fuel Trim - Bank 1,3 */
|
||||
#define OBD_PID_LONG_TERM_FUEL_TRIM13 0x07 /* Long Term Fuel Trim - Bank 1,3 */
|
||||
#define OBD_PID_SHORT_TERM_FUEL_TRIM24 0x08 /* Short Term Fuel Trim - Bank 2,4 */
|
||||
#define OBD_PID_LONG_TERM_FUEL_TRIM24 0x09 /* Long Term Fuel Trim - Bank 2,4 */
|
||||
#define OBD_PID_FUEL_RAIL_PRESSURE 0x0a /* Fuel Rail Pressure (gauge) */
|
||||
#define OBD_PID_MANIFOLD_ABS_PRESSURE 0x0b /* Intake Manifold Absolute Pressure (kPa) */
|
||||
#define OBD_PID_RPM 0x0c /* Engine RPM */
|
||||
#define OBD_PID_SPEED 0x0d /* Vehicle Speed Sensor */
|
||||
#define OBD_PID_SPARK_ADVANCE 0x0e /* Ignition Timing Advance for #1 Cylinder */
|
||||
#define OBD_PID_INTAKE_AIR_TEMPERATURE 0x0f /* Intake Air Temperature */
|
||||
#define OBD_PID_MASS_AIR_FLOW 0x10 /* Air Flow Rate from Mass Air Flow Sensor */
|
||||
#define OBD_PID_THROTTLE_POSITION 0x11 /* Absolute Throttle Position (0-100%) */
|
||||
#define OBD_PID_AIR_STATUS 0x12 /* Commanded Secondary Air Status (Bit Encoded) */
|
||||
#define OBD_PID_LOC_OXYGEN_SENSOR 0x13 /* Location of Oxygen Sensors (Bit Encoded) */
|
||||
#define OBD_PID_OXYGEN_BANK1_SENSOR1 0x14 /* Bank 1 - Sensor 1 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK1_SENSOR2 0x15 /* Bank 1 - Sensor 2 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK1_SENSOR3 0x16 /* Bank 1 - Sensor 3 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK1_SENSOR4 0x17 /* Bank 1 - Sensor 4 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK2_SENSOR1 0x18 /* Bank 2 - Sensor 1 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK2_SENSOR2 0x19 /* Bank 2 - Sensor 2 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK2_SENSOR3 0x1a /* Bank 2 - Sensor 3 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_OXYGEN_BANK2_SENSOR4 0x1b /* Bank 2 - Sensor 4 Oxygen Sensor Output Voltage / Short Term Fuel Trim (V) */
|
||||
#define OBD_PID_STANDARD_COMPLIANCE 0x1c /* OBD standards this vehicle conforms to */
|
||||
#define OBD_PID_OXYGEN_SENSORS 0x1d /* Oxygen sensors present */
|
||||
#define OBD_PID_AUXILIARY_INPUT_STATUS 0x1e /* Auxiliary input status */
|
||||
#define OBD_PID_RUNTIME_ENGINE_START 0x1f /* Run time since engine start */
|
||||
|
||||
/* Extended Standardized Sensor_Status */
|
||||
|
||||
#define OBD_PID_SUPPORTED_EXT 0x20 /* PIDs supported 21-40 */
|
||||
#define OBD_PID_DIST_TRAVELED_MIL 0x21 /* Distance traveled with malfunction indicator lamp (MIL) on */
|
||||
#define OBD_PID_FUEL_RAIL_PRESS_VACUUM 0x22 /* Fuel Rail Pressure (relative to manifold vacuum) */
|
||||
#define OBD_PID_FUEL_RAIL_PRESS_DIR_INJ 0x23 /* Fuel Rail Pressure (diesel, or gasoline direct inject) */
|
||||
#define OBD_PID_O2S1_WR_LAMBDA_ERV 0x24 /* O2S1_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S2_WR_LAMBDA_ERV 0x25 /* O2S2_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S3_WR_LAMBDA_ERV 0x26 /* O2S3_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S4_WR_LAMBDA_ERV 0x27 /* O2S4_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S5_WR_LAMBDA_ERV 0x28 /* O2S5_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S6_WR_LAMBDA_ERV 0x29 /* O2S6_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S7_WR_LAMBDA_ERV 0x2a /* O2S7_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_O2S8_WR_LAMBDA_ERV 0x2b /* O2S8_WR_lambda(1): Equivalence Ratio Voltage */
|
||||
#define OBD_PID_COMMANDED_EGR 0x2c /* Commanded EGR */
|
||||
#define OBD_PID_EGR_ERROR 0x2d /* EGR Error */
|
||||
#define OBD_PID_CMD_EVAPORAT_PURGE 0x2e /* Commanded evaporative purge */
|
||||
#define OBD_PID_FUEL_LEVEL_INPUT 0x2f /* Fuel Level Input */
|
||||
#define OBD_PID_WARMUP_CODES_CLEARED 0x30 /* Number of warm-ups since codes cleared */
|
||||
#define OBD_PID_DIST_TRAV_CODES_CLEAR 0x31 /* Distance traveled since codes cleared */
|
||||
#define OBD_PID_EVAP_SYS_VAPOR_PRESS 0x32 /* Evap. System Vapor Pressure */
|
||||
#define OBD_PID_BAROMETRIC_PRESSURE 0x33 /* Barometric pressure */
|
||||
#define OBD_PID_O2S1_WR_LAMBDA_ERC 0x34 /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S2_WR_LAMBDA_ERC 0x35 /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S3_WR_LAMBDA_ERC 0x36 /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S4_WR_LAMBDA_ERC 0x37 /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S5_WR_LAMBDA_ERC 0x38 /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S6_WR_LAMBDA_ERC 0x39 /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S7_WR_LAMBDA_ERC 0x3a /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_O2S8_WR_LAMBDA_ERC 0x3b /* O2S1_WR_lambda(1): Equivalence Ratio Current */
|
||||
#define OBD_PID_CATAL_TEMP_BK1SS1 0x3c /* Catalyst Temperature Bank 1, Sensor 1 */
|
||||
#define OBD_PID_CATAL_TEMP_BK2SS1 0x3d /* Catalyst Temperature Bank 2, Sensor 1 */
|
||||
#define OBD_PID_CATAL_TEMP_BK1SS2 0x3e /* Catalyst Temperature Bank 1, Sensor 2 */
|
||||
#define OBD_PID_CATAL_TEMP_BK2SS2 0x3f /* Catalyst Temperature Bank 2, Sensor 2 */
|
||||
|
||||
#endif /* __APPS_INCLUDE_CANUTILS_OBD_PID_H */
|
||||
61
Ubiquitous/Nuttx/apps/include/fsutils/flash_eraseall.h
Normal file
61
Ubiquitous/Nuttx/apps/include/fsutils/flash_eraseall.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
* apps/include/fsutils/flash_eraseall.h
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FSUTILS_FLASH_ERASEALL_H
|
||||
#define __APPS_INCLUDE_FSUTILS_FLASH_ERASEALL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: flash_eraseall
|
||||
*
|
||||
* Description:
|
||||
* Call a block driver with the MDIOC_BULKERASE ioctl command. This will
|
||||
* cause the MTD driver to erase all of the flash.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int flash_eraseall(FAR const char *driver);
|
||||
|
||||
#endif /* __APPS_INCLUDE_FSUTILS_FLASH_ERASEALL_H */
|
||||
138
Ubiquitous/Nuttx/apps/include/fsutils/inifile.h
Normal file
138
Ubiquitous/Nuttx/apps/include/fsutils/inifile.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/****************************************************************************
|
||||
* apps/include/fsutils/inifile.h
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FSUTILS_INIFILE_H
|
||||
#define __APPS_INCLUDE_FSUTILS_INIFILE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef FAR void *INIHANDLE;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inifile_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize for access to the INI file 'inifile_name'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
INIHANDLE inifile_initialize(FAR const char *inifile_name);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inifile_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Free resources commit to INI file parsing
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inifile_uninitialize(INIHANDLE handle);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inifile_read_string
|
||||
*
|
||||
* Description:
|
||||
* Obtains the specified string value for the specified variable name
|
||||
* within the specified section of the INI file. The receiver of the
|
||||
* value string should call inifile_free_string when it no longer needs
|
||||
* the memory held by the value string.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR char *inifile_read_string(INIHANDLE handle,
|
||||
FAR const char *section,
|
||||
FAR const char *variable,
|
||||
FAR const char *defvalue);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inifile_read_integer
|
||||
*
|
||||
* Description:
|
||||
* Obtains the specified integer value for the specified variable name
|
||||
* within the specified section of the INI file
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
long inifile_read_integer(INIHANDLE handle,
|
||||
FAR const char *section,
|
||||
FAR const char *variable,
|
||||
FAR long defvalue);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: inifile_free_string
|
||||
*
|
||||
* Description:
|
||||
* Release resources allocated for the value string previously obtained
|
||||
* from inifile_read_string. The purpose of this inline function is to
|
||||
* hide the memory allocator used by this implementation.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void inifile_free_string(FAR char *value);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_FSUTILS_INIFILE_H */
|
||||
220
Ubiquitous/Nuttx/apps/include/fsutils/ipcfg.h
Normal file
220
Ubiquitous/Nuttx/apps/include/fsutils/ipcfg.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/****************************************************************************
|
||||
* apps/include/fsutils/ipcfg.h
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FSUTILS_IPCFG_H
|
||||
#define __APPS_INCLUDE_FSUTILS_IPCFG_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Prototype enumerations are bit encoded */
|
||||
|
||||
#define _IPCFG_STATIC (1 << 0) /* Bit 0: Have static addresses */
|
||||
#define _IPCFG_DHCP (1 << 1) /* Bit 1: Use DHCP (IPv4) */
|
||||
#define _IPCFG_AUTOCONF (1 << 1) /* Bit 1: Use ICMPv4 auto-configuration */
|
||||
|
||||
#define IPCFG_HAVE_STATIC(p) (((p) & _IPCFG_STATIC) != 0)
|
||||
#define IPCFG_USE_DHCP(p) (((p) & _IPCFG_DHCP) != 0)
|
||||
#define IPCFG_USE_AUTOCONF(p) (((p) & _IPCFG_AUTOCONF) != 0)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* The structure contains the parsed content of the ipcfg-<dev> file.
|
||||
* Summary of file content:
|
||||
*
|
||||
* Common Settings:
|
||||
*
|
||||
* DEVICE=name
|
||||
* where name is the name of the physical device.
|
||||
*
|
||||
* IPv4 Settings:
|
||||
*
|
||||
* IPv4PROTO=protocol
|
||||
* where protocol is one of the following:
|
||||
*
|
||||
* none - No protocol selected
|
||||
* static - Use static IP
|
||||
* dhcp - The DHCP protocol should be used
|
||||
* fallback - Use DHCP with fall back static IP
|
||||
*
|
||||
* All of the following addresses are in network order. The special value
|
||||
* zero is used to indicate that the address is not available:
|
||||
*
|
||||
* IPv4IPADDR=address
|
||||
* where address is the IPv4 address. Used only with static or fallback
|
||||
* protocols.
|
||||
*
|
||||
* IPv4NETMASK=address
|
||||
* where address is the netmask. Used only with static or fallback
|
||||
* protocols.
|
||||
*
|
||||
* IPv4ROUTER=address
|
||||
* where address is the IPv4 default router address. Used only with
|
||||
* static or fallback protocols.
|
||||
*
|
||||
* IPv4DNS=address
|
||||
* where address is a (optional) name server address.
|
||||
*/
|
||||
|
||||
/* Values for the IPv4PROTO setting */
|
||||
|
||||
enum ipv4cfg_bootproto_e
|
||||
{
|
||||
IPv4PROTO_NONE = 0, /* 00: No protocol assigned */
|
||||
IPv4PROTO_STATIC = 1, /* 01: Use static IP */
|
||||
IPv4PROTO_DHCP = 2, /* 10: Use DHCP */
|
||||
IPv4PROTO_FALLBACK = 3 /* 11: Use DHCP with fall back static IP */
|
||||
};
|
||||
|
||||
struct ipv4cfg_s
|
||||
{
|
||||
enum ipv4cfg_bootproto_e proto; /* Configure for static and/or DHCP */
|
||||
|
||||
/* The following fields are required for static/fallback configurations */
|
||||
|
||||
in_addr_t ipaddr; /* IPv4 address */
|
||||
in_addr_t netmask; /* Network mask */
|
||||
in_addr_t router; /* Default router */
|
||||
|
||||
/* The following fields are optional for dhcp and fallback configurations */
|
||||
|
||||
in_addr_t dnsaddr; /* Name server address */
|
||||
};
|
||||
|
||||
/* IPv6 Settings:
|
||||
*
|
||||
* IPv6BOOTPROTO=protocol
|
||||
* where protocol is one of the following:
|
||||
*
|
||||
* none - No protocol selected
|
||||
* static - Use static IP
|
||||
* autoconf - ICMPv6 auto-configuration should be used
|
||||
* fallback - Use auto-configuration with fall back static IP
|
||||
*
|
||||
* All of the following addresses are in network order. The special value
|
||||
* zero is used to indicate that the address is not available:
|
||||
*
|
||||
* IPv6IPADDR=address
|
||||
* where address is the IPv6 address. Used only with static or fallback
|
||||
* protocols.
|
||||
*
|
||||
* IPv6NETMASK=address
|
||||
* where address is the netmask. Used only with static or fallback
|
||||
* protocols.
|
||||
*
|
||||
* IPv6ROUTER=address
|
||||
* where address is the IPv6 default router address. Used only with
|
||||
* static or fallback protocols.
|
||||
*/
|
||||
|
||||
/* Values for the IPv6BOOTPROTO setting */
|
||||
|
||||
enum ipv6cfg_bootproto_e
|
||||
{
|
||||
IPv6PROTO_NONE = 0, /* 00: No protocol assigned */
|
||||
IPv6PROTO_STATIC = 1, /* 01: Use static IP */
|
||||
IPv6PROTO_AUTOCONF = 2, /* 10: Use ICMPv6 auto-configuration */
|
||||
IPv6PROTO_FALLBACK = 3 /* 11: Use auto-configuration with fall back static IP */
|
||||
};
|
||||
|
||||
struct ipv6cfg_s
|
||||
{
|
||||
enum ipv6cfg_bootproto_e proto; /* Configure for static and/or autoconfig */
|
||||
|
||||
/* The following fields are required for static/fallback configurations */
|
||||
|
||||
struct in6_addr ipaddr; /* IPv6 address */
|
||||
struct in6_addr netmask; /* Network mask */
|
||||
struct in6_addr router; /* Default router */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ipcfg_read
|
||||
*
|
||||
* Description:
|
||||
* Read and parse the IP configuration file for the specified network
|
||||
* device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* netdev - The network device. For examplel "eth0"
|
||||
* ipcfg - Pointer to a user provided location to receive the IP
|
||||
* configuration. Refers to either struct ipv4cfg_s or
|
||||
* ipv6cfg_s, depending on the value of af.
|
||||
* af - Identifies the address family whose IP configuration is
|
||||
* requested. May be either AF_INET or AF_INET6.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success; a negated errno value is returned on any
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ipcfg_read(FAR const char *netdev, FAR void *ipcfg, sa_family_t af);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ipcfg_write
|
||||
*
|
||||
* Description:
|
||||
* Write the IP configuration file for the specified network device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* netdev - The network device. For examplel "eth0"
|
||||
* ipcfg - The IP configuration to be written. Refers to either struct
|
||||
* ipv4cfg_s or ipv6cfg_s, depending on the value of af.
|
||||
* af - Identifies the address family whose IP configuration is
|
||||
* to be written. May be either AF_INET or AF_INET6.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success; a negated errno value is returned on any
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_IPCFG_WRITABLE
|
||||
int ipcfg_write(FAR const char *netdev, FAR const void *ipcfg,
|
||||
sa_family_t af);
|
||||
#endif
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_FSUTILS_IPCFG_H */
|
||||
150
Ubiquitous/Nuttx/apps/include/fsutils/mkfatfs.h
Normal file
150
Ubiquitous/Nuttx/apps/include/fsutils/mkfatfs.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
* apps/include/fsutils/mkfatfs.h
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2012, 2015, 2017 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FSUTILS_MKFATFS_H
|
||||
#define __APPS_INCLUDE_FSUTILS_MKFATFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define MKFATFS_DEFAULT_NFATS 2 /* 2: Default number of FATs */
|
||||
#define MKFATFS_DEFAULT_FATTYPE 0 /* 0: Autoselect FAT size */
|
||||
#define MKFATFS_DEFAULT_CLUSTSHIFT 0xff /* 0xff: Autoselect cluster size */
|
||||
#define MKFATFS_DEFAULT_VOLUMELABEL { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }
|
||||
#define MKFATFS_DEFAULT_BKUPBOOT 0 /* 0: Determine sector number of the backup boot sector */
|
||||
#define MKFATFS_DEFAULT_ROOTDIRENTS 0 /* 0: Autoselect number of root directory entries */
|
||||
#define MKFATFS_DEFAULT_RSVDSECCOUNT 0 /* 0: Autoselect number reserved sectors (usually 32) */
|
||||
#define MKFATFS_DEFAULT_HIDSEC 0 /* No hidden sectors */
|
||||
#define MKFATFS_DEFAULT_VOLUMEID 0 /* No volume ID */
|
||||
#define MKFATFS_DEFAULT_NSECTORS 0 /* 0: Use all sectors on device */
|
||||
|
||||
#define FAT_FORMAT_INITIALIZER \
|
||||
{ \
|
||||
MKFATFS_DEFAULT_NFATS, \
|
||||
MKFATFS_DEFAULT_FATTYPE, \
|
||||
MKFATFS_DEFAULT_CLUSTSHIFT, \
|
||||
MKFATFS_DEFAULT_VOLUMELABEL, \
|
||||
MKFATFS_DEFAULT_BKUPBOOT, \
|
||||
MKFATFS_DEFAULT_ROOTDIRENTS, \
|
||||
MKFATFS_DEFAULT_RSVDSECCOUNT, \
|
||||
MKFATFS_DEFAULT_HIDSEC, \
|
||||
MKFATFS_DEFAULT_VOLUMEID, \
|
||||
MKFATFS_DEFAULT_NSECTORS \
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* These are input parameters for the format. On return, these values may be
|
||||
* overwritten with actual values used in the format.
|
||||
*/
|
||||
|
||||
struct fat_format_s
|
||||
{
|
||||
uint8_t ff_nfats; /* Number of FATs */
|
||||
uint8_t ff_fattype; /* FAT size: 0 (autoselect), 12, 16, or 32 */
|
||||
uint8_t ff_clustshift; /* Log2 of sectors per cluster: 0-5, 0xff (autoselect) */
|
||||
uint8_t ff_volumelabel[11]; /* Volume label */
|
||||
uint16_t ff_backupboot; /* Sector number of the backup boot sector (0=use default)*/
|
||||
uint16_t ff_rootdirentries; /* Number of root directory entries */
|
||||
uint16_t ff_rsvdseccount; /* Reserved sectors */
|
||||
uint32_t ff_hidsec; /* Count of hidden sectors preceding fat */
|
||||
uint32_t ff_volumeid; /* FAT volume id */
|
||||
uint32_t ff_nsectors; /* Number of sectors from device to use: 0: Use all */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mkfatfs
|
||||
*
|
||||
* Description:
|
||||
* Make a FAT file system image on the specified block device. This
|
||||
* function can automatically format a FAT12 or FAT16 file system. By
|
||||
* tradition, FAT32 will only be selected is explicitly requested.
|
||||
*
|
||||
* Inputs:
|
||||
* pathname - the full path to a registered block driver
|
||||
* fmt - Describes characteristics of the desired filesystem
|
||||
*
|
||||
* Return:
|
||||
* Zero (OK) on success; -1 (ERROR) on failure with errno set appropriately:
|
||||
*
|
||||
* EINVAL - NULL block driver string, bad number of FATS in 'fmt', bad FAT
|
||||
* size in 'fmt', bad cluster size in 'fmt'
|
||||
* ENOENT - 'pathname' does not refer to anything in the filesystem.
|
||||
* ENOTBLK - 'pathname' does not refer to a block driver
|
||||
* EACCESS - block driver does not support write or geometry methods
|
||||
*
|
||||
* Assumptions:
|
||||
* - The caller must assure that the block driver is not mounted and not in
|
||||
* use when this function is called. The result of formatting a mounted
|
||||
* device is indeterminate (but likely not good).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_FSUTILS_MKFATFS_H */
|
||||
121
Ubiquitous/Nuttx/apps/include/fsutils/mksmartfs.h
Normal file
121
Ubiquitous/Nuttx/apps/include/fsutils/mksmartfs.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* apps/include/fsutils/mksmartfs.h
|
||||
*
|
||||
* Copyright (C) 2015 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FSUTILS_MKSMARTFS_H
|
||||
#define __APPS_INCLUDE_FSUTILS_MKSMARTFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: issmartfs
|
||||
*
|
||||
* Description:
|
||||
* Check a SMART (Sector Mapped Allocation for Really Tiny) Flash file
|
||||
* system image on the specified block device (must be a SMART device).
|
||||
*
|
||||
* Inputs:
|
||||
* pathname - the full path to a registered block driver
|
||||
*
|
||||
* Return:
|
||||
* Zero (OK) on success; -1 (ERROR) on failure with errno set appropriately:
|
||||
*
|
||||
* EINVAL - NULL block driver string
|
||||
* ENOENT - 'pathname' does not refer to anything in the filesystem.
|
||||
* ENOTBLK - 'pathname' does not refer to a block driver
|
||||
* EFTYPE - the block driver hasn't been formatted yet
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int issmartfs(FAR const char *pathname);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mksmartfs
|
||||
*
|
||||
* Description:
|
||||
* Make a SMART (Sector Mapped Allocation for Really Tiny) Flash file
|
||||
* system image on the specified block device (must be a SMART device).
|
||||
*
|
||||
* Inputs:
|
||||
* pathname - the full path to a registered block driver
|
||||
* nrootdirs - the number of Root Directory entries to support
|
||||
* on this device (supports multiple mount points).
|
||||
*
|
||||
* Return:
|
||||
* Zero (OK) on success; -1 (ERROR) on failure with errno set appropriately:
|
||||
*
|
||||
* EINVAL - NULL block driver string
|
||||
* ENOENT - 'pathname' does not refer to anything in the filesystem.
|
||||
* ENOTBLK - 'pathname' does not refer to a block driver
|
||||
* EACCESS - block driver does not support write or geometry methods or
|
||||
* is not a SMART device
|
||||
*
|
||||
* Assumptions:
|
||||
* - The caller must assure that the block driver is not mounted and not in
|
||||
* use when this function is called. The result of formatting a mounted
|
||||
* device is indeterminate (but likely not good).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
int mksmartfs(FAR const char *pathname, uint16_t sectorsize,
|
||||
uint8_t nrootdirs);
|
||||
#else
|
||||
int mksmartfs(FAR const char *pathname, uint16_t sectorsize);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_FSUTILS_MKSMARTFS_H */
|
||||
124
Ubiquitous/Nuttx/apps/include/fsutils/passwd.h
Normal file
124
Ubiquitous/Nuttx/apps/include/fsutils/passwd.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
* apps/include/fsutils/passwd.h
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FSUTILS_PASSWD_H
|
||||
#define __APPS_INCLUDE_FSUTILS_PASSWD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* passwd_verify() return value tests */
|
||||
|
||||
#define PASSWORD_VERIFY_MATCH(ret) (ret == 1)
|
||||
#define PASSWORD_VERIFY_NOMATCH(ret) (ret == 0)
|
||||
#define PASSWORD_VERIFY_ERROR(ret) (ret < 0)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: passwd_adduser
|
||||
*
|
||||
* Description:
|
||||
* Add a new user to the /etc/passwd file. If the user already exists,
|
||||
* then this function will fail with -EEXIST.
|
||||
*
|
||||
* Input Parameters:
|
||||
* username - Identifies the user to be added
|
||||
* password - The password for the new user
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FSUTILS_PASSWD_READONLY)
|
||||
int passwd_adduser(FAR const char *username, FAR const char *password);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: passwd_deluser
|
||||
*
|
||||
* Description:
|
||||
* Remove an existing user from the /etc/passwd file. If the user does
|
||||
* not exist, then this function will fail.
|
||||
*
|
||||
* Input Parameters:
|
||||
* username - Identifies the user to be deleted
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int passwd_deluser(FAR const char *username);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: passwd_update
|
||||
*
|
||||
* Description:
|
||||
* Change a user in the /etc/passwd file. If the user does not exist,
|
||||
* then this function will fail.
|
||||
*
|
||||
* Input Parameters:
|
||||
* username - Identifies the user whose password will be updated
|
||||
* password - The new password for the existing user
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int passwd_update(FAR const char *username, FAR const char *password);
|
||||
|
||||
#endif /* CONFIG_FSUTILS_PASSWD_READONLY */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: passwd_verify
|
||||
*
|
||||
* Description:
|
||||
* Return true if the username exists in the /etc/passwd file and if the
|
||||
* password matches the user password in that failed.
|
||||
*
|
||||
* Input Parameters:
|
||||
* username - Identifies the user whose password will be verified
|
||||
* password - The password to be verified
|
||||
*
|
||||
* Returned Value:
|
||||
* One (1) is returned on success match, Zero (OK) is returned on an
|
||||
* unsuccessful match; a negated errno value is returned on any other
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int passwd_verify(FAR const char *username, FAR const char *password);
|
||||
|
||||
#endif /* __APPS_INCLUDE_FSUTILS_PASSWD_H */
|
||||
309
Ubiquitous/Nuttx/apps/include/gpsutils/minmea.h
Normal file
309
Ubiquitous/Nuttx/apps/include/gpsutils/minmea.h
Normal file
@@ -0,0 +1,309 @@
|
||||
/****************************************************************************
|
||||
* apps/include/gpsutils/minmea.h
|
||||
*
|
||||
* Copyright © 2014 Kosma Moczek <kosma@cloudyourcar.com>
|
||||
*
|
||||
* Released under the NuttX BSD license with permission from the author:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GPSUTILS_MINMEA_H
|
||||
#define __APPS_INCLUDE_GPSUTILS_MINMEA_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define MINMEA_MAX_LENGTH 80
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
enum minmea_sentence_id
|
||||
{
|
||||
MINMEA_INVALID = -1,
|
||||
MINMEA_UNKNOWN = 0,
|
||||
MINMEA_SENTENCE_RMC,
|
||||
MINMEA_SENTENCE_GGA,
|
||||
MINMEA_SENTENCE_GSA,
|
||||
MINMEA_SENTENCE_GLL,
|
||||
MINMEA_SENTENCE_GST,
|
||||
MINMEA_SENTENCE_GSV,
|
||||
};
|
||||
|
||||
struct minmea_float
|
||||
{
|
||||
int_least32_t value;
|
||||
int_least32_t scale;
|
||||
};
|
||||
|
||||
struct minmea_date
|
||||
{
|
||||
int day;
|
||||
int month;
|
||||
int year;
|
||||
};
|
||||
|
||||
struct minmea_time
|
||||
{
|
||||
int hours;
|
||||
int minutes;
|
||||
int seconds;
|
||||
int microseconds;
|
||||
};
|
||||
|
||||
struct minmea_sentence_rmc
|
||||
{
|
||||
struct minmea_time time;
|
||||
bool valid;
|
||||
struct minmea_float latitude;
|
||||
struct minmea_float longitude;
|
||||
struct minmea_float speed;
|
||||
struct minmea_float course;
|
||||
struct minmea_date date;
|
||||
struct minmea_float variation;
|
||||
};
|
||||
|
||||
struct minmea_sentence_gga
|
||||
{
|
||||
struct minmea_time time;
|
||||
struct minmea_float latitude;
|
||||
struct minmea_float longitude;
|
||||
int fix_quality;
|
||||
int satellites_tracked;
|
||||
struct minmea_float hdop;
|
||||
struct minmea_float altitude;
|
||||
char altitude_units;
|
||||
struct minmea_float height;
|
||||
char height_units;
|
||||
int dgps_age;
|
||||
};
|
||||
|
||||
enum minmea_gll_status
|
||||
{
|
||||
MINMEA_GLL_STATUS_DATA_VALID = 'A',
|
||||
MINMEA_GLL_STATUS_DATA_NOT_VALID = 'V',
|
||||
};
|
||||
|
||||
enum minmea_gll_mode
|
||||
{
|
||||
MINMEA_GLL_MODE_AUTONOMOUS = 'A',
|
||||
MINMEA_GLL_MODE_DPGS = 'D',
|
||||
MINMEA_GLL_MODE_DR = 'E',
|
||||
};
|
||||
|
||||
struct minmea_sentence_gll
|
||||
{
|
||||
struct minmea_float latitude;
|
||||
struct minmea_float longitude;
|
||||
struct minmea_time time;
|
||||
char status;
|
||||
char mode;
|
||||
};
|
||||
|
||||
struct minmea_sentence_gst
|
||||
{
|
||||
struct minmea_time time;
|
||||
struct minmea_float rms_deviation;
|
||||
struct minmea_float semi_major_deviation;
|
||||
struct minmea_float semi_minor_deviation;
|
||||
struct minmea_float semi_major_orientation;
|
||||
struct minmea_float latitude_error_deviation;
|
||||
struct minmea_float longitude_error_deviation;
|
||||
struct minmea_float altitude_error_deviation;
|
||||
};
|
||||
|
||||
enum minmea_gsa_mode
|
||||
{
|
||||
MINMEA_GPGSA_MODE_AUTO = 'A',
|
||||
MINMEA_GPGSA_MODE_FORCED = 'M',
|
||||
};
|
||||
|
||||
enum minmea_gsa_fix_type
|
||||
{
|
||||
MINMEA_GPGSA_FIX_NONE = 1,
|
||||
MINMEA_GPGSA_FIX_2D = 2,
|
||||
MINMEA_GPGSA_FIX_3D = 3,
|
||||
};
|
||||
|
||||
struct minmea_sentence_gsa
|
||||
{
|
||||
char mode;
|
||||
int fix_type;
|
||||
int sats[12];
|
||||
struct minmea_float pdop;
|
||||
struct minmea_float hdop;
|
||||
struct minmea_float vdop;
|
||||
};
|
||||
|
||||
struct minmea_sat_info
|
||||
{
|
||||
int nr;
|
||||
int elevation;
|
||||
int azimuth;
|
||||
int snr;
|
||||
};
|
||||
|
||||
struct minmea_sentence_gsv
|
||||
{
|
||||
int total_msgs;
|
||||
int msg_nr;
|
||||
int total_sats;
|
||||
struct minmea_sat_info sats[4];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Calculate raw sentence checksum. Does not check sentence integrity. */
|
||||
|
||||
uint8_t minmea_checksum(FAR const char *sentence);
|
||||
|
||||
/* Check sentence validity and checksum. Returns true for valid sentences. */
|
||||
|
||||
bool minmea_check(FAR const char *sentence, bool strict);
|
||||
|
||||
/* Determine talker identifier. */
|
||||
|
||||
bool minmea_talker_id(char talker[3], FAR const char *sentence);
|
||||
|
||||
/* Determine sentence identifier. */
|
||||
|
||||
enum minmea_sentence_id minmea_sentence_id(FAR const char *sentence,
|
||||
bool strict);
|
||||
|
||||
/* Scanf-like processor for NMEA sentences. Supports the following formats:
|
||||
* c - single character (char *)
|
||||
* d - direction, returned as 1/-1, default 0 (int *)
|
||||
* f - fractional, returned as value + scale (int *, int *)
|
||||
* i - decimal, default zero (int *)
|
||||
* s - string (char *)
|
||||
* t - talker identifier and type (char *)
|
||||
* T - date/time stamp (int *, int *, int *)
|
||||
* Returns true on success. See library source code for details.
|
||||
*/
|
||||
|
||||
bool minmea_scan(const char *sentence, const char *format, ...);
|
||||
|
||||
/* Parse a specific type of sentence. Return true on success. */
|
||||
|
||||
bool minmea_parse_rmc(struct minmea_sentence_rmc *frame, const char *sentence);
|
||||
bool minmea_parse_gga(struct minmea_sentence_gga *frame, const char *sentence);
|
||||
bool minmea_parse_gsa(struct minmea_sentence_gsa *frame, const char *sentence);
|
||||
bool minmea_parse_gll(struct minmea_sentence_gll *frame, const char *sentence);
|
||||
bool minmea_parse_gst(struct minmea_sentence_gst *frame, const char *sentence);
|
||||
bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence);
|
||||
|
||||
/* Convert GPS UTC date/time representation to a UNIX timestamp. */
|
||||
|
||||
int minmea_gettime(FAR struct timespec *ts,
|
||||
FAR const struct minmea_date *date,
|
||||
FAR const struct minmea_time *time_);
|
||||
|
||||
/* Rescale a fixed-point value to a different scale. Rounds towards zero. */
|
||||
|
||||
static inline int_least32_t minmea_rescale(FAR struct minmea_float *f,
|
||||
int_least32_t new_scale)
|
||||
{
|
||||
if (f->scale == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (f->scale == new_scale)
|
||||
{
|
||||
return f->value;
|
||||
}
|
||||
|
||||
if (f->scale > new_scale)
|
||||
{
|
||||
return (f->value + ((f->value > 0) - (f->value < 0)) * f->scale /
|
||||
new_scale / 2) / (f->scale / new_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
return f->value * (new_scale / f->scale);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert a fixed-point value to a floating-point value.
|
||||
* Returns NaN for "unknown" values.
|
||||
*/
|
||||
|
||||
static inline float minmea_tofloat(FAR struct minmea_float *f)
|
||||
{
|
||||
if (f->scale == 0)
|
||||
{
|
||||
return NAN;
|
||||
}
|
||||
|
||||
return (float) f->value / (float) f->scale;
|
||||
}
|
||||
|
||||
/* Convert a raw coordinate to a floating point DD.DDD... value.
|
||||
* Returns NaN for "unknown" values.
|
||||
*/
|
||||
|
||||
static inline float minmea_tocoord(FAR struct minmea_float *f)
|
||||
{
|
||||
if (f->scale == 0)
|
||||
{
|
||||
return NAN;
|
||||
}
|
||||
|
||||
int_least32_t degrees = f->value / (f->scale * 100);
|
||||
int_least32_t minutes = f->value % (f->scale * 100);
|
||||
|
||||
return (float) degrees + (float) minutes / (60 * f->scale);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_GPSUTILS_MINMEA_H */
|
||||
1528
Ubiquitous/Nuttx/apps/include/graphics/curses.h
Normal file
1528
Ubiquitous/Nuttx/apps/include/graphics/curses.h
Normal file
File diff suppressed because it is too large
Load Diff
607
Ubiquitous/Nuttx/apps/include/graphics/ft80x.h
Normal file
607
Ubiquitous/Nuttx/apps/include/graphics/ft80x.h
Normal file
@@ -0,0 +1,607 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/ft80x.h
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_FT80X_H
|
||||
#define __APPS_INCLUDE_GRAPHICS_FT80X_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef CONFIG_GRAPHICS_FT80X
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Buffer size in units of words (truncating any unaligned bytes) */
|
||||
|
||||
#define FT80X_DL_BUFSIZE (CONFIG_GRAPHICS_FT80X_BUFSIZE & ~3)
|
||||
#define FT80X_DL_BUFWORDS (CONFIG_GRAPHICS_FT80X_BUFSIZE >> 2)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure defines the local display list buffer */
|
||||
|
||||
struct ft80x_dlbuffer_s
|
||||
{
|
||||
bool coproc; /* True: Use co-processor FIFO; false: Use DL memory */
|
||||
uint16_t dlsize; /* Total sizeof the display list written to hardware */
|
||||
uint16_t dloffset; /* The number display list bytes buffered locally */
|
||||
uint32_t dlbuffer[FT80X_DL_BUFWORDS];
|
||||
};
|
||||
|
||||
/* Describes touch sample */
|
||||
|
||||
union ft80x_touchpos_u
|
||||
{
|
||||
uint32_t xy; /* To force 32-bit alignment */
|
||||
struct /* Little-endian */
|
||||
{
|
||||
int16_t x; /* Touch X position (-32768 if no touch) */
|
||||
int16_t y; /* Touch Y position (-32768 if no touch) */
|
||||
} u;
|
||||
};
|
||||
|
||||
struct ft80x_touchinfo_s
|
||||
{
|
||||
uint8_t tag; /* Touch 0 tag */
|
||||
#if defined(CONFIG_LCD_FT800)
|
||||
int16_t pressure; /* Touch pressure (32767 if not touched) */
|
||||
#endif
|
||||
union ft80x_touchpos_u tagpos; /* Position associated with tag */
|
||||
#if defined(CONFIG_LCD_FT800) || !defined(CONFIG_LCD_FT801_MULTITOUCH)
|
||||
union ft80x_touchpos_u pos; /* Current touch position */
|
||||
#else
|
||||
union ft80x_touchpos_u pos[4]; /* Current touch position for up to 5 touches */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_dl_start
|
||||
*
|
||||
* Description:
|
||||
* Start a new display list. This function will:
|
||||
*
|
||||
* 1) Set the total display list size to zero
|
||||
* 2) Set the display list buffer offset to zero
|
||||
* 3) Reposition the VFS so that subsequent writes will be to the
|
||||
* beginning of the hardware display list.
|
||||
* 4) Write the CMD_DLSTART command into the local display list buffer
|
||||
* (Only for co-processor commands)
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
|
||||
* coproc - True: Use co-processor FIFO; false: Use DL memory.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_dl_start(int fd, FAR struct ft80x_dlbuffer_s *buffer, bool coproc);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_dl_end
|
||||
*
|
||||
* Description:
|
||||
* Terminate the display list. This function will:
|
||||
*
|
||||
* 1) Add the DISPLAY command to the local display list buffer to finish
|
||||
* the last display
|
||||
* 2) If using co-processor RAM CMD, add the CMD_SWAP to the DL command
|
||||
* list
|
||||
* 3) Flush the local display buffer to hardware and set the display list
|
||||
* buffer offset to zero.
|
||||
* 4) Swap to the newly created display list (DL memory case only).
|
||||
* 5) For the case of the co-processor RAM CMD, it will also wait for the
|
||||
* FIFO to be emptied.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_dl_end(int fd, FAR struct ft80x_dlbuffer_s *buffer);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_dl_data
|
||||
*
|
||||
* Description:
|
||||
* Add data to the display list and increment the display list buffer
|
||||
* offset. If the data will not fit into the local display buffer, then
|
||||
* the local display buffer will first be flushed to hardware in order to
|
||||
* free up space.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
|
||||
* data - The data to be added to the display list
|
||||
* datlen - The length of the data to be added to the display list. If
|
||||
* this is not an even multiple of 4 bytes, then the actual length
|
||||
* will be padded with zero bytes to achieve alignment.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_dl_data(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
||||
FAR const void *data, size_t datlen);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_dl_string
|
||||
*
|
||||
* Description:
|
||||
* Add the string along with its NUL terminator to the display list and
|
||||
* increment the display list buffer offset. If the length of the string
|
||||
* with its NUL terminator is not an even multiple of 4 bytes, then the
|
||||
* actual length will be padded with zero bytes to achieve alignment.
|
||||
*
|
||||
* If the data will not fit into the local display buffer, then the local
|
||||
* display buffer will first be flushed to hardware in order to free up
|
||||
* space.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
|
||||
* str - The string to be added to the display list. If NUL, then a
|
||||
* NUL string will be added to the display list.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_dl_string(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
||||
FAR const char *str);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_dl_flush
|
||||
*
|
||||
* Description:
|
||||
* Flush the current contents of the local local display list buffer to
|
||||
* hardware and reset the local display list buffer offset to zero.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
|
||||
* wait - True: wait until data has been consumed by the co-processor
|
||||
* (only for co-processor destination); false: Send to hardware
|
||||
* and return immediately.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_dl_flush(int fd, FAR struct ft80x_dlbuffer_s *buffer, bool wait);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_dl_create
|
||||
*
|
||||
* Description:
|
||||
* For simple display lists, this function combines all functionality into
|
||||
* a single combined. This function does the following:
|
||||
*
|
||||
* 1) Calls ft80x_dl_dlstart() to initialize the display list.
|
||||
* 2) Calls ft80x_dl_data() to transfer the simple display list
|
||||
* 3) Calls ft80x_dl_end() to complete the display list
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
|
||||
* data - Pointer to a uint32_t array containing the simple display list
|
||||
* nwords - The number of 32-bit words in the array.
|
||||
* coproc - True: Use co-processor FIFO; false: Use DL memory.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_dl_create(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
||||
FAR const uint32_t *cmds, unsigned int nwords,
|
||||
bool coproc);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_coproc_send
|
||||
*
|
||||
* Description:
|
||||
* Send commands to the co-processor via the CMD RAM FIFO. This function
|
||||
* will not return until the command has been consumed by the co-processor.
|
||||
*
|
||||
* NOTE: This command is not appropriate use while a display is being
|
||||
* formed. It is will mess up the CMD RAM FIFO offsets managed by the
|
||||
* display list logic.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* cmds - A list of 32-bit commands to be sent.
|
||||
* ncmds - The number of commands in the list.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_coproc_send(int fd, FAR const uint32_t *cmds, size_t ncmds);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_coproc_waitlogo
|
||||
*
|
||||
* Description:
|
||||
* Wait for the logo animation to complete. The logo command causes the
|
||||
* co-processor engine to play back a short animation of the FTDI logo.
|
||||
* During logo playback the MCU should not access any FT800 resources.
|
||||
* After 2.5 seconds have elapsed, the co-processor engine writes zero to
|
||||
* REG_CMD_READ and REG_CMD_WRITE, and starts waiting for commands. After
|
||||
* this command is complete, the MCU shall write the next command to the
|
||||
* starting address of RAM_CMD.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_coproc_waitlogo(int fd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_ramg_write
|
||||
*
|
||||
* Description:
|
||||
* Write to graphics memory
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* offset - Offset in graphics memory to write to (dest)
|
||||
* data - Pointer to a data to be written (src)
|
||||
* nbytes - The number of bytes to write to graphics memory.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_ramg_write(int fd, unsigned int offset, FAR const void *data,
|
||||
unsigned int nbytes);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_touch_gettransform
|
||||
*
|
||||
* Description:
|
||||
* Read the touch transform matrix
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* matrix - The location to return the transform matrix
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_touch_gettransform(int fd, FAR uint32_t matrix[6]);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_touch_tag
|
||||
*
|
||||
* Description:
|
||||
* Read the current touch tag. The touch tag is an 8-bit value
|
||||
* identifying the specific graphics object on the screen that is being
|
||||
* touched. The value zero indicates that there is no graphic object being
|
||||
* touched.
|
||||
*
|
||||
* Only a single touch can be queried. For the FT801 in "extended",
|
||||
* multi-touch mode, this value indicates only the tag associated with
|
||||
* touch 0.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
*
|
||||
* Returned Value:
|
||||
* A value of 1-255 is returned if a graphics object is touched. Zero is
|
||||
* returned if no graphics object is touched. A negated errno value on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_touch_tag(int fd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_touch_waittag
|
||||
*
|
||||
* Description:
|
||||
* Wait until there is a change in the touch tag.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* oldtag - The previous tag value. This function will return when the
|
||||
* current touch tag differs from this value.
|
||||
*
|
||||
* Returned Value:
|
||||
* A value of 1-255 is returned if a graphics object is touched. Zero is
|
||||
* returned if no graphics object is touched. A negated errno value on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_touch_waittag(int fd, uint8_t oldtag);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_touch_info
|
||||
*
|
||||
* Description:
|
||||
* Return the current touch tag and touch position information.
|
||||
*
|
||||
* For the FT801 in "extended", multi-touch mode, the tag value indicates
|
||||
* only the tag associated with touch 0.
|
||||
*
|
||||
* Touch positions of -32768 indicate that no touch is detected.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* info - Location in which to return the touch information
|
||||
*
|
||||
* Returned Value:
|
||||
* A value of 1-255 is returned if a graphics object is touched. Zero is
|
||||
* returned if no graphics object is touched. A negated errno value on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_touch_info(int fd, FAR struct ft80x_touchinfo_s *info);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_audio_enable
|
||||
*
|
||||
* Description:
|
||||
* Play an short sound effect. If there is a audio amplifier on board
|
||||
* (such as TPA6205A or LM4864), then there may also be an active low
|
||||
* audio shutdown output. That output is controlled by this interface.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the
|
||||
* caller with write access.
|
||||
* enable - True: Enabled the audio amplifier; false: disable
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_audio_enable(int fd, bool enable);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_audio_playsound
|
||||
*
|
||||
* Description:
|
||||
* Play an short sound effect.
|
||||
*
|
||||
* NOTE: It may be necessary to enable the audio amplifier with
|
||||
* ft80x_audio_enable() prior to calling this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the
|
||||
* caller with write access.
|
||||
* effect - The sound effect to use (see FT80X_EFFECT_* definitions).
|
||||
* pitch - Pitch associated with the sound effect (see FT80X_NOTE_*
|
||||
* definitions). May be zero if there is no pitch associated
|
||||
* with the effect.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_audio_playsound(int fd, uint16_t effect, uint16_t pitch);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_audio_playfile
|
||||
*
|
||||
* Description:
|
||||
* Play an audio file. Audio files must consist of raw sample data.
|
||||
*
|
||||
* NOTE: It may be necessary to enable the audio amplifier with
|
||||
* ft80x_audio_enable() prior to calling this function.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the
|
||||
* caller with write access.
|
||||
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the
|
||||
* caller.
|
||||
* filepath - Absolute path to the audio file
|
||||
* format - Audio format. One of:
|
||||
*
|
||||
* AUDIO_FORMAT_LINEAR Linear Sample format
|
||||
* AUDIO_FORMAT_ULAW uLaw Sample format
|
||||
* AUDIO_FORMAT_ADPCM 4-bit IMA ADPCM Sample format
|
||||
*
|
||||
* frequency - Audio sample frequency (<65,536)
|
||||
* volume - Playback volume (0=mute; 255=max)
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
||||
FAR const char *filepath, uint8_t format,
|
||||
uint16_t frequency, uint8_t volume);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_backlight_set
|
||||
*
|
||||
* Description:
|
||||
* Set the backlight intensity via the PWM duty.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* duty - The new backlight duty (as a percentage 0..100)
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_backlight_set(int fd, uint8_t duty);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_backlight_fade
|
||||
*
|
||||
* Description:
|
||||
* Change the backlight intensity with a controllable fade.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* duty - The terminal duty (as a percentage 0..100)
|
||||
* delay - The duration of the fade in milliseconds (10..16700).
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_backlight_fade(int fd, uint8_t duty, uint16_t delay);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_gpio_configure
|
||||
*
|
||||
* Description:
|
||||
* Configure an FT80x GPIO pin
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* gpio - Identifies the GPIO pin {0,1}
|
||||
* dir - Direction: 0=input, 1=output
|
||||
* drive - Common output drive strength for GPIO 0 and 1 (see
|
||||
* FT80X_GPIO_DRIVE_* definitions). Default is 4mA.
|
||||
* value - Initial value for output pins
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_gpio_configure(int fd, uint8_t gpio, uint8_t dir, uint8_t drive,
|
||||
bool value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_gpio_write
|
||||
*
|
||||
* Description:
|
||||
* Write a value to a pin configured for output
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* gpio - Identifies the GPIO pin {0,1}
|
||||
* value - True: high, false: low
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ft80x_gpio_write(int fd, uint8_t gpio, bool value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ft80x_gpio_read
|
||||
*
|
||||
* Description:
|
||||
* Read the value from a pin configured for input
|
||||
*
|
||||
* Input Parameters:
|
||||
* fd - The file descriptor of the FT80x device. Opened by the caller
|
||||
* with write access.
|
||||
* gpio - Identifies the GPIO pin {0,1}
|
||||
*
|
||||
* Returned Value:
|
||||
* True: high, false: low
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool ft80x_gpio_read(int fd, uint8_t gpio);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_GRAPHICS_FT80X */
|
||||
#endif /* __APPS_INCLUDE_GRAPHICS_FT80X_H */
|
||||
134
Ubiquitous/Nuttx/apps/include/graphics/nxglyphs.hxx
Normal file
134
Ubiquitous/Nuttx/apps/include/graphics/nxglyphs.hxx
Normal file
@@ -0,0 +1,134 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/nxglyphs.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXGLYPHS_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXGLYPHS_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Default background color */
|
||||
|
||||
#ifndef CONFIG_NXGLYPHS_BACKGROUNDCOLOR
|
||||
# define CONFIG_NXGLYPHS_BACKGROUNDCOLOR MKRGB(148,189,215)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Bitmap Glyph References
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
struct SBitmap;
|
||||
|
||||
// Bitmaps used by NxWidgets
|
||||
// Global RLE Paletted Bitmaps
|
||||
|
||||
extern const struct SRlePaletteBitmap g_nuttxBitmap160x160;
|
||||
extern const struct SRlePaletteBitmap g_nuttxBitmap320x320;
|
||||
|
||||
// Global Simple Bitmaps
|
||||
|
||||
extern const struct SBitmap g_screenDepthUp;
|
||||
extern const struct SBitmap g_screenDepthDown;
|
||||
extern const struct SBitmap g_windowClose;
|
||||
extern const struct SBitmap g_windowDepthUp;
|
||||
extern const struct SBitmap g_windowDepthDown;
|
||||
extern const struct SBitmap g_radioButtonOn;
|
||||
extern const struct SBitmap g_radioButtonOff;
|
||||
extern const struct SBitmap g_radioButtonMu;
|
||||
extern const struct SBitmap g_checkBoxOff;
|
||||
extern const struct SBitmap g_checkBoxOn;
|
||||
extern const struct SBitmap g_checkBoxMu;
|
||||
extern const struct SBitmap g_screenFlipUp;
|
||||
extern const struct SBitmap g_screenFlipDown;
|
||||
extern const struct SBitmap g_arrowUp;
|
||||
extern const struct SBitmap g_arrowDown;
|
||||
extern const struct SBitmap g_arrowLeft;
|
||||
extern const struct SBitmap g_arrowRight;
|
||||
extern const struct SBitmap g_cycle;
|
||||
extern const struct SBitmap g_backspace;
|
||||
extern const struct SBitmap g_return;
|
||||
extern const struct SBitmap g_shift;
|
||||
extern const struct SBitmap g_capslock;
|
||||
extern const struct SBitmap g_control;
|
||||
|
||||
// Bitmaps used by NxWM, Twm4Nx, and SLcd
|
||||
// Global RLE Paletted Bitmaps
|
||||
|
||||
extern const struct SRlePaletteBitmap g_calculatorBitmap;
|
||||
extern const struct SRlePaletteBitmap g_calibrationBitmap;
|
||||
extern const struct SRlePaletteBitmap g_cmdBitmap;
|
||||
extern const struct SRlePaletteBitmap g_menuBitmap;
|
||||
extern const struct SRlePaletteBitmap g_menu2Bitmap;
|
||||
extern const struct SRlePaletteBitmap g_resizeBitmap;
|
||||
extern const struct SRlePaletteBitmap g_resize2Bitmap;
|
||||
extern const struct SRlePaletteBitmap g_nxiconBitmap;
|
||||
extern const struct SRlePaletteBitmap g_lcdClockBitmap;
|
||||
|
||||
// Used by NxWM media player
|
||||
|
||||
extern const struct SRlePaletteBitmap g_mediaplayerBitmap;
|
||||
extern const struct SRlePaletteBitmap g_mplayerFwdBitmap;
|
||||
extern const struct SRlePaletteBitmap g_mplayerPlayBitmap;
|
||||
extern const struct SRlePaletteBitmap g_mplayerPauseBitmap;
|
||||
extern const struct SRlePaletteBitmap g_mplayerRewBitmap;
|
||||
extern const struct SRlePaletteBitmap g_mplayerVolBitmap;
|
||||
extern const struct SRlePaletteBitmap g_minimizeBitmap;
|
||||
extern const struct SRlePaletteBitmap g_minimize2Bitmap;
|
||||
extern const struct SRlePaletteBitmap g_playBitmap;
|
||||
extern const struct SRlePaletteBitmap g_stopBitmap;
|
||||
extern const struct SRlePaletteBitmap g_stop2Bitmap;
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXGLYPHS_HXX
|
||||
422
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cbgwindow.hxx
Normal file
422
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cbgwindow.hxx
Normal file
@@ -0,0 +1,422 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cbgwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2015, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBGWINDOW_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBGWINDOW_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/ccallback.hxx"
|
||||
#include "graphics/nxwidgets/inxwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class INxWindow;
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* This class defines operations on a the NX background window.
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
*/
|
||||
|
||||
class CBgWindow : protected CCallback, public INxWindow
|
||||
{
|
||||
private:
|
||||
NXHANDLE m_hNxServer; /**< Handle to the NX server. */
|
||||
NXWINDOW m_hWindow; /**< Handle to the NX background window */
|
||||
CWidgetControl *m_widgetControl; /**< The controlling widget for the window */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Obtains the background window from server and wraps
|
||||
* the window as CBgWindow. Creates an uninitialized instance of the
|
||||
* CBgWindow object. The open() method must be called to initialize
|
||||
* the instance.
|
||||
*
|
||||
* The general steps to create any window include:
|
||||
* 1) Create a dumb CWigetControl instance
|
||||
* 2) Pass the dumb CWidgetControl instance to the window constructor
|
||||
* that inherits from INxWindow.
|
||||
* 3) The window constructor call CWidgetControl methods to "smarten"
|
||||
* the CWidgetControl instance with window-specific knowledge.
|
||||
* 4) Call the open() method on the window to display the window.
|
||||
* 5) After that, the fully smartend CWidgetControl instance can
|
||||
* be used to generate additional widgets.
|
||||
* 6) After that, the fully smartened CWidgetControl instance can
|
||||
* be used to generate additional widgets by passing it to the
|
||||
* widget constructor
|
||||
*
|
||||
* @param hNxServer Handle to the NX server.
|
||||
* @param widgetControl Controlling widget for this window.
|
||||
*/
|
||||
|
||||
CBgWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl);
|
||||
|
||||
/**
|
||||
* Destructor. Returns the background window to the server.
|
||||
*/
|
||||
|
||||
virtual ~CBgWindow(void);
|
||||
|
||||
/**
|
||||
* Creates the new window. Window creation is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully created.
|
||||
*/
|
||||
|
||||
bool open(void);
|
||||
|
||||
/**
|
||||
* Each implementation of INxWindow must provide a method to recover
|
||||
* the contained CWidgetControl instance.
|
||||
*
|
||||
* @return The contained CWidgetControl instance
|
||||
*/
|
||||
|
||||
CWidgetControl *getWidgetControl(void) const;
|
||||
|
||||
/**
|
||||
* Synchronize the window with the NX server. This function will delay
|
||||
* until the the NX server has caught up with all of the queued requests.
|
||||
* When this function returns, the state of the NX server will be the
|
||||
* same as the state of the application.
|
||||
*/
|
||||
|
||||
inline void synchronize(void)
|
||||
{
|
||||
CCallback::synchronize(m_hWindow, CCallback::NX_RAWWINDOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the position and size information of the window. The values
|
||||
* will be returned asynchronously through the client callback method.
|
||||
* The GetPosition() method may than be called to obtain the positional
|
||||
* data as provided by the callback.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool requestPosition(void);
|
||||
|
||||
/**
|
||||
* Get the position of the window (as reported by the NX callback). NOTE:
|
||||
* The background window is always positioned at {0,0}
|
||||
*
|
||||
* @return The position.
|
||||
*/
|
||||
|
||||
bool getPosition(FAR struct nxgl_point_s *pPos);
|
||||
|
||||
/**
|
||||
* Get the size of the window (as reported by the NX callback). NOTE:
|
||||
* The size of the background window is always the entire display.
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
bool getSize(FAR struct nxgl_size_s *pSize);
|
||||
|
||||
/**
|
||||
* Set the position and size of the window.
|
||||
*
|
||||
* @param pPos The new position of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool setPosition(FAR const struct nxgl_point_s *pPos);
|
||||
|
||||
/**
|
||||
* Set the size of the selected window. NOTE: The size of the
|
||||
* background window is always the entire display and cannot be
|
||||
* changed.
|
||||
*
|
||||
* @param pSize The new size of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool setSize(FAR const struct nxgl_size_s *pSize);
|
||||
|
||||
/**
|
||||
* Bring the window to the top of the display. NOTE: The background
|
||||
* window cannot be raised.
|
||||
*
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool raise(void)
|
||||
{
|
||||
// The background cannot be raised
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower the window to the bottom of the display. NOTE: The background
|
||||
* window is always at the bottom of the window hierarchy.
|
||||
*
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool lower(void)
|
||||
{
|
||||
// The background cannot be lowered
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the window is currently being displayed
|
||||
*
|
||||
* @return Always returns true.
|
||||
*/
|
||||
|
||||
inline bool isVisible(void)
|
||||
{
|
||||
// The background is always visible (although perhaps obscured)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a hidden window
|
||||
*
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool show(void)
|
||||
{
|
||||
// The background is always visible (although perhaps obscured)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a visible window
|
||||
*
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool hide(void)
|
||||
{
|
||||
// The background cannot be hidden
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* May be used to either (1) raise a window to the top of the display and
|
||||
* select modal behavior, or (2) disable modal behavior. NOTE: The
|
||||
* background cannot be a modal window.
|
||||
*
|
||||
* @param enable True: enter modal state; False: leave modal state
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool modal(bool enable)
|
||||
{
|
||||
// The background cannot a modal window
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
/**
|
||||
* Each window implementation also inherits from CCallback. CCallback,
|
||||
* by default, forwards NX keyboard input to the various widgets residing
|
||||
* in the window. But NxTerm is a different usage model; In this case,
|
||||
* keyboard input needs to be directed to the NxTerm character driver.
|
||||
* This method can be used to enable (or disable) redirection of NX
|
||||
* keyboard input from the window widgets to the NxTerm
|
||||
*
|
||||
* @param handle. The NXTERM handle. If non-NULL, NX keyboard
|
||||
* input will be directed to the NxTerm driver using this
|
||||
* handle; If NULL (the default), NX keyboard input will be
|
||||
* directed to the widgets within the window.
|
||||
*/
|
||||
|
||||
inline void redirectNxTerm(NXTERM handle)
|
||||
{
|
||||
setNxTerm(handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set an individual pixel in the window with the specified color.
|
||||
*
|
||||
* @param pPos The location of the pixel to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool setPixel(FAR const struct nxgl_point_s *pPos,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified rectangle in the window with the specified color.
|
||||
*
|
||||
* @param pRect The location to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fill(FAR const struct nxgl_rect_s *pRect,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Get the raw contents of graphic memory within a rectangular region. NOTE:
|
||||
* Since raw graphic memory is returned, the returned memory content may be
|
||||
* the memory of windows above this one and may not necessarily belong to
|
||||
* this window unless you assure that this is the top window.
|
||||
*
|
||||
* @param rect The location to be copied
|
||||
* @param dest - The describes the destination bitmap to receive the
|
||||
* graphics data.
|
||||
*/
|
||||
|
||||
void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
|
||||
|
||||
/**
|
||||
* Fill the specified trapezoidal region in the window with the specified
|
||||
* color.
|
||||
*
|
||||
* @param pClip Clipping rectangle relative to window (may be null).
|
||||
* @param pTrap The trapezoidal region to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
|
||||
FAR const struct nxgl_trapezoid_s *pTrap,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified line in the window with the specified color.
|
||||
*
|
||||
* @param vector - Describes the line to be drawn
|
||||
* @param width - The width of the line
|
||||
* @param color - The color to use to fill the line
|
||||
* @param caps - Draw a circular cap on the ends of the line to support
|
||||
* better line joins
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool drawLine(FAR struct nxgl_vector_s *vector,
|
||||
nxgl_coord_t width, nxgl_mxpixel_t color,
|
||||
enum ELineCaps caps);
|
||||
|
||||
/**
|
||||
* Draw a filled circle at the specified position, size, and color.
|
||||
*
|
||||
* @param center The window-relative coordinates of the circle center.
|
||||
* @param radius The radius of the rectangle in pixels.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Move a rectangular region within the window.
|
||||
*
|
||||
* @param pRect Describes the rectangular region to move.
|
||||
* @param pOffset The offset to move the region.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool move(FAR const struct nxgl_rect_s *pRect,
|
||||
FAR const struct nxgl_point_s *pOffset);
|
||||
|
||||
/**
|
||||
* Copy a rectangular region of a larger image into the rectangle in the
|
||||
* specified window.
|
||||
*
|
||||
* @param pDest Describes the rectangular on the display that will receive
|
||||
* the bitmap.
|
||||
* @param pSrc The start of the source image.
|
||||
* @param pOrigin the pOrigin of the upper, left-most corner of the full
|
||||
* bitmap. Both pDest and pOrigin are in window coordinates, however,
|
||||
* pOrigin may lie outside of the display.
|
||||
* @param stride The width of the full source image in bytes.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool bitmap(FAR const struct nxgl_rect_s *pDest,
|
||||
FAR const void *pSrc,
|
||||
FAR const struct nxgl_point_s *pOrigin,
|
||||
unsigned int stride);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBGWINDOW_HXX
|
||||
213
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cbitmap.hxx
Normal file
213
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cbitmap.hxx
Normal file
@@ -0,0 +1,213 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cbitmap.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBITMAP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBITMAP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/ibitmap.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Bitmap Structure
|
||||
*/
|
||||
|
||||
struct SBitmap
|
||||
{
|
||||
uint8_t bpp; /**< Bits per pixel */
|
||||
uint8_t fmt; /**< Color format */
|
||||
nxgl_coord_t width; /**< Width in pixels */
|
||||
nxgl_coord_t height; /**< Height in rows */
|
||||
uint16_t stride; /**< Width in bytes */
|
||||
FAR const void *data; /**< Pointer to the beginning of pixel data */
|
||||
};
|
||||
|
||||
/**
|
||||
* Class providing bitmap accessor for a bitmap represented by SBitmap.
|
||||
*/
|
||||
|
||||
class CBitmap : public IBitmap
|
||||
{
|
||||
protected:
|
||||
const struct SBitmap *m_bitmap; /**< The bitmap that is being managed */
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CBitmap(const CBitmap &bitmap) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bitmap The bitmap structure being wrapped.
|
||||
*/
|
||||
|
||||
CBitmap(const struct SBitmap *bitmap);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~CBitmap(void) {}
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's width.
|
||||
*/
|
||||
|
||||
const uint8_t getColorFormat(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's color format.
|
||||
*/
|
||||
|
||||
const uint8_t getBitsPerPixel(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in pixels/columns).
|
||||
*
|
||||
* @return The bitmap's pixel depth.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getWidth(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's height (in rows).
|
||||
*
|
||||
* @return The bitmap's height.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getHeight(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in bytes).
|
||||
*
|
||||
* @return The bitmap's width.
|
||||
*/
|
||||
|
||||
const size_t getStride(void) const;
|
||||
|
||||
/**
|
||||
* Use the colors associated with a selected image.
|
||||
*
|
||||
* @param selected. true: Use colors for a selected widget,
|
||||
* false: Use normal (default) colors.
|
||||
*/
|
||||
|
||||
inline void setSelected(bool selected) {}
|
||||
|
||||
/**
|
||||
* Get one row from the bit map image.
|
||||
*
|
||||
* @param x The offset into the row to get
|
||||
* @param y The row number to get
|
||||
* @param width The number of pixels to get from the row
|
||||
* @param data The memory location provided by the caller
|
||||
* in which to return the data. This should be at least
|
||||
* (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
|
||||
* and properly aligned for the pixel color format.
|
||||
* @param True if the run was returned successfully.
|
||||
*/
|
||||
|
||||
bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
FAR void *data);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBITMAP_HXX
|
||||
244
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cbutton.hxx
Normal file
244
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cbutton.hxx
Normal file
@@ -0,0 +1,244 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cbutton.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBUTTON_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBUTTON_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Clickable button widget. Displays text within the button.
|
||||
*/
|
||||
|
||||
class CButton : public CLabel
|
||||
{
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Draws the outline of the button.
|
||||
*
|
||||
* @param port Graphics port to draw to.
|
||||
*/
|
||||
|
||||
virtual void drawOutline(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Draws the outline of the button.
|
||||
*
|
||||
* @param port Graphics port to draw to.
|
||||
* @param useClicked Present outline using the 'clicked' style
|
||||
*/
|
||||
|
||||
void drawOutline(CGraphicsPort *port, bool useClicked);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @param useClicked Present contents using the 'clicked' style
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
void drawContents(CGraphicsPort *port, bool useClicked);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @param useClicked Present border using the 'clicked' style
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
void drawBorder(CGraphicsPort *port, bool useClicked);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Raises an action.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CButton(const CButton &button) : CLabel(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for buttons that display a string.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the button, relative to its parent.
|
||||
* @param y The y coordinate of the button, relative to its parent.
|
||||
* @param width The width of the button.
|
||||
* @param height The height of the button.
|
||||
* @param text The text for the button to display.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CButton(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height, const CNxString &text,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* CButton Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CButton() { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBUTTON_HXX
|
||||
@@ -0,0 +1,339 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cbuttonarray.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBUTTONARRAY_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBUTTONARRAY_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CNxString;
|
||||
|
||||
/**
|
||||
* Manages a two-dimensional array of buttons as one widget. A two-
|
||||
* dimensional array of buttons might also be called a "keyboard".
|
||||
*/
|
||||
|
||||
class CButtonArray : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
uint8_t m_buttonColumns; /**< The number of columns in one row */
|
||||
uint8_t m_buttonRows; /**< The number buttons in one column */
|
||||
bool m_redrawButton; /**< True: Redraw button; False: redraw all */
|
||||
bool m_cursorOn; /**< Cursor on; highlighted button displayed */
|
||||
bool m_cursorChange; /**< True: Redraw cursor button only */
|
||||
nxgl_coord_t m_buttonWidth; /**< The width of one button in pixels */
|
||||
nxgl_coord_t m_buttonHeight; /**< The height of one button in rows */
|
||||
nxgl_coord_t m_clickX; /**< The X position of the last clicked button */
|
||||
nxgl_coord_t m_clickY; /**< The Y position of the last clicked button */
|
||||
uint8_t m_cursorColumn; /**< The column index of the highlighted button */
|
||||
uint8_t m_cursorRow; /**< The row index of the highlighted button */
|
||||
CNxString *m_buttonText; /**< Text for each button */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Redraw only one button
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
* @param column The button column index
|
||||
* @param row The button row index
|
||||
* @param useClicked Draw the button using the 'clicked' button style,
|
||||
* regardless of the actual button state.
|
||||
* @see onClick() and onRelease()
|
||||
*/
|
||||
|
||||
virtual void drawButton(CGraphicsPort *port, int column, int row, bool useClicked);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Raises an action.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Convert an X/Y position to a button column/row index
|
||||
*
|
||||
* @param x The x position
|
||||
* @param y The y position
|
||||
* @param column The location to return the column index of the button
|
||||
* of interest
|
||||
* @param row The location to return the row index of the button of
|
||||
* interest
|
||||
* @return false is the position is invalid
|
||||
*/
|
||||
|
||||
virtual bool posToButton(nxgl_coord_t x, nxgl_coord_t y, int &column, int &row);
|
||||
|
||||
/**
|
||||
* Updates the GUI after the text has changed.
|
||||
*/
|
||||
|
||||
virtual void onTextChange(void);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CButtonArray(const CButtonArray &button) : CNxWidget(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for an array of buttons.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the button array, relative to its parent.
|
||||
* @param y The y coordinate of the button array, relative to its parent.
|
||||
* @param buttonColumns The number of buttons in one row of the button array
|
||||
* @param buttonRows The number of buttons in one column of the button array
|
||||
* @param buttonWidth The width of one button
|
||||
* @param buttonHeight The height of one button
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CButtonArray(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
uint8_t buttonColumns, uint8_t buttonRows,
|
||||
nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* CButtonArray Destructor.
|
||||
*/
|
||||
|
||||
~CButtonArray(void);
|
||||
|
||||
/**
|
||||
* Resize the array of buttons. Button labels will be removed and will
|
||||
* have to be reapplied in the new geometry.
|
||||
*
|
||||
* @param buttonColumns The number of buttons in one row of the button array
|
||||
* @param buttonRows The number of buttons in one column of the button array
|
||||
* @param buttonWidth The width of one button
|
||||
* @param buttonHeight The height of one button
|
||||
*/
|
||||
|
||||
bool resizeArray(uint8_t buttonColumns, uint8_t buttonRows,
|
||||
nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight);
|
||||
|
||||
/**
|
||||
* Returns the string shown in the label.
|
||||
*
|
||||
* @param column The column index of the button of interest
|
||||
* @param row The row index of the button of interest
|
||||
* @return The label's text.
|
||||
*/
|
||||
|
||||
virtual const CNxString &getText(int column, int row) const;
|
||||
|
||||
/**
|
||||
* Set the text displayed in the label.
|
||||
*
|
||||
* @param column The column index of the button to set
|
||||
* @param row The row index of the button to set
|
||||
* @param text String to display.
|
||||
*/
|
||||
|
||||
virtual void setText(int column, int row, const CNxString &text);
|
||||
|
||||
/**
|
||||
* Return the position of the last clicked button (0,0 will be returned
|
||||
* the no button has every been clicked). The button at this position
|
||||
* is currently clicked then, in addition, return true.
|
||||
*
|
||||
* @param column The location to return the column index of the button
|
||||
* of interest
|
||||
* @param row The location to return the row index of the button of
|
||||
* interest
|
||||
* @return True if any button in the array is clicked
|
||||
*/
|
||||
|
||||
virtual bool isButtonClicked(int &column, int &row) const;
|
||||
|
||||
/**
|
||||
* Check if this specific button in the array is clicked
|
||||
*
|
||||
* @param column The column of the button to check.
|
||||
* @param row The row of the button to check.
|
||||
* @return True if this button is clicked
|
||||
*/
|
||||
|
||||
virtual bool isThisButtonClicked(int column, int row) const;
|
||||
|
||||
/**
|
||||
* Control the cursor state.
|
||||
*
|
||||
* @param cursorOn True(1), the current cursor position will be highlighted
|
||||
*/
|
||||
|
||||
virtual void cursor(bool cursorOn);
|
||||
|
||||
/**
|
||||
* Return the current cursor position (button indices) and an indication
|
||||
* if the button at the cursor is currently highlighted.
|
||||
*
|
||||
* @param column The location to return the column index of the button
|
||||
* of interest
|
||||
* @param row The location to return the row index of the button of
|
||||
* interest
|
||||
* @return True if the cursor is enabled and the button is highlighted
|
||||
*/
|
||||
|
||||
virtual bool getCursorPosition(int &column, int &row) const;
|
||||
|
||||
/**
|
||||
* Set the cursor position (button indices). Note that the cursor
|
||||
* does not have to be enabled to set the position.
|
||||
*
|
||||
* @param column The column index of the button of interest
|
||||
* @param row The row index of the button of interest
|
||||
* @return True if the cursor position is valid
|
||||
*/
|
||||
|
||||
virtual bool setCursorPosition(int column, int row);
|
||||
|
||||
/**
|
||||
* Check if this specific button in the array is at the cursor position
|
||||
* and highlighted.
|
||||
*
|
||||
* @param column The column of the button to check.
|
||||
* @param row The row of the button to check.
|
||||
* @return True if this button is at the cursor position and highlighted.
|
||||
*/
|
||||
|
||||
virtual bool isCursorPosition(int column, int row) const;
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the
|
||||
* widget's parent.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Sets the font.
|
||||
*
|
||||
* @param font A pointer to the font to use.
|
||||
*/
|
||||
|
||||
virtual void setFont(CNxFont *font);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CBUTTONARRAY_HXX
|
||||
311
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ccallback.hxx
Normal file
311
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ccallback.hxx
Normal file
@@ -0,0 +1,311 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ccallback.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCALLBACK_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCALLBACK_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
# include <nuttx/nx/nxterm.h>
|
||||
#endif
|
||||
|
||||
#include "graphics/nxwidgets/crect.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Callback function proxies. This class receives and dispatches callbacks
|
||||
* from the NX server. This calls also manages a few lower-level details
|
||||
* such as keeping track of the reported window handles and window positions
|
||||
* and sizes.
|
||||
*
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
|
||||
*/
|
||||
|
||||
class CCallback
|
||||
{
|
||||
private:
|
||||
CWidgetControl *m_widgetControl; /**< The widget control instance for this window */
|
||||
struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
NXTERM m_nxterm; /**< The NxTerm handle for redirection of keyboard input */
|
||||
#endif
|
||||
volatile bool m_synchronized; /**< True: Synchronized with NX server */
|
||||
sem_t m_semevent; /**< Event wait semaphore */
|
||||
|
||||
// Methods in the callback vtable
|
||||
|
||||
/**
|
||||
* Re-Draw Callback. The redraw event is handled by CWidgetControl::redrawEvent.
|
||||
*
|
||||
* NOTE: This method runs in the context of the NX callback which may
|
||||
* either be the context of the owning thread or, in the case of multi-
|
||||
* user NX, the context of the NX event listener thread.
|
||||
*
|
||||
* @param hwnd Handle to a specific NX window.
|
||||
* @param rect The rectangle that needs to be re-drawn (in window
|
||||
* relative coordinates).
|
||||
* @param bMore true: More re-draw requests will follow.
|
||||
* @param arg User provided argument (see nx_openwindow, nx_requestbg,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar).
|
||||
*/
|
||||
|
||||
static void redraw(NXHANDLE hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
bool bMore, FAR void *arg);
|
||||
|
||||
/**
|
||||
* Position Callback. The new positional data is handled by
|
||||
* CWidgetControl::geometryEvent.
|
||||
*
|
||||
* NOTE: This method runs in the context of the NX callback which may
|
||||
* either be the context of the owning thread or, in the case of multi-
|
||||
* user NX, the context of the NX event listener thread.
|
||||
*
|
||||
* @param hwnd Handle to a specific NX window.
|
||||
* @param size The size of the window.
|
||||
* @param pos The position of the upper left hand corner of the window on
|
||||
* the overall display.
|
||||
* @param bounds The bounding rectangle that describes the entire display.
|
||||
* @param arg User provided argument (see nx_openwindow, nx_requestbg,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar).
|
||||
*/
|
||||
|
||||
static void position(NXHANDLE hwnd, FAR const struct nxgl_size_s *size,
|
||||
FAR const struct nxgl_point_s *pos,
|
||||
FAR const struct nxgl_rect_s *bounds,
|
||||
FAR void *arg);
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
* New mouse data is available for the window. The new mouse
|
||||
* data is handled by CWidgetControl::newMouseEvent.
|
||||
*
|
||||
* NOTE: This method runs in the context of the NX callback which may
|
||||
* either be the context of the NX event listener thread (if multi-
|
||||
* user NX), or possibly in the connects of device driver or even a
|
||||
* device driver interrupt.
|
||||
*
|
||||
* The GUI thread is probably sleeping a semaphore, waiting to be
|
||||
* awakened by a mouse or keyboard event.
|
||||
*
|
||||
* @param hwnd Handle to a specific NX window.
|
||||
* @param pos The (x,y) position of the mouse.
|
||||
* @param buttons See NX_MOUSE_* definitions.
|
||||
* @param arg User provided argument (see nx_openwindow, nx_requestbg,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar).
|
||||
*/
|
||||
|
||||
static void newMouseEvent(NXHANDLE hwnd,
|
||||
FAR const struct nxgl_point_s *pos,
|
||||
uint8_t buttons, FAR void *arg);
|
||||
#endif /* CONFIG_NX_XYINPUT */
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* New keyboard/keypad data is available for the window. The new
|
||||
* keyboard data is handled by CWidgetControl::newKeyboardEvent.
|
||||
*
|
||||
* NOTE: This method runs in the context of the NX callback which may
|
||||
* either be the context of the NX event listener thread (if multi-
|
||||
* user NX), or possibly in the connects of device driver or even a
|
||||
* device driver interrupt.
|
||||
*
|
||||
* The GUI thread is probably sleeping a semaphore, waiting to be
|
||||
* awakened by a mouse or keyboard event.
|
||||
*
|
||||
* @param hwnd Handle to a specific NX window.
|
||||
* @param nCh The number of characters that are available in str[].
|
||||
* @param str The array of characters.
|
||||
* @param arg User provided argument (see nx_openwindow, nx_requestbg,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar).
|
||||
*/
|
||||
|
||||
static void newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
|
||||
FAR const uint8_t *str, FAR void *arg);
|
||||
#endif // CONFIG_NX_KBD
|
||||
|
||||
/**
|
||||
* This callback is used to communicate server events to the window
|
||||
* listener.
|
||||
*
|
||||
* NXEVENT_BLOCKED - Window messages are blocked.
|
||||
*
|
||||
* This callback is the response from nx_block (or nxtk_block). Those
|
||||
* blocking interfaces are used to assure that no further messages are
|
||||
* directed to the window. Receipt of the blocked callback signifies
|
||||
* that (1) there are no further pending callbacks and (2) that the
|
||||
* window is now 'defunct' and will receive no further callbacks.
|
||||
*
|
||||
* This callback supports coordinated destruction of a window. In
|
||||
* the multi-user mode, the client window logic must stay intact until
|
||||
* all of the queued callbacks are processed. Then the window may be
|
||||
* safely closed. Closing the window prior with pending callbacks can
|
||||
* lead to bad behavior when the callback is executed.
|
||||
*
|
||||
* NXEVENT_SYCNCHED - Synchronization handshake
|
||||
*
|
||||
* This completes the handshake started by nx_synch(). nx_synch()
|
||||
* sends a syncrhonization messages to the NX server which responds
|
||||
* with this event. The sleeping client is awakened and continues
|
||||
* graphics processing, completing the handshake.
|
||||
*
|
||||
* Due to the highly asynchronous nature of client-server
|
||||
* communications, nx_synch() is sometimes necessary to assure that
|
||||
* the client and server are fully synchronized.
|
||||
*
|
||||
* @param hwnd. Window handle of the blocked window
|
||||
* @param event. The server event
|
||||
* @param arg1. User provided argument (see nx_openwindow, nx_requestbkgd,
|
||||
* nxtk_openwindow, or nxtk_opentoolbar)
|
||||
* @param arg2 - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
static void windowEvent(NXWINDOW hwnd, enum nx_event_e event,
|
||||
FAR void *arg1, FAR void *arg2);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum of window types
|
||||
*/
|
||||
|
||||
enum WindowType
|
||||
{
|
||||
NX_RAWWINDOW = 0,
|
||||
NXTK_FRAMEDWINDOW
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param widgetControl Control object associated with this window
|
||||
*/
|
||||
|
||||
CCallback(CWidgetControl *widgetControl);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~CCallback(void) {}
|
||||
|
||||
/**
|
||||
* Get the callback vtable. This is need only by the window
|
||||
* instance that inherits this class. The window instance needs the
|
||||
* C-callable vtable in order to create the NX window. Once the
|
||||
* window is created, this class will begin to receive callbacks via
|
||||
* the C-callable vtable methods.
|
||||
*
|
||||
* @return This method returns the C-callable vtable needed for
|
||||
* NX window creation.
|
||||
*/
|
||||
|
||||
inline FAR struct nx_callback_s *getCallbackVTable(void)
|
||||
{
|
||||
return &m_callbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronize the window with the NX server. This function will delay
|
||||
* until the the NX server has caught up with all of the queued requests.
|
||||
* When this function returns, the state of the NX server will be the
|
||||
* same as the state of the application.
|
||||
*
|
||||
* @param hwnd Handle to a specific NX window.
|
||||
*/
|
||||
|
||||
void synchronize(NXWINDOW hwnd, enum WindowType windowType);
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
/**
|
||||
* By default, NX keyboard input is given to the various widgets
|
||||
* residing in the window. But NxTerm is a different usage model;
|
||||
* In this case, keyboard input needs to be directed to the NxTerm
|
||||
* character driver. This method can be used to enable (or disable)
|
||||
* redirection of NX keyboard input from the window widgets to the
|
||||
* NxTerm
|
||||
*
|
||||
* @param handle. The NXTERM handle. If non-NULL, NX keyboard
|
||||
* input will be directed to the NxTerm driver using this
|
||||
* handle; If NULL (the default), NX keyboard input will be
|
||||
* directed to the widgets within the window.
|
||||
*/
|
||||
|
||||
inline void setNxTerm(NXTERM handle)
|
||||
{
|
||||
m_nxterm = handle;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCALLBACK_HXX
|
||||
209
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ccheckbox.hxx
Normal file
209
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ccheckbox.hxx
Normal file
@@ -0,0 +1,209 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ccheckbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCHECKBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCHECKBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbutton.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Class representing a checkbox. Like radio buttons, checkboxes
|
||||
* are tri-state - off, on and "mu". The mu state cannot be enabled by
|
||||
* a user - it can only be set by the developer.
|
||||
*/
|
||||
|
||||
class CCheckBox : public CButton
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum listing all possible checkbox states.
|
||||
*/
|
||||
|
||||
enum CheckBoxState
|
||||
{
|
||||
CHECK_BOX_STATE_OFF = 0, /**< Checkbox is unticked */
|
||||
CHECK_BOX_STATE_ON = 1, /**< Checkbox is ticked */
|
||||
CHECK_BOX_STATE_MU = 2 /**< Checkbox is in the third state */
|
||||
};
|
||||
|
||||
protected:
|
||||
CheckBoxState m_state; /**< The state of the checkbox */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Toggles the state of the checkbox.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CCheckBox(const CCheckBox &checkBox) : CButton(checkBox) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the checkbox, relative to its parent.
|
||||
* @param y The y coordinate of the checkbox, relative to its parent.
|
||||
* @param width The width of the checkbox.
|
||||
* @param height The height of the checkbox.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CCheckBox(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CCheckBox(void) { }
|
||||
|
||||
/**
|
||||
* Get the current state of the checkbox.
|
||||
*
|
||||
* @return The state of the checkbox.
|
||||
*/
|
||||
|
||||
virtual inline const CheckBoxState getState(void) const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of the checkbox.
|
||||
*
|
||||
* @param state The new checkbox state.
|
||||
*/
|
||||
|
||||
virtual void setState(CheckBoxState state);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCHECKBOX_HXX
|
||||
@@ -0,0 +1,357 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ccyclebutton.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCYLEBUTTON_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCYLEBUTTON_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbutton.hxx"
|
||||
#include "graphics/nxwidgets/ilistdataeventhandler.hxx"
|
||||
#include "graphics/nxwidgets/clistdata.hxx"
|
||||
#include "graphics/nxwidgets/clistdataitem.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Cycle button widget. Displays text within the button. Clicking it cycles
|
||||
* through its available options.
|
||||
*/
|
||||
|
||||
class CCycleButton : public CButton, public IListDataEventHandler
|
||||
{
|
||||
protected:
|
||||
|
||||
CListData m_options; /**< Option storage. */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Draws the outline of the button.
|
||||
*
|
||||
* @param port Graphics port to draw to.
|
||||
*/
|
||||
|
||||
virtual void drawOutline(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Selects the next option in the list and redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Prevents the CButton onResize() method from recalculating the text
|
||||
* positions by overriding it.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual inline void onResize(nxgl_coord_t width, nxgl_coord_t height) { }
|
||||
|
||||
/**
|
||||
* Override method in Label class to prevent recalculation of text positions.
|
||||
*/
|
||||
|
||||
virtual inline void calculateTextPosition(void) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CCycleButton(const CCycleButton &cycleButton) : CButton(cycleButton) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for cycle buttons.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the button, relative to its parent.
|
||||
* @param y The y coordinate of the button, relative to its parent.
|
||||
* @param width The width of the button.
|
||||
* @param height The height of the button.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The button will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CCycleButton(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CCycleButton(void) { }
|
||||
|
||||
/**
|
||||
* Add a new option to the widget.
|
||||
*
|
||||
* @param text The text of the option.
|
||||
* @param value The value of the option.
|
||||
*/
|
||||
|
||||
void addOption(const CNxString &text, const uint32_t value);
|
||||
|
||||
/**
|
||||
* Remove an option from the widget by its index.
|
||||
*
|
||||
* @param index The index of the option to remove.
|
||||
*/
|
||||
|
||||
virtual void removeOption(const int index);
|
||||
|
||||
/**
|
||||
* Remove all options from the widget.
|
||||
*/
|
||||
|
||||
virtual void removeAllOptions(void);
|
||||
|
||||
/**
|
||||
* Select an option by its index.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual void selectOption(const int index);
|
||||
|
||||
/**
|
||||
* Get the selected index. Returns -1 if nothing is selected. If more than one
|
||||
* option is selected, the index of the first selected option is returned.
|
||||
*
|
||||
* @return The selected index.
|
||||
*/
|
||||
|
||||
virtual const int getSelectedIndex(void) const;
|
||||
|
||||
/**
|
||||
* Sets the selected index. Specify -1 to select nothing. Resets any
|
||||
* other selected options to deselected.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The selected index.
|
||||
*/
|
||||
|
||||
virtual void setSelectedIndex(const int index);
|
||||
|
||||
/**
|
||||
* Get the selected option. Returns NULL if nothing is selected.
|
||||
*
|
||||
* @return The selected option.
|
||||
*/
|
||||
|
||||
virtual const CListDataItem *getSelectedOption(void) const;
|
||||
|
||||
/**
|
||||
* Get the value of the current option.
|
||||
*
|
||||
* @return Value of the current option.
|
||||
*/
|
||||
|
||||
inline const uint32_t getValue(void) const
|
||||
{
|
||||
const NXWidgets::CListDataItem *item = getSelectedOption();
|
||||
return item ? item->getValue() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specified option.
|
||||
*
|
||||
* @return The specified option.
|
||||
*/
|
||||
|
||||
virtual inline const CListDataItem *getOption(const int index)
|
||||
{
|
||||
return m_options.getItem(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the options alphabetically by the text of the options.
|
||||
*/
|
||||
|
||||
virtual void sort(void);
|
||||
|
||||
/**
|
||||
* Get the total number of options.
|
||||
*
|
||||
* @return The number of options.
|
||||
*/
|
||||
|
||||
virtual inline const int getOptionCount(void) const
|
||||
{
|
||||
return m_options.getItemCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not items added to the list are automatically sorted
|
||||
* on insert or not.
|
||||
*
|
||||
* @param sortInsertedItems True to enable sort on insertion.
|
||||
*/
|
||||
|
||||
virtual inline void setSortInsertedItems(const bool sortInsertedItems)
|
||||
{
|
||||
m_options.setSortInsertedItems(sortInsertedItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles list data changed events.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleListDataChangedEvent(const CListDataEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handles list selection changed events.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleListDataSelectionChangedEvent(const CListDataEventArgs &e);
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the widget's
|
||||
* parent. Value is based on the length of the largest string in the
|
||||
* set of options.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CCYLEBUTTON_HXX
|
||||
@@ -0,0 +1,238 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cbutton.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHBUTTON_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHBUTTON_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* Class representing a button that will display a glyph.
|
||||
* Class representing a clickable button that contains a bitmap image
|
||||
* instead of text. Displays two bitmaps, one when the button is clicked,
|
||||
* and one when it isn't. The bitmaps should be the same size.
|
||||
*/
|
||||
|
||||
class CGlyphButton : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
|
||||
FAR const struct SBitmap *m_bitmapNormal; /**< Bitmap when button is not clicked */
|
||||
FAR const struct SBitmap *m_bitmapClicked; /**< Bitmap when button is clicked */
|
||||
nxgl_coord_t m_bitmapX; /**< X coordinate of the bitmaps */
|
||||
nxgl_coord_t m_bitmapY; /**< Y coordinate of the bitmaps */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param port Graphics port to draw to.
|
||||
*/
|
||||
|
||||
virtual void drawOutline(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Raises an action event.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Raises a release event and redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CGlyphButton(const CGlyphButton &button) : CNxWidget(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the button.
|
||||
* @param y The y coordinate of the button.
|
||||
* @param width The width of the button.
|
||||
* @param height The height of the button.
|
||||
* @param normalGlyph Glyph to display when unclicked.
|
||||
* @param clickedGlyph Glyph to display when clicked.
|
||||
* @param bitmapX The x coordinate at which the bitmaps will be drawn.
|
||||
* @param bitmapY The y coordinate at which the bitmaps will be drawn.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The button will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CGlyphButton(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
nxgl_coord_t bitmapX, nxgl_coord_t bitmapY,
|
||||
FAR const struct SBitmap *normalGlyph,
|
||||
FAR const struct SBitmap *clickedGlyph,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CGlyphButton(void) { }
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the widget's
|
||||
* parent.
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHBUTTON_HXX
|
||||
@@ -0,0 +1,340 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cglyphsliderhorizontal.hxx
|
||||
*
|
||||
* Copyright (C) 2013, 2014 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHSLIDERHORIZONTAL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHSLIDERHORIZONTAL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "graphics/nxwidgets/csliderhorizontal.hxx"
|
||||
#include "graphics/nxwidgets/cglyphsliderhorizontalgrip.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Widget providing a sliding "grip" that can be moved left and
|
||||
* right in the "gutter". Essentially a scrollbar, but more
|
||||
* generic.
|
||||
*/
|
||||
|
||||
class CGlyphSliderHorizontal : public ISlider, public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CGlyphSliderHorizontalGrip *m_grip; /**< Pointer to the grip. */
|
||||
int m_minimumValue; /**< Minimum value that the grip can represent. */
|
||||
int m_maximumValue; /**< Maximum value that the grip can represent. */
|
||||
int32_t m_value; /**< Current value of the slider. */
|
||||
nxgl_coord_t m_minimumGripWidth; /**< Smallest width that the grip can become */
|
||||
nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
|
||||
the gutter. */
|
||||
int32_t m_gutterWidth; /**< Width of the gutter, taking into account
|
||||
any adjustments made to the width of the grip. */
|
||||
uint32_t m_contentSize; /**< Number of values in the min/max range. */
|
||||
nxwidget_pixel_t m_fillColor; /**< Fill color for left side of "fuel gague" */
|
||||
bool m_fill; /**< Set true if fill is active */
|
||||
uint32_t m_barThickness; /**< Thickness (in pixels) of the bar */
|
||||
|
||||
/**
|
||||
* Get the maximum possible value that the slider can represent. Useful when
|
||||
* using the slider as a scrollbar, as the height of the grip prevents the full
|
||||
* range of values being accessed (intentionally).
|
||||
* The returned value is shifted left 16 places for more accuracy in fixed-point
|
||||
* calculations.
|
||||
*
|
||||
* @return The maximum possible value that the slider can represent.
|
||||
*/
|
||||
|
||||
int32_t getPhysicalMaximumValueWithBitshift(void) const;
|
||||
|
||||
/**
|
||||
* Get the value represented by the top of the grip.
|
||||
* return The value represented by the top of the grip.
|
||||
*/
|
||||
|
||||
const int32_t getGripValue(void) const;
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the slider to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Moves the grip towards the mouse.
|
||||
*
|
||||
* @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);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param control The widget control instance for the window.
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param thickness The thickness of the slider.
|
||||
* @param gripBitmap The slider grip image
|
||||
* @param fillColor The color to use when filling the grip
|
||||
* @param fill True: The grip will be filled with fillColor
|
||||
*/
|
||||
|
||||
CGlyphSliderHorizontal(CWidgetControl *control,
|
||||
nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_coord_t thickness, IBitmap *gripBitmap,
|
||||
nxwidget_pixel_t fillColor, bool fill = true);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* NOTE: That the contained bitmap image is not destroyed when the image
|
||||
* container is destroyed.
|
||||
*/
|
||||
|
||||
virtual inline ~CGlyphSliderHorizontal(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
inline const int getMinimumValue(void) const
|
||||
{
|
||||
return m_minimumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest value that the slider can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
inline const int getMaximumValue(void) const
|
||||
{
|
||||
return m_maximumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the slider.
|
||||
*
|
||||
* return The current slider value.
|
||||
*/
|
||||
|
||||
inline const int getValue(void) const
|
||||
{
|
||||
return (int)(m_value >> 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value represented by the height of the grip. For sliders,
|
||||
* this would typically be 1 (so each new grip position is worth 1).
|
||||
* For scrollbars, this would be the height of the scrolling widget.
|
||||
*
|
||||
* @return The page size.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getPageSize(void) const
|
||||
{
|
||||
return m_pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the smallest value that the slider can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
inline void setMinimumValue(const int value)
|
||||
{
|
||||
m_minimumValue = value;
|
||||
m_contentSize = m_maximumValue - m_minimumValue + 1;
|
||||
//resizeGrip();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the largest value that the slider can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
inline void setMaximumValue(const int value)
|
||||
{
|
||||
m_maximumValue = value;
|
||||
m_contentSize = m_maximumValue - m_minimumValue + 1;
|
||||
//resizeGrip();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition
|
||||
* and redraw the grip.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition and redraw
|
||||
* the grip. The supplied value should be shifted left 16 places.
|
||||
* This ensures greater accuracy than the standard setValue() method if
|
||||
* the slider is being used as a scrollbar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValueWithBitshift(const int32_t value);
|
||||
|
||||
/**
|
||||
* Set the page size represented by the grip.
|
||||
*
|
||||
* @param pageSize The page size.
|
||||
* @see getPageSize().
|
||||
*/
|
||||
|
||||
inline void setPageSize(const nxgl_coord_t pageSize)
|
||||
{
|
||||
m_pageSize = pageSize;
|
||||
//resizeGrip();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the thickness of the slider bar
|
||||
*
|
||||
* @param thickness The slider bar thickness in pixels
|
||||
*/
|
||||
|
||||
inline void setBarThickness(const nxgl_coord_t thickness)
|
||||
{
|
||||
m_barThickness = thickness;
|
||||
redraw();
|
||||
};
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleDragEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can move through when
|
||||
* dragged.
|
||||
*
|
||||
* @return The smallest value that the slider can move through when
|
||||
* dragged.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getMinimumStep(void) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHSLIDERHORIZONTAL_HXX
|
||||
@@ -0,0 +1,205 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cglyphsliderhorizontalgrip.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHSLIDERHORIZONTALGRIP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHSLIDERHORIZONTALGRIP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "graphics/nxwidgets/csliderhorizontalgrip.hxx"
|
||||
#include "graphics/nxwidgets/cimage.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class IBitmap;
|
||||
|
||||
/**
|
||||
* Class representing the grip, or draggable button, with a horizontal
|
||||
* slider.
|
||||
*/
|
||||
|
||||
class CGlyphSliderHorizontalGrip : public CImage
|
||||
{
|
||||
protected:
|
||||
|
||||
/**
|
||||
* The CImage to represent the grip.
|
||||
*/
|
||||
|
||||
//CImage* m_pImage;
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
//virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
//virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the slider to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Starts dragging the grip and redraws it.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Redraws the grip.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the grip.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Moves the grip to follow the mouse.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
* @param vX The horizontal distance of the drag.
|
||||
* @param vY The vertical distance of the drag.
|
||||
*/
|
||||
|
||||
virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the grip, relative to its parent.
|
||||
* @param y The y coordinate of the grip, relative to its parent.
|
||||
* @param width The width of the grip.
|
||||
* @param height The height of the grip.
|
||||
*/
|
||||
|
||||
CGlyphSliderHorizontalGrip(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
IBitmap *pGripBitmap);
|
||||
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CGlyphSliderHorizontalGrip(void) { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGLYPHSLIDERHORIZONTALGRIP_HXX
|
||||
@@ -0,0 +1,489 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cgraphicsport.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGRAPHICSPORT_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGRAPHICSPORT_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/inxwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxFont;
|
||||
class CNxString;
|
||||
class CRect;
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* CGraphicsPort is the interface between a NXwidget and NX layer.
|
||||
*/
|
||||
|
||||
class CGraphicsPort
|
||||
{
|
||||
private:
|
||||
INxWindow *m_pNxWnd; /**< NX window interface. */
|
||||
#ifdef CONFIG_NX_WRITEONLY
|
||||
nxgl_mxpixel_t m_backColor; /**< The background color to use */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The underlying implementation for drawText functions
|
||||
* @param pos The window-relative x/y coordinate of the string.
|
||||
* @param bound The window-relative bounds of the string.
|
||||
* @param font The font to draw with.
|
||||
* @param string The string to output.
|
||||
* @param startIndex The start index within the string from which
|
||||
* drawing will commence.
|
||||
* @param length The number of characters to draw.
|
||||
* @param background Color to use for background if transparent is false.
|
||||
* @param transparent Whether to fill the background.
|
||||
*/
|
||||
|
||||
void _drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
|
||||
const CNxString &string, int startIndex, int length,
|
||||
nxgl_mxpixel_t background, bool transparent);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pNxWnd. An instance of the underlying window type.
|
||||
* @param backColor. The background color is only needed if we
|
||||
* cannot read from the graphics device.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_WRITEONLY
|
||||
CGraphicsPort(INxWindow *pNxWnd,
|
||||
nxgl_mxpixel_t backColor = CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR);
|
||||
#else
|
||||
CGraphicsPort(INxWindow *pNxWnd);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CGraphicsPort();
|
||||
|
||||
/**
|
||||
* Return the absolute x coordinate of the upper left hand corner of the
|
||||
* underlying window.
|
||||
*
|
||||
* @return The x coordinate of the window.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getX(void) const;
|
||||
|
||||
/**
|
||||
* Return the absolute y coordinate of the upper left hand corner of the
|
||||
* underlying window.
|
||||
*
|
||||
* @return The y coordinate of the window.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getY(void) const;
|
||||
|
||||
/**
|
||||
* Get the background color that will be used to fill in the spaces
|
||||
* when rendering fonts. This background color is ONLY used if the
|
||||
* LCD device does not support reading GRAM contents.
|
||||
*
|
||||
* @return. The current background color being used.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_WRITEONLY
|
||||
nxgl_mxpixel_t getBackColor(void) const
|
||||
{
|
||||
return m_backColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the background color that will be used to fill in the spaces
|
||||
* when rendering fonts. This background color is ONLY used if the
|
||||
* LCD device does not support reading GRAM contents.
|
||||
*
|
||||
* @return. The current background color being used.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_WRITEONLY
|
||||
void setBackColor(nxgl_mxpixel_t backColor)
|
||||
{
|
||||
m_backColor = backColor;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Draw a pixel into the window.
|
||||
*
|
||||
* @param x The window-relative x coordinate of the pixel.
|
||||
* @param y The window-relative y coordinate of the pixel.
|
||||
* @param color The color of the pixel.
|
||||
*/
|
||||
|
||||
void drawPixel(nxgl_coord_t x, nxgl_coord_t y, nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Draw a horizontal line of the specified start position, width, and
|
||||
* color.
|
||||
*
|
||||
* @param x The x coordinate of the line.
|
||||
* @param y The y coordinate of the top-most end of the line.
|
||||
* @param width The width of the line in pixels.
|
||||
* @param color The color of the line.
|
||||
*/
|
||||
|
||||
void drawHorizLine(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Draw a vertical line of the specified start position, width, and
|
||||
* color.
|
||||
*
|
||||
* @param x The x coordinate of the left-most end of the line.
|
||||
* @param y The y coordinate of the line.
|
||||
* @param height The height of the line in rows.
|
||||
* @param color The color of the line.
|
||||
*/
|
||||
|
||||
void drawVertLine(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t height,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Draw a line of a fixed color in the window.
|
||||
*
|
||||
* @param x1 The x coordinate of the start point of the line.
|
||||
* @param y1 The y coordinate of the start point of the line.
|
||||
* @param x2 The x coordinate of the end point of the line.
|
||||
* @param y2 The y coordinate of the end point of the line.
|
||||
* @param color The color of the line.
|
||||
* @param caps Draw a circular cap on the ends of the line to support
|
||||
* better line joins
|
||||
*/
|
||||
|
||||
void drawLine(nxgl_coord_t x1, nxgl_coord_t y1,
|
||||
nxgl_coord_t x2, nxgl_coord_t y2,
|
||||
nxgl_mxpixel_t color, enum INxWindow::ELineCaps caps);
|
||||
|
||||
/**
|
||||
* Draw a filled rectangle of the specified start position, end position,
|
||||
* width, and color.
|
||||
*
|
||||
* @param x The window-relative x coordinate of the rectangle.
|
||||
* @param y The window-relative y coordinate of the rectangle.
|
||||
* @param width The width of the rectangle in pixels.
|
||||
* @param height The height of the rectangle in rows.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
void drawFilledRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_coord_t height, nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Draw an unfilled rectangle to the window
|
||||
*
|
||||
* @param x The window-relative x coordinate of the rectangle.
|
||||
* @param y The window-relative y coordinate of the rectangle.
|
||||
* @param width The width of the rectangle.
|
||||
* @param height The height of the rectangle.
|
||||
* @param color The color of the rectangle .
|
||||
*/
|
||||
|
||||
void drawRect(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_coord_t height, nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Draw a bevelled rectangle to the window.
|
||||
*
|
||||
* @param x The x coordinate of the rectangle.
|
||||
* @param y The y coordinate of the rectangle.
|
||||
* @param width The width of the rectangle.
|
||||
* @param height The height of the rectangle.
|
||||
* @param shineColor The color of the top/left sides.
|
||||
* @param shadowColor The color of the bottom/right sides.
|
||||
*/
|
||||
|
||||
void drawBevelledRect(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
nxgl_mxpixel_t shineColor,
|
||||
nxgl_mxpixel_t shadowColor);
|
||||
|
||||
/**
|
||||
* Draw a filled circle at the specified position, size, and color.
|
||||
*
|
||||
* @param center The window-relative coordinates of the circle center.
|
||||
* @param radius The radius of the rectangle in pixels.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
inline void drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
nxgl_mxpixel_t color)
|
||||
{
|
||||
m_pNxWnd->drawFilledCircle(center, radius, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a string to the window.
|
||||
* @param pos The window-relative x/y coordinate of the string.
|
||||
* @param bound The window-relative bounds of the string.
|
||||
* @param font The font to draw with.
|
||||
* @param string The string to output.
|
||||
*/
|
||||
|
||||
void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
|
||||
const CNxString &string);
|
||||
|
||||
/**
|
||||
* Draw a particular length of a string to the window in a specific color.
|
||||
* @param pos The window-relative x/y coordinate of the string.
|
||||
* @param bound The window-relative bounds of the string.
|
||||
* @param font The font to draw with.
|
||||
* @param string The string to output.
|
||||
* @param startIndex The start index within the string from which
|
||||
* drawing will commence.
|
||||
* @param length The number of characters to draw.
|
||||
* @param color The color of the string.
|
||||
*/
|
||||
|
||||
void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
|
||||
const CNxString &string, int startIndex, int length,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Draw a portion of a string to the window.
|
||||
* @param pos The window-relative x/y coordinate of the string.
|
||||
* @param bound The window-relative bounds of the string.
|
||||
* @param font The font to draw with.
|
||||
* @param string The string to output.
|
||||
* @param startIndex The start index within the string from which
|
||||
* drawing will commence.
|
||||
* @param length The number of characters to draw.
|
||||
*/
|
||||
|
||||
void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
|
||||
const CNxString &string, int startIndex, int length);
|
||||
|
||||
/**
|
||||
* Draw a portion of a string to the window and fill the background
|
||||
* in one go.
|
||||
* @param pos The window-relative x/y coordinate of the string.
|
||||
* @param bound The window-relative bounds of the string.
|
||||
* @param font The font to draw with.
|
||||
* @param string The string to output.
|
||||
* @param startIndex The start index within the string from which
|
||||
* drawing will commence.
|
||||
* @param length The number of characters to draw.
|
||||
* @param color Foreground color
|
||||
* @param background Background color
|
||||
*/
|
||||
|
||||
void drawText(struct nxgl_point_s *pos, CRect *bound, CNxFont *font,
|
||||
const CNxString &string, int startIndex, int length,
|
||||
nxgl_mxpixel_t color, nxgl_mxpixel_t background);
|
||||
|
||||
/**
|
||||
* Draw an opaque bitmap to the window.
|
||||
*
|
||||
* @param x The window-relative x coordinate to draw the bitmap to.
|
||||
* @param y The window-relative y coordinate to draw the bitmap to.
|
||||
* @param width The width of the bitmap to draw.
|
||||
* @param height The height of the bitmap to draw.
|
||||
* @param bitmap Pointer to the bitmap to draw.
|
||||
* @param bitmapX The window-relative x coordinate within the supplied
|
||||
* bitmap to use as the origin.
|
||||
* @param bitmapY The window-relative y coordinate within the supplied
|
||||
* bitmap to use as the origin.
|
||||
*/
|
||||
|
||||
void drawBitmap(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const struct SBitmap *bitmap, int bitmapX, int bitmapY);
|
||||
|
||||
/**
|
||||
* Draw a bitmap to the window, using the supplied transparent
|
||||
* color as an invisible color.
|
||||
*
|
||||
* @param x The window-relative x coordinate to draw the bitmap to.
|
||||
* @param y The window-relative y coordinate to draw the bitmap to.
|
||||
* @param width The width of the bitmap to draw.
|
||||
* @param height The height of the bitmap to draw.
|
||||
* @param bitmap Pointer to the bitmap to draw.
|
||||
* @param bitmapX The window-relative x coordinate within the supplied bitmap to use as
|
||||
* the origin.
|
||||
* @param bitmapY The window-relative y coordinate within the supplied bitmap to use as
|
||||
* the origin.
|
||||
* @param transparentColor The transparent color used in the bitmap.
|
||||
*/
|
||||
|
||||
void drawBitmap(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const struct SBitmap *bitmap, int bitmapX, int bitmapY,
|
||||
nxgl_mxpixel_t transparentColor);
|
||||
|
||||
/**
|
||||
* Draw a bitmap to the port in greyscale.
|
||||
*
|
||||
* @param x The window-relative x coordinate to draw the bitmap to.
|
||||
* @param y The window-relative y coordinate to draw the bitmap to.
|
||||
* @param width The width of the bitmap to draw.
|
||||
* @param height The height of the bitmap to draw.
|
||||
* @param bitmap Pointer to the bitmap to draw.
|
||||
* @param bitmapX The window-relative x coordinate within the supplied bitmap to use as
|
||||
* the origin.
|
||||
* @param bitmapY The window-relative y coordinate within the supplied bitmap to use as
|
||||
* the origin.
|
||||
*/
|
||||
|
||||
void drawBitmapGreyScale(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const struct SBitmap *bitmap, int bitmapX, int bitmapY);
|
||||
|
||||
/**
|
||||
* Copy a rectangular region from the source coordinateinates to the
|
||||
* destination coordinateinates.
|
||||
*
|
||||
* @param sourceX Source x coordinate.
|
||||
* @param sourceY Source y coordinate.
|
||||
* @param destX Destination x coordinate.
|
||||
* @param destY Destination y coordinate.
|
||||
* @param width Width of the rectangle to copy.
|
||||
* @param height Height of the rectangle to copy.
|
||||
*/
|
||||
|
||||
void copy(nxgl_coord_t sourceX, nxgl_coord_t sourceY,
|
||||
nxgl_coord_t destX, nxgl_coord_t destY,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Move a region by a specified distance in two dimensions.
|
||||
*
|
||||
* @param x X coordinate of the source area to move.
|
||||
* @param y Y coordinate of the source area to move.
|
||||
* @param deltaX Horizontal distance to move.
|
||||
* @param deltaY Vertical distance to move.
|
||||
* @param width Width of the area to move.
|
||||
* @param height Height of the area to move.
|
||||
*/
|
||||
|
||||
void move(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t deltaX, nxgl_coord_t deltaY,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Convert the region to greyscale.
|
||||
*
|
||||
* @param x X coordinate of the region to change.
|
||||
* @param y Y coordinate of the region to change.
|
||||
* @param width Width of the region to change.
|
||||
* @param height Height of the region to change.
|
||||
*/
|
||||
|
||||
void greyScale(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Invert colors in a region. NOTE: This allocates an in-memory
|
||||
* buffer the size of one row in graphic memory. So it may only be
|
||||
* useful for inverting small regions and its only current use is for
|
||||
* the inverted cursor text.
|
||||
*
|
||||
* @param x X coordinate of the region to change.
|
||||
* @param y Y coordinate of the region to change.
|
||||
* @param width Width of the region to change.
|
||||
* @param height Height of the region to change.
|
||||
*/
|
||||
|
||||
void invert(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CGRAPHICSPORT_HXX
|
||||
346
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cimage.hxx
Normal file
346
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cimage.hxx
Normal file
@@ -0,0 +1,346 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cimage.hxx
|
||||
*
|
||||
* Copyright (C) 2012-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CIMAGE_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CIMAGE_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class IBitmap;
|
||||
|
||||
/**
|
||||
* Simple image widget for present static images in the widget framework.
|
||||
*/
|
||||
|
||||
class CImage : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
FAR IBitmap *m_bitmap; /**< Source bitmap image */
|
||||
struct nxgl_point_s m_origin; /**< Origin for offset image display position */
|
||||
bool m_highlighted; /**< Image is highlighted */
|
||||
|
||||
/**
|
||||
* Draw the area of this widget that falls within the clipping region.
|
||||
* Called by the drawContents(port) and by classes that inherit from
|
||||
* CImage.
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
void drawContents(CGraphicsPort *port, bool selected);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Draw the border of this widget. Called by the indirectly via
|
||||
* drawBoard(port) and also by classes that inherit from CImage.
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
void drawBorder(CGraphicsPort *port, bool selected);
|
||||
|
||||
/**
|
||||
* Draw the border of this widget. Called by the redraw() function to draw
|
||||
* all visible regions.
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Raises an action.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the image.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the image.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CImage(const CImage &label) : CNxWidget(label) { };
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for an image.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the image box, relative to its parent.
|
||||
* @param y The y coordinate of the image box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param bitmap The source bitmap image.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height, FAR IBitmap *bitmap,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* NOTE: That the contained bitmap image is not destroyed when the image
|
||||
* container is destroyed.
|
||||
*/
|
||||
|
||||
virtual inline ~CImage() { }
|
||||
|
||||
/**
|
||||
* Get pointer to the bitmap that this image contains.
|
||||
*/
|
||||
|
||||
inline FAR IBitmap *getBitmap() const { return m_bitmap; }
|
||||
|
||||
/**
|
||||
* Set the bitmap that this image contains.
|
||||
*/
|
||||
|
||||
inline void setBitmap(FAR IBitmap *bitmap) { m_bitmap = bitmap; }
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the
|
||||
* widget's parent.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
void getPreferredDimensions(CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Set the horizontal position of the bitmap. Zero is the left edge
|
||||
* of the bitmap and values >0 will move the bit map to the right.
|
||||
* This method is useful for horizontal scrolling a large bitmap
|
||||
* within a smaller window
|
||||
*/
|
||||
|
||||
void setImageLeft(nxgl_coord_t column);
|
||||
|
||||
/**
|
||||
* Align the image at the left of the widget region.
|
||||
*
|
||||
* NOTE: The CImage widget does not support any persistent alignment
|
||||
* attribute (at least not at the moment). As a result, this alignment
|
||||
* can be lost if the image is changed or if the widget is resized.
|
||||
*/
|
||||
|
||||
inline void alignHorizontalLeft(void)
|
||||
{
|
||||
setImageLeft(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Align the image at the left of the widget region.
|
||||
*
|
||||
* NOTE: The CImage widget does not support any persistent alignment
|
||||
* attribute (at least not at the moment). As a result, this alignment
|
||||
* can be lost if the image is changed or if the widget is resized.
|
||||
*/
|
||||
|
||||
void alignHorizontalCenter(void);
|
||||
|
||||
/**
|
||||
* Align the image at the left of the widget region.
|
||||
*
|
||||
* NOTE: The CImage widget does not support any persistent alignment
|
||||
* attribute (at least not at the moment). As a result, this alignment
|
||||
* can be lost if the image is changed or if the widget is resized.
|
||||
*/
|
||||
|
||||
void alignHorizontalRight(void);
|
||||
|
||||
/**
|
||||
* Set the vertical position of the bitmap. Zero is the top edge
|
||||
* of the bitmap and values >0 will move the bit map down.
|
||||
* This method is useful for vertical scrolling a large bitmap
|
||||
* within a smaller window
|
||||
*/
|
||||
|
||||
void setImageTop(nxgl_coord_t row);
|
||||
|
||||
/**
|
||||
* Align the image at the top of the widget region.
|
||||
*
|
||||
* NOTE: The CImage widget does not support any persistent alignment
|
||||
* attribute (at least not at the moment). As a result, this alignment
|
||||
* can be lost if the image is changed or if the widget is resized.
|
||||
*/
|
||||
|
||||
inline void alignVerticalTop(void)
|
||||
{
|
||||
setImageTop(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Align the image at the middle of the widget region.
|
||||
*
|
||||
* NOTE: The CImage widget does not support any persistent alignment
|
||||
* attribute (at least not at the moment). As a result, this alignment
|
||||
* can be lost if the image is changed or if the widget is resized.
|
||||
*/
|
||||
|
||||
void alignVerticalCenter(void);
|
||||
|
||||
/**
|
||||
* Align the image at the left of the widget region.
|
||||
*
|
||||
* NOTE: The CImage widget does not support any persistent alignment
|
||||
* attribute (at least not at the moment). As a result, this alignment
|
||||
* can be lost if the image is changed or if the widget is resized.
|
||||
*/
|
||||
|
||||
void alignVerticalBottom(void);
|
||||
|
||||
/**
|
||||
* Control the highlight state.
|
||||
*
|
||||
* @param highlightOn True(1), the image will be highlighted
|
||||
*/
|
||||
|
||||
void highlight(bool highlightOn);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CIMAGE_HXX
|
||||
156
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ckeypad.hxx
Normal file
156
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ckeypad.hxx
Normal file
@@ -0,0 +1,156 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ckeypad.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbuttonarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#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 */
|
||||
|
||||
/**
|
||||
* Configure the keypad for the currently selected display mode.
|
||||
*/
|
||||
|
||||
void configureKeypadMode(void);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CKEYPAD_HXX
|
||||
357
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clabel.hxx
Normal file
357
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clabel.hxx
Normal file
@@ -0,0 +1,357 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/clabel.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABEL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABEL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CRect;
|
||||
|
||||
/**
|
||||
* Single-line label widget. Can align text both vertically and
|
||||
* horizontally in different ways.
|
||||
*/
|
||||
|
||||
class CLabel : public CNxWidget
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum of horizontal alignment options.
|
||||
*/
|
||||
|
||||
enum TextAlignmentHoriz
|
||||
{
|
||||
TEXT_ALIGNMENT_HORIZ_CENTER = 0, /**< Centre the text */
|
||||
TEXT_ALIGNMENT_HORIZ_LEFT = 1, /**< Align left */
|
||||
TEXT_ALIGNMENT_HORIZ_RIGHT = 2 /**< Align right */
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum of vertical alignment options.
|
||||
*/
|
||||
|
||||
enum TextAlignmentVert
|
||||
{
|
||||
TEXT_ALIGNMENT_VERT_CENTER = 0, /**< Align to centre of textbox */
|
||||
TEXT_ALIGNMENT_VERT_TOP = 1, /**< Align to top of textbox */
|
||||
TEXT_ALIGNMENT_VERT_BOTTOM = 2 /**< Align to bottom of textbox */
|
||||
};
|
||||
|
||||
protected:
|
||||
CNxString m_text; /**< Text that the textbox will display */
|
||||
struct nxgl_point_s m_align; /**< X/Y offset for text alignment */
|
||||
TextAlignmentHoriz m_hAlignment; /**< Horizontal alignment of the text */
|
||||
TextAlignmentVert m_vAlignment; /**< Vertical alignment of the text */
|
||||
bool m_textChange; /**< Redraw is due to a text change */
|
||||
bool m_highlighted; /**< Label is highlighted */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
*
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the widget to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Calculate the vertical position of the string based on the font
|
||||
*
|
||||
* height and the alignment options.
|
||||
*/
|
||||
|
||||
virtual void calculateTextPositionVertical(void);
|
||||
|
||||
/**
|
||||
* Calculate the position of the string based on its length and the
|
||||
* alignment options.
|
||||
*/
|
||||
|
||||
virtual void calculateTextPositionHorizontal(void);
|
||||
|
||||
/**
|
||||
* Updates the GUI after the text has changed.
|
||||
*/
|
||||
|
||||
virtual void onTextChange(void);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CLabel(const CLabel &label) : CNxWidget(label) { };
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for a label containing a string.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the text box, relative to its parent.
|
||||
* @param y The y coordinate of the text box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param text Pointer to a string to display in the textbox.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CLabel(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height, const CNxString &text,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CLabel() { }
|
||||
|
||||
/**
|
||||
* Set the horizontal alignment of text within the label.
|
||||
*
|
||||
* @param alignment The horizontal position of the text.
|
||||
*/
|
||||
|
||||
virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
|
||||
|
||||
/**
|
||||
* Set the vertical alignment of text within the label.
|
||||
*
|
||||
* @param alignment The vertical position of the text.
|
||||
*/
|
||||
|
||||
virtual void setTextAlignmentVert(TextAlignmentVert alignment);
|
||||
|
||||
/**
|
||||
* Set the horizontal alignment of text within the label.
|
||||
*
|
||||
* @param alignment The horizontal position of the text.
|
||||
*/
|
||||
|
||||
inline const TextAlignmentHoriz getTextAlignmentHoriz(void) const
|
||||
{
|
||||
return m_hAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the vertical alignment of text within the label.
|
||||
*
|
||||
* @param alignment The vertical position of the text.
|
||||
*/
|
||||
|
||||
inline const TextAlignmentVert getTextAlignmentVert(void) const
|
||||
{
|
||||
return m_vAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string shown in the label.
|
||||
*
|
||||
* @return The label's text.
|
||||
*/
|
||||
|
||||
virtual inline const CNxString &getText(void) const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text displayed in the label.
|
||||
*
|
||||
* @param text String to display.
|
||||
*/
|
||||
|
||||
virtual void setText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Append new text to the end of the current text displayed in the
|
||||
* label.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
virtual void appendText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Insert text at the specified index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index Index at which to insert the text.
|
||||
*/
|
||||
|
||||
virtual void insertText(const CNxString &text, const int index);
|
||||
|
||||
/**
|
||||
* Control the highlight state.
|
||||
*
|
||||
* @param highlightOn True(1), the label will be highlighted
|
||||
*/
|
||||
|
||||
virtual void highlight(bool highlightOn);
|
||||
|
||||
/**
|
||||
* Return the current highlight state.
|
||||
*
|
||||
* @return True if the label is highlighted
|
||||
*/
|
||||
|
||||
virtual inline bool isHighlighted(void) const
|
||||
{
|
||||
return m_highlighted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the
|
||||
* widget's parent.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Sets the font.
|
||||
*
|
||||
* @param font A pointer to the font to use.
|
||||
*
|
||||
* NOTE: This font is not deleted when the widget is destroyed!
|
||||
*/
|
||||
|
||||
virtual void setFont(CNxFont *font);
|
||||
|
||||
/**
|
||||
* Is the redraw due to a text-only change?
|
||||
*
|
||||
* @return True if the redraw was caused by a text change
|
||||
*/
|
||||
|
||||
virtual inline bool isTextChange(void) const
|
||||
{
|
||||
return m_textChange;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABEL_HXX
|
||||
190
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clabelgrid.hxx
Normal file
190
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clabelgrid.hxx
Normal file
@@ -0,0 +1,190 @@
|
||||
/****************************************************************************
|
||||
* apps/include/nxwidgets/include/clabelgrid.hxx
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Petteri Aimonen <jpa@kapsi.fi>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABELGRIG_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABELGRIG_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CRect;
|
||||
class CLabel;
|
||||
|
||||
/**
|
||||
* 2-dimensional grid of labels. Each row and column can have custom
|
||||
* label styles applied.
|
||||
*/
|
||||
|
||||
class CLabelGrid : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
int m_cols;
|
||||
int m_rows;
|
||||
|
||||
TNxArray<CLabel*> m_labels;
|
||||
TNxArray<int> m_colwidths;
|
||||
TNxArray<int> m_rowheights;
|
||||
|
||||
/**
|
||||
* Resize the widget to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for a grid of labels
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the text box, relative to its parent.
|
||||
* @param y The y coordinate of the text box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param cols Number of columns in the grid.
|
||||
* @param rows Number of rows in the grid.
|
||||
*/
|
||||
|
||||
CLabelGrid(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height, int cols, int rows);
|
||||
|
||||
virtual inline ~CLabelGrid() { }
|
||||
|
||||
/**
|
||||
* Get reference to the label at particular position of the grid.
|
||||
*
|
||||
* @param col Zero-based index of the column.
|
||||
* @param row Zero-based index of the row.
|
||||
* @returns Reference to CLabel.
|
||||
*/
|
||||
|
||||
virtual CLabel &at(int col, int row);
|
||||
|
||||
/**
|
||||
* Set width of a column.
|
||||
*
|
||||
* @param col Zero-based index of the column.
|
||||
* @param width Width of column in pixels, or -1 to size automatically.
|
||||
*/
|
||||
|
||||
void setColumnWidth(int col, int width);
|
||||
|
||||
/**
|
||||
* Set height of a row.
|
||||
*
|
||||
* @param row Zero-based index of the row.
|
||||
* @param height Height of row in pixels, or -1 to size automatically.
|
||||
*/
|
||||
|
||||
void setRowHeight(int row, int height);
|
||||
|
||||
void setBackgroundColor(nxgl_mxpixel_t color);
|
||||
|
||||
void setBorderless(bool borderless);
|
||||
|
||||
void useWidgetStyle(const CWidgetStyle *style);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABELGRIG_HXX
|
||||
@@ -0,0 +1,173 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/clatchbutton.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLATCHBUTTON_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLATCHBUTTON_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cstickybutton.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* CButton that latches down when clicked and unlatches when clicked again.
|
||||
*/
|
||||
|
||||
class CLatchButton : public CStickyButton
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Handles button click events
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CLatchButton(const CLatchButton &button) : CStickyButton(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for buttons that display a string.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display.
|
||||
* @param x The x coordinate of the button, relative to its parent.
|
||||
* @param y The y coordinate of the button, relative to its parent.
|
||||
* @param width The width of the button.
|
||||
* @param height The height of the button.
|
||||
* @param text The text for the button to display.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CLatchButton(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const CNxString &text,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CLatchButton(void) { }
|
||||
|
||||
/**
|
||||
* Check if the button is latched
|
||||
*
|
||||
* @return True if the button is latched
|
||||
*/
|
||||
|
||||
inline const bool isLatched(void) const
|
||||
{
|
||||
return isStuckDown();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLATCHBUTTON_HXX
|
||||
@@ -0,0 +1,170 @@
|
||||
/****************************************************************************
|
||||
* include/clatchbuttonarray.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLATCHBUTTONARRAY_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLATCHBUTTONARRAY_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cstickybuttonarray.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CNxString;
|
||||
|
||||
/**
|
||||
* Manages a two-dimensional array of buttons as one widget. When a button
|
||||
* is clicked is latches (i.e., it stays pushed after the press is released.
|
||||
* The behavior is then like radio buttons: Pressing each each button in
|
||||
* the array unlatches the previous button and latches the new button.
|
||||
*
|
||||
* Unlike CLatchButton, pressing the same button more than once has no
|
||||
* effect.
|
||||
*/
|
||||
|
||||
class CLatchButtonArray : public CStickyButtonArray
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Handles button click events
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Redraws the button.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CLatchButtonArray(const CLatchButtonArray &button) : CStickyButtonArray(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for an array of latch buttons.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the button array, relative to its parent.
|
||||
* @param y The y coordinate of the button array, relative to its parent.
|
||||
* @param buttonColumns The number of buttons in one row of the button array
|
||||
* @param buttonRows The number of buttons in one column of the button array
|
||||
* @param buttonWidth The width of one button
|
||||
* @param buttonHeight The height of one button
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CLatchButtonArray(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
uint8_t buttonColumns, uint8_t buttonRows,
|
||||
nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* CLatchButtonArray Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CLatchButtonArray(void) { }
|
||||
|
||||
/**
|
||||
* Return the position of the last latched button (0,0 will be returned
|
||||
* the no button has every been latched). The button at this position
|
||||
* is currently latched then, in addition, return true.
|
||||
*
|
||||
* @param column The location to return the column index of the button
|
||||
* of interest
|
||||
* @param row The location to return the row index of the button of
|
||||
* interest
|
||||
* @return True if a button in the array is latched
|
||||
*/
|
||||
|
||||
inline const bool isAnyButtonLatched(int &column, int &row) const
|
||||
{
|
||||
return isAnyButtonStuckDown(column, row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this specific button in the array is latched
|
||||
*
|
||||
* @param column The column of the button to check.
|
||||
* @param row The row of the button to check.
|
||||
* @return True if this button is clicked
|
||||
*/
|
||||
|
||||
inline const bool isThisButtonLatched(int column, int row) const
|
||||
{
|
||||
return isThisButtonStuckDown(column, row);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLATCHBUTTONARRAY_HXX
|
||||
430
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clistbox.hxx
Normal file
430
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clistbox.hxx
Normal file
@@ -0,0 +1,430 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/clistbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdbool>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/cscrollingpanel.hxx"
|
||||
#include "graphics/nxwidgets/ilistdataeventhandler.hxx"
|
||||
#include "graphics/nxwidgets/clistdata.hxx"
|
||||
#include "graphics/nxwidgets/clistboxdataitem.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/ilistbox.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class providing a scrollable list of options. The CListBox can be set
|
||||
* up to only allow one selection or multiple selections. Processes
|
||||
* double-clicks and raises double-click events, so that a double-click
|
||||
* on an option can be made to automatically select and close a window/etc.
|
||||
* The options themselves have user-definable text and background colors
|
||||
* for their selected and unselected states.
|
||||
*/
|
||||
|
||||
class CListBox : public IListBox, public CScrollingPanel,
|
||||
public IListDataEventHandler
|
||||
{
|
||||
protected:
|
||||
CListData m_options; /**< Option storage. */
|
||||
uint8_t m_optionPadding; /**< Padding between options. */
|
||||
int m_lastSelectedIndex; /**< Index of the last option selected. */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Determines which item was clicked and selects or deselects it as
|
||||
* appropriate. Also starts the dragging system.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Selects the clicked item and deselects all others.
|
||||
*
|
||||
* @param x The x coordinate of the click.
|
||||
* @param y The y coordinate of the click.
|
||||
*/
|
||||
|
||||
virtual void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Select or deselect an option by its index. Does not deselect any other
|
||||
* selected options. Set index to -1 to select nothing. Redraws the widget
|
||||
* and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
* @param selected True to select the option, false to deselect it.
|
||||
*/
|
||||
|
||||
virtual void setOptionSelected(const int index, const bool selected);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CListBox(const CListBox &listBox) : CScrollingPanel(listBox) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display.
|
||||
* @param x The x coordinate of the widget.
|
||||
* @param y The y coordinate of the widget.
|
||||
* @param width The width of the widget.
|
||||
* @param height The height of the widget.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CListBox(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CListBox(void);
|
||||
|
||||
/**
|
||||
* Add a new option to the widget using default colors.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
*/
|
||||
|
||||
virtual void addOption(const CNxString &text, const uint32_t value);
|
||||
|
||||
/**
|
||||
* Add an option to the widget.
|
||||
*
|
||||
* @param option The option to add.
|
||||
*/
|
||||
|
||||
virtual void addOption(CListBoxDataItem *option);
|
||||
|
||||
/**
|
||||
* Remove an option from the widget by its index.
|
||||
*
|
||||
* @param index The index of the option to remove.
|
||||
*/
|
||||
|
||||
virtual void removeOption(const int index);
|
||||
|
||||
/**
|
||||
* Remove all options from the widget.
|
||||
*/
|
||||
|
||||
virtual void removeAllOptions(void);
|
||||
|
||||
/**
|
||||
* Add a new option to the widget.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
* @param normalTextColor Color to draw the text with when not selected.
|
||||
* @param normalBackColor Color to draw the background with when not selected.
|
||||
* @param selectedTextColor Color to draw the text with when selected.
|
||||
* @param selectedBackColor Color to draw the background with when selected.
|
||||
*/
|
||||
|
||||
virtual void addOption(const CNxString &text, const uint32_t value,
|
||||
const nxwidget_pixel_t normalTextColor,
|
||||
const nxwidget_pixel_t normalBackColor,
|
||||
const nxwidget_pixel_t selectedTextColor,
|
||||
const nxwidget_pixel_t selectedBackColor);
|
||||
|
||||
/**
|
||||
* Select an option by its index.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual void selectOption(const int index);
|
||||
|
||||
/**
|
||||
* De-select an option by its index.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual void deselectOption(const int index);
|
||||
|
||||
/**
|
||||
* Select all options. Does nothing if the listbox does not allow
|
||||
* multiple selections. Redraws the widget and raises a value changed
|
||||
* event.
|
||||
*/
|
||||
|
||||
virtual void selectAllOptions(void);
|
||||
|
||||
/**
|
||||
* Deselect all options.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*/
|
||||
|
||||
virtual void deselectAllOptions(void);
|
||||
|
||||
/**
|
||||
* Get the selected index. Returns -1 if nothing is selected. If
|
||||
* more than one option is selected, the index of the first selected
|
||||
* option is returned.
|
||||
*
|
||||
* @return The selected index.
|
||||
*/
|
||||
|
||||
virtual const int getSelectedIndex(void) const;
|
||||
|
||||
/**
|
||||
* Sets the selected index. Specify -1 to select nothing. Resets any
|
||||
* other selected options to deselected. Redraws the widget and raises
|
||||
* a value changed event.
|
||||
*
|
||||
* @param index The selected index.
|
||||
*/
|
||||
|
||||
virtual void setSelectedIndex(const int index);
|
||||
|
||||
/**
|
||||
* Get the selected option. Returns NULL if nothing is selected.
|
||||
*
|
||||
* @return The selected option.
|
||||
*/
|
||||
|
||||
virtual const CListBoxDataItem *getSelectedOption(void) const;
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @param allowMultipleSelections True to allow multiple selections.
|
||||
*/
|
||||
|
||||
virtual inline void
|
||||
setAllowMultipleSelections(const bool allowMultipleSelections)
|
||||
{
|
||||
m_options.setAllowMultipleSelections(allowMultipleSelections);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @return True if multiple selections are allowed.
|
||||
*/
|
||||
|
||||
virtual inline const bool allowsMultipleSelections(void) const
|
||||
{
|
||||
return m_options.allowsMultipleSelections();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the scrolling canvas to encompass all options.
|
||||
*/
|
||||
|
||||
virtual void resizeCanvas(void);
|
||||
|
||||
/**
|
||||
* Get the specified option.
|
||||
*
|
||||
* @return The specified option.
|
||||
*/
|
||||
|
||||
virtual inline const CListBoxDataItem *getOption(const int index)
|
||||
{
|
||||
return (const CListBoxDataItem *)m_options.getItem(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the options alphabetically by the text of the options.
|
||||
*/
|
||||
|
||||
virtual void sort(void);
|
||||
|
||||
/**
|
||||
* Get the total number of options.
|
||||
*
|
||||
* @return The number of options.
|
||||
*/
|
||||
|
||||
virtual inline const int getOptionCount(void) const
|
||||
{
|
||||
return m_options.getItemCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of a single option.
|
||||
*
|
||||
* @return The height of an option.
|
||||
*/
|
||||
|
||||
virtual const nxgl_coord_t getOptionHeight(void) const;
|
||||
|
||||
/**
|
||||
* Sets whether or not items added to the list are automatically sorted on insert or not.
|
||||
*
|
||||
* @param sortInsertedItems True to enable sort on insertion.
|
||||
*/
|
||||
|
||||
virtual inline void setSortInsertedItems(const bool sortInsertedItems)
|
||||
{
|
||||
m_options.setSortInsertedItems(sortInsertedItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles list data changed events.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleListDataChangedEvent(const CListDataEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handles list selection changed events.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleListDataSelectionChangedEvent(const CListDataEventArgs &e);
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the widget's
|
||||
* parent. Value is based on the length of the largest string in the
|
||||
* set of options.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Check if the click is a double-click.
|
||||
*
|
||||
* @param x X coordinate of the click.
|
||||
* @param y Y coordinate of the click.
|
||||
* @return True if the click is a double-click.
|
||||
*/
|
||||
|
||||
virtual bool isDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTBOX_HXX
|
||||
@@ -0,0 +1,179 @@
|
||||
/****************************************************************************
|
||||
* include/clistboxdataitem.hxx
|
||||
*apps/include/graphics/nxwidgets/
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTBOXDATAITEM_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTBOXDATAITEM_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/clistdataitem.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class representing a data item within a ListBox.
|
||||
*/
|
||||
|
||||
class CListBoxDataItem : public CListDataItem
|
||||
{
|
||||
private:
|
||||
nxwidget_pixel_t m_normalTextColor; /**< Color used for text when not selected. */
|
||||
nxwidget_pixel_t m_normalBackColor; /**< Color used for background when not selected. */
|
||||
nxwidget_pixel_t m_selectedTextColor; /**< Color used for text when selected. */
|
||||
nxwidget_pixel_t m_selectedBackColor; /**< Color used for background when selected. */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param text The text to display in the item.
|
||||
* @param value The value of the item.
|
||||
* @param normalTextColor Color to draw the text with when not selected.
|
||||
* @param normalBackColor Color to draw the background with when not selected.
|
||||
* @param selectedTextColor Color to draw the text with when selected.
|
||||
* @param selectedBackColor Color to draw the background with when selected.
|
||||
*/
|
||||
|
||||
CListBoxDataItem(const CNxString &text, const uint32_t value,
|
||||
const nxwidget_pixel_t normalTextColor,
|
||||
const nxwidget_pixel_t normalBackColor,
|
||||
const nxwidget_pixel_t selectedTextColor,
|
||||
const nxwidget_pixel_t selectedBackColor);
|
||||
|
||||
/**
|
||||
* Get the color used for text when the item is unselected.
|
||||
*
|
||||
* @return The text color when the item is unselected.
|
||||
*/
|
||||
|
||||
inline nxwidget_pixel_t getNormalTextColor(void) const
|
||||
{
|
||||
return m_normalTextColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color used for the background when the item is unselected.
|
||||
*
|
||||
* @return The background color when the item is unselected.
|
||||
*/
|
||||
|
||||
inline nxwidget_pixel_t getNormalBackColor(void) const
|
||||
{
|
||||
return m_normalBackColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color used for text when the item is selected.
|
||||
*
|
||||
* @return The text color when the item is selected.
|
||||
*/
|
||||
|
||||
inline nxwidget_pixel_t getSelectedTextColor(void) const
|
||||
{
|
||||
return m_selectedTextColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color used for the background when the item is selected.
|
||||
*
|
||||
* @return The background color when the item is selected.
|
||||
*/
|
||||
|
||||
inline nxwidget_pixel_t getSelectedBackColor(void) const
|
||||
{
|
||||
return m_selectedBackColor;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTBOXDATAITEM_HXX
|
||||
358
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clistdata.hxx
Normal file
358
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/clistdata.hxx
Normal file
@@ -0,0 +1,358 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/clistdata.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATA_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATA_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdbool>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
#include "graphics/nxwidgets/ilistdataeventhandler.hxx"
|
||||
#include "graphics/nxwidgets/clistdataitem.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class representing a list of items. Designed to be used by the
|
||||
* CListBox class, etc, to store its data. Fires events to notify
|
||||
* listeners when the list changes or a new selection is made.
|
||||
*/
|
||||
|
||||
class CListData
|
||||
{
|
||||
protected:
|
||||
TNxArray<CListDataItem*> m_items; /**< Collection of list data items. */
|
||||
TNxArray<IListDataEventHandler*> m_listDataEventhandlers; /**< Collection of event handlers. */
|
||||
bool m_allowMultipleSelections; /**< If true, multiple options can
|
||||
be selected. */
|
||||
bool m_sortInsertedItems; /**< Automatically sorts items on
|
||||
insertion if true. */
|
||||
|
||||
/**
|
||||
* Quick sort the items using their compareTo() methods.
|
||||
*
|
||||
* @param start The index to start sorting at.
|
||||
* @param end The index to stop sorting at.
|
||||
*/
|
||||
|
||||
virtual void quickSort(const int start, const int end);
|
||||
|
||||
/**
|
||||
* Swap the locations of two items in the array.
|
||||
*
|
||||
* @param index1 The index of the first item to swap.
|
||||
* @param index2 The index of the second item to swap.
|
||||
*/
|
||||
|
||||
virtual void swapItems(const int index1, const int index2);
|
||||
|
||||
/**
|
||||
* Return the index that an item should be inserted at to maintain a sorted list of data.
|
||||
*
|
||||
* @param item The item to insert.
|
||||
* @return The index that the item should be imserted into at.
|
||||
*/
|
||||
|
||||
const int getSortedInsertionIndex(const CListDataItem *item) const;
|
||||
|
||||
/**
|
||||
* Raise a data changed event.
|
||||
*/
|
||||
|
||||
void raiseDataChangedEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a selection changed event.
|
||||
*/
|
||||
|
||||
void raiseSelectionChangedEvent(void);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
CListData(void);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~CListData(void);
|
||||
|
||||
/**
|
||||
* Add a new item.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
*/
|
||||
|
||||
virtual void addItem(const CNxString &text, const uint32_t value);
|
||||
|
||||
/**
|
||||
* Add an existing item. CListData becomes the owner of the option and will delete it
|
||||
* when the list is deleted.
|
||||
*
|
||||
* @param item The item to add.
|
||||
*/
|
||||
|
||||
virtual void addItem(CListDataItem *item);
|
||||
|
||||
/**
|
||||
* Remove an item by its index.
|
||||
*
|
||||
* @param index The index of the option to remove.
|
||||
*/
|
||||
|
||||
virtual void removeItem(const int index);
|
||||
|
||||
/**
|
||||
* Select an item by its index.
|
||||
*
|
||||
* @param index The index of the item to select.
|
||||
*/
|
||||
|
||||
virtual void selectItem(const int index);
|
||||
|
||||
/**
|
||||
* Deselect an item by its index.
|
||||
*
|
||||
* @param index The index of the item to select.
|
||||
*/
|
||||
|
||||
virtual void deselectItem(const int index);
|
||||
|
||||
/**
|
||||
* Remove all items.
|
||||
*/
|
||||
|
||||
virtual void removeAllItems(void);
|
||||
|
||||
/**
|
||||
* Get the selected index. Returns -1 if nothing is selected. If more than one
|
||||
* item is selected, the index of the first selected item is returned.
|
||||
*
|
||||
* @return The selected index.
|
||||
*/
|
||||
|
||||
virtual const int getSelectedIndex(void) const;
|
||||
|
||||
/**
|
||||
* Sets the selected index. Specify -1 to select nothing. Resets any
|
||||
* other selected items to deselected.
|
||||
*
|
||||
* @param index The selected index.
|
||||
*/
|
||||
|
||||
virtual void setSelectedIndex(const int index);
|
||||
|
||||
/**
|
||||
* Get the selected item. Returns NULL if nothing is selected.
|
||||
*
|
||||
* @return The selected option.
|
||||
*/
|
||||
|
||||
virtual const CListDataItem *getSelectedItem(void) const;
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @param allowMultipleSelections True to allow multiple selections.
|
||||
*/
|
||||
|
||||
virtual inline void
|
||||
setAllowMultipleSelections(const bool allowMultipleSelections)
|
||||
{
|
||||
m_allowMultipleSelections = allowMultipleSelections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specified item.
|
||||
*
|
||||
* @return The specified item.
|
||||
*/
|
||||
|
||||
virtual inline const CListDataItem *getItem(const int index) const
|
||||
{
|
||||
if (index < 0 || index >= m_items.size())
|
||||
{
|
||||
return (const CListDataItem *)0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_items[index];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the items using their compareTo() methods.
|
||||
*/
|
||||
|
||||
virtual void sort(void);
|
||||
|
||||
/**
|
||||
* Get the total number of items.
|
||||
*
|
||||
* @return The number of items.
|
||||
*/
|
||||
|
||||
virtual inline const int getItemCount(void) const
|
||||
{
|
||||
return m_items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all items. Does nothing if the list does not allow
|
||||
* multiple selections.
|
||||
*/
|
||||
|
||||
virtual void selectAllItems(void);
|
||||
|
||||
/**
|
||||
* Deselect all items.
|
||||
*/
|
||||
|
||||
virtual void deselectAllItems(void);
|
||||
|
||||
/**
|
||||
* Select or deselect an item by its index. Does not deselect any
|
||||
* other selected items. Set index to -1 to select nothing.
|
||||
*
|
||||
* @param index The index of the item to select.
|
||||
* @param selected True to select the item, false to deselect it.
|
||||
*/
|
||||
|
||||
virtual void setItemSelected(const int index, const bool selected);
|
||||
|
||||
/**
|
||||
* Returns whether multiple selections are possible or not.
|
||||
*
|
||||
* @return True if multiple selections are allowed.
|
||||
*/
|
||||
|
||||
virtual inline const bool allowsMultipleSelections(void) const
|
||||
{
|
||||
return m_allowMultipleSelections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not items added to the list are automatically
|
||||
* sorted on insert or not.
|
||||
*
|
||||
* @param sortInsertedItems True to enable sort on insertion.
|
||||
*/
|
||||
|
||||
virtual inline void setSortInsertedItems(const bool sortInsertedItems)
|
||||
{
|
||||
m_sortInsertedItems = sortInsertedItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event handler.
|
||||
*
|
||||
* @param eventHandler The event handler to add.
|
||||
*/
|
||||
|
||||
inline void addListDataEventHandler(IListDataEventHandler *eventHandler)
|
||||
{
|
||||
m_listDataEventhandlers.push_back(eventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an event handler.
|
||||
*
|
||||
* @param eventHandler The event handler to remove.
|
||||
*/
|
||||
|
||||
void removeListDataEventHandler(IListDataEventHandler *eventHandler);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATA_HXX
|
||||
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/clistdataeventargs.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATAEVENTARGS_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATAEVENTARGS_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/teventargs.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CListData;
|
||||
|
||||
/**
|
||||
* Event arguments passed to listeners when a CListData object raises an
|
||||
* event.
|
||||
*/
|
||||
|
||||
class CListDataEventArgs : public TEventArgs<CListData*>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source Pointer to the CListData object that raised the event.
|
||||
*/
|
||||
|
||||
inline CListDataEventArgs(CListData *source) : TEventArgs<CListData*>(source)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATAEVENTARGS_HXX
|
||||
@@ -0,0 +1,189 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/clistdataitem.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATAITEM_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATAITEM_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class representing a data item within a list. Intended for use within
|
||||
* the CListData class.
|
||||
*/
|
||||
|
||||
class CListDataItem
|
||||
{
|
||||
protected:
|
||||
CNxString m_text; /**< Text to display for option. */
|
||||
uint32_t m_value; /**< Option value. */
|
||||
bool m_isSelected; /**< True if the option is selected. */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param text The text to display in the item.
|
||||
* @param value The value of the item.
|
||||
*/
|
||||
|
||||
CListDataItem(const CNxString &text, const uint32_t value);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CListDataItem(void);
|
||||
|
||||
/**
|
||||
* Get the item's text.
|
||||
*
|
||||
* @return The item's text.
|
||||
*/
|
||||
|
||||
inline const CNxString &getText(void) const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item's value.
|
||||
*
|
||||
* @return The item's value.
|
||||
*/
|
||||
|
||||
inline const uint32_t getValue(void) const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item's selection state.
|
||||
*
|
||||
* @return True if the item is selected; false if not.
|
||||
*/
|
||||
|
||||
inline const bool isSelected(void) const
|
||||
{
|
||||
return m_isSelected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item's selection state.
|
||||
*
|
||||
* @param selected True to select the item; false to deselect it.
|
||||
*/
|
||||
|
||||
inline void setSelected(bool selected)
|
||||
{
|
||||
m_isSelected = selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the item with another. Comparison is based on the text of
|
||||
* the item. Returns 0 if the text in the two items is the same,
|
||||
* a value less than 0 if this item is less than the argument, and
|
||||
* a value greater than 0 if this item is greater than the argument.
|
||||
*
|
||||
* @param item An item to compare this object with.
|
||||
* @return 0 if the text in the two items is the same,
|
||||
* a value less than 0 if this item is less than the argument, and
|
||||
* a value greater than 0 if this item is greater than the argument.
|
||||
*/
|
||||
|
||||
virtual int compareTo(const CListDataItem *item) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLISTDATAITEM_HXX
|
||||
@@ -0,0 +1,632 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cmultilinetextbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CMULTILINETEXTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CMULTILINETEXTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#include "graphics/nxwidgets/cscrollingpanel.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/ctext.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/itextbox.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxTimer;
|
||||
|
||||
/**
|
||||
* Textbox that offers multiple lines of text. Has scrolling
|
||||
* capability and can be dragged using the mouse. The text
|
||||
* it contains can be changed or added to. It can remember more
|
||||
* rows of text than it can display, and these additional
|
||||
* rows can be scrolled through.
|
||||
*/
|
||||
|
||||
class CMultiLineTextBox : public ITextBox, public CScrollingPanel,
|
||||
public CWidgetEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum of horizontal alignment options.
|
||||
*/
|
||||
|
||||
enum TextAlignmentHoriz
|
||||
{
|
||||
TEXT_ALIGNMENT_HORIZ_CENTER = 0, /**< Centre the text */
|
||||
TEXT_ALIGNMENT_HORIZ_LEFT = 1, /**< Align left */
|
||||
TEXT_ALIGNMENT_HORIZ_RIGHT = 2 /**< Align right */
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum of vertical alignment options.
|
||||
*/
|
||||
|
||||
enum TextAlignmentVert
|
||||
{
|
||||
TEXT_ALIGNMENT_VERT_CENTER = 0, /**< Align to centre of textbox */
|
||||
TEXT_ALIGNMENT_VERT_TOP = 1, /**< Align to top of textbox */
|
||||
TEXT_ALIGNMENT_VERT_BOTTOM = 2 /**< Align to bottom of textbox */
|
||||
};
|
||||
|
||||
protected:
|
||||
CText *m_text; /**< CText object that manipulates
|
||||
and wraps the raw text string. */
|
||||
uint8_t m_visibleRows; /**< Total number of rows that the
|
||||
textbox can display at once. */
|
||||
nxgl_coord_t m_maxRows; /**< Maximum number of rows that the
|
||||
textbox should buffer. */
|
||||
int32_t m_topRow; /**< Index of the top row of text
|
||||
currently displayed. */
|
||||
TextAlignmentHoriz m_hAlignment; /**< Horizontal alignment of the text. */
|
||||
TextAlignmentVert m_vAlignment; /**< Vertical alignment of the text. */
|
||||
int m_cursorPos; /**< Position of the cursor within
|
||||
the string. */
|
||||
uint8_t m_showCursor; /**< Cursor visibility. */
|
||||
bool m_wrapCursor; /**< True wrap cursor at the ends of the text */
|
||||
|
||||
/**
|
||||
* Get the coordinates of the cursor relative to the text.
|
||||
*
|
||||
* @param x Will be populated with the x coordinate of the cursor.
|
||||
* @param y Will be populated with the y coordinate of the cursor.
|
||||
*/
|
||||
|
||||
virtual void getCursorCoordinates(nxgl_coord_t& x, nxgl_coord_t& y) const;
|
||||
|
||||
/**
|
||||
* Gets the index of the character at the specified x coordinate in the
|
||||
* specified row.
|
||||
*
|
||||
* @param x X coordinate of the character.
|
||||
* @param rowIndex Index of the row containing the character.
|
||||
* @return The index of the character at the specified coordinate.
|
||||
*/
|
||||
|
||||
virtual int getCharIndexAtCoordinate(nxgl_coord_t x, int rowIndex) const;
|
||||
|
||||
/**
|
||||
* Get the index of the character at the specified coordinates.
|
||||
*
|
||||
* @param x X coordinate of the character.
|
||||
* @param y Y coordinate of the character.
|
||||
* @return The index of the character at the specified coordinates.
|
||||
*/
|
||||
|
||||
virtual unsigned int getCharIndexAtCoordinates(nxgl_coord_t x, nxgl_coord_t y) const;
|
||||
|
||||
/**
|
||||
* Get the row containing the specified Y coordinate.
|
||||
*
|
||||
* @param y Y coordinate to locate.
|
||||
* @return The index of the row containing the specified Y coordinate.
|
||||
*/
|
||||
|
||||
int getRowContainingCoordinate(nxgl_coord_t y) const;
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Move cursor one character to the left.
|
||||
*/
|
||||
|
||||
virtual void moveCursorLeft(void);
|
||||
|
||||
/**
|
||||
* Move cursor one character to the right.
|
||||
*/
|
||||
|
||||
virtual void moveCursorRight(void);
|
||||
|
||||
/**
|
||||
* Move cursor one row upwards.
|
||||
*/
|
||||
|
||||
virtual void moveCursorUp(void);
|
||||
|
||||
/**
|
||||
* Move cursor one row downwards.
|
||||
*/
|
||||
|
||||
virtual void moveCursorDown(void);
|
||||
|
||||
/**
|
||||
* Ensures that the textbox only contains the maximum allowed
|
||||
* number of rows by culling any excess rows from the top of
|
||||
* the text.
|
||||
*
|
||||
* @return True if lines were removed from the text; false if not.
|
||||
*/
|
||||
|
||||
virtual bool cullTopLines(void);
|
||||
|
||||
/**
|
||||
* Ensures that the canvas height is the height of the widget,
|
||||
* if the widget exceeds the size of the text, or the height of
|
||||
* the text if the text exceeds the size of the widget.
|
||||
*/
|
||||
|
||||
virtual void limitCanvasHeight(void);
|
||||
|
||||
/**
|
||||
* Ensures that the canvas cannot scroll beyond its height.
|
||||
*/
|
||||
|
||||
virtual void limitCanvasY(void);
|
||||
|
||||
/**
|
||||
* Jumps to the cursor coordinates of the text.
|
||||
*/
|
||||
|
||||
void jumpToCursor(void);
|
||||
|
||||
/**
|
||||
* Jumps to the bottom of the text.
|
||||
*/
|
||||
|
||||
void jumpToTextBottom(void);
|
||||
|
||||
/**
|
||||
* Resize the textbox to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Starts the dragging system.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Opens the keyboard on the bottom display.
|
||||
*
|
||||
* @param x The x coordinates of the click.
|
||||
* @param y The y coordinates of the click.
|
||||
*/
|
||||
|
||||
virtual void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Handles physical button presses. Moves the cursor
|
||||
* in the direction pressed.
|
||||
*
|
||||
* @param key The key that was pressed.
|
||||
*/
|
||||
|
||||
void processPhysicalKey(nxwidget_char_t key);
|
||||
|
||||
/**
|
||||
* Handle a keyboard press event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleKeyPressEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a cursor control event. Replaces CWidgetEventHandler method.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleCursorControlEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Gets the x position of a row of text based on the width of the row and the
|
||||
* type of horizontal alignment currently set.
|
||||
*
|
||||
* @param row The index of the row.
|
||||
* @return The x coordinate of the row.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getRowX(int row) const;
|
||||
|
||||
/**
|
||||
* Gets the y position of the specified row of text based on the type of
|
||||
* vertical alignment currently set.
|
||||
*
|
||||
* @param row The row number to find the y coordinate of.
|
||||
* @return The y coordinate of the specified row of text.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getRowY(int row) const;
|
||||
|
||||
/**
|
||||
* Return true if the cursor is visible
|
||||
*/
|
||||
|
||||
virtual bool isCursorVisible(void) const;
|
||||
|
||||
/**
|
||||
* Gets the character under the cursor.
|
||||
*
|
||||
* @return The character under the cursor.
|
||||
*/
|
||||
|
||||
nxwidget_char_t getCursorChar(void) const;
|
||||
|
||||
/**
|
||||
* Works out the number of visible rows within the textbox.
|
||||
*/
|
||||
|
||||
void calculateVisibleRows(void);
|
||||
|
||||
/**
|
||||
* Draws text.
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
*/
|
||||
|
||||
void drawText(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Draws the cursor.
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
*/
|
||||
|
||||
void drawCursor(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Draws a single line of text.
|
||||
*
|
||||
* @param port The CGraphicsPort to draw to.
|
||||
* @param row The index of the row to draw.
|
||||
*/
|
||||
|
||||
void drawRow(CGraphicsPort *port, int row);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline virtual ~CMultiLineTextBox(void)
|
||||
{
|
||||
delete m_text;
|
||||
m_text = (CText *)NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CMultiLineTextBox(const CMultiLineTextBox &multiLineTextBox)
|
||||
: CScrollingPanel(multiLineTextBox) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the text box, relative to its parent.
|
||||
* @param y The y coordinate of the text box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param text Pointer to a string to display in the textbox.
|
||||
* @param flags Standard widget flag options.
|
||||
* @param maxRows The maximum number of rows the textbox can track. Adding
|
||||
* text beyond this number will cause rows at the start of the text to be
|
||||
* forgotten; text is essentially stored as a queue, and adding to the back
|
||||
* of a full queue causes the front items to be popped off. Setting this to
|
||||
* 0 will make the textbox track only the visible rows.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CMultiLineTextBox(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const CNxString &text, uint32_t flags,
|
||||
nxgl_coord_t maxRows = 0,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Set the horizontal alignment of text within the textbox.
|
||||
*
|
||||
* @param alignment The horizontal position of the text.
|
||||
*/
|
||||
|
||||
virtual void setTextAlignmentHoriz(TextAlignmentHoriz alignment);
|
||||
|
||||
/**
|
||||
* Set the vertical alignment of text within the textbox.
|
||||
*
|
||||
* @param alignment The vertical position of the text.
|
||||
*/
|
||||
|
||||
virtual void setTextAlignmentVert(TextAlignmentVert alignment);
|
||||
|
||||
/**
|
||||
* Returns the number of "pages" that the text spans. A page
|
||||
* is defined as the amount of text that can be displayed within
|
||||
* the textbox at one time.
|
||||
*
|
||||
* @return The page count.
|
||||
*/
|
||||
|
||||
virtual const int getPageCount(void) const;
|
||||
|
||||
/**
|
||||
* Returns the current page.
|
||||
*
|
||||
* @return The current page.
|
||||
* @see getPageCount().
|
||||
*/
|
||||
|
||||
virtual const int getCurrentPage(void) const;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the CText object that contains the
|
||||
* wrapped text used in the textbox. It is used as the
|
||||
* pre-processed data source for the textbox, and should
|
||||
* not be altered.
|
||||
*
|
||||
* @return Pointer to the CText object.
|
||||
*/
|
||||
|
||||
virtual inline const CText *getText(void) const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text displayed in the textbox.
|
||||
*
|
||||
* @param text String to display.
|
||||
*/
|
||||
|
||||
virtual void setText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Append new text to the end of the current text
|
||||
* displayed in the textbox.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
virtual void appendText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex);
|
||||
|
||||
/**
|
||||
* Remove specified number of characters from the string from the
|
||||
* start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
* @param count Number of characters to remove.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex, const unsigned int count);
|
||||
|
||||
/**
|
||||
* Set the font used in the textbox.
|
||||
*
|
||||
* @param font Pointer to the new font.
|
||||
*/
|
||||
|
||||
virtual void setFont(CNxFont *font);
|
||||
|
||||
/**
|
||||
* Set the line spacing of the text.
|
||||
*
|
||||
* @param spacing Extra space (in pixels) to add between lines.
|
||||
*/
|
||||
|
||||
virtual inline void setLineSpacing(nxgl_coord_t lineSpacing)
|
||||
{
|
||||
m_text->setLineSpacing(lineSpacing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the text string.
|
||||
*
|
||||
* @return The length of the text string.
|
||||
*/
|
||||
|
||||
virtual const int getTextLength(void) const;
|
||||
|
||||
/**
|
||||
* Sets the cursor display mode.
|
||||
*
|
||||
* @param cursorMode Determines cursor display mode
|
||||
*/
|
||||
|
||||
virtual void showCursor(EShowCursor cursorMode);
|
||||
|
||||
/**
|
||||
* Shows the cursor in default mode (only when the TextBox has focus).
|
||||
*/
|
||||
|
||||
virtual inline void showCursor(void)
|
||||
{
|
||||
showCursor(SHOW_CURSOR_ONFOCUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the cursor.
|
||||
*/
|
||||
|
||||
virtual inline void hideCursor(void)
|
||||
{
|
||||
showCursor(SHOW_CURSOR_NEVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables cursor wrapping
|
||||
*
|
||||
* @param wrap True enables cursor wrapping
|
||||
*/
|
||||
|
||||
virtual inline void wrapCursor(bool wrap)
|
||||
{
|
||||
m_wrapCursor = wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to the text position specified. 0 indicates the start
|
||||
* of the string. If position is greater than the length of the string,
|
||||
* the cursor is moved to the end of the string.
|
||||
*
|
||||
* @param position The new cursor position.
|
||||
*/
|
||||
|
||||
virtual void moveCursorToPosition(const int position);
|
||||
|
||||
/**
|
||||
* Get the cursor position. This is the index within the string that
|
||||
* the cursor is currently positioned over.
|
||||
*
|
||||
* @return position The cursor position.
|
||||
*/
|
||||
|
||||
virtual inline const int getCursorPosition(void) const
|
||||
{
|
||||
return m_cursorPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert text at the specified index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index Index at which to insert the text.
|
||||
*/
|
||||
|
||||
virtual void insertText(const CNxString &text,
|
||||
const unsigned int index);
|
||||
|
||||
/**
|
||||
* Insert text at the current cursor position.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
*/
|
||||
|
||||
virtual void insertTextAtCursor(const CNxString & ext);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CMULTILINETEXTBOX_HXX
|
||||
@@ -0,0 +1,221 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnumericedit.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Petteri Aimonen <jpa@kapsi.fi>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in all NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNUMERICEDIT_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNUMERICEDIT_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CRect;
|
||||
class CLabel;
|
||||
class CButton;
|
||||
class CNxTimer;
|
||||
|
||||
/**
|
||||
* Numeric edit control, with plus and minus buttons.
|
||||
*/
|
||||
|
||||
class CNumericEdit : public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CLabel *m_label;
|
||||
CButton *m_button_minus;
|
||||
CButton *m_button_plus;
|
||||
CNxTimer *m_timer;
|
||||
CNxString m_unittext;
|
||||
int m_value;
|
||||
int m_minimum;
|
||||
int m_maximum;
|
||||
int m_increment;
|
||||
int m_timercount;
|
||||
|
||||
/**
|
||||
* Resize the widget to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
virtual void handleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
virtual void handleReleaseEvent(const CWidgetEventArgs &e);
|
||||
|
||||
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
|
||||
|
||||
virtual void handleActionEvent(const CWidgetEventArgs &e);
|
||||
|
||||
virtual void handleDragEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CNumericEdit(const CNumericEdit &num) : CNxWidget(num) { };
|
||||
|
||||
void updateText();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for a numeric edit control.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the text box, relative to its parent.
|
||||
* @param y The y coordinate of the text box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CNumericEdit(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CNumericEdit();
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the
|
||||
* widget's parent.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Sets the font.
|
||||
*
|
||||
* @param font A pointer to the font to use.
|
||||
*/
|
||||
|
||||
virtual void setFont(CNxFont *font);
|
||||
|
||||
/**
|
||||
* Sets the text to display after the numeric value.
|
||||
*/
|
||||
|
||||
void setUnit(const CNxString& text);
|
||||
|
||||
inline int getValue() const { return m_value; }
|
||||
void setValue(int value);
|
||||
|
||||
inline int getMaximum() const { return m_maximum; }
|
||||
inline void setMaximum(int value) { m_maximum = value; setValue(m_value); }
|
||||
|
||||
inline int getMinimum() const { return m_minimum; }
|
||||
inline void setMinimum(int value) { m_minimum = value; setValue(m_value); }
|
||||
|
||||
inline int getIncrement() const { return m_increment; }
|
||||
inline void setIncrement(int value) { m_increment = value; setValue(m_value); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CLABEL_HXX
|
||||
251
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxfont.hxx
Normal file
251
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxfont.hxx
Normal file
@@ -0,0 +1,251 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnxfont.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXFONT_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXFONT_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nxfonts.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxString;
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* Class defining the properties of one font.
|
||||
*/
|
||||
|
||||
class CNxFont
|
||||
{
|
||||
private:
|
||||
enum nx_fontid_e m_fontId; /**< The font ID. */
|
||||
NXHANDLE m_fontHandle; /**< The font handle */
|
||||
FAR const struct nx_font_s *m_pFontSet; /** < The font set metrics */
|
||||
nxgl_mxpixel_t m_fontColor; /**< Color to draw the font with when rendering. */
|
||||
nxgl_mxpixel_t m_transparentColor; /**< Background color that should not be rendered. */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CNxFont Constructor.
|
||||
*
|
||||
* @param fontid The font ID to use.
|
||||
* @param fontColor The font color to use.
|
||||
* @param transparentColor The color in the font bitmap used as the
|
||||
* background color.
|
||||
*/
|
||||
|
||||
CNxFont(enum nx_fontid_e fontid, nxgl_mxpixel_t fontColor,
|
||||
nxgl_mxpixel_t transparentColor);
|
||||
|
||||
/**
|
||||
* CNxFont Destructor.
|
||||
*/
|
||||
|
||||
~CNxFont() { }
|
||||
|
||||
/**
|
||||
* Checks if supplied character is blank in the current font.
|
||||
*
|
||||
* @param letter The character to check.
|
||||
* @return True if the glyph contains any pixels to be drawn. False if
|
||||
* the glyph is blank.
|
||||
*/
|
||||
|
||||
const bool isCharBlank(const nxwidget_char_t letter) const;
|
||||
|
||||
/**
|
||||
* Gets the color currently being used as the drawing color.
|
||||
*
|
||||
* @return The current drawing color.
|
||||
*/
|
||||
|
||||
inline const nxgl_mxpixel_t getColor() const
|
||||
{
|
||||
return m_fontColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color to use as the drawing color. If set, this overrides
|
||||
* the colors present in a non-monochrome font.
|
||||
* @param color The new drawing color.
|
||||
*/
|
||||
|
||||
inline void setColor(const nxgl_mxpixel_t color)
|
||||
{
|
||||
m_fontColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color currently being used as the transparent background
|
||||
* color.
|
||||
* @return The transparent background color.
|
||||
*/
|
||||
|
||||
inline const nxgl_mxpixel_t getTransparentColor() const
|
||||
{
|
||||
return m_transparentColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transparent background color to a new value.
|
||||
* @param color The new background color.
|
||||
*/
|
||||
|
||||
inline void setTransparentColor(const nxgl_mxpixel_t color)
|
||||
{
|
||||
m_transparentColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw an individual character of the font to the specified bitmap.
|
||||
*
|
||||
* @param bitmap The bitmap to draw to.
|
||||
* @param letter The character to output.
|
||||
*/
|
||||
|
||||
void drawChar(FAR SBitmap *bitmap, nxwidget_char_t letter);
|
||||
|
||||
/**
|
||||
* Get the width of a string in pixels when drawn with this font.
|
||||
*
|
||||
* @param text The string to check.
|
||||
* @return The width of the string in pixels.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getStringWidth(const CNxString &text) const;
|
||||
|
||||
inline nxgl_coord_t getStringWidth(FAR const CNxString *text) const
|
||||
{
|
||||
return getStringWidth(*text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a portion of a string in pixels when drawn with this
|
||||
* font.
|
||||
*
|
||||
* @param text The string to check.
|
||||
* @param startIndex The start point of the substring within the string.
|
||||
* @param length The length of the substring in chars.
|
||||
* @return The width of the substring in pixels.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getStringWidth(const CNxString &text,
|
||||
int startIndex, int length) const;
|
||||
|
||||
inline nxgl_coord_t getStringWidth(FAR const CNxString *text,
|
||||
int startIndex, int length) const
|
||||
{
|
||||
return getStringWidth(*text, startIndex, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets font metrics for a particular character
|
||||
*
|
||||
*
|
||||
* @param letter The character to get the width of.
|
||||
* @param metrics The location to return the font metrics
|
||||
*/
|
||||
|
||||
void getCharMetrics(nxwidget_char_t letter,
|
||||
FAR struct nx_fontmetric_s *metrics) const;
|
||||
|
||||
/**
|
||||
* Get the width of an individual character.
|
||||
*
|
||||
* @param letter The character to get the width of.
|
||||
* @return The width of the character in pixels.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getCharWidth(nxwidget_char_t letter) const;
|
||||
|
||||
/**
|
||||
* Get the height of an individual character.
|
||||
*
|
||||
* @param letter The letter to get the height of.
|
||||
* @return The height of the character in pixels.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getCharHeight(nxwidget_char_t letter) const;
|
||||
|
||||
/**
|
||||
* Gets the maximum width of the font.
|
||||
*
|
||||
* @return The height of the font.
|
||||
*/
|
||||
|
||||
inline const uint8_t getMaxWidth(void) const
|
||||
{
|
||||
return m_pFontSet->mxwidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the height of the font.
|
||||
*
|
||||
* @return The height of the font.
|
||||
*/
|
||||
|
||||
inline const uint8_t getHeight(void) const
|
||||
{
|
||||
return m_pFontSet->mxheight;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXFONT_HXX
|
||||
241
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxserver.hxx
Normal file
241
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxserver.hxx
Normal file
@@ -0,0 +1,241 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnxserver.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXSERVER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXSERVER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxcursor.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwindow.hxx"
|
||||
#include "graphics/nxwidgets/cnxtkwindow.hxx"
|
||||
#include "graphics/nxwidgets/cbgwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CBgWindow;
|
||||
|
||||
/**
|
||||
* This class represents the NX server. It includes methods to connect to
|
||||
* and disconnect form the NX server, methods to manage the background, and
|
||||
* "factory" methods to create window objects on the NX server. NXWidget
|
||||
* objects them may be created on the window objects.
|
||||
*/
|
||||
|
||||
class CNxServer
|
||||
{
|
||||
private:
|
||||
FAR NX_DRIVERTYPE *m_hDevice; /**< LCD/Framebuffer device handle */
|
||||
NXHANDLE m_hNxServer; /**< NX server handle */
|
||||
volatile bool m_running; /**< True: The listener thread is running */
|
||||
volatile bool m_connected; /**< True: Connected to the server */
|
||||
volatile bool m_stop; /**< True: Waiting for the listener thread to stop */
|
||||
sem_t m_connsem; /**< Wait for server connection */
|
||||
static uint8_t m_nServers; /**< The number of NX server instances */
|
||||
|
||||
/**
|
||||
* NX listener thread. This is the entry point of a thread that listeners for and
|
||||
* dispatches events from the NX server.
|
||||
*/
|
||||
|
||||
static FAR void *listener(FAR void *arg);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CNXServer constructor. The CNxServer is a normally singleton. However, that
|
||||
* not enforced: This constructor could run more than one in the situation where
|
||||
* there are multiple physical displays. However, that configuration has never
|
||||
* been texted.
|
||||
*/
|
||||
|
||||
CNxServer(void);
|
||||
|
||||
/**
|
||||
* CNXServer destructor
|
||||
*/
|
||||
|
||||
~CNxServer(void);
|
||||
|
||||
/**
|
||||
* Connect to the NX Server
|
||||
*/
|
||||
|
||||
virtual bool connect(void);
|
||||
|
||||
/**
|
||||
* Disconnect from the NX Server
|
||||
*/
|
||||
|
||||
virtual void disconnect(void);
|
||||
|
||||
/**
|
||||
* Get the NX server handle
|
||||
*
|
||||
* @return The NX server handler (NULL is not connected)
|
||||
*/
|
||||
|
||||
inline NXHANDLE getServer(void)
|
||||
{
|
||||
return m_hNxServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if we are connected to the NX server.
|
||||
*
|
||||
* @return True is connected; false is not connected.
|
||||
*/
|
||||
|
||||
inline bool connected(void)
|
||||
{
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background color
|
||||
*/
|
||||
|
||||
inline bool setBackgroundColor(nxgl_mxpixel_t color)
|
||||
{
|
||||
return nx_setbgcolor(m_hNxServer, &color) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of a raw NX window.
|
||||
*/
|
||||
|
||||
inline CNxWindow *createRawWindow(CWidgetControl *widgetControl, uint8_t flags = 0)
|
||||
{
|
||||
return new CNxWindow(m_hNxServer, widgetControl, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of the framed NX window.
|
||||
*/
|
||||
|
||||
inline CNxTkWindow *createFramedWindow(CWidgetControl *widgetControl, uint8_t flags = 0)
|
||||
{
|
||||
return new CNxTkWindow(m_hNxServer, widgetControl, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of the background window.
|
||||
*/
|
||||
|
||||
inline CBgWindow *getBgWindow(CWidgetControl *widgetControl)
|
||||
{
|
||||
return new CBgWindow(m_hNxServer, widgetControl);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||
/**
|
||||
* Enable/disable the cursor.
|
||||
*
|
||||
* @param enable. True: show the cursor, false: hide the cursor.
|
||||
*/
|
||||
|
||||
inline void enableCursor(bool enable)
|
||||
{
|
||||
nxcursor_enable(m_hNxServer, enable);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSORIMAGE)
|
||||
/**
|
||||
* Enable/disable the cursor.
|
||||
*
|
||||
* The image is provided a a 2-bits-per-pixel image. The two bit encoding
|
||||
* is as follows:
|
||||
*
|
||||
* 0b00 - The transparent background.
|
||||
* 0b01 - Color1: The main color of the cursor.
|
||||
* 0b10 - Color2: The color of any border.
|
||||
* 0b11 - Color3: A blend color for better imaging (fake anti-aliasing).
|
||||
*
|
||||
* NOTE: The NX logic will reference the user image buffer repeatedly.
|
||||
* That image buffer must persist for as long as the NX server connection
|
||||
* persists.
|
||||
*
|
||||
* @param image. Describes the cursor image in the expected format..
|
||||
*/
|
||||
|
||||
inline void setCursorImage(FAR const struct nx_cursorimage_s *image)
|
||||
{
|
||||
nxcursor_setimage(m_hNxServer, image);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||
/**
|
||||
* Set the cursor position.
|
||||
*
|
||||
* @param pos. The new cursor position.
|
||||
*/
|
||||
|
||||
inline void setCursorPosition(FAR struct nxgl_point_s *pos)
|
||||
{
|
||||
nxcursor_setposition(m_hNxServer, pos);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXSERVER_HXX
|
||||
533
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxstring.hxx
Normal file
533
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxstring.hxx
Normal file
@@ -0,0 +1,533 @@
|
||||
/****************************************************************************
|
||||
* include/cnxtring.hxx
|
||||
*apps/include/graphics/nxwidgets/
|
||||
*
|
||||
* Copyright (C) 2012, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXSTRING_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXSTRING_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CStringIterator;
|
||||
|
||||
/**
|
||||
* Unicode string class. Uses 16-bt wide-character encoding. For optimal
|
||||
* performance, use the CStringIterator class to iterate over a CNxString
|
||||
* instance.
|
||||
*
|
||||
* Where possible, the string avoids allocating memory each time the
|
||||
* string grows or shrinks. This means that the string may consume more
|
||||
* memory than the number of chars would seem to dictate if the object
|
||||
* previously contained a large string that has subsequently been truncated.
|
||||
* It also means that increasing the length of such a string is a cheaper
|
||||
* operation as memory does not need to allocated and copied.
|
||||
*
|
||||
* Additionally, the string increases its array size by m_growAmount every
|
||||
* time it needs to allocate extra memory, potentially reducing the number
|
||||
* of reallocs needed.
|
||||
*
|
||||
* The string is not null-terminated. Instead, it uses a m_stringLength
|
||||
* member that stores the number of characters in the string. This saves a
|
||||
* byte and makes calls to getLength() run in O(1) time instead of O(n).
|
||||
*/
|
||||
|
||||
class CNxString
|
||||
{
|
||||
private:
|
||||
friend class CStringIterator;
|
||||
|
||||
int m_stringLength; /**< Number of characters in the string */
|
||||
int m_allocatedSize; /**< Number of bytes allocated for this string */
|
||||
int m_growAmount; /**< Number of chars that the string grows by
|
||||
whenever it needs to get larger */
|
||||
|
||||
|
||||
protected:
|
||||
FAR nxwidget_char_t *m_text; /**< Raw char array data */
|
||||
|
||||
/**
|
||||
* Allocate memory for the string.
|
||||
*
|
||||
* @param chars Number of chars to allocate.
|
||||
* @param preserve If true, the data in the existing memory will be
|
||||
* preserved if new memory must be allocated
|
||||
*/
|
||||
|
||||
void allocateMemory(int chars, bool preserve);
|
||||
|
||||
/**
|
||||
* Check if we've got any string data stored or not.
|
||||
*
|
||||
* @return True if the string contains any data; false if no data has
|
||||
* yet been supplied.
|
||||
*/
|
||||
|
||||
inline bool hasData(void) const
|
||||
{
|
||||
return m_stringLength > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of allocated memory.
|
||||
*
|
||||
* @return The number of chars allocated in RAM.
|
||||
*/
|
||||
|
||||
inline int getAllocatedSize(void) const
|
||||
{
|
||||
return m_allocatedSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer to the raw char array data.
|
||||
*
|
||||
* @return Pointer to the char array.
|
||||
*/
|
||||
|
||||
inline FAR const nxwidget_char_t *getCharArray(void) const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to the specified character.
|
||||
*
|
||||
* @param index Index of the character to retrieve.
|
||||
*/
|
||||
|
||||
FAR nxwidget_char_t *getCharPointer(const int index) const;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor to create an empty string object.
|
||||
*/
|
||||
|
||||
CNxString();
|
||||
|
||||
/**
|
||||
* Constructor to create a string from a C character array.
|
||||
*
|
||||
* @param text Pointer to a char array to use as the basis of the
|
||||
* string.
|
||||
*/
|
||||
|
||||
CNxString(FAR const char *text);
|
||||
|
||||
/**
|
||||
* Constructor to create a string from a single character.
|
||||
*
|
||||
* @param letter Single character to use as the basis of the string.
|
||||
*/
|
||||
|
||||
CNxString(const nxwidget_char_t letter);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param string CNxString object to create a copy of.
|
||||
*/
|
||||
|
||||
CNxString(const CNxString &string);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CNxString()
|
||||
{
|
||||
delete[] m_text;
|
||||
m_text = (FAR nxwidget_char_t *)NULL;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates and returns a new CStringIterator object that will iterate
|
||||
* over this string. The object must be manually deleted once it is
|
||||
* no longer needed.
|
||||
*
|
||||
* @return A new CStringIterator object.
|
||||
*/
|
||||
|
||||
CStringIterator *newStringIterator(void) const;
|
||||
|
||||
/**
|
||||
* Copy the internal array to the supplied buffer. The buffer must be
|
||||
* large enough to contain the full text in the string. The
|
||||
* getAllocSize() method can be used to obtain the length of the string.
|
||||
* Unlike the CNxString class, the char array is null-terminated.
|
||||
* The buffer must be (getAllocSize() + 1) bytes long, in order to
|
||||
* accommodate the terminator.
|
||||
*
|
||||
* @param buffer Buffer to copy the internal char array to.
|
||||
*/
|
||||
|
||||
void copyToCharArray(FAR nxwidget_char_t *buffer) const;
|
||||
|
||||
/**
|
||||
* Set the text in the string.
|
||||
*
|
||||
* @param text CNxString containing the new data for this string.
|
||||
*/
|
||||
|
||||
void setText(const CNxString &text);
|
||||
|
||||
inline void setText(FAR const CNxString *text)
|
||||
{
|
||||
setText(*text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text in the string.
|
||||
*
|
||||
* @param text Char array to use as the new data for this string.
|
||||
*/
|
||||
|
||||
void setText(FAR const char *text);
|
||||
|
||||
/**
|
||||
* Set the nxwidget_char_t text in the string.
|
||||
*
|
||||
* @param text Char array to use as the new data for this string.
|
||||
*/
|
||||
|
||||
void setText(FAR const nxwidget_char_t *text, int nchars);
|
||||
|
||||
/**
|
||||
* Set the 8-bit C-string text in the string.
|
||||
*
|
||||
* @param text Character to use as the new data for this string.
|
||||
*/
|
||||
|
||||
void setText(const nxwidget_char_t text);
|
||||
|
||||
/**
|
||||
* Append text to the end of the string.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
void append(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Insert text at the specified character index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index The index at which to insert the text.
|
||||
*/
|
||||
|
||||
void insert(const CNxString &text, const int index);
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
*/
|
||||
|
||||
void remove(const int startIndex);
|
||||
|
||||
/**
|
||||
* Remove specified number of characters from the string from the
|
||||
* start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
* @param count Number of characters to remove.
|
||||
*/
|
||||
|
||||
void remove(const int startIndex, const int count);
|
||||
|
||||
/**
|
||||
* Get the of number of letters (ie. the length) of the string.
|
||||
*
|
||||
* @return The length of the string.
|
||||
*/
|
||||
|
||||
inline const unsigned int getLength(void) const
|
||||
{
|
||||
return m_stringLength;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the size of a buffer (in bytes) required in order to copy the
|
||||
* internal string into an the array. This is normally used in
|
||||
* conjunction with copyToCharArray(). Note that the returned size
|
||||
* includes additional byte(s) to hold NUL termination.
|
||||
*/
|
||||
|
||||
inline const unsigned int getAllocSize(void) const
|
||||
{
|
||||
return sizeof(nxwidget_char_t) * (m_stringLength + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the character at the specified index. This function is useful
|
||||
* for finding the occasional character at an index, but for iterating
|
||||
* over strings it is exceptionally slow. The newStringIterator()
|
||||
* method should be used to retrieve an iterator object that can iterate
|
||||
* over the string efficiently.
|
||||
*
|
||||
* @param index The index of the character to retrieve.
|
||||
* @return The character at the specified index.
|
||||
*/
|
||||
|
||||
const nxwidget_char_t getCharAt(int index) const;
|
||||
|
||||
/**
|
||||
* Returns the first index of the specified letter within the string.
|
||||
* Will return -1 if the letter is not found.
|
||||
*
|
||||
* @param letter Letter to find.
|
||||
* @return The index of the letter.
|
||||
*/
|
||||
|
||||
const int indexOf(nxwidget_char_t letter) const;
|
||||
|
||||
/**
|
||||
* Returns the first index of the specified letter within the string.
|
||||
* Will return -1 if the letter is not found. Scans through the string
|
||||
* from "startIndex" until it has examined all subsequent letters.
|
||||
* @param letter Letter to find.
|
||||
*
|
||||
* @param startIndex The index to start searching from.
|
||||
* @return The index of the letter.
|
||||
*/
|
||||
|
||||
const int indexOf(nxwidget_char_t letter, int startIndex) const;
|
||||
|
||||
/**
|
||||
* Returns the first index of the specified letter within the string.
|
||||
* Will return -1 if the letter is not found. Scans through the string
|
||||
* from "startIndex" until it has examined all letters within the
|
||||
* range "count".
|
||||
*
|
||||
* @param letter Letter to find.
|
||||
* @param startIndex The index to start searching from.
|
||||
* @param count The number of characters to examine.
|
||||
* @return The index of the letter.
|
||||
*/
|
||||
|
||||
const int indexOf(nxwidget_char_t letter, int startIndex, int count) const;
|
||||
|
||||
/**
|
||||
* Returns the last index of the specified letter within the string.
|
||||
* Will return -1 if the letter is not found.
|
||||
*
|
||||
* @param letter Letter to find.
|
||||
* @return The index of the letter.
|
||||
*/
|
||||
|
||||
const int lastIndexOf(nxwidget_char_t letter) const;
|
||||
|
||||
/**
|
||||
* Returns the last index of the specified letter within the string.
|
||||
* Will return -1 if the letter is not found. Scans through the string
|
||||
* backwards from "startIndex" until it has examined all preceding
|
||||
* letters within the string.
|
||||
*
|
||||
* @param letter Letter to find.
|
||||
* @param startIndex The index to start searching from.
|
||||
* @return The index of the letter.
|
||||
*/
|
||||
|
||||
const int lastIndexOf(nxwidget_char_t letter, int startIndex) const;
|
||||
|
||||
/**
|
||||
* Returns the last index of the specified letter within the string.
|
||||
* Will return -1 if the letter is not found. Scans through the string
|
||||
* backwards from "startIndex" until it has examined all letters within
|
||||
* the range "count".
|
||||
* @param letter Letter to find.
|
||||
* @param startIndex The index to start searching from.
|
||||
* @param count The number of characters to examine.
|
||||
* @return The index of the letter.
|
||||
*/
|
||||
|
||||
const int lastIndexOf(nxwidget_char_t letter, int startIndex, int count) const;
|
||||
|
||||
/**
|
||||
* Get a substring from this string. It is the responsibility of the
|
||||
* caller to delete the substring when it is no longer required.
|
||||
*
|
||||
* @param startIndex The starting point of the substring.
|
||||
* @return A pointer to a new CNxString object containing the
|
||||
* substring.
|
||||
*/
|
||||
|
||||
FAR CNxString *subString(int startIndex) const;
|
||||
|
||||
/**
|
||||
* Get a substring from this string. It is the responsibility of the
|
||||
* caller to delete the substring when it is no longer required.
|
||||
*
|
||||
* @param startIndex The starting point of the substring.
|
||||
* @param length The length of the substring.
|
||||
* @return A pointer to a new CNxString object containing the
|
||||
* substring.
|
||||
*/
|
||||
|
||||
FAR CNxString *subString(int startIndex, int length) const;
|
||||
|
||||
/**
|
||||
* Overloaded assignment operator. Copies the data within the argument
|
||||
* string to this string.
|
||||
*
|
||||
* @param string The string to copy.
|
||||
* @return This string.
|
||||
*/
|
||||
|
||||
CNxString &operator=(const CNxString &string);
|
||||
|
||||
/**
|
||||
* Overloaded assignment operator. Copies the data within the argument
|
||||
* char array to this string.
|
||||
*
|
||||
* @param string The string to copy.
|
||||
* @return This string.
|
||||
*/
|
||||
|
||||
CNxString &operator=(FAR const char *string);
|
||||
|
||||
/**
|
||||
* Overloaded assignment operator. Copies the data from the argument
|
||||
* char to this string.
|
||||
*
|
||||
* @param letter The char to copy.
|
||||
* @return This string.
|
||||
*/
|
||||
|
||||
CNxString &operator=(nxwidget_char_t letter);
|
||||
|
||||
/**
|
||||
* Overloaded sum operator. Appends the string to current string.
|
||||
*/
|
||||
|
||||
inline CNxString &operator+=(const CNxString &other)
|
||||
{
|
||||
append(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloaded sum operator. Concatenates two strings.
|
||||
*/
|
||||
|
||||
inline CNxString operator+(const CNxString &other)
|
||||
{
|
||||
CNxString result = *this;
|
||||
result.append(other);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this string to the argument.
|
||||
*
|
||||
* @param string String to compare to.
|
||||
* @return Zero if both strings are equal. A value greater than zero
|
||||
* indicates that this string is greater than the argument string. A
|
||||
* value less than zero indicates the opposite. Note that the return
|
||||
* value indicates the *byte* that does not match, not the *character*.
|
||||
*/
|
||||
|
||||
int compareTo(const CNxString &string) const;
|
||||
int compareTo(FAR const char *string) const;
|
||||
|
||||
/**
|
||||
* snprintf()-style string formatting. Automatically allocates correct
|
||||
* amount of memory.
|
||||
*
|
||||
* @param fmt printf format string.
|
||||
* @return New CNxString instance.
|
||||
*/
|
||||
|
||||
static CNxString format(const char *fmt, ...);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXSTRING_HXX
|
||||
207
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxtimer.hxx
Normal file
207
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxtimer.hxx
Normal file
@@ -0,0 +1,207 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnxtimer.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTIMER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTIMER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <ctime>
|
||||
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetcontrol;
|
||||
|
||||
/**
|
||||
* Timer widget. It can drive time-based events, animations, etc.
|
||||
*
|
||||
* Using the timer is simple:
|
||||
* - Create an instance of the CNxTimer and add it as a child to a widget.
|
||||
* - Call the instance's "start()" method.
|
||||
* - Catch the timer's action event and call any code that should run.
|
||||
*/
|
||||
|
||||
class CNxTimer : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
struct work_s m_work; /**< Work queue entry */
|
||||
uint32_t m_timeout; /**< The timeout value in milliseconds */
|
||||
bool m_isRunning; /**< Indicates whether or not the timer is running */
|
||||
bool m_isRepeater; /**< Indicates whether or not the timer repeats */
|
||||
|
||||
/**
|
||||
* Static function called from work queue when the timeout expires.
|
||||
*
|
||||
* @param arg Pointer to the CNxTimer instance.
|
||||
*/
|
||||
|
||||
static void workQueueCallback(FAR void *arg);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CNxTimer(const CNxTimer &timer) : CNxWidget(timer) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display.
|
||||
* @param timeout Time, in milliseconds, before the timer fires an
|
||||
* EVENT_ACTION event.
|
||||
* @param repeat If true, the timer will fire multiple events. If false,
|
||||
* the timer will fire just once and stop.
|
||||
*/
|
||||
|
||||
CNxTimer(CWidgetControl *pWidgetControl, uint32_t timeout, bool repeat);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CNxTimer(void);
|
||||
|
||||
/**
|
||||
* Resets the (running) timer to its initial timeout value. This
|
||||
* call does nothing if the timer is not running.
|
||||
*/
|
||||
|
||||
void reset(void);
|
||||
|
||||
/**
|
||||
* Starts the timer. This call does nothing if the timer is already
|
||||
* running.
|
||||
*/
|
||||
|
||||
void start(void);
|
||||
|
||||
/**
|
||||
* Stops the timer. Does nothing if the timer is not running.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Returns true if the timer is currently running.
|
||||
*/
|
||||
|
||||
inline bool isRunning() const { return m_isRunning; }
|
||||
|
||||
/**
|
||||
* Set the timeout of this timer. This timeout value will not
|
||||
* take effect until start() or reset() is called.
|
||||
*
|
||||
* @param timeout The number of milliseconds that this timer will run
|
||||
* before firing an event.
|
||||
*/
|
||||
|
||||
inline void setTimeout(uint32_t timeout)
|
||||
{
|
||||
m_timeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the timeout of this timer.
|
||||
*
|
||||
* @return The number of milliseconds that this timer will run before
|
||||
* firing an event.
|
||||
*/
|
||||
|
||||
inline uint32_t getTimeout(void) const
|
||||
{
|
||||
return m_timeout;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTIMER_HXX
|
||||
430
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxtkwindow.hxx
Normal file
430
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxtkwindow.hxx
Normal file
@@ -0,0 +1,430 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnxtkwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2015, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTKWINDOW_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTKWINDOW_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
|
||||
#include "graphics/nxwidgets/ccallback.hxx"
|
||||
#include "graphics/nxwidgets/inxwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxToolbar;
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* This class defines operations on a framed NX window.
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
*/
|
||||
|
||||
class CNxTkWindow : protected CCallback, public INxWindow
|
||||
{
|
||||
protected:
|
||||
NXHANDLE m_hNxServer; /**< Handle to the NX server. */
|
||||
NXTKWINDOW m_hNxTkWindow; /**< Handle to the NxTk window */
|
||||
CWidgetControl *m_widgetControl; /**< Controlling widget for the window */
|
||||
CNxToolbar *m_toolbar; /**< Child toolbar */
|
||||
nxgl_coord_t m_toolbarHeight; /**< The height of the toolbar */
|
||||
uint8_t m_flags; /**< Window properties */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Creates an uninitialized instance of the CNxTkWindow
|
||||
* object. The open() method must be called to initialize the instance.
|
||||
*
|
||||
* The general steps to create any window include:
|
||||
* 1) Create a dumb CWigetControl instance
|
||||
* 2) Pass the dumb CWidgetControl instance to the window constructor
|
||||
* that inherits from INxWindow.
|
||||
* 3) The window constructor call CWidgetControl methods to "smarten"
|
||||
* the CWidgetControl instance with window-specific knowledge.
|
||||
* 4) Call the open() method on the window to display the window.
|
||||
* 5) After that, the fully smartened CWidgetControl instance can
|
||||
* be used to generate additional widgets.
|
||||
* 6) After that, the fully smartened CWidgetControl instance can
|
||||
* be used to generate additional widgets by passing it to the
|
||||
* widget constructor
|
||||
*
|
||||
* @param hNxServer Handle to the NX server.
|
||||
* @param widgetControl Controlling widget for this window.
|
||||
* @param flags Window properties
|
||||
*/
|
||||
|
||||
CNxTkWindow(NXHANDLE hNxServer, CWidgetControl *widgetControl,
|
||||
uint8_t flags);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CNxTkWindow(void);
|
||||
|
||||
/**
|
||||
* Creates a new window. Window creation is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully opened.
|
||||
*/
|
||||
|
||||
bool open(void);
|
||||
|
||||
/**
|
||||
* Each implementation of INxWindow must provide a method to recover
|
||||
* the contained CWidgetControl instance.
|
||||
*
|
||||
* @return The contained CWidgetControl instance
|
||||
*/
|
||||
|
||||
CWidgetControl *getWidgetControl(void) const;
|
||||
|
||||
/**
|
||||
* Synchronize the window with the NX server. This function will delay
|
||||
* until the the NX server has caught up with all of the queued requests.
|
||||
* When this function returns, the state of the NX server will be the
|
||||
* same as the state of the application.
|
||||
*/
|
||||
|
||||
inline void synchronize(void)
|
||||
{
|
||||
CCallback::synchronize(m_hNxTkWindow, CCallback::NXTK_FRAMEDWINDOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a toolbar on the framed window. This method both instantiates
|
||||
* the toolbar object AND calls the INxWindow::open() method to
|
||||
* create the toolbar. The toolbar is ready for use upon return.
|
||||
*
|
||||
* @param height. The height in rows of the tool bar
|
||||
* @param widgetControl. The controlling widget for this window. If
|
||||
* none is provided, then a new, vanilla CWidgetControl will be created
|
||||
* for the tool bar.
|
||||
* @return True if the toolbar was successfully created.
|
||||
*/
|
||||
|
||||
CNxToolbar *openToolbar(nxgl_coord_t height,
|
||||
CWidgetControl *widgetControl = (CWidgetControl *)0);
|
||||
|
||||
/**
|
||||
* Detach the toolbar. This should *ONLY* be called by the toolbar
|
||||
* instance itself. If this is called by end-user logic, it will
|
||||
* screw things up miserably.
|
||||
*/
|
||||
|
||||
inline void detachToolbar(void)
|
||||
{
|
||||
m_toolbar = (CNxToolbar *)NULL;
|
||||
m_toolbarHeight = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the position and size information of the window. The values
|
||||
* will be returned asynchronously through the client callback method.
|
||||
* The GetPosition() method may than be called to obtain the positional
|
||||
* data as provided by the callback.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool requestPosition(void);
|
||||
|
||||
/**
|
||||
* Get the position of the window (as reported by the NX callback).
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool getPosition(FAR struct nxgl_point_s *pos);
|
||||
|
||||
/**
|
||||
* Get the size of the window (as reported by the NX callback).
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
bool getSize(FAR struct nxgl_size_s *size);
|
||||
|
||||
/**
|
||||
* Set the position and size of the window.
|
||||
*
|
||||
* @param pos The new position of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool setPosition(FAR const struct nxgl_point_s *pos);
|
||||
|
||||
/**
|
||||
* Set the size of the selected window.
|
||||
*
|
||||
* @param size The new size of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool setSize(FAR const struct nxgl_size_s *size);
|
||||
|
||||
/**
|
||||
* Bring the window to the top of the display.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool raise(void)
|
||||
{
|
||||
return nxtk_raise(m_hNxTkWindow) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower the window to the bottom of the display.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool lower(void)
|
||||
{
|
||||
return nxtk_lower(m_hNxTkWindow) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the window is currently being displayed
|
||||
*
|
||||
* @return True if the window is visible
|
||||
*/
|
||||
|
||||
inline bool isVisible(void)
|
||||
{
|
||||
return !nxtk_ishidden(m_hNxTkWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a hidden window
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool show(void)
|
||||
{
|
||||
return nxtk_setvisibility(m_hNxTkWindow, false) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a visible window
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool hide(void)
|
||||
{
|
||||
return nxtk_setvisibility(m_hNxTkWindow, true) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* May be used to either (1) raise a window to the top of the display and
|
||||
* select modal behavior, or (2) disable modal behavior.
|
||||
*
|
||||
* @param enable True: enter modal state; False: leave modal state
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool modal(bool enable);
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
/**
|
||||
* Each window implementation also inherits from CCallback. CCallback,
|
||||
* by default, forwards NX keyboard input to the various widgets residing
|
||||
* in the window. But NxTerm is a different usage model; In this case,
|
||||
* keyboard input needs to be directed to the NxTerm character driver.
|
||||
* This method can be used to enable (or disable) redirection of NX
|
||||
* keyboard input from the window widgets to the NxTerm
|
||||
*
|
||||
* @param handle. The NXTERM handle. If non-NULL, NX keyboard
|
||||
* input will be directed to the NxTerm driver using this
|
||||
* handle; If NULL (the default), NX keyboard input will be
|
||||
* directed to the widgets within the window.
|
||||
*/
|
||||
|
||||
inline void redirectNxTerm(NXTERM handle)
|
||||
{
|
||||
setNxTerm(handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set an individual pixel in the window with the specified color.
|
||||
*
|
||||
* @param pos The location of the pixel to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool setPixel(FAR const struct nxgl_point_s *pos,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified rectangle in the window with the specified color.
|
||||
*
|
||||
* @param pRect The location to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fill(FAR const struct nxgl_rect_s *pRect,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Get the raw contents of graphic memory within a rectangular region. NOTE:
|
||||
* Since raw graphic memory is returned, the returned memory content may be
|
||||
* the memory of windows above this one and may not necessarily belong to
|
||||
* this window unless you assure that this is the top window.
|
||||
*
|
||||
* @param rect The location to be copied
|
||||
* @param dest - The describes the destination bitmap to receive the
|
||||
* graphics data.
|
||||
*/
|
||||
|
||||
void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
|
||||
|
||||
/**
|
||||
* Fill the specified trapezoidal region in the window with the specified
|
||||
* color.
|
||||
*
|
||||
* @param pClip Clipping rectangle relative to window (may be null).
|
||||
* @param pTrap The trapezoidal region to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
|
||||
FAR const struct nxgl_trapezoid_s *pTrap,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified line in the window with the specified color.
|
||||
*
|
||||
* @param vector - Describes the line to be drawn
|
||||
* @param width - The width of the line
|
||||
* @param color - The color to use to fill the line
|
||||
* @param caps - Draw a circular cap on the ends of the line to support
|
||||
* better line joins
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool drawLine(FAR struct nxgl_vector_s *vector,
|
||||
nxgl_coord_t width, nxgl_mxpixel_t color,
|
||||
enum ELineCaps caps);
|
||||
|
||||
/**
|
||||
* Draw a filled circle at the specified position, size, and color.
|
||||
*
|
||||
* @param center The window-relative coordinates of the circle center.
|
||||
* @param radius The radius of the rectangle in pixels.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Move a rectangular region within the window.
|
||||
*
|
||||
* @param pRect Describes the rectangular region to move.
|
||||
* @param pOffset The offset to move the region.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool move(FAR const struct nxgl_rect_s *pRect,
|
||||
FAR const struct nxgl_point_s *pOffset);
|
||||
|
||||
/**
|
||||
* Copy a rectangular region of a larger image into the rectangle in the
|
||||
* specified window.
|
||||
*
|
||||
* @param pDest Describes the rectangular on the display that will receive
|
||||
* the bitmap.
|
||||
* @param pSrc The start of the source image.
|
||||
* @param pOrigin the pOrigin of the upper, left-most corner of the full
|
||||
* bitmap. Both pDest and pOrigin are in window coordinates, however,
|
||||
* pOrigin may lie outside of the display.
|
||||
* @param stride The width of the full source image in bytes.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool bitmap(FAR const struct nxgl_rect_s *pDest,
|
||||
FAR const void *pSrc,
|
||||
FAR const struct nxgl_point_s *pOrigin,
|
||||
unsigned int stride);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTKWINDOW_HXX
|
||||
410
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxtoolbar.hxx
Normal file
410
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxtoolbar.hxx
Normal file
@@ -0,0 +1,410 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnxtoolbar.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2015, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTOOLBAR_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTOOLBAR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
|
||||
#include "graphics/nxwidgets/ccallback.hxx"
|
||||
#include "graphics/nxwidgets/inxwindow.hxx"
|
||||
#include "graphics/nxwidgets/cnxtkwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* This class defines operations on a the toolbar in a framed NX window.
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
*/
|
||||
|
||||
class CNxToolbar : protected CCallback, public INxWindow
|
||||
{
|
||||
private:
|
||||
CNxTkWindow *m_nxTkWindow; /**< Parent framed window instance. */
|
||||
NXTKWINDOW m_hNxTkWindow; /**< Parent framed window handle. */
|
||||
CWidgetControl *m_widgetControl; /**< Controlling widget for the toolbar */
|
||||
nxgl_coord_t m_height; /**< The toolbar height */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Creates an uninitialized instance of the CNxToolbar
|
||||
* object. The open() method must be called to initialize the instance.
|
||||
*
|
||||
* @param pNxTkWindow Parent framed window instance
|
||||
* @param hNxTkWindow Parent framed window NX handler
|
||||
* @param widgetControl Controlling widget for this toolbar.
|
||||
* @param height The height of the toolbar.
|
||||
*/
|
||||
|
||||
CNxToolbar(CNxTkWindow *pNxTkWindow, NXTKWINDOW hNxTkWindow,
|
||||
CWidgetControl *pWidgetControl, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CNxToolbar(void);
|
||||
|
||||
/**
|
||||
* Creates a new toolbar. Toolbar creation is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the toolbar was successfully created.
|
||||
*/
|
||||
|
||||
bool open(void);
|
||||
|
||||
/**
|
||||
* Each implementation of INxWindow must provide a method to recover
|
||||
* the contained CWidgetControl instance.
|
||||
*
|
||||
* @return The contained CWidgetControl instance
|
||||
*/
|
||||
|
||||
CWidgetControl *getWidgetControl(void) const;
|
||||
|
||||
/**
|
||||
* Synchronize the window with the NX server. This function will delay
|
||||
* until the the NX server has caught up with all of the queued requests.
|
||||
* When this function returns, the state of the NX server will be the
|
||||
* same as the state of the application.
|
||||
*/
|
||||
|
||||
inline void synchronize(void)
|
||||
{
|
||||
CCallback::synchronize(m_hNxTkWindow, CCallback::NXTK_FRAMEDWINDOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the position and size information of the toolbar. The values
|
||||
* will be returned asynchronously through the client callback method.
|
||||
* The GetPosition() method may than be called to obtain the positional
|
||||
* data as provided by the callback.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool requestPosition(void);
|
||||
|
||||
/**
|
||||
* Get the position of the toolbar (as reported by the NX callback).
|
||||
*
|
||||
* @return The position.
|
||||
*/
|
||||
|
||||
bool getPosition(FAR struct nxgl_point_s *pPos);
|
||||
|
||||
/**
|
||||
* Get the size of the toolbar (as reported by the NX callback).
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
bool getSize(FAR struct nxgl_size_s *pSize);
|
||||
|
||||
/**
|
||||
* Set the position and size of the toolbar. The position of
|
||||
* the toolbar is fixed at the top of the parent framed window.
|
||||
*
|
||||
* @param pPos The new position of the toolbar.
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool setPosition(FAR const struct nxgl_point_s *pPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the selected toolbar. The only variable dimension
|
||||
* is the height of the toolbar, but that cannot be changed once
|
||||
* it is created.
|
||||
*
|
||||
* @param pSize The new size of the toolbar.
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool setSize(FAR const struct nxgl_size_s *pSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bring the toolbar to the top of the display. The toolbar is
|
||||
* a component of the containing, parent, framed window. It
|
||||
* cannot be raised separately.
|
||||
*
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool raise(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower the toolbar to the bottom of the display. The toolbar is
|
||||
* a component of the containing, parent, framed window. It
|
||||
* cannot be raised separately.
|
||||
*
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool lower(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the toolbar is currently being displayed
|
||||
*
|
||||
* @return True if the window is visible
|
||||
*/
|
||||
|
||||
inline bool isVisible(void)
|
||||
{
|
||||
return !nxtk_ishidden(m_hNxTkWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a hidden toolbar. The toolbar is a component of the containing,
|
||||
* parent, framed window. It cannot be shown separately.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool show(void)
|
||||
{
|
||||
return nxtk_setvisibility(m_hNxTkWindow, false) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a visible window. The toolbar is a component of the containing,
|
||||
* parent, framed window. It cannot be hidden separately.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool hide(void)
|
||||
{
|
||||
return nxtk_setvisibility(m_hNxTkWindow, true) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* May be used to either (1) raise a window to the top of the display and
|
||||
* select modal behavior, or (2) disable modal behavior. The toolbar is
|
||||
* a component of the containing, parent, framed window. It cannot
|
||||
* be placed in the modal state separately.
|
||||
*
|
||||
* @param enable True: enter modal state; False: leave modal state
|
||||
* @return Always returns false.
|
||||
*/
|
||||
|
||||
inline bool modal(bool enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each window implementation also inherits from CCallback. CCallback,
|
||||
* by default, forwards NX keyboard input to the various widgets residing
|
||||
* in the window. But NxTerm is a different usage model; In this case,
|
||||
* keyboard input needs to be directed to the NxTerm character driver.
|
||||
* This method can be used to enable (or disable) redirection of NX
|
||||
* keyboard input from the window widgets to the NxTerm
|
||||
*
|
||||
* @param handle. The NXTERM handle. If non-NULL, NX keyboard
|
||||
* input will be directed to the NxTerm driver using this
|
||||
* handle; If NULL (the default), NX keyboard input will be
|
||||
* directed to the widgets within the window.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
inline void redirectNxTerm(NXTERM handle)
|
||||
{
|
||||
setNxTerm(handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set an individual pixel in the toolbar with the specified color.
|
||||
*
|
||||
* @param pPos The location of the pixel to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool setPixel(FAR const struct nxgl_point_s *pPos,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified rectangle in the toolbar with the specified color.
|
||||
*
|
||||
* @param pRect The location to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fill(FAR const struct nxgl_rect_s *pRect,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Get the raw contents of graphic memory within a rectangular region. NOTE:
|
||||
* Since raw graphic memory is returned, the returned memory content may be
|
||||
* the memory of windows above this one and may not necessarily belong to
|
||||
* this window unless you assure that this is the top window.
|
||||
*
|
||||
* @param rect The location to be copied
|
||||
* @param dest - The describes the destination bitmap to receive the
|
||||
* graphics data.
|
||||
*/
|
||||
|
||||
void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
|
||||
|
||||
/**
|
||||
* Fill the specified trapezoidal region in the toolbar with the specified
|
||||
* color.
|
||||
*
|
||||
* @param pClip Clipping rectangle relative to toolbar (may be null).
|
||||
* @param pTrap The trapezoidal region to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
|
||||
FAR const struct nxgl_trapezoid_s *pTrap,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified line in the toolbar with the specified color.
|
||||
*
|
||||
* @param vector - Describes the line to be drawn
|
||||
* @param width - The width of the line
|
||||
* @param color - The color to use to fill the line
|
||||
* @param caps - Draw a circular cap on the ends of the line to support
|
||||
* better line joins
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool drawLine(FAR struct nxgl_vector_s *vector,
|
||||
nxgl_coord_t width, nxgl_mxpixel_t color,
|
||||
enum ELineCaps caps);
|
||||
|
||||
/**
|
||||
* Draw a filled circle at the specified position, size, and color.
|
||||
*
|
||||
* @param center The window-relative coordinates of the circle center.
|
||||
* @param radius The radius of the rectangle in pixels.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Move a rectangular region within the toolbar.
|
||||
*
|
||||
* @param pRect Describes the rectangular region to move.
|
||||
* @param pOffset The offset to move the region.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool move(FAR const struct nxgl_rect_s *pRect,
|
||||
FAR const struct nxgl_point_s *pOffset);
|
||||
|
||||
/**
|
||||
* Copy a rectangular region of a larger image into the rectangle in the
|
||||
* specified toolbar.
|
||||
*
|
||||
* @param pDest Describes the rectangular on the display that will receive
|
||||
* the bitmap.
|
||||
* @param pSrc The start of the source image.
|
||||
* @param pOrigin the pOrigin of the upper, left-most corner of the full
|
||||
* bitmap. Both pDest and pOrigin are in toolbar coordinates, however,
|
||||
* pOrigin may lie outside of the display.
|
||||
* @param stride The width of the full source image in bytes.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool bitmap(FAR const struct nxgl_rect_s *pDest,
|
||||
FAR const void *pSrc,
|
||||
FAR const struct nxgl_point_s *pOrigin,
|
||||
unsigned int stride);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXTOOLBAR_HXX
|
||||
1351
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxwidget.hxx
Normal file
1351
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxwidget.hxx
Normal file
File diff suppressed because it is too large
Load Diff
399
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxwindow.hxx
Normal file
399
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/cnxwindow.hxx
Normal file
@@ -0,0 +1,399 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cnxwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2015, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXWINDOW_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXWINDOW_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
|
||||
#include "graphics/nxwidgets/ccallback.hxx"
|
||||
#include "graphics/nxwidgets/inxwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
struct SBitmap;
|
||||
|
||||
/**
|
||||
* This class defines operations on a basic "raw" NX window. These windows
|
||||
* are "raw" in the since that they are simply rectangular regions with
|
||||
* no framing or decoration of any kind
|
||||
*
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
*/
|
||||
|
||||
class CNxWindow : protected CCallback, public INxWindow
|
||||
{
|
||||
private:
|
||||
NXHANDLE m_hNxServer; /**< Handle to the NX server. */
|
||||
NXWINDOW m_hNxWindow; /**< Handle to the NX raw window */
|
||||
CWidgetControl *m_widgetControl; /**< The controlling widget for the window */
|
||||
uint8_t m_flags; /**< Window properties */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Creates an uninitialized instance of the CNxWindow
|
||||
* object. The open() method must be called to initialize the instance.
|
||||
*
|
||||
* The general steps to create any window include:
|
||||
* 1) Create a dumb CWigetControl instance
|
||||
* 2) Pass the dumb CWidgetControl instance to the window constructor
|
||||
* that inherits from INxWindow.
|
||||
* 3) The window constructor call CWidgetControl methods to "smarten"
|
||||
* the CWidgetControl instance with window-specific knowledge.
|
||||
* 4) Call the open() method on the window to display the window.
|
||||
* 5) After that, the fully smartend CWidgetControl instance can
|
||||
* be used to generate additional widgets.
|
||||
* 6) After that, the fully smartened CWidgetControl instance can
|
||||
* be used to generate additional widgets by passing it to the
|
||||
* widget constructor
|
||||
*
|
||||
* @param hNxServer Handle to the NX server.
|
||||
* @param widgetControl Controlling widget for this window.
|
||||
* @param flags Window properties
|
||||
*/
|
||||
|
||||
CNxWindow(NXHANDLE hNxServer, CWidgetControl *pWidgetControl,
|
||||
uint8_t flags = 0);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CNxWindow(void);
|
||||
|
||||
/**
|
||||
* Creates a new window. Window creation is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully opened.
|
||||
*/
|
||||
|
||||
bool open(void);
|
||||
|
||||
/**
|
||||
* Each implementation of INxWindow must provide a method to recover
|
||||
* the contained CWidgetControl instance.
|
||||
*
|
||||
* @return The contained CWidgetControl instance
|
||||
*/
|
||||
|
||||
CWidgetControl *getWidgetControl(void) const;
|
||||
|
||||
/**
|
||||
* Synchronize the window with the NX server. This function will delay
|
||||
* until the the NX server has caught up with all of the queued requests.
|
||||
* When this function returns, the state of the NX server will be the
|
||||
* same as the state of the application.
|
||||
*/
|
||||
|
||||
inline void synchronize(void)
|
||||
{
|
||||
CCallback::synchronize(m_hNxWindow, CCallback::NX_RAWWINDOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the position and size information of the window. The values
|
||||
* will be returned asynchronously through the client callback method.
|
||||
* The GetPosition() method may than be called to obtain the positional
|
||||
* data as provided by the callback.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool requestPosition(void);
|
||||
|
||||
/**
|
||||
* Get the position of the window (as reported by the NX callback).
|
||||
*
|
||||
* @return The position.
|
||||
*/
|
||||
|
||||
bool getPosition(FAR struct nxgl_point_s *pPos);
|
||||
|
||||
/**
|
||||
* Get the size of the window (as reported by the NX callback).
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
bool getSize(FAR struct nxgl_size_s *pSize);
|
||||
|
||||
/**
|
||||
* Set the position and size of the window.
|
||||
*
|
||||
* @param pPos The new position of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool setPosition(FAR const struct nxgl_point_s *pPos);
|
||||
|
||||
/**
|
||||
* Set the size of the selected window.
|
||||
*
|
||||
* @param pSize The new size of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool setSize(FAR const struct nxgl_size_s *pSize);
|
||||
|
||||
/**
|
||||
* Bring the window to the top of the display.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool raise(void)
|
||||
{
|
||||
return nx_raise(m_hNxWindow) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower the window to the bottom of the display.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool lower(void)
|
||||
{
|
||||
return nx_lower(m_hNxWindow) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the window is currently being displayed
|
||||
*
|
||||
* @return True if the window is visible
|
||||
*/
|
||||
|
||||
inline bool isVisible(void)
|
||||
{
|
||||
return !nx_ishidden(m_hNxWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a hidden window
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool show(void)
|
||||
{
|
||||
return nx_setvisibility(m_hNxWindow, false) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a visible window
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
inline bool hide(void)
|
||||
{
|
||||
return nx_setvisibility(m_hNxWindow, true) == OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* May be used to either (1) raise a window to the top of the display and
|
||||
* select modal behavior, or (2) disable modal behavior.
|
||||
*
|
||||
* @param enable True: enter modal state; False: leave modal state
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
bool modal(bool enable);
|
||||
|
||||
/**
|
||||
* Each window implementation also inherits from CCallback. CCallback,
|
||||
* by default, forwards NX keyboard input to the various widgets residing
|
||||
* in the window. But NxTerm is a different usage model; In this case,
|
||||
* keyboard input needs to be directed to the NxTerm character driver.
|
||||
* This method can be used to enable (or disable) redirection of NX
|
||||
* keyboard input from the window widgets to the NxTerm
|
||||
*
|
||||
* @param handle. The NXTERM handle. If non-NULL, NX keyboard
|
||||
* input will be directed to the NxTerm driver using this
|
||||
* handle; If NULL (the default), NX keyboard input will be
|
||||
* directed to the widgets within the window.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
inline void redirectNxTerm(NXTERM handle)
|
||||
{
|
||||
setNxTerm(handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set an individual pixel in the window with the specified color.
|
||||
*
|
||||
* @param pPos The location of the pixel to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool setPixel(FAR const struct nxgl_point_s *pPos,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified rectangle in the window with the specified color.
|
||||
*
|
||||
* @param pRect The location to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fill(FAR const struct nxgl_rect_s *pRect,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Get the raw contents of graphic memory within a rectangular region. NOTE:
|
||||
* Since raw graphic memory is returned, the returned memory content may be
|
||||
* the memory of windows above this one and may not necessarily belong to
|
||||
* this window unless you assure that this is the top window.
|
||||
*
|
||||
* @param rect The location to be copied
|
||||
* @param dest - The describes the destination bitmap to receive the
|
||||
* graphics data.
|
||||
*/
|
||||
|
||||
void getRectangle(FAR const struct nxgl_rect_s *rect, struct SBitmap *dest);
|
||||
|
||||
/**
|
||||
* Fill the specified trapezoidal region in the window with the specified
|
||||
* color.
|
||||
*
|
||||
* @param pClip Clipping rectangle relative to window (may be null).
|
||||
* @param pTrap The trapezoidal region to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
|
||||
FAR const struct nxgl_trapezoid_s *pTrap,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Fill the specified line in the window with the specified color.
|
||||
*
|
||||
* @param vector - Describes the line to be drawn
|
||||
* @param width - The width of the line
|
||||
* @param color - The color to use to fill the line
|
||||
* @param caps - Draw a circular cap on the ends of the line to support
|
||||
* better line joins
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool drawLine(FAR struct nxgl_vector_s *vector,
|
||||
nxgl_coord_t width, nxgl_mxpixel_t color,
|
||||
enum ELineCaps caps);
|
||||
|
||||
/**
|
||||
* Draw a filled circle at the specified position, size, and color.
|
||||
*
|
||||
* @param center The window-relative coordinates of the circle center.
|
||||
* @param radius The radius of the rectangle in pixels.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/**
|
||||
* Move a rectangular region within the window.
|
||||
*
|
||||
* @param pRect Describes the rectangular region to move.
|
||||
* @param pOffset The offset to move the region.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool move(FAR const struct nxgl_rect_s *pRect,
|
||||
FAR const struct nxgl_point_s *pOffset);
|
||||
|
||||
/**
|
||||
* Copy a rectangular region of a larger image into the rectangle in the
|
||||
* specified window.
|
||||
*
|
||||
* @param pDest Describes the rectangular on the display that will receive
|
||||
* the bitmap.
|
||||
* @param pSrc The start of the source image.
|
||||
* @param pOrigin the pOrigin of the upper, left-most corner of the full
|
||||
* bitmap. Both pDest and pOrigin are in window coordinates, however,
|
||||
* pOrigin may lie outside of the display.
|
||||
* @param stride The width of the full source image in bytes.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
bool bitmap(FAR const struct nxgl_rect_s *pDest,
|
||||
FAR const void *pSrc,
|
||||
FAR const struct nxgl_point_s *pOrigin,
|
||||
unsigned int stride);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CNXWINDOW_HXX
|
||||
@@ -0,0 +1,251 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cprogressbar.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CPROGRESSBAR_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CPROGRESSBAR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Widget providing a horizontal progress bar.
|
||||
*/
|
||||
|
||||
class CProgressBar : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
int16_t m_minimumValue; /**< Minimum value that the grip can represent. */
|
||||
int16_t m_maximumValue; /**< Maximum value that the grip can represent. */
|
||||
int16_t m_value; /**< Value of the progress bar. */
|
||||
bool m_showPercentageText; /**< If true, completion percentage is drawn
|
||||
over the bar. */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CProgressBar(const CProgressBar &progressBar) : CNxWidget(progressBar) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the progress bar, relative to its parent.
|
||||
* @param y The y coordinate of the progress bar, relative to its parent.
|
||||
* @param width The width of the progress bar.
|
||||
* @param height The height of the progress bar.
|
||||
*/
|
||||
|
||||
CProgressBar(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CProgressBar(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the progress bar can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
inline const int16_t getMinimumValue(void) const
|
||||
{
|
||||
return m_minimumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest value that the progress bar can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
inline const int16_t getMaximumValue(void) const
|
||||
{
|
||||
return m_maximumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the progress bar.
|
||||
* return The current progress bar value.
|
||||
*/
|
||||
|
||||
inline const int16_t getValue(void) const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the smallest value that the progress bar can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
inline void setMinimumValue(const int16_t value)
|
||||
{
|
||||
m_minimumValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the largest value that the progress bar can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
inline void setMaximumValue(const int16_t value)
|
||||
{
|
||||
m_maximumValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value that of the progress bar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValue(const int16_t value);
|
||||
|
||||
/**
|
||||
* Shows the percentage text over the bar.
|
||||
*/
|
||||
|
||||
inline void showPercentageText(void)
|
||||
{
|
||||
m_showPercentageText = true;
|
||||
redraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the percentage text over the bar.
|
||||
*/
|
||||
|
||||
inline void hidePercentageText(void)
|
||||
{
|
||||
m_showPercentageText = false;
|
||||
redraw();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CPROGRESSBAR_HXX
|
||||
@@ -0,0 +1,207 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cradiobutton.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRADIOBUTTON_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRADIOBUTTON_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbutton.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
class CRadioButtonGroup;
|
||||
|
||||
/**
|
||||
* Represents a radio button. Radio buttons can only exist as part of a
|
||||
* CRadioButtonGroup class, and should not be instantiated individually.
|
||||
* Radio buttons are tri-state - off, on and "mu".
|
||||
* The mu state cannot be enabled by a user - it can only be set by the
|
||||
* developer.
|
||||
*/
|
||||
|
||||
class CRadioButton : public CButton
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum listing all possible radio button states.
|
||||
*/
|
||||
|
||||
enum RadioButtonState
|
||||
{
|
||||
RADIO_BUTTON_STATE_OFF = 0, /**< Radio button is off */
|
||||
RADIO_BUTTON_STATE_ON = 1, /**< Radio button is on */
|
||||
RADIO_BUTTON_STATE_MU = 2 /**< Radio button is in the third state */
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
RadioButtonState m_state; /**< The state of the radio button */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Sets the radiobutton's state to "on".
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CRadioButton() { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CRadioButton(const CRadioButton &radioButton) : CButton(radioButton) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display.
|
||||
* @param x The x coordinate of the radio button, relative to its
|
||||
* parent.
|
||||
* @param y The y coordinate of the radio button, relative to its
|
||||
* parent.
|
||||
* @param width The width of the radio button.
|
||||
* @param height The height of the radio button.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* defaultCWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CRadioButton(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Get the current state of the radio button.
|
||||
*
|
||||
* @return The state of the radio button.
|
||||
*/
|
||||
|
||||
virtual inline RadioButtonState getState(void)
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of the radio button.
|
||||
*
|
||||
* @param state The new radio button state.
|
||||
*/
|
||||
|
||||
virtual void setState(RadioButtonState state);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRADIOBUTTON_HXX
|
||||
@@ -0,0 +1,253 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cradiobuttongroup.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRADIOBUTTONGROUP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRADIOBUTTONGROUP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cbutton.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
class CRadioButton;
|
||||
|
||||
/**
|
||||
* Container class that holds radio button widgets and tracks their status.
|
||||
* The group provides an easy way to determine which radio button is
|
||||
* selected. Note that, in order to set the "mu" state for a radio button,
|
||||
* it is necessary to set the state via the radio button, not the group.
|
||||
*/
|
||||
|
||||
class CRadioButtonGroup : public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CWidgetControl *m_pWidgetControl; /**< The controlling widget */
|
||||
CRadioButton *m_selectedWidget; /**< Pointer to the currently selected radio button */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort* port);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CRadioButtonGroup(const CRadioButtonGroup &radioButtonGroup) : CNxWidget(radioButtonGroup) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Note that the group determines its width and height
|
||||
* from the position and dimensions of its children.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display.
|
||||
* @param x The x coordinate of the group.
|
||||
* @param y The y coordinate of the group.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CRadioButtonGroup(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CRadioButtonGroup(void) { }
|
||||
|
||||
/**
|
||||
* Simple method for adding a new radio button to the group.
|
||||
* This should be used in preference to the usual addWidget() method,
|
||||
* as this method automatically resizes the group.
|
||||
*
|
||||
* @param x The x coordinate of the new button, relative to this
|
||||
* widget.
|
||||
* @param y The y coordinate of the new button, relative to this
|
||||
* widget.
|
||||
* @param width The width of the new button.
|
||||
* @param height The height of the new button.
|
||||
*/
|
||||
|
||||
CRadioButton *newRadioButton(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the selected widget.
|
||||
*
|
||||
* @return Pointer to the selected widget.
|
||||
*/
|
||||
|
||||
virtual const CRadioButton *getSelectedWidget(void) const;
|
||||
|
||||
/**
|
||||
* Gets the index of the selected widget.
|
||||
*
|
||||
* @return The index of the selected widget.
|
||||
*/
|
||||
|
||||
virtual const int getSelectedIndex(void) const;
|
||||
|
||||
/**
|
||||
* Sets the selected radio button to the supplied widget.
|
||||
*
|
||||
* @param widget The radio button to select.
|
||||
*/
|
||||
|
||||
virtual void setSelectedWidget(CRadioButton *widget);
|
||||
|
||||
/**
|
||||
* Selects the widget at the specified index.
|
||||
*
|
||||
* @param index The index of the widget to select.
|
||||
*/
|
||||
|
||||
virtual void setSelectedIndex(int index);
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the
|
||||
* widget's parent. Value is based on the length of the largest string
|
||||
* in the set of options.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Handle a mouse click event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a mouse double-click event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleDoubleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a mouse button release event that occurred within the bounds of
|
||||
* the source widget.
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a mouse button release event that occurred outside the bounds of
|
||||
* the source widget.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRADIOBUTTONGROUP_HXX
|
||||
449
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/crect.hxx
Normal file
449
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/crect.hxx
Normal file
@@ -0,0 +1,449 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cbgwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRECT_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRECT_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class describing a rectangle.
|
||||
*/
|
||||
|
||||
class CRect
|
||||
{
|
||||
public:
|
||||
struct nxgl_point_s m_pos; /**< The position of the rectangle in the window */
|
||||
struct nxgl_size_s m_size; /**< The size of the rectangle */
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
||||
CRect(void);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param x The x coordinate of the rect.
|
||||
* @param y The y coordinate of the rect.
|
||||
* @param width The width of the rect.
|
||||
* @param height The height of the rect.
|
||||
*/
|
||||
|
||||
CRect(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param rect Pointer to an NX rectangle
|
||||
*/
|
||||
|
||||
CRect(FAR const nxgl_rect_s *rect);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param rect CRect to copy.
|
||||
*/
|
||||
|
||||
CRect(const CRect& rect);
|
||||
|
||||
/**
|
||||
* Create a rect object from the supplied coordinates.
|
||||
*
|
||||
* @param x1 The x coordinate of the rect's top-left corner.
|
||||
* @param y1 The y coordinate of the rect's top-left corner.
|
||||
* @param x2 The x coordinate of the rect's bottom-right corner.
|
||||
* @param y2 The y coordinate of the rect's bottom-right corner.
|
||||
* @return A new rect.
|
||||
*/
|
||||
|
||||
static CRect fromCoordinates(nxgl_coord_t x1, nxgl_coord_t y1,
|
||||
nxgl_coord_t x2, nxgl_coord_t y2);
|
||||
|
||||
/**
|
||||
* Get the rectangle's left x coordinate.
|
||||
*
|
||||
* @return The rectangle's x coordinate.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getX(void) const
|
||||
{
|
||||
return m_pos.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rectangle's top y coordinate.
|
||||
*
|
||||
* @return The rectangle's y coordinate.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getY(void) const
|
||||
{
|
||||
return m_pos.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the rectangle
|
||||
*
|
||||
* @pos The location to return the rectangle position
|
||||
*/
|
||||
|
||||
inline void getPos(struct nxgl_point_s &pos) const
|
||||
{
|
||||
pos.x = m_pos.x;
|
||||
pos.y = m_pos.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rectangle's width.
|
||||
*
|
||||
* @return The rectangle's width.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getWidth(void) const
|
||||
{
|
||||
return m_size.w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rectangle's height.
|
||||
*
|
||||
* @return The rectangle's height.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getHeight(void) const
|
||||
{
|
||||
return m_size.h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the rectangle
|
||||
*
|
||||
* @param size The location to return the rectangle size
|
||||
*/
|
||||
|
||||
inline void getSize(struct nxgl_size_s &size) const
|
||||
{
|
||||
size.h = m_size.h;
|
||||
size.w = m_size.w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NX rectangle representation
|
||||
*
|
||||
* @param rect Pointer to NX rectangle
|
||||
*/
|
||||
|
||||
inline void getNxRect(FAR struct nxgl_rect_s *rect) const
|
||||
{
|
||||
rect->pt1.x = m_pos.x;
|
||||
rect->pt1.y = m_pos.y;
|
||||
rect->pt2.x = m_pos.x + m_size.w - 1;
|
||||
rect->pt2.y = m_pos.y + m_size.h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rectangle's left x coordinate.
|
||||
*
|
||||
* @param x The new x coordinate.
|
||||
*/
|
||||
|
||||
inline void setX(nxgl_coord_t x)
|
||||
{
|
||||
m_pos.x = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rectangle's top y coordinate.
|
||||
*
|
||||
* @param y The new y coordinate.
|
||||
*/
|
||||
|
||||
inline void setY(nxgl_coord_t y)
|
||||
{
|
||||
m_pos.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rect's width.
|
||||
*
|
||||
* @param width The new width.
|
||||
*/
|
||||
inline void setWidth(nxgl_coord_t width)
|
||||
{
|
||||
m_size.w = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rect's height.
|
||||
*
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
inline void setHeight(nxgl_coord_t height)
|
||||
{
|
||||
m_size.h = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NX rectangle representation
|
||||
*
|
||||
* @param rect Pointer to NX rectangle
|
||||
*/
|
||||
|
||||
inline void setNxRect(FAR const struct nxgl_rect_s *rect)
|
||||
{
|
||||
m_pos.x = rect->pt1.x;
|
||||
m_pos.y = rect->pt1.y;
|
||||
m_size.w = rect->pt2.x - rect->pt1.x + 1;
|
||||
m_size.h = rect->pt2.y - rect->pt1.y + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the x coordinate of the rect's bottom-right corner. If x2 is less
|
||||
* than the rect's current x coordinate the method automatically adjusts
|
||||
* the coordinates so that the rect's width is never negative. Changing this
|
||||
* property will change the width of the rect.
|
||||
*
|
||||
* @param x2 The x coordinate of the rect's bottom-right corner.
|
||||
*/
|
||||
|
||||
void setX2(nxgl_coord_t x2);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of the rect's bottom-right corner. If y2 is less
|
||||
* than the rect's current y coordinate the method automatically adjusts
|
||||
* the coordinates so that the rect's height is never negative. Changing this
|
||||
* property will change the height of the rect.
|
||||
*
|
||||
* @param y2 The y coordinate of the rect's bottom-right corner.
|
||||
*/
|
||||
|
||||
void setY2(nxgl_coord_t y2);
|
||||
|
||||
/**
|
||||
* Get the x coordinate of the rectangle's right side.
|
||||
*
|
||||
* @return The x coordinate of the rectangle's right side.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getX2(void) const
|
||||
{
|
||||
return m_pos.x + m_size.w - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y coordinate of the rectangle's bottom side.
|
||||
*
|
||||
* @return The y coordinate of the rerectangle's bottom side.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getY2(void) const
|
||||
{
|
||||
return m_pos.y + m_size.h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset the rectangle position by the specified dx, dy values.
|
||||
*
|
||||
* @param dx X offset value
|
||||
* @param dy Y offset value
|
||||
*/
|
||||
|
||||
inline void offset(nxgl_coord_t dx, nxgl_coord_t dy)
|
||||
{
|
||||
m_pos.x += dx;
|
||||
m_pos.y += dy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the rectangle has two dimensions; in other words, does it
|
||||
* have both height and width? Negative width or height is considered not to
|
||||
* be valid.
|
||||
*
|
||||
* @return True if the rect has height and width; false if not.
|
||||
*/
|
||||
|
||||
inline bool hasDimensions(void) const
|
||||
{
|
||||
return m_size.w > 0 && m_size.h > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates dest with a rectangle representing the intersection
|
||||
* of this rectangle and rect.
|
||||
*
|
||||
* @param rect The rectangle to intersect with this.
|
||||
* @param dest The destination rectangle.
|
||||
*/
|
||||
|
||||
void getIntersect(const CRect& rect, CRect& dest) const;
|
||||
|
||||
/**
|
||||
* Populates dest with a rectangle representing the smallest
|
||||
* rectangle that contains this rectangle and rect.
|
||||
*
|
||||
* @param rect The rectangle to add to this.
|
||||
* @param dest The destination rectangle.
|
||||
*/
|
||||
|
||||
void getAddition(const CRect &rect, CRect &dest) const;
|
||||
|
||||
/**
|
||||
* Clips this rect to the region that intersects the supplied rect.
|
||||
*
|
||||
* @param rect CRect to intersect.
|
||||
*/
|
||||
|
||||
void clipToIntersect(const CRect &rect);
|
||||
|
||||
/**
|
||||
* Expands this rect so that it includes the area described by the supplied
|
||||
* rect.
|
||||
*
|
||||
* @param rect CRect to include.
|
||||
*/
|
||||
|
||||
void expandToInclude(const CRect &rect);
|
||||
|
||||
/**
|
||||
* Check if the supplied rect intersects this.
|
||||
*
|
||||
* @param rect CRect to check for intersection with this.
|
||||
* @return True if the rect intersects this; false if not.
|
||||
*/
|
||||
|
||||
bool intersects(const CRect &rect) const;
|
||||
|
||||
/**
|
||||
* Check if the rect contains the supplied point.
|
||||
*
|
||||
* @param x X coordinate of the point.
|
||||
* @param y Y coordinate of the point.
|
||||
* @return True if the rect contains the point; false if not.
|
||||
*/
|
||||
|
||||
bool contains(nxgl_coord_t x, nxgl_coord_t y) const;
|
||||
|
||||
/**
|
||||
* Copy the properties of this rect to the destination rect.
|
||||
*
|
||||
* @param dest Destination rect to copy to.
|
||||
*/
|
||||
|
||||
void copyTo(CRect &dest) const;
|
||||
|
||||
/**
|
||||
* Overloaded & operator. Returns the intersect of this rectangle and the
|
||||
* rectangle passed as the "rect" argument".
|
||||
*
|
||||
* @param rect The rectangle to intersect with this.
|
||||
*/
|
||||
|
||||
CRect operator&(const CRect &rect);
|
||||
|
||||
/**
|
||||
* Overloaded + operator. Returns the smallest rectangle that can contain
|
||||
* this rectangle and the rectangle passed as the "rect" argument".
|
||||
*
|
||||
* @param rect The rectangle to add to this.
|
||||
*/
|
||||
|
||||
CRect operator+(const CRect &rect);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRECT_HXX
|
||||
@@ -0,0 +1,269 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/crlepalettebitmap.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRLEPALETTBITMAP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRLEPALETTBITMAP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/ibitmap.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* One Run-Length Encoded (RLE) value
|
||||
*/
|
||||
|
||||
struct SRlePaletteBitmapEntry
|
||||
{
|
||||
uint8_t npixels; /**< Number of pixels */
|
||||
uint8_t lookup; /**< Pixel RGB lookup index */
|
||||
};
|
||||
|
||||
/**
|
||||
* Run-Length Encoded (RLE), Paletted Bitmap Structure
|
||||
*/
|
||||
|
||||
struct SRlePaletteBitmap
|
||||
{
|
||||
uint8_t bpp; /**< Bits per pixel */
|
||||
uint8_t fmt; /**< Color format */
|
||||
uint8_t nlut; /**< Number of colors in the Look-Up Table (LUT) */
|
||||
nxgl_coord_t width; /**< Width in pixels */
|
||||
nxgl_coord_t height; /**< Height in rows */
|
||||
FAR const void *lut[2]; /**< Pointers to the beginning of the Look-Up Tables (LUTs) */
|
||||
|
||||
/**
|
||||
* The pointer to the beginning of the RLE data
|
||||
*/
|
||||
|
||||
FAR const struct SRlePaletteBitmapEntry *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class providing bitmap accessor for a bitmap represented by SRlePaletteBitmap.
|
||||
*/
|
||||
|
||||
class CRlePaletteBitmap : public IBitmap
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* The bitmap that is being managed
|
||||
*/
|
||||
|
||||
FAR const struct SRlePaletteBitmap *m_bitmap; /**< The bitmap that is being managed */
|
||||
|
||||
/**
|
||||
* Accessor state data
|
||||
*/
|
||||
|
||||
nxgl_coord_t m_row; /**< Logical row number */
|
||||
nxgl_coord_t m_col; /**< Logical column number */
|
||||
uint8_t m_remaining; /**< Number of bytes remaining in current entry */
|
||||
FAR const void *m_lut; /**< The selected LUT */
|
||||
FAR const struct SRlePaletteBitmapEntry *m_rle; /**< RLE entry being processed */
|
||||
|
||||
/**
|
||||
* Reset to the beginning of the image
|
||||
*/
|
||||
|
||||
void startOfImage(void);
|
||||
|
||||
/**
|
||||
* Advance position data ahead. Called after npixels have
|
||||
* have been consume.
|
||||
*
|
||||
* @param npixels The number of pixels to advance
|
||||
* @return False if this goes beyond the end of the image
|
||||
*/
|
||||
|
||||
bool advancePosition(nxgl_coord_t npixels);
|
||||
|
||||
/**
|
||||
* Seek ahead the specific number of pixels -- discarding
|
||||
* and advancing.
|
||||
*
|
||||
* @param npixels The number of pixels to skip
|
||||
* @return False if this goes beyond the end of the image
|
||||
*/
|
||||
|
||||
bool skipPixels(nxgl_coord_t npixels);
|
||||
|
||||
/** Seek to the beginning of the next row
|
||||
*
|
||||
* @return False if this was the last row of the image
|
||||
*/
|
||||
|
||||
bool nextRow(void);
|
||||
|
||||
/** Seek to the beignning specific row
|
||||
*
|
||||
* @param row The row number to seek to
|
||||
* @return False if this goes beyond the end of the image
|
||||
*/
|
||||
|
||||
bool seekRow(nxgl_coord_t row);
|
||||
|
||||
/** Copy the pixels from the current RLE entry the specified number of times.
|
||||
*
|
||||
* @param npixels The number of pixels to copy. Must be less than or equal
|
||||
* to m_remaining.
|
||||
* @param data The memory location provided by the caller
|
||||
* in which to return the data. This should be at least
|
||||
* (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
|
||||
* and properly aligned for the pixel color format.
|
||||
*/
|
||||
|
||||
void copyColor(nxgl_coord_t npixels, FAR void *data);
|
||||
|
||||
/** Copy pixels from the current position
|
||||
*
|
||||
* @param npixels The number of pixels to copy
|
||||
* @param data The memory location provided by the caller
|
||||
* in which to return the data. This should be at least
|
||||
* (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
|
||||
* and properly aligned for the pixel color format.
|
||||
* @return False if this goes beyond the end of the image
|
||||
*/
|
||||
|
||||
bool copyPixels(nxgl_coord_t npixels, FAR void *data);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bitmap The bitmap structure being wrapped.
|
||||
*/
|
||||
|
||||
CRlePaletteBitmap(const struct SRlePaletteBitmap *bitmap);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~CRlePaletteBitmap(void) {}
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's width.
|
||||
*/
|
||||
|
||||
const uint8_t getColorFormat(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's color format.
|
||||
*/
|
||||
|
||||
const uint8_t getBitsPerPixel(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in pixels/columns).
|
||||
*
|
||||
* @return The bitmap's pixel depth.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getWidth(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's height (in rows).
|
||||
*
|
||||
* @return The bitmap's height.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getHeight(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in bytes).
|
||||
*
|
||||
* @return The bitmap's width.
|
||||
*/
|
||||
|
||||
const size_t getStride(void) const;
|
||||
|
||||
/**
|
||||
* Use the colors associated with a selected image.
|
||||
*
|
||||
* @param selected. true: Use colors for a selected widget,
|
||||
* false: Use normal (default) colors.
|
||||
*/
|
||||
|
||||
void setSelected(bool selected);
|
||||
|
||||
/**
|
||||
* Get one row from the bit map image using the selected colors.
|
||||
*
|
||||
* @param x The offset into the row to get
|
||||
* @param y The row number to get
|
||||
* @param width The number of pixels to get from the row
|
||||
* @param data The memory location provided by the caller
|
||||
* in which to return the data. This should be at least
|
||||
* (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
|
||||
* and properly aligned for the pixel color format.
|
||||
* @param True if the run was returned successfully.
|
||||
*/
|
||||
|
||||
bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
FAR void *data);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CRLEPALETTBITMAP_HXX
|
||||
@@ -0,0 +1,209 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscaledbitmap.hxx
|
||||
*
|
||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCALEDBITMAP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCALEDBITMAP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <fixedmath.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/video/rgbcolors.h>
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/ibitmap.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class for scaling layer for any bitmap that inherits from IBitMap
|
||||
*/
|
||||
|
||||
class CScaledBitmap : public IBitmap
|
||||
{
|
||||
protected:
|
||||
FAR IBitmap *m_bitmap; /**< The bitmap that is being scaled */
|
||||
struct nxgl_size_s m_size; /**< Scaled size of the image */
|
||||
FAR uint8_t *m_rowCache[2]; /**< Two cached rows of the image */
|
||||
unsigned int m_row; /**< Row number of the first cached row */
|
||||
b16_t m_xScale; /**< X scale factor */
|
||||
b16_t m_yScale; /**< Y scale factor */
|
||||
|
||||
/**
|
||||
* Read two rows into the row cache
|
||||
*
|
||||
* @param row - The row number of the first row to cache
|
||||
*/
|
||||
|
||||
bool cacheRows(unsigned int row);
|
||||
|
||||
/**
|
||||
* Given an two RGB colors and a fractional value, return the scaled
|
||||
* value between the two colors.
|
||||
*
|
||||
* @param incolor1 - The first color to be used
|
||||
* @param incolor2 - The second color to be used
|
||||
* @param fraction - The fractional value
|
||||
* @param outcolor - The returned, scaled color
|
||||
*/
|
||||
|
||||
bool scaleColor(FAR const struct rgbcolor_s &incolor1,
|
||||
FAR const struct rgbcolor_s &incolor2,
|
||||
b16_t fraction, FAR struct rgbcolor_s &outcolor);
|
||||
|
||||
/**
|
||||
* Given an image row and a non-integer column offset, return the
|
||||
* interpolated RGB color value corresponding to that position
|
||||
*
|
||||
* @param row - The pointer to the row in the row cache to use
|
||||
* @param column - The non-integer column offset
|
||||
* @param outcolor - The returned, interpolated color
|
||||
*
|
||||
*/
|
||||
|
||||
bool rowColor(FAR uint8_t *row, b16_t column,
|
||||
FAR struct rgbcolor_s &outcolor);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScaledBitmap(const CScaledBitmap &bitmap) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param bitmap The bitmap structure being scaled.
|
||||
* @newSize The new, scaled size of the image
|
||||
*/
|
||||
|
||||
CScaledBitmap(IBitmap *bitmap, struct nxgl_size_s &newSize);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CScaledBitmap(void);
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's color format.
|
||||
*/
|
||||
|
||||
const uint8_t getColorFormat(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's pixel depth.
|
||||
*/
|
||||
|
||||
const uint8_t getBitsPerPixel(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in pixels/columns).
|
||||
*
|
||||
* @return The bitmap's width (in pixels/columns).
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getWidth(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's height (in rows).
|
||||
*
|
||||
* @return The bitmap's height (in rows).
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getHeight(void) const;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in bytes).
|
||||
*
|
||||
* @return The bitmap's width (in bytes).
|
||||
*/
|
||||
|
||||
const size_t getStride(void) const;
|
||||
|
||||
/**
|
||||
* Use the colors associated with a selected image.
|
||||
*
|
||||
* @param selected. true: Use colors for a selected widget,
|
||||
* false: Use normal (default) colors.
|
||||
*/
|
||||
|
||||
inline void setSelected(bool selected) {}
|
||||
|
||||
/**
|
||||
* Get one row from the bit map image.
|
||||
*
|
||||
* @param x The offset into the row to get
|
||||
* @param y The row number to get
|
||||
* @param width The number of pixels to get from the row
|
||||
* @param data The memory location provided by the caller
|
||||
* in which to return the data. This should be at least
|
||||
* (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
|
||||
* and properly aligned for the pixel color format.
|
||||
* @param True if the run was returned successfully.
|
||||
*/
|
||||
|
||||
bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
FAR void *data);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCALEDBITMAP_HXX
|
||||
@@ -0,0 +1,292 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscrollbarhorizontal.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARHORIZONTAL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARHORIZONTAL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/islider.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CSliderHorizontal;
|
||||
class CGlyphButton;
|
||||
class CNxTimer;
|
||||
|
||||
/**
|
||||
* Container class that holds a slider widget and two arrow buttons.
|
||||
* The interface is presents is virtually identical to the CSliderHorizontal
|
||||
* widget, which means the two are easily interchangeable. All events
|
||||
* raised by the internal slider widget are re-raised by this widget
|
||||
* to this widget's event handler, meaning its events are also identical
|
||||
* to the CSliderHorizontal's.
|
||||
*/
|
||||
|
||||
class CScrollbarHorizontal : public ISlider, public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CSliderHorizontal *m_slider; /**< Pointer to the slider widget */
|
||||
CGlyphButton *m_leftButton; /**< Pointer to the left button */
|
||||
CGlyphButton *m_rightButton; /**< Pointer to the right button */
|
||||
nxgl_coord_t m_buttonWidth; /**< Width of the buttons */
|
||||
uint8_t m_scrollTimeout; /**< Time until a button triggers
|
||||
another grip movement */
|
||||
CNxTimer *m_timer; /**< Controls slider button repeats */
|
||||
|
||||
/**
|
||||
* Resize the scrollbar to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScrollbarHorizontal(const CScrollbarHorizontal &scrollbarHorizontal)
|
||||
: CNxWidget(scrollbarHorizontal) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control instance for the window.
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param height The height of the slider.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CScrollbarHorizontal(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CScrollbarHorizontal(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
const int getMinimumValue(void) const;
|
||||
|
||||
/**
|
||||
* Get the largest value that the slider can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
const int getMaximumValue(void) const;
|
||||
|
||||
/**
|
||||
* Get the current value of the slider.
|
||||
*
|
||||
* @return The current slider value.
|
||||
*/
|
||||
|
||||
const int getValue(void) const;
|
||||
|
||||
/**
|
||||
* Get the value represented by the height of the grip.
|
||||
* For sliders, this would typically be 1 (so each new
|
||||
* grip position is worth 1). For scrollbars, this
|
||||
* would be the height of the scrolling widget.
|
||||
*
|
||||
* @return The page size.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getPageSize(void) const;
|
||||
|
||||
/**
|
||||
* Set the smallest value that the slider can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
void setMinimumValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the largest value that the slider can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
void setMaximumValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition
|
||||
* and redraw the grip.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition and redraw
|
||||
* the grip. The supplied value should be bitshifted left 16 places.
|
||||
* This ensures greater accuracy than the standard setValue() method if
|
||||
* the slider is being used as a scrollbar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValueWithBitshift(const int32_t value);
|
||||
|
||||
/**
|
||||
* Set the page size represented by the grip.
|
||||
*
|
||||
* @param pageSize The page size.
|
||||
* @see getPageSize().
|
||||
*/
|
||||
|
||||
void setPageSize(const nxgl_coord_t pageSize);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleActionEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARHORIZONTAL_HXX
|
||||
@@ -0,0 +1,308 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscrollbarpanel.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARPANEL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARPANEL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cscrollingpanel.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cscrollbarvertical.hxx"
|
||||
#include "graphics/nxwidgets/cscrollbarhorizontal.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/iscrollable.hxx"
|
||||
#include "graphics/nxwidgets/cgraphicsport.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class containing a scrolling panel bordered by scrollbars.
|
||||
*/
|
||||
class CScrollbarPanel : public CNxWidget, public IScrollable,
|
||||
public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CWidgetControl *m_widgetControl; /**< Widget control instance */
|
||||
CScrollingPanel *m_panel; /**< Internal panel that
|
||||
contains children. */
|
||||
CScrollbarHorizontal *m_scrollbarHorizontal; /**< Horizontal scrollbar. */
|
||||
CScrollbarVertical *m_scrollbarVertical; /**< Vertical scrollbar. */
|
||||
uint8_t m_scrollbarWidth; /**< Width of the vertical
|
||||
scrollbar. */
|
||||
uint8_t m_scrollbarHeight; /**< Height of the horizontal
|
||||
scrollbar. */
|
||||
bool m_hasVerticalScrollbar; /**< Indicates the presence of
|
||||
a vertical scrollbar. */
|
||||
bool m_hasHorizontalScrollbar; /**< Indicates the presence of
|
||||
a horizontal scrollbar. */
|
||||
|
||||
/**
|
||||
* Creates the child widgets.
|
||||
*/
|
||||
|
||||
void buildUI(void);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CScrollbarPanel(void) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScrollbarPanel(const CScrollbarPanel &scrollbarPanel)
|
||||
: CNxWidget(scrollbarPanel) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the widget.
|
||||
* @param y The y coordinate of the widget.
|
||||
* @param width The width of the widget.
|
||||
* @param height The height of the widget.
|
||||
* @param flags The usual widget flags.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CScrollbarPanel(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
uint32_t flags,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Scroll the panel by the specified amounts.
|
||||
*
|
||||
* @param dx The horizontal distance to scroll.
|
||||
* @param dy The vertical distance to scroll.
|
||||
*/
|
||||
|
||||
virtual void scroll(int32_t dx, int32_t dy);
|
||||
|
||||
/**
|
||||
* Reposition the panel's scrolling region to the specified coordinates.
|
||||
*
|
||||
* @param x The new x coordinate of the scrolling region.
|
||||
* @param y The new y coordinate of the scrolling region.
|
||||
*/
|
||||
|
||||
virtual void jump(int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
virtual void setAllowsVerticalScroll(bool allow);
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
virtual void setAllowsHorizontalScroll(bool allow);
|
||||
|
||||
/**
|
||||
* Sets the width of the virtual canvas.
|
||||
*
|
||||
* @param width The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void setCanvasWidth(const int32_t width);
|
||||
|
||||
/**
|
||||
* Sets the height of the virtual canvas.
|
||||
*
|
||||
* @param height The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void setCanvasHeight(const int32_t height);
|
||||
|
||||
/**
|
||||
* Returns true if vertical scrolling is allowed.
|
||||
*
|
||||
* @return True if vertical scrolling is allowed.
|
||||
*/
|
||||
|
||||
virtual bool allowsVerticalScroll(void) const;
|
||||
|
||||
/**
|
||||
* Returns true if horizontal scrolling is allowed.
|
||||
*
|
||||
* @return True if horizontal scrolling is allowed.
|
||||
*/
|
||||
|
||||
virtual bool allowsHorizontalScroll(void) const;
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The x coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasX(void) const;
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The y coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasY(void) const;
|
||||
|
||||
/**
|
||||
* Gets the width of the virtual canvas.
|
||||
*
|
||||
* @return The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasWidth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the height of the virtual canvas.
|
||||
*
|
||||
* @return The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasHeight(void) const;
|
||||
|
||||
/**
|
||||
* Handle a widget scroll event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleScrollEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a widget value change event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleValueChangeEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the CScrollingPanel widget contained within
|
||||
* this widget.
|
||||
*
|
||||
* @return A pointer to the CScrollingPanel widget.
|
||||
*/
|
||||
|
||||
inline CScrollingPanel *getPanel(void)
|
||||
{
|
||||
return m_panel;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARPANEL_HXX
|
||||
@@ -0,0 +1,291 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscrollbarvertical.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARVERTICAL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARVERTICAL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/islider.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CSliderVertical;
|
||||
class CGlyphButton;
|
||||
class CNxTimer;
|
||||
|
||||
/**
|
||||
* Container class that holds a slider widget and two arrow buttons.
|
||||
* The interface is presents is virtually identical to the CSliderVertical
|
||||
* widget, which means the two are easily interchangeable. All events
|
||||
* raised by the internal slider widget are re-raised by this widget
|
||||
* to this widget's event handler, meaning its events are also identical
|
||||
* to the CSliderVertical's.
|
||||
*/
|
||||
class CScrollbarVertical : public ISlider, public CNxWidget, public CWidgetEventHandler {
|
||||
|
||||
protected:
|
||||
CSliderVertical *m_slider; /**< Pointer to the slider widget */
|
||||
CGlyphButton *m_upButton; /**< Pointer to the up button */
|
||||
CGlyphButton *m_downButton; /**< Pointer to the down button */
|
||||
nxgl_coord_t m_buttonHeight; /**< Height of the buttons */
|
||||
uint8_t m_scrollTimeout; /**< Time until a button triggers another grip
|
||||
movement */
|
||||
CNxTimer *m_timer; /**< Controls slider button repeats */
|
||||
|
||||
/**
|
||||
* Resize the scrollbar to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScrollbarVertical(const CScrollbarVertical& scrollbarVertical)
|
||||
: CNxWidget(scrollbarVertical) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control instance for the window.
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param height The height of the slider.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CScrollbarVertical(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CScrollbarVertical(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
const int getMinimumValue(void) const;
|
||||
|
||||
/**
|
||||
* Get the largest value that the slider can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
const int getMaximumValue(void) const;
|
||||
|
||||
/**
|
||||
* Get the current value of the slider.
|
||||
*
|
||||
* @return The current slider value.
|
||||
*/
|
||||
|
||||
const int getValue(void) const;
|
||||
|
||||
/**
|
||||
* Get the value represented by the height of the grip.
|
||||
* For sliders, this would typically be 1 (so each new
|
||||
* grip position is worth 1). For scrollbars, this
|
||||
* would be the height of the scrolling widget.
|
||||
*
|
||||
* @return The page size.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getPageSize(void) const;
|
||||
|
||||
/**
|
||||
* Set the smallest value that the slider can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
void setMinimumValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the largest value that the slider can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
void setMaximumValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition
|
||||
* and redraw the grip.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition and redraw
|
||||
* the grip. The supplied value should be bitshifted left 16 places.
|
||||
* This ensures greater accuracy than the standard setValue() method if
|
||||
* the slider is being used as a scrollbar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValueWithBitshift(const int32_t value);
|
||||
|
||||
/**
|
||||
* Set the page size represented by the grip.
|
||||
*
|
||||
* @param pageSize The page size.
|
||||
* @see getPageSize().
|
||||
*/
|
||||
|
||||
void setPageSize(const nxgl_coord_t pageSize);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleActionEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLBARVERTICAL_HXX
|
||||
@@ -0,0 +1,480 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscrollinglistbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGLISTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGLISTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/clistbox.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/clistdata.hxx"
|
||||
#include "graphics/nxwidgets/clistboxdataitem.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/ilistbox.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CScrollbarVertical;
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Widget containing a CListBox and a vertical scrollbar. Exposed
|
||||
* methods are more or less identical to the methods exposed by the CListBox
|
||||
* to ensure that the two are interchangeable.
|
||||
*/
|
||||
|
||||
class CScrollingListBox : public IListBox, public CNxWidget,
|
||||
public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CListBox *m_listbox; /**< Pointer to the list box. */
|
||||
CScrollbarVertical *m_scrollbar; /**< Pointer to the scrollbar. */
|
||||
uint8_t m_scrollbarWidth; /**< Width of the scrollbar. */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the listbox to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CScrollingListBox(void) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScrollingListBox(const CScrollingListBox &scrollingListBox)
|
||||
: CNxWidget(scrollingListBox) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the widget.
|
||||
* @param y The y coordinate of the widget.
|
||||
* @param width The width of the widget.
|
||||
* @param height The height of the widget.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CScrollingListBox(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Add a new option to the widget using default colors.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
*/
|
||||
|
||||
virtual void addOption(const CNxString &text, const uint32_t value);
|
||||
|
||||
/**
|
||||
* Add an option to the widget.
|
||||
*
|
||||
* @param option The option to add.
|
||||
*/
|
||||
|
||||
virtual void addOption(CListBoxDataItem *option);
|
||||
|
||||
/**
|
||||
* Add a new option to the widget.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
* @param normalTextColor Color to draw the text with when not selected.
|
||||
* @param normalBackColor Color to draw the background with when not selected.
|
||||
* @param selectedTextColor Color to draw the text with when selected.
|
||||
* @param selectedBackColor Color to draw the background with when selected.
|
||||
*/
|
||||
|
||||
virtual void addOption(const CNxString &text, const uint32_t value,
|
||||
const nxwidget_pixel_t normalTextColor,
|
||||
const nxwidget_pixel_t normalBackColor,
|
||||
const nxwidget_pixel_t selectedTextColor,
|
||||
const nxwidget_pixel_t selectedBackColor);
|
||||
|
||||
/**
|
||||
* Remove an option from the widget by its index.
|
||||
*
|
||||
* @param index The index of the option to remove.
|
||||
*/
|
||||
|
||||
virtual void removeOption(const int index);
|
||||
|
||||
/**
|
||||
* Remove all options from the widget.
|
||||
*/
|
||||
|
||||
virtual void removeAllOptions(void);
|
||||
|
||||
/**
|
||||
* Select an option by its index. Does not deselect any other selected options.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual inline void selectOption(const int index)
|
||||
{
|
||||
m_listbox->selectOption(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select an option by its index. Does not deselect any other selected options.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual inline void deselectOption(const int index)
|
||||
{
|
||||
m_listbox->deselectOption(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all options. Does nothing if the listbox does not allow multiple selections.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*/
|
||||
|
||||
virtual inline void selectAllOptions(void)
|
||||
{
|
||||
m_listbox->selectAllOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deselect all options.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*/
|
||||
|
||||
virtual inline void deselectAllOptions(void)
|
||||
{
|
||||
m_listbox->deselectAllOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selected index. Returns -1 if nothing is selected. If more than one
|
||||
* option is selected, the index of the first selected option is returned.
|
||||
*
|
||||
* @return The selected index.
|
||||
*/
|
||||
|
||||
virtual inline const int getSelectedIndex(void) const
|
||||
{
|
||||
return m_listbox->getSelectedIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selected index. Specify -1 to select nothing. Resets any
|
||||
* other selected items to deselected.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The selected index.
|
||||
*/
|
||||
|
||||
virtual inline void setSelectedIndex(const int index)
|
||||
{
|
||||
m_listbox->setSelectedIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selected option. Returns NULL if nothing is selected.
|
||||
*
|
||||
* @return The selected option.
|
||||
*/
|
||||
|
||||
virtual inline const CListBoxDataItem *getSelectedOption(void) const
|
||||
{
|
||||
return m_listbox->getSelectedOption();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @param allowMultipleSelections True to allow multiple selections.
|
||||
*/
|
||||
|
||||
virtual inline
|
||||
void setAllowMultipleSelections(const bool allowMultipleSelections)
|
||||
{
|
||||
m_listbox->setAllowMultipleSelections(allowMultipleSelections);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @return True if multiple selections are allowed.
|
||||
*/
|
||||
|
||||
virtual inline const bool allowsMultipleSelections(void) const
|
||||
{
|
||||
return m_listbox->allowsMultipleSelections();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the scrolling canvas to encompass all options.
|
||||
*/
|
||||
|
||||
virtual inline void resizeCanvas(void)
|
||||
{
|
||||
m_listbox->resizeCanvas();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specified option.
|
||||
*
|
||||
* @return The specified option.
|
||||
*/
|
||||
|
||||
virtual inline const CListBoxDataItem *getOption(const int index)
|
||||
{
|
||||
return m_listbox->getOption(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selected index. Returns -1 if nothing is selected.
|
||||
*
|
||||
* @return The selected index.
|
||||
*/
|
||||
|
||||
virtual inline const CListBoxDataItem *getOption(const int index) const
|
||||
{
|
||||
return m_listbox->getOption(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the options alphabetically by the text of the options.
|
||||
*/
|
||||
|
||||
virtual inline void sort(void)
|
||||
{
|
||||
m_listbox->sort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of options.
|
||||
*
|
||||
* @return The number of options.
|
||||
*/
|
||||
|
||||
virtual inline const int getOptionCount(void) const
|
||||
{
|
||||
return m_listbox->getOptionCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of a single option.
|
||||
*
|
||||
* @return The height of an option.
|
||||
*/
|
||||
|
||||
virtual inline const nxgl_coord_t getOptionHeight(void) const
|
||||
{
|
||||
return m_listbox->getOptionHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles events raised by its sub-widgets.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a widget action event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleActionEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handles events raised by its sub-widgets.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleScrollEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a mouse button click event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handles events raised by its sub-widgets.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleDoubleClickEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a mouse button release event that occurred within the bounds of
|
||||
* the source widget.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a mouse button release event that occurred outside the bounds of
|
||||
* the source widget.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Set the font used in the textbox.
|
||||
*
|
||||
* @param font Pointer to the new font.
|
||||
*/
|
||||
|
||||
virtual void setFont(CNxFont *font);
|
||||
|
||||
/**
|
||||
* Sets whether or not items added to the list are automatically
|
||||
* sorted on insert or not.
|
||||
*
|
||||
* @param sortInsertedItems True to enable sort on insertion.
|
||||
*/
|
||||
|
||||
virtual inline void setSortInsertedItems(const bool sortInsertedItems)
|
||||
{
|
||||
m_listbox->setSortInsertedItems(sortInsertedItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the widget's
|
||||
* parent. Value is based on the length of the largest string in the
|
||||
* set of options.
|
||||
*
|
||||
* @param rect Reference to a rect to populate with data.
|
||||
*/
|
||||
|
||||
virtual void getPreferredDimensions(CRect &rect) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGLISTBOX_HXX
|
||||
@@ -0,0 +1,372 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscrollingpanel.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGPANEL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGPANEL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/iscrollable.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Class containing a scrollable region. Responds to mouse movement. Can
|
||||
* contain sub-widgets which will also be scrolled.
|
||||
*/
|
||||
|
||||
class CScrollingPanel : public CNxWidget, public IScrollable
|
||||
{
|
||||
protected:
|
||||
CWidgetControl *m_widgetControl; /**< Widget control instance */
|
||||
int32_t m_canvasX; /**< X coordinate of the virtual
|
||||
canvas. */
|
||||
int32_t m_canvasY; /**< Y coordinate of the virtual
|
||||
canvas. */
|
||||
int32_t m_canvasWidth; /**< Width of the virtual canvas. */
|
||||
int32_t m_canvasHeight; /**< Height of the virtual canvas. */
|
||||
bool m_allowVerticalScroll; /**< True if vertical scrolling is
|
||||
allowed. */
|
||||
bool m_allowHorizontalScroll; /**< True if horizontal scrolling is
|
||||
allowed. */
|
||||
bool m_isContentScrolled; /**< True if the content drawn to the
|
||||
panel is scrolled(ie. everything
|
||||
drawn in the draw() method);
|
||||
false if just child objects are scrolled. */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Scrolls the panel to match the drag.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
* @param vX The horizontal drag distance.
|
||||
* @param vY The vertical drag distance.
|
||||
*/
|
||||
|
||||
virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
|
||||
/**
|
||||
* Starts the dragging system.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Scroll all child widgets by the specified amounts. Actually uses
|
||||
* the widget's moveTo() function to reposition them.
|
||||
*
|
||||
* @param dx The horizontal distance to scroll.
|
||||
* @param dy The vertical distance to scroll.
|
||||
* @param do_redraw Redraw widgets after moving.
|
||||
*/
|
||||
|
||||
void scrollChildren(int32_t dx, int32_t dy, bool do_redraw);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CScrollingPanel(void) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScrollingPanel(const CScrollingPanel &scrollingPanel)
|
||||
: CNxWidget(scrollingPanel) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the widget.
|
||||
* @param y The y coordinate of the widget.
|
||||
* @param width The width of the widget.
|
||||
* @param height The height of the widget.
|
||||
* @param flags The usual widget flags.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CScrollingPanel(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
uint32_t flags,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Scroll the panel by the specified amounts.
|
||||
*
|
||||
* @param dx The horizontal distance to scroll.
|
||||
* @param dy The vertical distance to scroll.
|
||||
*/
|
||||
|
||||
virtual void scroll(int32_t dx, int32_t dy);
|
||||
|
||||
/**
|
||||
* Reposition the panel's scrolling region to the specified coordinates.
|
||||
*
|
||||
* @param x The new x coordinate of the scrolling region.
|
||||
* @param y The new y coordinate of the scrolling region.
|
||||
*/
|
||||
|
||||
virtual void jump(int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Returns true if vertical scrolling is allowed.
|
||||
*
|
||||
* @return True if vertical scrolling is allowed.
|
||||
*/
|
||||
|
||||
inline bool allowsVerticalScroll(void) const
|
||||
{
|
||||
return m_allowVerticalScroll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if horizontal scrolling is allowed.
|
||||
*
|
||||
* @return True if horizontal scrolling is allowed.
|
||||
*/
|
||||
|
||||
inline bool allowsHorizontalScroll(void) const
|
||||
{
|
||||
return m_allowHorizontalScroll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The x coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual inline const int32_t getCanvasX(void) const
|
||||
{
|
||||
return m_canvasX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The y coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual inline const int32_t getCanvasY(void) const
|
||||
{
|
||||
return m_canvasY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the width of the virtual canvas.
|
||||
*
|
||||
* @return The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual inline const int32_t getCanvasWidth(void) const
|
||||
{
|
||||
return m_canvasWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the height of the virtual canvas.
|
||||
*
|
||||
* @return The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual inline const int32_t getCanvasHeight(void) const
|
||||
{
|
||||
return m_canvasHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
inline void setAllowsVerticalScroll(bool allow)
|
||||
{
|
||||
m_allowVerticalScroll = allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
inline void setAllowsHorizontalScroll(bool allow)
|
||||
{
|
||||
m_allowHorizontalScroll = allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not the content of the panel is scrolled.
|
||||
* Content is anything drawn to the panel in the draw() method.
|
||||
* This property is disabled by default, which will result in
|
||||
* faster scrolling of child objects.
|
||||
* If the panel contains no child objects, just draw() method
|
||||
* content, consider using a SuperBitmap class instead.
|
||||
*
|
||||
* @param scrolled True to enable content scrolling; false to disable it.
|
||||
*/
|
||||
|
||||
inline void setContentScrolled(bool scrolled)
|
||||
{
|
||||
m_isContentScrolled = scrolled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the content of the panel, drawn via the draw() method,
|
||||
* is scrolled.
|
||||
*
|
||||
* @return True if the content is scrolled; false if not.
|
||||
*/
|
||||
|
||||
inline bool IsContentScrolled(void)
|
||||
{
|
||||
return m_isContentScrolled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the virtual canvas.
|
||||
*
|
||||
* @param width The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual inline void setCanvasWidth(const int32_t width)
|
||||
{
|
||||
m_canvasWidth = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the height of the virtual canvas.
|
||||
*
|
||||
* @param height The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual inline void setCanvasHeight(const int32_t height)
|
||||
{
|
||||
m_canvasHeight = height;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGPANEL_HXX
|
||||
@@ -0,0 +1,466 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cscrollingtextbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGTEXTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGTEXTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cmultilinetextbox.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/iscrollable.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CScrollbarVertical;
|
||||
class CNxFont;
|
||||
|
||||
/**
|
||||
* Widget containing a CMultiLineTextBox and a vertical scrollbar. Exposed
|
||||
* methods are more or less identical to the methods exposed by the
|
||||
* CMultiLineTextBox to ensure that the two are interchangeable.
|
||||
*/
|
||||
|
||||
class CScrollingTextBox : public ITextBox, public CNxWidget,
|
||||
public IScrollable, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CMultiLineTextBox *m_texbox; /**< Pointer to the textbox */
|
||||
CScrollbarVertical *m_scrollbar; /**< Pointer to the scrollbar */
|
||||
uint8_t m_scrollbarWidth; /**< Width of the scrollbar */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the textbox to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CScrollingTextBox(void) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CScrollingTextBox(const CScrollingTextBox& scrollingTextBox)
|
||||
: CNxWidget(scrollingTextBox) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the text box, relative to its parent.
|
||||
* @param y The y coordinate of the text box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param text Pointer to a string to display in the textbox.
|
||||
* @param flags Standard widget flag options.
|
||||
* @param maxRows The maximum number of rows the textbox can track. Adding
|
||||
* text beyond this number will cause rows at the start of the text to be
|
||||
* forgotten; text is essentially stored as a queue, and adding to the back
|
||||
* of a full queue causes the front items to be popped off. Setting this to
|
||||
* 0 will make the textbox track only the visible rows.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the widget will use the values stored in the global
|
||||
* g_defaultWidgetStyle object. The widget will copy the properties of
|
||||
* the style into its own internal style object.
|
||||
*/
|
||||
|
||||
CScrollingTextBox(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const CNxString &text, uint32_t flags,
|
||||
nxgl_coord_t maxRows = 0,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Set the horizontal alignment of text within the textbox.
|
||||
*
|
||||
* @param alignment The horizontal position of the text.
|
||||
*/
|
||||
|
||||
virtual void setTextAlignmentHoriz(CMultiLineTextBox::TextAlignmentHoriz alignment);
|
||||
|
||||
/**
|
||||
* Set the vertical alignment of text within the textbox.
|
||||
*
|
||||
* @param alignment The vertical position of the text.
|
||||
*/
|
||||
|
||||
virtual void setTextAlignmentVert(CMultiLineTextBox::TextAlignmentVert alignment);
|
||||
|
||||
/**
|
||||
* Returns the number of "pages" that the text spans. A page
|
||||
* is defined as the amount of text that can be displayed within
|
||||
* the textbox at one time.
|
||||
*
|
||||
* @return The page count.
|
||||
*/
|
||||
|
||||
virtual const uint16_t getPageCount(void) const;
|
||||
|
||||
/**
|
||||
* Returns the current page.
|
||||
*
|
||||
* @return The current page.
|
||||
* @see getPageCount().
|
||||
*/
|
||||
|
||||
virtual const uint16_t getCurrentPage(void) const;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the Text object that contains the
|
||||
* wrapped text used in the textbox. It is used as the
|
||||
* pre-processed data source for the textbox, and should
|
||||
* not be altered.
|
||||
*
|
||||
* @return Pointer to the Text object.
|
||||
*/
|
||||
|
||||
virtual const CText *getText(void) const;
|
||||
|
||||
/**
|
||||
* Set the text displayed in the textbox.
|
||||
*
|
||||
* @param text String to display.
|
||||
*/
|
||||
|
||||
virtual void setText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Append new text to the end of the current text
|
||||
* displayed in the textbox.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
virtual void appendText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex);
|
||||
|
||||
/**
|
||||
* Remove specified number of characters from the string from the
|
||||
* start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
* @param count Number of characters to remove.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex, const unsigned int count);
|
||||
|
||||
/**
|
||||
* Set the font used in the textbox.
|
||||
*
|
||||
* @param font Pointer to the new font.
|
||||
*/
|
||||
|
||||
virtual void setFont(CNxFont *font);
|
||||
|
||||
/**
|
||||
* Get the length of the text string.
|
||||
*
|
||||
* @return The length of the text string.
|
||||
*/
|
||||
|
||||
virtual const unsigned int getTextLength(void) const;
|
||||
|
||||
/**
|
||||
* Sets the cursor display mode.
|
||||
*
|
||||
* @param cursorMode Determines cursor display mode
|
||||
*/
|
||||
|
||||
virtual void showCursor(EShowCursor cursorMode);
|
||||
|
||||
/**
|
||||
* Shows the cursor in default mode (only when the TextBox has focus).
|
||||
*/
|
||||
|
||||
inline void showCursor(void)
|
||||
{
|
||||
showCursor(SHOW_CURSOR_ONFOCUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the cursor.
|
||||
*/
|
||||
|
||||
inline void hideCursor(void)
|
||||
{
|
||||
showCursor(SHOW_CURSOR_NEVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables cursor wrapping
|
||||
*
|
||||
* @param wrap True enables cursor wrapping
|
||||
*/
|
||||
|
||||
virtual void wrapCursor(bool wrap);
|
||||
|
||||
/**
|
||||
* Move the cursor to the text position specified. 0 indicates the start
|
||||
* of the string. If position is greater than the length of the string,
|
||||
* the cursor is moved to the end of the string.
|
||||
*
|
||||
* @param position The new cursor position.
|
||||
*/
|
||||
|
||||
virtual void moveCursorToPosition(const int position);
|
||||
|
||||
/**
|
||||
* Get the cursor position. This is the index within the string that
|
||||
* the cursor is currently positioned over.
|
||||
*
|
||||
* @return position The cursor position.
|
||||
*/
|
||||
|
||||
virtual const int getCursorPosition(void) const;
|
||||
|
||||
/**
|
||||
* Insert text at the specified index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index Index at which to insert the text.
|
||||
*/
|
||||
|
||||
virtual void insertText(const CNxString &text, const unsigned int index);
|
||||
|
||||
/**
|
||||
* Insert text at the current cursor position.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
*/
|
||||
|
||||
virtual void insertTextAtCursor(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Handles events raised by its sub-widgets.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleValueChangeEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handles events raised by its sub-widgets.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleScrollEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The x coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasX(void) const;
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The y coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasY(void) const;
|
||||
|
||||
/**
|
||||
* Gets the width of the virtual canvas.
|
||||
*
|
||||
* @return The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasWidth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the height of the virtual canvas.
|
||||
*
|
||||
* @return The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasHeight(void) const;
|
||||
|
||||
/**
|
||||
* Scroll the panel by the specified amounts.
|
||||
*
|
||||
* @param dx The horizontal distance to scroll.
|
||||
* @param dy The vertical distance to scroll.
|
||||
*/
|
||||
|
||||
virtual void scroll(int32_t dx, int32_t dy);
|
||||
|
||||
/**
|
||||
* Reposition the panel's scrolling region to the specified coordinates.
|
||||
*
|
||||
* @param x The new x coordinate of the scrolling region.
|
||||
* @param y The new y coordinate of the scrolling region.
|
||||
*/
|
||||
|
||||
virtual void jump(int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
virtual void setAllowsVerticalScroll(bool allow);
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
virtual void setAllowsHorizontalScroll(bool allow);
|
||||
|
||||
/**
|
||||
* Sets the width of the virtual canvas.
|
||||
*
|
||||
* @param width The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void setCanvasWidth(const int32_t width);
|
||||
|
||||
/**
|
||||
* Sets the height of the virtual canvas.
|
||||
*
|
||||
* @param height The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void setCanvasHeight(const int32_t height);
|
||||
|
||||
/**
|
||||
* Returns true if vertical scrolling is allowed.
|
||||
*
|
||||
* @return True if vertical scrolling is allowed.
|
||||
*/
|
||||
|
||||
virtual bool allowsVerticalScroll(void) const;
|
||||
|
||||
/**
|
||||
* Returns true if horizontal scrolling is allowed.
|
||||
*
|
||||
* @return True if horizontal scrolling is allowed.
|
||||
*/
|
||||
|
||||
virtual bool allowsHorizontalScroll(void) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSCROLLINGTEXTBOX_HXX
|
||||
@@ -0,0 +1,343 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/csliderhorizontal.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERHORIZONTAL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERHORIZONTAL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/islider.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CSliderHorizontalGrip;
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Widget providing a sliding "grip" that can be moved left and
|
||||
* right in the "gutter". Essentially a scrollbar, but more
|
||||
* generic.
|
||||
*/
|
||||
|
||||
class CSliderHorizontal : public ISlider, public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CSliderHorizontalGrip *m_grip; /**< Pointer to the grip. */
|
||||
int m_minimumValue; /**< Minimum value that the grip can represent. */
|
||||
int m_maximumValue; /**< Maximum value that the grip can represent. */
|
||||
int32_t m_value; /**< Current value of the slider. */
|
||||
nxgl_coord_t m_minimumGripWidth; /**< Smallest width that the grip can become */
|
||||
nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
|
||||
the gutter. */
|
||||
int32_t m_gutterWidth; /**< Width of the gutter, taking into account
|
||||
any adjustments made to the width of the grip. */
|
||||
uint32_t m_contentSize; /**< Number of values in the min/max range. */
|
||||
|
||||
/**
|
||||
* Get the maximum possible value that the slider can represent. Useful when
|
||||
* using the slider as a scrollbar, as the height of the grip prevents the full
|
||||
* range of values being accessed (intentionally).
|
||||
* The returned value is shifted left 16 places for more accuracy in fixed-point
|
||||
* calculations.
|
||||
*
|
||||
* @return The maximum possible value that the slider can represent.
|
||||
*/
|
||||
|
||||
int32_t getPhysicalMaximumValueWithBitshift(void) const;
|
||||
|
||||
/**
|
||||
* Get the value represented by the top of the grip.
|
||||
* return The value represented by the top of the grip.
|
||||
*/
|
||||
|
||||
const int32_t getGripValue(void) const;
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the slider to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Moves the grip towards the mouse.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CSliderHorizontal(const CSliderHorizontal& sliderHorizontal)
|
||||
: CNxWidget(sliderHorizontal) { }
|
||||
|
||||
/**
|
||||
* Resize and redraw the grip.
|
||||
*/
|
||||
|
||||
void resizeGrip(void);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The widget control instance for the window.
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param height The height of the slider.
|
||||
*/
|
||||
|
||||
CSliderHorizontal(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CSliderHorizontal(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
inline const int getMinimumValue(void) const
|
||||
{
|
||||
return m_minimumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest value that the slider can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
inline const int getMaximumValue(void) const
|
||||
{
|
||||
return m_maximumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the slider.
|
||||
*
|
||||
* return The current slider value.
|
||||
*/
|
||||
|
||||
inline const int getValue(void) const
|
||||
{
|
||||
return m_value >> 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value represented by the height of the grip.
|
||||
* For sliders, this would typically be 1 (so each new
|
||||
* grip position is worth 1). For scrollbars, this
|
||||
* would be the height of the scrolling widget.
|
||||
*
|
||||
* @return The page size.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getPageSize(void) const
|
||||
{
|
||||
return m_pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the smallest value that the slider can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
inline void setMinimumValue(const int value)
|
||||
{
|
||||
m_minimumValue = value;
|
||||
m_contentSize = m_maximumValue - m_minimumValue + 1;
|
||||
resizeGrip();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the largest value that the slider can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
inline void setMaximumValue(const int value)
|
||||
{
|
||||
m_maximumValue = value;
|
||||
m_contentSize = m_maximumValue - m_minimumValue + 1;
|
||||
resizeGrip();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition
|
||||
* and redraw the grip.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition and redraw
|
||||
* the grip. The supplied value should be shifted left 16 places.
|
||||
* This ensures greater accuracy than the standard setValue() method if
|
||||
* the slider is being used as a scrollbar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValueWithBitshift(const int32_t value);
|
||||
|
||||
/**
|
||||
* Set the page size represented by the grip.
|
||||
*
|
||||
* @param pageSize The page size.
|
||||
* @see getPageSize().
|
||||
*/
|
||||
|
||||
inline void setPageSize(const nxgl_coord_t pageSize)
|
||||
{
|
||||
m_pageSize = pageSize;
|
||||
resizeGrip();
|
||||
};
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleDragEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can move through when
|
||||
* dragged.
|
||||
*
|
||||
* @return The smallest value that the slider can move through when
|
||||
* dragged.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getMinimumStep(void) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERHORIZONTAL_HXX
|
||||
@@ -0,0 +1,202 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/csliderhorizontalgrip.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERHORIZONTALGRIP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERHORIZONTALGRIP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Class representing the grip, or draggable button, with a horizontal
|
||||
* slider.
|
||||
*/
|
||||
|
||||
class CSliderHorizontalGrip : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Starts dragging the grip and redraws it.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Redraws the grip.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the grip.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Moves the grip to follow the mouse.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
* @param vX The horizontal distance of the drag.
|
||||
* @param vY The vertical distance of the drag.
|
||||
*/
|
||||
|
||||
virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CSliderHorizontalGrip(const CSliderHorizontalGrip &sliderHorizontalGrip)
|
||||
: CNxWidget(sliderHorizontalGrip) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the grip, relative to its parent.
|
||||
* @param y The y coordinate of the grip, relative to its parent.
|
||||
* @param width The width of the grip.
|
||||
* @param height The height of the grip.
|
||||
*/
|
||||
|
||||
CSliderHorizontalGrip(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CSliderHorizontalGrip(void) { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERHORIZONTALGRIP_HXX
|
||||
@@ -0,0 +1,343 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cslidervertical.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERVERTICAL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERVERTICAL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/islider.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CSliderVerticalGrip;
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Widget providing a sliding "grip" that can be moved up and
|
||||
* down the "gutter". Essentially a scrollbar, but more
|
||||
* generic.
|
||||
*/
|
||||
|
||||
class CSliderVertical : public ISlider, public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
CSliderVerticalGrip* m_grip; /**< Pointer to the grip. */
|
||||
int m_minimumValue; /**< Minimum value that the grip can represent. */
|
||||
int m_maximumValue; /**< Maximum value that the grip can represent. */
|
||||
int32_t m_value; /**< Current value of the slider. */
|
||||
nxgl_coord_t m_minimumGripHeight; /**< Smallest height that the grip can become. */
|
||||
nxgl_coord_t m_pageSize; /**< Value of a page of data, used when clicking
|
||||
the gutter */
|
||||
int32_t m_gutterHeight; /**< Height of the gutter, taking into account
|
||||
any adjustments made to the height of the grip. */
|
||||
uint32_t m_contentSize; /**< Number of values in the min/max range. */
|
||||
|
||||
/**
|
||||
* Get the maximum possible value that the slider can represent. Useful when
|
||||
* using the slider as a scrollbar, as the height of the grip prevents the full
|
||||
* range of values being accessed (intentionally).
|
||||
* The returned value is shifted left 16 places for more accuracy in fixed-point
|
||||
* calculations.
|
||||
*
|
||||
* @return The maximum possible value that the slider can represent.
|
||||
*/
|
||||
|
||||
int32_t getPhysicalMaximumValueWithBitshift(void) const;
|
||||
|
||||
/**
|
||||
* Get the value represented by the top of the grip. The value is
|
||||
* bitshifted left 16 places for accuracy.
|
||||
* return The value represented by the top of the grip.
|
||||
*/
|
||||
|
||||
const int32_t getGripValue(void) const;
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Resize the slider to the new dimensions.
|
||||
*
|
||||
* @param width The new width.
|
||||
* @param height The new height.
|
||||
*/
|
||||
|
||||
virtual void onResize(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Moves the grip towards the mouse.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CSliderVertical(const CSliderVertical &sliderVertical)
|
||||
: CNxWidget(sliderVertical) { }
|
||||
|
||||
/**
|
||||
* Resize and redraw the grip.
|
||||
*/
|
||||
|
||||
void resizeGrip();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the slider, relative to its parent.
|
||||
* @param y The y coordinate of the slider, relative to its parent.
|
||||
* @param width The width of the slider.
|
||||
* @param height The height of the slider.
|
||||
*/
|
||||
|
||||
CSliderVertical(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CSliderVertical(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
inline const int getMinimumValue(void) const
|
||||
{
|
||||
return m_minimumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the largest value that the slider can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
inline const int getMaximumValue(void) const
|
||||
{
|
||||
return m_maximumValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the slider.
|
||||
* return The current slider value.
|
||||
*/
|
||||
|
||||
inline const int getValue(void) const
|
||||
{
|
||||
return m_value >> 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value represented by the height of the grip.
|
||||
* For sliders, this would typically be 1 (so each new
|
||||
* grip position is worth 1). For scrollbars, this
|
||||
* would be the height of the scrolling widget.
|
||||
*
|
||||
* @return The page size.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getPageSize(void) const
|
||||
{
|
||||
return m_pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the smallest value that the slider can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
inline void setMinimumValue(const int value)
|
||||
{
|
||||
m_minimumValue = value;
|
||||
m_contentSize = m_maximumValue - m_minimumValue + 1;
|
||||
resizeGrip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the largest value that the slider can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
inline void setMaximumValue(const int value)
|
||||
{
|
||||
m_maximumValue = value;
|
||||
m_contentSize = m_maximumValue - m_minimumValue + 1;
|
||||
resizeGrip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition
|
||||
* and redraw the grip.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValue(const int value);
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition and redraw
|
||||
* the grip. The supplied value should be shifted left 16 places.
|
||||
* This ensures greater accuracy than the standard setValue() method if
|
||||
* the slider is being used as a scrollbar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
void setValueWithBitshift(const int32_t value);
|
||||
|
||||
/**
|
||||
* Set the page size represented by the grip.
|
||||
*
|
||||
* @param pageSize The page size.
|
||||
* @see getPageSize().
|
||||
*/
|
||||
|
||||
inline void setPageSize(const nxgl_coord_t pageSize)
|
||||
{
|
||||
m_pageSize = pageSize;
|
||||
resizeGrip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process events fired by the grip.
|
||||
*
|
||||
* @param e The event details.
|
||||
*/
|
||||
|
||||
virtual void handleDragEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can move through when
|
||||
* dragged.
|
||||
*
|
||||
* @return The smallest value that the slider can move through when
|
||||
* dragged.
|
||||
*/
|
||||
|
||||
nxgl_coord_t getMinimumStep(void) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERVERTICAL_HXX
|
||||
@@ -0,0 +1,201 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cslidervertical.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERVERTICALGRIP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERVERTICALGRIP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* Class representing the grip, or draggable button, with a vertical
|
||||
* slider.
|
||||
*/
|
||||
|
||||
class CSliderVerticalGrip : public CNxWidget
|
||||
{
|
||||
protected:
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Starts dragging the grip and redraws it.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Redraws the grip.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Redraws the grip.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Moves the grip to follow the mouse.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
* @param vX The horizontal distance of the drag.
|
||||
* @param vY The vertical distance of the drag.
|
||||
*/
|
||||
|
||||
virtual void onDrag(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CSliderVerticalGrip(const CSliderVerticalGrip &sliderVerticalGrip)
|
||||
: CNxWidget(sliderVerticalGrip) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the grip, relative to its parent.
|
||||
* @param y The y coordinate of the grip, relative to its parent.
|
||||
* @param width The width of the grip.
|
||||
* @param height The height of the grip.
|
||||
*/
|
||||
|
||||
CSliderVerticalGrip(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CSliderVerticalGrip(void) { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSLIDERVERTICALGRIP_HXX
|
||||
@@ -0,0 +1,237 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cstickybutton.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKYBUTTON_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKYBUTTON_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbutton.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* CButton that sticks down when clicked.
|
||||
*/
|
||||
|
||||
class CStickyButton : public CButton
|
||||
{
|
||||
protected:
|
||||
bool m_isStuckDown; /**< True if the key is stuck down */
|
||||
|
||||
/**
|
||||
* Draws the outline of the button.
|
||||
*
|
||||
* @param port Graphics port to draw to.
|
||||
*/
|
||||
|
||||
virtual void drawOutline(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Don't redraw on button press events. The button display is
|
||||
* completely controlled by the externally controlled stuck state.
|
||||
*
|
||||
* @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) {}
|
||||
|
||||
/**
|
||||
* Don't redraw on button release events. The button display is
|
||||
* completely controlled by the externally controlled stuck state.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y) { }
|
||||
|
||||
/**
|
||||
* Don't redraw on button release events. The button display is
|
||||
* completely controlled by the externally controlled stuck state.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage. The button display is
|
||||
* completely controlled by the externally controlled stuck state.
|
||||
*/
|
||||
|
||||
inline CStickyButton(const CStickyButton &button) : CButton(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for buttons that display a string.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display.
|
||||
* @param x The x coordinate of the button, relative to its parent.
|
||||
* @param y The y coordinate of the button, relative to its parent.
|
||||
* @param width The width of the button.
|
||||
* @param height The height of the button.
|
||||
* @param text The text for the button to display.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CStickyButton(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
const CNxString &text,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CStickyButton(void) { }
|
||||
|
||||
/**
|
||||
* Sets the key's stuck down state. If this is true, the key has a
|
||||
* inwards-bevelled border when drawn. If it is false, the key has
|
||||
* an outwards-bevelled border.
|
||||
*
|
||||
* @param stuckDown The new stuck down state.
|
||||
*/
|
||||
|
||||
void setStuckDown(bool stuckDown);
|
||||
|
||||
/**
|
||||
* Toggles the key's stuck down state.
|
||||
*/
|
||||
|
||||
inline void toggleStuckDown(void)
|
||||
{
|
||||
setStuckDown(!m_isStuckDown);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stuck down state.
|
||||
*
|
||||
* @return True is the button is in the stuck down state.
|
||||
*/
|
||||
|
||||
inline const bool isStuckDown(void) const
|
||||
{
|
||||
return m_isStuckDown;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKYBUTTON_HXX
|
||||
@@ -0,0 +1,174 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cstickybuttonarray.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKYBUTTONARRAY_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKYBUTTONARRAY_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbuttonarray.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CNxString;
|
||||
|
||||
/**
|
||||
* Manages a two-dimensional array of buttons as one widget. A two-
|
||||
* dimensional array of buttons might also be called a "keyboard".
|
||||
*/
|
||||
|
||||
class CStickyButtonArray : public CButtonArray
|
||||
{
|
||||
protected:
|
||||
bool m_isStuckDown; /**< True if one key in the array stuck down */
|
||||
bool m_stickDown; /**< True there is a change in a sticky button state */
|
||||
uint8_t m_stickyRow; /**< The row index of the stuck button */
|
||||
uint8_t m_stickyColumn; /**< The column index of the stuck button */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CStickyButtonArray(const CStickyButtonArray &button) : CButtonArray(button) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for an array of sticky buttons.
|
||||
*
|
||||
* @param pWidgetControl The widget control for the display.
|
||||
* @param x The x coordinate of the button array, relative to its parent.
|
||||
* @param y The y coordinate of the button array, relative to its parent.
|
||||
* @param buttonColumns The number of buttons in one row of the button array
|
||||
* @param buttonRows The number of buttons in one column of the button array
|
||||
* @param buttonWidth The width of one button
|
||||
* @param buttonHeight The height of one button
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CStickyButtonArray(CWidgetControl *pWidgetControl,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
uint8_t buttonColumns, uint8_t buttonRows,
|
||||
nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* CStickyButtonArray Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CStickyButtonArray(void) { }
|
||||
|
||||
/**
|
||||
* Return the position of the last stuck down button (0,0 will be returned
|
||||
* the no button has every been stuck down). The button at this position
|
||||
* is currently stuck down then, in addition, return true.
|
||||
*
|
||||
* @param column The location to return the column index of the button
|
||||
* of interest
|
||||
* @param row The location to return the row index of the button of
|
||||
* interest
|
||||
* @return True if a button in the array is clicked
|
||||
*/
|
||||
|
||||
virtual bool isAnyButtonStuckDown(int &column, int &row) const;
|
||||
|
||||
/**
|
||||
* Check if this specific button in the array is stuck down
|
||||
*
|
||||
* @param column The column of the button to check.
|
||||
* @param row The row of the button to check.
|
||||
* @return True if this button is stuck down
|
||||
*/
|
||||
|
||||
virtual bool isThisButtonStuckDown(int column, int row) const;
|
||||
|
||||
/**
|
||||
* Force the button at this position into the stuck down state
|
||||
*
|
||||
* @param column The column containing the button to stick down
|
||||
* @param row The rowtcontaining the button to stick down
|
||||
* @return False(0) is returned if the indices are out of range.
|
||||
*/
|
||||
|
||||
virtual bool stickDown(int column, int row);
|
||||
|
||||
/**
|
||||
* Unstick all buttons
|
||||
*/
|
||||
|
||||
virtual void unstick(void);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKYBUTTONARRAY_HXX
|
||||
@@ -0,0 +1,190 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cstickyimage.hxx
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKIMAGE_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKIMAGE_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cimage.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* CImage that sticks in the selected selected state when clicked.
|
||||
*/
|
||||
|
||||
class CStickyImage : public CImage
|
||||
{
|
||||
protected:
|
||||
bool m_stuckSelection; /**< True if the image is stuck in the selected */
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Don't redraw on click events. The image state is completely controlled
|
||||
* by the m_stuckSelection state.
|
||||
*
|
||||
* @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) {}
|
||||
|
||||
/**
|
||||
* Don't redraw on release events. The image state is completely controlled
|
||||
* by the m_stuckSelection state.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y) { }
|
||||
|
||||
/**
|
||||
* Don't redraw on release events. The image state is completely controlled
|
||||
* by the m_stuckSelection state.
|
||||
*
|
||||
* @param x The x coordinate of the mouse.
|
||||
* @param y The y coordinate of the mouse.
|
||||
*/
|
||||
|
||||
virtual void onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y) { }
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CStickyImage(const CStickyImage &image) : CImage(image) { }
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for an image.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the display
|
||||
* @param x The x coordinate of the image box, relative to its parent.
|
||||
* @param y The y coordinate of the image box, relative to its parent.
|
||||
* @param width The width of the image box.
|
||||
* @param height The height of the image box.
|
||||
* @param bitmap The source bitmap image.
|
||||
* @param style The style that the widget should use. If this is not
|
||||
* specified, the image will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CStickyImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height, FAR IBitmap *bitmap,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CStickyImage(void) { }
|
||||
|
||||
/**
|
||||
* Sets the image's stuck selection state.
|
||||
*
|
||||
* @param selection The new stuck selection state.
|
||||
*/
|
||||
|
||||
void setStuckSelection(bool selection);
|
||||
|
||||
/**
|
||||
* Toggles the images stuck selection state.
|
||||
*/
|
||||
|
||||
inline void toggleStuckSelection(void)
|
||||
{
|
||||
setStuckSelection(!m_stuckSelection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stuck selection state.
|
||||
*
|
||||
* @return True if the image is in the stuck selection state.
|
||||
*/
|
||||
|
||||
inline const bool isStuckSelection(void) const
|
||||
{
|
||||
return m_stuckSelection;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTICKIMAGE_HXX
|
||||
@@ -0,0 +1,192 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cstringiterator.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTRINGITERATOR_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTRINGITERATOR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxString;
|
||||
|
||||
/**
|
||||
* Class used to efficiently iterate over the characters in a CNxString
|
||||
* object. The CNxString is a Unicode string that uses the fixed-width
|
||||
* 16-bit encoding to represent its characters.
|
||||
*/
|
||||
|
||||
class CStringIterator
|
||||
{
|
||||
private:
|
||||
const CNxString *m_pString; /**< String being iterated over. */
|
||||
const nxwidget_char_t *m_pCurrentChar; /**< Pointer to the current position of the iterator. */
|
||||
int m_currentIndex; /**< Iterator's current index within the string. */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Moves the iterator to the first character in the string.
|
||||
*
|
||||
* @param string Pointer to the string that will be iterated over.
|
||||
*/
|
||||
|
||||
CStringIterator(FAR const CNxString* string);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~CStringIterator(void) { }
|
||||
|
||||
/**
|
||||
* Moves the iterator to the first character in the string.
|
||||
*
|
||||
* @param Returns false if the string is empty
|
||||
*/
|
||||
|
||||
bool moveToFirst(void);
|
||||
|
||||
/**
|
||||
* Moves the iterator to the last character in the string.
|
||||
*
|
||||
* @param Returns false if the string is empty
|
||||
*/
|
||||
|
||||
bool moveToLast(void);
|
||||
|
||||
/**
|
||||
* Move the iterator to the next character in the string.
|
||||
*
|
||||
* @return True if the iterator moved; false if not (indicates end of string).
|
||||
*/
|
||||
|
||||
bool moveToNext(void);
|
||||
|
||||
/**
|
||||
* Move the iterator to the previous character in the string.
|
||||
*
|
||||
* @return True if the iterator moved; false if not (indicates start of string).
|
||||
*/
|
||||
|
||||
bool moveToPrevious(void);
|
||||
|
||||
/**
|
||||
* Move the iterator to the specified index.
|
||||
*
|
||||
* @param index The index to move to.
|
||||
* @return True if the iterator moved; false if not (indicates end of string).
|
||||
*/
|
||||
|
||||
bool moveTo(int index);
|
||||
|
||||
/**
|
||||
* Get the current position of the iterator within the string.
|
||||
*
|
||||
* @return The current character index of the iterator.
|
||||
*/
|
||||
|
||||
inline int getIndex(void) const
|
||||
{
|
||||
return m_currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the letter in the string at the iterator's current point.
|
||||
*
|
||||
* @return The current character in the string.
|
||||
*/
|
||||
|
||||
inline nxwidget_char_t getChar(void) const
|
||||
{
|
||||
return *m_pCurrentChar;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CSTRINGITERATOR_HXX
|
||||
110
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ctabpanel.hxx
Normal file
110
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ctabpanel.hxx
Normal file
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ctabpanel.hxx
|
||||
*
|
||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Petteri Aimonen <jpa@kapsi.fi>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTABPANEL_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTABPANEL_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
#include "graphics/nxwidgets/clatchbuttonarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CRect;
|
||||
class CStickyButtonArray;
|
||||
|
||||
/**
|
||||
* Tab panel, with tabs at the top and a panel at the bottom.
|
||||
*/
|
||||
|
||||
class CTabPanel : public CNxWidget, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
TNxArray<CNxWidget*> m_tabpages;
|
||||
CLatchButtonArray *m_buttonbar;
|
||||
|
||||
virtual void handleActionEvent(const CWidgetEventArgs &e);
|
||||
|
||||
virtual void drawContents(CGraphicsPort* port) {}
|
||||
virtual void drawBorder(CGraphicsPort* port) {}
|
||||
|
||||
public:
|
||||
CTabPanel(CWidgetControl *pWidgetControl, uint8_t numPages,
|
||||
nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height,
|
||||
nxgl_coord_t buttonHeight,
|
||||
FAR const CWidgetStyle *style = (FAR const CWidgetStyle *)NULL
|
||||
);
|
||||
|
||||
inline CNxWidget &page(uint8_t index) { return *m_tabpages.at(index); }
|
||||
|
||||
void setPageName(uint8_t index, const CNxString &name);
|
||||
|
||||
void showPage(uint8_t index);
|
||||
|
||||
uint8_t getCurrentPageIndex() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
391
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ctext.hxx
Normal file
391
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ctext.hxx
Normal file
@@ -0,0 +1,391 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ctext.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTEXT_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTEXT_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/cnxfont.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* This class functions as a wrapper around a char array offering
|
||||
* more advanced functionality - it can wrap text, calculate its
|
||||
* height in pixels, calculate the width of a row, etc.
|
||||
*/
|
||||
|
||||
class CText : public CNxString
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Struct defining the position and length of a longest line within
|
||||
* the m_linePositions array.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int index;
|
||||
uint8_t width;
|
||||
} LongestLine;
|
||||
|
||||
CNxFont *m_font; /**< Font to be used for output */
|
||||
TNxArray<int> m_linePositions; /**< Array containing start indexes
|
||||
of each wrapped line */
|
||||
TNxArray<LongestLine> m_longestLines; /**< Array containing data describing
|
||||
successively longer wrapped
|
||||
lines */
|
||||
nxgl_coord_t m_lineSpacing; /**< Spacing between lines of text */
|
||||
int32_t m_textPixelHeight; /**< Total height of the wrapped
|
||||
text in pixels */
|
||||
uint8_t m_textPixelWidth; /**< Total width of the wrapped text
|
||||
in pixels */
|
||||
nxgl_coord_t m_width; /**< Width in pixels available t
|
||||
the text */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param font The font to use for this text object.
|
||||
* @param text A string that this text object should wrap around.
|
||||
* @param width The pixel width at which the text should wrap.
|
||||
*/
|
||||
|
||||
CText(CNxFont *font, const CNxString &text, nxgl_coord_t width);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CText(void) {}
|
||||
|
||||
/**
|
||||
* Set the text in the string.
|
||||
*
|
||||
* @param text Char array to use as the new data for this string.
|
||||
*/
|
||||
|
||||
virtual void setText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Set the text in the string.
|
||||
*
|
||||
* @param text Char array to use as the new data for this string.
|
||||
*/
|
||||
|
||||
virtual void setText(FAR const char *text);
|
||||
|
||||
/**
|
||||
* Set the text in the string.
|
||||
*
|
||||
* @param text Character to use as the new data for this string.
|
||||
*/
|
||||
|
||||
virtual void setText(const nxwidget_char_t text);
|
||||
|
||||
/**
|
||||
* Append text to the end of the string.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
virtual void append(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Insert text at the specified character index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index The char index to insert at.
|
||||
*/
|
||||
|
||||
virtual void insert(const CNxString &text, const int index);
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex The char index to start removing from.
|
||||
*/
|
||||
|
||||
virtual void remove(const int startIndex);
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex The char index to start removing from.
|
||||
* @param count The number of chars to remove.
|
||||
*/
|
||||
|
||||
virtual void remove(const int startIndex, const int count);
|
||||
|
||||
/**
|
||||
* Set the vertical spacing between rows of text.
|
||||
*
|
||||
* @param lineSpacing The line spacing.
|
||||
*/
|
||||
|
||||
void setLineSpacing(nxgl_coord_t lineSpacing);
|
||||
|
||||
/**
|
||||
* Sets the pixel width of the text; text wider than
|
||||
* this will automatically wrap.
|
||||
*
|
||||
* @param width Maximum pixel width of the text.
|
||||
*/
|
||||
|
||||
void setWidth(nxgl_coord_t width);
|
||||
|
||||
/**
|
||||
* Set the font to use.
|
||||
*
|
||||
* @param font Pointer to the new font.
|
||||
*/
|
||||
|
||||
void setFont(CNxFont *font);
|
||||
|
||||
/**
|
||||
* Get the number of characters in the specified line number.
|
||||
*
|
||||
* @param lineNumber The line number to check.
|
||||
* @return The number of characters in the line.
|
||||
*/
|
||||
|
||||
const int getLineLength(const int lineNumber) const;
|
||||
|
||||
/**
|
||||
* Get the number of characters in the specified line number,
|
||||
* ignoring any trailing blank characters.
|
||||
*
|
||||
* @param lineNumber The line number to check.
|
||||
* @return The number of characters in the line.
|
||||
*/
|
||||
|
||||
const int getLineTrimmedLength(const int lineNumber) const;
|
||||
|
||||
/**
|
||||
* Get the width in pixels of the specified line number.
|
||||
*
|
||||
* @param lineNumber The line number to check.
|
||||
* @return The pixel width of the line.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getLinePixelLength(const int lineNumber) const;
|
||||
|
||||
/**
|
||||
* Get the width in pixels of the specified line number,
|
||||
* ignoring any trailing blank characters.
|
||||
*
|
||||
* @param lineNumber The line number to check.
|
||||
* @return The pixel width of the line.
|
||||
*/
|
||||
|
||||
const nxgl_coord_t getLineTrimmedPixelLength(const int lineNumber) const;
|
||||
|
||||
/**
|
||||
* Get the total height of the text in pixels.
|
||||
*
|
||||
* @return The total height of the text.
|
||||
*/
|
||||
|
||||
inline const int32_t getPixelHeight(void) const
|
||||
{
|
||||
return m_textPixelHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the longest line in pixels.
|
||||
*
|
||||
* @return The width of the longest line.
|
||||
*/
|
||||
|
||||
inline const uint8_t getPixelWidth(void) const
|
||||
{
|
||||
return m_textPixelWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pixel spacing between each line of text.
|
||||
*
|
||||
* @return The line spacing.
|
||||
*/
|
||||
|
||||
inline const uint8_t getLineSpacing(void) const
|
||||
{
|
||||
return m_lineSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height in pixels of a line, given as the
|
||||
* height of the font plus the line spacing.
|
||||
*
|
||||
* @return The height of a line.
|
||||
*/
|
||||
|
||||
inline const uint8_t getLineHeight(void) const
|
||||
{
|
||||
return m_font->getHeight() + m_lineSpacing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of lines in the text.
|
||||
*
|
||||
* @return The line count.
|
||||
*/
|
||||
|
||||
inline const int getLineCount(void) const
|
||||
{
|
||||
return m_linePositions.size() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to the CText object's font.
|
||||
*
|
||||
* @return Pointer to the font.
|
||||
*/
|
||||
|
||||
CNxFont *getFont(void) const;
|
||||
|
||||
/**
|
||||
* Removes lines of text from the start of the text buffer.
|
||||
*
|
||||
* @param lines Number of lines to remove
|
||||
*/
|
||||
|
||||
void stripTopLines(const int lines);
|
||||
|
||||
/**
|
||||
* Wrap all of the text.
|
||||
*/
|
||||
|
||||
void wrap(void);
|
||||
|
||||
/**
|
||||
* Wrap the text from the line containing the specified char index onwards.
|
||||
*
|
||||
* @param charIndex The index of the char to start wrapping from; note
|
||||
* that the wrapping function will re-wrap that entire line of text.
|
||||
*/
|
||||
|
||||
void wrap(int charIndex);
|
||||
|
||||
/**
|
||||
* Get the index of the line of text that contains the specified index
|
||||
* within the raw char array.
|
||||
*
|
||||
* @param index The index to locate within the wrapped lines of text.
|
||||
* @return The number of the line of wrapped text that contains the
|
||||
* specified index.
|
||||
*/
|
||||
|
||||
const int getLineContainingCharIndex(const int index) const;
|
||||
|
||||
/**
|
||||
* Gets the index within the char array that represents the start of the line of
|
||||
* text indicated by the line parameter.
|
||||
*
|
||||
* @param line The line number to locate within the char array.
|
||||
* @return The index within the char array of the start of the supplied line.
|
||||
*/
|
||||
|
||||
const int getLineStartIndex(const int line) const
|
||||
{
|
||||
return m_linePositions[line];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTEXT_HXX
|
||||
375
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ctextbox.hxx
Normal file
375
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ctextbox.hxx
Normal file
@@ -0,0 +1,375 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ctextbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTEXTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTEXTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
|
||||
#include "graphics/nxwidgets/itextbox.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward references.
|
||||
*/
|
||||
|
||||
class CWidgetControl;
|
||||
class CNxTimer;
|
||||
class CNxString;
|
||||
|
||||
/**
|
||||
* Single-line textbox widget. Can align text both vertically and
|
||||
* horizontally in different ways. The widget gains this functionality by
|
||||
* inheriting from the CLabel class. However, if the amount of text exceeds
|
||||
* the dimensions of the widget, the widget will ignore its horizontal
|
||||
* alignment settings and switch to left-aligned instead. This ensures that
|
||||
* moving the cursor over the text will scroll through it correctly.
|
||||
*/
|
||||
|
||||
class CTextBox : public ITextBox, public CLabel, public CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
int m_cursorPos; /**< Position of the cursor within the string. */
|
||||
uint8_t m_showCursor; /**< Controls cursor visibility. */
|
||||
bool m_wrapCursor; /**< True wrap cursor at the ends of the text */
|
||||
|
||||
/**
|
||||
* Redraws the widget
|
||||
*/
|
||||
|
||||
inline void onBlur(void);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawContents(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Moves the cursor without redrawing.
|
||||
*
|
||||
* @param position New cursor position.
|
||||
* @return True if the cursor position changed
|
||||
*/
|
||||
|
||||
virtual bool repositionCursor(const int position);
|
||||
|
||||
/**
|
||||
* Move the cursor to the specified coordinates. The coordinates
|
||||
* are expected to be the result of a click, and therefore in
|
||||
* world-space rather than widget-space.
|
||||
*/
|
||||
|
||||
void moveCursorToClickLocation(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* 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 CGraphicsPort to draw to.
|
||||
* @see redraw()
|
||||
*/
|
||||
|
||||
virtual void drawBorder(CGraphicsPort *port);
|
||||
|
||||
/**
|
||||
* Moves the cursor to the clicked coordinates.
|
||||
*
|
||||
* @param x The x coordinates of the click.
|
||||
* @param y The y coordinates of the click.
|
||||
*/
|
||||
|
||||
virtual void onClick(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Does nothing.
|
||||
*
|
||||
* @param x The x coordinates of the click.
|
||||
* @param y The y coordinates of the click.
|
||||
*/
|
||||
|
||||
virtual void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Return true if the cursor is visible
|
||||
*/
|
||||
|
||||
virtual bool isCursorVisible(void) const;
|
||||
|
||||
/**
|
||||
* Get the x coordinate of the cursor in pixels relative
|
||||
* to the left-hand edge of the client rect.
|
||||
*
|
||||
* @return The x coordinate of the cursor in pixels.
|
||||
*/
|
||||
|
||||
virtual const nxgl_coord_t getCursorXPos(void) const;
|
||||
|
||||
/**
|
||||
* Get the width of the cursor in pixels.
|
||||
*
|
||||
* @return The width of the cursor in pixels.
|
||||
*/
|
||||
|
||||
virtual nxgl_coord_t getCursorWidth(void) const;
|
||||
|
||||
/**
|
||||
* Calculate the horizontal position of the string based on its length
|
||||
* and the alignment options. Alignment options are overridden if the
|
||||
* width of the string exceeds the width of the textbox.
|
||||
*/
|
||||
|
||||
virtual void calculateTextPositionHorizontal(void);
|
||||
|
||||
/**
|
||||
* Copy constructor is protected to prevent usage.
|
||||
*/
|
||||
|
||||
inline CTextBox(const CTextBox& textbox) : CLabel(textbox) { };
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for a textbox containing a string.
|
||||
*
|
||||
* @param pWidgetControl The controlling widget for the window
|
||||
* @param x The x coordinate of the text box, relative to its parent.
|
||||
* @param y The y coordinate of the text box, relative to its parent.
|
||||
* @param width The width of the textbox.
|
||||
* @param height The height of the textbox.
|
||||
* @param text Pointer to a string to display in the textbox.
|
||||
* @param style The style that the button should use. If this is not
|
||||
* specified, the button will use the global default widget
|
||||
* style.
|
||||
*/
|
||||
|
||||
CTextBox(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t width, nxgl_coord_t height, const CNxString &text,
|
||||
CWidgetStyle *style = (CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Sets the cursor display mode.
|
||||
*
|
||||
* @param cursorMode Determines cursor display mode
|
||||
*/
|
||||
|
||||
virtual void showCursor(EShowCursor cursorMode);
|
||||
|
||||
/**
|
||||
* Shows the cursor in default mode (only when the TextBox has focus).
|
||||
*/
|
||||
|
||||
virtual inline void showCursor(void)
|
||||
{
|
||||
showCursor(SHOW_CURSOR_ONFOCUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the cursor.
|
||||
*/
|
||||
|
||||
virtual inline void hideCursor(void)
|
||||
{
|
||||
showCursor(SHOW_CURSOR_NEVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables cursor wrapping
|
||||
*
|
||||
* @param wrap True enables cursor wrapping
|
||||
*/
|
||||
|
||||
virtual inline void wrapCursor(bool wrap)
|
||||
{
|
||||
m_wrapCursor = wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text displayed in the label.
|
||||
*
|
||||
* @param text String to display.
|
||||
*/
|
||||
|
||||
virtual void setText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Append new text to the end of the current text displayed in the
|
||||
* label.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
virtual void appendText(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex);
|
||||
|
||||
/**
|
||||
* Remove specified number of characters from the string from the
|
||||
* start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
* @param count Number of characters to remove.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex, const unsigned int count);
|
||||
|
||||
/**
|
||||
* Insert text at the specified index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index Index at which to insert the text.
|
||||
*/
|
||||
|
||||
virtual void insertText(const CNxString &text, const unsigned int index);
|
||||
|
||||
/**
|
||||
* Insert text at the current cursor position.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
*/
|
||||
|
||||
virtual void insertTextAtCursor(const CNxString &text);
|
||||
|
||||
/**
|
||||
* Move the cursor to the text position specified. 0 indicates the
|
||||
* start of the string. If position is greater than the length of the
|
||||
* string, the cursor is moved to the end of the string.
|
||||
*
|
||||
* @param position The new cursor position.
|
||||
*/
|
||||
|
||||
virtual void moveCursorToPosition(const int position);
|
||||
|
||||
/**
|
||||
* Get the cursor position. This is the index within the string that
|
||||
* the cursor is currently positioned over.
|
||||
*
|
||||
* @return position The cursor position.
|
||||
*/
|
||||
|
||||
virtual inline const int getCursorPosition(void) const
|
||||
{
|
||||
return m_cursorPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a keyboard press event. Replaces CWidgetEventHandler method.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleKeyPressEvent(const CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a cursor control event. Replaces CWidgetEventHandler method.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleCursorControlEvent(const CWidgetEventArgs &e);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CTEXTBOX_HXX
|
||||
@@ -0,0 +1,823 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwidgetcontrol.hxx
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETCONTROLT_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETCONTROLT_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/cgraphicsport.hxx"
|
||||
#include "graphics/nxwidgets/cnxwidget.hxx"
|
||||
#include "graphics/nxwidgets/crect.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cwindoweventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwindoweventhandlerlist.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class INxWindow;
|
||||
class CNxWidget;
|
||||
|
||||
/**
|
||||
* Class providing a top-level widget and an interface to the CWidgetControl
|
||||
* widget hierarchy.
|
||||
*
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
*/
|
||||
|
||||
class CWidgetControl
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Structure holding the status of the Mouse or Touchscreen. There must
|
||||
* be one instance of this structure per window instance. The
|
||||
* content of this structure is update by the CGraphicsPort on each
|
||||
* NX mouse callback
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
struct SXYInput
|
||||
{
|
||||
// A touchscreen has no buttons. However, the convention is that
|
||||
// touchscreen contacts are reported with the LEFT button pressed.
|
||||
// The loss of contct is reported with no buttons pressed.
|
||||
|
||||
#if 0 // Center and right buttons are not used
|
||||
// But only a mouse has center and right buttons
|
||||
|
||||
uint16_t leftPressed : 1; /**< Left button pressed (or
|
||||
touchscreen contact) */
|
||||
uint16_t centerPressed : 1; /**< Center button pressed (not
|
||||
used with touchscreen) */
|
||||
uint16_t rightPressed : 1; /**< Right button pressed (not
|
||||
used with touchscreen) */
|
||||
uint16_t leftHeld : 1; /**< Left button held down (or
|
||||
touchscreen contact) */
|
||||
uint16_t centerHeld : 1; /**< Center button held down
|
||||
(not used with touchscreen) */
|
||||
uint16_t rightHeld : 1; /**< Right button held down
|
||||
(not used with touchscreen) */
|
||||
uint16_t leftDrag : 1; /**< Left button held down (or
|
||||
touchscreen contact) */
|
||||
uint16_t centerDrag : 1; /**< Center button held down (or
|
||||
touchscreen contact) */
|
||||
uint16_t rightDrag : 1; /**< Right button held down (or
|
||||
touchscreen contact) */
|
||||
uint16_t leftReleased : 1; /**< Left button release (or
|
||||
loss of touchscreen contact) */
|
||||
uint16_t centerReleased : 1; /**< Center button release (or
|
||||
loss of touchscreen contact) */
|
||||
uint16_t rightReleased : 1; /**< Right button release (or
|
||||
loss of touchscreen contact) */
|
||||
uint16_t doubleClick : 1; /**< Left button double click */
|
||||
uint16_t unused : 3; /**< Padding bits */
|
||||
#else
|
||||
uint8_t leftPressed : 1; /**< Left button pressed (or
|
||||
touchscreen contact) */
|
||||
uint8_t leftHeld : 1; /**< Left button held down (or
|
||||
touchscreen contact) */
|
||||
uint8_t leftDrag : 1; /**< Left button held down (or
|
||||
touchscreen contact) */
|
||||
uint8_t leftReleased : 1; /**< Left button release (or
|
||||
loss of touchscreen contact) */
|
||||
uint8_t doubleClick : 1; /**< Left button double click */
|
||||
uint8_t unused : 3; /**< Padding bits */
|
||||
#endif
|
||||
|
||||
// These are attributes common to both touchscreen and mouse input devices
|
||||
|
||||
nxgl_coord_t x; /**< Current X coordinate of
|
||||
the mouse/touch */
|
||||
nxgl_coord_t y; /**< Current Y coordinate of
|
||||
the mouse/touch */
|
||||
nxgl_coord_t lastX; /**< X coordinate of the mouse
|
||||
at the previous poll */
|
||||
nxgl_coord_t lastY; /**< Y coordinate of the mouse
|
||||
at the previous poll */
|
||||
struct timespec leftPressTime; /**< Time the left button was
|
||||
pressed */
|
||||
struct timespec leftReleaseTime; /**< Time the left button was
|
||||
released */
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* State data
|
||||
*/
|
||||
|
||||
CGraphicsPort *m_port; /**< The graphics port
|
||||
that is used for
|
||||
drawing on this window */
|
||||
TNxArray<CNxWidget*> m_deleteQueue; /**< Array of widgets
|
||||
awaiting deletion. */
|
||||
TNxArray<CNxWidget*> m_widgets; /**< List of controlled
|
||||
widgets. */
|
||||
volatile bool m_haveGeometry; /**< True: indicates that we
|
||||
have valid geometry data. */
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
bool m_waiting; /**< True: External logic waiting for
|
||||
window event */
|
||||
sem_t m_waitSem; /**< External loops waits for
|
||||
events on this semaphore */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* I/O
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
struct SXYInput m_xyinput; /**< Current XY input
|
||||
device state */
|
||||
#endif
|
||||
CNxWidget *m_clickedWidget; /**< Pointer to the widget
|
||||
that is clicked. */
|
||||
CNxWidget *m_focusedWidget; /**< Pointer to the widget
|
||||
that received keyboard
|
||||
input. */
|
||||
uint8_t m_kbdbuf[CONFIG_NXWIDGETS_KBDBUFFER_SIZE];
|
||||
uint8_t m_nCh; /**< Number of buffered
|
||||
keyboard characters */
|
||||
uint8_t m_controls[CONFIG_NXWIDGETS_CURSORCONTROL_SIZE];
|
||||
uint8_t m_nCc; /**< Number of buffered
|
||||
cursor controls */
|
||||
/**
|
||||
* The following were picked off from the position callback.
|
||||
*/
|
||||
|
||||
NXHANDLE m_hWindow; /**< Handle to the NX window */
|
||||
struct nxgl_size_s m_size; /**< Size of the window */
|
||||
struct nxgl_point_s m_pos; /**< Position in display space */
|
||||
struct nxgl_rect_s m_bounds; /**< Size of the display */
|
||||
sem_t m_geoSem; /**< Posted when geometry is valid */
|
||||
sem_t m_boundsSem; /**< Posted when bounds are valid */
|
||||
CWindowEventHandlerList m_eventHandlers; /**< List of event handlers. */
|
||||
|
||||
/**
|
||||
* Style
|
||||
*/
|
||||
|
||||
CWidgetStyle m_style; /**< Default style used by all
|
||||
widgets in the window. */
|
||||
|
||||
/**
|
||||
* Copy a widget style
|
||||
*
|
||||
* @param dest The destination style
|
||||
* @param src The source to use
|
||||
*/
|
||||
|
||||
void copyWidgetStyle(CWidgetStyle *dest, const CWidgetStyle *src);
|
||||
|
||||
/**
|
||||
* Return the elapsed time in millisconds
|
||||
*
|
||||
* @param startTime A time in the past from which to compute the elapsed time.
|
||||
* @return The elapsed time since startTime
|
||||
*/
|
||||
|
||||
uint32_t elapsedTime(FAR const struct timespec *startTime);
|
||||
|
||||
/**
|
||||
* Pass clicks to the widget hierarchy. Closes the context menu if
|
||||
* the clicked widget is not the context menu. If a single widget
|
||||
* is supplied, only that widget is sent the click.
|
||||
*
|
||||
* @param x Click xcoordinate.
|
||||
* @param y Click ycoordinate.
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
* @return True means an interesting mouse event occurred
|
||||
*/
|
||||
|
||||
bool handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Get the index of the specified controlled widget.
|
||||
*
|
||||
* @param widget The widget to get the index of.
|
||||
* @return The index of the widget. -1 if the widget is not found.
|
||||
*/
|
||||
|
||||
const int getWidgetIndex(const CNxWidget *widget) const;
|
||||
|
||||
/**
|
||||
* Delete any widgets in the deletion queue.
|
||||
*/
|
||||
|
||||
void processDeleteQueue(void);
|
||||
|
||||
/**
|
||||
* Process mouse/touchscreen events and send throughout the hierarchy.
|
||||
*
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
* @return True means a mouse event occurred
|
||||
*/
|
||||
|
||||
bool pollMouseEvents(CNxWidget* widget);
|
||||
|
||||
/**
|
||||
* Process keypad events and send throughout the hierarchy.
|
||||
*
|
||||
* @return True means a keyboard event occurred
|
||||
*/
|
||||
|
||||
bool pollKeyboardEvents(void);
|
||||
|
||||
/**
|
||||
* Process cursor control events and send throughout the hierarchy.
|
||||
*
|
||||
* @return True means a cursor control event was processes
|
||||
*/
|
||||
|
||||
bool pollCursorControlEvents(void);
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
/**
|
||||
* Wake up and external logic that is waiting for a window event.
|
||||
*/
|
||||
|
||||
void postWindowEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Take the geometry semaphore (handling signal interruptions)
|
||||
*/
|
||||
|
||||
void takeGeoSem(void);
|
||||
|
||||
/**
|
||||
* Give the geometry semaphore
|
||||
*/
|
||||
|
||||
inline void giveGeoSem(void)
|
||||
{
|
||||
sem_post(&m_geoSem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if geometry data is available. If not, [re-]request the
|
||||
* geometry data and wait for it to become valid.
|
||||
* CAREFUL: This assumes that if we already have geometry data, then
|
||||
* it is valid. This might not be true if the size position was
|
||||
* recently changed.
|
||||
*/
|
||||
|
||||
void waitGeoData(void);
|
||||
|
||||
/**
|
||||
* Take the bounds semaphore (handling signal interruptions)
|
||||
*/
|
||||
|
||||
void takeBoundsSem(void);
|
||||
|
||||
/**
|
||||
* Give the bounds semaphore
|
||||
*/
|
||||
|
||||
inline void giveBoundsSem(void)
|
||||
{
|
||||
sem_post(&m_boundsSem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for bounds data
|
||||
*/
|
||||
|
||||
inline void waitBoundsData(void)
|
||||
{
|
||||
takeBoundsSem();
|
||||
giveBoundsSem();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
* Clear all mouse events
|
||||
*/
|
||||
|
||||
void clearMouseEvents(void);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param style The default style that all widgets on this display
|
||||
* should use. If this is not specified, the widget will use the
|
||||
* values stored in the defaultCWidgetStyle object.
|
||||
*/
|
||||
|
||||
CWidgetControl(FAR const CWidgetStyle *style = (const CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual ~CWidgetControl(void);
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
/**
|
||||
* Wait for an interesting window event to occur (like a mouse or keyboard event)
|
||||
* Caller's should exercise care to assure that the test for waiting and this
|
||||
* call are "atomic" .. perhaps by locking the scheduler like:
|
||||
*
|
||||
* sched_lock();
|
||||
* <check for events>
|
||||
* if (<no interesting events>)
|
||||
* {
|
||||
* window->waitForWindowEvent();
|
||||
* }
|
||||
* sched_unlock();
|
||||
*/
|
||||
|
||||
void waitForWindowEvent(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
/**
|
||||
* Is external logic awaiting for a window event?
|
||||
*
|
||||
* @return True if the widget if external logic is waiting.
|
||||
*/
|
||||
|
||||
inline const bool isWaiting(void) const
|
||||
{
|
||||
return m_waiting;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Run all code that needs to take place on a periodic basis.
|
||||
* This method normally called externally... either periodically
|
||||
* or when a window event is detected. If CONFIG_NXWIDGET_EVENTWAIT
|
||||
* is defined, then external logic want call waitWindow event and
|
||||
* when awakened, they should call this function. As an example:
|
||||
*
|
||||
* for (;;)
|
||||
* {
|
||||
* sched_lock(); // Make the sequence atomic
|
||||
* if (!window->pollEvents(0))
|
||||
* {
|
||||
* window->waitWindowEvent();
|
||||
* }
|
||||
* sched_unlock();
|
||||
* }
|
||||
*
|
||||
* This method is just a wrapper simply calls the followi.
|
||||
*
|
||||
* processDeleteQueue()
|
||||
* pollMouseEvents(widget)
|
||||
* pollKeyboardEvents()
|
||||
* pollCursorControlEvents()
|
||||
*
|
||||
* @param widget. Specific widget to poll. Use NULL to run through
|
||||
* of the widgets in the window.
|
||||
* @return True means some interesting event occurred
|
||||
*/
|
||||
|
||||
bool pollEvents(CNxWidget *widget = (CNxWidget *)NULL);
|
||||
|
||||
/**
|
||||
* Swaps the depth of the supplied widget.
|
||||
* This function presumes that all child widgets are screens.
|
||||
*
|
||||
* @param widget The widget to be depth-swapped.
|
||||
* @return True if the depth swap occurred.
|
||||
*/
|
||||
|
||||
bool swapWidgetDepth(CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Add another widget to be managed by this control instance
|
||||
*
|
||||
* @param widget The widget to be controlled.
|
||||
*/
|
||||
|
||||
inline void addControlledWidget(CNxWidget* widget)
|
||||
{
|
||||
m_widgets.push_back(widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a controlled widget
|
||||
*
|
||||
* @param widget The widget to be removed
|
||||
*/
|
||||
|
||||
void removeControlledWidget(CNxWidget* widget);
|
||||
|
||||
/**
|
||||
* Get the number of controlled widgets.
|
||||
*
|
||||
* @return The number of child widgets belonging to this widget.
|
||||
*/
|
||||
|
||||
inline const int getControlledWidgetCount(void) const
|
||||
{
|
||||
return m_widgets.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a widget to the list of widgets to be deleted.
|
||||
* Must never be called by anything other than the framework itself.
|
||||
*
|
||||
* @param widget The widget to add to the delete queue.
|
||||
*/
|
||||
|
||||
void addToDeleteQueue(CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Set the clicked widget pointer. Note that this should not be
|
||||
* called by code other than within the CWidgetControl library itself.
|
||||
*
|
||||
* @param widget The new clicked widget.
|
||||
*/
|
||||
|
||||
void setClickedWidget(CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Get the clicked widget pointer.
|
||||
*
|
||||
* @return Pointer to the clicked widget.
|
||||
*/
|
||||
|
||||
inline CNxWidget *getClickedWidget(void)
|
||||
{
|
||||
return m_clickedWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the focused widget that will receive keyboard input.
|
||||
*
|
||||
* @param widget The new focused widget.
|
||||
*/
|
||||
|
||||
void setFocusedWidget(CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Reset the focused widget so that it will no longer receive keyboard input.
|
||||
*
|
||||
* @param widget The new focused widget.
|
||||
*/
|
||||
|
||||
void clearFocusedWidget(CNxWidget *widget)
|
||||
{
|
||||
if (widget == m_focusedWidget)
|
||||
{
|
||||
m_focusedWidget = (CNxWidget *)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the focused widget pointer.
|
||||
*
|
||||
* @return Pointer to the focused widget.
|
||||
*/
|
||||
|
||||
inline CNxWidget *getFocusedWidget(void)
|
||||
{
|
||||
return m_focusedWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the occurrence of a double click.
|
||||
*
|
||||
* @return Pointer to the clicked widget.
|
||||
*/
|
||||
|
||||
inline bool doubleClick(void)
|
||||
{
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
return (bool)m_xyinput.doubleClick;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default widget style for this window.
|
||||
*
|
||||
* @param style. The location to return the widget's style
|
||||
*/
|
||||
|
||||
inline void getWidgetStyle(CWidgetStyle *style)
|
||||
{
|
||||
copyWidgetStyle(style, &m_style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default widget style for this window.
|
||||
*
|
||||
* @param style. The new widget style to copy.
|
||||
*/
|
||||
|
||||
inline void setWidgetStyle(const CWidgetStyle *style)
|
||||
{
|
||||
copyWidgetStyle(&m_style, style);
|
||||
}
|
||||
|
||||
/**
|
||||
* These remaining methods are used by the CCallback instance to
|
||||
* provide notifications of certain events.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This event will occur when the position or size of the underlying
|
||||
* window occurs.
|
||||
*
|
||||
* @param hWindow The window handle that should be used to communicate
|
||||
* with the window
|
||||
* @param pos The position of the window in the physical device space.
|
||||
* @param size The size of the window.
|
||||
* @param bounds The size of the underlying display (pixels x rows)
|
||||
*/
|
||||
|
||||
void geometryEvent(NXHANDLE hWindow,
|
||||
const struct nxgl_size_s *size,
|
||||
const struct nxgl_point_s *pos,
|
||||
const struct nxgl_rect_s *bounds);
|
||||
|
||||
/**
|
||||
* This event will occur when the a portion of the window that was
|
||||
* previously obscured is now exposed.
|
||||
*
|
||||
* @param nxRect The region in the window that must be redrawn.
|
||||
* @param more True means that more re-draw requests will follow
|
||||
*/
|
||||
|
||||
void redrawEvent(FAR const struct nxgl_rect_s *nxRect, bool more);
|
||||
|
||||
/**
|
||||
* This event means that new mouse data is available for the window.
|
||||
*
|
||||
* @param pos The (x,y) position of the mouse.
|
||||
* @param buttons See NX_MOUSE_* definitions.
|
||||
*/
|
||||
|
||||
void newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t buttons);
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* This event means that keyboard/keypad data is available for the window.
|
||||
*
|
||||
* @param nCh The number of characters that are available in pStr[].
|
||||
* @param pStr The array of characters.
|
||||
*/
|
||||
|
||||
void newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This event is the response from nx_block (or nxtk_block). Those
|
||||
* blocking interfaces are used to assure that no further messages are
|
||||
* directed to the window. Receipt of the blocked callback signifies
|
||||
* that (1) there are no further pending events and (2) that the
|
||||
* window is now 'defunct' and will receive no further events.
|
||||
*
|
||||
* This event supports coordinated destruction of a window in multi-
|
||||
* user mode. In multi-use mode, the client window logic must stay
|
||||
* intact until all of the queued callbacks are processed. Then the
|
||||
* window may be safely closed. Closing the window prior with pending
|
||||
* callbacks can lead to bad behavior when the callback is executed.
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
inline void windowBlocked(FAR void *arg)
|
||||
{
|
||||
m_eventHandlers.raiseBlockedEvent(arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* This event means that cursor control data is available for the window.
|
||||
*
|
||||
* @param cursorControl The cursor control code received.
|
||||
*/
|
||||
|
||||
void newCursorControlEvent(ECursorControl cursorControl);
|
||||
|
||||
/**
|
||||
* Get the window handle reported on the first position callback.
|
||||
*
|
||||
* @return This function returns the window handle.
|
||||
*/
|
||||
|
||||
inline NXHANDLE getWindowHandle(void)
|
||||
{
|
||||
// Verify that we have the window handle
|
||||
|
||||
if (m_hWindow == (NXHANDLE)0)
|
||||
{
|
||||
// The window handle is saved at the same time as the bounds
|
||||
|
||||
waitBoundsData();
|
||||
}
|
||||
|
||||
return m_hWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the window bounding box in physical display coordinates. This
|
||||
* method may need to wait until bounds data is available.
|
||||
*
|
||||
* @return This function returns the window handle.
|
||||
*/
|
||||
|
||||
inline CRect getWindowBoundingBox(void)
|
||||
{
|
||||
waitBoundsData();
|
||||
return CRect(&m_bounds);
|
||||
}
|
||||
|
||||
inline void getWindowBoundingBox(FAR struct nxgl_rect_s *bounds)
|
||||
{
|
||||
waitBoundsData();
|
||||
nxgl_rectcopy(bounds, &m_bounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the window (as reported by the last NX callback). This
|
||||
* method may need to wait until geometry data is available.
|
||||
*
|
||||
* @return The position.
|
||||
*/
|
||||
|
||||
inline bool getWindowPosition(FAR struct nxgl_point_s *pos)
|
||||
{
|
||||
// Check if we already have geometry data available. CAREFUL: This
|
||||
// might refer to OLD geometry data if the position was recently
|
||||
// changed!
|
||||
|
||||
waitGeoData();
|
||||
pos->x = m_pos.x;
|
||||
pos->y = m_pos.y;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the window (as reported by the last NX callback). This
|
||||
* method may need to wait until geometry data is available.
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
inline bool getWindowSize(FAR struct nxgl_size_s *size)
|
||||
{
|
||||
// Check if we already have geometry data available. CAREFUL: This
|
||||
// might refer to OLD geometry data if the position was recently
|
||||
// changed!
|
||||
|
||||
waitGeoData();
|
||||
size->h = m_size.h;
|
||||
size->w = m_size.w;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the window (as reported by the last NX callback). This
|
||||
* method may need to wait until geometry data is available.
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getWindowWidth(void)
|
||||
{
|
||||
// Check if we already have geometry data available. CAREFUL: This
|
||||
// might refer to OLD geometry data if the position was recently
|
||||
// changed!
|
||||
|
||||
waitGeoData();
|
||||
return m_size.w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the window (as reported by the last NX callback). This
|
||||
* method may need to wait until geometry data is available.
|
||||
*
|
||||
* @return The size.
|
||||
*/
|
||||
|
||||
inline nxgl_coord_t getWindowHeight(void)
|
||||
{
|
||||
// Check if we already have geometry data available. CAREFUL: This
|
||||
// might refer to OLD geometry data if the position was recently
|
||||
// changed!
|
||||
|
||||
waitGeoData();
|
||||
return m_size.h;
|
||||
}
|
||||
|
||||
/**
|
||||
* The creation sequence is:
|
||||
*
|
||||
* 1) Create a dumb CWigetControl instance
|
||||
* 2) Pass the dumb CWidgetControl instance to the window constructor
|
||||
* that inherits from INxWindow.
|
||||
* 3) The call this method with the static_cast to INxWindow to,
|
||||
* finally, create the CGraphicsPort for this window.
|
||||
* 4) After that, the fully smartend CWidgetControl instance can
|
||||
* be used to generate additional widgets.
|
||||
*
|
||||
* @param window The instance of INxWindow needed to construct the
|
||||
* CGraphicsPort instance
|
||||
*/
|
||||
|
||||
bool createGraphicsPort(INxWindow *window);
|
||||
|
||||
/**
|
||||
* Get the CGraphicsPort instance for drawing on this window
|
||||
*/
|
||||
|
||||
inline CGraphicsPort *getGraphicsPort(void)
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a window event handler. The window handler will receive
|
||||
* notification all NX events received by this window\.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler.
|
||||
*/
|
||||
|
||||
inline void addWindowEventHandler(CWindowEventHandler *eventHandler)
|
||||
{
|
||||
m_eventHandlers.addWindowEventHandler(eventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a window event handler.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler to remove.
|
||||
*/
|
||||
|
||||
inline void removeWindowEventHandler(CWindowEventHandler *eventHandler)
|
||||
{
|
||||
m_eventHandlers.removeWindowEventHandler(eventHandler);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETCONTROLT_HXX
|
||||
@@ -0,0 +1,237 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwidgeteventargs.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTARGS_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTARGS_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/teventargs.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Interesting Key events ***************************************************/
|
||||
|
||||
#define KEY_CODE_NONE ((nxwidget_char_t)0x00) /**< No key (NUL) */
|
||||
#define KEY_CODE_BACKSPACE ((nxwidget_char_t)0x08) /**< Backspace key */
|
||||
#define KEY_CODE_DELETE ((nxwidget_char_t)0x7f) /**< Delete key */
|
||||
#define KEY_CODE_ENTER ((nxwidget_char_t)0x0d) /**< Enter key (carriage return) */
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxWidget;
|
||||
|
||||
/**
|
||||
* Cursor control events
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CURSOR_HOME = 1, // Set the cursor to the beginning
|
||||
CURSOR_END, // Set the cursor to the end
|
||||
CURSOR_UP, // Set the cursor up one row
|
||||
CURSOR_DOWN, // Set the cursor down one row
|
||||
CURSOR_LEFT, // Move the cursor left one column
|
||||
CURSOR_RIGHT, // Move the cursor right one column
|
||||
CURSOR_PAGEUP, // Move the cursor up one page
|
||||
CURSOR_PAGEDOWN, // Move the cursor down one page
|
||||
} ECursorControl;
|
||||
|
||||
/**
|
||||
* Event arguments passed to listeners when a CNxWidget object raises an event.
|
||||
*/
|
||||
|
||||
class CWidgetEventArgs : public TEventArgs<CNxWidget*>
|
||||
{
|
||||
private:
|
||||
nxgl_coord_t m_x; /**< X coordinate of the event. */
|
||||
nxgl_coord_t m_y; /**< Y coordinate of the event. */
|
||||
nxgl_coord_t m_vX; /**< X distance moved during event, for dragging. */
|
||||
nxgl_coord_t m_vY; /**< Y distance moved during event, for dragging. */
|
||||
nxwidget_char_t m_key; /**< The key code / cursor code that raised the event. */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source Pointer to the CNxWidget object that raised the event.
|
||||
* @param x The x coordinate of the event.
|
||||
* @param y The y coordinate of the event.
|
||||
* @param vX The x distance of the event.
|
||||
* @param vY The y distance of the event.
|
||||
* @param keyCode The keycode of the event.
|
||||
*/
|
||||
|
||||
CWidgetEventArgs(CNxWidget *source, const nxgl_coord_t x, const nxgl_coord_t y,
|
||||
const nxgl_coord_t vX, const nxgl_coord_t vY,
|
||||
const nxwidget_char_t key)
|
||||
: TEventArgs<CNxWidget*>(source)
|
||||
{
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_vX = vX;
|
||||
m_vY = vY;
|
||||
m_key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x coordinate of the mouse event. Applies only to the following
|
||||
* events: mouse click, mouse double click, mouse drag, mouse release
|
||||
*
|
||||
* @return The x coordinate of the event.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getX(void) const
|
||||
{
|
||||
return m_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y coordinate of the mouse event. Applies only to the following
|
||||
* events: mouse click, mouse double click, mouse drag, mouse release
|
||||
*
|
||||
* @return The y coordinate of the event.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getY(void) const
|
||||
{
|
||||
return m_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x-axis mouse move distance of the mouse event. Applies
|
||||
* only to the mouse drag event.
|
||||
*
|
||||
* @return The x-axis mouse move distance of the event.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getVX(void) const
|
||||
{
|
||||
return m_vX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y-axis mouse move distance of the event. Applies
|
||||
* only to the mouse drag event.
|
||||
*
|
||||
* @return The y-axis mouse move distance of the event.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t getVY(void) const
|
||||
{
|
||||
return m_vY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key press that generated the event. Applies only to
|
||||
* the key press event.
|
||||
*
|
||||
* @return The key that generated the event.
|
||||
*/
|
||||
|
||||
inline const nxwidget_char_t getKey(void) const
|
||||
{
|
||||
return m_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cursor control that generated the event. Applies only
|
||||
* to the cursor control event.
|
||||
*
|
||||
* @return The cursor control that generated the event.
|
||||
*/
|
||||
|
||||
inline const ECursorControl getCursorControl(void) const
|
||||
{
|
||||
return (ECursorControl)m_key;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTARGS_HXX
|
||||
@@ -0,0 +1,284 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwidgeteventhandler.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTHANDLER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTHANDLER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxWidget;
|
||||
|
||||
/**
|
||||
* Base CWidgetEventHandler class, intended to be subclassed. Any class that
|
||||
* needs to listen for widget events should inherit from this class.
|
||||
*/
|
||||
|
||||
class CWidgetEventHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
||||
inline CWidgetEventHandler() { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CWidgetEventHandler() { }
|
||||
|
||||
/**
|
||||
* Handle a mouse button click event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleClickEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a mouse button drag event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleDragEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a drop event, triggered when the widget has been dragged-and-dropped.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleDropEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a mouse button release event that occurred within the bounds of
|
||||
* the source widget.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a mouse button release event that occurred outside the bounds of
|
||||
* the source widget.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleReleaseOutsideEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a key press event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleKeyPressEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a cursor control event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleCursorControlEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a key repeat event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleFocusEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget blur event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleBlurEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget close event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleCloseEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget hide event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleHideEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget show event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleShowEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget enable event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleEnableEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget disable event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleDisableEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget value change event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleValueChangeEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget resize event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleResizeEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget move event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleMoveEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget scroll event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleScrollEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget double-click event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleDoubleClickEvent(const CWidgetEventArgs &e) { }
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
virtual void handleActionEvent(const CWidgetEventArgs &e) { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTHANDLER_HXX
|
||||
@@ -0,0 +1,358 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwidgeteventhandlerlist.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTHANDLERLIST_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTHANDLERLIST_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxWidget;
|
||||
class CListDataItem;
|
||||
|
||||
/**
|
||||
* List of widget event handlers.
|
||||
*/
|
||||
class CWidgetEventHandlerList
|
||||
{
|
||||
protected:
|
||||
TNxArray<CWidgetEventHandler*> m_widgetEventHandlers; /**< List of event handlers */
|
||||
CNxWidget *m_widget; /**< Owning widget */
|
||||
bool m_isEnabled; /**< Indicates if events are active */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param widget The owning widget.
|
||||
*/
|
||||
|
||||
CWidgetEventHandlerList(CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
~CWidgetEventHandlerList(void) { }
|
||||
|
||||
/**
|
||||
* Check if the object raises events or not.
|
||||
*
|
||||
* @return True if events are enabled.
|
||||
*/
|
||||
|
||||
bool isEnabled(void) const;
|
||||
|
||||
/**
|
||||
* Get the event handler at the specified index.
|
||||
*
|
||||
* @param index The index of the event handler.
|
||||
* @return The event handler at the specified index.
|
||||
*/
|
||||
|
||||
inline CWidgetEventHandler *at(int index) const
|
||||
{
|
||||
return m_widgetEventHandlers.at(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the array.
|
||||
*
|
||||
* @return The size of the array.
|
||||
*/
|
||||
|
||||
inline int size(void) const
|
||||
{
|
||||
return m_widgetEventHandlers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a widget event handler. The event handler will receive
|
||||
* all events raised by this object.
|
||||
* @param eventHandler A pointer to the event handler.
|
||||
*/
|
||||
|
||||
void addWidgetEventHandler(CWidgetEventHandler *eventHandler);
|
||||
|
||||
/**
|
||||
* Remove a widget event handler.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler to remove.
|
||||
*/
|
||||
|
||||
void removeWidgetEventHandler(CWidgetEventHandler *eventHandler);
|
||||
|
||||
/**
|
||||
* Enables event raising.
|
||||
*/
|
||||
|
||||
inline void enable(void)
|
||||
{
|
||||
m_isEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables event raising.
|
||||
*/
|
||||
|
||||
inline void disable(void)
|
||||
{
|
||||
m_isEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a click event to the event handler.
|
||||
*
|
||||
* @param x The x coordinate of the click.
|
||||
* @param y The y coordinate of the click.
|
||||
*/
|
||||
|
||||
void raiseClickEvent(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Raise a double-click event to the event handler.
|
||||
*
|
||||
* @param x The x coordinate of the click.
|
||||
* @param y The y coordinate of the click.
|
||||
*/
|
||||
|
||||
void raiseDoubleClickEvent(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Raise a mouse release event to the event handler.
|
||||
*
|
||||
* @param x The x coordinate of the release.
|
||||
* @param y The y coordinate of the release.
|
||||
*/
|
||||
|
||||
void raiseReleaseEvent(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Raise a mouse release-outside event to the event handler.
|
||||
*
|
||||
* @param x The x coordinate of the release.
|
||||
* @param y The y coordinate of the release.
|
||||
*/
|
||||
|
||||
void raiseReleaseOutsideEvent(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Raise a mouse drag event to the event handler.
|
||||
*
|
||||
* @param x The x coordinate of the mouse when the drag started.
|
||||
* @param y The y coordinate of the mouse when the drag started.
|
||||
* @param vX The horizontal distance dragged.
|
||||
* @param vY The vertical distance dragged.
|
||||
*/
|
||||
|
||||
void raiseDragEvent(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
|
||||
/**
|
||||
* Raise a widget drop event to the event handler.
|
||||
*
|
||||
* @param x The x coordinate of the mouse when the drop occurred.
|
||||
* @param y The y coordinate of the mouse when the drop occurred.
|
||||
*/
|
||||
|
||||
void raiseDropEvent(nxgl_coord_t x, nxgl_coord_t y);
|
||||
|
||||
/**
|
||||
* Raise a key press event to the event handler.
|
||||
*
|
||||
* @param key The character code of the key that caused the event.
|
||||
*/
|
||||
|
||||
void raiseKeyPressEvent(nxwidget_char_t key);
|
||||
|
||||
/**
|
||||
* Raise a cursor control event to the event handler.
|
||||
*
|
||||
* @param cursorControl The cursor control code that caused the event.
|
||||
*/
|
||||
|
||||
void raiseCursorControlEvent(ECursorControl cursorControl);
|
||||
|
||||
/**
|
||||
* Raise a focus event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseFocusEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a blur event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseBlurEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a close event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseCloseEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a hide event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseHideEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a show event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseShowEvent(void);
|
||||
|
||||
/**
|
||||
* Raise an enable event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseEnableEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a disable event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseDisableEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a value change event to the event handler.
|
||||
*/
|
||||
|
||||
void raiseValueChangeEvent(void);
|
||||
|
||||
/**
|
||||
* Raise a resize event to the event handler.
|
||||
*
|
||||
* @param width The new width of the widget.
|
||||
* @param height The new height of the widget.
|
||||
*/
|
||||
|
||||
void raiseResizeEvent(nxgl_coord_t width, nxgl_coord_t height);
|
||||
|
||||
/**
|
||||
* Raise a move event to the event handler.
|
||||
*
|
||||
* @param x The new x coordinate of the widget.
|
||||
* @param y The new y coordinate of the widget.
|
||||
* @param vX The horizontal distance moved.
|
||||
* @param vY The vertical distance moved.
|
||||
*/
|
||||
|
||||
void raiseMoveEvent(nxgl_coord_t x, nxgl_coord_t y,
|
||||
nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
|
||||
/**
|
||||
* Raise an action event to the event handler. This should be called
|
||||
* when a widget's purpose has been fulfilled. For example, in the case
|
||||
* of a button, this event is raised when the button is released within
|
||||
* its boundaries. The button has produced a valid click, and thus
|
||||
* fulfilled its purpose, so it needs to raise an "action" event.
|
||||
*/
|
||||
|
||||
void raiseActionEvent(void);
|
||||
|
||||
/**
|
||||
* Raises a scroll event. Fired when the panel scrolls.
|
||||
*
|
||||
* @param vX Horizontal distance scrolled.
|
||||
* @param vY Vertical distance scrolled.
|
||||
*/
|
||||
|
||||
void raiseScrollEvent(nxgl_coord_t vX, nxgl_coord_t vY);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETEVENTHANDLERLIST_HXX
|
||||
@@ -0,0 +1,135 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwidgetstyle.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETSTYLE_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETSTYLE_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxFont;
|
||||
|
||||
/**
|
||||
* Class containing all colors that a widget depends on.
|
||||
*/
|
||||
|
||||
class CWidgetColors
|
||||
{
|
||||
public:
|
||||
nxgl_mxpixel_t background; /**< Color used for a normal background */
|
||||
nxgl_mxpixel_t selectedBackground; /**< Color used for a selected background */
|
||||
nxgl_mxpixel_t shineEdge; /**< Color used as light bevel edge */
|
||||
nxgl_mxpixel_t shadowEdge; /**< Color used as dark bevel edge */
|
||||
nxgl_mxpixel_t highlight; /**< Color used as highlighted elements */
|
||||
nxgl_mxpixel_t disabledText; /**< Color used for text in a disabled widget */
|
||||
nxgl_mxpixel_t enabledText; /**< Color used for text in a enabled widget */
|
||||
nxgl_mxpixel_t selectedText; /**< Color used for text in a clicked widget */
|
||||
};
|
||||
|
||||
/**
|
||||
* Class providing the default colors and fonts for all widgets. This
|
||||
* information is copied into the widgets when they are constructed, so you
|
||||
* will need to change these values *before* creating any widgets if you
|
||||
* want those widgets to use the altered colors.
|
||||
*
|
||||
* If the font objects are set, NXWidgets will use them in preference to the
|
||||
* default system fonts.
|
||||
*/
|
||||
|
||||
class CWidgetStyle
|
||||
{
|
||||
public:
|
||||
CWidgetColors colors; /**< Default widget colors */
|
||||
CNxFont *font; /**< Default font */
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWIDGETSTYLE_HXX
|
||||
@@ -0,0 +1,127 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwindoweventhandler.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxWidget;
|
||||
|
||||
/**
|
||||
* Base CWindowEventHandler class, intended to be subclassed. Any class that
|
||||
* needs to listen for window events should inherit from this class.
|
||||
*/
|
||||
|
||||
class CWindowEventHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
||||
inline CWindowEventHandler() { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CWindowEventHandler() { }
|
||||
|
||||
/**
|
||||
* Handle a NX window redraw request event
|
||||
*
|
||||
* @param nxRect The region in the window to be redrawn
|
||||
* @param more More redraw requests will follow
|
||||
*/
|
||||
|
||||
virtual void handleRedrawEvent(FAR const nxgl_rect_s *nxRect, bool more)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a NX window position/size change event
|
||||
*/
|
||||
|
||||
virtual void handleGeometryEvent(void) { }
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*/
|
||||
|
||||
virtual void handleMouseEvent(FAR const struct nxgl_point_s *pos,
|
||||
uint8_t buttons)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
virtual void handleKeyboardEvent(void) { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window blocked event
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
virtual void handleBlockedEvent(FAR void *arg) { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLER_HXX
|
||||
@@ -0,0 +1,180 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/cwindoweventhandlerlist.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLERLIST_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLERLIST_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cwindoweventhandler.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CListDataItem;
|
||||
|
||||
/**
|
||||
* List of window event handlers.
|
||||
*/
|
||||
class CWindowEventHandlerList
|
||||
{
|
||||
protected:
|
||||
TNxArray<CWindowEventHandler*> m_eventHandlers; /**< List of event handlers */
|
||||
|
||||
/**
|
||||
* Return the index to the window event handler.
|
||||
*/
|
||||
|
||||
bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param widget The owning widget.
|
||||
*/
|
||||
|
||||
CWindowEventHandlerList(void) { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~CWindowEventHandlerList(void) { }
|
||||
|
||||
/**
|
||||
* Get the event handler at the specified index.
|
||||
*
|
||||
* @param index The index of the event handler.
|
||||
* @return The event handler at the specified index.
|
||||
*/
|
||||
|
||||
inline CWindowEventHandler *at(const int index) const
|
||||
{
|
||||
return m_eventHandlers.at(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the array.
|
||||
*
|
||||
* @return The size of the array.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t size(void) const
|
||||
{
|
||||
return m_eventHandlers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a window event handler. The event handler will receive
|
||||
* all events raised by this object.
|
||||
* @param eventHandler A pointer to the event handler.
|
||||
*/
|
||||
|
||||
void addWindowEventHandler(CWindowEventHandler *eventHandler);
|
||||
|
||||
/**
|
||||
* Remove a window event handler.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler to remove.
|
||||
*/
|
||||
|
||||
void removeWindowEventHandler(CWindowEventHandler *eventHandler);
|
||||
|
||||
/**
|
||||
* Raise the NX window redraw event.
|
||||
*
|
||||
* @param nxRect The region in the window to be redrawn
|
||||
* @param more More redraw requests will follow
|
||||
*/
|
||||
|
||||
void raiseRedrawEvent(FAR const nxgl_rect_s *nxRect, bool more);
|
||||
|
||||
/**
|
||||
* Raise an NX window position/size change event.
|
||||
*/
|
||||
|
||||
void raiseGeometryEvent(void);
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
* Raise an NX mouse window input event.
|
||||
*/
|
||||
|
||||
void raiseMouseEvent(FAR const struct nxgl_point_s *pos,
|
||||
uint8_t buttons);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* Raise an NX keyboard input event
|
||||
*/
|
||||
|
||||
void raiseKeyboardEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Raise an NX window blocked event.
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
void raiseBlockedEvent(FAR void *arg);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_CWINDOWEVENTHANDLERLIST_HXX
|
||||
184
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ibitmap.hxx
Normal file
184
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ibitmap.hxx
Normal file
@@ -0,0 +1,184 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ibitmap.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_IBITMAP_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_IBITMAP_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Abstract class defining the basic properties of a source bitmap. The
|
||||
* primary intent of this class is two support a variety of sources of
|
||||
* bitmap data with various kinds of compression.
|
||||
*/
|
||||
|
||||
class IBitmap
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the IBitmap
|
||||
* destructor. We do this because if we delete IBitmap, we want the
|
||||
* destructor of the class that inherits from IBitmap to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~IBitmap(void) { }
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's color format.
|
||||
*/
|
||||
|
||||
virtual const uint8_t getColorFormat(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the bitmap's color format.
|
||||
*
|
||||
* @return The bitmap's color format.
|
||||
*/
|
||||
|
||||
virtual const uint8_t getBitsPerPixel(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in pixels/columns).
|
||||
*
|
||||
* @return The bitmap's width (in pixels/columns).
|
||||
*/
|
||||
|
||||
virtual const nxgl_coord_t getWidth(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the bitmap's height (in rows).
|
||||
*
|
||||
* @return The bitmap's height (in rows).
|
||||
*/
|
||||
|
||||
virtual const nxgl_coord_t getHeight(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the bitmap's width (in bytes).
|
||||
*
|
||||
* @return The bitmap's width.
|
||||
*/
|
||||
|
||||
virtual const size_t getStride(void) const = 0;
|
||||
|
||||
/**
|
||||
* Use the colors associated with a selected image.
|
||||
*
|
||||
* @param selected. true: Use colors for a selected widget,
|
||||
* false: Use normal (default) colors.
|
||||
*/
|
||||
|
||||
virtual void setSelected(bool selected) = 0;
|
||||
|
||||
/**
|
||||
* Get one row from the bit map image using the selected colors.
|
||||
*
|
||||
* @param x The offset into the row to get
|
||||
* @param y The row number to get
|
||||
* @param width The number of pixels to get from the row
|
||||
* @param data The memory location provided by the caller
|
||||
* in which to return the data. This should be at least
|
||||
* (getWidth()*getBitsPerPixl() + 7)/8 bytes in length
|
||||
* and properly aligned for the pixel color format.
|
||||
* @param True if the run was returned successfully.
|
||||
*/
|
||||
|
||||
virtual bool getRun(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width,
|
||||
FAR void *data) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_IBITMAP_HXX
|
||||
280
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ilistbox.hxx
Normal file
280
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/ilistbox.hxx
Normal file
@@ -0,0 +1,280 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ilistbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ILISTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ILISTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/clistboxdataitem.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Defines the interface for ListBox classes.
|
||||
*/
|
||||
|
||||
class IListBox
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the IListBox
|
||||
* destructor. We do this because if we delete IListBox, we want the
|
||||
* destructor of the class that inherits from IListBox to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~IListBox(void) { }
|
||||
|
||||
/**
|
||||
* Add a new option to the widget using default colors.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
*/
|
||||
|
||||
virtual void addOption(const CNxString &text, const uint32_t value) = 0;
|
||||
|
||||
/**
|
||||
* Add an option to the widget.
|
||||
*
|
||||
* @param option The option to add.
|
||||
*/
|
||||
|
||||
virtual void addOption(CListBoxDataItem *option) = 0;
|
||||
|
||||
/**
|
||||
* Remove an option from the widget by its index.
|
||||
*
|
||||
* @param index The index of the option to remove.
|
||||
*/
|
||||
|
||||
virtual void removeOption(const int index) = 0;
|
||||
|
||||
/**
|
||||
* Remove all options from the widget.
|
||||
*/
|
||||
|
||||
virtual void removeAllOptions(void) = 0;
|
||||
|
||||
/**
|
||||
* Add a new option to the widget.
|
||||
*
|
||||
* @param text Text to show in the option.
|
||||
* @param value The value of the option.
|
||||
* @param normalTextColor Color to draw the text with when not selected.
|
||||
* @param normalBackColor Color to draw the background with when not selected.
|
||||
* @param selectedTextColor Color to draw the text with when selected.
|
||||
* @param selectedBackColor Color to draw the background with when selected.
|
||||
*/
|
||||
|
||||
virtual void addOption(const CNxString &text, const uint32_t value,
|
||||
const nxwidget_pixel_t normalTextColor,
|
||||
const nxwidget_pixel_t normalBackColor,
|
||||
const nxwidget_pixel_t selectedTextColor,
|
||||
const nxwidget_pixel_t selectedBackColor) = 0;
|
||||
|
||||
/**
|
||||
* Select an option by its index.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual void selectOption(const int index) = 0;
|
||||
|
||||
/**
|
||||
* Select an option by its index.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The index of the option to select.
|
||||
*/
|
||||
|
||||
virtual void deselectOption(const int index) = 0;
|
||||
|
||||
/**
|
||||
* Select all options. Does nothing if the listbox does not allow
|
||||
* multiple selections. Redraws the widget and raises a value
|
||||
* changed event.
|
||||
*/
|
||||
|
||||
virtual void selectAllOptions(void) = 0;
|
||||
|
||||
/**
|
||||
* Deselect all options.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*/
|
||||
|
||||
virtual void deselectAllOptions(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the selected index. Returns -1 if nothing is selected. If more than one
|
||||
* option is selected, the index of the first selected option is returned.
|
||||
*
|
||||
* @return The selected index.
|
||||
*/
|
||||
|
||||
virtual const int getSelectedIndex(void) const = 0;
|
||||
|
||||
/**
|
||||
* Sets the selected index. Specify -1 to select nothing. Resets any
|
||||
* other selected options to deselected.
|
||||
* Redraws the widget and raises a value changed event.
|
||||
*
|
||||
* @param index The selected index.
|
||||
*/
|
||||
|
||||
virtual void setSelectedIndex(const int index) = 0;
|
||||
|
||||
/**
|
||||
* Get the selected option. Returns NULL if nothing is selected.
|
||||
*
|
||||
* @return The selected option.
|
||||
*/
|
||||
|
||||
virtual const CListBoxDataItem *getSelectedOption(void) const = 0;
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @param allowMultipleSelections True to allow multiple selections.
|
||||
*/
|
||||
|
||||
virtual void setAllowMultipleSelections(const bool allowMultipleSelections) = 0;
|
||||
|
||||
/**
|
||||
* Sets whether multiple selections are possible or not.
|
||||
*
|
||||
* @return True if multiple selections are allowed.
|
||||
*/
|
||||
|
||||
virtual const bool allowsMultipleSelections(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the specified option.
|
||||
*
|
||||
* @return The specified option.
|
||||
*/
|
||||
|
||||
virtual const CListBoxDataItem *getOption(const int index) = 0;
|
||||
|
||||
/**
|
||||
* Sort the options alphabetically by the text of the options.
|
||||
*/
|
||||
|
||||
virtual void sort(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the total number of options.
|
||||
*
|
||||
* @return The number of options.
|
||||
*/
|
||||
|
||||
virtual const int getOptionCount(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the height of a single option.
|
||||
*
|
||||
* @return The height of an option.
|
||||
*/
|
||||
|
||||
virtual const nxgl_coord_t getOptionHeight(void) const = 0;
|
||||
|
||||
/**
|
||||
* Sets whether or not items added to the list are automatically sorted on insert or not.
|
||||
*
|
||||
* @param sortInsertedItems True to enable sort on insertion.
|
||||
*/
|
||||
|
||||
virtual void setSortInsertedItems(const bool sortInsertedItems) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ILISTBOX_HXX
|
||||
@@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/ilistdataeventhandler.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ILISTDATAEVENTHANDLERR_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ILISTDATAEVENTHANDLERR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/clistdataeventargs.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class ListData;
|
||||
|
||||
/**
|
||||
* Base IListDataEventHandler class, intended to be subclassed. Any class
|
||||
* that needs to listen for CListData events should inherit from this class.
|
||||
*/
|
||||
|
||||
class IListDataEventHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the IListDataEventHandler
|
||||
* destructor. We do this because if we delete IListDataEventHandler, we want the
|
||||
* destructor of the class that inherits from IListDataEventHandler to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~IListDataEventHandler(void) { }
|
||||
|
||||
/**
|
||||
* Handle data changes.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void handleListDataChangedEvent(const CListDataEventArgs &e) = 0;
|
||||
|
||||
/**
|
||||
* Handle data changes.
|
||||
*
|
||||
* @param e Event arguments.
|
||||
*/
|
||||
|
||||
virtual void
|
||||
handleListDataSelectionChangedEvent(const CListDataEventArgs &e) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ILISTDATAEVENTHANDLERR_HXX
|
||||
361
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/inxwindow.hxx
Normal file
361
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/inxwindow.hxx
Normal file
@@ -0,0 +1,361 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/inxwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2015, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_INXWINDOW_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_INXWINDOW_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
# include <nuttx/nx/nxterm.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pure Virtual Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
struct SBitmap;
|
||||
class CWidgetControl;
|
||||
|
||||
/**
|
||||
* This class defines common operations on a any NX window.
|
||||
* There are three instances that represent an NX window from the
|
||||
* perspective of NXWidgets.
|
||||
*
|
||||
* - There is one widget control instance per NX window,
|
||||
* - One CCallback instance per window,
|
||||
* - One window instance.
|
||||
*
|
||||
* There a various kinds of of window instances, but each inherits
|
||||
* (1) CCallback and dispatches the Windows callbacks and (2) INxWindow
|
||||
* that describes the common window behavior.
|
||||
*/
|
||||
|
||||
class INxWindow
|
||||
{
|
||||
public:
|
||||
enum ELineCaps
|
||||
{
|
||||
LINECAP_NONE = NX_LINECAP_NONE, // No line caps
|
||||
LINECAP_PT1 = NX_LINECAP_PT1, // Line cap on pt1 of the vector only
|
||||
LINECAP_PT2 = NX_LINECAP_PT2, // Line cap on pt2 of the vector only
|
||||
LINECAP_BOTH = NX_LINECAP_BOTH // Line cap on both ends of the vector only
|
||||
};
|
||||
|
||||
/**
|
||||
* A virtual destructor is required in order to override the INxWindow
|
||||
* destructor. We do this because if we delete INxWindow, we want the
|
||||
* destructor of the class that inherits from INxWindow to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~INxWindow(void) { }
|
||||
|
||||
/**
|
||||
* Creates a new window. Window creation is separate from
|
||||
* object instantiation so that window creation failures can
|
||||
* be properly reported.
|
||||
*
|
||||
* @return True if the window was successfully created.
|
||||
*/
|
||||
|
||||
virtual bool open(void) = 0;
|
||||
|
||||
/**
|
||||
* Each implementation of INxWindow must provide a method to recover
|
||||
* the contained CWidgetControl instance.
|
||||
*
|
||||
* @return The contained CWidgetControl instance
|
||||
*/
|
||||
|
||||
virtual CWidgetControl *getWidgetControl(void) const = 0;
|
||||
|
||||
/**
|
||||
* Synchronize the window with the NX server. This function will delay
|
||||
* until the the NX server has caught up with all of the queued requests.
|
||||
* When this function returns, the state of the NX server will be the
|
||||
* same as the state of application.
|
||||
*/
|
||||
|
||||
virtual void synchronize(void) = 0;
|
||||
|
||||
/**
|
||||
* Request the position and size information of the window. The values
|
||||
* will be returned asynchronously through the client callback method.
|
||||
* The GetPosition() method may than be called to obtain the positional
|
||||
* data as provided by the callback.
|
||||
*
|
||||
* @return OK on success; ERROR on failure with errno set appropriately.
|
||||
*/
|
||||
|
||||
virtual bool requestPosition(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the position of the window (as reported by the NX callback).
|
||||
*
|
||||
* @return The position.
|
||||
*/
|
||||
|
||||
virtual bool getPosition(FAR struct nxgl_point_s *pPos) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the window (as reported by the NX callback).
|
||||
*
|
||||
* @param pSize The location to return window size.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool getSize(FAR struct nxgl_size_s *pSize) = 0;
|
||||
|
||||
/**
|
||||
* Set the position and size of the window.
|
||||
*
|
||||
* @param pPos The new position of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool setPosition(FAR const struct nxgl_point_s *pPos) = 0;
|
||||
|
||||
/**
|
||||
* Set the size of the selected window.
|
||||
*
|
||||
* @param pSize The new size of the window.
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool setSize(FAR const struct nxgl_size_s *pSize) = 0;
|
||||
|
||||
/**
|
||||
* Bring the window to the top of the display.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool raise(void) = 0;
|
||||
|
||||
/**
|
||||
* Lower the window to the bottom of the display.
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool lower(void) = 0;
|
||||
|
||||
/**
|
||||
* Return true if the window is currently being displayed
|
||||
*
|
||||
* @return True if the window is visible
|
||||
*/
|
||||
|
||||
virtual bool isVisible(void) = 0;
|
||||
|
||||
/**
|
||||
* Show a hidden window
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool show(void) = 0;
|
||||
|
||||
/**
|
||||
* Hide a visible window
|
||||
*
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool hide(void) = 0;
|
||||
|
||||
/**
|
||||
* May be used to either (1) raise a window to the top of the display and
|
||||
* select modal behavior, or (2) disable modal behavior.
|
||||
*
|
||||
* @param enable True: enter modal state; False: leave modal state
|
||||
* @return True on success, false on any failure.
|
||||
*/
|
||||
|
||||
virtual bool modal(bool enable) = 0;
|
||||
|
||||
#ifdef CONFIG_NXTERM_NXKBDIN
|
||||
/**
|
||||
* Each window implementation also inherits from CCallback. CCallback,
|
||||
* by default, forwards NX keyboard input to the various widgets residing
|
||||
* in the window. But NxTerm is a different usage model; In this case,
|
||||
* keyboard input needs to be directed to the NxTerm character driver.
|
||||
* This method can be used to enable (or disable) redirection of NX
|
||||
* keyboard input from the window widgets to the NxTerm
|
||||
*
|
||||
* @param handle. The NXTERM handle. If non-NULL, NX keyboard
|
||||
* input will be directed to the NxTerm driver using this
|
||||
* handle; If NULL (the default), NX keyboard input will be
|
||||
* directed to the widgets within the window.
|
||||
*/
|
||||
|
||||
virtual void redirectNxTerm(NXTERM handle) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set an individual pixel in the window with the specified color.
|
||||
*
|
||||
* @param pPos The location of the pixel to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
virtual bool setPixel(FAR const struct nxgl_point_s *pPos,
|
||||
nxgl_mxpixel_t color) = 0;
|
||||
|
||||
/**
|
||||
* Fill the specified rectangle in the window with the specified color.
|
||||
*
|
||||
* @param pRect The location to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
virtual bool fill(FAR const struct nxgl_rect_s *pRect,
|
||||
nxgl_mxpixel_t color) = 0;
|
||||
|
||||
/**
|
||||
* Get the raw contents of graphic memory within a rectangular region. NOTE:
|
||||
* Since raw graphic memory is returned, the returned memory content may be
|
||||
* the memory of windows above this one and may not necessarily belong to
|
||||
* this window unless you assure that this is the top window.
|
||||
*
|
||||
* @param rect The location to be copied
|
||||
* @param dest - The describes the destination bitmap to receive the
|
||||
* graphics data.
|
||||
*/
|
||||
|
||||
virtual void getRectangle(FAR const struct nxgl_rect_s *rect,
|
||||
struct SBitmap *dest) = 0;
|
||||
|
||||
/**
|
||||
* Fill the specified trapezoidal region in the window with the specified
|
||||
* color.
|
||||
*
|
||||
* @param pClip Clipping rectangle relative to window (may be null).
|
||||
* @param pTrap The trapezoidal region to be filled.
|
||||
* @param color The color to use in the fill.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
virtual bool fillTrapezoid(FAR const struct nxgl_rect_s *pClip,
|
||||
FAR const struct nxgl_trapezoid_s *pTrap,
|
||||
nxgl_mxpixel_t color) = 0;
|
||||
|
||||
/**
|
||||
* Fill the specified line in the window with the specified color.
|
||||
*
|
||||
* @param vector - Describes the line to be drawn
|
||||
* @param width - The width of the line
|
||||
* @param color - The color to use to fill the line
|
||||
* @param caps - Draw a circular cap on the ends of the line to support
|
||||
* better line joins
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
virtual bool drawLine(FAR struct nxgl_vector_s *vector,
|
||||
nxgl_coord_t width, nxgl_mxpixel_t color,
|
||||
enum ELineCaps caps) = 0;
|
||||
|
||||
/**
|
||||
* Draw a filled circle at the specified position, size, and color.
|
||||
*
|
||||
* @param center The window-relative coordinates of the circle center.
|
||||
* @param radius The radius of the rectangle in pixels.
|
||||
* @param color The color of the rectangle.
|
||||
*/
|
||||
|
||||
virtual bool drawFilledCircle(struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
nxgl_mxpixel_t color) = 0;
|
||||
|
||||
/**
|
||||
* Move a rectangular region within the window.
|
||||
*
|
||||
* @param pRect Describes the rectangular region to move.
|
||||
* @param pOffset The offset to move the region.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
virtual bool move(FAR const struct nxgl_rect_s *pRect,
|
||||
FAR const struct nxgl_point_s *pOffset) = 0;
|
||||
|
||||
/**
|
||||
* Copy a rectangular region of a larger image into the rectangle in the
|
||||
* specified window. The source image is treated as an opaque image.
|
||||
*
|
||||
* @param pDest Describes the rectangular on the display that will receive
|
||||
* the bitmap.
|
||||
* @param pSrc The start of the source image.
|
||||
* @param pOrigin the pOrigin of the upper, left-most corner of the full
|
||||
* bitmap. Both pDest and pOrigin are in window coordinates, however,
|
||||
* pOrigin may lie outside of the display.
|
||||
* @param stride The width of the full source image in bytes.
|
||||
*
|
||||
* @return True on success; false on failure.
|
||||
*/
|
||||
|
||||
virtual bool bitmap(FAR const struct nxgl_rect_s *pDest,
|
||||
FAR const void *pSrc,
|
||||
FAR const struct nxgl_point_s *pOrigin,
|
||||
unsigned int stride) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_INXWINDOW_HXX
|
||||
216
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/iscrollable.hxx
Normal file
216
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/iscrollable.hxx
Normal file
@@ -0,0 +1,216 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/iscrollable.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ISCROLLABLE_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ISCROLLABLE_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Abstract class defining basic functionality of scrolling widgets.
|
||||
* Scrolling regions are modelled as a virtual "canvas", or rectangular
|
||||
* region, with height/width dimensions and x/y coordinates.
|
||||
*/
|
||||
|
||||
class IScrollable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the IScrollable
|
||||
* destructor. We do this because if we delete IScrollable, we want the
|
||||
* destructor of the class that inherits from IScrollable to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~IScrollable(void) { }
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The x coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasX(void) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the virtual canvas.
|
||||
*
|
||||
* @return The y coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasY(void) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the width of the virtual canvas.
|
||||
*
|
||||
* @return The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasWidth(void) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the height of the virtual canvas.
|
||||
*
|
||||
* @return The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual const int32_t getCanvasHeight(void) const = 0;
|
||||
|
||||
/**
|
||||
* Scrolls the virtual canvas by the specified amounts.
|
||||
*
|
||||
* @param dx Distance to scroll horizontally.
|
||||
* @param dy Distance to scroll vertically.
|
||||
*/
|
||||
|
||||
virtual void scroll(int32_t dx, int32_t dy) = 0;
|
||||
|
||||
/**
|
||||
* Repositions the virtual canvas to the specified coordinates.
|
||||
*
|
||||
* @param x New x coordinate of the virtual canvas.
|
||||
* @param y New y coordinate of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void jump(int32_t x, int32_t y) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if vertical scrolling is allowed.
|
||||
*
|
||||
* @return True if vertical scrolling is allowed.
|
||||
*/
|
||||
|
||||
virtual bool allowsVerticalScroll(void) const = 0;
|
||||
|
||||
/**
|
||||
* Returns true if horizontal scrolling is allowed.
|
||||
*
|
||||
* @return True if horizontal scrolling is allowed.
|
||||
*/
|
||||
|
||||
virtual bool allowsHorizontalScroll(void) const = 0;
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
virtual void setAllowsVerticalScroll(bool allow) = 0;
|
||||
|
||||
/**
|
||||
* Set whether or not horizontal scrolling is allowed.
|
||||
*
|
||||
* @param allow True to allow horizontal scrolling; false to deny it.
|
||||
*/
|
||||
|
||||
virtual void setAllowsHorizontalScroll(bool allow) = 0;
|
||||
|
||||
/**
|
||||
* Sets the width of the virtual canvas.
|
||||
*
|
||||
* @param width The width of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void setCanvasWidth(const int32_t width) = 0;
|
||||
|
||||
/**
|
||||
* Sets the height of the virtual canvas.
|
||||
*
|
||||
* @param height The height of the virtual canvas.
|
||||
*/
|
||||
|
||||
virtual void setCanvasHeight(const int32_t height) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ISCROLLABLE_HXX
|
||||
195
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/islider.hxx
Normal file
195
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/islider.hxx
Normal file
@@ -0,0 +1,195 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/islider.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ISLIDER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ISLIDER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Defines the interface for slider widgets.
|
||||
*/
|
||||
class ISlider
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the ISlider
|
||||
* destructor. We do this because if we delete ISlider, we want the
|
||||
* destructor of the class that inherits from ISlider to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~ISlider(void) { }
|
||||
|
||||
/**
|
||||
* Get the smallest value that the slider can represent.
|
||||
*
|
||||
* @return The smallest value.
|
||||
*/
|
||||
|
||||
virtual const int getMinimumValue(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the largest value that the slider can represent.
|
||||
*
|
||||
* @return The largest value.
|
||||
*/
|
||||
|
||||
virtual const int getMaximumValue(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the current value of the slider.
|
||||
*
|
||||
* return The current slider value.
|
||||
*/
|
||||
|
||||
virtual const int getValue(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the value represented by the height of the grip.
|
||||
* For sliders, this would typically be 1 (so each new
|
||||
* grip position is worth 1). For scrollbars, this
|
||||
* would be the height of the scrolling widget.
|
||||
*
|
||||
* @return The page size.
|
||||
*/
|
||||
|
||||
virtual const nxgl_coord_t getPageSize(void) const = 0;
|
||||
|
||||
/**
|
||||
* Set the smallest value that the slider can represent.
|
||||
*
|
||||
* @param value The smallest value.
|
||||
*/
|
||||
|
||||
virtual void setMinimumValue(const int value) = 0;
|
||||
|
||||
/**
|
||||
* Set the largest value that the slider can represent.
|
||||
*
|
||||
* @param value The largest value.
|
||||
*/
|
||||
|
||||
virtual void setMaximumValue(const int value) = 0;
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition
|
||||
* and redraw the grip.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
virtual void setValue(const int value) = 0;
|
||||
|
||||
/**
|
||||
* Set the value that of the slider. This will reposition and redraw
|
||||
* the grip. The supplied value should be bitshifted left 16 places.
|
||||
* This ensures greater accuracy than the standard setValue() method if
|
||||
* the slider is being used as a scrollbar.
|
||||
*
|
||||
* @param value The new value.
|
||||
*/
|
||||
|
||||
virtual void setValueWithBitshift(const int32_t value) = 0;
|
||||
|
||||
/**
|
||||
* Set the page size represented by the grip.
|
||||
*
|
||||
* @param pageSize The page size.
|
||||
* @see getPageSize().
|
||||
*/
|
||||
|
||||
virtual void setPageSize(const nxgl_coord_t pageSize) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ISLIDER_HXX
|
||||
217
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/itextbox.hxx
Normal file
217
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/itextbox.hxx
Normal file
@@ -0,0 +1,217 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/itextbox.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ITEXTBOX_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ITEXTBOX_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Cursor display options.
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SHOW_CURSOR_ONFOCUS = 0, /**< Show the cursor only if the widget has focus */
|
||||
SHOW_CURSOR_NEVER, /**< The cursor is never displayed */
|
||||
SHOW_CURSOR_ALWAYS /**< Always show the cursor */
|
||||
} EShowCursor;
|
||||
|
||||
/**
|
||||
* Defines the interface that textbox-like classes should implement.
|
||||
*/
|
||||
|
||||
class ITextBox
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the ITextBox
|
||||
* destructor. We do this because if we delete ITextBox, we want the
|
||||
* destructor of the class that inherits from ITextBox to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~ITextBox(void) { }
|
||||
|
||||
/**
|
||||
* Sets the cursor display mode.
|
||||
*
|
||||
*@param cursorMode Determines cursor display mode
|
||||
*/
|
||||
|
||||
virtual void showCursor(EShowCursor cursorMode) = 0;
|
||||
|
||||
/**
|
||||
* Enables/disables cursor wrapping
|
||||
*
|
||||
* @param wrap True enables cursor wrapping
|
||||
*/
|
||||
|
||||
virtual void wrapCursor(bool wrap) = 0;
|
||||
|
||||
/**
|
||||
* Set the text displayed in the label.
|
||||
*
|
||||
* @param text String to display.
|
||||
*/
|
||||
|
||||
virtual void setText(const CNxString &text) = 0;
|
||||
|
||||
/**
|
||||
* Append new text to the end of the current text displayed in the
|
||||
* label.
|
||||
*
|
||||
* @param text String to append.
|
||||
*/
|
||||
|
||||
virtual void appendText(const CNxString &text) = 0;
|
||||
|
||||
/**
|
||||
* Remove all characters from the string from the start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex) = 0;
|
||||
|
||||
/**
|
||||
* Remove specified number of characters from the string from the
|
||||
* start index onwards.
|
||||
*
|
||||
* @param startIndex Index to remove from.
|
||||
* @param count Number of characters to remove.
|
||||
*/
|
||||
|
||||
virtual void removeText(const unsigned int startIndex, const unsigned int count) = 0;
|
||||
|
||||
/**
|
||||
* Insert text at the specified index.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
* @param index Index at which to insert the text.
|
||||
*/
|
||||
|
||||
virtual void insertText(const CNxString &text, const unsigned int index) = 0;
|
||||
|
||||
/**
|
||||
* Insert text at the current cursor position.
|
||||
*
|
||||
* @param text The text to insert.
|
||||
*/
|
||||
|
||||
virtual void insertTextAtCursor(const CNxString &text) = 0;
|
||||
|
||||
/**
|
||||
* Move the cursor to the text position specified. 0 indicates the
|
||||
* start of the string. If position is greater than the length of the
|
||||
* string, the cursor is moved to the end of the string.
|
||||
*
|
||||
* @param position The new cursor position.
|
||||
*/
|
||||
|
||||
virtual void moveCursorToPosition(const int position) = 0;
|
||||
|
||||
/**
|
||||
* Get the cursor position. This is the index within the string that
|
||||
* the cursor is currently positioned over.
|
||||
* @return position The cursor position.
|
||||
*/
|
||||
|
||||
virtual const int getCursorPosition(void) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_ITEXTBOX_HXX
|
||||
466
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/nxconfig.hxx
Normal file
466
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/nxconfig.hxx
Normal file
@@ -0,0 +1,466 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/nxconfig.hxx
|
||||
*
|
||||
* Copyright (C) 2012-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_NXCONFIG_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_NXCONFIG_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/video/rgbcolors.h>
|
||||
#include <nuttx/nx/nxfonts.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* NX Configuration *********************************************************/
|
||||
/**
|
||||
* Prerequisites:
|
||||
*
|
||||
* CONFIG_HAVE_CXX=y : C++ support is required
|
||||
* CONFIG_NX=y : NX graphics support must be enabled
|
||||
* CONFIG_NX_XYINPUT=y : Required to enable NX mouse/touchscreen support
|
||||
* CONFIG_NX_KBD=y : Required to enabled NX keyboard support
|
||||
* CONFIG_NX_NPLANES=1 : Only a single video plane is supported
|
||||
*
|
||||
* NX Server/Device Configuration
|
||||
*
|
||||
* CONFIG_NXSTART_SERVERPRIO - Priority of the NX server.
|
||||
* Default: (SCHED_PRIORITY_DEFAULT+10). NOTE: Of the three priority
|
||||
* definitions here, CONFIG_NXSTART_SERVERPRIO should have the highest
|
||||
* priority to avoid data overrun race conditions. Such errors would most
|
||||
* likely appear as duplicated rows of data on the display.
|
||||
* CONFIG_NXWIDGETS_CLIENTPRIO - The thread that calls CNxServer::connect()
|
||||
* will be re-prioritized to this priority. Default:
|
||||
* SCHED_PRIORITY_DEFAULT
|
||||
* CONFIG_NXWIDGETS_LISTENERPRIO - Priority of the NX event listener thread.
|
||||
* Default: SCHED_PRIORITY_DEFAULT
|
||||
* CONFIG_NXWIDGETS_LISTENERSTACK - NX listener thread stack size (in multi-user
|
||||
* mode). Default 2048
|
||||
* CONFIG_NXWIDGET_EVENTWAIT - Build in support for external window event, modal
|
||||
* loop management logic. This includes methods to wait for windows events
|
||||
* to occur so that looping logic can sleep until something interesting
|
||||
* happens with the window.
|
||||
*
|
||||
* NXWidget Configuration
|
||||
*
|
||||
* CONFIG_NXWIDGETS_BPP - Supported bits-per-pixel {8, 16, 24, 32}. Default:
|
||||
* The smallest BPP configuration supported by NX.
|
||||
* CONFIG_NXWIDGETS_SIZEOFCHAR - Size of character {1 or 2 bytes}. Default
|
||||
* Determined by CONFIG_NXWIDGETS_SIZEOFCHAR
|
||||
*
|
||||
* NXWidget Default Values
|
||||
*
|
||||
* CONFIG_NXWIDGETS_DEFAULT_FONTID - Default font ID. Default: NXFONT_DEFAULT
|
||||
* CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE, CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT -
|
||||
* Default dynamic array parameters. Default: 16, 8
|
||||
*
|
||||
* CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR - Normal background color. Default:
|
||||
* MKRGB(148,189,215)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR - Default selected background
|
||||
* color. Default: MKRGB(206,227,241)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR - Shiny side boarder color. Default
|
||||
* MKRGB(248,248,248)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR - Shadowed side border color.
|
||||
* Default: MKRGB(35,58,73)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR - Highlight color. Default:
|
||||
* MKRGB(192,192,192)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR - Text color on a disabled widget:
|
||||
* Default: MKRGB(192,192,192)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR - Text color on a enabled widget:
|
||||
* Default: MKRGB(248,248,248)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR - Text color on a selected widget:
|
||||
* Default: MKRGB(0,0,0)
|
||||
* CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR - Default font color: Default:
|
||||
* MKRGB(255,255,255)
|
||||
* CONFIG_NXWIDGETS_TRANSPARENT_COLOR - Transparent color: Default: MKRGB(0,0,0)
|
||||
*
|
||||
* Keypad behavior
|
||||
*
|
||||
* CONFIG_NXWIDGETS_FIRST_REPEAT_TIME - Time taken before a key starts
|
||||
* repeating (in milliseconds). Default: 500
|
||||
* CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME - Time taken before a repeating key
|
||||
* repeats again (in milliseconds). Default: 200
|
||||
* CONFIG_NXWIDGETS_DOUBLECLICK_TIME - Left button release-press time for
|
||||
* double click (in milliseconds). Default: 350
|
||||
* CONFIG_NXWIDGETS_KBDBUFFER_SIZE - Size of incoming character buffer, i.e.,
|
||||
* the maximum number of characters that can be entered between NX polling
|
||||
* cycles without losing data.
|
||||
* CONFIG_NXWIDGETS_CURSORCONTROL_SIZE - Size of incoming cursor control
|
||||
* buffer, i.e., the maximum number of cursor controls that can between
|
||||
* entered by NX polling cycles without losing data. Default: 4
|
||||
*/
|
||||
|
||||
/* Prerequisites ************************************************************/
|
||||
/**
|
||||
* C++ support is required
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_CXX
|
||||
# error "C++ support is required (CONFIG_HAVE_CXX)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* NX graphics support must be enabled
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NX
|
||||
# error "NX graphics support is required (CONFIG_NX)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Required to enable NX mouse/touchscreen support
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NX_XYINPUT
|
||||
# warning "NX mouse/touchscreen support is required (CONFIG_NX_XYINPUT)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Required to enabled NX keyboard support
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NX_KBD
|
||||
# warning "NX keyboard support is required (CONFIG_NX_KBD)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only a single video plane is supported
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NX_NPLANES
|
||||
# define CONFIG_NX_NPLANES 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_NX_NPLANES != 1
|
||||
# error "Only a single color plane is supported (CONFIG_NX_NPLANES)"
|
||||
#endif
|
||||
|
||||
/* NxTerm checks. This just simplifies the conditional compilation by
|
||||
* reducing the AND of these three conditions to a single condition.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_NX_KBD) || !defined(CONFIG_NXTERM)
|
||||
# undef CONFIG_NXTERM_NXKBDIN
|
||||
#endif
|
||||
|
||||
/* NX Server/Device Configuration *******************************************/
|
||||
/**
|
||||
* Priority of the NX server (in multi-user mode)
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_CLIENTPRIO
|
||||
# define CONFIG_NXWIDGETS_CLIENTPRIO SCHED_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO
|
||||
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_CLIENTPRIO"
|
||||
# warning" -- This can result in data overrun errors"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Priority of the NX event listener thread (in multi-user mode)
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_LISTENERPRIO
|
||||
# define CONFIG_NXWIDGETS_LISTENERPRIO SCHED_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#if CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO
|
||||
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_NXWIDGETS_LISTENERPRIO"
|
||||
# warning" -- This can result in data overrun errors"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* NX listener thread stack size (in multi-user mode)
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_LISTENERSTACK
|
||||
# define CONFIG_NXWIDGETS_LISTENERSTACK 2048
|
||||
#endif
|
||||
|
||||
/* NXWidget Configuration ***************************************************/
|
||||
/**
|
||||
* Bits per pixel
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_BPP
|
||||
# if !defined(CONFIG_NX_DISABLE_8BPP)
|
||||
# warning "Assuming 8-bits per pixel, RGB 3:3:2"
|
||||
# define CONFIG_NXWIDGETS_BPP 8
|
||||
# elif !defined(CONFIG_NX_DISABLE_16BPP)
|
||||
# warning "Assuming 16-bits per pixel, RGB 5:6:5"
|
||||
# define CONFIG_NXWIDGETS_BPP 16
|
||||
# elif !defined(CONFIG_NX_DISABLE_24BPP)
|
||||
# warning "Assuming 24-bits per pixel, RGB 8:8:8"
|
||||
# define CONFIG_NXWIDGETS_BPP 24
|
||||
# elif !defined(CONFIG_NX_DISABLE_32BPP)
|
||||
# warning "Assuming 32-bits per pixel, RGB 8:8:8"
|
||||
# define CONFIG_NXWIDGETS_BPP 32
|
||||
# else
|
||||
# error "No supported pixel depth is enabled"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_NXWIDGETS_BPP == 8
|
||||
# ifdef CONFIG_NX_DISABLE_8BPP
|
||||
# error "NX 8-bit support is disabled (CONFIG_NX_DISABLE_8BPP)"
|
||||
# endif
|
||||
# define CONFIG_NXWIDGETS_FMT FB_FMT_RGB8_332
|
||||
# define MKRGB RGBTO8
|
||||
# define RGB2RED RGB8RED
|
||||
# define RGB2GREEN RGB8GREEN
|
||||
# define RGB2BLUE RGB8BLUE
|
||||
# define FONT_RENDERER nxf_convert_8bpp
|
||||
#elif CONFIG_NXWIDGETS_BPP == 16
|
||||
# ifdef CONFIG_NX_DISABLE_16BPP
|
||||
# error "NX 16-bit support is disabled (CONFIG_NX_DISABLE_16BPP)"
|
||||
# endif
|
||||
# define CONFIG_NXWIDGETS_FMT FB_FMT_RGB16_565
|
||||
# define MKRGB RGBTO16
|
||||
# define RGB2RED RGB16RED
|
||||
# define RGB2GREEN RGB16GREEN
|
||||
# define RGB2BLUE RGB16BLUE
|
||||
# define FONT_RENDERER nxf_convert_16bpp
|
||||
#elif CONFIG_NXWIDGETS_BPP == 24
|
||||
# ifdef CONFIG_NX_DISABLE_24BPP
|
||||
# error "NX 24-bit support is disabled (CONFIG_NX_DISABLE_24BPP)"
|
||||
# endif
|
||||
# define CONFIG_NXWIDGETS_FMT FB_FMT_RGB24
|
||||
# define MKRGB RGBTO24
|
||||
# define RGB2RED RGB24RED
|
||||
# define RGB2GREEN RGB24GREEN
|
||||
# define RGB2BLUE RGB24BLUE
|
||||
# define FONT_RENDERER nxf_convert_24bpp
|
||||
#elif CONFIG_NXWIDGETS_BPP == 32
|
||||
# ifdef CONFIG_NX_DISABLE_32BPP
|
||||
# error "NX 32-bit support is disabled (CONFIG_NX_DISABLE_32BPP)"
|
||||
# endif
|
||||
# define CONFIG_NXWIDGETS_FMT FB_FMT_RGB32
|
||||
# define MKRGB RGBTO24
|
||||
# define RGB2RED RGB24RED
|
||||
# define RGB2GREEN RGB24GREEN
|
||||
# define RGB2BLUE RGB24BLUE
|
||||
# define FONT_RENDERER nxf_convert_32bpp
|
||||
#else
|
||||
# error "Pixel depth not supported (CONFIG_NXWIDGETS_BPP)"
|
||||
#endif
|
||||
|
||||
/* Size of a character */
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_SIZEOFCHAR
|
||||
# if CONFIG_NXFONTS_CHARBITS <= 8
|
||||
# define CONFIG_NXWIDGETS_SIZEOFCHAR 1
|
||||
# else
|
||||
# define CONFIG_NXWIDGETS_SIZEOFCHAR 2
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_NXWIDGETS_SIZEOFCHAR != 1 && CONFIG_NXWIDGETS_SIZEOFCHAR != 2
|
||||
# error "Unsupported character width (CONFIG_NXWIDGETS_SIZEOFCHAR)"
|
||||
#endif
|
||||
|
||||
/* NXWidget Default Values **************************************************/
|
||||
/**
|
||||
* Default font ID
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_FONTID
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_FONTID NXFONT_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default dynamic array parameters
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE
|
||||
# define CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE 16
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT
|
||||
# define CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Normal background color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR MKRGB(148,189,215)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default selected background color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_SELECTEDBACKGROUNDCOLOR MKRGB(206,227,241)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Shiny side border color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_SHINEEDGECOLOR MKRGB(248,248,248)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Shadowed side border color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_SHADOWEDGECOLOR MKRGB(35,58,73)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Highlight color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_HIGHLIGHTCOLOR MKRGB(192,192,192)
|
||||
#endif
|
||||
|
||||
/* Text colors */
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_DISABLEDTEXTCOLOR MKRGB(192,192,192)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_ENABLEDTEXTCOLOR MKRGB(248,248,248)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_SELECTEDTEXTCOLOR MKRGB(0,0,0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default font color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
|
||||
# define CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR MKRGB(255,255,255)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Transparent color
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_TRANSPARENT_COLOR
|
||||
# define CONFIG_NXWIDGETS_TRANSPARENT_COLOR MKRGB(0,0,0)
|
||||
#endif
|
||||
|
||||
/* Keypad behavior **********************************************************/
|
||||
/**
|
||||
* Time taken before a key starts repeating (in milliseconds).
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_FIRST_REPEAT_TIME
|
||||
# define CONFIG_NXWIDGETS_FIRST_REPEAT_TIME 500
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Time taken before a repeating key repeats again (in milliseconds).
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME
|
||||
# define CONFIG_NXWIDGETS_CONTINUE_REPEAT_TIME 200
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Left button release-press time for double click (in milliseconds).
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_DOUBLECLICK_TIME
|
||||
# define CONFIG_NXWIDGETS_DOUBLECLICK_TIME 350
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Size of incoming character buffer, i.e., the maximum number of characters
|
||||
* that can be entered between NX polling cycles without losing data.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_KBDBUFFER_SIZE
|
||||
# define CONFIG_NXWIDGETS_KBDBUFFER_SIZE 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Size of incoming cursor control buffer, i.e., the maximum number of cursor
|
||||
* controls that can between entered by NX polling cycles without losing data.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWIDGETS_CURSORCONTROL_SIZE
|
||||
# define CONFIG_NXWIDGETS_CURSORCONTROL_SIZE 4
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
#if CONFIG_NXWIDGETS_BPP == 8
|
||||
typedef uint8_t nxwidget_pixel_t;
|
||||
#elif CONFIG_NXWIDGETS_BPP == 16
|
||||
typedef uint16_t nxwidget_pixel_t;
|
||||
#elif CONFIG_NXWIDGETS_BPP == 24
|
||||
typedef uint32_t nxwidget_pixel_t;
|
||||
#elif CONFIG_NXWIDGETS_BPP == 32
|
||||
typedef uint32_t nxwidget_pixel_t;
|
||||
#else
|
||||
# error "Pixel depth is unknown"
|
||||
#endif
|
||||
|
||||
#if CONFIG_NXWIDGETS_SIZEOFCHAR == 2
|
||||
typedef uint16_t nxwidget_char_t;
|
||||
#elif CONFIG_NXWIDGETS_SIZEOFCHAR == 1
|
||||
typedef uint8_t nxwidget_char_t;
|
||||
#else
|
||||
# error "Character width is unknown"
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_NXCONFIG_HXX
|
||||
136
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/singletons.hxx
Normal file
136
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/singletons.hxx
Normal file
@@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/singletons.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_SINGLETONS_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_SINGLETONS_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxtimer.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Forward References
|
||||
*/
|
||||
|
||||
class CWidgetStyle;
|
||||
class CNxString;
|
||||
|
||||
/**
|
||||
* Global singleton instances
|
||||
*/
|
||||
|
||||
extern CWidgetStyle *g_defaultWidgetStyle; /**< The default widget style */
|
||||
extern CNxString *g_nullString; /**< The reusable empty string */
|
||||
extern TNxArray<CNxTimer*> *g_nxTimers; /**< An array of all timers */
|
||||
|
||||
/**
|
||||
* Setup misc singleton instances.
|
||||
*
|
||||
* Q: Why is there here?
|
||||
* A: Because it needs to be done one time before any widgets are created.
|
||||
* Q: So why isn't it just the default style just a statically constructed class?
|
||||
* A: Because not all platforms will support static class constructions.
|
||||
* Q: Why isn't it part of CNxServer?
|
||||
* A: Because the singletons may be needed before the server is started.
|
||||
*/
|
||||
|
||||
void instantiateSingletons(void);
|
||||
|
||||
/**
|
||||
* Free the singleton instances when the last NX server is destroyed.
|
||||
*
|
||||
* Q: Why is there here is it is only called as part of the CNxServer destructor?
|
||||
* A: Just for symmetry with instantiateSingletons().
|
||||
*/
|
||||
|
||||
void freeSingletons(void);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_SINGLETONS_HXX
|
||||
136
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/teventargs.hxx
Normal file
136
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/teventargs.hxx
Normal file
@@ -0,0 +1,136 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/teventargs.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_TEVENTARGS_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_TEVENTARGS_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
/**
|
||||
* Base template class for all events within the NxWidgets system.
|
||||
* All event types should inherit from this class.
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
class TEventArgs
|
||||
{
|
||||
private:
|
||||
T m_source; /**< The object that raised the event */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param source The object that raised the event.
|
||||
*/
|
||||
|
||||
inline TEventArgs(const T& source)
|
||||
{
|
||||
m_source = source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~TEventArgs() { }
|
||||
|
||||
/**
|
||||
* Get the source object that raised the event.
|
||||
*/
|
||||
|
||||
inline const T& getSource(void) const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_TEVENTARGS_HXX
|
||||
437
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/tnxarray.hxx
Normal file
437
Ubiquitous/Nuttx/apps/include/graphics/nxwidgets/tnxarray.hxx
Normal file
@@ -0,0 +1,437 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwidgets/tnxarray.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Portions of this package derive from Woopsi (http://woopsi.org/) and
|
||||
* portions are original efforts. It is difficult to determine at this
|
||||
* point what parts are original efforts and which parts derive from Woopsi.
|
||||
* However, in any event, the work of Antony Dzeryn will be acknowledged
|
||||
* in most NxWidget files. Thanks Antony!
|
||||
*
|
||||
* Copyright (c) 2007-2011, Antony Dzeryn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the names "Woopsi", "Simian Zombie" nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Antony Dzeryn ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Antony Dzeryn BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWIDGETS_TNXARRAY_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWIDGETS_TNXARRAY_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
/**
|
||||
* Class providing a dynamic array; that is, an array that will automatically
|
||||
* grow to accommodate new data. It provides a fast way to randomly access
|
||||
* a list of data. Essentially, it provides the most important functionality
|
||||
* of the STL vector class without any of the overhead of including an STL
|
||||
* class.
|
||||
*
|
||||
* If the data to be stored will store a lot of data that will predominantly
|
||||
* be read sequentially, consider using the LinkedList class instead. Resizing
|
||||
* the list is an expensive operation that will occur frequently when filling
|
||||
* the array with large amounts of data. Adding new data to the linked list is
|
||||
* very inexpensive.
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
class TNxArray
|
||||
{
|
||||
private:
|
||||
T *m_data; /**< Internal array of data items */
|
||||
int m_size; /**< Number of items in the array */
|
||||
int m_reservedSize; /**< Total size of the array including unpopulated slots */
|
||||
|
||||
/**
|
||||
* Re-allocate the array to this size;
|
||||
*/
|
||||
|
||||
void reallocate(const int newSize);
|
||||
|
||||
/**
|
||||
* Resize the array if it is full.
|
||||
*/
|
||||
|
||||
void resize(void);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Creates an un-allocated array. The array will
|
||||
* be allocated when items are added to it or when preallocate()
|
||||
* is called.
|
||||
*/
|
||||
|
||||
inline TNxArray();
|
||||
|
||||
/**
|
||||
* Constructor. Creates an allocated array.
|
||||
*
|
||||
*@param initialSize The initial size of the array.
|
||||
*/
|
||||
|
||||
inline TNxArray(int initialSize);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~TNxArray();
|
||||
|
||||
/**
|
||||
* Set the initial size of the array. Normally, the array is
|
||||
* unallocated until the first data is pushed into the array.
|
||||
* That works great for stacks and lists. But if you want a
|
||||
* array of uninitialized elements, then this method will
|
||||
* preallocate the array for you.
|
||||
*
|
||||
* @return The size of the array.
|
||||
*/
|
||||
|
||||
void preallocate(void);
|
||||
|
||||
/**
|
||||
* Get the size of the array.
|
||||
*
|
||||
* @return The size of the array.
|
||||
*/
|
||||
|
||||
inline const int size(void) const;
|
||||
|
||||
/**
|
||||
* Add a value to the end of the array.
|
||||
*
|
||||
* @param value The value to add to the array.
|
||||
*/
|
||||
|
||||
void push_back(const T &value);
|
||||
|
||||
/**
|
||||
* Insert a value into the array.
|
||||
*
|
||||
* @param index The index to insert into.
|
||||
* @param value The value to insert.
|
||||
*/
|
||||
|
||||
void insert(const int index, const T &value);
|
||||
|
||||
/**
|
||||
* Remove the last element from the array.
|
||||
*/
|
||||
|
||||
void pop_back(void);
|
||||
|
||||
/**
|
||||
* Erase a single value at the specified index
|
||||
*/
|
||||
|
||||
void erase(const int index);
|
||||
|
||||
/**
|
||||
* Get a value at the specified location. Does not perform bounds checking.
|
||||
* @param index The index of the desired value.
|
||||
* @return The value at the specified index.
|
||||
*/
|
||||
|
||||
inline T &at(const int index) const;
|
||||
|
||||
/**
|
||||
* Check if the array has any data.
|
||||
* @return True if the array is empty.
|
||||
*/
|
||||
|
||||
inline bool empty(void) const;
|
||||
|
||||
/**
|
||||
* Remove all data.
|
||||
*/
|
||||
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Overload the [] operator to allow array-style access.
|
||||
* @param index The index to retrieve.
|
||||
* @return The value at the specified index.
|
||||
*/
|
||||
|
||||
T& operator[](const int index) const;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
TNxArray<T>::TNxArray()
|
||||
{
|
||||
// Don't allocate anything until the first data is added to
|
||||
// the array
|
||||
|
||||
m_size = 0; // Number of data items in use
|
||||
m_reservedSize = 0; // Number of data items allocated
|
||||
m_data = (T *)0; // Allocated memory for data items
|
||||
}
|
||||
|
||||
template <class T>
|
||||
TNxArray<T>::TNxArray(int initialSize)
|
||||
{
|
||||
m_size = 0; // Number of data items in use
|
||||
m_reservedSize = 0; // Number of data items allocated
|
||||
m_data = (T *)0; // Allocated memory for data items
|
||||
preallocate(initialSize); // Allocate the initial array
|
||||
}
|
||||
|
||||
template <class T>
|
||||
TNxArray<T>::~TNxArray()
|
||||
{
|
||||
if (m_data)
|
||||
{
|
||||
delete [] m_data;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const int TNxArray<T>::size(void) const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::push_back(const T &value)
|
||||
{
|
||||
// Ensure the array is large enough to hold one more data item
|
||||
|
||||
resize();
|
||||
|
||||
// Add data to array
|
||||
|
||||
m_data[m_size] = value;
|
||||
|
||||
// Remember we've filled a slot
|
||||
|
||||
m_size++;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::pop_back(void)
|
||||
{
|
||||
if (m_size >= 1)
|
||||
{
|
||||
// We can just reduce the used size of the array, as the value
|
||||
// will get overwritten automatically
|
||||
|
||||
m_size--;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::insert(const int index, const T &value)
|
||||
{
|
||||
// Bounds check
|
||||
|
||||
if ((index >= m_size) || (m_size == 0))
|
||||
{
|
||||
push_back(value);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the array is large enough to hold one more data item
|
||||
|
||||
resize();
|
||||
|
||||
// Shift all of the data back one place to make a space for the new data
|
||||
|
||||
for (int i = m_size; i > index; i--)
|
||||
{
|
||||
m_data[i] = m_data[i - 1];
|
||||
}
|
||||
|
||||
// Add data to array
|
||||
|
||||
m_data[index] = value;
|
||||
|
||||
// Remember we've filled a slot
|
||||
|
||||
m_size++;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::erase(const int index)
|
||||
{
|
||||
// Bounds check
|
||||
|
||||
if (index >= m_size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Shift all of the data back one place and overwrite the value
|
||||
|
||||
for (int i = index; i < m_size - 1; i++)
|
||||
{
|
||||
m_data[i] = m_data[i + 1];
|
||||
}
|
||||
|
||||
// Remember we've removed a slot
|
||||
|
||||
m_size--;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::reallocate(const int newSize)
|
||||
{
|
||||
// Do we need to redim the array?
|
||||
|
||||
if (m_reservedSize < newSize)
|
||||
{
|
||||
// Create the new array
|
||||
|
||||
T *newData = new T[newSize];
|
||||
|
||||
// Copy old array contents to new the new array
|
||||
|
||||
for (int i = 0; i < m_reservedSize; i++)
|
||||
{
|
||||
newData[i] = m_data[i];
|
||||
}
|
||||
|
||||
// Delete the old array (if there was one)
|
||||
|
||||
if (m_data)
|
||||
{
|
||||
delete [] m_data;
|
||||
}
|
||||
|
||||
// Update values
|
||||
|
||||
m_data = newData;
|
||||
m_reservedSize = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::resize(void)
|
||||
{
|
||||
// Do we need to redim the array in order to add one more entry?
|
||||
|
||||
if (m_reservedSize == m_size)
|
||||
{
|
||||
// We have filled the array, so resize it
|
||||
|
||||
int newSize = m_reservedSize;
|
||||
#if CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE != CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT
|
||||
newSize += m_reservedSize ?
|
||||
CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT :
|
||||
CONFIG_NXWIDGETS_TNXARRAY_INITIALSIZE;
|
||||
#else
|
||||
newSize += CONFIG_NXWIDGETS_TNXARRAY_SIZEINCREMENT;
|
||||
#endif
|
||||
|
||||
// Re-allocate the array
|
||||
|
||||
reallocate(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T& TNxArray<T>::at(const int index) const
|
||||
{
|
||||
// What if this is called with index > m_reservedSize? What if
|
||||
// this is called before m_data is allocated? Don't do that!
|
||||
|
||||
return m_data[index];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool TNxArray<T>::empty() const
|
||||
{
|
||||
return (m_size == 0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T& TNxArray<T>::operator[](const int index) const
|
||||
{
|
||||
// What if this is called with index > m_reservedSize? What if
|
||||
// this is called before m_data is allocated? Don't do that!
|
||||
|
||||
return m_data[index];
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void TNxArray<T>::clear()
|
||||
{
|
||||
// All we need to do is reset the size value
|
||||
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWIDGETS_TNXARRAY_HXX
|
||||
@@ -0,0 +1,211 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/capplicationwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CAPPLICATIONWINDOW_NXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CAPPLICATIONWINDOW_NXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxtkwindow.hxx"
|
||||
#include "graphics/nxwidgets/cnxtoolbar.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetcontrol.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cimage.hxx"
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/crlepalettebitmap.hxx"
|
||||
|
||||
#include "graphics/nxwm/iapplicationwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class represents that application window. This class contains that the
|
||||
* framed window and its toolbar. It manages callbacks from the toolbar minimize
|
||||
* and close buttions and passes these to the application via callbacks.
|
||||
*/
|
||||
|
||||
class CApplicationWindow : public IApplicationWindow,
|
||||
private NXWidgets::CWidgetEventHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Enumeration describing the bit settings for each window flag
|
||||
*/
|
||||
|
||||
enum EWindowFlags
|
||||
{
|
||||
WINDOW_PERSISTENT = 0x01 /**< Persistent windows have no stop button */
|
||||
};
|
||||
|
||||
protected:
|
||||
NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
|
||||
NXWidgets::CNxToolbar *m_toolbar; /**< The toolbar */
|
||||
NXWidgets::CImage *m_minimizeImage; /**< The minimize icon */
|
||||
NXWidgets::CImage *m_stopImage; /**< The close icon */
|
||||
NXWidgets::CLabel *m_windowLabel; /**< The window title */
|
||||
NXWidgets::CRlePaletteBitmap *m_minimizeBitmap; /**< The minimize icon bitmap */
|
||||
NXWidgets::CRlePaletteBitmap *m_stopBitmap; /**< The stop icon bitmap */
|
||||
NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
|
||||
IApplicationCallback *m_callback; /**< Toolbar action callbacks */
|
||||
uint8_t m_flags; /**< Window flags */
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CApplicationWindow Constructor
|
||||
*
|
||||
* @param window. The window to be used by this application.
|
||||
* @param flags. Optional flags to control the window configuration (See EWindowFlags).
|
||||
*/
|
||||
|
||||
CApplicationWindow(NXWidgets::CNxTkWindow *window, uint8_t flags = 0);
|
||||
|
||||
/**
|
||||
* CApplicationWindow Destructor
|
||||
*/
|
||||
|
||||
~CApplicationWindow(void);
|
||||
|
||||
/**
|
||||
* Initialize window. Window initialization is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully initialized.
|
||||
*/
|
||||
|
||||
bool open(void);
|
||||
|
||||
/**
|
||||
* Re-draw the application window
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy)
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Recover the contained NXTK window instance
|
||||
*
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::INxWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Recover the contained widget control
|
||||
*
|
||||
* @return. The widget control used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::CWidgetControl *getWidgetControl(void) const;
|
||||
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
void block(IApplication *app);
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
*
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
void setWindowLabel(NXWidgets::CNxString &appname);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
void registerCallbacks(IApplicationCallback *callback);
|
||||
|
||||
/**
|
||||
* Check if this window is configured for a persistent application (i.e.,
|
||||
* an application that has no STOP icon
|
||||
*
|
||||
* @return True if the window is configured for a persistent application.
|
||||
*/
|
||||
|
||||
inline bool isPersistent(void) const
|
||||
{
|
||||
return (m_flags & WINDOW_PERSISTENT) != 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CAPPLICATIONWINDOW_NXX
|
||||
452
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ccalibration.hxx
Normal file
452
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ccalibration.hxx
Normal file
@@ -0,0 +1,452 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/ccalibration.hxx
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CCALIBRATION_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CCALIBRATION_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetcontrol.hxx"
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/cnxfont.hxx"
|
||||
|
||||
#include "graphics/nxwm/ctaskbar.hxx"
|
||||
#include "graphics/nxwm/iapplication.hxx"
|
||||
#include "graphics/nxwm/cfullscreenwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/**
|
||||
* Calibration indices
|
||||
*/
|
||||
|
||||
#define CALIB_UPPER_LEFT_INDEX 0
|
||||
#define CALIB_UPPER_RIGHT_INDEX 1
|
||||
#define CALIB_LOWER_RIGHT_INDEX 2
|
||||
#define CALIB_LOWER_LEFT_INDEX 3
|
||||
|
||||
#define CALIB_DATA_POINTS 4
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
struct CTouchscreen;
|
||||
|
||||
/**
|
||||
* Touchscreen calibration data
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXWM_CALIBRATION_ANISOTROPIC
|
||||
struct SCalibrationLine
|
||||
{
|
||||
float slope; /**< The slope of a line */
|
||||
float offset; /**< The offset of a line */
|
||||
};
|
||||
|
||||
struct SCalibrationData
|
||||
{
|
||||
struct SCalibrationLine left; /**< Describes Y values along left edge */
|
||||
struct SCalibrationLine right; /**< Describes Y values along right edge */
|
||||
struct SCalibrationLine top; /**< Describes X values along top */
|
||||
struct SCalibrationLine bottom; /**< Describes X values along bottom edge */
|
||||
nxgl_coord_t leftX; /**< Left X value used in calibration */
|
||||
nxgl_coord_t rightX; /**< Right X value used in calibration */
|
||||
nxgl_coord_t topY; /**< Top Y value used in calibration */
|
||||
nxgl_coord_t bottomY; /**< Bottom Y value used in calibration */
|
||||
};
|
||||
|
||||
#else
|
||||
struct SCalibrationData
|
||||
{
|
||||
b16_t xSlope; /**< X conversion: xSlope*(x) + xOffset */
|
||||
b16_t xOffset;
|
||||
b16_t ySlope; /**< Y conversion: ySlope*(y) + yOffset */
|
||||
b16_t yOffset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The CCalibration class provides the the calibration window and obtains
|
||||
* calibration data.
|
||||
*/
|
||||
|
||||
class CCalibration : public IApplication
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The state of the calibration thread.
|
||||
*/
|
||||
|
||||
enum ECalThreadState
|
||||
{
|
||||
CALTHREAD_NOTRUNNING = 0, /**< The calibration thread has not yet been started */
|
||||
CALTHREAD_STARTED, /**< The calibration thread has been started, but is not yet running */
|
||||
CALTHREAD_RUNNING, /**< The calibration thread is running normally */
|
||||
CALTHREAD_STOPREQUESTED, /**< The calibration thread has been requested to stop */
|
||||
CALTHREAD_HIDE, /**< The hide() called by calibration thread running */
|
||||
CALTHREAD_SHOW, /**< The redraw() called by calibration thread running */
|
||||
CALTHREAD_TERMINATED /**< The calibration thread terminated normally */
|
||||
};
|
||||
|
||||
/**
|
||||
* Identifies the current display state
|
||||
*/
|
||||
|
||||
enum ECalibrationPhase
|
||||
{
|
||||
CALPHASE_NOT_STARTED = 0, /**< Constructed, but not yet started */
|
||||
CALPHASE_UPPER_LEFT, /**< Touch point is in the upper left corner */
|
||||
CALPHASE_UPPER_RIGHT, /**< Touch point is in the upper right corner */
|
||||
CALPHASE_LOWER_RIGHT, /**< Touch point is in the lower left corner */
|
||||
CALPHASE_LOWER_LEFT, /**< Touch point is in the lower right corner */
|
||||
CALPHASE_COMPLETE /**< Calibration is complete */
|
||||
};
|
||||
|
||||
/**
|
||||
* Characterizes one calibration screen
|
||||
*/
|
||||
|
||||
struct SCalibScreenInfo
|
||||
{
|
||||
struct nxgl_point_s pos; /**< The position of the touch point */
|
||||
nxgl_mxpixel_t lineColor; /**< The color of the cross-hair lines */
|
||||
nxgl_mxpixel_t circleFillColor; /**< The color of the circle */
|
||||
};
|
||||
|
||||
/**
|
||||
* CCalibration state data
|
||||
*/
|
||||
|
||||
CTaskbar *m_taskbar; /**< The taskbar (used to terminate calibration) */
|
||||
CFullScreenWindow *m_window; /**< The window for the calibration display */
|
||||
CTouchscreen *m_touchscreen; /**< The touchscreen device */
|
||||
#ifdef CONFIG_NXWM_CALIBRATION_MESSAGES
|
||||
NXWidgets::CLabel *m_text; /**< Calibration message */
|
||||
NXWidgets::CNxFont *m_font; /**< The font used in the message */
|
||||
#endif
|
||||
pthread_t m_thread; /**< The calibration thread ID */
|
||||
struct SCalibScreenInfo m_screenInfo; /**< Describes the current calibration display */
|
||||
struct nxgl_point_s m_touchPos; /**< This is the last touch position */
|
||||
volatile uint8_t m_calthread; /**< Current calibration display state (See ECalibThreadState)*/
|
||||
uint8_t m_calphase; /**< Current calibration display state (See ECalibrationPhase)*/
|
||||
bool m_stop; /**< True: We have been asked to stop the calibration */
|
||||
bool m_touched; /**< True: The screen is touched */
|
||||
uint8_t m_touchId; /**< The ID of the touch */
|
||||
#ifdef CONFIG_NXWM_CALIBRATION_AVERAGE
|
||||
uint8_t m_nsamples; /**< Number of samples collected so far at this position */
|
||||
struct nxgl_point_s m_sampleData[CONFIG_NXWM_CALIBRATION_NSAMPLES];
|
||||
#endif
|
||||
struct nxgl_point_s m_calibData[CALIB_DATA_POINTS];
|
||||
|
||||
/**
|
||||
* Accept raw touchscreen input.
|
||||
*
|
||||
* @param sample Touchscreen input sample
|
||||
*/
|
||||
|
||||
void touchscreenInput(struct touch_sample_s &sample);
|
||||
|
||||
#ifdef CONFIG_NXWM_CALIBRATION_MESSAGES
|
||||
/**
|
||||
* Create widgets need by the calibration thread.
|
||||
*
|
||||
* @return True if the widgets were successfully created.
|
||||
*/
|
||||
|
||||
bool createWidgets(void);
|
||||
|
||||
/**
|
||||
* Destroy widgets created for the calibration thread.
|
||||
*/
|
||||
|
||||
void destroyWidgets(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Start the calibration thread.
|
||||
*
|
||||
* @param initialState. The initial state of the calibration thread
|
||||
* @return True if the thread was successfully started.
|
||||
*/
|
||||
|
||||
bool startCalibration(enum ECalThreadState initialState);
|
||||
|
||||
/**
|
||||
* Return true if the calibration thread is running normally. There are
|
||||
* lots of potential race conditions. There are also two ambiguous
|
||||
* states:
|
||||
*
|
||||
* 1) The thread may have been started but not yet running
|
||||
* (CALTHREAD_STARTED), or the
|
||||
* 2) The thread may been requested to terminate, but has not yet
|
||||
* terminated (CALTHREAD_STOPREQUESTED)
|
||||
*
|
||||
* Both of those states will cause isRunning() to return false.
|
||||
*
|
||||
* @return True if the calibration thread is running normally.
|
||||
*/
|
||||
|
||||
inline bool isRunning(void) const
|
||||
{
|
||||
return (m_calthread == CALTHREAD_RUNNING ||
|
||||
m_calthread == CALTHREAD_HIDE ||
|
||||
m_calthread == CALTHREAD_SHOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the calibration thread is has been started and has not
|
||||
* yet terminated. There is a potential race condition here when the
|
||||
* thread has been requested to terminate, but has not yet terminated
|
||||
* (CALTHREAD_STOPREQUESTED). isStarted() will return false in that case.
|
||||
*
|
||||
* @return True if the calibration thread has been started and/or is
|
||||
* running normally.
|
||||
*/
|
||||
|
||||
inline bool isStarted(void) const
|
||||
{
|
||||
return (m_calthread == CALTHREAD_STARTED ||
|
||||
m_calthread == CALTHREAD_RUNNING ||
|
||||
m_calthread == CALTHREAD_HIDE ||
|
||||
m_calthread == CALTHREAD_SHOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* The calibration thread. This is the entry point of a thread that provides the
|
||||
* calibration displays, waits for input, and collects calibration data.
|
||||
*
|
||||
* @param arg. The CCalibration 'this' pointer cast to a void*.
|
||||
* @return This function always returns NULL when the thread exits
|
||||
*/
|
||||
|
||||
static FAR void *calibration(FAR void *arg);
|
||||
|
||||
#ifdef CONFIG_NXWM_CALIBRATION_AVERAGE
|
||||
/**
|
||||
* Accumulate and average touch sample data
|
||||
*
|
||||
* @param average. When the averaged data is available, return it here
|
||||
* @return True: Average data is available; False: Need to collect more samples
|
||||
*/
|
||||
|
||||
bool averageSamples(struct nxgl_point_s &average);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the calibration state machine. It is called initially and then
|
||||
* as new touchscreen data is received.
|
||||
*/
|
||||
|
||||
void stateMachine(void);
|
||||
|
||||
/**
|
||||
* Presents the next calibration screen
|
||||
*/
|
||||
|
||||
void showCalibration(void);
|
||||
|
||||
/**
|
||||
* Finish calibration steps and provide the calibration data to the
|
||||
* touchscreen driver.
|
||||
*/
|
||||
|
||||
void finishCalibration(void);
|
||||
|
||||
/**
|
||||
* Given the raw touch data collected by the calibration thread, create the
|
||||
* massaged calibration data needed by CTouchscreen.
|
||||
*
|
||||
* @param data. A reference to the location to save the calibration data
|
||||
* @return True if the calibration data was successfully created.
|
||||
*/
|
||||
|
||||
bool createCalibrationData(struct SCalibrationData &data);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CCalibration Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
* @param window. The window to use for the calibration display
|
||||
* @param touchscreen. An instance of the class that wraps the
|
||||
* touchscreen device.
|
||||
*/
|
||||
|
||||
CCalibration(CTaskbar *taskbar, CFullScreenWindow *window,
|
||||
CTouchscreen *touchscreen);
|
||||
|
||||
/**
|
||||
* CCalibration Destructor
|
||||
*/
|
||||
|
||||
~CCalibration(void);
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained IApplicationWindow instance.
|
||||
*/
|
||||
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxString getName(void);
|
||||
|
||||
/**
|
||||
* Start the application (perhaps in the minimized state).
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
bool run(void);
|
||||
|
||||
/**
|
||||
* Stop the application.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
void destroy(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is called from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
|
||||
class CCalibrationFactory : public IApplicationFactory
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< The taskbar */
|
||||
CTouchscreen *m_touchscreen; /**< The touchscreen device */
|
||||
|
||||
public:
|
||||
/**
|
||||
* CCalibrationFactory Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
* @param touchscreen. An instance of the class that wraps the
|
||||
* touchscreen device.
|
||||
*/
|
||||
|
||||
CCalibrationFactory(CTaskbar *taskbar, CTouchscreen *touchscreen);
|
||||
|
||||
/**
|
||||
* CCalibrationFactory Destructor
|
||||
*/
|
||||
|
||||
inline ~CCalibrationFactory(void) { }
|
||||
|
||||
/**
|
||||
* Create a new instance of an CCalibration (as IApplication).
|
||||
*/
|
||||
|
||||
IApplication *create(void);
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CCALIBRATION_HXX
|
||||
@@ -0,0 +1,163 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/cfullscreenwindow.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CFULLSCREENWINDOW_NXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CFULLSCREENWINDOW_NXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxwindow.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetcontrol.hxx"
|
||||
|
||||
#include "graphics/nxwm/iapplicationwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class represents a generic window. This bland window is used,
|
||||
* for example, to support full screen displays.
|
||||
*/
|
||||
|
||||
class CFullScreenWindow : public IApplicationWindow
|
||||
{
|
||||
protected:
|
||||
NXWidgets::CNxWindow *m_window; /**< The generic window used by the application */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CFullScreenWindow Constructor
|
||||
*
|
||||
* @param window. The raw window to be used by this full screen application.
|
||||
*/
|
||||
|
||||
CFullScreenWindow(NXWidgets::CNxWindow *window);
|
||||
|
||||
/**
|
||||
* CFullScreenWindow Destructor
|
||||
*/
|
||||
|
||||
~CFullScreenWindow(void);
|
||||
|
||||
/**
|
||||
* Initialize window. Window initialization is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully initialized.
|
||||
*/
|
||||
|
||||
bool open(void);
|
||||
|
||||
/**
|
||||
* Re-draw the application window
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy)
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Recover the contained NXTK window instance
|
||||
*
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::INxWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Recover the contained widget control
|
||||
*
|
||||
* @return. The widget control used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::CWidgetControl *getWidgetControl(void) const;
|
||||
|
||||
/**
|
||||
* Block further activity on this window in preparation for window
|
||||
* shutdown.
|
||||
*
|
||||
* @param app. The application to be blocked
|
||||
*/
|
||||
|
||||
void block(IApplication *app);
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
*
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
void setWindowLabel(NXWidgets::CNxString &appname);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
void registerCallbacks(IApplicationCallback *callback);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CFULLSCREENWINDOW_NXX
|
||||
329
Ubiquitous/Nuttx/apps/include/graphics/nxwm/chexcalculator.hxx
Normal file
329
Ubiquitous/Nuttx/apps/include/graphics/nxwm/chexcalculator.hxx
Normal file
@@ -0,0 +1,329 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/chexcalculator.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CHEXCALCULATOR_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CHEXCALCULATOR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
|
||||
#include "graphics/nxwidgets/cbuttonarray.hxx"
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/cnxfont.hxx"
|
||||
|
||||
#include "graphics/nxwm/iapplication.hxx"
|
||||
#include "graphics/nxwm/capplicationwindow.hxx"
|
||||
#include "graphics/nxwm/ctaskbar.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NXWM_HEXCALCULATOR_NROWS 6
|
||||
#define NXWM_HEXCALCULATOR_NCOLUMNS 6
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class implements the Hex calculator application.
|
||||
*/
|
||||
|
||||
class CHexCalculator : public IApplication,
|
||||
private IApplicationCallback,
|
||||
private NXWidgets::CWidgetEventHandler
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The structure defines a pending operation.
|
||||
*/
|
||||
|
||||
struct SPendingOperation
|
||||
{
|
||||
int64_t value; /**< Accumulated value */
|
||||
uint8_t operation; /**< Identifies the operations */
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculator state data.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Cached constructor parameters.
|
||||
*/
|
||||
|
||||
CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
|
||||
CApplicationWindow *m_window; /**< Reference to the application window */
|
||||
|
||||
/**
|
||||
* Widgets
|
||||
*/
|
||||
|
||||
NXWidgets::CButtonArray *m_keypad; /**< The calculator keyboard */
|
||||
NXWidgets::CLabel *m_text; /**< The accumulator text display */
|
||||
NXWidgets::CNxFont *m_font; /**< The font used in the calculator */
|
||||
|
||||
/**
|
||||
* Calculator geometry. This stuff does not really have to be retained
|
||||
* in memory. If you are pinched for memory, get rid of these.
|
||||
*/
|
||||
|
||||
struct nxgl_size_s m_windowSize; /**< The size of the calculator window */
|
||||
struct nxgl_size_s m_keypadSize; /**< The size the calculator keypad */
|
||||
struct nxgl_size_s m_buttonSize; /**< The size of one calculator button */
|
||||
struct nxgl_size_s m_textSize; /**< The size of the calculator textbox */
|
||||
struct nxgl_point_s m_keypadPos; /**< The position the calculator keypad */
|
||||
struct nxgl_point_s m_textPos; /**< The position of the calculator textbox */
|
||||
|
||||
/**
|
||||
* Calculator computational data. Note: Since we do not support
|
||||
* parentheses and support only two levels of operator precedence, it is
|
||||
* not necessary to maintain a stack of operations. Within there
|
||||
* limitations, there can be at most only one pending low prececence
|
||||
* operation and one pending high precedence operation. If you want
|
||||
* to support parentheses or more levels of precedence, they you will
|
||||
* have to extend the design.
|
||||
*/
|
||||
|
||||
int64_t m_accum; /**< The current accumulated value */
|
||||
int64_t m_memory; /**< The current value saved in memory */
|
||||
struct SPendingOperation m_low; /**< Low precedence pending operation */
|
||||
struct SPendingOperation m_high; /**< High precedence pending operation */
|
||||
bool m_hexMode; /**< True if in hex mode */
|
||||
bool m_result ; /**< True if the accumulator holds a previoius result */
|
||||
|
||||
/**
|
||||
* Select the geometry of the calculator given the current window size.
|
||||
* Only called as part of construction.
|
||||
*/
|
||||
|
||||
inline void setGeometry(void);
|
||||
|
||||
/**
|
||||
* Create the calculator keypad. Only start as part of the application
|
||||
* start method.
|
||||
*/
|
||||
|
||||
inline bool createCalculator(void);
|
||||
|
||||
/**
|
||||
* Applies labels to the keys.
|
||||
*/
|
||||
|
||||
void labelKeypad(void);
|
||||
|
||||
/**
|
||||
* Evaluate a binary operation.
|
||||
*
|
||||
* @param value1. The first value
|
||||
* @param value2. The second value
|
||||
*
|
||||
* @return The result of the operation
|
||||
*/
|
||||
|
||||
int64_t evaluateBinaryOperation(uint8_t operation, int64_t value1, int64_t value2);
|
||||
|
||||
/**
|
||||
* Show the current value of the accumulator.
|
||||
*/
|
||||
|
||||
void updateText(void);
|
||||
|
||||
/**
|
||||
* Called when the window minimize button is pressed.
|
||||
*/
|
||||
|
||||
void minimize(void);
|
||||
|
||||
/**
|
||||
* Called when the window minimize close is pressed.
|
||||
*/
|
||||
|
||||
void close(void);
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CImage, this is a button pre-
|
||||
* release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
public:
|
||||
/**
|
||||
* CHexCalculator constructor
|
||||
*
|
||||
* @param window. The application window
|
||||
*
|
||||
* @param taskbar. A pointer to the parent task bar instance
|
||||
* @param window. The window to be used by this application.
|
||||
*/
|
||||
|
||||
CHexCalculator(CTaskbar *taskbar, CApplicationWindow *window);
|
||||
|
||||
/**
|
||||
* CHexCalculator destructor
|
||||
*/
|
||||
|
||||
~CHexCalculator(void);
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxString getName(void);
|
||||
|
||||
/**
|
||||
* Start the application (perhaps in the minimized state).
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
bool run(void);
|
||||
|
||||
/**
|
||||
* Stop the application.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
void destroy(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is call from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
|
||||
class CHexCalculatorFactory : public IApplicationFactory
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< The taskbar */
|
||||
|
||||
public:
|
||||
/**
|
||||
* CHexCalculatorFactory Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
*/
|
||||
|
||||
CHexCalculatorFactory(CTaskbar *taskbar);
|
||||
|
||||
/**
|
||||
* CHexCalculatorFactory Destructor
|
||||
*/
|
||||
|
||||
inline ~CHexCalculatorFactory(void) { }
|
||||
|
||||
/**
|
||||
* Create a new instance of an CHexCalculator (as IApplication).
|
||||
*/
|
||||
|
||||
IApplication *create(void);
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CHEXCALCULATOR_HXX
|
||||
171
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ckeyboard.hxx
Normal file
171
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ckeyboard.hxx
Normal file
@@ -0,0 +1,171 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/keyboard.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NXWM_INCLUDE_CKEYBOARD_HXX
|
||||
#define __NXWM_INCLUDE_CKEYBOARD_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include <semaphore.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <nuttx/input/touchscreen.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxserver.hxx"
|
||||
#include "graphics/nxwm/ccalibration.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* The CKeyboard class provides the the calibration window and obtains
|
||||
* calibration data.
|
||||
*/
|
||||
|
||||
class CKeyboard
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The state of the listener thread.
|
||||
*/
|
||||
|
||||
enum EListenerState
|
||||
{
|
||||
LISTENER_NOTRUNNING = 0, /**< The listener thread has not yet been started */
|
||||
LISTENER_STARTED, /**< The listener thread has been started, but is not yet running */
|
||||
LISTENER_RUNNING, /**< The listener thread is running normally */
|
||||
LISTENER_STOPREQUESTED, /**< The listener thread has been requested to stop */
|
||||
LISTENER_TERMINATED, /**< The listener thread terminated normally */
|
||||
LISTENER_FAILED /**< The listener thread terminated abnormally */
|
||||
};
|
||||
|
||||
/**
|
||||
* CKeyboard state data
|
||||
*/
|
||||
|
||||
NXWidgets::CNxServer *m_server; /**< The current NX server */
|
||||
int m_kbdFd; /**< File descriptor of the opened keyboard device */
|
||||
pthread_t m_thread; /**< The listener thread ID */
|
||||
volatile enum EListenerState m_state; /**< The state of the listener thread */
|
||||
sem_t m_waitSem; /**< Used to synchronize with the listener thread */
|
||||
|
||||
/**
|
||||
* Open the keyboard device. Not very interesting for the case of
|
||||
* standard device but much more interesting for a USB keyboard device
|
||||
* that may disappear when the keyboard is disconnect but later reappear
|
||||
* when the keyboard is reconnected. In this case, this function will
|
||||
* not return until the keyboard device was successfully opened (or
|
||||
* until an irrecoverable error occurs.
|
||||
*
|
||||
* Opens the keyboard device specified by CONFIG_NXWM_KEYBOARD_DEVPATH.
|
||||
*
|
||||
* @return On success, then method returns a valid file descriptor that
|
||||
* can be used to redirect stdin. A negated errno value is returned
|
||||
* if an irrecoverable error occurs.
|
||||
*/
|
||||
|
||||
inline int open(void);
|
||||
|
||||
/**
|
||||
* This is the heart of the keyboard listener thread. It contains the
|
||||
* actual logic that listeners for and dispatches keyboard events to the
|
||||
* NX server.
|
||||
*
|
||||
* @return If the session terminates gracefully (i.e., because >m_state
|
||||
* is no longer equal to LISTENER_RUNNING, then method returns OK. A
|
||||
* negated errno value is returned if an error occurs while reading from
|
||||
* the keyboard device. A read error, depending upon the type of the
|
||||
* error, may simply indicate that a USB keyboard was removed and we
|
||||
* should wait for the keyboard to be connected.
|
||||
*/
|
||||
|
||||
inline int session(void);
|
||||
|
||||
/**
|
||||
* The keyboard listener thread. This is the entry point of a thread
|
||||
* that listeners for and dispatches keyboard events to the NX server.
|
||||
* It simply opens the keyboard device (using CKeyboard::open()) and
|
||||
* executes the session (via CKeyboard::session()).
|
||||
*
|
||||
* If an errors while reading from the keyboard device AND we are
|
||||
* configured to use a USB keyboard, then this function will wait for
|
||||
* the USB keyboard to be re-connected.
|
||||
*
|
||||
* @param arg. The CKeyboard 'this' pointer cast to a void*.
|
||||
* @return This function normally does not return but may return NULL on
|
||||
* error conditions.
|
||||
*/
|
||||
|
||||
static FAR void *listener(FAR void *arg);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CKeyboard Constructor
|
||||
*
|
||||
* @param server. An instance of the NX server. This will be needed for
|
||||
* injecting mouse data.
|
||||
*/
|
||||
|
||||
CKeyboard(NXWidgets::CNxServer *server);
|
||||
|
||||
/**
|
||||
* CKeyboard Destructor
|
||||
*/
|
||||
|
||||
~CKeyboard(void);
|
||||
|
||||
/**
|
||||
* Start the keyboard listener thread.
|
||||
*
|
||||
* @return True if the keyboard listener thread was correctly started.
|
||||
*/
|
||||
|
||||
bool start(void);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __NXWM_INCLUDE_CKEYBOARD_HXX
|
||||
486
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cmediaplayer.hxx
Normal file
486
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cmediaplayer.hxx
Normal file
@@ -0,0 +1,486 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/cmediaplayer.hxx
|
||||
*
|
||||
* Copyright (C) 2013 Ken Pettit. All rights reserved.
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
* Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CMEDIAPLAYER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CMEDIAPLAYER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
#include <nuttx/nx/nxterm.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxfont.hxx"
|
||||
#include "graphics/nxwidgets/cimage.hxx"
|
||||
#include "graphics/nxwidgets/cstickyimage.hxx"
|
||||
#include "graphics/nxwidgets/clabel.hxx"
|
||||
#include "graphics/nxwidgets/clistbox.hxx"
|
||||
#include "graphics/nxwidgets/clistboxdataitem.hxx"
|
||||
#include "graphics/nxwidgets/cglyphsliderhorizontal.hxx"
|
||||
|
||||
#include "graphics/nxwm/iapplication.hxx"
|
||||
#include "graphics/nxwm/capplicationwindow.hxx"
|
||||
#include "graphics/nxwm/ctaskbar.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NXWM_MEDIAPLAYER_NROWS 6
|
||||
#define NXWM_MEDIAPLAYER_NCOLUMNS 6
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class implements the CMediaPlayer application.
|
||||
*/
|
||||
|
||||
class CMediaPlayer : public IApplication,
|
||||
private IApplicationCallback,
|
||||
private NXWidgets::CWidgetEventHandler
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* This enumeration identifies the state of the media player
|
||||
*
|
||||
* State Transition Table
|
||||
* ---------+----------+----------+----------+----------+----------+----------+
|
||||
* | FILE | FILE | | | FAST | |
|
||||
* STATE | SELECTED |DESELECTED| PLAY | PAUSE | FORWARD | REWIND |
|
||||
* ---------+----------+----------+----------+----------+----------+----------+
|
||||
* STOPPED | STAGED | X | X | X | X | X |
|
||||
* STAGED | STAGED | STOPPED | PLAYING | X | X | X |
|
||||
* PLAYING | X | X | X | PAUSED |FFORWARD2 | REWIND2 |
|
||||
* PAUSED | STAGED | STOPPED | PLAYING | X |FFORWARD1 | REWIND1 |
|
||||
* FFORWARD1| X | X | PAUSED | X |FFORWARD1 | REWIND1 |
|
||||
* REWIND1 | X | X | PAUSED | X |FFORWARD1 | REWIND1 |
|
||||
* FFORWARD2| X | X | X | PLAYING | PLAYING | REWIND1 |
|
||||
* REWIND2 | X | X | X | PLAYING |FFORWARD1 | PLAYING |
|
||||
* ---------+----------+----------+----------+----------+----------+----------+
|
||||
*
|
||||
* Configuration Dependencies. States in the above state transition table may
|
||||
* not be supported if any of the following features are excluded from the
|
||||
* configuration:
|
||||
*
|
||||
* CONFIG_AUDIO_EXCLUDE_STOP
|
||||
* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
|
||||
* CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||
* CONFIG_AUDIO_EXCLUDE_FFORWARD
|
||||
* CONFIG_AUDIO_EXCLUDE_REWIND
|
||||
*/
|
||||
|
||||
enum EMediaPlayerState
|
||||
{
|
||||
MPLAYER_STOPPED = 0, /**< No media file has been selected */
|
||||
MPLAYER_STAGED, /**< Media file selected, not playing */
|
||||
MPLAYER_PLAYING, /**< Playing a media file */
|
||||
MPLAYER_PAUSED, /**< Playing a media file but paused */
|
||||
MPLAYER_FFORWARD, /**< Fast forwarding through a media file */
|
||||
MPLAYER_FREWIND, /**< Rewinding a media file */
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the state of an image touch. Some image touch cannot be
|
||||
* processed until the image contact is lost. This enumeration arms and
|
||||
* manages those cases.
|
||||
*/
|
||||
|
||||
enum EPendingRelease
|
||||
{
|
||||
PENDING_NONE = 0, /**< Nothing is pending */
|
||||
PENDING_PLAY_RELEASE, /**< Expect play image to be released */
|
||||
PENDING_PAUSE_RELEASE /**< Expect pause image to be released */
|
||||
};
|
||||
|
||||
/**
|
||||
* The structure defines a pending operation.
|
||||
*/
|
||||
|
||||
struct SPendingOperation
|
||||
{
|
||||
int64_t value; /**< Accumulated value */
|
||||
uint8_t operation; /**< Identifies the operations */
|
||||
};
|
||||
|
||||
/**
|
||||
* Media player state data.
|
||||
*/
|
||||
|
||||
FAR struct nxplayer_s *m_player; /**< NxPlayer handle */
|
||||
enum EMediaPlayerState m_state; /**< Media player current state */
|
||||
enum EMediaPlayerState m_prevState; /**< Media player previous state */
|
||||
enum EPendingRelease m_pending; /**< Pending image release event */
|
||||
NXWidgets::CNxString m_filePath; /**< The full path to the selected file */
|
||||
int m_fileIndex; /**< Last selected text box selection */
|
||||
bool m_fileReady; /**< True: Ready to play */
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||
uint8_t m_level; /**< Current volume level, range 0-100 */
|
||||
#endif
|
||||
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||
uint8_t m_subSample; /**< Current FFFORWARD subsampling index */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Media player geometry.
|
||||
*/
|
||||
|
||||
struct nxgl_size_s m_windowSize; /**< The size of the media player window */
|
||||
|
||||
/**
|
||||
* Cached constructor parameters.
|
||||
*/
|
||||
|
||||
CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
|
||||
CApplicationWindow *m_window; /**< Reference to the application window */
|
||||
|
||||
/**
|
||||
* Widgets
|
||||
*/
|
||||
|
||||
NXWidgets::CListBox *m_listbox; /**< List box containing media files selections */
|
||||
NXWidgets::CNxFont *m_font; /**< The font used in the media player */
|
||||
NXWidgets::CImage *m_play; /**< Play control */
|
||||
NXWidgets::CImage *m_pause; /**< Pause control */
|
||||
NXWidgets::CStickyImage *m_rewind; /**< Rewind control */
|
||||
NXWidgets::CStickyImage *m_fforward; /**< Fast forward control */
|
||||
NXWidgets::CGlyphSliderHorizontal *m_volume; /**< Volume control */
|
||||
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||
NXWidgets::CLabel *m_speed; /**< FForward/rewind speed */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Bitmaps
|
||||
*
|
||||
* These are retained only so that they can be released when the media
|
||||
* is closed player
|
||||
*/
|
||||
|
||||
NXWidgets::CRlePaletteBitmap *m_playBitmap; /**< Bitmap for the play control */
|
||||
NXWidgets::CRlePaletteBitmap *m_pauseBitmap; /**< Bitmap for the pause control */
|
||||
NXWidgets::CRlePaletteBitmap *m_rewindBitmap; /**< Bitmap for the rewind control */
|
||||
NXWidgets::CRlePaletteBitmap *m_fforwardBitmap; /**< Bitmap for the fast forward control */
|
||||
NXWidgets::CRlePaletteBitmap *m_volumeBitmap; /**< Volume control grip bitmap */
|
||||
|
||||
/**
|
||||
* Get the full media file path and make ready for playing. Called
|
||||
* after a file has been selected from the list box.
|
||||
*/
|
||||
|
||||
bool getMediaFile(const NXWidgets::CListBoxDataItem *item);
|
||||
|
||||
/**
|
||||
* Get the full media file path and make ready for playing. Called
|
||||
* after a file has been selected from the list box.
|
||||
*/
|
||||
|
||||
bool openMediaFile(const NXWidgets::CListBoxDataItem *item);
|
||||
|
||||
/**
|
||||
* Stop playing the current file. Called when a new media file is selected,
|
||||
* when a media file is de-selected, or when destroying the media player
|
||||
* instance.
|
||||
*/
|
||||
|
||||
void stopPlaying(void);
|
||||
|
||||
/**
|
||||
* Select the geometry of the media player given the current window size.
|
||||
* Only called as part of construction.
|
||||
*/
|
||||
|
||||
inline void setGeometry(void);
|
||||
|
||||
/**
|
||||
* Load media files into the list box.
|
||||
*/
|
||||
|
||||
inline bool showMediaFiles(FAR const char *mediaPath);
|
||||
|
||||
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
|
||||
/**
|
||||
* Set the preferred audio device for playback
|
||||
*/
|
||||
|
||||
inline bool setDevice(FAR const char *devPath);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Configure the NxPlayer.
|
||||
*/
|
||||
|
||||
inline bool configureNxPlayer(void);
|
||||
|
||||
/**
|
||||
* Create the Media Player controls. Only start as part of the application
|
||||
* start method.
|
||||
*/
|
||||
|
||||
inline bool createPlayer(void);
|
||||
|
||||
/**
|
||||
* Called when the window minimize image is pressed.
|
||||
*/
|
||||
|
||||
void minimize(void);
|
||||
|
||||
/**
|
||||
* Called when the window minimize close is pressed.
|
||||
*/
|
||||
|
||||
void close(void);
|
||||
|
||||
/**
|
||||
* Redraw all widgets. Called from redraw() and also on any state
|
||||
* change.
|
||||
*
|
||||
* @param state The new state to enter.
|
||||
*/
|
||||
|
||||
void redrawWidgets(void);
|
||||
|
||||
/**
|
||||
* Transition to a new media player state.
|
||||
*
|
||||
* @param state The new state to enter.
|
||||
*/
|
||||
|
||||
void setMediaPlayerState(enum EMediaPlayerState state);
|
||||
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||
/**
|
||||
* Set the new volume level based on the position of the volume slider.
|
||||
*/
|
||||
|
||||
void setVolumeLevel(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check if a new file has been selected (or de-selected) in the list box
|
||||
*/
|
||||
|
||||
inline void checkFileSelection(void);
|
||||
|
||||
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||
/**
|
||||
* Update fast forward/rewind speed indicator. Called on each state
|
||||
* change and after each change in the speed of motion.
|
||||
*/
|
||||
|
||||
void updateMotionIndicator(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For this application, that means image
|
||||
* pre-release events.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a widget release event. Only the play and pause image release
|
||||
* are of interest.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleReleaseEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle a widget release event when the widget WAS dragged outside of
|
||||
* its original bounding box. Only the play and pause image release
|
||||
* are of interest.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleReleaseOutsideEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
/**
|
||||
* Handle value changes. This will get events when there is a change in the
|
||||
* volume level or a file is selected or deselected.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleValueChangeEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
public:
|
||||
/**
|
||||
* CMediaPlayer constructor
|
||||
*
|
||||
* @param window. The application window
|
||||
*
|
||||
* @param taskbar. A pointer to the parent task bar instance
|
||||
* @param window. The window to be used by this application.
|
||||
*/
|
||||
|
||||
CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window);
|
||||
|
||||
/**
|
||||
* CMediaPlayer destructor
|
||||
*/
|
||||
|
||||
~CMediaPlayer(void);
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxString getName(void);
|
||||
|
||||
/**
|
||||
* Start the application (perhaps in the minimized state).
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
bool run(void);
|
||||
|
||||
/**
|
||||
* Stop the application.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
void destroy(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is call from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
|
||||
class CMediaPlayerFactory : public IApplicationFactory
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< The taskbar */
|
||||
|
||||
public:
|
||||
/**
|
||||
* CMediaPlayerFactory Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
*/
|
||||
|
||||
CMediaPlayerFactory(CTaskbar *taskbar);
|
||||
|
||||
/**
|
||||
* CMediaPlayerFactory Destructor
|
||||
*/
|
||||
|
||||
inline ~CMediaPlayerFactory(void) { }
|
||||
|
||||
/**
|
||||
* Create a new instance of an CMediaPlayer (as IApplication).
|
||||
*/
|
||||
|
||||
IApplication *create(void);
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CMEDIAPLAYER_HXX
|
||||
246
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cnxterm.hxx
Normal file
246
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cnxterm.hxx
Normal file
@@ -0,0 +1,246 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/cnxterm.hxx
|
||||
*
|
||||
* Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CNXTERM_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CNXTERM_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
#include <nuttx/nx/nxterm.h>
|
||||
|
||||
#include "graphics/nxwm/iapplication.hxx"
|
||||
#include "graphics/nxwm/capplicationwindow.hxx"
|
||||
#include "graphics/nxwm/ctaskbar.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* One time NSH initialization. This function must be called exactly
|
||||
* once during the boot-up sequence to initialize the NSH library.
|
||||
*
|
||||
* @return True on successful initialization
|
||||
*/
|
||||
|
||||
bool nshlibInitialize(void);
|
||||
|
||||
/**
|
||||
* This class implements the NxTerm application.
|
||||
*/
|
||||
|
||||
class CNxTerm : public IApplication, private IApplicationCallback
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
|
||||
CApplicationWindow *m_window; /**< Reference to the application window */
|
||||
NXTERM m_nxterm; /**< NxTerm handle */
|
||||
pid_t m_pid; /**< Task ID of the NxTerm thread */
|
||||
int m_minor; /**< Terminal device minor number */
|
||||
|
||||
/**
|
||||
* This is the NxTerm task. This function first redirects output to the
|
||||
* console window then calls to start the NSH logic.
|
||||
*/
|
||||
|
||||
static int nxterm(int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* This is the NxTerm task exit handler. It is registered with on_exit()
|
||||
* and called automatically when the nxterm task exits.
|
||||
*/
|
||||
|
||||
static void exitHandler(int code, FAR void *arg);
|
||||
|
||||
/**
|
||||
* Called when the window minimize button is pressed.
|
||||
*/
|
||||
|
||||
void minimize(void);
|
||||
|
||||
/**
|
||||
* Called when the window close button is pressed.
|
||||
*/
|
||||
|
||||
void close(void);
|
||||
|
||||
public:
|
||||
/**
|
||||
* CNxTerm constructor
|
||||
*
|
||||
* @param window. The application window
|
||||
*
|
||||
* @param taskbar. A pointer to the parent task bar instance
|
||||
* @param window. The window to be used by this application.
|
||||
*/
|
||||
|
||||
CNxTerm(CTaskbar *taskbar, CApplicationWindow *window);
|
||||
|
||||
/**
|
||||
* CNxTerm destructor
|
||||
*/
|
||||
|
||||
~CNxTerm(void);
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxString getName(void);
|
||||
|
||||
/**
|
||||
* Start the application (perhaps in the minimized state).
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
bool run(void);
|
||||
|
||||
/**
|
||||
* Stop the application.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
void destroy(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is call from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
|
||||
class CNxTermFactory : public IApplicationFactory
|
||||
{
|
||||
private:
|
||||
CTaskbar *m_taskbar; /**< The taskbar */
|
||||
|
||||
public:
|
||||
/**
|
||||
* CNxTermFactory Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
*/
|
||||
|
||||
CNxTermFactory(CTaskbar *taskbar);
|
||||
|
||||
/**
|
||||
* CNxTermFactory Destructor
|
||||
*/
|
||||
|
||||
inline ~CNxTermFactory(void) { }
|
||||
|
||||
/**
|
||||
* Create a new instance of an CNxTerm (as IApplication).
|
||||
*/
|
||||
|
||||
IApplication *create(void);
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CNXTERM_HXX
|
||||
292
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cstartwindow.hxx
Normal file
292
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cstartwindow.hxx
Normal file
@@ -0,0 +1,292 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/cnxstart.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CSTARTWINDOW_NXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CSTARTWINDOW_NXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
|
||||
#include "graphics/nxwm/iapplication.hxx"
|
||||
#include "graphics/nxwm/capplicationwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class CTaskbar;
|
||||
|
||||
/**
|
||||
* Start window message opcodes and format
|
||||
*/
|
||||
|
||||
enum EStartWindowMessageOpcodes
|
||||
{
|
||||
MSGID_POSITIONAL_CHANGE = 1, /**< Change in window positional data (not used) */
|
||||
MSGID_REDRAW_REQUEST, /**< Request to redraw a portion of the window (not used) */
|
||||
MSGID_MOUSE_INPUT, /**< New mouse input is available */
|
||||
MSGID_KEYBOARD_INPUT, /**< New keyboard input is available */
|
||||
MSGID_DESTROY_APP /**< Destroy the application */
|
||||
};
|
||||
|
||||
struct SStartWindowMessage
|
||||
{
|
||||
enum EStartWindowMessageOpcodes msg_id; /**< The message opcode */
|
||||
FAR void *instance; /**< Object instance. */
|
||||
};
|
||||
|
||||
/**
|
||||
* The well-known name for the Start Window's message queue.
|
||||
*/
|
||||
|
||||
extern FAR const char *g_startWindowMqName;
|
||||
|
||||
/**
|
||||
* This class is the the start window application.
|
||||
*/
|
||||
|
||||
class CStartWindow : public IApplication,
|
||||
protected IApplicationCallback,
|
||||
protected NXWidgets::CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* This structure represents an application and its associated icon image
|
||||
*/
|
||||
|
||||
struct SStartWindowSlot
|
||||
{
|
||||
IApplicationFactory *app; /**< A reference to the icon */
|
||||
NXWidgets::CImage *image; /**< The icon image that goes with the application */
|
||||
};
|
||||
|
||||
/**
|
||||
* CStartWindow state data
|
||||
*/
|
||||
|
||||
CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
|
||||
CApplicationWindow *m_window; /**< Reference to the application window */
|
||||
TNxArray<struct SStartWindowSlot> m_slots; /**< List of apps in the start window */
|
||||
struct nxgl_size_s m_iconSize; /**< A box big enough to hold the largest icon */
|
||||
|
||||
/**
|
||||
* This is the start window task. This function receives window events from
|
||||
* the NX listener threads indirectly through this sequence:
|
||||
*
|
||||
* 1. The NX listener thread receives a windows event. The NX listener thread
|
||||
* which is part of CTaskBar and was created when NX server connection was
|
||||
* established). This event may be a positional change notification, a
|
||||
* redraw request, or mouse or keyboard input.
|
||||
* 2. The NX listener thread handles the message by calling nx_eventhandler().
|
||||
* nx_eventhandler() dispatches the message by calling a method in the
|
||||
* NXWidgets::CCallback instance associated with the window.
|
||||
* NXWidgets::CCallback is a part of the CWidgetControl.
|
||||
* 3. NXWidgets::CCallback calls into NXWidgets::CWidgetControl to process
|
||||
* the event.
|
||||
* 4. NXWidgets::CWidgetControl records the new state data and raises a
|
||||
* window event.
|
||||
* 5. NXWidgets::CWindowEventHandlerList will give the event to
|
||||
* NxWM::CWindowMessenger.
|
||||
* 6. NxWM::CWindowMessenger will send the a message on a well-known message
|
||||
* queue.
|
||||
* 7. This CStartWindow::startWindow task will receive and process that
|
||||
* message.
|
||||
*/
|
||||
|
||||
static int startWindow(int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* Called when the window minimize button is pressed.
|
||||
*/
|
||||
|
||||
void minimize(void);
|
||||
|
||||
/**
|
||||
* Called when the window close button is pressed.
|
||||
*/
|
||||
|
||||
void close(void);
|
||||
|
||||
/**
|
||||
* Calculate the icon bounding box
|
||||
*/
|
||||
|
||||
void getIconBounds(void);
|
||||
|
||||
/**
|
||||
* Stop all applications
|
||||
*/
|
||||
|
||||
void removeAllApplications(void);
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CButtonArray, this is a mouse
|
||||
* button pre-release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CStartWindow Constructor
|
||||
*
|
||||
* @param taskbar. A pointer to the parent task bar instance
|
||||
* @param window. The window to be used by this application.
|
||||
*/
|
||||
|
||||
CStartWindow(CTaskbar *taskbar, CApplicationWindow *window);
|
||||
|
||||
/**
|
||||
* CStartWindow Constructor
|
||||
*/
|
||||
|
||||
~CStartWindow(void);
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
NXWidgets::IBitmap *getIcon(void);
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxString getName(void);
|
||||
|
||||
/**
|
||||
* Start the application.
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
bool run(void);
|
||||
|
||||
/**
|
||||
* Stop the application.
|
||||
*/
|
||||
|
||||
void stop(void);
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
void destroy(void);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy)
|
||||
*/
|
||||
|
||||
void hide(void);
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is call from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
|
||||
/**
|
||||
* Add the application to the start window. The general sequence for
|
||||
* setting up the start window is:
|
||||
*
|
||||
* 1. Call IAppicationFactory::create to a new instance of the application
|
||||
* 2. Call CStartWindow::addApplication to add the application to the
|
||||
* start window.
|
||||
*
|
||||
* @param app. The new application to add to the start window
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool addApplication(IApplicationFactory *app);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CSTARTWINDOW_NXX
|
||||
424
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ctaskbar.hxx
Normal file
424
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ctaskbar.hxx
Normal file
@@ -0,0 +1,424 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/cnxtaskbar.hxx
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NXWM_INCLUDE_CTASKBAR_HXX
|
||||
#define __NXWM_INCLUDE_CTASKBAR_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "graphics/nxwidgets/nxconfig.hxx"
|
||||
#include "graphics/nxwidgets/tnxarray.hxx"
|
||||
#include "graphics/nxwidgets/cnxwindow.hxx"
|
||||
#include "graphics/nxwidgets/cnxserver.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
|
||||
|
||||
#include "graphics/nxglyphs.hxx"
|
||||
|
||||
#include "graphics/nxwm/nxwmconfig.hxx"
|
||||
#include "graphics/nxwm/capplicationwindow.hxx"
|
||||
#include "graphics/nxwm/cfullscreenwindow.hxx"
|
||||
#include "graphics/nxwm/iapplication.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Class Definition
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class describes the NX window manager's task bar. That task bar is,
|
||||
* of course, used to dock active applications. But in NxWM, it is also
|
||||
* the heart of the window manager: It inherits for CNxServer and, hence,
|
||||
* represents the NX server itself. It also then serves as the NxWM
|
||||
* window factory.
|
||||
*
|
||||
* Why do it this way? The only reason is so that if you have an instance
|
||||
* of CTaskbar, you have everything you need to manage new applications.
|
||||
* It might have been a better decision to separate the window factory into
|
||||
* a separate class instead of making the task bar of such central importance
|
||||
* (and I may still do that someday)
|
||||
*/
|
||||
|
||||
class CTaskbar : public NXWidgets::CNxServer,
|
||||
protected NXWidgets::CWidgetEventHandler
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* This structure represents an application and its associated icon image
|
||||
*/
|
||||
|
||||
struct STaskbarSlot
|
||||
{
|
||||
IApplication *app; /**< A reference to the application */
|
||||
NXWidgets::CImage *image; /**< The icon image for the application */
|
||||
};
|
||||
|
||||
/**
|
||||
* Taskbar state
|
||||
*/
|
||||
|
||||
NXWidgets::CNxWindow *m_taskbar; /**< The task bar window */
|
||||
NXWidgets::CBgWindow *m_background; /**< The background window */
|
||||
NXWidgets::CImage *m_backImage; /**< The background image */
|
||||
IApplication *m_topApp; /**< The top application in the hierarchy */
|
||||
TNxArray<struct STaskbarSlot> m_slots; /**< List of application slots in the task bar */
|
||||
bool m_started; /**< True if window manager has been started */
|
||||
|
||||
/**
|
||||
* Create a raw window.
|
||||
*
|
||||
* 1) Create a dumb NXWidgets::CWidgetControl instance (See not).
|
||||
* 2) Pass the dumb NXWidgets::CWindowMessenger instance to the window constructor
|
||||
* that inherits from INxWindow. This will "smarten" the NXWidgets::CWidgetControl
|
||||
* instance with some window knowlede
|
||||
* 3) Call the open() method on the window to display the window.
|
||||
* 4) After that, the fully smartened NXWidgets::CWidgetControl instance can
|
||||
* be used to generate additional widgets by passing it to the
|
||||
* widget constructor
|
||||
*
|
||||
* NOTE: Actually, NxWM uses the CWindowMessenger class that inherits from
|
||||
* CWidgetControl. That class just adds some unrelated messaging capability;
|
||||
* It cohabitates with CWidgetControl only because it needs the CWidgetControl
|
||||
* this point.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxWindow *openRawWindow(void);
|
||||
|
||||
/**
|
||||
* Create a framed application window
|
||||
*
|
||||
* This may be used to provide the window parater to the IApplication constructor
|
||||
*
|
||||
* @return A partially initialized application window instance.
|
||||
*/
|
||||
|
||||
NXWidgets::CNxTkWindow *openFramedWindow(void);
|
||||
|
||||
/**
|
||||
* Set size and position of a window in the application area.
|
||||
*
|
||||
* @param window. The window to be resized and repositioned
|
||||
* @param fullscreen. True: Use full screen
|
||||
*/
|
||||
|
||||
void setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen);
|
||||
|
||||
/**
|
||||
* Create the task bar window.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
virtual bool createTaskbarWindow(void);
|
||||
|
||||
/**
|
||||
* Create the background window.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
virtual bool createBackgroundWindow(void);
|
||||
|
||||
/**
|
||||
* Create the background image.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
virtual bool createBackgroundImage(void);
|
||||
|
||||
/**
|
||||
* (Re-)draw the task bar window.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
virtual bool redrawTaskbarWindow(void);
|
||||
|
||||
/**
|
||||
* Redraw the window at the top of the hierarchy.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
virtual bool redrawTopApplication(void);
|
||||
|
||||
/**
|
||||
* Raise the top window to the top of the NXheirarchy.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
void raiseTopApplication(void);
|
||||
|
||||
/**
|
||||
* (Re-)draw the background window.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
virtual bool redrawBackgroundWindow(void);
|
||||
|
||||
/**
|
||||
* Redraw the last application in the list of application maintained by
|
||||
* the task bar.
|
||||
*
|
||||
* @param app. The new top application to draw
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool redrawApplicationWindow(IApplication *app);
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy)
|
||||
*
|
||||
* @param app. The application to hide
|
||||
*/
|
||||
|
||||
void hideApplicationWindow(IApplication *app);
|
||||
|
||||
/**
|
||||
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
|
||||
|
||||
public:
|
||||
/**
|
||||
* CTaskbar Constructor
|
||||
*
|
||||
* @param hWnd - NX server handle
|
||||
*/
|
||||
|
||||
CTaskbar(void);
|
||||
|
||||
/**
|
||||
* CTaskbar Destructor
|
||||
*/
|
||||
|
||||
~CTaskbar(void);
|
||||
|
||||
/**
|
||||
* Connect to the server
|
||||
*/
|
||||
|
||||
bool connect(void);
|
||||
|
||||
/**
|
||||
* Disconnect from the server
|
||||
*/
|
||||
|
||||
void disconnect(void);
|
||||
|
||||
/**
|
||||
* Initialize task bar. Task bar initialization is separate from
|
||||
* object instantiation so that failures can be reported. The window
|
||||
* manager start-up sequence is:
|
||||
*
|
||||
* 1. Create the CTaskbar instance,
|
||||
* 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
|
||||
* inherits the connect method from CNxServer),
|
||||
* 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
|
||||
* 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
|
||||
* 5. Call CTaskBar::startWindowManager() to start the display with applications in place
|
||||
*
|
||||
* CTaskbar::initWindowManager() prepares the task bar to receive applications.
|
||||
* CTaskBar::startWindowManager() brings the window manager up with those applications
|
||||
* in place.
|
||||
*
|
||||
* @return True if the window was successfully initialized.
|
||||
*/
|
||||
|
||||
bool initWindowManager(void);
|
||||
|
||||
/**
|
||||
* Start the window manager and present the initial displays. The window
|
||||
* manager start-up sequence is:
|
||||
*
|
||||
* 1. Create the CTaskbar instance,
|
||||
* 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
|
||||
* inherits the connect method from CNxServer),
|
||||
* 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
|
||||
* 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
|
||||
* 5. Call CTaskBar::startWindowManager to start the display with applications in place
|
||||
*
|
||||
* CTaskbar::initWindowManager() prepares the task bar to receive applications.
|
||||
* CTaskBar::startWindowManager() brings the window manager up with those applications
|
||||
* in place.
|
||||
*
|
||||
* CTaskBar::startWindowManager() will present the task bar and the background image.
|
||||
* The The initial taskbar will contain only the start window icon.
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool startWindowManager(void);
|
||||
|
||||
/**
|
||||
* Create an normal application window. Creating a normal application in the
|
||||
* start window requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::openApplicationWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
* constructor,
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the
|
||||
* start window.
|
||||
*
|
||||
* When the application is selected from the start window:
|
||||
*
|
||||
* 4. Call CTaskBar::startApplication start the application and bring its window to
|
||||
* the top.
|
||||
*
|
||||
* @param flags. CApplicationWindow flugs for window customization.
|
||||
*/
|
||||
|
||||
CApplicationWindow *openApplicationWindow(uint8_t flags = 0);
|
||||
|
||||
/**
|
||||
* Create a full screen application window. Creating a new full screen application
|
||||
* requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::FullScreenWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
* constructor,
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the
|
||||
* start window.
|
||||
*
|
||||
* When the application is selected from the start window:
|
||||
*
|
||||
* 4. Call CTaskBar::startApplication start the application and bring its window to
|
||||
* the top.
|
||||
*/
|
||||
|
||||
CFullScreenWindow *openFullScreenWindow(void);
|
||||
|
||||
/**
|
||||
* Start an application and add its icon to the taskbar. The applications's
|
||||
* window is brought to the top. Creating a new application in the start
|
||||
* window requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::openApplicationWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
* constructor,
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the start window.
|
||||
*
|
||||
* When the application is selected from the start window:
|
||||
*
|
||||
* 4. Call CTaskBar::startApplication start the application and bring its window to
|
||||
* the top.
|
||||
*
|
||||
* @param app. The new application to add to the task bar
|
||||
* @param minimized. The new application starts in the minimized state
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool startApplication(IApplication *app, bool minimized);
|
||||
|
||||
/**
|
||||
* Move window to the top of the hierarchy and re-draw it. This method
|
||||
* does nothing if the application is minimized.
|
||||
*
|
||||
* @param app. The new application to show
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool topApplication(IApplication *app);
|
||||
|
||||
/**
|
||||
* Maximize an application by moving its window to the top of the hierarchy
|
||||
* and re-drawing it. If the application was already maximized, then this
|
||||
* method is equivalent to topApplication().
|
||||
*
|
||||
* @param app. The new application to add to the task bar
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool maximizeApplication(IApplication *app);
|
||||
|
||||
/**
|
||||
* Minimize an application by moving its window to the bottom of the
|
||||
* and redrawing the next visible application.
|
||||
*
|
||||
* @param app. The new application to add to the task bar
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool minimizeApplication(IApplication *app);
|
||||
|
||||
/**
|
||||
* Destroy an application. Move its window to the bottom and remove its
|
||||
* icon from the task bar.
|
||||
*
|
||||
* @param app. The new application to remove from the task bar
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
bool stopApplication(IApplication *app);
|
||||
|
||||
/**
|
||||
* Get the size of the physical display device as it is known to the task
|
||||
* bar.
|
||||
*
|
||||
* @return The size of the display
|
||||
*/
|
||||
|
||||
void getDisplaySize(FAR struct nxgl_size_s &size);
|
||||
|
||||
/**
|
||||
* Force a redraw of the taskbar and current application.
|
||||
* This should only be necessary if the display loses state due to e.g. powerdown
|
||||
* or other manual intervention.
|
||||
*/
|
||||
|
||||
inline void redraw() { redrawTopApplication(); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // __NXWM_INCLUDE_CTASKBAR_HXX
|
||||
222
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ctouchscreen.hxx
Normal file
222
Ubiquitous/Nuttx/apps/include/graphics/nxwm/ctouchscreen.hxx
Normal file
@@ -0,0 +1,222 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/ctouchscreen.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CTOUCHSCREEN_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CTOUCHSCREEN_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include <semaphore.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <nuttx/input/touchscreen.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxserver.hxx"
|
||||
#include "graphics/nxwm/ccalibration.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* The CTouchscreen class provides the the calibration window and obtains
|
||||
* calibration data.
|
||||
*/
|
||||
|
||||
class CTouchscreen
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The state of the listener thread.
|
||||
*/
|
||||
|
||||
enum EListenerState
|
||||
{
|
||||
LISTENER_NOTRUNNING = 0, /**< The listener thread has not yet been started */
|
||||
LISTENER_STARTED, /**< The listener thread has been started, but is not yet running */
|
||||
LISTENER_RUNNING, /**< The listener thread is running normally */
|
||||
LISTENER_STOPREQUESTED, /**< The listener thread has been requested to stop */
|
||||
LISTENER_TERMINATED, /**< The listener thread terminated normally */
|
||||
LISTENER_FAILED /**< The listener thread terminated abnormally */
|
||||
};
|
||||
|
||||
/**
|
||||
* CTouchscreen state data
|
||||
*/
|
||||
|
||||
NXWidgets::CNxServer *m_server; /**< The current NX server */
|
||||
int m_touchFd; /**< File descriptor of the opened touchscreen device */
|
||||
sem_t m_waitSem; /**< Semaphore the supports waits for touchscreen data */
|
||||
pthread_t m_thread; /**< The listener thread ID */
|
||||
volatile enum EListenerState m_state; /**< The state of the listener thread */
|
||||
volatile bool m_enabled; /**< True: Normal touchscreen processing */
|
||||
volatile bool m_capture; /**< True: There is a thread waiting for raw touch data */
|
||||
volatile bool m_calibrated; /**< True: If have calibration data */
|
||||
struct nxgl_size_s m_windowSize; /**< The size of the physical display */
|
||||
struct SCalibrationData m_calibData; /**< Calibration data */
|
||||
struct touch_sample_s m_sample; /**< In normal mode, touch data is collected here */
|
||||
struct touch_sample_s *m_touch; /**< Points to the current touch data buffer */
|
||||
|
||||
/**
|
||||
* The touchscreen listener thread. This is the entry point of a thread that
|
||||
* listeners for and dispatches touchscreens events to the NX server.
|
||||
*
|
||||
* @param arg. The CTouchscreen 'this' pointer cast to a void*.
|
||||
* @return This function normally does not return but may return NULL on
|
||||
* error conditions.
|
||||
*/
|
||||
|
||||
static FAR void *listener(FAR void *arg);
|
||||
|
||||
/**
|
||||
* Inject touchscreen data into NX as mouse input
|
||||
*
|
||||
* @param sample. The buffer where data was collected.
|
||||
*/
|
||||
|
||||
void handleMouseInput(struct touch_sample_s *sample);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CTouchscreen Constructor
|
||||
*
|
||||
* @param server. An instance of the NX server. This will be needed for
|
||||
* injecting mouse data.
|
||||
* @param windowSize. The size of the physical window in pixels. This
|
||||
* is needed for touchscreen scaling.
|
||||
*/
|
||||
|
||||
CTouchscreen(NXWidgets::CNxServer *server, struct nxgl_size_s *windowSize);
|
||||
|
||||
/**
|
||||
* CTouchscreen Destructor
|
||||
*/
|
||||
|
||||
~CTouchscreen(void);
|
||||
|
||||
/**
|
||||
* Start the touchscreen listener thread.
|
||||
*
|
||||
* @return True if the touchscreen listener thread was correctly started.
|
||||
*/
|
||||
|
||||
bool start(void);
|
||||
|
||||
/**
|
||||
* Enable/disable touchscreen data processing. When enabled, touchscreen events
|
||||
* are calibrated and forwarded to the NX layer which dispatches the touchscreen
|
||||
* events in window-relative positions to the correct NX window.
|
||||
*
|
||||
* When disabled, touchscreen data is not forwarded to NX, but is instead captured
|
||||
* and made available for touchscreen calibration. The touchscreen driver is
|
||||
* initially disabled and must be specifically enabled be begin normal processing.
|
||||
* Normal processing also requires calibration data (see method setCalibrationData)
|
||||
*
|
||||
* @param capture. True enables capture mode; false disables.
|
||||
*/
|
||||
|
||||
inline void setEnabled(bool enable)
|
||||
{
|
||||
// Set the capture flag. m_calibrated must also be set to get to normal
|
||||
// mode where touchscreen data is forwarded to NX.
|
||||
|
||||
m_enabled = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the touchscreen calibrated?
|
||||
*
|
||||
* @return True if the touchscreen has been calibrated.
|
||||
*/
|
||||
|
||||
inline bool isCalibrated(void) const
|
||||
{
|
||||
return m_calibrated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide touchscreen calibration data. If calibration data is received (and
|
||||
* the touchscreen is enabled), then received touchscreen data will be scaled
|
||||
* using the calibration data and forward to the NX layer which dispatches the
|
||||
* touchscreen events in window-relative positions to the correct NX window.
|
||||
*
|
||||
* @param caldata. A reference to the touchscreen data.
|
||||
*/
|
||||
|
||||
void setCalibrationData(const struct SCalibrationData &caldata);
|
||||
|
||||
/**
|
||||
* Recover the calibration data so that it can be saved to non-volatile storage.
|
||||
*
|
||||
* @param data. A reference to the touchscreen data.
|
||||
* @return True if calibration data was successfully returned.
|
||||
*/
|
||||
|
||||
inline bool getCalibrationData(struct SCalibrationData &caldata) const
|
||||
{
|
||||
if (m_calibrated)
|
||||
{
|
||||
caldata = m_calibData;
|
||||
}
|
||||
|
||||
return m_calibrated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture raw driver data. This method will capture mode one raw touchscreen
|
||||
* input. The normal use of this method is for touchscreen calibration.
|
||||
*
|
||||
* This function is not re-entrant: There may be only one thread waiting for
|
||||
* raw touchscreen data.
|
||||
*
|
||||
* @return True if the raw touchscreen data was successfully obtained
|
||||
*/
|
||||
|
||||
bool waitRawTouchData(struct touch_sample_s *touch);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CTOUCHSCREEN_HXX
|
||||
148
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cwindowmessenger.hxx
Normal file
148
Ubiquitous/Nuttx/apps/include/graphics/nxwm/cwindowmessenger.hxx
Normal file
@@ -0,0 +1,148 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/cwindowmessenger.hxx
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_CWINDOWMESSENGER_HXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_CWINDOWMESSENGER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/nx/nxtk.h>
|
||||
#include <nuttx/nx/nxterm.h>
|
||||
|
||||
#include "graphics/nxwidgets/cwindoweventhandler.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetstyle.hxx"
|
||||
#include "graphics/nxwidgets/cwidgetcontrol.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* Forward references.
|
||||
*/
|
||||
|
||||
class IApplication;
|
||||
|
||||
/**
|
||||
* The class CWindowMessenger integrates the widget control with some special
|
||||
* handling of mouse and keyboard inputs needs by NxWM. It use used
|
||||
* in place of CWidgetControl whenever an NxWM window is created.
|
||||
*
|
||||
* CWindowMessenger cohabitates with CWidgetControl only because it needs the
|
||||
* CWidgetControl as an argument in its messaging.
|
||||
*/
|
||||
|
||||
class CWindowMessenger : public NXWidgets::CWindowEventHandler,
|
||||
public NXWidgets::CWidgetControl
|
||||
{
|
||||
private:
|
||||
/** Structure that stores data for the work queue callback. */
|
||||
|
||||
struct work_state_t
|
||||
{
|
||||
work_s work;
|
||||
CWindowMessenger *windowMessenger;
|
||||
void *instance;
|
||||
|
||||
work_state_t() : work() {}
|
||||
};
|
||||
|
||||
/** Work queue callback functions */
|
||||
|
||||
static void inputWorkCallback(FAR void *arg);
|
||||
static void destroyWorkCallback(FAR void *arg);
|
||||
|
||||
#ifdef CONFIG_NX_XYINPUT
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*/
|
||||
|
||||
void handleMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t buttons);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
void handleKeyboardEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window blocked event
|
||||
*
|
||||
* @param arg - User provided argument (see nx_block or nxtk_block)
|
||||
*/
|
||||
|
||||
void handleBlockedEvent(FAR void *arg);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CWindowMessenger Constructor
|
||||
*
|
||||
* @param style The default style that all widgets on this display
|
||||
* should use. If this is not specified, the widget will use the
|
||||
* values stored in the defaultCWidgetStyle object.
|
||||
*/
|
||||
|
||||
CWindowMessenger(FAR const NXWidgets::CWidgetStyle *style =
|
||||
(const NXWidgets::CWidgetStyle *)NULL);
|
||||
|
||||
/**
|
||||
* CWindowMessenger Destructor.
|
||||
*/
|
||||
|
||||
~CWindowMessenger(void);
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_CWINDOWMESSENGER_HXX
|
||||
250
Ubiquitous/Nuttx/apps/include/graphics/nxwm/iapplication.hxx
Normal file
250
Ubiquitous/Nuttx/apps/include/graphics/nxwm/iapplication.hxx
Normal file
@@ -0,0 +1,250 @@
|
||||
/****************************************************************************
|
||||
* apps/include/graphics/nxwm/iapplication.hxx
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
||||
* me be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_GRAPHICS_NXWM_IAPPLICATION_NXX
|
||||
#define __APPS_INCLUDE_GRAPHICS_NXWM_IAPPLICATION_NXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "graphics/nxwidgets/cnxstring.hxx"
|
||||
#include "graphics/nxwidgets/ibitmap.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* Forward references
|
||||
*/
|
||||
|
||||
class IApplicationWindow;
|
||||
|
||||
/**
|
||||
* IApplication provides the abstract base class for each NxWM application.
|
||||
*/
|
||||
|
||||
class IApplication
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* These values (and the accessors that go with them) violate the "purity"
|
||||
* of the base class. These are really part of the task bar implementation:
|
||||
* Each application provides this state information needed by the taskbar.
|
||||
*/
|
||||
|
||||
bool m_minimized; /**< True if the application is minimized */
|
||||
bool m_topapp; /**< True if this application is at the top in the hierarchy */
|
||||
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the IApplication
|
||||
* destructor. We do this because if we delete IApplication, we want the
|
||||
* destructor of the class that inherits from IApplication to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~IApplication(void) { }
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
virtual IApplicationWindow *getWindow(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
virtual NXWidgets::IBitmap *getIcon(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the name string associated with the application
|
||||
*
|
||||
* @return A copy if CNxString that contains the name of the application.
|
||||
*/
|
||||
|
||||
virtual NXWidgets::CNxString getName(void) = 0;
|
||||
|
||||
/**
|
||||
* Start the application (perhaps in the minimized state).
|
||||
*
|
||||
* @return True if the application was successfully started.
|
||||
*/
|
||||
|
||||
virtual bool run(void) = 0;
|
||||
|
||||
/**
|
||||
* Stop the application, put all widgets in a deactivated/disabled state
|
||||
* and wait to see what happens next.
|
||||
*/
|
||||
|
||||
virtual void stop(void) = 0;
|
||||
|
||||
/**
|
||||
* Destroy the application and free all of its resources. This method
|
||||
* will initiate blocking of messages from the NX server. The server
|
||||
* will flush the window message queue and reply with the blocked
|
||||
* message. When the block message is received by CWindowMessenger,
|
||||
* it will send the destroy message to the start window task which
|
||||
* will, finally, safely delete the application.
|
||||
*/
|
||||
|
||||
virtual void destroy(void) = 0;
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy
|
||||
*/
|
||||
|
||||
virtual void hide(void) = 0;
|
||||
|
||||
/**
|
||||
* Redraw the entire window. The application has been maximized or
|
||||
* otherwise moved to the top of the hierarchy. This method is call from
|
||||
* CTaskbar when the application window must be displayed
|
||||
*/
|
||||
|
||||
virtual void redraw(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the application's minimized state
|
||||
*
|
||||
* @param minimized. True if the application is minimized
|
||||
*/
|
||||
|
||||
inline void setMinimized(bool minimized)
|
||||
{
|
||||
m_minimized = minimized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application's top state
|
||||
*
|
||||
* @param topapp. True if the application is the new top application
|
||||
*/
|
||||
|
||||
inline void setTopApplication(bool topapp)
|
||||
{
|
||||
m_topapp = topapp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application's minimized state
|
||||
*
|
||||
* @return True if the application is minimized
|
||||
*/
|
||||
|
||||
inline bool isMinimized(void) const
|
||||
{
|
||||
return m_minimized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is the top application
|
||||
*
|
||||
* @return True if the application is the new top application
|
||||
*/
|
||||
|
||||
inline bool isTopApplication(void) const
|
||||
{
|
||||
return m_topapp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
virtual bool isFullScreen(void) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* IApplicationFactory provides a mechanism for creating multiple instances
|
||||
* of an application.
|
||||
*/
|
||||
|
||||
class IApplicationFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A virtual destructor is required in order to override the IApplicationFactory
|
||||
* destructor. We do this because if we delete IApplicationFactory, we want the
|
||||
* destructor of the class that inherits from IApplication to run, not this
|
||||
* one.
|
||||
*/
|
||||
|
||||
virtual ~IApplicationFactory(void) { }
|
||||
|
||||
/**
|
||||
* Create a new instance of an application.
|
||||
*/
|
||||
|
||||
virtual IApplication *create(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
*
|
||||
* @return An instance if IBitmap that may be used to rend the
|
||||
* application's icon. This is an new IBitmap instance that must
|
||||
* be deleted by the caller when it is no long needed.
|
||||
*/
|
||||
|
||||
virtual NXWidgets::IBitmap *getIcon(void) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_IAPPLICATION_NXX
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user