John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (779881), страница 36
Текст из файла (страница 36)
Values for style%:KgStyleNormal%KgStyleBold%KgStyleUnder%KgStyleInverse%KgStyleDoubleHeight%KgStyleMonoFont%KgStyleItalic%012481632normalboldunderlineinversedouble heightmonospaced fontitalicYou can combine these styles by adding their values, for example, to set bold, underlined, and doubleheight, use:gSTYLE KgStyleBold%+KgStyleUnder%+KgStyleDoubleHeight%This command does not affect non-graphics commands, like PRINT.gTMODESets the character display modeUsage: gTMODE mode%Sets the way characters are displayed by subsequentgPRINT and gPRINTCLIP commands on the currentdrawable.
Values for mode%:KtModeSet%KtModeClear%KtModeInvert%KtModeReplace%0123pixels will be setpixels will be clearedpixels will be invertedpixels will be replacedWhen you first use graphics text commands on a drawable, each dot in a letter causes a pixel to be set in thedrawable, i.e. the default gTMODE is KtModeSet%.When mode% is Clear or Invert, graphics text commands work in a similar way, but the pixels are clearedor inverted. When mode% is Replace, entire characterboxes are drawn on the screen – pixels are set in theletter and cleared in the background box.208OPL COMMAND LISTThis command does not affect other text displaycommands.Constants for the modes are supplied in Const.oph.gTWIDTHCalculates the screen width of a stringUsage: width%=gTWIDTH(text$)Returns the width of text$ in the current font and style.See also gPRINT, gPRINTB, gPRINTCLIP, gXPRINT.gUNLOADFONT Unloads a fontUsage: gULOADFONT fileId%Unloads a user-defined font that was previously loadedusing gLOADFONT.
Raises an error if the font has notbeen loaded.The built-in fonts are not held in memory and cannotbe unloaded.See also gLOADFONT.gUPDATEControls screen updatesUsage: any ofgUPDATE ONgUPDATE OFFgUPDATEThe screen is usually updated whenever you displayanything on it. gUPDATE OFF switches off this feature.The screen will then be updated as few times as possible(though note that some keywords will always cause anupdate).
You can still force an update by using thegUPDATE command on its own.This can result in a considerable speed improvementin some cases. You might, for example, use gUPDATEOFF, then a sequence of graphics commands, followedby gUPDATE. You should certainly use gUPDATE OFFif you are about to write exclusively to bitmaps.gUPDATE ON returns to normal screen updating.gUPDATE affects anything that displays on thescreen. If you are using a lot of PRINT commands,gUPDATE OFF may make a noticeable differencein speed.OPL COMMAND LIST209Note that with gUPDATE OFF, the location of errorsthat occur while the procedure is running may beincorrectly reported.
For this reason, gUPDATE OFF isbest used in the final stages of program development,and even then you may have to remove it to locatesome errors.gUSESets the current drawableUsage: gUSE id%Makes the drawable id% current. Graphics drawingcommands will now go to this drawable. gUSE doesnot bring a drawable to the foreground (see gORDER).gVISIBLESets the visibility of the current windowUsage: gVISIBLE ONorgVISIBLE OFFMakes the current window visible or invisible.Raises an error if the current drawable is a bitmap.gWIDTHCurrent drawable’s widthUsage: width%=gWIDTHReturns the width of the current drawable.gXX position in the current drawableUsage: x%=gXReturns the x current position (in from the left) in thecurrent drawable.gXBORDERDraws a borderUsage: gXBORDER type%,flags%,w%,h%orgXBORDER type%,flags%Draws a border in the current drawable of a specifiedtype, fitting inside a rectangle of the specified sizeor with the size of the current drawable if no sizeis specified.type% should always be the constant value KgXBorderS5Type%.
Other border types are implemented forbackwards compatibility, but should not be used withSymbian OS.210OPL COMMAND LISTKgXBorderS5Type%2the standard border typeValues for flags% are:NoneSingle blackShallow sunkenDeep sunkenDeep sunken with outlineShallow raisedDeep raisedDeep raised with outlineVertical barHorizontal bar$00$01$42$44$54$82$84$94$22$2aConstants for these flags and types are supplied inConst.oph. The following values of flags% apply to allborder types:0 for normal cornersAdding $100 leaves 1 pixel gap around the borderAdding $200 for more rounded cornersAdding $400 for losing a single pixelIf both $400 and $200 are mistakenly supplied, $200has prioritySee also gBORDER.gXPRINTPrints a string with precise highlighting or underliningUsage: gXPRINT string$,flags%Displays string$ at the current position, with precisehighlighting or underlining. The current font and styleare still used, even if the style itself is inverse or underlined.
If text mode 3 (Replace) is used, both set andcleared pixels in the text are drawn.Possible values for flags% are:KgXPrintNormal%KgXPrintInverse%KgXPrintInverseRound%KgXPrintThinInverse%KgXPrintThinInverseRound%KgXPrintUnderlined%KgXPrintThinUnderlined%0123456normal, as with gPRINTinverseinverse, omitting corner pixelsthin inversethin inverse, omitting corner pixelsunderlinedthin underlinedOPL COMMAND LIST211These constants are supplied in Const.oph.Where lines of text are separated by a single pixel,the thin options maintain the separation between lines.gXPRINT does not support the display of a list ofexpressions of various types.gYY position in the current drawableUsage: y%=gYReturns the y current position (down from the top) inthe current drawable.HEX$Converts an integer to a hex stringUsage: h$=HEX$(x&)Returns a string containing the hexadecimal (base 16)representation of integer or long integer x&.For example, HEX$(255) returns the string "FF".NotesTo enter integer hexadecimal constants (16-bit) put a $in front of them.
For example, $FF is 255 in decimal.(Don’t confuse this use of $ with string variable names.)To enter long integer hexadecimal constants (32bit) put a & in front of them. For example, &FFFFF is1048575 in decimal.Counting in hexadecimal is done like this: 0 1 2 34 5 6 7 8 9 A B C D E F 10 ... where A stands fordecimal 10, B for decimal 11, C for decimal 12 ...
up toF for decimal 15. After F comes 10, which is equivalentto decimal 16. To understand numbers greater thanhexadecimal 10, again compare hexadecimals withdecimals. In these examples, 102 means 10 × 10, 103means 10 × 10 × 10, and so on.253 in decimal is:(2 × 102) + (5 × 101) + (3 × 100) = (2 × 100) +(5 × 10) + (3 × 1) = 200 + 50 + 3By analogy, &253 in hexadecimal is:(&2 × 162) + (&5 × 161) + (&3 × 160) = (2 × 256) +(5 × 16) + (3 × 1) = 512 + 80 + 3 = 595 in decimalSimilarly, &A6B in hexadecimal is:(&A × 162) + (&6 × 161) + (&B× 160) = (10 × 256) +(6×16)+(11×1) = 2560+96+11 = 2667 in decimal212OPL COMMAND LISTYou may also find this table useful for convertingbetween hex and decimal:Hex&1&10&100&1 000decimal1162564096–= 16ˆ0= 16ˆ1= 16ˆ2= 16ˆ3For example, &20F9 is:(2 × &1000)+(0 × &100)+(15 × &10)+9, which in decimal is: (2 × 4096)+(0 × 256)+(15 × 16)+9=8441.All hexadecimal constants are integers ($) or longintegers (&). So arithmetic operations involving hexadecimal numbers behave in the usual way.
For example,&3/&2 returns 1, &3/2.0 returns 1.5, 3/$2 returns 1.HOURGets the current hourUsage: h%=HOURReturns the number of the current hour from the systemclock as an integer between 0 and 23.IABSAbsolute value of an integer expressionUsage: i&=IABS(x&)Returns the absolute value, i.e. without any sign, of theinteger or long integer expression x&.For example, IABS(-10) is 10.See also ABS, which returns the absolute value as afloating point value.ICONSets an application’s iconUsage: ICON mbm$Gives the name of the bitmap file mbm$, also knownas an Symbian OS Picture file, to use as the icon for anOPL application.If the ICON command is not used inside the APP...ENDA structure, then a default icon is used, but therest of the information in the APP... ENDA constructis still used to specify the other features of the OPLapplication.OPL COMMAND LIST213mbm$ is a multi-bitmap file, which can contain upto three bitmap/mask pairs – the sizes are 24, 32, and48 squares.
These different sizes are used for the different zoom levels in the system screen. The sizes are readfrom the MBM and the most suitable size is zoomedif the exact sizes required are not provided or if someare missing.In fact, you can use ICON more than once withinthe APP...ENDA construct.
The translator only insiststhat all icons are paired with a mask of the same sizein the final ICON list. This allows you to use pairsof MBMs containing just one bitmap, as produced bythe Sketch application. For example, you could specifythem individually:APP ...ICON "icon24.mbm"ICON "mask24.mbm"ICON "icon32.mbm"ICON "mask32.mbm"ICON "icon48.mbm"ICON "mask48.mbm"ENDAor with pairs in each MBM:APP ...ICON "iconMask24"ICON "iconMask32"ICON "iconMask48"ENDAor with all the bitmaps as just one MBM, as wouldnormally be the case if prepared on the PC usingbmconv and aiftool.This command can only be used between APPand ENDA.IF...ENDIFConditional loopUsage:IF condition1...ELSEIF condition2214OPL COMMAND LIST...ELSE...ENDIFDoes eitherthe statements following the IF conditionorthe statements following one of the ELSEIF conditions(there may be as many ELSEIF statements as you like,none at all if you want)orthe statements following ELSE (or, if there is no ELSE,nothing at all).