📄 messagebox.lst
字号:
C51 COMPILER V8.05a MESSAGEBOX 04/11/2008 14:19:37 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE MESSAGEBOX
OBJECT MODULE PLACED IN messagebox.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Widget\messagebox.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXT
-END PRINT(.\messagebox.lst) OBJECT(messagebox.obj)
line level source
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ----------------------------------------------------------------------
15 File : ProgBar.c
16 Purpose : Progress bar for emWin GSC
17 ---------------------------END-OF-HEADER------------------------------
18 */
19
20
21 #include <string.h> /* for memset */
22 #include "gui\Core\GUI.h"
23 #include "BUTTON.h"
24 #include "FRAMEWIN.h"
25 #include "TEXT.h"
26 #include "DIALOG.h"
27
28 #if GUI_WINSUPPORT
/*********************************************************************
*
* Defaults
*
**********************************************************************
*/
#ifndef MESSAGEBOX_BORDER
#define MESSAGEBOX_BORDER 4
#endif
#ifndef MESSAGEBOX_XSIZEOK
#define MESSAGEBOX_XSIZEOK 50
#endif
#ifndef MESSAGEBOX_YSIZEOK
#define MESSAGEBOX_YSIZEOK 20
#endif
#ifndef MESSAGEBOX_BKCOLOR
#define MESSAGEBOX_BKCOLOR GUI_WHITE
#endif
#define ID_FRAME 100
C51 COMPILER V8.05a MESSAGEBOX 04/11/2008 14:19:37 PAGE 2
/*********************************************************************
*
* Static functions
*
**********************************************************************
*/
static WM_RESULT _MESSAGEBOX_cbCallback(WM_MESSAGE * pMsg) {
WM_HWIN hWin = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
FRAMEWIN_SetClientColor(hWin, MESSAGEBOX_BKCOLOR);
break;
case WM_KEY:
{
int Key = ((WM_KEY_INFO*)(pMsg->Data.p))->Key;
switch (Key) {
case GUI_KEY_ESCAPE:
GUI_EndDialog(hWin, 1); /* End dialog with return value 1 if <ESC> is pressed */
break;
case GUI_KEY_ENTER:
GUI_EndDialog(hWin, 0); /* End dialog with return value 0 if <ENTER> is pressed */
break;
}
}
break;
case WM_NOTIFY_PARENT:
{
int NCode = pMsg->Data.v; /* Get notification code */
int Id = WM_GetId(pMsg->hWinSrc); /* Get control ID */
switch (NCode) {
case WM_NOTIFICATION_RELEASED: /* React only if released */
if (Id == GUI_ID_OK) {
GUI_EndDialog(hWin, 0); /* End dialog with return value 0 if OK */
}
break;
}
}
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* Exported routines
*
**********************************************************************
*/
int GUI_MessageBox(const char * sMessage, const char * sCaption, int Flags) {
GUI_WIDGET_CREATE_INFO _aDialogCreate[3]; /* 0: FrameWin, 1: Text, 2
-: Button */
int BorderSize = FRAMEWIN_GetDefaultBorderSize(); /* Default border size of
-frame window */
int xSizeFrame = MESSAGEBOX_XSIZEOK + 2 * BorderSize + MESSAGEBOX_BORDER * 2; /* XSize of frame window *
-/
int ySizeFrame; /* YSize of frame window *
-/
int x0, y0; /* Position of frame windo
-w */
C51 COMPILER V8.05a MESSAGEBOX 04/11/2008 14:19:37 PAGE 3
int xSizeMessage; /* Length in pixels of mes
-sage */
int xSizeCaption; /* Length in pixels of cap
-tion */
int ySizeCaption; /* YSize of caption */
int ySizeMessage; /* YSize of message */
GUI_RECT Rect;
const GUI_FONT * pOldFont;
/* Zeroinit variables */
memset(_aDialogCreate, 0, sizeof(_aDialogCreate));
/* Get dimension of message */
pOldFont = GUI_SetFont(TEXT_GetDefaultFont());
GUI_GetTextExtend(&Rect, sMessage, 255);
xSizeMessage = Rect.x1 - Rect.x0 + MESSAGEBOX_BORDER * 2;
ySizeMessage = Rect.y1 - Rect.y0 + 1;
if (xSizeFrame < (xSizeMessage + 4 + MESSAGEBOX_BORDER * 2))
xSizeFrame = xSizeMessage + 4 + MESSAGEBOX_BORDER * 2;
ySizeCaption = GUI_GetYSizeOfFont(FRAMEWIN_GetDefaultFont());
if (ySizeCaption < FRAMEWIN_GetDefaultCaptionSize())
ySizeCaption = FRAMEWIN_GetDefaultCaptionSize();
ySizeFrame = ySizeMessage + /* size of message */
MESSAGEBOX_YSIZEOK + /* size of button */
ySizeCaption + /* caption size */
MESSAGEBOX_BORDER * 3 + /* inner border - text, text - button, button - bottom */
BorderSize * 2 + /* top & bottom border */
1; /* inner border */
/* Get xsize of caption */
xSizeCaption = GUI_GetStringDistX(sCaption);
if (xSizeFrame < xSizeCaption + BorderSize * 2)
xSizeFrame = xSizeCaption + BorderSize * 2;
/* Check maximum */
if (xSizeFrame > LCD_GET_XSIZE())
xSizeFrame = LCD_GET_XSIZE();
if (ySizeFrame > LCD_GET_YSIZE())
ySizeFrame = LCD_GET_YSIZE();
/* Calculate position of framewin */
x0 = (LCD_GET_XSIZE() - xSizeFrame) / 2;
y0 = (LCD_GET_YSIZE() - ySizeFrame) / 2;
/* Fill frame win ressource */
_aDialogCreate[0].pfCreateIndirect = FRAMEWIN_CreateIndirect;
_aDialogCreate[0].pName = sCaption;
_aDialogCreate[0].x0 = x0;
_aDialogCreate[0].y0 = y0;
_aDialogCreate[0].xSize = xSizeFrame;
_aDialogCreate[0].ySize = ySizeFrame;
if (Flags & GUI_MESSAGEBOX_CF_MOVEABLE) {
_aDialogCreate[0].Flags = FRAMEWIN_CF_MOVEABLE;
}
/* Fill text ressource */
_aDialogCreate[1].pfCreateIndirect = TEXT_CreateIndirect;
_aDialogCreate[1].pName = sMessage;
_aDialogCreate[1].x0 = (xSizeFrame - xSizeMessage - BorderSize * 2) / 2;
_aDialogCreate[1].y0 = MESSAGEBOX_BORDER;
_aDialogCreate[1].xSize = xSizeMessage;
_aDialogCreate[1].ySize = ySizeMessage;
_aDialogCreate[1].Para = GUI_TA_TOP | GUI_TA_HCENTER;
/* Fill button ressource */
_aDialogCreate[2].pfCreateIndirect = BUTTON_CreateIndirect;
_aDialogCreate[2].pName = "OK";
_aDialogCreate[2].Id = GUI_ID_OK;
_aDialogCreate[2].x0 = (xSizeFrame - MESSAGEBOX_XSIZEOK - BorderSize * 2) / 2;
_aDialogCreate[2].y0 = MESSAGEBOX_BORDER * 2 + ySizeMessage;
C51 COMPILER V8.05a MESSAGEBOX 04/11/2008 14:19:37 PAGE 4
_aDialogCreate[2].xSize = MESSAGEBOX_XSIZEOK;
_aDialogCreate[2].ySize = MESSAGEBOX_YSIZEOK;
/* Exec dialog */
GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _MESSAGEBOX_cbCallback, 0, 0, 0);
GUI_SetFont(pOldFont);
return 0;
}
#else
181
182 void GUI_MessageBox_C(void) {} /* avoid empty object files */
183
184 #endif /* GUI_WINSUPPORT */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -