/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * 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 name of the copyright holder 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
 * HOLDER 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.
 *
 *****************************************************************************/

/*----------------------------------------------------------------------------*/
/*! @file u_wgl_button.h 
 *  $RCSfile: $
 *  $Revision: #1 $
 *  $Date: 2015/05/29 $
 *  $Author: brianpc.huang $
 *  
 *  @par Description:
 *         This header file contains public interfaces, constant and type 
 *         definitions of the Widget Library.
 */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/*! @defgroup groupMW_WGL_BUTTON   Button Widget  
 *
 *  @ingroup groupMW_WGL
 *  @brief Provides definitions and exported function of the widget button library.
 *
 *  %MW Application API would be used by TV Application, lot of these APIs would
 *   be wrapped from Exported API
 *
 *  @see groupMW_WGL
 *  @{ 
 */
/*----------------------------------------------------------------------------*/

 
#ifndef _U_WGL_BUTTON_H_
#define _U_WGL_BUTTON_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_wgl.h"
#include "u_wgl_tools.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
#define WGL_BTN_MAX_STRING                      ((UINT16) 128) /**<Indicate the max length of buttom string */

/*Specific Widget Style*/
/**If this style is assigned, it means the Button widget switches its state between pushed and 
unpushed when it receives enter-key-down message; otherwise, it switches to pushed state when it 
receives enter-key-down message, and to unpushed state when it receives enter-key-up message.*/
#define WGL_STL_BTN_CHECKBOX                    (((UINT32)(WGL_STL_WGT_SPF_START))<<0)    

/**If this style is assigned, it means the Button read text from left. */
#define WGL_STL_BTN_READ_TEXT_FROM_LEFT         (((UINT32)(WGL_STL_WGT_SPF_START))<<1)    

/**If this style is assigned, it means the Button read text from right. */
#define WGL_STL_BTN_READ_TEXT_FROM_RIGHT        (((UINT32)(WGL_STL_WGT_SPF_START))<<2)    


/*Display Order*/
#define WGL_BTN_DO_IMG_FIRST                    ((UINT8)0x00)    /**<If this style is assigned, Button's string will follow its image. */
#define WGL_BTN_DO_TEXT_FIRST                   ((UINT8)0x01)    /**<If this style is assigned, Button's image will follow its string. */

/*Specific Command*/
/**
This command is used to change a Button to the pushed/unpushed state.

Input arguments

pv_param1	TRUE to change to pushed state and FALSE to change to unpushed state. 

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 isn't TRUE or FALSE.
*/
#define WGL_CMD_BTN_SET_PUSHED                  WGL_MAKE_WIDGET_CMD(HT_WGL_WIDGET_BUTTON, 0) 

/**
This command is used to check whether a Button is pushed or not.

Input arguments

pv_param1	Pointer to a BOOL variable to receive the result. If it returns TRUE, it means the 
Button is pushed; otherwise, it is unpushed. 

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BTN_GET_PUSHED                  WGL_MAKE_WIDGET_CMD(HT_WGL_WIDGET_BUTTON, 1)    

/**
This command is used to get minimum widget size, which includes minimum sizes of content and 
border. Note: this command isn't supported in this version.

Input arguments

pv_param1	Pointer of a GL_SIZE_T to receive the size. It cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BTN_GET_MIN_SIZE                WGL_MAKE_WIDGET_CMD(HT_WGL_WIDGET_BUTTON, 2)    



/*Specific Command Supported by BUTTON-Content*/
/**
This command is used to set Button's foreground alignment.

Input arguments

pv_param1	Specifies the alignment style. It can be from WGL_AS_LEFT_TOP to WGL_AS_RIGHT_BOTTOM. 
About the explanation of these alignment styles.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The style specified by pv_param1 is invalid.
*/
#define WGL_CMD_BTN_SET_ALIGN                   WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 0)   

/**
This command returns Button's foreground alignment.

Input arguments

pv_param1	Pointer to a UINT8 to receive its alignment style. It cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BTN_GET_ALIGN                   WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 1)   

/**
This command is used to set the string displayed in Button.

Input arguments

pv_param1	Pointer to a UTF16_T string. It must be a null terminated string and cannot be over 
WGL_BTN_MAX_STRING (128, the null character isn't included). If it is NULL, it means to remove 
the old string.

pv_param2	A UINT16 integer to specify the character length of pv_param1 (the null character isn't 
included).

Returns

WGLR_OK	The function call is successful.

WGLR_BUFFER_NOT_ENOUGH	This error is caused when the length specified by pv_param2 is larger than 
WGL_BTN_MAX_STRING.
*/
#define WGL_CMD_BTN_SET_TEXT                    WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 2)   

/**
This command is used to get Button's string.

Input arguments

pv_param1	Pointer to a buffer, which the length should not be less than the string length stored 
in the Button (the null character isn't included).

pv_param2	A UINT16 integer to specify the length in character of pv_param1.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.

WGLR_BUFFER_NOT_ENOUGH	This error is caused when the length specified by pv_param2 is less than 
the string length stored in the Button.
*/
#define WGL_CMD_BTN_GET_TEXT                    WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 3)   

/**
This command is used to set the horizontal interval between Button's string and image.

Input arguments

pv_param1	An INT32 integer specifies the horizontal interval.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.
*/
#define WGL_CMD_BTN_SET_DISTANCE                WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 4)   

/**
This command returns the horizontal interval between Button's string and image.

Input arguments

pv_param1	Pointer to an INT32 variable to receive horizontal interval. It cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BTN_GET_DISTANCE                WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 5)   

/**
This command is used to set the display margin of Button's foreground. The i4_left is for the 
left margin, the i4_right is for the right margin, the i4_top is for the top margin, and the 
i4_bottom is for the bottom margin. All of them cannot be less than 0.

Input arguments

pv_param1	Pointer to a WGL_INSET_T value to specify the display margin. It cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	pv_param1 is NULL, or the sum of i4_left and i4_right isn't less than Icon Static's 
width, or the sum of i4_top and i4_bottom isn't less than Button's height.
*/
#define WGL_CMD_BTN_SET_CNT_INSET               WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 6)   

/**
This command returns the display margin of Button's foreground. The i4_left is the left margin, 
the i4_right is the right margin, the i4_top is the top margin, and the i4_bottom is the bottom 
margin. 

Input arguments

pv_param1	Pointer to a WGL_INSET_T value to receive the display margin. It cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BTN_GET_CNT_INSET               WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 7)   

/**
This command is used to set the display order of a Button.

Input arguments

pv_param1	Specifies the display order. The possible values are WGL_PB_DO_IMG_FIRST and 
WGL_PB_DO_TEXT_FIRST, and WGL_PB_DO_TEXT_FIRST means the display string is followed by display 
image, whereas display image is followed by display string.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The order specified by pv_param1is invalid.
*/
#define WGL_CMD_BTN_SET_ORDER                   WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 8)   

/**
This command returns the display order of a Button.

Input arguments

pv_param1	Pointer to a UINT8 variable to receive the display order. It cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BTN_GET_ORDER                   WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 9)   

/**
This command returns the necessary width of a Button.

Input arguments

pv_param1	The button state.

pv_param2	Point to the width value.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CNT_BTN_GET_NECESSARY_SIZE          WGL_MAKE_CONTENT_CMD(HT_WGL_WIDGET_BUTTON, 10)  


#define BTN_CNT_PRIVATE_START                   11      /**<(WGL_CNT_BTN_GET_NECESSARY_SIZE - WGL_CMD_BTN_SET_ALIGN + 1)*/    


/*Specific Notify Code*/
#define WGL_NC_BTN_PUSHED                       ((UINT32)WGL_NC_WIDGET_SPF_START + 0)    /**< This notification is sent when a Button changes to pushed state.*/
#define WGL_NC_BTN_UNPUSHED                     ((UINT32)WGL_NC_WIDGET_SPF_START + 1)    /**< This notification is sent when a Button changes to unpushed state.*/

/*-----------------------------------------------------------------------------
                    structures
 ----------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------
                    functions
 ----------------------------------------------------------------------------*/



#ifdef __cplusplus
}
#endif

#endif


/*----------------------------------------------------------------------------*/
/*! @} */   /* end of groupMW_WGL_BUTTON*/
/*----------------------------------------------------------------------------*/



