×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Romania, Cluj-Napoca
    Posts
    82

    Force CCoeControl to draw inside a specified rect

    Hello!

    I am facing a strange problem.
    Maybe it's a wrong approach, but let's give it a try.
    So, I have a container(C), in which I have a bigger control(A).
    So A's rect is not inside C's rect.
    A's Draw(TRect r) -(from CCoecontrol) gets called with the rect of A intersected with rect of C.
    This seems to be pretty nice, but the draw of A does not use the parameter, it draws itself inside his own rect (Rect()).

    Let's say that A is CEikLabel.
    How can I force A not to draw outside parents rect?

    I've got a partial solution for this:
    Make C window owning. But if I make it window owning, the connection to it's parent is lost.
    So if I want to make C transparent, this method does not seems to resolve the problem.

    Or other approach...How can I force a control to draw on a backbuffer (syncronius)?

    Any idead?

    BR,
    Gr3go

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Force CCoeControl to draw inside a specified rect

    Theoretically a SetRect should be enough for well-behaving controls.
    Drawing controls to bitmaps is a bit deeper magic, CCoeEnv::SwapSystemGc may help (though there is a CCoeControl::SetGc too), if combined with CWindowToBitmapMappingGc (check it in epoc32\include, most SDK Helps do not mention it).

  3. #3
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Romania, Cluj-Napoca
    Posts
    82

    Re: Force CCoeControl to draw inside a specified rect

    Quote Originally Posted by wizard_hu_ View Post
    Theoretically a SetRect should be enough for well-behaving controls.
    Ok, it should be, but:
    I was going to make a containre (C), that moves A inside of itself, some kind of marquee effect (I modify the position of A at each animation step, but not the rect)
    And A could be any type of ccoecontrol, so calling SetRect on each animation step, shouldn't be an elegant solution. (Maybe there are some controls, that on SizeChanged do some image resize, etc...)
    The A:: Draw(TRect aRect), is called with the correct parameter, aRect, that is constrained by the parents rect.
    So practically, the draw is called with right params, but some controls do not take that parameter into consideration. They are drawing on their whole rect, that, in my case, is much more bigger. (example: http://developer.symbian.org/xref/os...KLABEL.CPP#404)
    Note:
    EXPORT_C void CEikLabel :: Draw( const TRect& /*aRect*/ ) const
    Quote Originally Posted by wizard_hu_ View Post
    Drawing controls to bitmaps is a bit deeper magic, CCoeEnv::SwapSystemGc may help (though there is a CCoeControl::SetGc too), if combined with CWindowToBitmapMappingGc (check it in epoc32\include, most SDK Helps do not mention it).
    This maybe could help me...

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Force CCoeControl to draw inside a specified rect

    Quote Originally Posted by Gr3go View Post
    And A could be any type of ccoecontrol, so calling SetRect on each animation step, shouldn't be an elegant solution. (Maybe there are some controls, that on SizeChanged do some image resize, etc...)
    SetRect has two components: SetPosition and SetSize...
    The A:: Draw(TRect aRect), is called with the correct parameter, aRect, that is constrained by the parents rect.
    So practically, the draw is called with right params, but some controls do not take that parameter into consideration. They are drawing on their whole rect, that, in my case, is much more bigger.
    It is nice that you dig into the source code, but you are mis-interpreting aRect: it specifies the invalidated region, which has to be redrawn - however the controls are free to redraw their entire rectangle if they want, just check examples or generated code, most of the time that argument does not even have a name "const TRect& /*aRect*/". CEikLabel is just one such control out of many.

  5. #5
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Romania, Cluj-Napoca
    Posts
    82

    Re: Force CCoeControl to draw inside a specified rect

    Quote Originally Posted by wizard_hu_ View Post
    Drawing controls to bitmaps is a bit deeper magic, CCoeEnv::SwapSystemGc may help (though there is a CCoeControl::SetGc too), if combined with CWindowToBitmapMappingGc (check it in epoc32\include, most SDK Helps do not mention it).
    Question: can I modify the GC of a not window owning container?
    Let's say, I have a Window owning container, with default GC, and that window has a non window owning container with another GC?

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Force CCoeControl to draw inside a specified rect

    Actually I have not tried neither of these stuff. Technically SetGc is obviously available in all CCoeControls, you could check when it gets invoked (e.g. if parent controls unconditionally set the gc prior to each redraw attempt, that is a problem - however if it is set once, say in SetContainerWindowL, or something, you could freely set your own one later).

  7. #7
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Romania, Cluj-Napoca
    Posts
    82

    Re: Force CCoeControl to draw inside a specified rect

    Hei!

    Found a solution for my problem.
    The constrait is, that every control that is inside de C (the container), must gc.SetClippingRect(aRect), where aRect is the rect from draw.
    In this case, if I want to put in C a CEikLabel, I do the following:

    class CCustomLabel: public CEikLabel
    {
    void Draw(TRect aRect)
    {
    CWindowGc& gc = SystemGc();
    gc.setClippingRect(aRect);
    CEikLabel:: Draw(aRect);
    }
    }

    So, CCustomLabel will never draw outside it's parent rect.

    This solves my problem.

    Thanks for help, wizard_hu...

    Br,
    Gr3go

Similar Threads

  1. Can i draw control without taking Rect
    By purnima.attarsingh in forum Symbian
    Replies: 7
    Last Post: 2009-11-06, 01:42
  2. quesion about Draw() in ccoecontrol
    By ptclin_2007 in forum Symbian User Interface
    Replies: 6
    Last Post: 2009-04-17, 13:10
  3. Canvas: How to draw a Rect around an image?
    By ricardopcunha in forum Mobile Java General
    Replies: 2
    Last Post: 2009-02-10, 17:34
  4. How to Draw outside rect?
    By oslario in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-08-04, 07:45
  5. Replies: 0
    Last Post: 2004-08-06, 04: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
  •  
×