Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor nadis's Avatar
    Join Date
    Feb 2009
    Posts
    108
    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 Moderator A.A.M.'s Avatar
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,308
    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 Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,672
    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. draw text and bitmap
    By yingchuan in forum Symbian
    Replies: 1
    Last Post: 2004-10-12, 06:07
  5. Intercepting text draw events
    By spaceart in forum Symbian C++
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved