Commit 290b3025 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Add support for background blended text and text areas

The background colour for text can now be set to "none" in the colour picker to request Draw to blend to background, rather than a fixed colour.
In the saved file 0xFFFFFFFF, or -1, is used (same as foreground colour transparent) which would render gracefully as a white background on older versions of !Draw.
For text areas the \B and \C commands can use -1 -1 -1 for the RGB components to denote transparency (3 arguments are defined as required in the text area spec, even though only 1 would really be needed).
When text in a text area has a foreground colour of 'transparent' no text is plotted, this is to be consistent with the behaviour for ordinary text.
Reordered the 'Enter' submenu to have the tools listed in the same order that they appear in the tools pane.
Moved MIN/MAX macros into common header.
Draw will only offer this functionality if an appropriate background blending Font Manager is in use, this is required as !Draw appears inside RO350Hook for machines that predate the functionality.

Version 1.24. Tagged as 'Draw-1_24'
parent ef9162a7
No preview for this file type
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.23"
Module_Version SETA 123
Module_MajorVersion SETS "1.24"
Module_Version SETA 124
Module_MinorVersion SETS ""
Module_Date SETS "25 Sep 2012"
Module_ApplicationDate SETS "25-Sep-12"
Module_Date SETS "22 Jul 2013"
Module_ApplicationDate SETS "22-Jul-13"
Module_ComponentName SETS "Draw"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Draw"
Module_FullVersion SETS "1.23"
Module_HelpVersion SETS "1.23 (25 Sep 2012)"
Module_FullVersion SETS "1.24"
Module_HelpVersion SETS "1.24 (22 Jul 2013)"
END
/* (1.23)
/* (1.24)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.23
#define Module_MajorVersion_CMHG 1.24
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Sep 2012
#define Module_Date_CMHG 22 Jul 2013
#define Module_MajorVersion "1.23"
#define Module_Version 123
#define Module_MajorVersion "1.24"
#define Module_Version 124
#define Module_MinorVersion ""
#define Module_Date "25 Sep 2012"
#define Module_Date "22 Jul 2013"
#define Module_ApplicationDate "25-Sep-12"
#define Module_ApplicationDate "22-Jul-13"
#define Module_ComponentName "Draw"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Draw"
#define Module_FullVersion "1.23"
#define Module_HelpVersion "1.23 (25 Sep 2012)"
#define Module_LibraryVersionInfo "1:23"
#define Module_FullVersion "1.24"
#define Module_HelpVersion "1.24 (22 Jul 2013)"
#define Module_LibraryVersionInfo "1:24"
......@@ -105,8 +105,6 @@
#define EMPTY(s) ((s) [0] == '\0')
#define CLEAR(s) ((s) [0] = '\0')
static int max (int a, int b) {return a > b? a: b;}
#define SIG_LIMIT 11 /*largest signal number + 1*/
#undef FREEZE_STACK
......@@ -231,6 +229,7 @@ draw_bboxtyp draw_big_box = {INT_MAX, INT_MAX, INT_MIN, INT_MIN };
#endif
BOOL draw_jpegs_rotate = TRUE;
BOOL draw_fonts_blend = TRUE;
static void cache_currentmodevars (void)
......@@ -2457,6 +2456,7 @@ int main (int argc, char **argv)
{ os_error *error;
template *t;
int version;
#if CATCH_SIGNALS
int s, sig;
#endif
......@@ -2632,6 +2632,11 @@ int main (int argc, char **argv)
draw_jpegs_rotate = jpeg_arbitrary_trans_supported ();
ftracef1 ("jpegs rotate: %s\n", draw_jpegs_rotate ? "TRUE" : "FALSE");
/*Find out if fonts are background blendable by this version of FontManager*/
os_swix1r (Font_CacheAddr, 0, &version);
draw_fonts_blend = version >= 335;
ftracef1 ("fonts blend: %s\n", draw_fonts_blend ? "TRUE" : "FALSE");
/*Generate the points on a circle of standard radius, centre (0,0).*/
/*These are placed in a point buffer implemented as an array of coords,*/
/*the circle is given by:*/
......@@ -2855,7 +2860,7 @@ void draw_open_wind (wimp_openstr *main, viewrec *vuue)
if (main->box.x0 <= oldmain.o.box.x0)
{ pane.o.w = vuue->pw;
/*FIX G-RO-9755 JRC 7 Oct 1991 move pane onscreen if possible*/
pane.o.box.x1 = main->box.x0 >= 0? max (main->box.x0, pane_width):
pane.o.box.x1 = main->box.x0 >= 0? MAX (main->box.x0, pane_width):
main->box.x0 + pane_width;
pane.o.box.y1 = main->box.y1;
......@@ -2890,7 +2895,7 @@ void draw_open_wind (wimp_openstr *main, viewrec *vuue)
wimpt_noerr (wimp_open_wind (main)); /*open main (paper) window*/
/*FIX G-RO-9755 JRC 7 Oct 1991 move pane onscreen if possible*/
pane.o.box.x1 = main->box.x0 >= 0? max (main->box.x0, pane_width):
pane.o.box.x1 = main->box.x0 >= 0? MAX (main->box.x0, pane_width):
main->box.x0 + pane_width;
pane.o.box.y1 = main->box.y1;
......
......@@ -61,9 +61,6 @@
#include "DrawSelect.h"
#include "DrawTextC.h"
#undef font_ABS
#define font_ABS 0
#ifndef USETAGBBOX
draw_bboxtyp *draw_displ_bbox (draw_objptr hdrptr)
......@@ -75,9 +72,6 @@ draw_bboxtyp *draw_displ_bbox (draw_objptr hdrptr)
}
#endif
#define MAX(a, b) ((a) > (b)? (a): (b))
#define MIN(a, b) ((a) < (b)? (a): (b))
os_error *draw_displ_font_stringpixbbox (font fonth, char *ptr,
draw_bboxtyp *boundp)
......@@ -329,7 +323,7 @@ static os_error *draw_displ_settruefontcol (font fonth, draw_coltyp foregrd,
ftracef3 ("draw_displ_settruefontcol: "
"calling font_paint to set handle 0x%X colour to 0x%08X, 0x%08X\n",
fonth, foregrd, backgrd);
error = font_paint (paint, font_ABS, 0, 0); /*Doesn't matter where.*/
error = font_paint (paint, 0, 0, 0); /*Doesn't matter where.*/
ftracef1 ("... error returned was 0x%08X\n", error);
return error;
......@@ -499,7 +493,8 @@ static os_error *do_objtext (draw_objptr hdrptr, draw_objcoord *org,
{ os_error *error;
int textcol = hdrptr.textp->textcolour,
backgrd = hdrptr.textp->background; /*a hint (kludge) to font munger*/
backgrd = hdrptr.textp->background; /*a hint (kludge) to font munger*/
int blend = ((backgrd == TRANSPARENT) && draw_fonts_blend) ? font_BLENDED : 0;
ftracef1 ("do_objtext: painting \"%s\"\n", hdrptr.textp->text);
if (textcol == TRANSPARENT)
......@@ -589,7 +584,7 @@ static os_error *do_objtext (draw_objptr hdrptr, draw_objcoord *org,
"0x%X, %d, %d)\n"
"... coords are (%d, %d) offset from origin (%d, %d) and scaled\n",
hdrptr.textp->text,
font_OSCOORDS | font_ABS,
font_OSCOORDS | blend,
scaleT (org->x, hdrptr.textp->coord.x),
scaleT (org->y, hdrptr.textp->coord.y),
hdrptr.textp->coord.x, hdrptr.textp->coord.y,
......@@ -597,7 +592,7 @@ static os_error *do_objtext (draw_objptr hdrptr, draw_objcoord *org,
);
#endif
if ((error = font_paint (hdrptr.textp->text,
font_OSCOORDS | font_ABS,
font_OSCOORDS | blend,
scaleT (org->x, hdrptr.textp->coord.x),
scaleT (org->y, hdrptr.textp->coord.y))) != NULL)
{ ftracef1 ("do_objtext: *ERROR* \"%s\"\n", error->errmess);
......@@ -1075,7 +1070,8 @@ static os_error *do_objtrfmtext_system (draw_objptr hdrptr,
static os_error *do_objtrfmtext (draw_objptr hdrptr, draw_objcoord *org)
{ int textcol = hdrptr.trfmtextp->textcolour,
backgrd = hdrptr.trfmtextp->background;
backgrd = hdrptr.trfmtextp->background;
int blend = ((backgrd == TRANSPARENT) && draw_fonts_blend) ? font_BLENDED : 0;
os_error *error;
os_regset reg_set;
font fonth;
......@@ -1164,7 +1160,7 @@ static os_error *do_objtrfmtext (draw_objptr hdrptr, draw_objcoord *org)
"0x%X, %d, %d)\n"
"... coords are (%d, %d) offset from origin (%d, %d) and scaled\n",
hdrptr.trfmtextp->text,
font_OSCOORDS | font_ABS,
font_OSCOORDS | blend,
scaleT (org->x, hdrptr.trfmtextp->coord.x),
scaleT (org->y, hdrptr.trfmtextp->coord.y),
hdrptr.trfmtextp->coord.x, hdrptr.trfmtextp->coord.y,
......@@ -1174,8 +1170,7 @@ static os_error *do_objtrfmtext (draw_objptr hdrptr, draw_objcoord *org)
reg_set.r [2] =
font_OSCOORDS |
font_ABS |
1 << 6 /*use trfm*/ |
1 << 6 /*use trfm*/ | blend |
hdrptr.trfmtextp->flags.kerned << 9 |
hdrptr.trfmtextp->flags.direction << 10;
reg_set.r [3] = scaleT (org->x, hdrptr.trfmtextp->coord.x);
......
......@@ -2646,7 +2646,7 @@ void draw_menu_proc (void *handle, char *hit)
case s_Style_Background:
change_colour (diag, restyle_FONTBACKGROUND,
(dboxtcol_colour *) &style.text_data.background,
FALSE, "MenuCl5");
draw_fonts_blend, "MenuCl5");
break;
}
break;
......
......@@ -65,7 +65,6 @@
#include "DrawPrint.h"
#define strnul(s) ((s) [0] == '\0')
#define MAX(a, b) ((a) > (b)? (a): (b))
/* Defines for options that might want to be taken out again */
#define SINGLEPAGE 0
......
......@@ -349,6 +349,12 @@ static int draw_getNum (int from, char *base, int *to, BOOL negative,
base [*rest]);
return draw_numMORE;
}
else if (negative && base [r] == '-')
{ *rest = r;
ftracef1 ("draw_getNum -> -ve draw_numMORE, next \'%c\'\n",
base [*rest]);
return draw_numMORE;
}
else if (isTerm (base [r]))
{ *rest = r + 1;
ftracef1 ("draw_getNum -> draw_numOK, next \'%c\'\n",
......@@ -1015,14 +1021,22 @@ static char *draw_text_getString (char *in, font *fonts,
r = 0, g = 0, b = 0;
in = strpbrk (in, "\n/") + 1;
if (r < 0) r = 0; else if (r > 255) r = 255;
if (g < 0) g = 0; else if (g > 255) g = 255;
if (b < 0) b = 0; else if (b > 255) b = 255;
if (foreground)
draw_text_fg = b << 24 | g << 16 | r << 8;
if (r == -1)
{ if (foreground)
draw_text_fg = TRANSPARENT;
else
draw_text_bg = TRANSPARENT;
}
else
draw_text_bg = b << 24 | g << 16 | r << 8;
{ if (r < 0) r = 0; else if (r > 255) r = 255;
if (g < 0) g = 0; else if (g > 255) g = 255;
if (b < 0) b = 0; else if (b > 255) b = 255;
if (foreground)
draw_text_fg = b << 24 | g << 16 | r << 8;
else
draw_text_bg = b << 24 | g << 16 | r << 8;
}
draw_text_setup_colour (draw_text_fg, draw_text_bg, out);
#if USE_TRUE_COLOUR
......@@ -1501,8 +1515,8 @@ static int draw_text_paintCheck (int offset, int y, /*draw_bboxtyp *clip,*/
Function : draw_text_paint
Purpose : paint the current line
Parameters : chunk offset
displaced character from line
left limit, right limit
plot flags
align code
true width
x origin
......@@ -1515,11 +1529,11 @@ static int draw_text_paintCheck (int offset, int y, /*draw_bboxtyp *clip,*/
problems with redraw. We can be sure that it fits horizontally.
*/
static os_error *draw_text_paint (int offset, char displace, int x0, int x1,
draw_align align, int trueWidth, int orgx, int y)
static os_error *draw_text_paint (int offset, int x0, int x1,
int plotType, draw_align align, int trueWidth, int orgx, int y)
{ os_error *err = NULL;
int x, plotType = 0 /*font_ABS*/;
int x;
ftracef0 ("draw_text_paint: text \"");
ftrace_paint (chunk + offset);
......@@ -1529,10 +1543,6 @@ static os_error *draw_text_paint (int offset, char displace, int x0, int x1,
trueWidth, orgx, y);
#endif
/* Get plot point, allowing for alignment and scaling */
if (align == alignDouble && displace != '\0' && displace != '\n')
plotType |= font_JUSTIFY;
if (align == alignRight)
x = (int) (draw_displ_scalefactor*x1 - trueWidth);
else if (align == alignCentre)
......@@ -1758,7 +1768,7 @@ static BOOL draw_textArea (draw_objptr hdrptr, draw_objcoord *org,
/* Ensure chunk is not empty */
if (chunk [c] != '\0' && chunk [c] != '\n')
{ int trueWidth, scaledWidth, x0, x1, next;
{ int plotType, trueWidth, scaledWidth, x0, x1, next;
char displaced;
/* Loop over each line in the chunk */
......@@ -1801,9 +1811,15 @@ static BOOL draw_textArea (draw_objptr hdrptr, draw_objcoord *org,
/* Plot if we are still in box (may fail with descenders) */
switch (draw_text_paintCheck (c, y, /*clip,*/ &box, &state))
{ case draw_paint_OK:
if (state.defaultFont != -1 && (err = draw_text_paint
(c, displaced, x0, x1, state.align, trueWidth, orgx,
scaleupY (y))) != NULL)
/* Set up plotting style */
plotType = ((draw_text_bg == TRANSPARENT) && draw_fonts_blend) ? font_BLENDED : 0;
/* Get plot point, allowing for alignment and scaling */
if (state.align == alignDouble && displaced != '\0' && displaced != '\n')
plotType |= font_JUSTIFY;
if (state.defaultFont != -1 && draw_text_fg != TRANSPARENT && (err = draw_text_paint
(c, x0, x1, plotType, state.align, trueWidth, orgx, scaleupY (y))) != NULL)
{ draw_textPatchup ();
return FALSE;
}
......@@ -1968,11 +1984,17 @@ BOOL draw_text_verifyTextArea (char *text, int length, int *columns,
case 'B': case 'C': /* \B or \C followed by three numbers */
{ int i;
int r, g, b;
ftracef0 ("calling draw_getNum() up to 3 times\n");
if (draw_getNum (1, text, NULL, FALSE, TRUE, &i) != draw_numMORE
|| draw_getNum (i, text, NULL, FALSE, TRUE, &i) != draw_numMORE
|| draw_getNum (i, text, NULL, FALSE, TRUE, &i) != draw_numOK)
if (draw_getNum (1, text, &r, TRUE, TRUE, &i) != draw_numMORE
|| draw_getNum (i, text, &g, TRUE, TRUE, &i) != draw_numMORE
|| draw_getNum (i, text, &b, TRUE, TRUE, &i) != draw_numOK)
{ draw_report ("TextT1", *text);
return FALSE;
}
if (((r < 0) || (g < 0) || (b < 0)) /* If transparent allow only -1 -1 -1 */
&& ((r != -1) || (g != -1) || (b != -1)))
{ draw_report ("TextT1", *text);
return FALSE;
}
......
......@@ -173,6 +173,9 @@ don't work at large zoom factors.*/
#define makmsg(A) ((os_error *) (msgs_lookup (A)))
#define retmsg(A) {return makmsg (A);}
#define MAX(a, b) ((a) > (b)? (a): (b))
#define MIN(a, b) ((a) < (b)? (a): (b))
/* 'select' mode, expect Space,Object,Rotate,Stretch */
/* 'edit'submode, expect Space,Object,Control */
typedef enum /* Position of mouse click */
......@@ -1153,6 +1156,7 @@ extern char draw_zero_str[];
extern char draw_one_str[];
extern BOOL draw_jpegs_rotate;
extern BOOL draw_fonts_blend;
extern int __root_stack_size;
......
......@@ -73,15 +73,15 @@
/* Enter menu */
#define s_Enter_Enter 0
#define s_Enter_Text 1
#define s_Enter_Line 2
#define s_Enter_Curve 3
#define s_Enter_Move 4
#define s_Enter_Complete 5
#define s_Enter_Autoclose 6
#define s_Enter_Abandon 7
#define s_Enter_Rectangle 8
#define s_Enter_Ellipse 9
#define s_Enter_Line 1
#define s_Enter_Curve 2
#define s_Enter_Ellipse 3
#define s_Enter_Rectangle 4
#define s_Enter_Text 5
#define s_Enter_Move 6
#define s_Enter_Complete 7
#define s_Enter_Autoclose 8
#define s_Enter_Abandon 9
/* Select menus */
#define s_Select_Select 0
......
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