Custom widget based on a PtWindow

Hi everybody,

I would like to create a custom widget based on a PtWindow becauseI want
to use my own draw function.
I’ve followed the documentation and created the shared library
containing my custom window. It works
in applications created without phab but how can I use my custom window
in Phab ?

Regards

Take a look at the documentation found at
http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/bind.ht
ml

Regards,
Dave B.



“Pierre AUBERT” <p.aubert@staubli.com> wrote in message
news:bjpaaj$pef$1@inn.qnx.com

Hi everybody,

I would like to create a custom widget based on a PtWindow becauseI want
to use my own draw function.
I’ve followed the documentation and created the shared library
containing my custom window. It works
in applications created without phab but how can I use my custom window
in Phab ?

Regards

Dave Boltz wrote:

Take a look at the documentation found at
http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/bind.ht
ml

Regards,
Dave B.


I’ve read this documentation. It works for widgets by not for windows

… (my custom widget is based on a PtWindow)
I’ve modified my palette.def, created my mypalette.pal but nothing
appened in phab …
regards

“Pierre AUBERT” <> p.aubert@staubli.com> > wrote in message
news:bjpaaj$pef$> 1@inn.qnx.com> …


Hi everybody,

I would like to create a custom widget based on a PtWindow becauseI want
to use my own draw function.
I’ve followed the documentation and created the shared library
containing my custom window. It works
in applications created without phab but how can I use my custom window
in Phab ?

Regards



\

Hello Pierre,

You don’t really want this button added in your widgets panel. The reason
being that the widgets found inside the widget panel are meant to be put in
modules. If your custom window were there, This would imply that you could
put a window inside another window. The proper way of telling PhAB that a
widget is disjoint would be to use the “m=” line. Normally it should be
“m=dwp” which would mean that the widget is good for dialog, window and
picture modules.

Regards,
Dave B.



“Pierre AUBERT” <p.aubert@staubli.com> wrote in message
news:bjq18k$c09$1@inn.qnx.com

Dave Boltz wrote:

Take a look at the documentation found at

http://www.qnx.com/developer/docs/momentics621_docs/photon/wid_build/bind.h
t
ml

Regards,
Dave B.


I’ve read this documentation. It works for widgets by not for windows
… (my custom widget is based on a PtWindow)
I’ve modified my palette.def, created my mypalette.pal but nothing
appened in phab …
regards



“Pierre AUBERT” <> p.aubert@staubli.com> > wrote in message
news:bjpaaj$pef$> 1@inn.qnx.com> …


Hi everybody,

I would like to create a custom widget based on a PtWindow becauseI want
to use my own draw function.
I’ve followed the documentation and created the shared library
containing my custom window. It works
in applications created without phab but how can I use my custom window
in Phab ?

Regards




\

Hello Dave,

Thanks for your answer.


Dave Boltz wrote:

Hello Pierre,

You don’t really want this button added in your widgets panel. The reason
being that the widgets found inside the widget panel are meant to be put in
modules. If your custom window were there, This would imply that you could
put a window inside another window.

Sure, I just want to use my custom window as a new module.



The proper way of telling PhAB that a
widget is disjoint would be to use the “m=” line. Normally it should be
“m=dwp” which would mean that the widget is good for dialog, window and
picture modules.

This (undocumented ?) option works fine. Now, I can change the class of

a PtWindow to MyWindow.

By I have 2 remaining problems :

  1. I want to create custom window because I want to use my own draw
    function.
    The following draw funcion is an example that draw a red diagonal on the
    window :

static void mywindow_draw( PtWidget_t *widget, PhTile_t *damage )
{
MyWindowWidget_t *sb = ( MyWindowWidget_t * ) widget;
PtBasicWidget_t *basic = ( PtBasicWidget_t * ) widget;
PhRect_t rect;

// We want to use basic’s draw function to get borders
// and default focus rendering…
PtSuperClassDraw( PtWindow, widget, damage );

// we don’t want to draw outside our canvas! So we clip.
PtCalcCanvas( widget, &rect );
if (widget → resize_flags & Pt_UCLIP) {
PtClipAdd( widget, &rect );
}

printf (“Drawing line (%d, %d) → (%d, %d)\n”,
rect.ul.x, rect.ul.y, rect.lr.x, rect.lr.y);

PgSetStrokeColor(Pg_RED);
PgDrawILine(rect.ul.x, rect.ul.y, rect.lr.x, rect.lr.y);

/* remove the clipping */
if (widget → resize_flags & Pt_UCLIP) {
PtClipRemove();
}
}

When I resize my window, the red line is drawn only on the modified part
of the window. It sounds like a clipping
area was added before my function was called.

  1. I’ve modified the /usr/photon/appbuilder/palette.def file as following :
    l=mywindow,<photon/MyWindow.h>:ph,phrender,m
    p=mypalette,My Window

And I’ve copied MyWindow.h in /usr/include/photon and libmywindow.so in
/usr/lib.
In Phab, the MyWindow windows are not drawn by my function because I
don’t see my
red diagonal.



Best regards

Pierre AUBERT <p.aubert@staubli.com> wrote:

By I have 2 remaining problems :

  1. I want to create custom window because I want to use my own draw
    function.
    The following draw funcion is an example that draw a red diagonal on
    the
    window :

    When I resize my window, the red line is drawn only on the modified part
    of the window. It sounds like a clipping
    area was added before my function was called.

I think PtWindow “knows” that its own drawing function only draws a flat
fill colour, and therefore there’s no need to redraw everything when
it’s resized. You’ll need to add code to your widget to fully damage it
on a resize.

  1. I’ve modified the /usr/photon/appbuilder/palette.def file as following :
    l=mywindow,<photon/MyWindow.h>:ph,phrender,m
    p=mypalette,My Window

And I’ve copied MyWindow.h in /usr/include/photon and libmywindow.so in
/usr/lib.
In Phab, the MyWindow windows are not drawn by my function because I
don’t see my
red diagonal.

PhAB never uses a real disjoint widget to display a module – the
PtWindows you see in PhAB are not really PtWindows, either. That’s
because PhAB wants the displayed modules to stay inside PhAB’s window,
and there’s no way to do that with a real PtWindow or PtRegion.

Wojtek Lerch wrote:

Pierre AUBERT <> p.aubert@staubli.com> > wrote:


By I have 2 remaining problems :




\

  1. I want to create custom window because I want to use my own draw
    function.
    The following draw funcion is an example that draw a red diagonal on


    the


    window :





    When I resize my window, the red line is drawn only on the modified part
    of the window. It sounds like a clipping
    area was added before my function was called.



    I think PtWindow “knows” that its own drawing function only draws a flat
    fill colour, and therefore there’s no need to redraw everything when
    it’s resized. You’ll need to add code to your widget to fully damage it
    on a resize.


    Ok, understood. I will try this …


  2. I’ve modified the /usr/photon/appbuilder/palette.def file as following :
    l=mywindow,<photon/MyWindow.h>:ph,phrender,m
    p=mypalette,My Window





    And I’ve copied MyWindow.h in /usr/include/photon and libmywindow.so in
    /usr/lib.
    In Phab, the MyWindow windows are not drawn by my function because I
    don’t see my
    red diagonal.



    PhAB never uses a real disjoint widget to display a module – the
    PtWindows you see in PhAB are not really PtWindows, either. That’s
    because PhAB wants the displayed modules to stay inside PhAB’s window,
    and there’s no way to do that with a real PtWindow or PtRegion.



    Ok, thanks.

Regards