⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list_14_03.c

📁 This source code has been tested under OpenWindows 2.0, Sun s X11/NeWS server. For Xlib programs th
💻 C
字号:
/*************************************************************************                                                                    ****  listing_14_3.c                                                    ****                                                                    ****  List example. This program simulates address selection for an     ****  e-mail program. It presents two lists: the top list contains      ****  all known e-mail addresses, the second contains the addresses     ****  for the current message. These lists are maintained in a form,    ****  so they may be expanded as needed.                                ****                                                                    ****  In a real program, this code would be in a dialog box, with the   ****  addresses read from a data file.                                  ****                                                                    *************************************************************************/#include <Xm/Form.h>#include <Xm/Label.h>#include <Xm/List.h>void	LoadAddressList();		/* FORWARD Definitions	      */void	AddressListCB();Widget	appshell,			/* Application Shell	      */	the_form,			/* Child of the shell	      */	catlist,			/* Address Catalog list       */	cat_lbl,			/* Address Catalog label      */	sellist,			/* Selected Addresses list    */	sel_lbl;			/* Selected Addresses label   */Arg	arglist[16];			/* Used to set resources      */#define	    XMS( s )	XmStringCreate( s, XmSTRING_DEFAULT_CHARSET )void main( argc, argv )    int     argc;    char    *argv[];{    appshell = XtInitialize( argv[0], "Listing_14_03", NULL, 0, &argc, argv );    the_form = XmCreateForm( appshell, "TheForm", NULL, 0 );    XtManageChild( the_form );    cat_lbl = XmCreateLabel( the_form, "CatLbl", NULL, 0 );    XtManageChild( cat_lbl );    catlist = XmCreateList( the_form, "CatList", NULL, 0 );    XtManageChild( catlist );    LoadAddressList();    XtAddCallback( catlist, XmNbrowseSelectionCallback, AddressListCB, NULL );    sel_lbl = XmCreateLabel( the_form, "SelLbl", NULL, 0 );    XtManageChild( sel_lbl );    sellist = XmCreateList( the_form, "SelList", NULL, 0 );    XtManageChild( sellist );    XtRealizeWidget( appshell );    XtMainLoop();}/***** LoadAddressList()****** Fills the "items" resource of "catlist". In the real world, this*** function would read the addresses from a data file.**/void LoadAddressList(){    XmString	addresses[9];    addresses[0] = XMS( "kdg@world.std.com" );    addresses[1] = XMS( "postmaster@moscvax.arpa" );    addresses[2] = XMS( "xug@expo.lcs.mit.edu" );    addresses[3] = XMS( "xannounce@expo.lcs.mit.edu" );    addresses[4] = XMS( "xpert@expo.lcs.mit.edu" );    addresses[5] = XMS( "motif@alfalfa.com" );    addresses[6] = XMS( "info-c@research.att.com" );    addresses[7] = XMS( "std-unix@uunet.uu.net" );    addresses[8] = XMS( "unix-wizards@brl.arpa" );    XtSetArg( arglist[0], XmNitems, addresses );    XtSetArg( arglist[1], XmNitemCount, XtNumber(addresses) );    XtSetValues( catlist, arglist, 2 );}/***** AddressListCB()****** Address List Callback. This function is called whenever an address*** in the top list is selected. It adds that address to the bottom*** list, if it isn't already there.**/void AddressListCB( w, client_data, call_data )    Widget		    w;    caddr_t		    client_data;    XmListCallbackStruct    *call_data;{    if (!XmListItemExists(sellist, call_data->item))        XmListAddItem( sellist, call_data->item, 0 );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -