/*
O_HELLO
*/

#include <hwimman.g>
#include <hello2.g>
#include <hello2.rsg>

GLREF_D WSERV_SPEC *wserv_channel;
GLREF_D PR_HWIMMAN *w_am;
GLREF_D PR_WSERV *w_ws;

GLDEF_C VOID main(VOID)
    {
    IN_HWIMMAN app;
    IN_WSERV ws;

    p_linklib(0);
    app.flags=/*FLG_APPMAN_FULLSCREEN|*/FLG_APPMAN_RSCFILE|FLG_APPMAN_CLEAN|
        FLG_APPMAN_SRSCFILE/*|FLG_APPMAN_IPCS|FLG_APPMAN_LINKING*/;
    app.wserv_cat=p_getlibh(CAT_HELLO2_HELLO2);
    ws.com_cat=p_getlibh(CAT_HELLO2_HELLO2);
    app.wserv_class=C_HELLOWS;
    ws.com_class=C_HELLOCM;
    p_send4(p_new(CAT_HELLO2_HWIM,C_HWIMMAN),O_AM_INIT,&app,&ws);
    }

#pragma METHOD_CALL

METHOD VOID hellows_ws_dyn_init(PR_HELLOWS *self)
    {
    self->wserv.cli=f_new(CAT_HELLO2_HELLO2,C_HELLOBW);
    p_send2(self->wserv.cli,O_WN_INIT);
    }

METHOD VOID hellobw_wn_init(PR_HELLOBW *self)
    {
    W_WINDATA wd;

    wd.extent.tl.x=0;
    wd.extent.tl.y=0;
    wd.extent.width=wserv_channel->conn.info.pixels.x;
    wd.extent.height=wserv_channel->conn.info.pixels.y;
    p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd);
    p_send3(self,O_WN_VISIBLE,WV_INITVIS);
    /* hInitVis(self); */
    p_send3(self,O_WN_EMPHASISE,TRUE);
    }

METHOD VOID hellobw_wn_draw(PR_HELLOBW *self)
    {
    UINT resid;
    TEXT buf[40];

    resid=self->hellobw.isbye ? BYE_MESSAGE:HELLO_MESSAGE;
    p_send(w_am,O_AM_LOAD_RES_BUF,resid,&buf[0]);
    p_supersend2(self,O_WN_DRAW);
    gPrintText(50,50,&buf[0],p_slen(&buf[0]));
    }

METHOD VOID hellobw_wn_set(PR_HELLOBW *self,UINT isbye)
    {
    self->hellobw.isbye=isbye;
    p_send2(self,O_WN_DODRAW);
    }

METHOD VOID hellocm_com_hello(PR_HELLOCM *self)
    {
    p_send3(w_ws->wserv.cli,O_WN_SET,FALSE);
    }

METHOD VOID hellocm_com_bye(PR_HELLOCM *self)
    {
    p_send3(w_ws->wserv.cli,O_WN_SET,TRUE);
    }
