📄 syssetpanel.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
#include <semaphore.h>
#include <popt.h>
#include <unistd.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <minigui/filedlg.h>
#include "syssetpanel.h"
static BITMAP jpg_bkgnd;
static int myLoadBitmap (BITMAP* bm, const char* filename)
{
char full_path [MAX_PATH + 1];
#ifndef _PASS
#define _PASS
strcpy (full_path, "./image/syssetpanel/");
strcat (full_path, filename);
//#endif
#endif
return LoadBitmap (HDC_SCREEN, bm, full_path);
}
static char *xmBmpName[]=
{
"001.png","002.png","003.png","004.png",
"005.png","006.png","007.png","008.png"
};
static char *xmTitle[]=
{
"时间设置","开机问候","个人信息","背景设置",
"铃声设置","锁定屏幕","按键音音","返回上级"
};
static XMBUTTON xmButton [BTM_NUM];
static int WhichBox(int x,int y)
{
int i;
for (i=0;i<BTM_NUM;i++)
{
if ((x>xmButton[i].x)&&(x<xmButton[i].x+xmButton[i].w)
&&(y>xmButton[i].y)&&(y<xmButton[i].y+xmButton[i].h))
return i;
}
return -1;
}
static int changeMode(HWND hWnd,int x,int y,int mode)
{
int btm=WhichBox(x,y);
int i;
RECT rect;
static int lastbtm=-1;
static int lastmode=BTM_FLAT;
if ((btm==lastbtm)&&(mode==lastmode))
return btm;
for (i=0;i<BTM_NUM;i++)
{
if(xmButton[i].mode==BTM_FLAT) continue;
xmButton[i].mode=BTM_FLAT;
rect.left=xmButton[i].x;
rect.right=xmButton[i].x+xmButton[i].w;
rect.top=xmButton[i].y;
rect.bottom=xmButton[i].y+xmButton[i].h;
InvalidateRect(hWnd,&rect,FALSE);
}
if (btm!=-1)
{
xmButton[btm].mode=mode;
rect.left=xmButton[btm].x;
rect.right=xmButton[btm].x+xmButton[btm].w;
rect.top=xmButton[btm].y;
rect.bottom=xmButton[btm].y+xmButton[btm].h;
InvalidateRect(hWnd,&rect,FALSE);
}
if(btm!=lastbtm)
InvalidateRect(hWnd,&rect,FALSE);
lastbtm = btm;
lastmode = mode;
return btm;
}
int SysSetPanelWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
static int lastdown=-1;
switch (message)
{
/* case MSG_CREATE:
{
}
break;
case MSG_COMMAND:
{
}
break;
*/
case MSG_LBUTTONDOWN:
{
lastdown = changeMode(hWnd,LOWORD(lParam),HIWORD(lParam),BTM_DOWN );
}
break;
case MSG_LBUTTONUP:
{
int up = changeMode(hWnd,LOWORD(lParam),HIWORD(lParam),BTM_FLAT );
if(up==-1)
break;
if(up==lastdown)
{
//OpenPanel(hWnd,up);
switch(up)
{
case IDC_sysset0: settime(hWnd);break;//时间设置
case IDC_sysset1: openwel(hWnd);break;//开机问候语
case IDC_sysset2: user(hWnd);break; //用户信息
case IDC_sysset3: backgroundset(hWnd);break;
case IDC_sysset4: RingSet(hWnd);break;
case IDC_sysset5:
if(MessageBox(hWnd, "确定要锁定吗? 要解除锁定请按 '*'和'0'", "提示", MB_YESNO | MB_ICONINFORMATION) == IDYES)
{
screenlockset( hWnd);
}
break; //用户信息
//case IDC_sysset6: KeySound(hWnd);break;
case IDC_sysset7: //返回
DestroyMainWindow(hWnd);
PostQuitMessage(hWnd);
return 0;
}
return 0;
}
}
break;
//
case MSG_MOUSEMOVE:
{
changeMode(hWnd,LOWORD(lParam),HIWORD(lParam),BTM_UP );
}
break;
case MSG_PAINT:
{
HDC hdc;
RECT rc;//,rect;
int i;
hdc = BeginPaint (hWnd);
GetWindowRect(hWnd,&rc);
FillBoxWithBitmap (hdc,0, 0, 320, 215, &jpg_bkgnd);
for(i=0;i<BTM_NUM;i++)
{
if(xmButton[i].mode == BTM_UP)
Draw3DUpThickFrame (hdc, xmButton[i].x, xmButton[i].y ,xmButton[i].x+xmButton[i].w,
xmButton[i].y+xmButton[i].h,PIXEL_black);//PIXEL_lightwhite
else if(xmButton[i].mode == BTM_DOWN)
Draw3DDownThickFrame (hdc, xmButton[i].x, xmButton[i].y ,xmButton[i].x+xmButton[i].w,
xmButton[i].y+xmButton[i].h,PIXEL_black);
FillBoxWithBitmap (hdc, xmButton[i].x+xmButton[i].bmpx,
xmButton[i].y+xmButton[i].bmpy,0, 0, &xmButton[i].bitmap);
//////////////////////////////////////////////////
SetBkMode(hdc, BM_TRANSPARENT);
SetTextColor(hdc, PIXEL_red);
///////////////////////////////////////////////////
TextOut(hdc,xmButton[i].x+xmButton[i].titlex,xmButton[i].y+xmButton[i].titley,xmButton[i].title);
}
EndPaint (hWnd,hdc);
}
return 0;
case MSG_DESTROY:
DestroyAllControls(hWnd);
return 0;
case MSG_CLOSE:
{
int i;
for(i=0;i<BTM_NUM;i++)
UnloadBitmap(&(xmButton[i].bitmap));
UnloadBitmap(&jpg_bkgnd);
DestroyMainWindow (hWnd);
PostQuitMessage (hWnd);
return 0;
}
}
return DefaultMainWinProc (hWnd, message, wParam, lParam);
}
static void initBTMs(void)
{
int i,j;
for(i=0;i<BTM_NUM;i++)
{
xmButton[i].x=10+(i%4)*76;//170 +
xmButton[i].y=9 + ((int)(i/4))*93;
xmButton[i].h=80;
xmButton[i].w=68;
xmButton[i].bmpx=10.5;
xmButton[i].bmpy=5;
strcpy(xmButton[i].title,xmTitle[i]);
j=strlen(xmButton[i].title);
xmButton[i].titlex=(8.7-j)*5;
xmButton[i].titley=56;
myLoadBitmap (&(xmButton[i].bitmap),xmBmpName [i]);
}
}
static void InitSysSetPanelInfo (PMAINWINCREATE pCreateInfo, HWND hWnd)
{
pCreateInfo->dwStyle = WS_CAPTION | WS_BORDER |WS_VISIBLE ;
pCreateInfo->dwExStyle = WS_EX_IMECOMPOSE;;
pCreateInfo->spCaption = "系☆统☆设☆置";
pCreateInfo->hMenu = 0;
pCreateInfo->hCursor = GetSystemCursor(0);
pCreateInfo->hIcon = 0;
pCreateInfo->MainWindowProc = SysSetPanelWinProc;
pCreateInfo->lx = 0;
pCreateInfo->ty = 0;
pCreateInfo->rx = 320;
pCreateInfo->by = 216;
pCreateInfo->iBkColor = PIXEL_lightwhite;
pCreateInfo->dwAddData = (DWORD)0;
pCreateInfo->hHosting = hWnd;
}
int SysSetPanel(HWND hWnd)
{
MSG Msg;
MAINWINCREATE CreateInfo;
HWND hMainWnd;
initBTMs();
InitSysSetPanelInfo (&CreateInfo, hWnd);
LoadBitmap (HDC_SCREEN, &jpg_bkgnd, "./image/background/bkgnd29.jpg");
hMainWnd = CreateMainWindow (&CreateInfo);
if (hMainWnd == HWND_INVALID)
return -1;
while( GetMessage(&Msg, hMainWnd) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainWindowThreadCleanup(hMainWnd);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -