/* 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. */ OPTIONS "C_CALL LABELCHECK" NUMERIC DIGITS 10 LIBRARY rexxgui GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') /* 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_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