[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Window with toolbar and redraw messages



Hello

I have put an exemple at:
http://gem.lutece.net/download/toolbar.zip

There is a simple C source code of the use of toolbar with move of objects when the window is resize, you will find the program compiled with.

With XaAES and MyAES the object is moved and information in texte updated, it not use any userdef for this. In the case of XaAES there is a limitation of it, because XaAES dislike the program change the height of the toolbar tree, but this exemple should answer to your questions.

Olivier

#include <stdio.h>
#include <gem.h>

main()
{    OBJECT *toolbar=0L; int win,exit=0;
    char texte[30];
    unsigned short *pt,x2,y2,w2,h2;
    appl_init();
if(rsrc_load("toolbar.rsc")==0) form_alert(1,"[1][Can't load toolbar.rsc][Quit]");
    else
    {
        rsrc_gaddr(R_TREE,0,&toolbar);
        if(toolbar)
        {     int win;
            unsigned long add_rsrc = (unsigned long) toolbar;
            pt=(unsigned short*)&add_rsrc;
win=wind_create(CLOSER|NAME|MOVER|SIZER,0,0,10000,10000);
wind_calc(WC_WORK,CLOSER|MOVER|NAME|SIZER,100,100,300,200,&x2,&y2,&w2,&h2);
            toolbar[0].ob_height=h2;
            sprintf(texte," work area Width = %d ",w2);
            toolbar[1].ob_width=strlen(texte)*8;
            toolbar[1].ob_x=w2-toolbar[1].ob_width-2;
            if(toolbar[1].ob_x<1) toolbar[1].ob_x=1;
            toolbar[1].ob_spec.tedinfo->te_ptext=texte;
            toolbar[2].ob_x=1;
            toolbar[2].ob_y=h2-toolbar[2].ob_height-4;
            if(toolbar[2].ob_y<1) toolbar[2].ob_y=1;
            wind_set(win,WF_TOOLBAR,pt[0],pt[1],0,0);
            wind_open(win,100,100,300,200);

            while(!exit)
            { short mess[16];

                evnt_mesag(mess);
                switch(mess[0])
                {
                    case WM_MOVED:
                    case WM_SIZED:
wind_calc(WC_WORK,CLOSER|MOVER|NAME|SIZER,mess[4],mess[5],mess[6],mess[7],&x2,&y2,&w2,&h2);
                        toolbar[0].ob_height=h2;
                        sprintf(texte," work Width = %d ",w2);
                        toolbar[1].ob_width=strlen(texte)*8;
                        toolbar[1].ob_x=w2-toolbar[1].ob_width-2;
                        if(toolbar[1].ob_x<1) toolbar[1].ob_x=1;
                        toolbar[2].ob_y=h2-toolbar[2].ob_height-4;
                        if(toolbar[2].ob_y<1) toolbar[2].ob_y=1;
wind_set(mess[3],WF_CURRXYWH,mess[4],mess[5],mess[6],mess[7]);
                    /*    wind_set(mess[3],WF_TOOLBAR,0,0,0,0); */
wind_set(mess[3],WF_TOOLBAR,pt[0],pt[1],0,0);
                    break;
                    case WM_TOPPED:
                        wind_set(mess[3],WF_TOP,mess[3],0,0,0);
                    break;
                    case WM_CLOSED:
                    case AP_TERM:
                        exit=1;
                    break;
                    default: break;
                }
            }
            wind_close(win);
            wind_delete(win);
        } else form_alert(1,"[1][No object tree!][Ok]");
        rsrc_free();
    }
    appl_exit();
}

On Monday 02 December 2013 20:59:52 OL wrote:
Le 02/12/2013 17:18, Jean-François Lemaire a écrit :
Right now, in order to have a work area inside an AES object you need a
USERDEF. I think it's a limitation that could "easily" be overcome if that
window could receive redraw messages even if the redrawing is done by the
AES.

I hope it's clearer now ;-)
It's very clear, I'm only not agree with the analysis, I think it's only
a wrong problem.
Great! I'm looking forward for your example, then.

Chhers,
JFL