>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User

# gl2 commands 11!:2000+n

gl2 commands are for 2D drawing in an isigraph control. Script system\main\gl2.js defines gl2 verbs in the jgl2 locale.
load 'gl2' NB. define gl2 verbs in jgl2 locale
The many gl2 definitions are in the jgl2 locale so they don't clutter up the z locale. Production users of gl2 can either use the full name (e.g. glline_jgl2_) or can use coinsert to add the jgl2 locale to their locale path. Requiring _jgl2_ on all names for casual use is a nuisance and you can use coinsert to add jgl2 to your. For example:
coinsert'jgl2'
Most gl2 commands add drawing information to a buffer. When the control is painted, it is painted with these buffered commands. Some commands, such as glcursor are not buffered commands and either have an immediate effect, or change a global state.
mapping mode affects how the logical units of the gl2 commands are mapped onto the display surface.
isigraph events allow user interaction with the isigraph control with the keyboard and mouse.
Command 11!:2999 takes a list of multiple gl commands. Each command starts with an integer count followed by the command and data. For example:
11!:2999 [ 4 2013 500 500 4 2013 900 100 2 2036 NB. glline, glline, glshow
11!:2999 [ 4 2056 500 200 5 2038 65 66 67 2 2036 NB. gltextxy, gltext, glshow
This can be used to move the overhead in the J Engine Protocol of passing thousands of individual small commands over the socket interface by one large 2999 command.

## gl2 Commands

glarc x y w h xa ya xz yz ; (not wince) draw arc on the ellipse defined by rectangle. Arc starts at xa,ya and ends at xz,yz. Start and end points need not lie on the ellipse, they define a line from the center that intersects the ellipse.
glbkcolor '' ; set current background color to current color (last grgb). Background color is used in the gaps in styled lines and as the background for text.
glbkmode bool ; (noop java) set background mode for gbkcolor to OPAQUE with 0, or TRANSPARENT with 1
glbmp filename ; (only win32) display bitmap in glbmpxywh rectangle
glbmpxywh x y w h ; (only win32) set rectangle for the display of a bitmap
glbrush '' ; select solid brush in current color
glbrushnull '' ; select null brush (leaves area painted with it unchanged)
glcapture type ; type is 0 release, 1 capture, 2 line band, 3 box band, 4 ellipse band, 5 vertical line, 6 horizontal line. A capture is normally done in a mouse down event and a glcapture 0 should be done in the mouse up event.
glcaret w h ; (not java) create a text caret at the current position with a width and height of w h.
glchord x y w h xa ya xz yz ; (only win32) same parameters as garc. Drawn with pen and brush.
glclear '' ; clear isigraph drawing buffer and reset defaults. If a printer context has been created, it is carried forward. Default values are 0 except for the following:

> glmap MM_DEFAULT
> glzmap twips
> glbkcolor white
> glwindowext 1000 1000
> glplaymap anisotropic
> glplayextent 1000 1000
> glextent 1

glclear n ; initialize graphics state. If n is '' or 0, then an InvalidateRect is done, If n is 1, then it is not done.
glcursor n ; sets mouse cursor. Values are defined as IDC_... in gl2.
glellipse x y w h ; draw an ellipse in the rectangle with pen and brush
glextent bool ; 0 selects the screen context and 1 selects the printer for glqextent and glqtextmetrics. The default is 1.
glextentfont fontspec ; set font for glqtextent and glqtextmetrics
glfile filename ; (only win32) set filename for glsave and glsavebmp. '' is the clipboard.
glflood i j color ; (only win32) fill area around point i,j with the current brush. The area is bounded by color.
glfont fontspec ; font for text commands
glgrid '' ; buffered drawing command that causes a grid to be painted. The grid is painted based on the state information set by the following glgrid... commands.
glgridatt attributes ; A set of attributes is a list of 20 integers. The argument is the ravel of the sets of attributes.

> attribute set: pen, brush, text, font, align, edit, 8 unused values
> pen, brush, and text are 3 integers with RGB values
> font: _1 selects font based on first character (-, _ , and digit select font 1); 0 selects font 0, 1 selects font 1
> align: _1 selects left or right based on first character (-, _, and digit selects right), 0 selects right, 1 selects left, 2 selects center.
> edit: 0 not editable, 1 editable

glgridborder borders ; a border is specified as 20 integers:
row, col, rows, cols, left b, top b, right b, bottom b
b field for each side is a type and RGB color
type is 0 to 3 and 11 for none, thin, medium, fat, and double line
glgriddrawmark '' ; undraw previous mark and draw new mark
glgridedit text ; create edit box at mark
glgridedit 0 ; destroy edit box
glgridedit 1 ; enable arrow keys in edit box
glgridfill width height fixfilltype filltype ; information about cells beyond the grid data
glgridfix row col ; fixed rows and columns
glgridfont0 fontspec ;
glgridfont1 fontspec ;
glgridgetedit '' ; get text from edit box
glgridgettext row col ; get text for this cell
glgridgettype row col ; get type and attributes for this cell
glgridh heights ; row heights for the grid data
glgridinvalidate bool ; 1 causes subsequent glgridtext and glgridtype commands to invalidate the cells they change.
glgridmark row col rows cols ; marked range of cells
glgridrc rows cols ; rows and columns in grid data
glgridrchw row col rows cols ; select subarray used in subsequent glgridtext and glgridtype commands
glgridscroll row col ; scrolled rows and columns
glgridskip row col ; rows and columns in total data that are not in grid data
glgridtext ; NULL terminated strings of grid data
glgridtype types ; integer value for each cell that selects its attributes
glgridw widths ; column widths for the grid data
glline i j ; draw line from current position to point i,j and update current position
gllined I j k l linelen spacelen [linelen spacelen ...] ; (not java) draw dashed line from i,j to k,l. Works only for vertical and horizontal lines.
gllines pts ; draw connected lines. pts is 2 or more points.
glmap mode ; See mapping mode.
glmove i j ; move current position to i,j
glnoerasebkgnd bool ; default paint clears background and if commands paint entire area this is not necessary. Set to 1 to avoid initial paint of background.
glpaint '' ; does immediate paint of a 2D control. The painting of a 3D control is delayed until the paint event handler can be run.
glpaintx '' ; mark control for painting when possible. If a glpaintx is done and J continues execution for a while, then the painting will be delayed.
glpen i [style] ; select pen. pen is color from last glrgb command and is i units wide. style is from the set (ps_solid, ps_dash, ps_dot, ps_dashdot, ps_dashdotdot, ps_null, ps_insideframe)
glpie x y w h xa ya xz yz ; (not wince) draw pie shaped wedge with pen and brush. Same parameters as garc.
glpixel i j ; draw pixel at i,j in current color
glpixels x y w h pixeldata ; pixeldata is an integer per pixel with RGB values
glplay filename ; (only win32) the wmf file filename is played into the isigraph control. The glplaymap, glplayxywh, and glplayext commands determine how the file is played.
glplayext extx exty ; (only win32) windowport extent information for scaling the wmf file
glplaymap mode ; (only win32) set map mode for playing a wmf file. See mapping mode.
glplayxywh x y w h ; (only win32) set rectangle for playing a wmf file. This is not a clipping rectangle and if the drawing goes beyond the w and h values it will be displayed. The w h values establish the extents that are used for scaling if the drawing is done in an isotropic or anisotropic mapping.
glpolygon pts ; draw polygon in pen and brush
glpolymode bool ; (only win32) 0 selects alternate filling of polygon and 1 selects winding
glqdevmode '' ; (only win32) return printer document properties (see glzdevmode)
glqextent text ; return width and height of the text in a particular font on a particular device. The glextent command determines whether the screen or printer context is used and glextentfont determines which font is used.

> The layout (rasterization) of text is quite complicated and the final length of text is not simply the sum of the lengths of the individual characters. For this reason, calculations based on character widths are not very useful.
> In addition, the length of text depends on the device. Drawing "testing 1 2 3" with an arial 240 font in a twips mapping will have different lengths on the screen, on a 150dpi printer, and on a 300dpi printer. Calculations such as line breaks, page breaks, and positioning stuff at the end of text are sensitive to the actual device.

glqpixels x y w h; return pixeldata as integer per pixel with RGB values
glqprinter '' ; (only win32) return printer information

> horzsize | width in millimeters
> vertsize | height in millimeters
> horzres | width in pixels
> Vertres | height in raster lines (pixels)
> logpixelsx | horizontal pixels per logical inch
> logpixelsy | vertical pixels per logical inch
> bitspixel | number of color bits per pixel.
> planes | number of color planes
> numcolors | number of entries in the device's color table (_1 if > 8)
> aspectx | relative width of a pixel
> aspecty | relative height of a pixel
> aspectxy | diagonal width of a pixel
> physicalwidth | width of the physical page. A 600 dpi printer on 8.5"x11" paper could have a physical width of 5100. The physical page is almost always greater than the printable area of the page, and never smaller.
> physicalheight | height of the physical page
> physicaloffsetx | distance from the left edge of the physical page to the left edge of the printable area. A 600 dpi printer on 8.5"x11" paper, that cannot print on the leftmost 0.25" of paper, has a horizontal physical offset of 150.
> physicaloffsety | distance from the top edge of the physical page to the top edge of the printable area

glqtextmetrics '' ; return font information. The context (screen or printer) is selected by glextent and the font is selected by glextentfont. The values are: Height, Ascent, Descent, InternalLeading, ExternalLeading, AverageCharWidth, MaxCharWidth
glqwh '' ; return window width and height in pixels.
glrect x y w h ; draw rectangle with pen and brush
glrgb color ; set current color
glroundr x y w h rw rh ; (not java) draw rectangle with rounded corners defined by ellipse with width rw and height rh
glsave flip w h ; (only win32) save drawing in WMF format in the glfile filename. Save to the clipboard if filename is empty.

> flip 0 has J orientation of 0 0 as lower left corner.
> flip 1 flips for applications like Word with 0 0 as upper left corner.
> w h are suggested clipboard width and height in 0.01 millimeters.
> The wmf file is saved without a "placeable metafile header". Some applications require this 22 byte header at the front of a wmf file. The utility addwmfheader from script system\main\winutil.js adds a header to a wmf file so that it is suitable for use by WORD and similar applications.

glsavebmp width height ; (only win32) save drawing as bitmap (24bit color) to glfile filename. Save to clipboard if filename is empty.
glsel id ; select isigraph child of currently selected parent for graphic commands
glsel hwndc ; hwndc is the result of wd'qhwndc' for an isigraph control. Parent and child are selected as the wd and gl command targets.
glshow '' ; add new commands (since last glshow or glshowx) to the 2D paint buffer and immediately paints just the new commands. A glshow immediately after creating and showing a form can result in extra painting and flicker. The glshow paints the new stuff, which in most cases is everything, and then the normal window painting mechanism requests painting the new window and the painting will be done again. It is generally better to use glshowx and glpaintx.
glshowx '' ; add new commands to the 2D paint buffer with no explicit painting
gltext text ; write text in the glfont font. Where and how the text is displayed is affected by the gltextalign and gltextxy commands.
gltextalign TA_value ; the TA_value affects how gltext displays text

> TA_LEFT TA_CENTER TA_RIGHT
> TA_TOP TA_BASELINE TA_BOTTOM
> TA_NOUPDATECP TA_UPDATECP
> The first option in each group is the default. TA_NOUPDATECP causes gltext to use the position set by gltextxy. TA_UPDATECP causes gltext to use and update the current position.
> Values from each of the 3 groups can be combined:
> gltextalign TA_BOTTOM + TA_UPDATEDCP

gltextcolor '' ; glrgb color is set as color of text for gtext
gltextjustify space nblanks; (only win32) space is the amount of space to insert for nblanks. This space per blank is inserted for EACH blank in subsequent gtext commands. Because of rounding error there may be unused space at the end of the text. To allow spacing multiple texts on the same line this unused space is carried over into the next qlgextent calculations. Justifying a line should be sure to start with this unused space set to 0. A gltextjustify 0 0 sets this unused space to 0. Each section of a line should be measured with glqextent and then a gltextjustify should be done with the required space and the number of blanks in that section of text, and finally the gltext should be done. At the end of the justifying a line it is a good practice to do a gltextjustify 0 0 to clear the unused space value and to be sure that subsequent text is not inadvertently spaced out.

> gltext commands painted with glshow after gltextjustify commands have been processed will not be justified unless the entire control is repainted. glpaint forces a repaint.
> The Macintosh runs the gltextjustify command without error, but text justification is not supported and the text is displayed without justification.

gltextxy x y ; position for gltext with gltexalign of TA_NOUPDATECP
gltop topvalue ; (not java) topvalue is in logical units and ties that y coordinate value to the top of the drawing . This can be used to make a window display the top part of an image, rather than the bottom part.
glwantresize ; request resize event for gl2 control.
glwindowext x y ; default is 1000 1000. Change these values to change the scale (zoom) in anisotropic and isotropic mappings
glwindoworg x y ; (not java) default is 0 0. Change these values to scroll the drawing in the viewport
glzabortdoc '' ; (only win32) cancel the print job
glzcreate printername ; (only win32) name from the set of printers returned by wd qprinters. If no name is given then the session default printer is used. If a printer context already exists, it is deleted before creating the new context. The session default printer is the system default printer when J is started. This can be changed with wd mbprinter.
glzdelete '' ; (only win32) deletes printer context created by glzcreate. There is no error if there is no context.
glzdevmode '' ; (only win32) modifies printer document properties such as orientation and copies. The command glqdevmode returns the properties that can be changed by glzdevmode and their current values. You can determine arguments for glzdevmode by using mbprinter to create the desired printer document setup and then use glqdevmode to get those values. This command must be done before the glzstartpage command.

> The Macintosh does not support glzdevmode and printer properties can not be changed.
> The information returned is: orientation, papersize, paperlength, paperwidth, scale, copies, source, quality, color, duplex, yresolution, truetype

glzenddoc '' ; (only win32) ends a document.
glzendpage '' ; (only win32) ends a page.
glzmap mode ; (only win32) set mapping mode used in printing. Default is twips.
glzprint '' ; (only win32) draws the image on the printer.
glzprintpage ; (only java) prints current page
glzstartdoc 'jobname [filename]' ; (only win32) the job name can be up to 31 characters and appears in print manager. The filename indicates to print to a file instead of the printer. This file can be printed with the print command. The Macintosh does not support the second parameter of file name.
glzstartdoc '"first job"'
glzstartdoc '"my job" tofile.prn'
glzstartpage '' ; (only win32) starts a page. Each page must be bracketed by a glzstartpage and a glzendpage.
glzstartprint ; (only java) start printer job
glzorientation n ; (not wince) 0 landscape, 1 portrait

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User