Commit 0857587f authored by ROOL's avatar ROOL 🤖

Update to use drag & drop also

Detail:
  Implementation of the drag-and-drop aspects of 1309,419/FS revision G.
Admin:
  Submission for Clipboard Support bounty.

Version 1.35. Tagged as 'Draw-1_35'
parent a90d48bb
......@@ -91,26 +91,26 @@ OBJS =\
o.Draw o.DrawAction o.DrawCheck o.DrawDispl o.DrawDXF\
o.DrawEdit o.DrawEnter o.DrawFileIO o.DrawGrid o.DrawHelp\
o.DrawMenu o.DrawObject o.DrawPrint o.DrawScan o.DrawSelect\
o.DrawTextC o.DrawTrans o.DrawUndo o.bezierarc o.DrawClipb
o.DrawTextC o.DrawTrans o.DrawUndo o.bezierarc o.DrawClipb o.DrawDrag
OBJSZ =\
oz.Draw oz.DrawAction oz.DrawCheck oz.DrawDispl oz.DrawDXF\
oz.DrawEdit oz.DrawEnter oz.DrawFileIO oz.DrawGrid oz.DrawHelp\
oz.DrawMenu oz.DrawObject oz.DrawPrint oz.DrawScan oz.DrawSelect\
oz.DrawTextC oz.DrawTrans oz.DrawUndo oz.bezierarc oz.DrawClipb
oz.DrawTextC oz.DrawTrans oz.DrawUndo oz.bezierarc oz.DrawClipb oz.DrawDrag
OBJSD =\
od.Draw od.DrawAction od.DrawCheck od.DrawDispl\
od.DrawDXF od.DrawEdit od.DrawEnter od.DrawFileIO od.DrawGrid\
od.DrawHelp od.DrawMenu od.DrawObject od.DrawPrint od.DrawScan\
od.DrawSelect od.DrawTextC od.DrawTrans od.DrawUndo\
od.bezierarc od.ftrace od.guard od.flex od.DrawClipb
od.bezierarc od.ftrace od.guard od.flex od.DrawClipb od.DrawDrag
ASMS =\
s.Draw s.DrawAction s.DrawCheck s.DrawDispl s.DrawDXF\
s.DrawEdit s.DrawEnter s.DrawFileIO s.DrawGrid s.DrawHelp\
s.DrawMenu s.DrawObject s.DrawPrint s.DrawScan s.DrawSelect\
s.DrawTextC s.DrawTrans s.DrawUndo s.bezierarc s.DrawClipb
s.DrawTextC s.DrawTrans s.DrawUndo s.bezierarc s.DrawClipb s.DrawDrag
#
# Rule patterns
......
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.32"
Module_Version SETA 132
Module_MajorVersion SETS "1.35"
Module_Version SETA 135
Module_MinorVersion SETS ""
Module_Date SETS "24 Feb 2019"
Module_ApplicationDate SETS "24-Feb-19"
Module_Date SETS "16 Mar 2019"
Module_ApplicationDate SETS "16-Mar-19"
Module_ComponentName SETS "Draw"
Module_ComponentPath SETS "apache/RiscOS/Sources/Apps/Draw"
Module_FullVersion SETS "1.32"
Module_HelpVersion SETS "1.32 (24 Feb 2019)"
Module_FullVersion SETS "1.35"
Module_HelpVersion SETS "1.35 (16 Mar 2019)"
END
/* (1.32)
/* (1.35)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.32
#define Module_MajorVersion_CMHG 1.35
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 24 Feb 2019
#define Module_Date_CMHG 16 Mar 2019
#define Module_MajorVersion "1.32"
#define Module_Version 132
#define Module_MajorVersion "1.35"
#define Module_Version 135
#define Module_MinorVersion ""
#define Module_Date "24 Feb 2019"
#define Module_Date "16 Mar 2019"
#define Module_ApplicationDate "24-Feb-19"
#define Module_ApplicationDate "16-Mar-19"
#define Module_ComponentName "Draw"
#define Module_ComponentPath "apache/RiscOS/Sources/Apps/Draw"
#define Module_FullVersion "1.32"
#define Module_HelpVersion "1.32 (24 Feb 2019)"
#define Module_LibraryVersionInfo "1:32"
#define Module_FullVersion "1.35"
#define Module_HelpVersion "1.35 (16 Mar 2019)"
#define Module_LibraryVersionInfo "1:35"
......@@ -102,6 +102,7 @@
#include "DrawTrans.h"
#include "DrawUndo.h"
#include "DrawClipb.h"
#include "DrawDrag.h"
#define EMPTY(s) ((s) [0] == '\0')
#define CLEAR(s) ((s) [0] = '\0')
......@@ -918,7 +919,7 @@ static BOOL draw_null_event_handler (wimp_mousestr mouse)
if
(
#if 1 /*JRC*/
( diag->misc->mainstate == state_sel ||
( (diag->misc->mainstate == state_sel && diag->misc->substate != state_sel_trans) ||
diag->misc->mainstate == state_edit ||
diag->misc->substate == state_zoom ||
diag->misc->substate == state_printerI ||
......@@ -1178,28 +1179,28 @@ static void paper_redraw (viewrec *vuue)
#if TRACE
wimpt_noerr (draw_displ_do_objects (diag, diag->misc->solidstart,
diag->misc->pathedit_cb.obj_off, &org, &clip));
diag->misc->pathedit_cb.obj_off, diag->paper, &org, &clip));
wimpt_noerr (draw_displ_do_objects (diag,
diag->misc->pathedit_cb.obj_off + stop.objhdrp->size,
diag->misc->solidlimit, &org, &clip));
diag->misc->solidlimit, diag->paper, &org, &clip));
#else
(void) draw_displ_do_objects (diag, diag->misc->solidstart,
diag->misc->pathedit_cb.obj_off, &org, &clip);
diag->misc->pathedit_cb.obj_off, diag->paper, &org, &clip);
(void) draw_displ_do_objects (diag,
diag->misc->pathedit_cb.obj_off + stop.objhdrp->size,
diag->misc->solidlimit, &org, &clip);
diag->misc->solidlimit, diag->paper, &org, &clip);
#endif
}
else
/*repaint all objects in the database*/
#if TRACE
wimpt_noerr (draw_displ_do_objects (diag,
diag->misc->solidstart, diag->misc->solidlimit, &org, &clip));
diag->misc->solidstart, diag->misc->solidlimit, diag->paper, &org, &clip));
#else
(void) draw_displ_do_objects (diag,
diag->misc->solidstart, diag->misc->solidlimit, &org, &clip);
diag->misc->solidstart, diag->misc->solidlimit, diag->paper, &org, &clip);
#endif
/*Repaint construction lines if this diag claims nulls*/
......@@ -1348,8 +1349,7 @@ void draw_paper_close (viewrec *vuue)
/*SMC: Reset pointer if it's in this diag*/
if (pointer_diag == diag)
{
pointer_diag = 0;
{ pointer_diag = NULL;
pointer_reset_shape ();
}
......@@ -1389,7 +1389,7 @@ static void paper_but (wimp_mousestr *m, viewrec *vuue)
pt.x = draw_scaledown (m->x - org.x); /*mouse position relative to*/
pt.y = draw_scaledown (m->y - org.y); /*window (ie diagram) origin*/
if ((err = draw_obj_drop_construction (diag)) != NULL)
if ((err = draw_obj_drop_construction (diag, TRUE)) != NULL)
return;
if (m->bbits & wimp_BLEFT) /*0x004 Double 'select'*/
......@@ -1659,8 +1659,9 @@ static void draw_paper__wimp_event_handler (wimp_eventstr *e, void *handle)
{ diagrec *diag;
for (diag = draw_startdiagchain; diag != 0; diag = diag->nextdiag)
if (diag->misc->wantsnulls)
draw_obj_drop_construction (diag);
draw_obj_drop_construction (diag, TRUE);
}
draw_drag_check_current_op(mouse); /*Update any current drag operation*/
}
break;
......@@ -1680,20 +1681,22 @@ static void draw_paper__wimp_event_handler (wimp_eventstr *e, void *handle)
break;
case wimp_EPTRLEAVE:
{ wimp_mousestr mouse;
if (!current_drag_op.autoscrolling)
{ /*if we're doing scrolling we'll get a leave event but we want to ignore it.*/
wimp_mousestr mouse;
ftracef0 ("** Pointer_Leaving_Window **\n");
wimp_get_point_info (&mouse);
ftracef0 ("** Pointer_Leaving_Window **\n");
wimp_get_point_info (&mouse);
/*Simulate null event on the window (for better visual effect)*/
if (pointer_diag)
if (draw_null_event_handler (mouse))
break;
/*Simulate null event on the window (for better visual effect)*/
if (pointer_diag)
if (draw_null_event_handler (mouse))
break;
/*Reset the pointer to normal shape*/
pointer_diag = 0;
pointer_reset_shape ();
}
/*Reset the pointer to normal shape*/
pointer_diag = NULL;
pointer_reset_shape ();
}
break;
case wimp_EPTRENTER:
......@@ -1750,6 +1753,8 @@ static void draw_paper__wimp_event_handler (wimp_eventstr *e, void *handle)
break;
case wimp_MDATASAVE: /*import*/
draw_drag_release_claim(); /*in case we received as a result of enhanced drag/drop*/
/*fall through*/
case wimp_MDATALOAD: /*insert*/
case wimp_MDATAOPEN: /*insert*/
{ wimp_mousestr mouse;
......@@ -1761,18 +1766,28 @@ static void draw_paper__wimp_event_handler (wimp_eventstr *e, void *handle)
e->data.msg.hdr.action == wimp_MDATALOAD? " Data Load\n":
" Data Open\n"
);
/*Find the mouse location*/
wimp_get_point_info (&mouse);
wimp_get_wind_state (vuue->w, &r);
draw_displ_scalefactor = vuue->zoomfactor;
if (draw_selection->owner == diag && draw_selection->indx != 0)
{ /*If we have a selection then paste the object to*/
/*the selection's origin to replace it*/
draw_bboxtyp selbound;
draw_obj_bound_selection (&selbound);
mouseD.x = selbound.x0;
mouseD.y = selbound.y0;
}
else
{ /*Find the mouse location*/
wimp_get_point_info (&mouse);
wimp_get_wind_state (vuue->w, &r);
draw_displ_scalefactor = vuue->zoomfactor;
draw_make_origin (&org, &r.o.box, &r.o.x);
draw_point_scale (&mouseD, (draw_objcoord *)&mouse.x, &org);
draw_make_origin (&org, &r.o.box, &r.o.x);
draw_point_scale (&mouseD, (draw_objcoord *)&mouse.x, &org);
/*Gravitate to grid position*/
draw_grid_snap_if_locked (vuue, &mouseD);
/*Gravitate to grid position*/
draw_grid_snap_if_locked (vuue, &mouseD);
}
/*Delete any existing selection */
/*Delete any existing selection*/
if (draw_selection->owner == diag)
draw_select_delete(draw_selection->owner);
......@@ -2136,7 +2151,26 @@ static void draw_bkg_events (wimp_eventstr *e, void *handle)
if (!help_process (e))
#endif
switch (e->e)
{ case wimp_ESEND:
{ case wimp_EUSERDRAG:
ftracef0 ("** User_DragBox **\n");
/*see if we were exporting....*/
draw_drag_poll_response(e);
break;
case wimp_EACK:
{ /*message bounced*/
switch (e->data.msg.hdr.action)
{ case wimp_MDRAGGING:
draw_drag_rx_mdragging_bounce(e);
break;
case wimp_MDRAGCLAIM:
break;
}
}
break;
case wimp_ESEND:
case wimp_ESENDWANTACK:
{ wimp_msgstr *msg = &e->data.msg; /*Make access easier*/
......@@ -2204,7 +2238,17 @@ static void draw_bkg_events (wimp_eventstr *e, void *handle)
draw_clipboard_claimed(e);
break;
case wimp_MDRAGGING: /*message dragging from us or another task*/
draw_drag_rx_mdragging(e);
break;
case wimp_MDRAGCLAIM: /*received a drag claim in response to our dragging*/
draw_drag_rx_mdragclaim(e);
break;
case wimp_MDATASAVE:
draw_drag_release_claim(); /*in case we received as enhanced datasave*/
/*fall through*/
case wimp_MDATALOAD:
case wimp_MDATAOPEN:
err = draw_load_file (NULL, NULL, &zero, msg->hdr.action==wimp_MDATAOPEN);
......@@ -2491,6 +2535,8 @@ int main (int argc, char **argv)
wimp_MDATAREQUEST,
wimp_MDATASAVED,
wimp_MCLAIMENTITY,
wimp_MDRAGGING,
wimp_MDRAGCLAIM,
wimp_MMENUWARN,
wimp_MMODECHANGE,
wimp_MHELPREQUEST,
......
This diff is collapsed.
......@@ -1285,7 +1285,7 @@ static os_error *do_objjpeg (draw_objptr hdrptr, draw_objcoord *org)
/* */
/* ------------------------------------------------------------------- */
os_error *draw_displ_do_objects (diagrec *diag, int offset, int end,
os_error *draw_displ_do_objects (diagrec *diag, int offset, int end, char *paper,
draw_objcoord *org, draw_bboxtyp *clip)
{ os_error *error = 0;
......@@ -1303,7 +1303,7 @@ os_error *draw_displ_do_objects (diagrec *diag, int offset, int end,
{ draw_objptr hdrptr;
os_error *e = NULL;
hdrptr.bytep = diag->paper + offset;
hdrptr.bytep = paper + offset;
size = hdrptr.objhdrp->size;
switch (hdrptr.objhdrp->tag)
......@@ -1323,7 +1323,7 @@ os_error *draw_displ_do_objects (diagrec *diag, int offset, int end,
if (visible (hdrptr, clip))
/* Render the objects in the group */
e = draw_displ_do_objects (diag, offset + sizeof (draw_groustr),
offset + size, org, clip), boxed = TRUE;
offset + size, paper, org, clip), boxed = TRUE;
break;
case draw_OBJTAGG:
......@@ -1334,7 +1334,7 @@ os_error *draw_displ_do_objects (diagrec *diag, int offset, int end,
/*Render the (one) object within the tagged object*/
e = draw_displ_do_objects (diag,
offset + sizeof (draw_taggstr),
offset + sizeof (draw_taggstr) + tagptr.objhdrp->size, org,
offset + sizeof (draw_taggstr) + tagptr.objhdrp->size, paper, org,
clip), boxed = TRUE;
}
break;
......
This diff is collapsed.
......@@ -1164,9 +1164,8 @@ os_error *draw_edit_flatten_join (diagrec *diag)
{ /*Get the required angle for nextele. This needs the start point of curr!*/
int dx, dy;
double length, angle;
drawmod_pathelemptr prevele;
draw_objcoord s;
draw_objcoord s = { 0, 0 };
prevele.bytep = diag->paper + diag->misc->pathedit_cb.pele_off;
......
......@@ -38,6 +38,8 @@
#include "jpeg.h"
#include "dbox.h"
#include "font.h"
#include "resspr.h"
#include "pointer.h"
#include "ftrace.h"
#include "guard.h"
......@@ -47,6 +49,7 @@
#include "DrawEdit.h"
#include "DrawEnter.h"
#include "DrawObject.h"
#include "DrawDrag.h"
null_owner_str draw_enter_null_owner = {0,0,-1};
focus_owner_str draw_enter_focus_owner = {0,0,-1};
......@@ -99,31 +102,48 @@ static void claim_idle_for_null_owner (void)
win_claim_idle_events (draw_enter_null_owner.hand);
if (draw_enter_null_owner.hand == -1)
event_setmask ((wimp_emask) (event_getmask () | wimp_EMNULL));
{ event_setmask ((wimp_emask) (event_getmask () | wimp_EMNULL));
draw_drag_stop_current();
}
else
event_setmask ((wimp_emask) (event_getmask () & ~wimp_EMNULL));
#if 1 /*JRC*/
if
( draw_enter_null_owner.hand != -1 &&
draw_enter_null_owner.diag != 0 &&
( draw_enter_null_owner.diag->misc->mainstate == state_sel ||
draw_enter_null_owner.diag->misc->mainstate == state_edit ||
if (draw_enter_null_owner.hand != -1 && draw_enter_null_owner.diag != 0)
{ if (draw_enter_null_owner.diag->misc->mainstate == state_edit ||
draw_enter_null_owner.diag->misc->substate == state_zoom ||
draw_enter_null_owner.diag->misc->substate == state_printerI ||
draw_enter_null_owner.diag->misc->substate == state_printerO
) )
draw_enter_null_owner.diag->misc->substate == state_printerO)
{ wimp_wstate state;
/*Bound the mouse to this window, just for fun*/
wimpt_noerr (wimp_get_wind_state (draw_enter_null_owner.hand,
&state));
&state));
Bound_Pointer (state.o.box.x0, state.o.box.y0,
state.o.box.x1, state.o.box.y1);
state.o.box.x1, state.o.box.y1);
}
else
/*Unbound the mouse*/
Unbound_Pointer ();
{ if (draw_enter_null_owner.diag->misc->mainstate == state_sel)
{ if (draw_enter_null_owner.diag->misc->substate!=state_sel_trans)
{ wimp_wstate state;
wimpt_noerr (wimp_get_wind_state (draw_enter_null_owner.hand,
&state));
Bound_Pointer (state.o.box.x0, state.o.box.y0,
state.o.box.x1, state.o.box.y1);
}
else
draw_drag_start_export(draw_enter_null_owner.vuue);
}
else
{ /*Unbound the mouse*/
Unbound_Pointer ();
}
}
}
else
{ /*Unbound the mouse*/
Unbound_Pointer ();
}
#endif
}
......
......@@ -673,16 +673,64 @@ static BOOL fetch_jpeg (diagrec *diag, char *name, int filelen,
/*---------------------- Text area handling ------------------------------*/
static BOOL text_label_import (diagrec *diag, char **buffer, int length, draw_objcoord *mouse)
{ draw_objptr hdrptr;
/*Text must be null terminated*/
if ((*buffer) [length-1] != 0)
{ if (!FLEX_EXTEND ((flex_ptr) buffer, length+1))
{ Error (0, "TextM1");
return FALSE;
}
(*buffer) [length++] = 0;
}
if (wimpt_complain (draw_obj_checkspace (diag, sizeof (draw_fileheader) +
sizeof (draw_textstrhdr) + length + 3 & ~3)))
return FALSE;
hdrptr.bytep = (char *) diag->paper + diag->misc->ghoststart + sizeof (draw_fileheader);
memset (hdrptr.bytep, 0, sizeof (draw_textstrhdr) + length + 3 & ~3);
hdrptr.textp->tag = draw_OBJTEXT;
hdrptr.textp->size = sizeof (draw_textstrhdr) + length + 3 & ~3;
hdrptr.textp->textcolour = diag->misc->font.textcolour;
hdrptr.textp->background = diag->misc->font.background;
hdrptr.textp->textstyle.fontref = diag->misc->font.typeface;
hdrptr.textp->textstyle.reserved8 = 0;
hdrptr.textp->textstyle.reserved16 = 0;
hdrptr.textp->fsizex = diag->misc->font.typesizex;
hdrptr.textp->fsizey = diag->misc->font.typesizey;
hdrptr.textp->coord = *mouse;
memcpy (hdrptr.textp->text, *buffer, length);
*--hdrptr.filehdrp = draw_blank_header;
diag->misc->ghoststart = hdrptr.bytep - diag->paper;
diag->misc->ghostlimit = diag->misc->ghoststart +
sizeof (draw_fileheader) + sizeof (draw_textstrhdr) + length + 3 & ~3;
return TRUE;
}
static BOOL text_file_contains_newline (const char *ptr, const int length)
{ /*Does this text contain a plurality of lines?*/
int i;
for (i = 0; i < length; i++)
if (*(ptr + i) == '\n') return TRUE;
return FALSE;
}
static BOOL fetch_textArea_file (diagrec *diag, char *fileName, int length,
draw_objcoord *mouse)
{ int columns;
ftracef0 ("draw_file: fetch_textArea_file\n");
/*Create a file header so loading will work*/
if (wimpt_complain (draw_obj_checkspace (diag, sizeof (draw_fileheader))))
return FALSE;
draw_obj_fileheader (diag);
/*Allocate initial memory for load*/
ftracef1 ("draw_file: fetch_textArea_file: flex_alloc (, %d)\n", length);
......@@ -701,6 +749,32 @@ static BOOL fetch_textArea_file (diagrec *diag, char *fileName, int length,
ftracef2 ("File as initially loaded:\n[%.*s]", length, Load_Base);
/*See if there are newlines. If so, it's a text area.*/
/*If not, then import as a text label.*/
if (!text_file_contains_newline (Load_Base, length))
{ BOOL result = text_label_import (diag, &Load_Base, length, mouse);
FLEX_FREE ((flex_ptr) &Load_Base);
return result;
}
/*Text area must end with a newline. If none present, append one.*/
if (Load_Base [length - 1] != '\n')
{ if (!FLEX_EXTEND ((flex_ptr) &Load_Base, length+1))
{ Error (0, "TextM1");
FLEX_FREE ((flex_ptr) &Load_Base);
return FALSE;
}
Load_Base [length] = '\n';
length++;
}
/*Create a file header so loading will work*/
if (wimpt_complain (draw_obj_checkspace (diag, sizeof (draw_fileheader))))
return FALSE;
draw_obj_fileheader (diag);
ftracef0 ("Prepend standard header if none is present\n");
if (Load_Base [0] != '\\')
{ int i, len = strlen (draw_text_header), n_bs = 0;
......@@ -930,17 +1004,18 @@ static BOOL write_fontlist_clipboard (char **store, char *fontusedp, int *byteco
void draw_file_typemask(draw_objptr hdrptr, int *mask)
{ switch (hdrptr.objhdrp->tag) {
case draw_OBJTEXT:
{ switch (hdrptr.objhdrp->tag)
{ case draw_OBJTEXT:
case draw_OBJTEXTAREA:
case draw_OBJTRFMTEXT:
case draw_OBJTEXTCOL:
case draw_OBJTRFMTEXTAREA:
case draw_OBJTRFMTEXTCOL:
*mask=*mask | _tm_text;
*mask = *mask | _tm_text | _tm_draw;
*mask = *mask &~ ( _tm_pure_sprite | _tm_pure_jpeg);
break;
case draw_OBJGROUP:
case draw_OBJGROUP:
{ draw_objptr objptr;
for (objptr.bytep = hdrptr.bytep + sizeof (draw_groustr);
......@@ -950,14 +1025,33 @@ void draw_file_typemask(draw_objptr hdrptr, int *mask)
}
break;
case draw_OBJTAGG:
{ draw_objptr tagptr;
tagptr.bytep = hdrptr.bytep + sizeof(draw_taggstr);
draw_file_typemask (tagptr, mask);
}
break;
case draw_OBJSPRITE:
*mask = *mask | _tm_sprite;
if (*mask == _tm_sprite)
*mask = *mask | _tm_pure_sprite;
break;
case draw_OBJTRFMSPRITE:
*mask = *mask | _tm_sprite;
*mask = *mask &~ (_tm_pure_sprite | _tm_pure_jpeg);
break;
case draw_OBJJPEG:
*mask = *mask | _tm_jpeg;
if (*mask == _tm_jpeg)
*mask = *mask | _tm_pure_jpeg;
break;
default:
*mask = *mask | _tm_draw;
break;
}
}
......@@ -1115,7 +1209,7 @@ static BOOL saveall (diagrec *diag, char *filename, fileIO_method method,
method == via_DIRECTCLICK? "direct click": "", filename);
/*Form file bbox*/
draw_obj_bound_all (diag, &hdrbox);
draw_obj_bound_all (diag->paper, diag->misc->solidstart, diag->misc->solidlimit, &hdrbox);
/*find fonts used in each selected object*/
{ draw_objptr hdrptr, limit;
......@@ -1311,21 +1405,16 @@ static BOOL saveselection (diagrec *diag, char *filename, fileIO_method method,
return (ok);
}
BOOL draw_file_copy_selection(diagrec *diag)
BOOL draw_file_extract_selection(diagrec *diag, char **buffer, int *buffer_length)
{ /* Create in-memory version and move to clipboard */
draw_bboxtyp hdrbox;
char fontusetab[256]; /*slot 0..255 are valid fontrefs*/
int i, bytecount;
int i, bytecount, offset = 0;
BOOL ok=TRUE;
draw_objptr hdrptr;
ftracef0 ("draw_file: draw_file_copy_selection\n");
/*Deselect all text columns -- they cannot be saved individually*/
if (draw_select_deselect_type (diag, draw_OBJTEXTCOL))
return TRUE; /*Nothing to save*/
draw_obj_bound_selection (&hdrbox);
/*find fonts used in each selected object*/
......@@ -1337,53 +1426,54 @@ BOOL draw_file_copy_selection(diagrec *diag)
bytecount = 0;
(void) save_selected_data (&hdrbox, fontusetab, diag, 0, &bytecount);
/* Create somewhere to receive the data */
if (clipdata != NULL) {
FLEX_FREE((flex_ptr)&clipdata);
clipdata = NULL;
}
if (FLEX_ALLOC((flex_ptr)&clipdata, bytecount) == 0) {
/* Out of space */
return FALSE;
} else {
cliplength = bytecount;
}
int offset = 0;
int typemask = _tm_draw;
int typelist[5];
if (FLEX_ALLOC((flex_ptr)buffer, bytecount) == 0)
return FALSE; /* Out of space */
else
*buffer_length = bytecount;
/* Drawfile header */
draw_fileheader header = draw_blank_header;
header.bbox = hdrbox;
memcpy(clipdata + offset, &header, sizeof(draw_fileheader));
memcpy(*buffer + offset, &header, sizeof(draw_fileheader));
offset += sizeof(draw_fileheader);
/* fontlist (if any) */
write_fontlist_clipboard(&clipdata, fontusetab, &offset);
write_fontlist_clipboard(buffer, fontusetab, &offset);
/*do each selected object*/
for (i = 0; ok && (hdrptr = draw_select_find (i), hdrptr.bytep != NULL); i++)
{
memcpy(clipdata + offset, draw_selection->owner->paper + draw_selection->array[i], hdrptr.objhdrp->size);
/* File types... */
draw_file_typemask(hdrptr, &typemask);
{ memcpy(*buffer + offset, draw_selection->owner->paper + draw_selection->array[i],hdrptr.objhdrp->size);
offset += hdrptr.objhdrp->size;
}
offset = 0;
if (typemask & _tm_draw) typelist[offset++] = FileType_Draw;
if (typemask & _tm_sprite) typelist[offset++] = FileType_Sprite;
if (typemask & _tm_text) typelist[offset++] = FileType_Text;
if (typemask & _tm_jpeg) typelist[offset++] = FileType_JPEG;
typelist[offset] = wimp_MDATAREQUEST_types_end;
/* We have the clipboard */
draw_clipboard_claim(wimp_MCLAIMENTITY_flags_clipboard);
return ok;
}
BOOL draw_file_copy_selection(diagrec *diag)
{ ftracef0 ("draw_file: saveselection\n");
/*Deselect all text columns -- they cannot be saved individually*/
if (draw_select_deselect_type (diag, draw_OBJTEXTCOL))
return TRUE; /*Nothing to save*/
/*Create somewhere to receive the data*/
if (clipdata != NULL)
{ FLEX_FREE((flex_ptr)&clipdata);
clipdata = NULL;
}
if (FALSE == draw_file_extract_selection(diag, &clipdata, &cliplength)) return FALSE;
/*We have the clipboard*/
draw_clipboard_claim(wimp_MCLAIMENTITY_flags_clipboard);
/*Work out print page parameters in case we export as PostScript*/
cliprotate = draw_print_get_limits (diag, &clippage, NULL);
return TRUE;
}
BOOL draw_file_file_saveselection (char *filename, void *handle)
{ ftracef2 ("draw_file_file_saveselection: filename: %s; handle: 0x%X\n", filename, handle);
return saveselection ((diagrec*) handle, filename, via_FILE, 0);
......@@ -1618,7 +1708,7 @@ diagrec *draw_file_loadfile (diagrec *diag, viewrec *vuue, char *name,
BOOL cleanpaper, commandLine = method == via_COMMANDLINE, newdiag = FALSE,
ok;
draw_objptr hdrptr;
int atoff, size, loadaddr = 0, execaddr = 0;
int old_solidlimit, atoff, size, loadaddr = 0, execaddr = 0;
ftracef0 ("draw_file_loadfile\n");
......@@ -1796,8 +1886,7 @@ diagrec *draw_file_loadfile (diagrec *diag, viewrec *vuue, char *name,
/*Rebound all the objects. For DXF files, also set the file bbox*/
ftracef0 ("draw_file_loadfile: draw_obj_bound_objects\n");
draw_obj_bound_objects (diag, diag->misc->ghoststart,
diag->misc->ghostlimit, filetype == FileType_DataExchangeFormat ||
filetype == FileType_Draw? &hdrbox: NULL);
diag->misc->ghostlimit, &hdrbox);
/*Strip the ghost area of options objects, setting options from the first
found if paper is clean. If no options are set, try to deduce the size
......@@ -1809,19 +1898,21 @@ diagrec *draw_file_loadfile (diagrec *diag, viewrec *vuue, char *name,
into the diagram, and prevents undo subsequently corrupting the
diagram. JRC 25th Nov 1994*/
if (!read_options (diag, cleanpaper))
if (cleanpaper) draw_setPaperSize (diag, hdrbox.x1, hdrbox.y1);
if (cleanpaper)
if (newdiag) draw_setPaperSize (diag, hdrbox.x1, hdrbox.y1);
/*If this is an addition to an existing file, move the insertion so that
it is at the pointer position. JRC 5 Oct 1990*/
atoff = diag->misc->solidlimit;
size = diag->misc->ghostlimit - diag->misc->ghoststart;
if (!cleanpaper && filetype == FileType_Draw)
if (!cleanpaper && mouse != NULL)
{ trans_str trans;
trans.dx = mouse->x - hdrbox.x0;
trans.dy = mouse->y - hdrbox.y0;
ftracef2 ("draw_file_loadfile: draw_shift_Draw_file: "