×

Discussion Board

Results 1 to 4 of 4

Thread: canvas new line

  1. #1
    Regular Contributor
    Join Date
    May 2008
    Posts
    52

    canvas new line

    hi all
    how i can set new line in canvas ?
    for example
    i drow numbreing 1- ....... 2- ........ 3- .........
    but i want drow same this
    1- .............
    2- .............
    3- .............

    how i do this ?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: canvas new line

    Hi eya360,

    when using Canvas, you have to manually create newlines by calling drawString() method for each single line, and changing y coordinate by adding font height after each call. A quick example:

    Code:
    public void paint(Graphics g)
    {
    	g.setColor(0xffffff);
    	g.fillRect(0, 0, getWidth(), getHeight());
    		
    	Font font = Font.getDefaultFont();
    		
    	g.setColor(0x000000);
    	g.setFont(font);
    		
    	int fontHeight = font.getHeight();
    		
    	g.drawString("1 - .......", 0, 0, Graphics.TOP | Graphics.LEFT);
    	g.drawString("2 - .......", 0, fontHeight, Graphics.TOP | Graphics.LEFT);
    	g.drawString("3 - .......", 0, fontHeight * 2, Graphics.TOP | Graphics.LEFT);
    }
    Hope it helps,
    Pit

  3. #3
    Registered User
    Join Date
    Jan 2008
    Location
    Pune
    Posts
    24

    Re: canvas new line

    eya360

    Just set the key press event on ‘0’ key, like when user will triple tap on ‘0’ key move the cursor coordinate to the one line below in Canvas.
    Code like:
    y_pos = y_pos + (font_height+line_gap) , x = 0 or initial_position.

    Or

    Just check the string if it starts with “1-“ or “2-“….. drawString form new line by shifting the cursor position given above.

    anjan

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: canvas new line

    Hi,
    Thats the perfect way..
    Hope the only way for the underlined task..
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. i cant build helloworld project
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-12-22, 12:38
  2. [moved] HELP! Phone Debug (GCCE)
    By joseph.m in forum Symbian
    Replies: 18
    Last Post: 2008-07-14, 10:42
  3. carbidec++ helloworld project problem
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2007-03-11, 12:40
  4. carbide build problem help please
    By berkcekisbas in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-09-26, 19:41

Posting Permissions

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