/*
    DIYHWIF.C

Started by DavidW, 6/11/92

Routines to access some dialog item classes

*/

#include <dtedit.g>
#include <chlist.g>
#include <hwif.h>
#include <hwif.g>

GLREF_D PR_DLGBOX *DatDialogPtr;

GLDEF_C VOID hDTClose(VOID *dte)
    {
    p_send2(dte,O_DESTROY);
    }

GLDEF_C VOID hDTSet(VOID *dte,H_SE_DTEDIT *sdte)
    {
    p_send3(dte,O_WN_SET,sdte);
    }

GLDEF_C VOID hDTSense(VOID *dte,H_SE_DTEDIT *sdte)
    {
    p_send3(dte,O_WN_SENSE,sdte);
    }

GLDEF_C INT hDTSelfCheck(VOID *dte)
    {
    INT ret;

    ret=p_send2(dte,O_LG_SELF_CHECK);
    return(ret!=LG_CHECK_OK && ret!=LG_CHECK_OK_CHANGED);
    }

GLDEF_C VOID hDTEmphasise(VOID *dte,INT flag)
    {
    p_send3(dte,O_WN_EMPHASISE,flag);
    }

GLDEF_C INT hDTHandleKey(VOID *dte,INT keycode,INT modifier)
    {
    return(p_send4(dte,O_WN_KEY,keycode,modifier));
    }

GLDEF_C VOID *hDTOpen(H_DTEDIT *dte)
    {
    VOID *self;
    PR_WIN win;

    self=uCheckHandle(p_new(CAT_HWIF_HWIM,C_DTEDIT));
    if (self)
        {
        win.win.id=dte->win;
        p_send4(self,O_WN_INIT,dte,&win);
        p_send5(self,O_LG_SET_ID_POS,dte->win,&dte->pos,dte->width);
        hDTEmphasise(self,dte->emph);
        }
    return(self);
    }

GLDEF_C VOID hSetVarrayInChlist(INT index,INT nsel,VOID *varray)
    {
    SE_CHLIST set;

    set.nsel=nsel;
    set.data=varray;
    set.set_flags=SE_CHLIST_DATA|SE_CHLIST_NSEL|SE_CHLIST_RETAIN;
    p_send4(DatDialogPtr,O_WN_SET,index,&set);
    }

GLDEF_C VOID uSetDialogUline(INT pos,INT on)
    {
    DLGBOX_ITEM *pitm;

    pitm=(DatDialogPtr->dlgbox.count>7)?
                DatDialogPtr->dlgbox.u.pitm+pos:
                &DatDialogPtr->dlgbox.u.item[pos];
    if (on)
        pitm->flags|=DLGBOX_ITEM_UNDERLINED;
    else
        pitm->flags&=(~DLGBOX_ITEM_UNDERLINED);
    }

