To attach a toolbar to a window, simply call wind_set with the following parameters:
OBEJECT *tree=rsrc_gaddr(TOOLBAR); wind_set(window_handle,WF_TOOLBAR,((long)tree & 0xffff0000) >> 16,(long)tree & 0xffff);This gives the address of the object tree to the AES, and tells it to attach a tool bar. If the address given is NULL, it will remove the toolbar. The AES will automatically resize the root object so that it is the correct width of the window.
When an object which is flagged as 'touchexit' is clicked on, the AES sends a WM_TOOLBAR message to your program, with the window handle in msgbuf[3], the object index in msgbuf[4] and the number of clicks in msgbuf[5]. Note that the object is not automatically set to 'selected'.
To redraw parts of the toolbar, you will need to write a function such as the one below, which uses the new wind_get() flags. The function below will redraw the part of the toolbar indicated by pclipbox.
void redraw_bar(int windowhandle, OBJECT *tree, int obindex, GRECT *pclipbox)
{
GRECT windbox;
// walk the rectangle list with WF_TOOLBAR as the first rectangle, and WF_NTOOLBAR as the next
wind_get(windowhandle,WF_FTOOLBAR,&windbox.g_x,&windbox.g_y,&windbox.g_w,&windbox.g_h);
while (windbox.g_w && windbox.g_h) // while the rectangle covers something
{
if (rc_intersect(pclipbox,&windbox))
objc_draw(tree,obindex,MAX_DEPTH,windbox.g_x,windbox.g_y,windbox.g_w,windbox.g_h);
wind_get(windowhandle,WF_NTOOLBAR,&windbox.g_x,&windbox.g_y,&windbox.g_w,&windbox.g_h);
}
}
The calculations of wind_calc() do not take the toolbar into account, so you will
have to modify these by adding the height of the resource tree. Apart from this,
all other AES functions will operate correctly with respect to the changed work-area
size of the window.
Anthony Jacques : jacquesa@zetnet.co.uk