panels.c
来自「MDE 图形引擎」· C语言 代码 · 共 1,458 行 · 第 1/4 页
C
1,458 行
/*************************************************************************** * $Id: panels.c,v 1.5 2003/05/07 08:11:24 weiym Exp $ * panels.c - description * ------------------- * begin : Wed Jan 17 2001 * copyright : (C) 2001 by 冯大可 * email : minx@thtfchain.com ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#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/mywindows.h>#include <minigui/filedlg.h>#include "controlpanel.h"#include "panels.h"/************************ system panel dialog *************************/#define IDC_ENGNATIVERADIO0 100#define IDC_ENGLIBGGIDRADIO1 101#define IDC_ENGSVGALIBRADIO2 102DLGTEMPLATE DlgSystemPanelInfo ={ WS_BORDER|WS_CAPTION, WS_EX_NONE, 120, 120, 240, 200, "系统属性", 0, 0, 6, NULL};CTRLDATA CtrlSystemPanelInfo [] ={ { "static", WS_VISIBLE | SS_GROUPBOX | SS_LEFT, 10, 10, 220, 140, IDC_STATIC, "图形引擎", 0 }, { "button", WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_GROUP| WS_TABSTOP, 20, 40, 120, 22, IDC_ENGNATIVERADIO0, "自带引擎", 0 }, { "button", WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE , 20, 65, 120, 22, IDC_ENGLIBGGIDRADIO1, "LibGGI引擎", 0 }, { "button", WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE , 20, 90, 120, 22, IDC_ENGSVGALIBRADIO2, "SVGALib引擎", 0 }, { "button", WS_VISIBLE | BS_PUSHLIKE | BS_CENTER , 100, 154, 60, 22, IDOK, "确定", 0 }, { "button", WS_VISIBLE | BS_PUSHLIKE | BS_CENTER , 170, 154, 60, 22, IDCANCEL, "取消", 0 },};static intDialogSystemPanelProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam){ char tempStr[21]; switch(message) { case MSG_INITDIALOG: { if(GetValueFromEtcFile(MINIGUI_CONFIG, "system","engine",tempStr,20)!=ETC_OK) { tempStr[0]=0; }; tempStr[20]=0; if(strcmp(tempStr,"native")==0) CheckDlgButton(hDlg,IDC_ENGNATIVERADIO0,TRUE); else if(strcmp(tempStr,"LibGGI")==0) CheckDlgButton(hDlg,IDC_ENGLIBGGIDRADIO1,TRUE); else if(strcmp(tempStr,"SVGALib")==0) CheckDlgButton(hDlg,IDC_ENGSVGALIBRADIO2,TRUE); } break; case MSG_COMMAND: if (wParam == IDOK) { if(IsDlgButtonChecked(hDlg,IDC_ENGNATIVERADIO0)) strcpy (tempStr,"native"); else if(IsDlgButtonChecked(hDlg,IDC_ENGLIBGGIDRADIO1)) strcpy (tempStr,"LibGGI"); else if(IsDlgButtonChecked(hDlg,IDC_ENGSVGALIBRADIO2)) strcpy (tempStr,"SVGALib"); else { MessageBox(hDlg,"必须选择一个引擎","控制面板",MB_OK| MB_ICONSTOP); return 0; } if(SetValueToEtcFile(MINIGUI_CONFIG, "system","engine",tempStr)!=ETC_OK) { MessageBox(hDlg,"设置文件写入失败","控制面板",MB_OK| MB_ICONSTOP); return 0; } SetValueToEtcFile(MINIGUI_CONFIG,"system","availableEngine1","native"); SetValueToEtcFile(MINIGUI_CONFIG,"system","availableEngine2","LibGGI"); SetValueToEtcFile(MINIGUI_CONFIG,"system","availableEngine3","SVGALib"); EndDialog(hDlg,IDOK); } break; } return DefaultDialogProc(hDlg, message, wParam, lParam);}int SystemPanelDialog(HWND hWnd){ DlgSystemPanelInfo.controls = CtrlSystemPanelInfo; return DialogBoxIndirectParam(&DlgSystemPanelInfo, hWnd, DialogSystemPanelProc, 0);}/************************ display panel dialog *************************/#define IDC_BACKGROUNDPLACEMBUTTON 100#define IDC_BACKGROUNDBITMAPEDIT 101#define IDC_DISPLAYRESOLUTIONMBUTTON 102#define IDC_DISPLAYCOLORSMBUTTON 103#define IDC_FILECHOISE 104#define IDC_CHBMPPATHBTM 105#define IDC_BMPPATHEDIT 106DLGTEMPLATE DlgDisplayPanelInfo ={ WS_BORDER|WS_CAPTION, WS_EX_NONE, 120, 40, 440, 400, "显示属性", 0, 0, 16, NULL};CTRLDATA CtrlDisplayPanelInfo [] ={ { "static", WS_VISIBLE | SS_GROUPBOX | SS_LEFT, 10, 10, 420, 270, IDC_STATIC, "背景", 0 }, { "static", WS_VISIBLE | SS_LEFT, 20, 32, 80, 20, IDC_STATIC, "图片文件名", 0 }, { "listbox", WS_VISIBLE | WS_TABSTOP | LBS_NOTIFY | WS_VSCROLL | WS_BORDER, 20, 55, 185, 150, IDC_FILECHOISE, NULL, 0 }, { "static", WS_VISIBLE | SS_LEFT, 20, 225, 60, 20, IDC_STATIC, "图片路径", 0 }, { "button", WS_VISIBLE | BS_PUSHLIKE | BS_CENTER , 77, 220, 120, 22, IDC_CHBMPPATHBTM, "选择图片路径", 0 }, { "sledit", WS_VISIBLE | WS_TABSTOP | LBS_NOTIFY | WS_BORDER, 20, 250, 380, 22, IDC_BMPPATHEDIT, "", 0 }, { "static", WS_VISIBLE | SS_LEFT, 240, 32, 80, 20, IDC_STATIC, "预览", 0 }, { "static", WS_VISIBLE | SS_LEFT, 220, 225, 60, 20, IDC_STATIC, "背景位置", 0 }, { "menubutton", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 280, 220, 120, 22, IDC_BACKGROUNDPLACEMBUTTON, "选择背景位置", 0 }, { "static", WS_VISIBLE | SS_GROUPBOX | SS_LEFT, 10, 280, 420, 70, IDC_STATIC, "显示分辩率(功能未实现)", 0 }, { "static", WS_VISIBLE | SS_LEFT, 20, 310, 60, 20, IDC_STATIC, "分辩率", 0 }, { "menubutton", WS_CHILD | WS_VISIBLE | WS_TABSTOP , 77, 305, 120, 22, IDC_DISPLAYRESOLUTIONMBUTTON, "选择分辩率", 0 }, { "static", WS_VISIBLE | SS_LEFT, 220, 310, 80, 20, IDC_STATIC, "颜色数目", 0 }, { "menubutton", WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE , 280, 305, 120, 22, IDC_DISPLAYCOLORSMBUTTON, "选择颜色数目", 0 }, { "button", WS_VISIBLE | BS_PUSHLIKE | BS_CENTER , 300, 354, 60, 22, IDOK, "确定", 0 }, { "button", WS_VISIBLE | BS_PUSHLIKE | BS_CENTER , 370, 354, 60, 22, IDCANCEL, "取消", 0 },};void ListBMPFiles(HWND hDlg,char* path){ struct dirent* pDirEnt; DIR* dir; struct stat ftype; char fullpath [PATH_MAX + 1]; SendDlgItemMessage (hDlg, IDC_FILECHOISE, LB_RESETCONTENT, 0, (LPARAM)0); dir = opendir (path); while ( (pDirEnt = readdir ( dir )) != NULL ) { strncpy (fullpath, path, PATH_MAX); strcat (fullpath, "/"); strcat (fullpath, pDirEnt->d_name); if (lstat (fullpath, &ftype) < 0 ) { Ping(); continue; } if (S_ISREG(ftype.st_mode)) { SendDlgItemMessage (hDlg, IDC_FILECHOISE, LB_ADDSTRING,0,(LPARAM)pDirEnt->d_name); } }}static char *Cposition[]={ "上左", "上中", "上右", "左中", "居中", "右中", "下左", "下中", "下右", "不设背景"};static char *Eposition[]={ "upleft", "upcenter", "upright", "vcenterleft","center","vcenterright", "downleft", "downcenter", "downright", "none"};int Cp(char* CName){ int i; for (i=0;i<10;i++) if(strcmp(Cposition[i],CName)==0) return i; return -1;}int Ep(char* EName){ int i; for (i=0;i<10;i++) if(strcmp(Eposition[i],EName)==0) return i; return -1;}static intDialogDisplayPanelProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam){ char tempStr[101]; static BITMAP screenbitmap; static BITMAP bgbitmap; static char bmppath[PATH_MAX]; static char bmpfile[PATH_MAX]; static int bgposition; int i; RECT invrc; switch(message) { case MSG_INITDIALOG: { MENUBUTTONITEM mbi; HWND hTmp; mbi.data=0; mbi.bmp=0; //resolution hTmp = GetDlgItem(hDlg,IDC_DISPLAYRESOLUTIONMBUTTON); mbi.text= "640X480"; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); mbi.text= "800X600"; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); mbi.text= "1024X768"; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); //color hTmp = GetDlgItem(hDlg,IDC_DISPLAYCOLORSMBUTTON); mbi.text= "16"; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); mbi.text= "256"; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); mbi.text= "64K"; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); //position hTmp = GetDlgItem(hDlg,IDC_BACKGROUNDPLACEMBUTTON); for(i=0;i<10;i++) { mbi.text= Cposition[i]; SendMessage (hTmp, MBM_ADDITEM, -1, (LPARAM) &mbi); } if(GetValueFromEtcFile(MINIGUI_CONFIG, "bgpicture","position",tempStr,100)!=ETC_OK) { tempStr[0]=0; } else { tempStr[100]=0; bgposition = Ep(tempStr); SendMessage (hTmp,MBM_SETCURITEM,bgposition,0); } myLoadBitmap (&screenbitmap, "screen.bmp"); hTmp = GetDlgItem(hDlg,IDC_BMPPATHEDIT); EnableWindow(hTmp,FALSE); if(GetValueFromEtcFile(MINIGUI_CONFIG, "bitmapinfo","bitmappath",bmppath,100)!=ETC_OK) { bmppath[0]=0; }; bmppath[100]=0; SetDlgItemText(hDlg,IDC_BMPPATHEDIT,bmppath); ListBMPFiles(hDlg,bmppath); if(GetValueFromEtcFile(MINIGUI_CONFIG, "bitmapinfo","bgpicture", tempStr, 100)!=ETC_OK) { tempStr[0]=0; } else { tempStr[100]=0; strcpy(bmpfile, bmppath); strcat(bmpfile, "/"); strcat(bmpfile, tempStr); LoadBitmap (HDC_SCREEN, &bgbitmap,bmpfile); i=SendDlgItemMessage (hDlg, IDC_FILECHOISE, LB_FINDSTRINGEXACT, 0, (LPARAM)tempStr); SendDlgItemMessage (hDlg, IDC_FILECHOISE, LB_SETCURSEL, i,0); } } break; case MSG_PAINT: { HDC hdc;// hdc = BeginPaint (hDlg); hdc = GetClientDC (hDlg); FillBoxWithBitmap (hdc, 220,45,0, 0, &screenbitmap);// printf("%d,%d,%d\n",bgposition,bgposition%3,bgposition/3); if((bgposition<9)&&(bgposition>=0)) FillBoxWithBitmap (hdc, 220+20+2 + (bgposition%3)*158/3, 45+20 + (bgposition/3)*111/3, 158/3, 111/3, &bgbitmap);// EndPaint(hDlg,hdc); ReleaseDC (hdc); } break; case MSG_COMMAND: { int id = LOWORD(wParam); int code = HIWORD(wParam); switch (id) { case IDC_BACKGROUNDPLACEMBUTTON: { if(code != MBN_CHANGED) return 0; bgposition = SendDlgItemMessage(hDlg,IDC_BACKGROUNDPLACEMBUTTON, MBM_GETCURITEM ,0,0); invrc.left = 220; invrc.top = 45; invrc.right = invrc.left + screenbitmap.bmWidth; invrc.bottom = invrc.top + screenbitmap.bmHeight; InvalidateRect(hDlg,&invrc,FALSE);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?