Symbian OS C + + for Windows C + + programmers Andy Weinstein, Degel Software Ltd Version 1.0, OCT 2002 1.
This article discusses a problem that may occur when a typical Windows C + + programmer first touches the Symbian operating system. Our experience with three successful versions of the Symbian operating system has made it clear that it is difficult to work in this not-so-rich and stable environment. One reason for Symbian's success is that many handset makers do not want to be tied to Microsoft's "shanghaied", another reason is that Symbian integrates lightweight, state-of-the-art systems while providing such a wide range of functionality. Some of the tips here may be helpful in developing a successful Symbian operating system application.
2. Documentation and resources.
For a typical Windows programmer, the first thing he notices about Symbian's operating system is that Symbian has too few documents to develop, compared to Microsoft's sophisticated equipment. Although this situation is improving, some API classes still do not have relevant documentation. For example, Ceikrichtexteditor this class has no separate entries in the document. Crichtext This class includes most of the relevant functionality and is paid for the document, but you may not know when to use this control for the first time (see our description of the object structure below).
Rather than spending a lot of manpower and resources to perfect the document, a simpler approach is based on the fact that Symbian provides a lot of source code (though not the entire operating system) and routines. Programmers don't have to speculate on the behavior of many APIs-they just look at the implementation. If that's not enough, Symbian provides the source code for some components, such as word. The combination of APIs and routines is sufficient to meet the needs of most programmers.
Starting with version 6.0, Symbian OS 95% 's source code is open to its Platinum partner project (Platinum Partner program,http://www.symbian.com/partners/part-platnm.html). This requires additional pay registration. One of the effects of this project is that the complete source code for some older versions of the development package is no longer available, and instead, Symbian or Nokia continues to refine the documentation while providing an expanding routine. For example, the documentation provided with Series 60 has a separate entry called "How Rich Text is manipulated" (although Ceikrichtexteditor still has no entries).
There are many other useful, well written "How to" articles in the document. In Series 60, the combination of documentation and routines is obvious--references to each Avkon UI class directly in the document are routines.
One thing windows programmers have to take for granted is the lack of useful external resources, although this is improving. "Professional Symbian Programming" (' Professional Symbian Programming ' (PSP)) contains a lot of useful information, but it's not appropriate as a quick reference, and it's written in the 5th edition of Symbian OS The new edition will be available early in 2003. The PSP is not obsolete, but things have changed, especially at the UI level. A book called Symbian Devices Wireless Java (' Wireless java for Symbian Devices ') may be updated to be of little use to C + + developers. Symbian OS Communication programming (' Symbian OS Communications programming ') and "Series 60 and Symbian OS Programming" (' Programming for Series Symbian OS ') has also been on the shelves. More details can be found in http://www.symbian.com/books/index.html.
Online documentation and Q-A resources do help fill gaps. Symbian has set up its own Symbian Developer Network, a network of forums, FAQs, examples, and other useful information. Its address is http://www.symbian.com/developer. Nokia also has a similar project called "Nokia Forum", which is located in Http://www.forum.nokia.com. Where to go is not necessarily, and if you post a question you don't necessarily have an answer-it depends on the kindness of your other development partners. Symbian and Nokia insiders do sometimes appear here, but if you want to get a definitive answer from the person who knows the answer, you'll need to pay to register. Symbian's paid registration address is in Http://www.symbian.com/partners/part-servs.html's "Partner Programs", while Nokia can start with Nokia Forum's "Developer Support, technical case solving "found. But first look at the free resources: there is a lot of useful up-to-date information and resources, including scheduled development package upgrades.
3. Object structure.
One aspect of Symbian's operating system that takes time to familiarize itself with is its very powerful object structure. For example, a ListBox (list box) is not an object--it's four: List box objects (ListBox object), model, view, and plotter (drawer). The partitioning of functionality between them is predictable and logical.
Edit control is much more complicated. At first glance, it looks like there are only two main objects: UI control and a text object that contains the processing text formatting. However, the formatted operation introduces a further object that formats the characters and formats the paragraphs. These, in order, use a separate mask object to indicate that the formatted API call that you want to position on any given call is displayed. So the operation text is shown in bold or not, and the code that affects the line spacing needs to be used for Ceikrichtexteditor, Crichtext, Tcharformat, Tcharformatmask, Cparaformat and Cparaformatmask these classes. Here's a piece of code like this: Tcharformat defaultformat;tcharformatmask formatmask ; Formatmask.setattrib (eattfontstrokeweight); crichtext* text = Idisplay->richtext (); Text->reset (); for (int i = 0; i < ++i)
{TPTRC Boldtext = getboldpiece (i); tptrc plaintext = getromanpiece (i);
TInt Insertpos = Text->documentlength (); Text->setinsertcharformatl (*icharformat, Formatmask, InsertPos) ; Text->insertl (Insertpos, Boldtext); Text->cancelinsertcharformat (); insertpos = Text->documentlength () ; Text->setinsertcharformatl (DefaultFormat, Formatmask, Insertpos); Text->insertl (InsertPos, plainText); text- >cancelinsertcharformat ();} Cparaformat paraformat;tparaformatmask Paraformatmask;idisplay->richtext ()-> Getparaformatl (¶format, paraformatmask,0, Idisplay->textlength ()) ; Paraformatmask.clearall (); Paraformatmask.setattrib (eattlinespacing); Paraformatmask.setattrib (EAttLineSpacingControl); par Aformat.ilinespacingcontrol = cparaformat::elinespacingexactlyintwips;cgraphicsdevice* ScreenDevice = iEikonEnv- >screendevice (); TInt Paradelta;
TInt lineheight = Screendevice->verticalpixelstotwips (iregularfont->heightinpixels () + ParaDelta) ; paraformat.ilinespacingintwips = Lineheight;idisplay->richtext ()->applyparaformatl (¶Format, Paraformatmask, 0, Idisplay->textlength ()); but that's not all--about text view objects also have worlds, especially Ctextview and Ctextlayout, along with their help objects. When we want to position the scroll point in edit control so that the last line of text can be positioned on one line above the bottom of the edit control, we have to learn about the existence of Ctextview and how to get it, and about CTEXTVIEW::SETVIEWL, Tviewyposqualifier::sethotspot and tviewyposqualifier::setmakelinefullyvisible. They look like this: TInt YPos = idisplay-> TextView ()->viewrect (). Ibr.iy;tviewyposqualifier Yposqualifier ; Yposqualifier.sethotspot (Tviewyposqualifier::efviewbottomofline); Yposqualifier.setmakelinefullyvisible (TViewYPosQualifie r::efviewforcelinefullyvisible); Idisplay->textview ()->setviewl (Idisplay->textlength (), YPos, Yposqualifier,ctextview::efviewdiscardallformat); Who would want it? One of our colleagues is not convinced that this is the only way to do this, but he has tried different ways to prove this by exploiting many (various) APIs that exist in various classes.
The complexity we're describing is really important to understand that the Symbian operating system provides a lot of functionality. Once you understand this area, you will be grateful for the structure of the Symbian operating system's objects, and soon you will find that you can predict where the functions you need are hidden. So repeat, you will find that our initial confusion has now become an aesthetic enjoyment.