GDDM V3R2 Base Application Programming Guide
Previous topic | Next topic | Contents | Index | Contact z/OS | Library | PDF | BOOK


Dragging segments

GDDM V3R2 Base Application Programming Guide
SC33-0867-01



If a segment is to be repositioned, you can often help the end user by enabling a copy of it to be dragged around the screen before its final position is determined. You do this by making the segment the locator echo. The program in Figure 65 shows you how.

The locator is initialized at A with a type 6 echo, that is, a segment. The segment is a square.

The last parameter of the GSIDVI call, at B , specifies that the segment containing the square, namely segment 9, is the one to be used as the echo.

The GSIDVF calls at C and D offset the echo from the locator position by 0.2 window units in the x and y directions. The reason is explained in "How the 3270-PC/G and GX draw echoes" in topic 11.12.1.

The GSREAD, E , displays the square onto the screen. The end user can then drag a copy of it around with the mouse, puck, stylus, or cursor keys.

The GSREAD waits for an interrupt from the terminal. Any locator-trigger key can be used to send this interrupt; a mouse or puck button or the stylus tip-switch is probably the most convenient. When the interrupt is received, execution of the program resumes. The position of the locator is queried and a GSSPOS issued to move the segment to that position.

This example shows a very simple case. In less straightforward cases, you may get unexpected results if you do not pay particular attention to the segment origin. More information is given in "Local origin when dragging a segment" in topic 11.12.2.



DRAG1: PROCEDURE OPTIONS (MAIN); DCL (DEVICE_ID,DEVICE_TYPE) FIXED BIN(31); DCL INWIN FIXED BIN(31); DCL (X,Y) FLOAT DEC (6); DCL (YES,NO,STOP) FIXED BIN(15); /* Flags */ YES=1; NO=0; /* Values for flags */

CALL FSINIT; /* Initialize GDDM */

CALL GSUWIN(0.0,100.0,0.0,100.0); /* Uniform window coords.*/

CALL GSSATI(4,2); /* Make transformable a */ /* current segment attr. */ /* so square can be moved*/ CALL GSSEG(9); /* Open numbered segment */ CALL GSMOVE(0.0,0.0); /* Start square */ CALL GSLINE(10.0,0.0); /* Draw */ CALL GSLINE(10.0,10.0); /* sides */ CALL GSLINE(0.0,10.0); /* of */ CALL GSLINE(0.0,0.0); /* square */ CALL GSSCLS; /* Close segment */

CALL GSILOC(1,6,0.0,0.0); /* Set up locator ( eg. */ A CALL GSIDVI(2,1,1,9); /* a mouse) to drag */ B /* segment 9. */ CALL GSIDVF(2,1,1,0.2); /* Offset echo from */ C CALL GSIDVF(2,1,2,0.2); /* original segment */ D CALL GSENAB(2,1,1); /* Enable the locator. */

STOP=NO; /* Initialize flag */ DO WHILE (STOP=NO); CALL GSREAD(1,DEVICE_TYPE,DEVICE_ID);/* Display the square */ E /* Square moves as the */ /* cursor is moved. */ /* When trigger key is */ /* pressed, control */ /* returns to program. */ CALL GSQLOC(INWIN,X,Y); /* Get the location */ CALL GSSPOS(9,X,Y); /* Move the square */ IF X < 10.0 THEN STOP=YES; /* Stop when locator near*/ /* l.hand edge of screen */ END; CALL FSTERM; /* Terminate GDDM */ %INCLUDE ADMUPINF; %INCLUDE ADMUPING; END DRAG1;


Figure 65. Program for dragging segments


If you want to return to the default cursor as the locator echo after dragging a segment, you must disable and then reinitialize the locator before reenabling it:


     CALL GSENAB(2,1,0);         /* Disable the locator              */
     CALL GSILOC(1,2,X,Y);       /* Reinitialize with cursor as echo */
     CALL GSENAB(2,1,1);         /* Reenable                         */

Subtopics:

Go to the previous page Go to the next page



Copyright IBM Corporation 1990, 2012