John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (779881), страница 32
Текст из файла (страница 32)
The offset is a long integer to enable a wholeday to be specified when the offset is in seconds.If these arguments are not supplied, mode% is takenas 1 and offset& as 0.The system setting for the clock type (i.e. digital oranalog) can be changed by an OPL program using theprocedure LCSETCLOCKFORMAT: in the Date OPX180OPL COMMAND LIST(see Date.opx – Date and time manipulation). Thisfunction should be used to implement, for example,tapping a toolbar clock to change its type.format$, font%, and style% are used only for formatted digital clocks (mode% 11 on EPOC). The values forfont& and style% are as for gFONT and gSTYLE.
Thedefault font for gCLOCK is the system font. The defaultstyle is normal (0).For the formatted digital clock, a format string (upto 255 characters long) specifies how the clock is tobe displayed. The format string contains a number offormat specifications in the form of a % followed by aletter. Uppercase or lowercase may be used.The format string may contain the following symbolsto obtain the required effects:%%Insert a single % character in the string%*Abbreviate following item. (The asterisk should beinserted between the % and the number or letter,e.g. %*1.) In most cases this amounts to omitting anyleading zeros, for example, if it is the first of the month"%F %*M" will display as 1 rather than 01.%:nInsert a system time separator character.
n is an integer between zero and three inclusive, indicating whichtime separator character is to be used. For Europeantime settings, only n=1 and n=2 are used, giving thehours/minutes separator and minutes/seconds separator, respectively.%/nInsert a system date separator character. n is an integer between zero and three inclusive, indicating whichdate separator character is to be used.
For Europeantime settings, only n=1 and n=2 are used, giving theday/month separator and month/year separator, respectively.%1Insert the first component of a three-component date(i.e. a date including day, month, and year) where theorder of the components is determined by the systemsettings. The possibilities are: dd/mm/yyyy (European),mm/dd/yyyy (American), yyyy/mm/dd (Japanese).OPL COMMAND LIST181%2Insert the second component of a three-componentdate, where the order has been determined by thesystem settings. See %1.%3Insert the third component of a three-component date,where the order has been determined by the systemsettings.
See %1.%4Insert the first component of a two-component date(i.e. a date including day and month only), where theorder has been determined by system settings. The possibilities are: dd/mm (European), mm/dd (American),mm/dd (Japanese).%5Insert the second component of a two-component date,where the order has been determined by the systemsettings. See %4.%AInsert a.m. or p.m. according to the current languageand time of day. Text is printed even if 24-hour clockis in use. Text may be specified to be printed beforeor after the time, and a trailing or leading space asappropriate will be added. The abbreviated version(%*A) removes this space.Optionally, a minus or plus sign may be insertedbetween the % and the A.
This operates as follows:%–A causes a.m./p.m. text to be inserted only ifthe system setting of the a.m./p.m. symbol positionis set to display before the time. Similarly, %+A causesa.m./p.m. text to be inserted only if the system settingof the a.m./p.m. symbol is set to display after the time.No a.m./p.m. text will be inserted before the time ifa + is inserted in the string. For example, you coulduse "%–A%H%:1%T%+A" to insert the a.m./p.m. symbol either before or after the time, according to thesystem setting.
%+A and %–A cannot be abbreviated.%BAs %A, except that the a.m./p.m. text is only insertedif the system clock setting is 12 hour. (This should beused in conjunction with %J.)182OPL COMMAND LIST%DInsert the two-digit day number in month (in conjunction with %1, etc.).%EInsert the day name.
Abbreviation is language-specific(3 letters in English).%FUse this at the beginning of a format string to make thedate/time formatting independent of the system setting.This fixes the order of the following day/month/yearcomponent(s) in their given order, removing the needto use %1 to %5, allowing individual components ofthe date to be printed. (No abbreviation.)%HInsert the two-digit hour component of the time in24-hour clock format.%IInsert the two-digit hour component of the time in 12hour clock format. Any leading zero is automaticallysuppressed, regardless of whether an asterisk is insertedor not.%JInsert the two-digit hour component of time in either12- or 24-hour clock format depending on the corresponding system setting.
When the clock has been setto 12-hour format, the hour’s leading zero is automatically suppressed, regardless of whether an asterisk hasbeen inserted between the % and J.%MInsert the two-digit month number (in conjunction with%1, etc.).%NInsert the month name (in conjunction with %1, etc.).When using system settings (i.e. not using %F) thiscauses all months following %N in the string to be written in words. When using fixed format (i.e. when using%F), %N may be used alone to insert a month name.Abbreviation is language-specific (3 letters in English).%SInsert the two-digit second component of the time.OPL COMMAND LIST183%TInsert the two-digit minute component of the time.%WInsert the two-digit week number in year, counting thefirst (part) week as week 1.%XInsert the date suffix. When using system settings (i.e.not using %F), this causes a suffix to be put on any datefollowing %X in the string.
When using fixed format(i.e. using %F), %X following any date appends a suffixfor that particular date. Cannot be abbreviated.%YInsert the four-digit year number (in conjunction with%1, etc.). The abbreviation is the last two digits ofthe year.%ZInsert the three-digit day number in year.Some examples of the use of these format stringsare as follows. The example use is 1:30:05 p.m. onWednesday, 1st January 1997, with the system settingof European dates and with a.m./p.m. after the time:"%-A%I:%T:%S%+A" will print the time in 12-hourclock, including seconds, with the a.m./p.m.
eitherinserted before or after the time, depending on thesystem setting. So the example time would appear as1:30:05 p.m."%F%E %*D%X %N %Y" will print the day of theweek followed by the date with suffix, the month asa word, and the year. For example, Wednesday 1stJanuary 1997."%E %D%X%N%Y %1%2%3" will use the localesetting for ordering the elements of the date, but willuse a suffix on the day and the month in words. Forexample, Wednesday 01st January 1997."%*E %*D%X%*N%*Y %1 %2 ’%3" will be similarto 3, but will abbreviate the day of the week, the day,the month, and the year, so the example becomes "Wed1st Jan 97"."%M%Y%D%1%/0%2%/0%3" will appear as 01/01/1997. This demonstrates that the ordering of the %D,%M, and %Y is irrelevant when using locale-dependentformatting.
Instead the ordering of the date componentsis determined by the order of the %1, %2, and %3formatting commands.184OPL COMMAND LISTstyle% may take any of the values used to specifygSTYLE, other than 2 (underlined).A note should also be made that a ‘General failure’error will result if you attempt to use an invalid format.Invalid formats include using %: and %/ followed by0 or 3 when in European locale setting (when theseseparators are without meaning) and using %+ and%− followed by characters other than A or B.gCLOSECloses a drawableUsage: gCLOSE id%Closes the specified drawable that was previouslyopened by gCREATE, gCREATEBIT, or gLOADBIT.If the drawable closed was the current drawable, thedefault window (ID=1) becomes current.An error is raised if you try to close the defaultwindow.gCLSClears the current drawableUsage: gCLSClears the whole of the current drawable and sets thecurrent position to 0,0, its top left corner.gCOLORSets the pen colorUsage: gCOLOR red%,green%,blue%Sets the pen color of the current window.
The red%,green%,blue% values specify a color that will bemapped to white, black, or one of the greys on noncolor screens. Note that if the values of red%, green%,and blue% are equal, then a pure grey results, rangingfrom black (0) to white (255).See also gCOLORBACKGROUND, gCOLORINFO.gCOLORBACKGROUNDSets the background colorUsage: gCOLORBACKGROUNDgreen%,blue%red%,Sets the background, or ‘paper’ color of thecurrent graphics window.
Subsequent graphics commands in the window will use thisbackground color. The red%,green%,blue%values specify a color that will be mapped toOPL COMMAND LIST185white, black, or one of the greys on noncolor screens. Note that if the values ofred%, green%, and blue% are equal, thena pure grey results, ranging from black (0) towhite (255).For example:gUSE 1gCOLOR $ff,0,0gCOLORBACKGROUND 0,0,$ffgAT 20,20gPRINTB "Red text on a bluebackground",250See also gCOLORINFO, gCOLOR.gCOLORINFOGets the Symbian OS phone’s color informationUsage: gCOLORINFO var cinfo&()Interrogates the system to find the maximum number of colors available on the Symbian OS phone.cinfo&() must be at least seven elements long, andon gCOLORINFO’s return will contain informationindexed by the following values:gColorInfoADisplayMode%gColorInfoANumColors%gColorInfoANumGreys%123default window modenumber of colors supportednumber of greys supportedThe remaining four elements are reserved for future use.The default window mode will be one of the following values:KDisplayModeNone%KDisplayModeGray2%KDisplayModeGray4%KDisplayModeGray16%KDisplayModeGray256%KDisplayModeColor16%KDisplayModeColor256%KDisplayModeColor64K%KDisplayModeColor16M%KDisplayModeRGB%KDisplayModeColor4K%0123456789102 greys4 greys16 greys256 greys16 colors256 colors65,536 colors (16-bit color)16,777,216 colors (24-bit color)4096 colors (12-bit color)For example, to find out about the color depth of thedisplay on your device:186OPL COMMAND LISTinclude "Const.oph"proc ColTest:local c&(3)gColorInfo c&()print c&(gColorInfoADisplayMode%),print c&(gColorInfoANumColors%),print c&(gColorInfoANumGreys%)getendpSee also gCOLORBACKGROUND, gCOLOR.gCOPYCopies a rectangular areaUsage: gCOPY id%,x%,y%,w%,h%,mode%Copies a rectangle of the specified size (width w%,height h%) from the point x%,y% in drawable id%, tothe current position in the current drawable.It is inadvisable to use gCOPY to copy from windowsas it is very slow.