📄 guitest.c
字号:
head 1.2;access;symbols START:1.1.1.1 F[Cujitsu:1.1.1;locks; strict;comment @ * @;1.2date 2004.09.30.04.01.45; author floyd; state Exp;branches;next 1.1;deltatype text;permissions 644;commitid dc8415b84a31938;kopt kv;filename @guitest.c@;1.1date 2004.09.30.01.37.05; author floyd; state Exp;branches 1.1.1.1;next ;deltatype text;permissions 646;1.1.1.1date 2004.09.30.01.37.05; author floyd; state Exp;branches;next ;deltatype text;permissions 646;desc@@1.2log@replace to new file@text@/*************************************************//** **//** Reference program for SPD **//** GUI (Widget Manager) test **//** Application Reference program **//** Copyright (C) 2004 FMC / Fujitsu **//** **//*************************************************//* * $Log: guitest.c,v $ * Revision 1.5 2004/07/19 03:33:40 root * apply to color.h * * Revision 1.4 2004/07/19 01:27:52 root * append BG2312 Chinese charactor code * * Revision 1.3 2004/06/10 16:30:48 root * local bug fix * * Revision 1.2 2004/06/10 16:30:00 root * to make simple * * Revision 1.1 2004/05/29 12:36:17 root * Initial revision * * */#include <stdio.h>#include <stdio.h>#include <string.h>#include <SubApplication/WidgetMgr/inc/sa_widget_manager.h>#include <SubApplication/WidgetMgr/inc/color.h>#include <AbsDeviceDrv/FRV_Companion/VideoDevice/inc/ADD_VideoOut.h>#include <AbsDeviceDrv/ADK_Hard/FPGAdevice/inc/ADD_FPGAswitch.h>WMWidget *menu1, *menu2, *menu3;WMWidget *tip1, *tip2, *tip3 , *tip4;void make_widget_list(void);void user_func1(WMWindow *);void user_func2(WMWindow *);void user_func3(WMWindow *);WMContext wc;static int bg_flg = 0;int main(int argc, char** argv){ // setting graphic information wc.Graphic = GON; wc.GSIZE = C2_QVGA; wc.width = QVGA_W; wc.height = QVGA_H; // analyze command options if(argc > 1){ if(!strcmp(argv[1],"-ntsc")){ wc.GSIZE = C2_NTSC; wc.width = NTSC_W; wc.height = NTSC_H; }else if(!strcmp(argv[1],"-bg")){ bg_flg = 1; }else if(!strcmp(argv[1],"-h")){ printf("usage: guitest [-ntsc][-bg]\n"); printf(" -ntsc output to TV\n"); printf(" -bg draw background picture\n"); printf(" default is LCD output without back ground picture\n"); exit(-1); } if(argc > 2){ if(!strcmp(argv[2],"-ntsc")){ wc.GSIZE = C2_NTSC; wc.width = NTSC_W; wc.height = NTSC_H; }else if(!strcmp(argv[2],"-bg")){ bg_flg = 1; } } } wc.MonitorSW = MON; wc.InputDevice = KEY_DEVICE; wc.handle_interval = 10; // [ms] // initialize wivget context SA_WM_init(&wc); // make widget design make_widget_list(); // list up prepared widget SA_WM_widget_show(menu1); SA_WM_CheckWidget(); // start event watching SA_WM_main();}void make_widget_list(){ WMEvent *event1, *event2; char addr[32]; event1 = (WMEvent *)malloc(sizeof(WMEvent)); event2 = (WMEvent *)malloc(sizeof(WMEvent)); menu1 = SA_WM_window_new(WM_WINDOW_TOPLEVEL); // put "up.jpg" icon tip1 = SA_WM_pixmap_create_from_xpm(NULL, 30,200, "icon/icon.jpg"); // out "0123456789" string tip2 = SA_WM_label_new(" GUI Test ", 100,100, 160, 16); // put skin data for moving picture tip3 = SA_WM_pixmap_create_from_xpm(NULL, 0, 0, "icon/QVGAskin.jpg"); printf("tip3 VVRAM : %x\n", tip3->VVRAMaddr); sprintf(addr, "%d", tip3->VVRAMaddr); // VVRAM of this object is used for another program if(vfork() == 0){ execl("../captest/captest", "../captest/captest", addr, NULL); } if(bg_flg){ // append back ground picture tip4 = SA_WM_pixmap_create_from_xpm(NULL, 0, 0, "icon/bg.jpg"); SA_WM_alignment_set(tip4, 0, 0, wc.width, wc.height); SA_WM_container_add(menu1, tip4); } // pack all of graphic objects SA_WM_container_add(menu1, tip3); SA_WM_container_add(menu1, tip2); SA_WM_container_add(menu1, tip1); // attach SW1 event and action (call back function) to tip1 widget event1->keyval = SW1; SA_WM_signal_connect(tip1, event1, &user_func1, NULL); // attach SW2 event and action (call back function) to tip1 widget event2->keyval = SW2; SA_WM_signal_connect(tip2, event2, &user_func2, NULL);}int x = 0;int y = 0;int w = 320;int h = 240;int rate = 10;int bc = white;int fc = black;void user_func1(WMWindow *win){ printf("Event 1\n");#ifdef GB2312 SA_WM_set_fg_color(fc); SA_WM_set_bg_color(bc); fc+=8; bc+=8;#endif SA_WM_label(tip2, "EVENT 1 OK"); x += 5; y += 5; rate -= 1; w = rate*32; h = rate*24; // change window size SA_WM_alignment_set(tip3, x, y, w, h);}void user_func2(WMWindow *win){ printf("Event 2\n");#ifdef GB2312 SA_WM_set_fg_color(fc); SA_WM_set_bg_color(bc); fc-=8; bc-=8;#endif SA_WM_label(tip2, "EVENT 2 OK"); x -= 5; y -= 5; rate += 1; w = rate*32; h = rate*24; // change window size SA_WM_alignment_set(tip3, x, y, w,h);}@1.1log@Initial revision@text@@1.1.1.1log@native SPD@text@@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -