CHECKBOX - Custom (Sample)

From SEGGER Wiki
Jump to: navigation, search
CHECKBOX_Custom.c
CHECKBOX Custom.png
File(s) required
  • CHECKBOX_Custom.c
Runs in simulation Yes
Runs on target Yes
Download CHECKBOX_Custom.c

This sample demonstrates custom drawing of a CHECKBOX widget.

Demo

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        : CHECKBOX_Custom.c
Purpose     : Sample that demonstrates the usage of CHECKBOX widgets
              in emWin.
Requirements: WindowManager - (x)
              MemoryDevices - ( )
              AntiAliasing  - ( )
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/
static const CHECKBOX_SKINFLEX_PROPS _PropsEnabled = {
  { GUI_BLUE, GUI_WHITE, GUI_MAGENTA },
  { GUI_GRAY_3F, GUI_GRAY_AA },
  GUI_RED,
  20
};

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  CHECKBOX_Handle hBox;

  //
  // Init GUI
  //
  GUI_Init();
  GUI_SetBkColor(GUI_WHITE);
  GUI_Clear();
  //
  // Create checkbox widget
  //
  hBox = CHECKBOX_CreateEx(10, 10, 100, 50, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_CHECK0);
  CHECKBOX_SetText(hBox, "Check");
  CHECKBOX_SetBoxBkColor(hBox, GUI_WHITE, CHECKBOX_CI_ENABLED);
  //
  // Set skinning properties
  //
  CHECKBOX_SetSkinFlexProps(&_PropsEnabled, CHECKBOX_SKINFLEX_PI_ENABLED);
  //
  // Manually set the button size property
  //
  CHECKBOX_SetSkinFlexButtonSize(hBox, 40);

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

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