/*********************************************************************
*                    SEGGER Microcontroller GmbH                     *
*        Solutions for real time microcontroller applications        *
**********************************************************************
*                                                                    *
*        (c) 1996 - 2020  SEGGER Microcontroller GmbH                *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
**********************************************************************

** emWin V6.10 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws.   Knowledge of the
source code may not be used to write a similar product.  This file may
only  be used  in accordance  with  a license  and should  not be  re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File        : WIDGET_SkinningProps.c
Purpose     : This sample shows how to give widgets a custom look
              by setting the skinning properties.
Requirements: WindowManager - (x)
              MemoryDevices - ( )
              AntiAliasing  - ( )
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define BUTTON_SIZE 50

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

/*********************************************************************
*
*       _PropsEnabled: Properties for enabled state of button
*/
static BUTTON_SKINFLEX_PROPS _PropsEnabled = {
  { GUI_MAKE_COLOR(0xFF431422), GUI_MAKE_COLOR(0xFFF4D3CC), GUI_MAKE_COLOR(0xFFDF9587) }, // [0] Outer color of surrounding frame, [1] Inner color of surrounding frame, [2] Color of area between frame and inner area
  { GUI_MAKE_COLOR(0xFFE9A99C), GUI_MAKE_COLOR(0xFFDF9587)                             }, // [0] First (upper) color of upper gradient, [1] Second (lower) color of upper gradient
  { GUI_MAKE_COLOR(0xFFD37E6F), GUI_MAKE_COLOR(0xFFDF9587)                             }, // [0] First (upper) color of lower gradient, [1] Second(lower) color of lower gradient
  5                                                                                       // Radius of rounded corner
};

/*********************************************************************
*
*       _PropsPressed: Properties for pressed state of button
*/
static BUTTON_SKINFLEX_PROPS _PropsPressed = {
  { GUI_RED,                    GUI_MAKE_COLOR(0xFF9EB0BA), GUI_MAKE_COLOR(0xFF98D1EF) }, // [0] Outer color of surrounding frame, [1] Inner color of surrounding frame, [2] Color of area between frame and inner area
  { GUI_MAKE_COLOR(0xFFE5F4FC), GUI_MAKE_COLOR(0xFFC4E5F6)                             }, // [0] First (upper) color of upper gradient, [1] Second (lower) color of upper gradient
  { GUI_MAKE_COLOR(0xFF98D1EF), GUI_MAKE_COLOR(0xFF68B3DB)                             }, // [0] First (upper) color of lower gradient, [1] Second(lower) color of lower gradient
  5                                                                                       // Radius of rounded corner
};

/*********************************************************************
*
*       _PropsFocussed: Properties for focussed state of button
*/
static BUTTON_SKINFLEX_PROPS _PropsFocussed = {
  { GUI_YELLOW,                 GUI_MAKE_COLOR(0xFF46D8FB), GUI_MAKE_COLOR(0xFFDFDFDF) }, // [0] Outer color of surrounding frame, [1] Inner color of surrounding frame, [2] Color of area between frame and inner area
  { GUI_MAKE_COLOR(0xFFF3F3F3), GUI_MAKE_COLOR(0xFFECECEC)                             }, // [0] First (upper) color of upper gradient, [1] Second (lower) color of upper gradient
  { GUI_MAKE_COLOR(0xFFDFDFDF), GUI_MAKE_COLOR(0xFFD0D0D0)                             }, // [0] First (upper) color of lower gradient, [1] Second(lower) color of lower gradient
  5                                                                                       // Radius of rounded corner
};

/*********************************************************************
*
*       _PropsDisabled: Properties for disabled state of button
*/
static BUTTON_SKINFLEX_PROPS _PropsDisabled = {
  { GUI_MAKE_COLOR(0xFFADB2B5), GUI_MAKE_COLOR(0xFFFCFCFC), GUI_MAKE_COLOR(0xFFF4F4F4) }, // [0] Outer color of surrounding frame, [1] Inner color of surrounding frame, [2] Color of area between frame and inner area
  { GUI_MAKE_COLOR(0xFFF4F4F4), GUI_MAKE_COLOR(0xFFF4F4F4)                             }, // [0] First (upper) color of upper gradient, [1] Second (lower) color of upper gradient
  { GUI_MAKE_COLOR(0xFFF4F4F4), GUI_MAKE_COLOR(0xFFF4F4F4)                             }, // [0] First (upper) color of lower gradient, [1] Second(lower) color of lower gradient
  5                                                                                       // Radius of rounded corner
};

/*********************************************************************
*
*       _cbWin
*/
static void _cbWin(WM_MESSAGE * pMsg) {
  WM_HWIN hButton;

  switch (pMsg->MsgId) {
  case WM_CREATE:
    //
    // Create a button
    //
    hButton = BUTTON_Create(LCD_GetXSize() / 2 - BUTTON_SIZE / 2, LCD_GetYSize() / 2 - BUTTON_SIZE / 2, BUTTON_SIZE, BUTTON_SIZE, GUI_ID_BUTTON0, WM_CF_SHOW);
    //
    // Set BUTTON_SKINFLEX_PROPS for different states
    // (Not all states have to be set.)
    //
    BUTTON_SetSkinFlexProps(&_PropsEnabled,  BUTTON_SKINFLEX_PI_ENABLED);
    BUTTON_SetSkinFlexProps(&_PropsDisabled, BUTTON_SKINFLEX_PI_DISABLED);
    BUTTON_SetSkinFlexProps(&_PropsFocussed, BUTTON_SKINFLEX_PI_FOCUSSED);
    BUTTON_SetSkinFlexProps(&_PropsPressed,  BUTTON_SKINFLEX_PI_PRESSED);
    break;
  case WM_PAINT:
    GUI_SetColor(GUI_BLACK);
    GUI_Clear();
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  //
  // Init emWin.
  //
  GUI_Init();
  //
  // Create parent window.
  //
  WM_CreateWindow(0, 0, LCD_GetXSize(), LCD_GetYSize(), WM_CF_SHOW, _cbWin, 0);

  while (1) {
    GUI_Delay(100);
  }
}

/*************************** End of file ****************************/