📄 appmainwnd.c
字号:
/*** $Id: skindemo.c,v 1.16 2006/05/10 09:51:33 xwyan Exp $**** skindemo.c: Sample program for MiniGUI Programming Guide** Usage of SKIN.**** Copyright (C) 2004 ~ 2006 Feynman Software.**** License: GPL*/#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 "guicommon.h"#ifdef _EXT_SKIN#define SIID_LIVE 0#define SIID_MULTICAST 1#define SIID_SPECIFIC 2#define SIID_LOCAL 3#define SIID_SYSTEM 4#define SIID_LIVE_LABEL 6#define SIID_MULTICAST_LABEL 7#define SIID_SPECIFIC_LABEL 8#define SIID_LOCAL_LABEL 9#define SIID_SYSTEM_LABEL 10#define DEF_WIDTH 800#define DEF_HEIGHT 600HWND hWndMain = 0;static int focusIndex = -1;static si_nrmlabel_t si_mainlabel_items[] = { {"接收直播",0xDD0000, 0x00FF00, 0xFF0000, 0 }, {"接收组播",0xDD0000, 0x00FF00, 0xFF0000, 0 }, {"点播文件",0xDD0000, 0x00FF00, 0xFF0000, 0 }, {"本地播放",0xDD0000, 0x00FF00, 0xFF0000, 0 }, {"系统设置",0xDD0000, 0x00FF00, 0xFF0000, 0 }};//static si_nrmlabel_t si_testlabel_items = {"接收直播",0xDD0000, 0x00FF00, 0xFF0000, 0};/* 定义皮肤元素数组 */static skin_item_t skin_main_items [] ={{SIID_LIVE, SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT |SI_STATUS_VISIBLE, 0, 128, {}, 1, ""},{SIID_MULTICAST, SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 160, 128, {}, 2, ""}, {SIID_SPECIFIC, SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 310, 128, {}, 3, ""},{SIID_LOCAL, SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 460, 128, {}, 4, ""}, {SIID_SYSTEM, SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 610, 128, {}, 5, ""},{SIID_LIVE_LABEL, SI_TYPE_NRMLABEL | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 70, 370, {}, -1, "a",0,si_mainlabel_items },{SIID_MULTICAST_LABEL, SI_TYPE_NRMLABEL | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 230, 370, {}, -1, "b",0,si_mainlabel_items+1},{SIID_SPECIFIC_LABEL, SI_TYPE_NRMLABEL | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 380, 370, {}, -1, "c",0,si_mainlabel_items+2},{SIID_LOCAL_LABEL, SI_TYPE_NRMLABEL | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 530, 370, {}, -1, "d",0,si_mainlabel_items+3},{SIID_SYSTEM_LABEL, SI_TYPE_NRMLABEL | SI_TEST_SHAPE_RECT | SI_STATUS_VISIBLE, 680, 370, {}, -1, "e",0,si_mainlabel_items+4}};/* 定义皮肤 */skin_head_t main_skin ={ "主界面皮肤窗口", SKIN_STYLE_TOOLTIP, NULL, NULL, 0, 10, skin_main_items, FALSE};/* 位图数组 */const char *bmp_name[] = {"./res/main.png", "./res/live.png", "./res/multicast.png", "./res/specific.png","./res/local.png","./res/system.png"};/* 皮肤事件回调函数 */static int main_event_cb (HWND hwnd, skin_item_t* item, int event, void* data){ if (event == SIE_BUTTON_CLICKED) { switch (item->id) { //直播 case SIID_LIVE: { LiveGUIMain(hWndMain); } break; //组播 case SIID_MULTICAST: { multicastGUIMain(hWndMain); } break; //点播 case SIID_SPECIFIC: { specplayGUIMain(hWndMain); } break; //本地播放 case SIID_LOCAL: { filelistGUIMain(hWndMain); } break; //系统设置 case SIID_SYSTEM: SendMessage (hwnd, MSG_CLOSE, 0, 0); break; } } return 1;}/* 皮肤窗口消息回调函数 */static int msg_event_cb (HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int* result){ switch (message) { case MSG_KEYDOWN: { //printf("wparam = %d \n",wparam); switch(wparam) { case 0x1c: main_event_cb(hwnd,skin_main_items+focusIndex,SIE_BUTTON_CLICKED,0); break; //按键向左 case 105: { focusIndex--; if(focusIndex < 0) focusIndex = 4; skin_main_items[focusIndex].style |= SI_STATUS_HILIGHTED; skin_main_items[focusIndex + 5].style |= SI_STATUS_HILIGHTED; int otherindex; for(otherindex = 0;otherindex<10;otherindex++) { if(otherindex != focusIndex&&otherindex!= (focusIndex + 5)) skin_main_items[otherindex].style = SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT |SI_STATUS_VISIBLE; } set_window_skin(hwnd,&main_skin); UpdateWindow (hwnd, TRUE); } break; //按键向右 case 106: { focusIndex++; if(focusIndex > 4) focusIndex = 0; skin_main_items[focusIndex].style |= SI_STATUS_HILIGHTED; skin_main_items[focusIndex + 5].style |= SI_STATUS_HILIGHTED; int otherindex; for(otherindex = 0;otherindex<10;otherindex++) { if(otherindex != focusIndex&&otherindex!= (focusIndex + 5)) skin_main_items[otherindex].style = SI_TYPE_CMDBUTTON | SI_TEST_SHAPE_RECT |SI_STATUS_VISIBLE; } set_window_skin(hwnd,&main_skin); UpdateWindow (hwnd, TRUE); //printf("keydown focusIndex = %d\n",focusIndex); } break; } default: break; } break; } return 1;}int MiniGUIMain (int argc, const char *argv[]){ MSG msg; #ifdef _MGRM_PROCESSES JoinLayer(NAME_DEF_LAYER , "skindemo" , 0 , 0);#endif if (!InitMiniGUIExt()) { return 2; } load_skin_bmps (&main_skin, TRUE,bmp_name,sizeof(bmp_name)/sizeof(char*)); /* 装载位图资源 */ if (main_skin.bmps == NULL) { printf ("Could not load skin bitmaps!\n"); return 3; } load_skin_fonts(&main_skin,TRUE);/*装载字体*/ if ( !skin_init (&main_skin, main_event_cb, msg_event_cb) ){ /* 初始化皮肤 */ printf ("skin init fail!\n"); } else{ hWndMain = create_skin_main_window (&main_skin, HWND_DESKTOP, 0, 0, DEF_WIDTH, DEF_HEIGHT, TRUE); while (GetMessage (&msg, hWndMain)) { TranslateMessage (&msg); DispatchMessage (&msg); } MainWindowCleanup (hWndMain); skin_deinit (&main_skin); /* 撤销皮肤 */ } //load_skin_fonts (&main_skin, FALSE); /*卸载字体*/ load_skin_bmps(&main_skin, FALSE,bmp_name,sizeof(bmp_name)/sizeof(char*)); /* 卸载位图资源 */ MiniGUIExtCleanUp (); return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif#else#error "Lack of SKIN support in MiniGUIExt library."#endif /* _EXT_SKIN */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -