Difference between revisions of "MULTIPAGE - Custom (Sample)"
(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...") |
|||
Line 20: | Line 20: | ||
This sample demonstrates custom drawing of a MULTIPAGE widget. |
This sample demonstrates custom drawing of a MULTIPAGE widget. |
||
+ | |||
+ | == Demo == |
||
+ | |||
+ | <html><iframe src="https://wiki.segger.com/demo/emwin/MULTIPAGE_Custom/MULTIPAGE_Custom.html" width="480" height="272" style="border: 1px #c0c0c0 solid;" marginwidth="0" marginheight="0" hspace="0" vspace="0" scrolling="no"> </iframe></html> |
||
== Code == |
== Code == |
Latest revision as of 16:28, 7 March 2022
MULTIPAGE_Custom.c | |
---|---|
File(s) required |
|
Runs in simulation | Yes |
Runs on target | Yes |
Download | MULTIPAGE_Custom.c |
This sample demonstrates custom drawing of a MULTIPAGE 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 : MULTIPAGE_Custom.c
Purpose : Sample that demonstrates how custom drawing of a
MULTIPAGE widget works in emWin.
Requirements: WindowManager - (x)
MemoryDevices - ( )
AntiAliasing - ( )
VNC-Server - ( )
PNG-Library - ( )
TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/
#include "DIALOG.h"
#include <stdio.h>
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* Dialog resource
*
* These tables contain the information required to create each page
* of the multipage widget.
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
{ WINDOW_CreateIndirect, "Dialog 1", 0, 0, 0, 260, 100, FRAMEWIN_CF_MOVEABLE },
{ BUTTON_CreateIndirect, "Button 1", GUI_ID_BUTTON0, 5, 30, 100, 20, 0 },
{ TEXT_CreateIndirect, "Dialog 1", 0, 5, 10, 50, 20, TEXT_CF_LEFT }
};
static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
{ WINDOW_CreateIndirect, "Dialog 2", 0, 0, 0, 260, 100, FRAMEWIN_CF_MOVEABLE },
{ CHECKBOX_CreateIndirect, "", GUI_ID_CHECK0, 5, 30, 0, 0, 0 },
{ CHECKBOX_CreateIndirect, "", GUI_ID_CHECK1, 5, 50, 0, 0, 0 },
{ TEXT_CreateIndirect, "Check1", GUI_ID_TEXT0, 25, 30, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "Check2", GUI_ID_TEXT1, 25, 50, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "Dialog 2", 0, 5, 10, 50, 20, TEXT_CF_LEFT }
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _MultipageSkin
*/
static int _MultipageSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) {
char acBuffer[32];
switch (pDrawItemInfo->Cmd) {
case WIDGET_ITEM_CREATE:
//
// We land here right after the widget was created.
// Only useful if the skinning routine is set as the default skin.
//
return 0;
case WIDGET_ITEM_DRAW_BACKGROUND:
//
// Draw background of item (tab)
//
GUI_DrawGradientV(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, GUI_GRAY_7C, GUI_GRAY_AA);
GUI_SetColor(GUI_BLACK);
return 0;
case WIDGET_ITEM_DRAW_FRAME:
//
// Draw frame around the widget
//
GUI_SetColor(GUI_BLACK);
GUI_DrawRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1);
return 0;
case WIDGET_ITEM_DRAW_TEXT:
//
// Draw item text
//
MULTIPAGE_GetPageText(pDrawItemInfo->hWin, pDrawItemInfo->ItemIndex, acBuffer, sizeof(acBuffer));
GUI_SetTextMode(GUI_TM_TRANS);
GUI_DispStringAt(acBuffer, pDrawItemInfo->x0, pDrawItemInfo->y0 + 3);
return 0;
default:
return MULTIPAGE_DrawSkinFlex(pDrawItemInfo);
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
MULTIPAGE_Handle hMulti;
WM_HWIN hDialog;
//
// Init GUI
//
GUI_Init();
WM_SetDesktopColor(GUI_WHITE);
//
// Enable multi-buffering
//
WM_MULTIBUF_Enable(1);
//
// Create multipage widget
//
hMulti = MULTIPAGE_CreateEx(10, 10, 250, 150, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_MULTIPAGE0);
//
// Create dialog windows to add them as pages
//
hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), NULL, WM_UNATTACHED, 0, 0);
MULTIPAGE_AddPage(hMulti, hDialog, "Page 1");
hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL, WM_UNATTACHED, 0, 0);
MULTIPAGE_AddPage(hMulti, hDialog, "Page 2");
//
// Set skinning routine
//
MULTIPAGE_SetSkin(hMulti, _MultipageSkin);
while (1) {
GUI_Delay(100);
}
}
/*************************** End of file ****************************/