?? widget_treeviewtryit.c
字號:
/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2007 SEGGER Microcontroller Systeme GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V4.14 - 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_TreeviewTryit.c
Purpose : Demonstrates the use of the TREEVIEW widget
----------------------------------------------------------------------
*/
#include <stddef.h>
#include "DIALOG.h"
#include "TREEVIEW.h"
#include "MULTIPAGE.h"
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/*********************************************************************
*
* _aMain
*
* Purpose:
* Main window containing the two treeviews and a multipage widget
*/
static const GUI_WIDGET_CREATE_INFO _aMain[] = {
{ WINDOW_CreateIndirect, NULL, 0, 0, 0, 320, 240 },
{ TEXT_CreateIndirect, "Treeview TryIt", GUI_ID_TEXT0, 160, 0, 160, 20 },
{ TREEVIEW_CreateIndirect, NULL, GUI_ID_TREEVIEW0, 0, 0, 160, 220 },
{ TREEVIEW_CreateIndirect, NULL, GUI_ID_TREEVIEW1, 0, 220, 160, 20 },
{ MULTIPAGE_CreateIndirect, NULL, GUI_ID_MULTIPAGE0, 160, 20, 160, 220 },
};
/*********************************************************************
*
* _aPage0
*
* Purpose:
* First page of the multipage widget for setting the widget properties
*/
static const GUI_WIDGET_CREATE_INFO _aPage0[] = {
{ WINDOW_CreateIndirect, NULL, 0, 0, 0, 156, 192 },
{ TEXT_CreateIndirect, "Selection", 0, 5, 10, 100, 15 },
{ RADIO_CreateIndirect, NULL, GUI_ID_RADIO0, 5, 30, 100, 0, 0, 2 },
{ TEXT_CreateIndirect, "Lines", 0, 5, 70, 100, 15 },
{ RADIO_CreateIndirect, NULL, GUI_ID_RADIO1, 5, 90, 100, 0, 0, 2 },
{ TEXT_CreateIndirect, "Font", 0, 5, 130, 100, 15 },
{ RADIO_CreateIndirect, NULL, GUI_ID_RADIO4, 5, 150, 100, 0, 0, 2 },
{ TEXT_CreateIndirect, "H", 0, 92, 10, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "V", 0, 107, 10, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "Scroll", 0, 122, 10, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "Auto", 0, 122, 30, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "Off", 0, 122, 50, 50, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "On", 0, 122, 70, 50, 15, TEXT_CF_LEFT },
{ RADIO_CreateIndirect, NULL, GUI_ID_RADIO2, 87, 30, 0, 0, 0, 3 },
{ RADIO_CreateIndirect, NULL, GUI_ID_RADIO3, 102, 30, 0, 0, 0, 3 },
};
/*********************************************************************
*
* _aPage1
*
* Purpose:
* Second page of the multipage widget for playing with the data
*/
static const GUI_WIDGET_CREATE_INFO _aPage1[] = {
{ WINDOW_CreateIndirect, NULL, 0, 0, 0, 156, 192 },
{ BUTTON_CreateIndirect, "Delete item", GUI_ID_BUTTON0, 5, 10, 140, 18 },
{ BUTTON_CreateIndirect, "Detach item", GUI_ID_BUTTON1, 5, 28, 140, 18 },
{ BUTTON_CreateIndirect, "Attach item", GUI_ID_BUTTON2, 5, 46, 140, 18 },
{ BUTTON_CreateIndirect, "Move up", GUI_ID_BUTTON3, 5, 64, 140, 18 },
{ BUTTON_CreateIndirect, "Move down", GUI_ID_BUTTON4, 5, 82, 140, 18 },
{ BUTTON_CreateIndirect, "New node", GUI_ID_BUTTON5, 5, 100, 140, 18 },
{ BUTTON_CreateIndirect, "New leaf", GUI_ID_BUTTON6, 5, 118, 140, 18 },
{ BUTTON_CreateIndirect, "Set leaf bitmap", GUI_ID_BUTTON7, 5, 136, 140, 18 },
{ BUTTON_CreateIndirect, "Set open bitmap", GUI_ID_BUTTON8, 5, 154, 140, 18 },
{ BUTTON_CreateIndirect, "Set closed bitmap", GUI_ID_BUTTON9, 5, 172, 140, 18 },
};
/*********************************************************************
*
* _bmSmilie
*/
static const GUI_COLOR _ColorsSmilie[] = {
0xFFFFFF,0x000000,0x70FF70
};
static const GUI_LOGPALETTE _PalSmilie = {
3, /* number of entries */
1, /* Has transparency */
&_ColorsSmilie[0]
};
static const unsigned char _acSmilie[] = {
0x00, 0x55, 0x40, 0x00,
0x01, 0xAA, 0x90, 0x00,
0x06, 0xAA, 0xA4, 0x00,
0x19, 0x6A, 0x59, 0x00,
0x69, 0x6A, 0x5A, 0x40,
0x6A, 0xA6, 0xAA, 0x40,
0x6A, 0xA6, 0xAA, 0x40,
0x6A, 0xA6, 0xAA, 0x40,
0x6A, 0xAA, 0xAA, 0x40,
0x1A, 0x6A, 0x69, 0x00,
0x06, 0x95, 0xA4, 0x00,
0x01, 0xAA, 0x90, 0x00,
0x00, 0x55, 0x40, 0x00
};
static const GUI_BITMAP _bmSmilie = {
13, /* XSize */
13, /* YSize */
4, /* BytesPerLine */
2, /* BitsPerPixel */
_acSmilie, /* Pointer to picture data (indices) */
&_PalSmilie /* Pointer to palette */
};
/*********************************************************************
*
* _bmBookOpen
*/
static GUI_CONST_STORAGE GUI_COLOR _ColorsBookOpen[] = {
0x0000FF,0xFFFFFF,0x000000,0x008000
,0x808080,0xC0C0C0
};
static GUI_CONST_STORAGE GUI_LOGPALETTE _PalBookOpen = {
6, /* number of entries */
1, /* Has transparency */
&_ColorsBookOpen[0]
};
static GUI_CONST_STORAGE unsigned char _acBookOpen[] = {
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x23, 0x15, 0x40, 0x00, 0x04, 0x44, 0x00, 0x00,
0x23, 0x11, 0x40, 0x04, 0x41, 0x14, 0x00, 0x00,
0x23, 0x11, 0x54, 0x41, 0x11, 0x14, 0x22, 0x00,
0x23, 0x11, 0x12, 0x51, 0x11, 0x14, 0x13, 0x20,
0x23, 0x11, 0x12, 0x51, 0x11, 0x14, 0x13, 0x20,
0x23, 0x11, 0x12, 0x51, 0x11, 0x14, 0x13, 0x20,
0x23, 0x11, 0x12, 0x51, 0x11, 0x14, 0x13, 0x20,
0x23, 0x11, 0x12, 0x51, 0x11, 0x14, 0x13, 0x20,
0x23, 0x31, 0x12, 0x51, 0x11, 0x45, 0x13, 0x20,
0x02, 0x33, 0x12, 0x51, 0x44, 0x51, 0x13, 0x20,
0x00, 0x23, 0x12, 0x44, 0x51, 0x11, 0x13, 0x20,
0x00, 0x02, 0x33, 0x33, 0x33, 0x33, 0x33, 0x20,
0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20
};
GUI_CONST_STORAGE GUI_BITMAP _bmBookOpen = {
15, /* XSize */
15, /* YSize */
8, /* BytesPerLine */
4, /* BitsPerPixel */
_acBookOpen, /* Pointer to picture data (indices) */
&_PalBookOpen /* Pointer to palette */
};
/*********************************************************************
*
* _bmBookClosed
*/
static GUI_CONST_STORAGE GUI_COLOR _ColorsBookClosed[] = {
0x0000FF,0x008000,0x000000,0xC0C0C0
};
static GUI_CONST_STORAGE GUI_LOGPALETTE _PalBookClosed = {
4, /* number of entries */
1, /* Has transparency */
&_ColorsBookClosed[0]
};
static GUI_CONST_STORAGE unsigned char _acBookClosed[] = {
0x00, 0x02, 0x80, 0x00,
0x00, 0x29, 0x60, 0x00,
0x02, 0x95, 0x58, 0x00,
0x29, 0x55, 0x56, 0x00,
0x95, 0x55, 0x55, 0x80,
0xA5, 0x55, 0x55, 0x60,
0x99, 0x55, 0x55, 0x58,
0x96, 0x55, 0x55, 0x5A,
0x95, 0x95, 0x55, 0xAC,
0x25, 0x65, 0x5A, 0xFC,
0x09, 0x59, 0xAF, 0xFA,
0x02, 0x56, 0xFF, 0xE8,
0x00, 0x96, 0xFE, 0x80,
0x00, 0x26, 0xE8, 0x00,
0x00, 0x0A, 0x80, 0x00
};
GUI_CONST_STORAGE GUI_BITMAP _bmBookClosed = {
16, /* XSize */
15, /* YSize */
4, /* BytesPerLine */
2, /* BitsPerPixel */
_acBookClosed, /* Pointer to picture data (indices) */
&_PalBookClosed /* Pointer to palette */
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _cbPage0
*
* Purpose:
* Callback routine for the first page of the multipage widget
*/
static void _cbPage0(WM_MESSAGE * pMsg) {
WM_HWIN hItem, hDlg, hTree;
int Sel, NCode, Id;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_NOTIFY_PARENT:
hTree = WM_GetDialogItem(WM_GetFirstChild(WM_HBKWIN), GUI_ID_TREEVIEW0);
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
hItem = WM_GetDialogItem(hDlg, Id);
switch (Id) {
case GUI_ID_RADIO0: /* Select the selection mode */
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
Sel = RADIO_GetValue(hItem);
TREEVIEW_SetSelMode(hTree, (Sel == 1) ? TREEVIEW_SELMODE_ROW : TREEVIEW_SELMODE_TEXT);
break;
}
break;
case GUI_ID_RADIO1: /* Set the visibility of the lines */
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
Sel = RADIO_GetValue(hItem);
TREEVIEW_SetHasLines(hTree, (Sel == 1) ? 1 : 0);
break;
}
break;
case GUI_ID_RADIO2: /* Manage horizontal scrollbar */
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
Sel = RADIO_GetValue(hItem);
if (Sel == 1) {
WM_SetScrollbarH(hTree, 0);
}
TREEVIEW_SetAutoScrollH(hTree, (Sel == 0) ? 1 : 0);
if (Sel == 2) {
SCROLLBAR_CreateAttached(hTree, 0);
}
break;
}
break;
case GUI_ID_RADIO3: /* Manage vertical scrollbar */
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
Sel = RADIO_GetValue(hItem);
if (Sel == 1) {
WM_SetScrollbarV(hTree, 0);
}
TREEVIEW_SetAutoScrollV(hTree, (Sel == 0) ? 1 : 0);
if (Sel == 2) {
SCROLLBAR_CreateAttached(hTree, WIDGET_CF_VERTICAL);
}
break;
}
break;
case GUI_ID_RADIO4: /* Manage font */
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
Sel = RADIO_GetValue(hItem);
TREEVIEW_SetFont(hTree, (Sel == 1) ? &GUI_Font24B_1: &GUI_Font13_1);
break;
}
break;
}
break;
case WM_INIT_DIALOG: /* Initialize the items of the dialog */
hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
RADIO_SetText(hItem, "Text select", 0);
RADIO_SetText(hItem, "Row select", 1);
RADIO_SetValue(hItem, 1);
hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO1);
RADIO_SetText(hItem, "Off", 0);
RADIO_SetText(hItem, "On", 1);
RADIO_SetValue(hItem, 1);
hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO2);
RADIO_SetValue(hItem, 0);
hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO4);
RADIO_SetText(hItem, "Small font", 0);
RADIO_SetText(hItem, "Large font", 1);
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* _cbPage1
*
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -