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 :
- 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.
- 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