Symbian Game Programming Graphics display

Source: Internet
Author: User
Tags drawtext

In Symbian OS, all drawings are done in a window, which is the basic unit of interaction with the system. Before we make a drawing, we first declare a window:

Createwindowl ();

It then sets the size of the window by SetRect ().

SetRect (Arect);

Then we can work on the drawing.

4.1.2 Graphics Context

In the Symbian system, all the drawing work is done through the graphics context. These include drawing points, drawing rectangles, and drawing text. All graphics context is derived from the Cgraphicscontent class.

The features included in the Cgraphicscontent class are:

Pen: The drawing mode that represents all the lines to be drawn in the current graphics context, including color, width, style, etc., can be set by means of Setpencolor (), Setpensize (), Setpenstyle ().

Brushes (Brush): A drawing pattern that represents the current graphics context for filling, including fill color, style, background color, etc., available through Setbrushcolor (), Setbrushorigin (), Setbrushstyle (), Usebrushpattern (), Discardbrushpattern () and other methods are set.

Font: Represents the font that graphics Contex is currently using to draw text, using the Usefont (), Discardfont () method to set or remove the font.

Position (Position): Represents the current position of the graphics Contex. The current position can be changed by means of Moveby (), MoveTo ().

Origin (Origin): Defines the offset from the origin of the device, the default value is (0,0) and can be changed by Setorigin ().

Clip (clipping): Defines the area that needs to be trimmed, sets or cancels the trim area by Setclippingrect (), Cancelclippingrect () method.

4.1.3 Graphics Device

In the Symbian system, we implemented the graphics Device via Cgraphicsdevice, which specifies the interface of the specific device class we want to operate.

4.2 Use of basic drawing functions

After setting the cgraphicscontent, we can draw the graph in the window by calling the related method.

4.2.1 Text:

void DrawText (const tdesc& atext,const tpoint& aposition)

void DrawText (const tdesc& atext,const trect& abox,tint abaselineoffset, Ttextalign aalignment=eleft,tint aleftmargin=0)

The first to draw the text directly in the window, where Atext gives the text to be drawn, aposition the starting position to draw the text.

The second, while drawing the text, also draws a rectangular bounding box with the given Abox. The aalignment parameter specifies the alignment of the text, the default is left-aligned, aleftmargin specifies the interval distance, and the default value is 0.

Because the Symbian system has limited memory, the unused font system will not be transferred into memory, so we should first use Usefont () to set the font of the system before we draw the text:

void Usefont (const cfont* Afont)

This allows the system to transfer fonts into memory.

After we don't use this font, to save memory, use Discardfont () to release the fonts in memory.

void Discardfont ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.