/* 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_bdr_uniform.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_BDR_UNIFORM   Bord Uniform Widget 
 *
 *  @ingroup groupMW_WGL
 *  @brief Provides definitions and exported function of the widget bord uniform 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_BDR_UNIFORM_H_
#define _U_WGL_BDR_UNIFORM_H_

/*-----------------------------------------------------------------------------
                    include files
 ----------------------------------------------------------------------------*/
#include "u_wgl_common.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------------
                    macros, defines, typedefs, enums
 ----------------------------------------------------------------------------*/
/* specific border commands for uniform border */
/**
This command sets the thickness of the border body.

Input arguments

pv_param1	Specifies the thickness of the border body. This argument must be of type UINT16. Note 
that the thickness can be zero and if the thickness is zero, no border body will be rendered. 

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.
*/
#define WGL_CMD_BDR_UNFM_SET_THICKNESS          WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 0) 

/**
This command retrieves the thickness of the border body.

Input arguments

pv_param2	Reserved. It must be NULL.

Output arguments

pv_param1	Contains the pointer of a single UINT16 buffer to receive the border body's thickness. 
Thus this argument must be of type (UINT16 *) and cannot be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BDR_UNFM_GET_THICKNESS          WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 1) 

/**
This command sets the margin of the inner border area. Refer to 7 for more information about 
inner border area.

Input arguments

pv_param1	Specifies the margin of the inner border area. This argument must be of type (
WGL_BDR_UNFM_MARGIN_T *) and 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_BDR_UNFM_SET_MARGIN             WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 2) 

/**
This command retrieves the margin of the inner border area. Refer to 7 for more information about 
inner border area.

Input arguments

pv_param2	Reserved. It must be NULL.
Output arguments

pv_param1	Contains the pointer of a single WGL_BDR_UNFM_MARGIN_T buffer to receive the margin of 
the inner border area. Thus this argument must be of type (WGL_BDR_UNFM_MARGIN_T *) and cannot be 
NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BDR_UNFM_GET_MARGIN             WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 3) 

/**
This command sets the attributes of border title. 

Input arguments

pv_param1	Specifies the attributes of the border title. This argument must be of type (
WGL_BDR_UNFM_TITLE_INFO_T *) and cannot be NULL.

pv_param2	Reserved. It must be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	At least in one of the following cases:
 1. The argument pv_param1 is NULL.
 2. The Title Styles is invalid
 3. The Font cannot be created
 4. The Reference Rectangle is not a valid rectangle
 5. The specified alignment mode is invalid
 */
#define WGL_CMD_BDR_UNFM_SET_TITLE_INFO         WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 4) 

/**
This command retrieves the attributes of the border title.

Input arguments

pv_param2	Reserved. It must be NULL.

Output arguments

pv_param1	Contains the pointer of a single WGL_BDR_UNFM_TITLE_INFO_T buffer to receive the border 
title's attributes. Thus this argument must be of type (WGL_BDR_UNFM_TITLE_INFO_T *) and cannot 
be NULL.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.
*/
#define WGL_CMD_BDR_UNFM_GET_TITLE_INFO         WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 5) 

/**
This command sets the text of the title.

Input arguments

pv_param1	Specifies the UTF16_T string of the title text. This argument must be of type (UTF16_T *
). If this argument is NULL, the title text will be cleared and in this case the text length 
specified in pv_param2 must be zero.

pv_param2	Specifies the length of the title text counted in UTF16_T character unit. This argument 
must be of type UINT16. If this argument is zero, the title text will be cleared.

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL but the text length specified in pv_param2 is not zero
. 
*/
#define WGL_CMD_BDR_UNFM_SET_TITLE_TEXT         WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 6) 

/** 
This command retrieves the text of the border title.

Input arguments

pv_param2	Contains the size of the UTF16_T string buffer specified in the argument pv_param1. 
Note that the size of the buffer is counted in UTF16_T character unit. The argument must be of 
type UINT16.

Output arguments

pv_param1	Contains the pointer of a UTF16_T buffer to receive the title text. Thus this argument 
must be of type (UTF16_T *) and cannot be NULL. The size of the buffer must be specified in the 
argument pv_param2. 

Returns

WGLR_OK	The function call is successful.

WGLR_INV_ARG	The argument pv_param1 is NULL.

WGLR_BUFFER_NOT_ENOUGH   -The size of the buffer is not big enough for receiving the title text.
*/
#define WGL_CMD_BDR_UNFM_GET_TITLE_TEXT         WGL_MAKE_BORDER_CMD(WGL_BORDER_UNIFORM, 7) 


/* specific color targets for uniform border */
/**Indicates that the color target is the inner border area's color. */
#define WGL_CLR_BDR_UNFM_INNER_BK               (WGL_CLR_WGT_SPF_START+10)  

/**Indicates that the color target is the text of title. */
#define WGL_CLR_BDR_UNFM_TITLE_TEXT             (WGL_CLR_WGT_SPF_START+11)  

/**Indicates that the color target is the text background of title. */
#define WGL_CLR_BDR_UNFM_TITLE_TEXT_BK          (WGL_CLR_WGT_SPF_START+12)  

/*-----------------------------------------------------------------------------
                    structures
 ----------------------------------------------------------------------------*/
/* uniform border margin */
/*------------------------------------------------------------------*/
/*! @struct WGL_BDR_UNFM_MARGIN_T
 *  @brief This structure holds the margin reserved for Uniform Border's inner border area.
 *  @code
 *  typedef struct _WGL_BDR_UNFM_MARGIN_T 
 *  {
 *      INT32           i4_left;
 *      INT32           i4_top;
 *      INT32           i4_right;
 *      INT32           i4_bottom;
 *  } WGL_BDR_UNFM_MARGIN_T;    
 *  @endcode
 *  @li@c  i4_left                                           -Contains the left margin for inner border area.
 *  @li@c  i4_top                                            -Contains the top margin for inner border area.
 *  @li@c  i4_right                                          -Contains the right margin for inner border area.
 *  @li@c  i4_bottom                                         -Contains the bottom margin for inner border area.
 */
/*------------------------------------------------------------------*/
typedef struct _WGL_BDR_UNFM_MARGIN_T 
{
    INT32           i4_left;
    INT32           i4_top;
    INT32           i4_right;
    INT32           i4_bottom;
} WGL_BDR_UNFM_MARGIN_T;    

/* title information */
/**Indicates that the title has no text background. If this style is specified, only the text will 
be rendered and the text background is completely transparent. */
#define WGL_BDR_UNFM_TITLE_STL_TRANSP_BK        (((UINT16)1)<<0)   
/**It is last style.*/
#define WGL_BDR_UNFM_TITLE_STL_LAST_STYLE       WGL_BDR_UNFM_TITLE_STL_TRANSP_BK  
/*------------------------------------------------------------------*/
/*! @struct WGL_BDR_UNFM_TITLE_INFO_T
 *  @brief This structure holds the attributes of title, such as styles, font, reference rectangle and 
alignment of the title.
 *  @code
 *  typedef struct _WGL_BDR_UNFM_TITLE_INFO_T
 *  {
 *      UINT16                  ui2_style;
 *      WGL_FONT_INFO_T         t_font;
 *      GL_RECT_T               t_rc_ref;
 *      UINT8                   ui1_align;
 *  } WGL_BDR_UNFM_TITLE_INFO_T;
 *  @endcode
 *  @li@c  ui2_style                                         -Contains the styles of the title. 
 *  @li@c  t_font                                            -Contains the font information of the title. 
 *  @li@c  t_rc_ref                                          -Contains the reference rectangle for automatically positioning the title.
 *  @li@c  ui1_align                                         -Contains the alignment mode of the title.  
 */
/*------------------------------------------------------------------*/
typedef struct _WGL_BDR_UNFM_TITLE_INFO_T
{
    UINT16                  ui2_style;
    WGL_FONT_INFO_T         t_font;
    GL_RECT_T               t_rc_ref;
    UINT8                   ui1_align;
    
} WGL_BDR_UNFM_TITLE_INFO_T;




#ifdef __cplusplus
}
#endif
                         
#endif

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


