Reactos
at master 66 lines 1.4 kB view raw
1// 2// CardLib - DropZone class 3// 4// Freeware 5// Copyright J Brown 2001 6// 7 8#include "cardlib.h" 9 10bool CardWindow::RegisterDropZone(int id, RECT *rect, pDropZoneProc proc) 11{ 12 if(nNumDropZones == MAXDROPZONES) 13 return false; 14 15 DropZone *dz = new DropZone(id, rect, proc); 16 17 dropzone[nNumDropZones++] = dz; 18 19 return false; 20} 21 22DropZone *CardWindow::GetDropZoneFromRect(RECT *rect) 23{ 24 for(int i = 0; i < nNumDropZones; i++) 25 { 26 RECT inter; 27 RECT zone; 28 29 //if any part of the drag rectangle falls within a drop zone, 30 //let that take priority over any other card stack. 31 dropzone[i]->GetZone(&zone); 32 33 if(IntersectRect(&inter, rect, &zone)) 34 { 35 //see if the callback wants us to drop a card on 36 //a particular stack 37 return dropzone[i]; 38 } 39 } 40 41 return 0; 42} 43 44bool CardWindow::DeleteDropZone(int id) 45{ 46 for(int i = 0; i < nNumDropZones; i++) 47 { 48 if(dropzone[i]->id == id) 49 { 50 DropZone *dz = dropzone[i]; 51 52 //shift any after this one backwards 53 for(int j = i; j < nNumDropZones - 1; j++) 54 { 55 dropzone[j] = dropzone[j + 1]; 56 } 57 58 delete dz; 59 nNumDropZones--; 60 return true; 61 } 62 } 63 64 return false; 65} 66