📄 desktop.c
字号:
/* MShowTec - www.mshowtec.com
** msGUI desktop.c ver1.0
** 20051221 lmjx create limiao@mshowtec.com
**
*/
#define MSGUI_DESKTOP_C
#include "desktop.h"
#include "window.h"
#include "rc.h"
#include "msg.h"
int MSGUI_PID = 0;
static int item = 1;
char *item_string[3] = {
"item 1",
"item 2",
"菜单 3",
};
const unsigned char str_desktop[] = "桌面";
void PopInfoPaintCallback(HWND hwnd)
{
RECT rect;
rect = GetRect(hwnd);
rect.startX += 0x12;
rect.startY += 0x20;
gdi_text_out_border(rect,item_string[item-1],0xffff);
}
int PopInfoEntry(HWND hwnd, EVENT event, WPARAM wparam, LPARAM lparam)
{
static int tic = 0;
switch(event){
case WM_DESTORY:
tic = 0;
DestroyWindow(hwnd);
break;
case WM_WINTIMER:
if(tic++ >= 10){
SendWindowMessage(hwnd,WM_DESTORY,0,0);
}
TransferWindowMessage(hwnd,event,wparam,lparam);
break;
case WM_KEYDOWN:
switch(lparam){
case 0x12:
SendWindowMessage(hwnd,WM_DESTORY,0,0);
break;
default:
break;
}
break;
default:
TransferWindowMessage(hwnd,event,wparam,lparam);
break;
}
}
void MenuPaintCallback(HWND hwnd)
{
RECT rect,crect;
POINT pointL,pointR;
int i;
rect = GetRect(hwnd);
crect.startX = rect.startX;
crect.width = rect.width;
crect.height = 0x12;
for(i = 0;i<3;i++){
crect.startY = rect.startY + (i+1)*0x12;
gdi_text_out(crect,item_string[i],0);
}
crect.startY = rect.startY + item*0x12;
gdi_draw_picture(crect,(unsigned short*)prc_active_item);
gdi_text_out(crect,item_string[item-1],0);
pointL.x = rect.startX;
pointL.y = rect.startY+rect.height-1-14;
pointR.x = rect.startX+rect.width-1-28;
pointR.y = rect.startY+rect.height-1-14;
gdi_draw_string_border(pointL,"选择",0);
gdi_draw_string_border(pointR,"退出",0);
}
int MennuEntry(HWND hwnd, EVENT event, WPARAM wparam, LPARAM lparam)
{
RECT rect;
rect = GetRect(hwnd);
rect.startX += 10;
rect.startY += 20;
rect.width = 0x66;
rect.height = 0x45;
switch(event){
case WM_CREATE:
break;
case WM_DESTORY:
DestroyWindow(hwnd);
break;
case WM_PAINT:
InvalidateWindow(hwnd);
break;
case WM_WINTIMER:
TransferWindowMessage(hwnd,event,wparam,lparam);
break;
case WM_KEYDOWN:
switch(lparam){
case 0x12:
SendWindowMessage(hwnd,WM_DESTORY,0,0);
break;
case 0x11:
CreateWindow(hwnd,PopInfoEntry,PopInfoPaintCallback,rect,(HRESRC)prc_info,(unsigned char*)"PopInfo");
break;
case 0x0d:
if(++item>3)
item = 1;
InvalidateWindow(hwnd);
break;
case 0x0c:
if(--item<1)
item = 3;
InvalidateWindow(hwnd);
break;
default:
break;
}
break;
case WM_KEYUP:
break;
default:
TransferWindowMessage(hwnd,event,wparam,lparam);
break;
}
return 0;
}
void DesktopPaintCallback(HWND hwnd)
{
RECT rect;
POINT pointL,pointC;
rect = GetRect(hwnd);
pointL.x = rect.startX;
pointL.y = rect.startY+rect.height-1-14;
pointC.x = rect.startX + 10;
pointC.y = rect.startY + 50;
gdi_draw_string_border(pointL,"菜单",0);
gdi_draw_string(pointC,"msGUIv1.0测试版本",0);
}
int DesktopEntry(HWND hwnd, EVENT event, WPARAM wparam, LPARAM lparam)
{
RECT rect;
rect = GetRect(hwnd);
switch(event){
case WM_CREATE:
break;
case WM_DESTORY:
break;
case WM_PAINT:
InvalidateWindow(hwnd);
break;
case WM_WINTIMER:
TransferWindowMessage(hwnd,event,wparam,lparam);
break;
case WM_KEYDOWN:
switch(lparam){
case 0x12:
if(GetAllChild(hwnd) == 1){
SendWindowMessage(GetChild(hwnd),WM_DESTORY,0,0);
}
break;
case 0x11:
CreateWindow(hwnd,MennuEntry,MenuPaintCallback,rect,(HRESRC)prc_menu,(unsigned char*)"Menu");
break;
default:
break;
}
break;
case WM_KEYUP:
break;
default:
TransferWindowMessage(hwnd,event,wparam,lparam);
break;
}
return 0;
}
extern WIN g_wnd[];
void DesktopInit()
{
int i;
WIN* this = &g_wnd[0];
RECT rect;
HWND hwnd;
rect.startX = 0;
rect.startY = 0;
rect.width = LCDWIDTH;
rect.height = LCDHEIGHT;
memset(this, 0, sizeof(WIN));
this->pid = 0;
this->id = 0;
this->entry = DesktopEntry;
this->paint_callback = DesktopPaintCallback;
this->win_rect = rect;
this->pic = (unsigned short*)prc_desktop;
this->invalid = 1;
memcpy(this->title,str_desktop,strlen(str_desktop));
SendWindowMessage(0,WM_CREATE,0,0);
}
extern HWND topWindow;
void WinMain()
{
struct message msgui_msg;
MSGUI_PID = sys_getpid();
DesktopInit();
for(;;){
if(ShowWindows())
gdi_update_rscreen();
message_receive(&msgui_msg);
switch(msgui_msg.msg_sender){
case -2:
SendWindowMessage(topWindow,WM_KEYDOWN,0,(*(unsigned short*)(msgui_msg.msg_pointer)&0xff));
break;
case -3:
SendWindowMessage(0,WM_WINTIMER,0,0);
break;
default:
break;
}
if(msgui_msg.msg_pointer)
free(msgui_msg.msg_pointer);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -