DROPDOWN - Custom (Sample)

From SEGGER Wiki
Revision as of 09:38, 22 April 2020 by Florian (talk | contribs) (Created page with "{| class="wikitable" style="float:right; margin-left: 10px; background-color: #f9f9f9;" ! colspan="2" style="font-weight:bold; font-size:17px; font-family:Arial, Helvetica, sa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
DROPDOWN_Custom.c
DROPDOWN Custom.png
File(s) required
  • DROPDOWN_Custom.c
Runs in simulation Yes
Runs on target Yes
Download DROPDOWN_Custom.c

This sample demonstrates custom drawing of a DROPDOWN widget.

Code

/*********************************************************************
*                    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        : DROPDOWN_Custom.c
Purpose     : This sample shows how to give a custom look to a DROPDOWN
              widget.
Requirements: WindowManager - (x)
              MemoryDevices - ( )
              AntiAliasing  - ( )
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"
#include <stdio.h>

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

/*********************************************************************
*
*       _PropsEnabled: Properties for enabled state of dropdown
*/
static DROPDOWN_SKINFLEX_PROPS _Props = {
  { GUI_RED, GUI_LIGHTRED, GUI_GRAY_C0 },     // [0] Outer color of surrounding frame, [1] Inner color of surrounding frame, [2] Color of area between frame and inner area
  { GUI_GRAY_C0, GUI_GRAY_C8 },               // [0] First (upper) color of upper gradient, [1] Second (lower) color of upper gradient
  { GUI_GRAY_D0, GUI_GRAY_E7 },               // [0] First (upper) color of lower gradient, [1] Second(lower) color of lower gradient
  { GUI_RED },                                // Color of arrow.
  { GUI_YELLOW },                             // Text color.
  { GUI_DARKBLUE },                           // Color of separator.
  5                                           // Radius of rounded corner.
};

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  WM_HWIN hDrop;
  int     i;
  char    acBuffer[32];

  GUI_Init();
  WM_SetDesktopColor(GUI_BLACK);
  //
  // Create and config DROPDOWN widget
  //
  hDrop = DROPDOWN_CreateEx(10, 10, 150, 150, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_DROPDOWN0);
  for(i = 0; i < 10; i++) {
    sprintf(acBuffer, "Item %d", i);
    DROPDOWN_AddString(hDrop, acBuffer);
  }
  //
  // Set skinflex props to widget
  // Different states can have the same props or different props for each state.
  //
  DROPDOWN_SetSkinFlexProps(&_Props, DROPDOWN_SKINFLEX_PI_ENABLED);
  DROPDOWN_SetSkinFlexProps(&_Props, DROPDOWN_SKINFLEX_PI_EXPANDED);
  DROPDOWN_SetSkinFlexProps(&_Props, DROPDOWN_SKINFLEX_PI_FOCUSED);

  while (1) {
    GUI_Delay(100);
  }
}

/*************************** End of file ****************************/