×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    108

    How to draw the text at the centre of a rectangle ?

    How to draw text at the centre of a rectangle ?
    Is there any way to know the length of my text ?
    I am thinking if my text's length is lX, I can calculate the start position's x coordinate as (Rectangle.length - lX) / 2 .

  2. #2
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to draw the text at the centre of a rectangle ?

    Quote Originally Posted by nadis View Post
    How to draw text at the centre of a rectangle ?
    For drawing some text center justified in a box you can do like this:
    Code:
    gc.DrawText(KExampleText, box, baseline, CGraphicsContext::ECenter, margin);
    Quote Originally Posted by nadis View Post
    Is there any way to know the length of my text ?
    You can use CFont::TextWidthInPixels() function.
    TInt TextWidthInPixels(const TDesC &aText) const;

    Description
    Gets the width in pixels of the specified descriptor when displayed in this font.

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: How to draw the text at the centre of a rectangle ?

    you can alaign it to the center, just check the gc functions that can be used for text drawing, also check CFont for functionality foe the text lenght checkings.

Similar Threads

  1. Draw text and controls over video content
    By yant in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-05-14, 07:23
  2. Draw rotated text
    By smabres in forum Mobile Java General
    Replies: 2
    Last Post: 2008-09-05, 13:51
  3. Draw text on sprites/bitmaps...
    By erst in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-16, 15:05
  4. Intercepting text draw events
    By spaceart in forum Symbian
    Replies: 0
    Last Post: 2003-02-11, 17:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×