Struttura usata in caso di drag & drop negli oggetti scroll
Prerequisito
E' necessario abilitare il drag&drop in fase di aperture dello scroll.
Aggiunge in WS_OPEN due righe di settaggio.
case WS_OPEN:
ws.doDrag=1;
ws.doNoFollow=1;
break;
Struttura usata per il controllo
EH_DRAGDROP
typedef struct {
EN_DRAGDROP enDragStatus; // 0= No, 1=Drag fissato (ma ancora da partire), 2-Drag & Drop partito, 3=Punto di Drop Fissato DD_
BOOL bDragNotify; // T/F se è stato notificato all'oggetto di Drag che è stato selezionato (notifico dopo un po)
POINT sDragPointAbsolute; // Punto assoluto di Drag
void * pDragPtr;
POINT sDragPoint;
INT iDragParam;
void * pDropPtr;
POINT sDropPoint;
INT iDropParam;
} EH_DRAGDROP;
Eventi
Eventi gestibili.
- WS_DRAG
L'evento viene inviato per informazioni se il gestore può iniziare un DRAG.
static void * _scrMachine(struct OBJ *objCalled,EN_MESSAGE cmd,LONG info,CHAR *str)
.
case WS_DRAG:
if (str) // Richiesta se posso prendere
{
BOOL *bLock=(BOOL *) str;
if (sys.sDragDrop.iDragParam<0) return NULL;
(info contiene l'indice dell'elemento)
Fare le considerazioni ed valorizzare in *bLock true/false se si pul prendere l'elelemento
Es. if (bNoDrag) *bLock=true; // Blocco il Drag
obj_dataRefresh(objCalled->nome,sys.sDragDrop.iDragParam,sys.sDragDrop.iDragParam);
return NULL;
}
break;
- WS_DROPFOCUS
E' in atto un Drag&Drop ed il mouse è sulla riga dell'elenco.
L'evento fornisce su quale oggetto si trova (utile se la funziona si occupa di più oggetti) ->pDropPtr e su quale riga dell'elenco (->iDropParam).
La funzione deve ritornare true se è una riga valida dove può essere rilasciato l'elemento con il DROP.
static void * _scrMachine(struct OBJ *objCalled,EN_MESSAGE cmd,LONG info,CHAR *str)
.
.
case WS_DROPFOCUS:
psDD=(EH_DRAGDROP *) str;
// dispxEx(0,20,"%d,%d,%d,%d ",sys.sDragDrop.pDragPtr,sys.sDragDrop.pDropPtr,sys.sDragDrop.iDragParam,sys.sDragDrop.iDropParam);
if ((sys.sDragDrop.pDragPtr==sys.sDragDrop.pDropPtr)&&
(sys.sDragDrop.iDragParam==sys.sDragDrop.iDropParam))
{
return NULL; // Drag & DROP sullo stesso oggetto = NO!
}
//
// Sono in un punto differente
//
if (psDD->iDropParam!=sys.sDragDrop.iDropParam)
{
if (sys.sDragDrop.iDropParam==-1) // Accoda
obj_dataRefresh(objCalled->nome,psMac->sWs.maxcam-1,psMac->sWs.maxcam-1);
else
obj_dataRefresh(objCalled->nome,sys.sDragDrop.iDropParam,sys.sDragDrop.iDropParam);
}
return (INT *) true;
- WS_DROPBLUR
Il cursore del mouse non è più sopra alla riga oggetto.
Utile per rinfrescare la riga, se l'aspetto cambia
case WS_DROPBLUR:
psDD=(EH_DRAGDROP *) str;
if (psDD->iDropParam==sys.sDragDrop.iDropParam) return NULL;
if (psDD->iDropParam==-1)
obj_dataRefresh(objCalled->nome,psMac->sWs.maxcam-1,psMac->sWs.maxcam-1);
else
obj_dataRefresh(objCalled->nome,psDD->iDropParam,psDD->iDropParam);
return NULL;
- WS_DROP
Richiesta di Drop.
sys.sDragDrop.iDragParam contiene la riga "scelta" con il drag.
sys.sDragDrop.iDropParam contiene la riga dove viene rilasciata con il drop.
sys.sDragDrop.iDropParam è negativa, se è nello spazio bianco dopo l'ultima riga, quindi va accodata.
Nel caso il tasto venga rilasciato sopra le righe e/o in una zona non gestita, non viene invocato l'evento.
case WS_DROP:
if (sys.sDragDrop.iDropParam==sys.sDragDrop.iDragParam) break;
if (sys.sDragDrop.iDropParam<0)
{
// Accoda
COMPOServer(WS_REALGET,psSc->arsDpc[(INT) sys.sDragDrop.iDragParam].Pt,&Compo); a=Compo.Open;
COMPOServer(COMPO_NODEDEL,psSc->arsDpc[(INT) sys.sDragDrop.iDragParam].Pt,"");
Compo.iLivello=1;
ws.selez=COMPOServer(WS_INSERT,COMPOINCODA,&Compo);
}
else
{
info=psSc->arsDpc[(INT) sys.sDragDrop.iDropParam].Pt;
COMPOServer(WS_REALGET,info,&Compo); if (Compo.iLivello<1) {efx2(); break;}
COMPOServer(WS_REALGET,psSc->arsDpc[(INT) sys.sDragDrop.iDragParam].Pt,&Compo); a=Compo.Open;
COMPOServer(COMPO_NODEDEL,psSc->arsDpc[(INT) sys.sDragDrop.iDragParam].Pt,"");
Compo.iLivello=1;
ws.selez=COMPOServer(WS_INSERT,info,&Compo);
}
return NULL;