Guidance
指路人
g.yi.org
Software / Reginald / Examples / view.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/*
GUIBEGIN
WINDOW , 45, 163, 358, 229, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Santa Claus' list
	FONT 8, 400, MS Shell Dlg
	VIEW 4, 4, 347, 180, REPORT|SINGLE|ALWAYS|SHARE|EDIT|BORDER, , MyView
	PUSH 8, 191, 60, 14, TABSTOP, , Bad, , Delete bad kids
	PUSH 78, 191, 57, 14, TABSTOP, , NewGift, , Jeff's new gift
	PUSH 148, 191, 70, 14, TABSTOP, , ShowSel, , Display selected
DEND
GUIEND
*/

/* This shows how to use REXX GUI's VIEW control in "Report mode". We're going
 * to create Santa Claus' christmas list.
 */

LIBRARY rexxgui

guierr = "SYNTAX"
guiheading = 1
guicreatewindow('NORMAL')

/* Tell the VIEW control to inform us if anyone clicks upon
 * an item. Also, select the full row (instead of only the
 * first column) when selected)
 */
guisendmsg("MyView", "SETEXTENDEDLISTVIEWSTYLE", "CLICK|FULLROW", "CLICK|FULLROW")

/* Add three columns to the VIEW control. with the labels "Name", "Occupation",
 * and "Christmas present" respectively. We do this with GuiAddCtlText().
 * The first arg is the variable associated with the VIEW. The second arg
 * is the name of a stem variable we have initialized to contain information
 * about a column. And the third arg is a 1.
 *
 * We must initialize the stem as follows:
 *
 * Stemname.!Width = The column's width (in percentage).
 * Stemname.!Text = The column's label.
 * Stemname.!State = Various options. Any of the following, separated by a | character:
 *					"LEFT" = Label is left-aligned. The first column must be LEFT aligned.
 *					"RIGHT" = Label is right-aligned.
 *					"CENTER" = Label is centered.
 *					"HASIMAGE" = The column has an image displayed beside its label.
 *					"RIMAGE" = The image is displayed to the right (not left) of the label.
 *					"IMAGE" = Items under this column have images displayed.
 *					If this variable is not set, defaults to "LEFT".
 * Stemname.!SubItem = The sub-item number. If this variable is not set,
 *					the sub-item number is 0.
 * Stemname.!Image = The number of the image displayed beside the label. If this variable is not set,
 *					no image is displayed.
 * Stemname.!Order = Where the column is inserted. A 0 inserts as the first column. If not specified,
 *			the column is inserted as the last column.
 */
DO i = 1 TO 3
	mycolumn.!width = 33  /* 1/3 of the VIEW control's width */
	SELECT i
		WHEN 1 THEN mycolumn.!text = "Name"
		WHEN 2 THEN mycolumn.!text = "Occupation"
		OTHERWISE mycolumn.!text = "Christmas present"
	END
	mycolumn.!state = "LEFT"
	mycolumn.!subitem = i
	guiaddctltext("MyView", "MyColumn", 1)
END

/* Add some items under the columns. To add an item, we call GuiAddCtlText()
 * again, but omit the third arg. Again, the second arg is the name of a
 * stem variable that we must fill in with info about the item to add.
 *
 * We must initialize the stem as follows:
 *
 * Stemname.!Item = The item number.
 * Stemname.!SubItem = The column (subitem) number to place this item under.
 * Stemname.!Text = The text for the item.
 * Stemname.!State = Various options. Any of the following, separated by a | character:
 *					"FOCUS" = This item has the focus.
 *					"SELECT" = Item is selected.
 *					"CUT" = Item is marked for a cut-and-paste operation.
 *					"DROP" = Item is highlighted as a drag-and-drop target.
 *					If this variable is not set, defaults to none of the above.
 * Stemname.!Image = The number of the image displayed beside the label. If this variable is not set,
 *					no image is displayed.
 * Stemname.!Data = Any number you wish associated with this item. It can be used for any purpose. This
 *		can be set only for an item under the first column.
 */

myitem.!item = 1	/* First item */
myitem.!subitem = 1	/* Under the first column (ie, Name) */
myitem.!text = "Mike S."
myitem.!state = "SELECT"
guiaddctltext("MyView", "MyItem")
/* Note: MyItem.!Item = 1 for First item */
myitem.!subitem = 2	/* Under the second column (ie, Occupation) */
myitem.!text = "Causing havoc at a bank"
myitem.!state = ""
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 3	/* Under the third column (ie, Christmas present) */
myitem.!text = "A new database"
guiaddctltext("MyView", "MyItem")

myitem.!item = 2	/* Second item */
myitem.!subitem = 1	/* Under the first column (ie, Name) */
myitem.!text = "Mestrini"
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 2	/* Under the second column (ie, Occupation) */
myitem.!text = "Finding bugs"
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 3	/* Under the third column (ie, Christmas present) */
myitem.!text = "More bugs"
guiaddctltext("MyView", "MyItem")

myitem.!item = 3	/* Third item */
myitem.!subitem = 1	/* Under the first column (ie, Name) */
myitem.!text = "Jeff G"
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 2	/* Under the second column (ie, Occupation) */
myitem.!text = "Developing Reginald 24/7"
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 3	/* Under the third column (ie, Christmas present) */
myitem.!text = "Fame and fortune???"
guiaddctltext("MyView", "MyItem")

myitem.!item = 4
myitem.!subitem = 1
myitem.!text = "PeterJ"
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 2
myitem.!text = "Asking for new features"
guiaddctltext("MyView", "MyItem")
myitem.!subitem = 3
myitem.!text = "Already received"
guiaddctltext("MyView", "MyItem")

giftitem = 3


again:
DO FOREVER
	guigetmsg()
	CATCH SYNTAX
			CONDITION('M')
			SIGNAL again
	CATCH HALT
	FINALLY
		guidestroywindow()
END
RETURN

wm_rclick_myview:
	/* Called when user clicks the right mouse button on an item. The variable for our control is
	 * set to which column was clicked upon, and the variable.1 is set to
	 * the item number.
	 */
	guisay("Clicked the right mouse button on column" myview "of item" myview.1)
	RETURN


wm_click_myview:
	/* Called when user clicks the left mouse button on an item. The variable for our control is
	 * set to which column was clicked upon, and the variable.1 is set to
	 * the item number.
	 */
	guisay("Clicked the left mouse button on column" myview "of item" myview.1)
	RETURN

wm_columnclick_myview:
	/* Called when user clicks on a column header. The variable for our control is
	 * set to which column was clicked upon.
	 */
	guisay("User clicked upon column" myview)
	RETURN

wm_click_bad:
	/* Delete some items. We do this by sending a DELETEITEM message, and the
	 * third arg is the item #.
	 */
	guisendmsg("MyView", "DELETEITEM", 1)
	guisendmsg("MyView", "DELETEITEM", 1)
	guisendmsg("MyView", "DELETEITEM", 2)
	giftitem = 1
	RETURN


wm_click_newgift:
	/* Change Jeff's Christmas gift. We send a SETITEMTEXT message.
	 * The third arg is the item (row) #. The fourth arg is the subitem
	 * (column) #. The fifth arg is the new text.
	 */
	guisendmsg("MyView", "SETITEMTEXT", giftitem, 3, "A life")
	RETURN


wm_click_showsel:
	/* Get how many items there are. */
	guisendmsg("MyView", "GETITEMCOUNT")
	count = guisignal

	/* Go through all items and query the selection state. NOTE: We made our
	 * VIEW single select, so we should have only 1 selected item.
	 */
	DO i = 1 TO count

		/* We query an item's state by sending the GETITEMSTATE message. The
		 * third arg is the item #. The fourth arg is "SELECT" to query the
		 * selection state.
		 */
		guisendmsg("MyView", "GETITEMSTATE", i, "SELECT")

		/* Is it selected? If so, GuiSignal is "SELECT". Otherwise an empty string */
		IF guisignal == "SELECT" THEN guisay("Item" i "is selected.")

	END
	RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2017-6-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:45:30