Commit f6a7d56a authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Update Draw$Options when menu options selected.

Mirrors behaviour of !Edit, per request in ticket #329.
Trimmed some dead code, renamed a C++ variable[D[D[D[D[e.

Version 1.18. Tagged as 'Draw-1_18'
parent 2be7f1d5
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.17"
Module_Version SETA 117
Module_MajorVersion SETS "1.18"
Module_Version SETA 118
Module_MinorVersion SETS ""
Module_Date SETS "14 Apr 2011"
Module_ApplicationDate SETS "14-Apr-11"
Module_Date SETS "30 May 2011"
Module_ApplicationDate SETS "30-May-11"
Module_ComponentName SETS "Draw"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Draw"
Module_FullVersion SETS "1.17"
Module_HelpVersion SETS "1.17 (14 Apr 2011)"
Module_FullVersion SETS "1.18"
Module_HelpVersion SETS "1.18 (30 May 2011)"
END
/* (1.17)
/* (1.18)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.17
#define Module_MajorVersion_CMHG 1.18
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 14 Apr 2011
#define Module_Date_CMHG 30 May 2011
#define Module_MajorVersion "1.17"
#define Module_Version 117
#define Module_MajorVersion "1.18"
#define Module_Version 118
#define Module_MinorVersion ""
#define Module_Date "14 Apr 2011"
#define Module_Date "30 May 2011"
#define Module_ApplicationDate "14-Apr-11"
#define Module_ApplicationDate "30-May-11"
#define Module_ComponentName "Draw"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Draw"
#define Module_FullVersion "1.17"
#define Module_HelpVersion "1.17 (14 Apr 2011)"
#define Module_LibraryVersionInfo "1:17"
#define Module_FullVersion "1.18"
#define Module_HelpVersion "1.18 (30 May 2011)"
#define Module_LibraryVersionInfo "1:18"
......@@ -52,6 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include <swis.h>
#include "Global/Variables.h"
#include "Global/FileTypes.h"
#include "os.h"
......@@ -2005,15 +2006,8 @@ static void draw_prequit (void)
}
}
/**************************************************************************
* *
* Background message receiver: allow drops onto icon. *
* *
**************************************************************************/
static char *write_options (void)
/*Translate draw_current_options to string (in static space).*/
static char *write_options (void)
{ static char Buffer [MAX_OPTIONS + 1];
int len;
......@@ -2021,7 +2015,7 @@ static char *write_options (void)
draw_options *opt0 = &initial_options;
/*name equivalence to save typing.*/
ftracef0 ("write_options\n");
ftracef0 ("draw_formulate_options\n");
Buffer [0] = '\0';
if (memcmp (&opt->paper, &opt0->paper, sizeof opt->paper) != 0)
......@@ -2111,10 +2105,19 @@ static char *write_options (void)
if ((len = strlen (Buffer)) > 0)
/*Overwrite the last space with '\0' for neatness*/
Buffer [--len] = '\0';
else
/*No output*/
strcpy(Buffer, "\"\"");
return Buffer;
}
/**************************************************************************
* *
* Background message receiver: allow drops onto icon. *
* *
**************************************************************************/
static void draw_bkg_events (wimp_eventstr *e, void *handle)
{ os_error *err = 0;
......@@ -2138,23 +2141,13 @@ static void draw_bkg_events (wimp_eventstr *e, void *handle)
case wimp_PALETTECHANGE:
{ diagrec *diag;
wimp_palettestr newpalette;
wimp_readpalette (&newpalette);
/*Check change is genuine. It should always be, but someone might be
lying*/
/*Don't check this - it might be the calibration that has changed. JRC
if (memcmp (&draw_palette, &newpalette, sizeof (wimp_palettestr)) != 0)
{
*/
wimp_readpalette (&draw_palette);
/*always reread the palette, it might be the calibration that has changed */
wimp_readpalette (&draw_palette);
/*redraw all views of all diagrams so they show true colours*/
for (diag = draw_startdiagchain; diag != 0; diag = diag->nextdiag)
draw_displ_forceredraw (diag);
/*}
*/
/*redraw all views of all diagrams so they show true colours*/
for (diag = draw_startdiagchain; diag != 0; diag = diag->nextdiag)
draw_displ_forceredraw (diag);
}
break;
......@@ -2205,18 +2198,18 @@ static void draw_bkg_events (wimp_eventstr *e, void *handle)
case wimp_SAVEDESK:
if (strlen (Draw_Dir) > 0) /*save if we know where we started*/
{ os_gbpbstr gbpb_str;
char lines [18 + MAX_OPTIONS + 3 + FILENAMEMAX + 1];
char lines [17 + MAX_OPTIONS + 1 + 4 + FILENAMEMAX + 1 + 1];
sprintf
( lines,
"Set Draw$Options \"%s\"\n/%s\n",
"Set Draw$Options %s\nRun %s\n",
write_options (), Draw_Dir
);
gbpb_str.action = 0x2,
gbpb_str.file_handle = msg->data.savedesk.filehandle,
gbpb_str.data_addr = (void *) lines,
gbpb_str.number = strlen (lines);
gbpb_str.file_handle = msg->data.savedesk.filehandle,
gbpb_str.data_addr = (void *) lines,
gbpb_str.number = strlen (lines);
if (wimpt_complain (os_gbpb (&gbpb_str)) != NULL)
{ /*Send back acknowledgement*/
......@@ -2294,7 +2287,6 @@ static void read_options (void)
{ /*Now sets draw_current_options. Called only once, at startup. JRC*/
char buffer [MAX_OPTIONS + 1], *token, *options;
draw_options *opt = &draw_current_options;
/*i e draw_options &opt = draw_current_options; (save typing)*/
/*Set defaults*/
*opt = initial_options;
......@@ -2396,7 +2388,7 @@ static void read_options (void)
case 'U': /*U<size>*/
{ int size = (int) strtol (token + 1, (char **) NULL, 10);
/*USe either given size rounded to a multiple of 4 or default*/
/*Use either given size rounded to a multiple of 4 or default*/
opt->undo_size = size <= 0? initial_options.undo_size: size & ~3;
}
break;
......@@ -3140,8 +3132,18 @@ void draw_modified (diagrec *diag)
draw_modified_no_undo (diag);
}
/* Write to Draw$Options */
void draw_set_dollar_options (void)
{ char *value;
value = write_options ();
os_swix5 (OS_SetVarVal, "Draw$Options", value,
strlen (value), 0, VarType_String);
}
/*Create (but don't display) a view window (plus its pane),*/
/*and insert at he head of the view chain for the diagram*/
/*and insert at the head of the view chain for the diagram*/
static os_error *draw_createview (diagrec *diag, viewrec **vuuep)
{ os_error *err;
......
......@@ -281,23 +281,23 @@ static void readstyle_path (draw_objptr hdrptr, void *handle)
if (pat != SOLID)
for (i = 1; i < sizeof linepatternvalue/sizeof (draw_dashstr *); i++)
{ draw_dashstr *try = linepatternvalue [i];
{ draw_dashstr *proposed = linepatternvalue [i];
BOOL found = FALSE;
if (try != SOLID)
{ if ((pat->dash.dashcount == try->dash.dashcount) &&
(pat->dash.dashstart == try->dash.dashstart))
if (proposed != SOLID)
{ if ((pat->dash.dashcount == proposed->dash.dashcount) &&
(pat->dash.dashstart == proposed->dash.dashstart))
{ int j;
found = TRUE;
for (j = 0; j < pat->dash.dashcount; j++)
if (pat->elements [j] != try->elements [j])
if (pat->elements [j] != proposed->elements [j])
{ found = FALSE;
break;
}
}
}
if (found) { style->path_data.pattern = try; break; }
if (found) { style->path_data.pattern = proposed; break; }
}
style->path_data.join = s.s.join;
......@@ -2325,8 +2325,13 @@ void draw_menu_proc (void *handle, char *hit)
viewrec *vuue = (viewrec *) handle;
diagrec *diag = vuue->diag;
char *o_hit = hit;
draw_options old_options;
ftracef0 ("draw_menu_proc: [\n");
/* Take a copy of the current options for later compare */
memcpy (&old_options, &draw_current_options, sizeof (draw_options));
main_window = -1;
ftracef2 ("draw_menu_proc: diag %d, view %d\n", diag, vuue);
......@@ -2350,8 +2355,6 @@ void draw_menu_proc (void *handle, char *hit)
{ papersize_typ size;
paperoptions_typ options;
/*draw_print_recachepagelimits (); Moved to later.*/
size = diag->misc->paperstate.size;
options = diag->misc->paperstate.options;
......@@ -2400,50 +2403,18 @@ void draw_menu_proc (void *handle, char *hit)
(paperoptions_typ) (draw_current_options.paper.o | Paper_Landscape);
break;
#if 0
case s_Misc_Paper_A0:
draw_action_resize (diag, Paper_A0, options);
draw_current_options.paper.size = Paper_A0;
break;
case s_Misc_Paper_A1:
draw_action_resize (diag, Paper_A1, options);
draw_current_options.paper.size = Paper_A1;
break;
case s_Misc_Paper_A2:
draw_action_resize (diag, Paper_A2, options);
draw_current_options.paper.size = Paper_A2;
break;
case s_Misc_Paper_A3:
draw_action_resize (diag, Paper_A3, options);
draw_current_options.paper.size = Paper_A3;
break;
case s_Misc_Paper_A4:
draw_action_resize (diag, Paper_A4, options);
draw_current_options.paper.size = Paper_A4;
break;
case s_Misc_Paper_A0:
case s_Misc_Paper_A1:
case s_Misc_Paper_A2:
case s_Misc_Paper_A3:
case s_Misc_Paper_A4:
case s_Misc_Paper_A5:
{ papersize_typ paper = (papersize_typ) (*(hit - 1) - 4 << 8);
case s_Misc_Paper_A5:
draw_action_resize (diag, Paper_A5, options);
draw_current_options.paper.size = Paper_A5;
break;
#else
case s_Misc_Paper_A0:
case s_Misc_Paper_A1:
case s_Misc_Paper_A2:
case s_Misc_Paper_A3:
case s_Misc_Paper_A4:
case s_Misc_Paper_A5:
{ papersize_typ paper = (papersize_typ) (*(hit - 1) - 4 << 8);
draw_action_resize (diag, paper, options);
draw_current_options.paper.size = paper;
}
break;
#endif
draw_action_resize (diag, paper, options);
draw_current_options.paper.size = paper;
}
break;
}
draw_print_recachepagelimits ();
......@@ -2872,6 +2843,11 @@ void draw_menu_proc (void *handle, char *hit)
draw_reset_gchar ();
wimpt_complain (err); /* Report any errors */
/* Look if options changed and update Draw$Options if needed */
if (memcmp (&draw_current_options, &old_options, sizeof (draw_options)) != 0)
draw_set_dollar_options ();
ftracef0 ("draw_menu_proc: ]\n");
}
......@@ -3302,5 +3278,9 @@ void draw_menu_entry_option (draw_state newstate, int curved, int closed)
opt->mode.elli = 1;
break;
}
/* Must have changed the mode option */
draw_set_dollar_options ();
ftracef0 ("draw_menu_entry_option: ]\n");
}
......@@ -1156,6 +1156,7 @@ extern BOOL draw_jpegs_rotate;
extern int __root_stack_size;
extern void draw_set_dollar_options(void);
extern void draw_set_current_font(diagrec *diag, int, int,int);
/* as wimp_open_wind, but opens toolbox pane iff vuue->showpane set */
......
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