John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (779881), страница 34
Текст из файла (страница 34)
However, for each user key press,three events are generated: key up, key down, and keypress. The keycode can be extracted from the key pressevent (see above).ev&() indices for these event types are:––34key down or key up event’s scancodekey modifiersOPL COMMAND LIST193Pen point eventsFor pen events, ev&(KEvAType%) is one of:KEvPtr&KEvPtrEnter&KEvPtrExit&&408&409&40Apen eventpen point enters a windowpen point leaves a windowThe ev&() for a pointer event is a nine-element arrayindexed by the following values:KEvAPtrOplWindowId%KEvAPtrWindowId%KEvAPtrType%KEvAPtrModifiers%KEvAPtrPositionX%KEvAPtrPositionY%KEvAPtrScreenPosX%KEvAPtrScreenPosY%33456789ID of parent windowsynonym for KEvAPtrOplWindowId%type of pointer event (see below)modifiersX coordinateY coordinateX coordinate relative to the parent windowY coordinate relative to the parent windowev&(KEvAPtrType%) contains the type of pointer event.A given device may not support all types of pointerevent, because of the wide range of possible pointerinput devices.
ev&(KEvAPtrType%) will contain one ofthe following values:KEvPtrPenDown&KEvPtrPenUp&KEvPtrButton1Down&KEvPtrButton1Up&KEvPtrButton2Down&KEvPtrButton2Up&KEvPtrButton3Down&KEvPtrButton3Up&KEvPtrDrag&KEvPtrMove&0101234567KEvPtrButtonRepeat&KEvPtrSwitchOn&89pen downpen upbutton 1 downbutton 1 upbutton 2 downbutton 2 upbutton 3 downbutton 3 uppointer drag (while button held down)pointer move (without any buttonbeing pressed)button repeatmachine turned on by a screen touchEvent notesConstants for event codes and subscripts are suppliedin Const.oph.Some pointer events, and pointer enters and exits,can be filtered out to avoid being swamped by unwantedevent types. See POINTERFILTER.194OPL COMMAND LISTFor unknown events, ev&(1) contains &1400 addedto the code returned by the window server. ev&(2) isthe timestamp, ev&(3) is the window ID, and the restof the data returned by the window server is put intoev&(4), ev&(5), etc.If a non-key event such as ‘foreground’ occurs whilea keyboard keyword such as GET, INPUT, MENU,or DIALOG is being used, the event is discarded.
SoGETEVENT must be used if non-key events are tobe monitored. If you need to use these keywords inapplications, use LOCK ON/LOCK OFF around them,so that the System screen won’t send messages to switchfiles or shutdown while the application cannot respond.See also GETEVENTA32.GETEVENTA32Waits for an event asynchronouslyUsage: GETEVENTA32 status%,ev&()Asynchronous version of GETEVENT32. GETEVENTA32 returns the same codes to the array ev&() asGETEVENT32.The exist status of GETEVENTA32 is placed intostatus% when an event is received.
For this reason,status% should probably be a global variable.See GETEVENTC, GETEVENT32, GETEVENT.GETEVENTCCancels an outstanding GETEVENT32Usage: GETEVENTC(var stat%)Cancels the previously called GETEVENTA32 functionwith status stat%.
Note that GETEVENTC consumes thesignal (unlike IOCANCEL), so IOWAITSTAT should notbe used after GETEVENTC.gFILLDraws a filled rectangleUsage: gFILL width%,height%,gMode%Fills a rectangle of the specified size from the currentposition, according to the graphics mode specified.The current position is unaffected.gFONTSets the current drawable’s fontUsage: gFONT fontUid&Sets the font for current drawable to fontId&.
The fontmay be one of the predefined fonts in the ROM or a userdefined font. See Graphics for more details of fonts.OPL COMMAND LIST195Constants for the font UIDs are supplied inConst.oph.User-defined fonts must first be loaded by gLOADFONT, then the font UIDs of the loaded fonts may beused with gFONT. Note that this is not the ID returnedby gLOADFONT (which is the font file ID), but the UIDdefined in the font file itself.See also gLOADFONT, FONT.gGMODESets the effect of subsequent drawing commandsUsage: gGMODE mode%Sets the effect of all subsequent drawing commandsgLINEBY, gBOX, etc. on the current drawable.KgModeSet%KgModeClear%KgModeInvert%012pixels will be setpixels will be clearedpixels will be invertedThese constants are supplied in Const.oph.When you first use drawing commands on a drawable, they set pixels in the drawable.
Use gGMODE tochange this. For example, if you have drawn a blackbackground, you can draw a white box outline insideit with either gGMODE 1 or gGMODE 2, followedby gBOX.gGREYChanges pen color between black and greyUsage: gGREY mode%Changes the pen color between black and grey. mode%has the following effects:mode%=1 sets the foreground color of the currentdrawable to light grey. This is the same color as wouldbe achieved by using gCOLOR $aa,$aa,$aa.mode% of any other value sets the foreground colorto black (the default).See also DEFAULTWIN and gCREATE.gHEIGHTHeight of the current drawableUsage: height%=gHEIGHTReturns the height of the current drawable.gIDENTITYID of the current drawable196OPL COMMAND LISTUsage: id%=gIDENTITYReturns the ID of the current drawable.The default window has ID=1.gINFO32Gets information about the current drawableUsage: gINFO32 var i&()Gets general information about the current drawableand about the graphics cursor (whichever window it isin) changed.
The information is returned in the arrayi%(), which must be at least 32 integers long. i&() musthave 48 elements, although elements 37 to 48 arecurrently unused.i%(1)i%(2)i%(3)i%(4)i%(5)i%(6)i%(7)i%(8)i%(9)i%(10–17)i%(18)i%(19)i%(20)i%(21)i%(22)i%(23)i%(24)i%(25)i%(26)i%(27)i%(28)i%(29)i%(30)i%(31)i%(32)i%(33)i&(34)i&(35)i&(36)reservedreservedheight of fontdescent of fontascent of fontwidth of '0' charactermaximum character widthflags for font (see below)the font UID as used in gFONTunusedcurrent graphics mode (gGMODE)current text mode (gTMODE)current style (gSTYLE)cursor state (ON=1,OFF=0)ID of window containing cursor (–1 for textcursor)cursor widthcursor heightcursor ascentcursor x position in windowcursor y position in window1 if drawable is a bitmapcursor effectsgraphics color mode of the current window.
Thiswill be one of the values described inDEFAULTWINgCOLOR red% of foregroundgCOLOR green% of foregroundgCOLOR blue% of foregroundgCOLOR red% of backgroundgCOLOR green% of backgroundgCOLOR blue% of backgroundOPL COMMAND LIST197The value given for i%(8) is a combination of the following values:12481632$8000font uses standard ASCII characters(32–126)font uses Code Page 1252 characters(128–255)font is boldfont is italicfont has serifsfont is monospacedfont is stored expanded for quick drawingi%(29) has bit 1 set (i%(29) AND 2) if the cursor is notflashing, and bit 2 set (i%(29) AND 4) if it is grey.If the cursor is off (i%(21)=0) or is a text cursor (i%(22)=-1), i%(23) to i%(27) and i%(29) shouldbe ignored.See also gFONT, gCOLOR, gCREATE.gINVERTDraws an inverted rectangleUsage: gINVERT width%,height%Inverts the rectangle width% to the right and height%down from the cursor position, except for the fourcorner pixels.GIPRINTDisplays an information messageUsage: GIPRINT str$,c%orGIPRINT str$Displays an information message for about two seconds, in the bottom right corner of the screen.
Forexample, GIPRINT "Not Found" displays Not Found. Ifa string is too long for the screen, it will be clipped.If c% is given, it controls the corner in which themessage appears. Corner constants for the informationmessage are as given for BUSY.Only one message can be shown at a time. You canmake the message go away – for example, if a key hasbeen pressed – with GIPRINT "".gLINEBYDraws a lineUsage: gLINEBY dx%,dy%198OPL COMMAND LISTDraws a line from the current position to a point dx%to the right and dy% down from the starting point.Negative dx% and dy% mean left and up, respectively.The end point is not drawn, so for gLINEBY dx%,dy%,point gX+dx%,gY+dy% is not drawn.
Note, however,that OPL specially plots the point when the start andend point coincide.The current position moves to the end of the linedrawn. gLINEBY 0,0 sets the pixel at the currentposition.See also gLINETO, gPOLY.gLINETODraws a line to an absolute positionUsage: gLINETO x%,y%Draws a line from the current position to the pointx%,y%. The current position moves to x%,y%. Theend point is not drawn, so for gLINETO x%,y%, pointx%,y% is not drawn. Note, however, that OPL specially plots the point when the start and end pointcoincide.To plot a single point on all machines, use gLINETOto the current position (or gLINEBY 0,0).See also gLINEBY, gPOLY.gLOADBITLoads a bitmapUsage: any ofid%=gLOADBIT(name$,write%,index%)id%=gLOADBIT(name$,write%)id%=gLOADBIT(name$)Loads a bitmap from the named bitmap file and makesit the current drawable.