Commit 87d7f0c0 authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

Add a file info box

Paint and Edit have Misc > File menu entries, but not Draw. Add one, showing the file name and size, number of Draw objects in the drawing, and modified status.
parent a1faed3a
......@@ -19,6 +19,8 @@ DrawO1:Coordinate too big (maximum is %.2f)
DrawX:Draw has gone wrong (%0): attempting to preserve files in %1.%2 before exiting
DrawU:The undo mechanism has been asked to something nonsensical (line %d)
DrawCBE:There is nothing suitable on the clipboard
DrawY:Yes
DrawN:No
Chk00:%s at location 16_%X
ChkB1:Bounding box coordinates are in the wrong order
ChkC1:Bad character in string
......@@ -160,7 +162,7 @@ MenuLR1:Non-zero,Even-odd
MenuLW0:Line width
MenuLW1:Thin,0.25,0.5,1,2,4,(num)
MenuM0:Misc
MenuM1:>Info,New view,Paper limits,>Print PRINT,Zoom lock ^L,Undo F8,Redo F9
MenuM1:>Info,>File,New view,Paper limits,>Print PRINT,Zoom lock ^L,Undo F8,Redo F9
MenuP0:Paper limits
MenuP1:Show,Reset|Portrait,Landscape|A0,A1,A2,A3,A4,A5
MenuS0:Style
......@@ -248,12 +250,13 @@ D5:\Rtransform the selection.
D6:\Rcontrol the zoom factor.|m(Press ^Q to zoom out.)|m(Press ^W to zoom in.)|m(Press ^D to reset.)|m(Press ^R to toggle the factor.)|m(Drag |!|K\a to zoom in to a given box.)|m(Double-click |!|K\a to zoom out.)
D7:\Rcontrol the grid.|m\Stoggle the presence of the grid.
D8:Click \s (or press ^F1) to toggle the presence of the toolbox \w.
D01:Click \s for another \w onto the same drawing.
D02:\Stoggle the presence of visible paper limits.|m\Rcontrol the limits.|mClick ^\s or ^\a to move the limits.|mDrag ^\s or ^\a to change the outer or inner limits.
D03:\Sprint the drawing.|mMove the pointer right (or press PRINT) to set the number of copies.
D04:Click \s (or press ^L) to toggle the Zoom lock to powers of two.
D05:Click \s (or press F8) to undo the last operation.
D06:Click \s (or press F9) to redo the operation just undone.
D01:\Ropen a box showing information about this drawing.
D02:Click \s for another \w onto the same drawing.
D03:\Stoggle the presence of visible paper limits.|m\Rcontrol the limits.|mClick ^\s or ^\a to move the limits.|mDrag ^\s or ^\a to change the outer or inner limits.
D04:\Sprint the drawing.|mMove the pointer right (or press PRINT) to set the number of copies.
D05:Click \s (or press ^L) to toggle the Zoom lock to powers of two.
D06:Click \s (or press F8) to undo the last operation.
D07:Click \s (or press F9) to redo the operation just undone.
D10:Move the pointer right (or press F3) to get a save box for this drawing.
D11:Move the pointer right (or press |!|KF3) to get a save box for the selection.
D12:Move the pointer right (or press ^F3) to get a save box for the sprites of this drawing.
......@@ -378,6 +381,7 @@ EDIT9:Click \s (or press ^S or |!|KF5) to move all points in the current path to
DXF:Fill in the scale factor and default font name and click \s on OK to make a drawing from a DXF file.
LOAD:Fill in the name of a file and click \s on OK to add it into the drawing.|m(Drag \s from a file icon to a drawing to add the file into the drawing.)
INFO:This \w displays information about Draw.
FINF:This \w shows information about this drawing.
SAVEAS:Either drag \s from the file icon to a directory display, or fill in the name of a file and click \s on OK, to save as a drawing.
MAGNIFIER: Either fill in the numerator and denominator, or click \s on the arrows, to use the given zoom factor.
CLOSE:\Sanswer the question.
......
......@@ -42,6 +42,7 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "swis.h"
#include "Global/FileTypes.h"
#include "akbd.h"
......@@ -2297,6 +2298,53 @@ void draw_menu_infoaboutprogram (void)
}
}
static int draw_menu_countobjects (draw_objptr hdrptr)
{ if (hdrptr.objhdrp->tag == draw_OBJGROUP)
{ int objects = 0, i, limit = hdrptr.objhdrp->size;
draw_objptr objptr;
for (i = sizeof (draw_groustr); i < limit; i += objptr.objhdrp->size)
{ objptr.bytep = hdrptr.bytep + i;
/*Recurse into the group*/
objects += draw_menu_countobjects (objptr);
}
return objects;
}
return 1;
}
static void draw_menu_infoaboutfile (viewrec *vuue)
{ diagrec *diag = vuue->diag;
dbox d = dbox_new ("fileInfo");
char string[40];
int i, objects = 0;
draw_objptr hdrptr;
if (d)
{ /*Supply raw event handler for help messages*/
dbox_raw_eventhandler (d, &help_dboxrawevents, (void *) "FINF");
/*Populate info*/
dbox_setfield (d, 0, diag->misc->filename [0] != '\0' ? diag->misc->filename
: UNTITLED);
os_swix3 (OS_ConvertFileSize, draw_file_size (diag), string, sizeof(string));
dbox_setfield (d, 3, string);
for (i = diag->misc->solidstart; i < diag->misc->solidlimit;
i += hdrptr.objhdrp->size)
{ hdrptr.bytep = diag->paper + i;
objects += draw_menu_countobjects(hdrptr);
}
dbox_setnumeric (d, 1, objects);
dbox_setfield (d, 2, msgs_lookup (diag->misc->options.modified ? "DrawY" : "DrawN"));
dbox_show (d);
dbox_fillin (d);
dbox_hide (d);
dbox_dispose (&d);
}
}
static void draw_menu_infoaboutprinter (int *copiesp)
/* Returns copies count */
......@@ -2368,6 +2416,10 @@ void draw_menu_proc (void *handle, char *hit)
if (*hit) draw_menu_infoaboutprogram ();
break;
case s_Misc_File:
if (*hit) draw_menu_infoaboutfile (vuue);
break;
case s_Misc_Newview: /* misc.newview */
{ viewrec *vuue;
err = draw_opennewview (diag, &vuue);
......
......@@ -40,12 +40,13 @@
/* Misc menu */
#define s_Misc_Info 1
#define s_Misc_Newview 2
#define s_Misc_Paper 3
#define s_Misc_Print 4
#define s_Misc_Zoomlock 5
#define s_Misc_Undo 6
#define s_Misc_Redo 7
#define s_Misc_File 2
#define s_Misc_Newview 3
#define s_Misc_Paper 4
#define s_Misc_Print 5
#define s_Misc_Zoomlock 6
#define s_Misc_Undo 7
#define s_Misc_Redo 8
/* Save menu */
#define s_Save_File 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment