John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (779881), страница 33
Текст из файла (страница 33)
It should only be used for copyingfrom bitmaps to windows or other bitmaps.As this command can copy both set and clear pixels,the same modes are available as when displaying text.Possible values for mode% are:KtModeSet%KtModeClear%KtModeInvert%KtModeReplace%0123SetClearInvertReplaceSet, Clear, and Invert act only on set pixels in thepattern; Replace copies the entire rectangle, with setand clear pixels.The current position is not affected in either window.gCREATECreates a windowUsage: either ofid%=gCREATE(x%,y%,w%,h%,v%)id%=gCREATE(x%,y%,w%,h%,v%,flags%)Creates a window with specified position and size(width w%, height h%), and makes it both current andforeground.
The current position is set initially to (0,0),the top left corner.OPL COMMAND LIST187The v% argument specifies whether the window isinitially visible:KgCreateInvisible%KgCreateVisible%01invisible windowvisible windowgCREATE returns the ID of the window. Window IDsare used as arguments to other functions and keywords,and refer to the newly created window.Window mode flagsThe flags% argument specifies the graphics mode andshadowing style to use on the window. The defaults are2-color, with no shadow.It is simplest to specify flags% as a hexadecimalnumber, as its value is a bitwise OR of significantvalues.The least significant 4 bits of flags% (masked by$000F) give the color mode.
The next 4 bits (masked by$00F0) specify the window’s shadowing. The followingconstant values can be added, or ORed to give the first8 bits of flags%:KColorgCreate2GrayMode%KColorgCreate4GrayMode%KColorgCreate16GrayMode%KColorgCreate256GrayMode%KColorgCreate16ColorMode%KColorgCreate256ColorMode%KgCreateHasShadow%$0000$0001$0002$0003$0004$0005$00102-grey mode256-grey mode16-color mode256-color modewindow has a shadowThese constants are provided in Const.oph. The oldconstants, KgCreate2ColorMode%, KgCreate4ColorMode%, and KgCreate16ColorMode%, are still retainedfor backwards compatibility.Note: It is not an error to create a window withfeatures not supported on the hardware, but it isinefficient and should be avoided. This is similar tothe concept of copying a 4-grey bitmap into a 2grey window on greyscale machines: processor time iswasted dithering the colors down to the same level asthe window.Bits 8–11 (masked by $0F00) give the shadow heightrelative to the window behind it as a left-shifted 4bit number.
A height of N units gives a shadow ofN*2 pixels.188OPL COMMAND LISTExamples:flags% description$412 16-color mode ($2), shadowed window ($1), with height 4 units($4) above the previous window with a shadow of 8 pixels$010 2-color mode (black and white) shadowed window at the sameheight as the previous window$101 4-color mode window with no shadow (height ignored ifshadow disabled)$111 4-color mode window with shadow of 1 unit above windowbehind, i.e. 2 pixel shadowNote that 63 windows may be open at any time andit is recommended that you use many small windowsrather than a few large ones.See also gCLOSE, gCOLOR, DEFAULTWIN.gCREATEBITCreates a bitmapUsage:id%=gCREATEBIT(w%,h%)id%=gCREATEBIT(w%,h%,mode%)Creates a bitmap with the specified width and height,and makes it the current drawable.
Sets the currentposition to 0,0, its top left corner.Returns id%, which identifies this bitmap for otherkeywords.gCREATEBIT may be used with an optional thirdparameter that specifies the graphics mode of thebitmap to be created. The values of these are as givenin gCREATE. By default the graphics mode of a bitmapis 2-color.See also gCLOSE, gCREATE.gELLIPSEDraws an ellipseUsage: gELLIPSE hRadius%,vRadius%orgELLIPSE hRadius%,vRadius%,fill%Draws an ellipse with the center at the current positionin the current drawable. hRadius% is the horizontaldistance in pixels from the center of the ellipse to theOPL COMMAND LIST189left (and right) of the ellipse.
vRadius% is the verticaldistance from the center of the ellipse to the top (andbottom). If the length of either radius is less than zero,then no ellipse is drawn.If fill% is supplied and if fill%<>0 then the ellipse isfilled with the current pen color.See gCIRCLE, gCOLOR.GEN$Converts a number to a stringUsage: g$=gen$(x,y%)Returns a string representation of the number x. Thestring will be up to y% characters long.Example: GEN$(123.456,7) returns "123.456" andGEN$(243,5) returns "243".If y% is negative then the string is right-justified – forexample, GEN$(1,-6) returns "1" where there are fivespaces to the left of the 1.If y% is positive then no spaces are added, forexample GEN$(1,6) returns "1".If the number x will not fit in the width specified byy%, then the string will just be asterisks, for exampleGEN$(256.99,4) returns "****".See also FIX$, NUM$, SCI$.GETWaits for and returns the keycode for the next keypressedUsage: g%=GETWaits for a key to be pressed and returns the charactercode for that key.For example, if the A key is pressed with Caps Lockoff, the integer returned is 97 (a), or 65 (A) if A waspressed with the Shift key down.The character codes of special keys, such as Pg Dn,are given in Appendix D.You can use KMOD to check whether modifier keys(Shift, Ctrl, Fn, and Caps) were used.See also KEY.GET$Waits for and returns the next key pressed as a stringUsage: g$=GET$190OPL COMMAND LISTWaits until a key is pressed and then returns which keywas pressed, as a string.For example, if the A key is pressed in lowercasemode, the string returned is "a".You can use KMOD to check whether any modifierkeys (Shift, Ctrl, Fn, and Caps) were used.See also KEY$.GETCMD$Gets new command line argumentsUsage: w$=GETCMD$Returns new command line arguments to an OPL application, after a change files or quit event has occurred.Usually this is called after GETEVENT32 has returned asystem command.The command line arguments are returned as astring.
The first character of the return value has thefollowing meaning:KGetCmdLetterCreate$ "C" close down the current file, and createthe specified new fileKGetCmdLetterOpen$ "O" close down the current file, and open thespecified existing fileKGetCmdLetterExit$"X" close down the current file (if any) andquit the appThese constants are defined in Const.oph.If the first character is KGetCmdLetterCreate$ orKGetCmdLetterOpen$, then the rest of the returnedstring is a filename.You can only call GETCMD$ once for each system message.GETDOC$Gets the name of the current documentUsage: docname$=GETDOC$Returns the name of the current document.See also SETDOC.GETEVENTDeprecated version of GETEVENT32This keyword is included for compatibility with olderversions of the OPL language.OPL COMMAND LIST191It is strongly recommended that you useGETEVENT32 rather than GETEVENT. GETEVENT issupported only for backward compatibility and cannotbe used to handle pen events in a satisfactory way.GETEVENT32Synchronous wait for eventSection contentsKey press eventsForeground, background, and switch on eventsCommand events (exit or file switch)Key down and key up eventsPen point eventsEvent notesUsage: GETEVENT32 ev&()Waits for an event to occur, and returns withev&() specifying the event.
The data returned inev&() depends on the type of event that occurred.All events return a 32-bit time stamp. The windowID mentioned below refers to the value returned by thegCREATE keyword. The modifier values and scancodevalues for a key press (which specify a location on thekeyboard) are given in the Character codes.Const.oph supplies the following constants for indexing ev&():KEvAType%KEvATime%12type of the event32-bit time stampThese event index numbers and their meanings are thesame for all possible kinds of event. ev&(KEvAType%) isalways the event type, and ev&(KEvATime%) is alwaysthe time stamp for the event.
The meanings of othervalues in ev&() are dependent on the type of event.Keypress eventsNote that keycodes are returned in the first elementof ev&(), ev&(KEvAType%). To recognize a key pressevent, you have to use a bit mask. Key press events aremasked by KEvNotKeyMask&.For a key press event, (ev&(KEvAType%) AND KEvNotKeyMask&) is always 0.KEvNotKeyMask&&400masks out non-key press events192OPL COMMAND LISTThe index values for a key event are:––KEvAKMod%KEvAKRep%1345key code (cooked)scan code (raw)index for the key modifierindex for the repeat valueev&(KEvATime%) is the time stamp, as with any otherevent.Foreground, background, and switch on eventsFor these events, ev&(KEvAType%) is one of:KEvFocusGained&&401KEvFocusLost&&402KEvSwitchOn&&403program has moved toforegroundprogram has moved tobackgroundmachine is switched onNote that KEvSwitchOn& is only returned byGETEVENT32 if the appropriate flag is set by a call toSETFLAGS.
GETEVENT32 ignores the machine beingswitched on if the flag is not set.Command events (exit or file switch)This kind of event should be handled specially byprogrammers. For this event, ev&(KEvAType%) isKEvCommand&&404a commandA command is passed to an application when theOperating System wants the application to switch filesor exit. If this event is received, GETCMD$ should becalled to find out what action should be taken.Key down and key up eventsFor these events, ev&(KEvAType%) is either of:KEvKeyDown&KEvKeyUp&&406&407key pressed downkey releasedIt is only possible to extract the scancode of a key upor key down event.