#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <minigui/mgext.h>
#include <minigui/skin.h>
#include "define.h"
#include "ctrls.h"
#include "video.h"
#define IDM_CAPTION 400//高级设置选项id
#define IDM_LVBO 401
#define IDM_HEIDIANPING 402
#define IDM_GAMMA 403
#define IDM_JIANGZAO 404
#define IDM_BEIJING 405
#define IDM_EXIT 406
//定义设置选项的弹出菜单的首个选项id,选项id依次加1
#define IDM_1 10//设置第一个选项的弹出菜单的首选项id
#define IDM_2 20
#define IDM_3 30//
#define IDM_4 40
#define IDM_5 50
static char *msg1[] = {
" 开 ",
" 关 "
};
static char *msg1_en[]={
"ON ",
"OFF "
};
static char *msg2[]={
"强 ",
"中 ",
"弱 "
};
static char *msg2_en[]={
"HIGH ",
"MID ",
"LOW "
};
static char *msg3[]={
"晴天 ",
"标准 ",
"节能 "
};
static char *msg3_en[]={
"SUNNY ",
"STANDARD ",
"SAVE "
};
static char *caption[]=
{"高级设置"," 3D梳状滤波 开"," 黑电平延伸 弱"," Gamma 关",
" 数字降噪 弱"," 背景模式 晴天"," 返回"
};
static char *caption_en[]=
{"HIGH SETTING"," 3D_COMB On"," BlkStr Low",
" Gamma Off"," DNR Low",
" BkMode Sunny"," Exit"
};
static skin_head_t main_skin=
{
"",SKIN_STYLE_TOOLTIP, NULL, NULL,
0, 0, NULL, FALSE
};
static const char *bmp_name[]={"res/shezhi_bk.png"};
/* 位图资源装/卸载函数 */
static void load_skin_bmps (skin_head_t *skin, BOOL load)
{
int i, bmp_num = sizeof (bmp_name)/sizeof(char *);
/* 如果load为真,则将位图装载到skin的bmps数组,否则卸载bmps数组中的位图 */
if (load)
skin->bmps = (BITMAP* ) calloc (bmp_num, sizeof(BITMAP));
for (i = 0 ; i < bmp_num ; i++ ) {
if (load) {
if (LoadBitmapFromFile (HDC_SCREEN, (PBITMAP)&(skin->bmps[i]), bmp_name[i])) {
free ((void*)skin->bmps);
skin->bmps = NULL;
}
}
else
UnloadBitmap ((PBITMAP)&(skin->bmps[i]));
}
if (!load)
free ((void*)skin->bmps);
}
static int status_old[5]={1,0,0,0,0};
static int status_now[5];
static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
int i;
if (nc == STN_CLICKED)
switch(id)
{
case IDM_LVBO:
{
status_now[0]=1;
for(i=1;i<5;i++)
status_now[i]=0;
color(GetParent (hwnd),status_old,status_now,5,IDM_LVBO);
if(LANGUAGE==CHINESE)
choose(GetParent(hwnd),msg1, 345,190,2,IDM_1);
else if(LANGUAGE==ENGLISH)
choose(GetParent(hwnd),msg1_en, 345,190,2,IDM_1);
break;
}
case IDM_HEIDIANPING:
{
for(i=0;i<5;i++)
if(i==1)
status_now[i]=1;
else
status_now[i]=0;
color(GetParent (hwnd),status_old,status_now,5,IDM_LVBO);
if(LANGUAGE==CHINESE)
choose(GetParent(hwnd),msg2,345,210,3,IDM_2);
else if(LANGUAGE==ENGLISH)
choose(GetParent(hwnd),msg2_en,345,210,3,IDM_2);
break;
}
case IDM_GAMMA:
{
for(i=0;i<5;i++)
if(i==2)
status_now[i]=1;
else
status_now[i]=0;
color(GetParent (hwnd),status_old,status_now,5,IDM_LVBO);
if(LANGUAGE==CHINESE)
choose(GetParent(hwnd),msg1, 345,230,2,IDM_3);
else if(LANGUAGE==ENGLISH)
choose(GetParent(hwnd),msg1_en, 345,230,2,IDM_3);
break;
}
case IDM_JIANGZAO:
{
for(i=0;i<5;i++)
if(i==3)
status_now[i]=1;
else
status_now[i]=0;
color(GetParent (hwnd),status_old,status_now,5,IDM_LVBO);
if(LANGUAGE==CHINESE)
choose(GetParent(hwnd),msg2,345,250,3,IDM_4);
else if(LANGUAGE==ENGLISH)
choose(GetParent(hwnd),msg2_en,345,250,3,IDM_4);
break;
}
case IDM_BEIJING:
{
for(i=0;i<5;i++)
if(i==4)
status_now[i]=1;
else
status_now[i]=0;
color(GetParent (hwnd),status_old,status_now,5,IDM_LVBO);
if(LANGUAGE==CHINESE)
choose(GetParent(hwnd),msg3,345,270,3,IDM_5);
else if(LANGUAGE==ENGLISH)
choose(GetParent(hwnd),msg3_en,345,270,3,IDM_5);
break;
}
case IDM_EXIT:
{
for(i=1;i<5;i++)
status_old[i]=0;
status_old[0]=1;
EndDialog (GetParent (hwnd), id);
break;
}
}
}
static int main_event_cb (HWND hwnd, skin_item_t* item, int event, void* data)
{
return 1;
}
static int id;
static int msg_event_cb (HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int* result)
{
switch (message) {
case MSG_CREATE:
{
int i;
if(LANGUAGE==CHINESE)
CreateWindowEx( "static",caption[0], WS_VISIBLE|SS_CENTER , WS_EX_TRANSPARENT,IDM_CAPTION, 0, 5, 152, 20,hwnd, 0);
else if(LANGUAGE==ENGLISH)
CreateWindowEx( "static",caption_en[0], WS_VISIBLE|SS_CENTER , WS_EX_TRANSPARENT,IDM_CAPTION, 0, 5, 152, 20,hwnd, 0);
for(i=0;i<=5;i++)
{
if(LANGUAGE==CHINESE)
CreateWindowEx( "static",caption[i+1], WS_VISIBLE|SS_LEFT|SS_NOTIFY , WS_EX_TRANSPARENT,IDM_LVBO+i, 12, 30+20*i, 130, 20,hwnd, 0);
else if(LANGUAGE==ENGLISH)
CreateWindowEx( "static",caption_en[i+1], WS_VISIBLE|SS_LEFT|SS_NOTIFY , WS_EX_TRANSPARENT,IDM_LVBO+i, 12, 30+20*i, 130, 20,hwnd, 0);
SetNotificationCallback (GetDlgItem (hwnd, IDM_LVBO+i), my_notif_proc);
}
id=IDM_LVBO;
change(GetDlgItem(hwnd,id)); //初始化选择第一项
}
return 1;
case MSG_KEYDOWN:
{
switch(wparam)
{
case SCANCODE_ENTER:{
NotifyParent(GetDlgItem(hwnd,id), id, STN_CLICKED);
break;}
case SCANCODE_CURSORBLOCKLEFT:{
NotifyParent(GetDlgItem(hwnd,IDM_EXIT),IDM_EXIT, STN_CLICKED);
break;}
case SCANCODE_CURSORBLOCKUP:{
recover(GetDlgItem(hwnd,id));
if(id==IDM_LVBO)
id=id+5;
else
id--;
change(GetDlgItem(hwnd,id));
break;}
case SCANCODE_CURSORBLOCKDOWN:{
recover(GetDlgItem(hwnd,id));
if(id==IDM_EXIT)
id=id-5;
else
id++;
change(GetDlgItem(hwnd,id));
break;}
}
break;
}
case MSG_COMMAND:
switch(wparam){
case IDM_1:{
caption[1]=" 3D梳状滤波 开";
caption_en[1]=" 3D_COMB On";
if(LANGUAGE==CHINESE)
SetWindowText(GetDlgItem (hwnd, IDM_LVBO)," 3D梳状滤波 开");
else if(LANGUAGE==ENGLISH)
SetWindowText(GetDlgItem (hwnd, IDM_LVBO)," 3D_COMB On");
break;}
case IDM_1+1:{