CALENDAR (Sample)
CALENDAR_Usage.c | |
---|---|
File(s) required |
|
Runs in simulation | Yes |
Runs on target | Yes |
Download | CALENDAR_Usage.c |
This sample demonstrates the usage of CALENDAR dialogs.
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 : CALENDAR_Usage.c
Purpose : Sample that demonstrates the usage of CALENDAR
dialogues in emWin.
Requirements: WindowManager - (x)
MemoryDevices - ( )
AntiAliasing - ( )
VNC-Server - ( )
PNG-Library - ( )
TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/
#include "DIALOG.h"
#include <time.h>
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define HEADER_SIZE_Y 30 // default is 25
#define CELL_SIZE_X 22 // default is 18
#define CELL_SIZE_Y 16 // default is 13
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
WM_HWIN hCal;
CALENDAR_DATE Date;
time_t t;
struct tm Time;
//
// Init GUI
//
GUI_Init();
//
// Get current date
//
t = time(NULL);
Time = *localtime(&t);
//
// Change default apperance of the calendar BEFORE we create the dialogue.
//
CALENDAR_SetDefaultBkColor(CALENDAR_CI_SEL, GUI_LIGHTBLUE);
CALENDAR_SetDefaultColor(CALENDAR_CI_FRAME, GUI_RED);
CALENDAR_SetDefaultBkColor(CALENDAR_CI_WEEKEND, GUI_GRAY_C8);
//
// Change default size of calendar
//
CALENDAR_SetDefaultSize(CALENDAR_SI_HEADER, HEADER_SIZE_Y);
CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_X, CELL_SIZE_X);
CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_Y, CELL_SIZE_Y);
//
// Change default fonts to be used
//
CALENDAR_SetDefaultFont(CALENDAR_FI_CONTENT, &GUI_Font16_1);
CALENDAR_SetDefaultFont(CALENDAR_FI_HEADER, &GUI_Font16B_1);
//
// Create calendar dialogue with monday as the first day of the week
//
hCal = CALENDAR_Create(WM_HBKWIN, 10, 10, 2000, 1, 1, 2, GUI_ID_CALENDAR0, WM_CF_SHOW);
//
// Set the date to the current day
//
Date.Year = Time.tm_year + 1900;
Date.Month = Time.tm_mon + 1;
Date.Day = Time.tm_mday;
CALENDAR_SetDate(hCal, &Date);
//
// Select this date so the calender draws the month of this date
//
CALENDAR_SetSel(hCal, &Date);
//
// Set the selected day to tomorrow
//
CALENDAR_GetDate(hCal, &Date);
Date.Day++;
CALENDAR_SetSel(hCal, &Date);
while (1) {
GUI_Delay(100);
}
}
/*************************** End of file ****************************/