The clipboard

IFmapper has a clipboard, that can hold an arbitrary number of items. You can use this to

The clipboard is realised as a normal section outside of the current map. Insertion and deletion work the normal way.

«*»= void ClearClip() while(clipboard->itemNum>0) DeleteItem(clipboard,&clipboard->items[0]); clipboard->items=NULL; @

[[CutToClip]] moves all selected items from the current section to the clipboard. The current content of clipboard is deleted. «*»= void CutToClip() int i; Item *ci;

ClearClip();

for(i=0;i<currentSection->itemNum;i++) if(isSelected(&currentSection->items[i])) ci=NewItem(clipboard); CopyItemTo(&currentSection->items[i],ci); DeleteItem(currentSection,&currentSection->items[i]); i–; @

[[CopyToClip]] works similar to [[CutToClip]], but the selected items are deleted from the current section. «*»= void CopyToClip() Item *ci; int i;

ClearClip();

for(i=0;i<currentSection->itemNum;i++) if(isSelected(&currentSection->items[i])) ci=NewItem(clipboard); CopyItemTo(&currentSection->items[i],ci); @

Paste the content of the clipboard to the current section. this is done in 4 steps:

  1. Deselect all items. This is done, so you can move the inserted items or undo this action. Note the items in the clipboard are alredy selected.
  2. Allocate new items and copy the content of the clipboard.
  3. Recalculate the bounding box of the selected items (= the pasted items).
  4. Move the inserted items to the visible rectangle.
«*»= void PasteFromClip() Item *ci; RectangleType r; int mx,my; int i;

DeselectAll(); for(i=0;i<clipboard->itemNum;i++) ci=NewItem(currentSection); CopyItemTo(&clipboard->items[i],ci);

SelectedRect(&r); mx=r.topLeft.x-currentSection->si.xoffset; my=r.topLeft.y-currentSection->si.yoffset;

for(i=0;i<currentSection->itemNum;i++) if(isSelected(&currentSection->items[i])) MoveItem(&currentSection->items[i],-mx,-my); @