收藏 分享(赏)

c语言画图.doc

上传人:buyk185 文档编号:6102898 上传时间:2019-03-27 格式:DOC 页数:11 大小:51KB
下载 相关 举报
c语言画图.doc_第1页
第1页 / 共11页
c语言画图.doc_第2页
第2页 / 共11页
c语言画图.doc_第3页
第3页 / 共11页
c语言画图.doc_第4页
第4页 / 共11页
c语言画图.doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

1、1#include #include #include #include #include #include #include #include void FbtnActivateCallback();void FtextInputCheck();void FtextSumit();void FpostMenu();void FdeleteListItem();XtAppContext g_app;Widget g_wScrollList;Widget g_wTextField;Widget g_wPushButton;Widget g_wLabel;Widget g_wPopupMenuPa

2、nel;int g_iScreenW;int g_iScreenH;int g_iMainW;2int g_iMainH;int g_iMoveX;int g_iMoveY;int g_iSelectedItem;void main(argc, argv)int argc;char *argv;Arg args256;int n;g_iSelectedItem = 0;Widget toplevel;toplevel = XtVaAppInitialize(g_iMainW = 200;g_iMainH = 350;g_iScreenW=WidthOfScreen(XtScreen(tople

3、vel);g_iScreenH=HeightOfScreen(XtScreen(toplevel);printf(“w: %dnh: %dn“, g_iScreenW, g_iScreenH);g_iMoveX = (g_iScreenW - g_iMainW)/2;g_iMoveY = (g_iScreenH - g_iMainH)/2;3XtVaSetValues( toplevel,XmNx, g_iMoveX,XmNy, g_iMoveY,XmNtitle, “exam“,XmNwidth,g_iMainW,XmNheight, g_iMainH,XmNmaxWidth,g_iMain

4、W,XmNminWidth,g_iMainW,XmNmaxHeight,g_iMainH,XmNminHeight,g_iMainH,NULL);/formWidget form1 = XtVaCreateManagedWidget( “form1“, xmFormWidgetClass, toplevel, NULL);XtVaSetValues( form1,XmNwidth,g_iMainW,XmNheight, g_iMainH,XmNmaxWidth, g_iMainW,XmNminWidth, g_iMainW,XmNmaxHeight, g_iMainH,XmNminHeight

5、, g_iMainH,NULL);XtManageChild(form1);/4XmString cString;Widget menu_item;cString = XmStringCreateSimple(“Delete“);XtSetArg(args0, XmNmenuAccelerator, “Ctrlp“);g_wPopupMenuPanel = XmCreatePopupMenu(form1, “, args, 1);XtSetArg(args0, XmNlabelString, cString);XtSetArg(args1, XmNmnemonic, D);menu_item

6、= XmCreatePushButtonGadget(g_wPopupMenuPanel, “Delete“, args, 2);XtAddCallback(menu_item, XmNactivateCallback, FdeleteListItem, “delete“);XtManageChild(menu_item);XmStringFree(cString);/n = 0;XtSetArg(argsn, XmNwidth, 200); n+;XtSetArg(argsn, XmNheight, 270); n+;XtSetArg(argsn, XmNrightAttachment, X

7、mATTACH_FORM); n+;XtSetArg(argsn, XmNrightOffset, 5); n+;XtSetArg(argsn, XmNleftAttachment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNleftOffset, 5); n+;XtSetArg(argsn, XmNtopAttachment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNtopOffset, 0); n+;XtSetArg(argsn, XmNbottomAttachment, XmATTACH_FORM); n+;5XtSe

8、tArg(argsn, XmNbottomOffset, 80); n+;XtSetArg(argsn, XmNselectionPolicy, XmSINGLE_SELECT); n+;g_wScrollList = XmCreateScrolledList(form1, “, args, n);XtManageChild(g_wScrollList);XtAddCallback(g_wScrollList, XmNsingleSelectionCallback, FpostMenu, g_wPopupMenuPanel);/n = 0;XtSetArg(argsn, XmNtopAttac

9、hment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNtopOffset, 280); n+;XtSetArg(argsn, XmNleftAttachment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNleftOffset, 10); n+;XtSetArg(argsn, XmNwidth, 100); n+;XtSetArg(argsn, XmNheight, 30); n+;g_wTextField = XmCreateTextField(form1, “, args, n);XtAddCallback(g_wTex

10、tField, XmNmodifyVerifyCallback, FtextInputCheck, 9);XtAddCallback(g_wTextField, XmNactivateCallback, FtextSumit, 9);XtManageChild(g_wTextField);/n = 0;XtSetArg(argsn, XmNtopAttachment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNtopOffset, 280); n+;XtSetArg(argsn, XmNleftAttachment, XmATTACH_FORM); n+;6X

11、tSetArg(argsn, XmNleftOffset, 130); n+;XtSetArg(argsn, XmNwidth, 60); n+;XtSetArg(argsn, XmNheight, 30); n+;g_wPushButton = XmCreatePushButton(form1, “Close“, args, n);XtAddCallback(g_wPushButton, XmNactivateCallback, FbtnActivateCallback, 1);XtManageChild(g_wPushButton);/n = 0;XtSetArg(argsn, XmNto

12、pAttachment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNtopOffset, 315); n+;XtSetArg(argsn, XmNleftAttachment, XmATTACH_FORM); n+;XtSetArg(argsn, XmNleftOffset, 10); n+;XtSetArg(argsn, XmNwidth, 180); n+;XtSetArg(argsn, XmNheight, 30); n+;g_wLabel = XmCreateLabel(form1, “, args, n);/XtAddCallback(g_wPush

13、Button, XmNactivateCallback, FbtnActivateCallback, 1);XtManageChild(g_wLabel);XtRealizeWidget(toplevel);XtAppMainLoop(g_app);7void FbtnActivateCallback(widget, cl, cb)Widget widget;int cl;caddr_t cb;exit(0);void FtextInputCheck(textField, maxNum, cb)Widget textField;int maxNum;XmTextVerifyCallbackSt

14、ruct *cb;int len = 0;char c;if(cb-startPos currInsert)return;c = cb-text-ptr0;if(c z | (c 9 return;len = XmTextGetLastPosition(textField);8if(len = maxNum)cb-doit = False;return;void FtextSumit(textField, cl, cb)Widget textField;int cl;caddr_t cb;char *text;char *str;XmString newItem;XmStringTable x

15、mStrArray;int len;int listItemCount;len = XmTextGetLastPosition(textField);if(len = 0)return;text = XmTextGetString(textField);XmTextSetString(textField, “);XtVaGetValues(g_wScrollList, XmNitems, 9int i = 0;for(i = 0; i event != Button3 )/| cb-event-xbutton.button != 3)/ return;g_iSelectedItem = cb-

16、item_position;XmMenuPosition(popup, cb-event);XtManageChild(popup);void FdeleteListItem(menu_item, item_no, c_data)Widget menu_item;int item_no;XmAnyCallbackStruct *c_data;11int listItemCount;printf(“xyf_delete itemn“);if(g_iSelectedItem = 0)return;XmListDeletePos(g_wScrollList, g_iSelectedItem-);/if(g_iSelectedItem = 0)/ break;/XmListSelectPos(list)XtVaGetValues(g_wScrollList, XmNitemCount, if(listItemCount = 19)char str256;XmString xmStr;memset(str, 0, sizeof(str);sprintf(str, “);xmStr = XmStringCreateSimple(str);XtVaSetValues(g_wLabel, XmNlabelString, xmStr, NULL);XmStringFree(xmStr);

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 网络科技 > C/C++资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报