ZLGGUI源碼
單片機源程序如下:
- /****************************************************************************************
- * 文件名:WINDOW.C
- * 功能:窗口管理。將進行各種窗口的給制及窗口內部控制。
- * 作者:黃紹斌
- * 日期:2004.02.26
- * 備注:
- ****************************************************************************************/
- #include "config.h"
- #if GUI_WINDOW_EN==1
- /****************************************************************************
- * 名稱:GUI_WindowsDraw()
- * 功能:顯示窗口。根據提供的窗口參數進行畫窗口。
- * 入口參數:win 窗口句柄
- * 出口參數:返回0表示操作失敗,返回1表示操作成功
- ****************************************************************************/
- uint8 GUI_WindowsDraw(WINDOWS *win)
- { uint8 *str;
- int32 bak, bak1, bak2;
-
- /* 參數過濾,若窗口起出范圍,則返回0 */
- if( ( (win->with)<20 ) || ( (win->hight)<20 ) ) return(0); // 寬度、高度檢查,限制最小窗口
- if( (win->x + win->with ) > GUI_LCM_XMAX ) return(0); // 窗口寬度是否溢出
- if( (win->y + win->hight ) > GUI_LCM_YMAX ) return(0); // 窗口高度是否溢出
-
- /* 開始畫窗口 */
- GUI_RectangleFill(win->x, win->y, win->x + win->with - 1, win->y + win->hight - 1, back_color);
- GUI_Rectangle(win->x, win->y, win->x + win->with - 1, win->y + win->hight - 1, disp_color); // 畫窗口
- GUI_HLine(win->x, win->y + 12, win->x + win->with - 1, disp_color); // 畫標題目欄
- GUI_RLine(win->x + 12, win->y, win->y + 12, disp_color); // 畫關閉窗號按鈕
- GUI_Line(win->x, win->y, win->x + 12, win->y + 12, disp_color);
- GUI_Line(win->x + 12, win->y, win->x, win->y + 12, disp_color);
-
- /* 寫標題 */
- if( win->title != NULL )
- { str = win->title;
- bak = win->x + 15;
- bak1 = win->y + 3;
- bak2 = win->x + win->with -1;
-
- while(1)
- { if( (bak+8) > bak2 ) break; // 判斷標題是否溢出
- if(*str=='\0') break; // 判斷字符串是否結束
-
- GUI_PutChar(bak, bak1, *str++); // 顯示標題
- bak += 6;
- }
- }
- /* 寫狀態欄 */
- if( win->state != NULL )
- { if( win->hight < 60) return(0); // 判斷是否可以畫狀態欄
- /* 畫狀態欄 */
- GUI_HLine(win->x, win->y + win->hight - 11, win->x + win->with - 1, disp_color);
-
- str = win->state;
- bak = win->x + 3;
- bak1 = win->y + win->hight - 9;
- bak2 = win->x + win->with -1;
-
- while(1)
- { if( (bak+8) > bak2 ) break; // 判斷標題是否溢出
- if(*str=='\0') break; // 判斷字符串是否結束
-
- GUI_PutChar(bak, bak1, *str++); // 顯示標題
- bak += 6;
- }
- }
-
- return(1);
- }
- /****************************************************************************
- * 名稱:GUI_WindowsHide()
- * 功能:消隱窗口。
- * 入口參數:win 窗口句柄
- * 出口參數:返回0表示操作失敗,返回1表示操作成功
- ****************************************************************************/
- uint8 GUI_WindowsHide(WINDOWS *win)
- { /* 參數過濾,若窗口起出范圍,則返回0 */
- if( ( (win->with)<20 ) || ( (win->hight)<20 ) ) return(0); // 寬度、高度檢查,限制最小窗口
- if( (win->x + win->with ) > GUI_LCM_XMAX ) return(0); // 窗口寬度是否溢出
- if( (win->y + win->hight ) > GUI_LCM_YMAX ) return(0); // 窗口高度是否溢出
-
- /* 消隱窗口 */
- GUI_RectangleFill(win->x, win->y, win->x + win->with - 1, win->y + win->hight - 1, back_color);
- return(1);
- }
- /****************************************************************************
- * 名稱:GUI_WindowsClr()
- * 功能:清屏窗口。
- * 入口參數:win 窗口句柄
- * 出口參數:無
- * 說明:使用此函數前要先使用GUI_WindowsDraw()將窗口畫出。
- ****************************************************************************/
- void GUI_WindowsClr(WINDOWS *win)
- { uint8 x0, y0;
- uint8 x1, y1;
-
- /* 設置要清屏的區域 */
- x0 = win->x + 1;
- x1 = win->x + win->with - 2;
- y0 = win->y + 13;
- y1 = win->y + win->hight - 2;
- if( win->state != NULL ) // 判斷是否有狀態欄
- { if( win->hight >= 60)
- { y1 = win->y + win->hight - 12;
- }
- }
- /* 使用填充矩形實現清屏 */
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
zlggui.zip
(34.72 KB, 下載次數: 70)
2018-2-2 10:12 上傳
點擊文件名下載附件
ZLGGUI源碼 下載積分: 黑幣 -5
|