1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
/**********************************************************************
* File: txtregn.c (Formerly text_region.c)
* Description: Text region within a polygonal block
* Author: Sheelagh Lloyd?
* Created:
*
* (C) Copyright 1993, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*
**********************************************************************/
#include "mfcpch.h"
#include <ctype.h>
#include <math.h>
#include "txtregn.h"
#include "labls.h"
#include "hpddef.h" //must be last (handpd.dll)
ELISTIZE_S (TEXT_REGION) TEXT_REGION::TEXT_REGION (inT32 idno, ICOORDELT_LIST * points, TEXT_REGION_LIST * child):POLY_BLOCK (points,
POLY_TEXT) {
TEXT_REGION_IT
c = &txt_regions;
id_number = idno;
txt_regions.clear ();
c.move_to_first ();
c.add_list_before (child);
}
TEXT_REGION::TEXT_REGION (inT32 idno, ICOORDELT_LIST * points):POLY_BLOCK (points,
POLY_TEXT) {
id_number = idno;
txt_regions.clear ();
}
TEXT_REGION::TEXT_REGION ( //constructor
inT32 idno, ICOORDELT_LIST * points, inT8 hor, inT8 tex, inT8 ser, inT8 pro, inT8 nor, inT8 upr, inT8 sol, inT8 bla, inT8 und, inT8 dro):POLY_BLOCK (points,
POLY_TEXT) {
id_number = idno;
horizontal = hor;
text = tex;
serif = ser;
proportional = pro;
normal = nor;
upright = upr;
solid = sol;
black = bla;
underlined = und;
dropcaps = dro;
txt_regions.clear ();
}
void TEXT_REGION::set_attrs(inT8 hor,
inT8 tex,
inT8 ser,
inT8 pro,
inT8 nor,
inT8 upr,
inT8 sol,
inT8 bla,
inT8 und,
inT8 dro) {
horizontal = hor;
text = tex;
serif = ser;
proportional = pro;
normal = nor;
upright = upr;
solid = sol;
black = bla;
underlined = und;
dropcaps = dro;
}
#include "hpddef.h" //must be last (handpd.dll)
void TEXT_REGION::show_attrs( //Now uses tprintf instead
DEBUG_WIN *f) {
TEXT_REGION_IT it = &txt_regions;
if (id_number > -1) {
f->
dprintf
("Text region no. %d with attributes %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n",
id_number, tlabel[0][horizontal], tlabel[1][text],
tlabel[2][serif], tlabel[3][proportional], tlabel[4][normal],
tlabel[5][upright], tlabel[6][solid], tlabel[7][black],
tlabel[8][underlined], tlabel[9][dropcaps]);
if (!txt_regions.empty ()) {
f->dprintf ("with text subregions\n");
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
it.data ()->show_attrs (f);
f->dprintf ("end of subregions\n");
}
}
else
f->
dprintf
("Text subregion with attributes %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n",
tlabel[0][horizontal], tlabel[1][text], tlabel[2][serif],
tlabel[3][proportional], tlabel[4][normal], tlabel[5][upright],
tlabel[6][solid], tlabel[7][black], tlabel[8][underlined],
tlabel[9][dropcaps]);
}
void TEXT_REGION::add_a_region(TEXT_REGION *newchild) {
TEXT_REGION_IT c = &txt_regions;
c.move_to_first ();
c.add_to_end (newchild);
}
/**********************************************************************
* TEXT_REGION::rotate
*
* Rotate the TEXT_REGION and its children
**********************************************************************/
void TEXT_REGION::rotate( //cos,sin
FCOORD rotation) {
//sub block iterator
TEXT_REGION_IT child_it = &txt_regions;
TEXT_REGION *child; //child block
for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
child_it.forward ()) {
child = child_it.data ();
child->rotate (rotation);
}
POLY_BLOCK::rotate(rotation);
}
/**********************************************************************
* TEXT_REGION::move
*
* Move the TEXT_REGION and its children
**********************************************************************/
void TEXT_REGION::move(ICOORD shift //amount to move
) {
//sub block iterator
TEXT_REGION_IT child_it = &txt_regions;
TEXT_REGION *child; //child block
for (child_it.mark_cycle_pt (); !child_it.cycled_list ();
child_it.forward ()) {
child = child_it.data ();
child->move (shift);
}
POLY_BLOCK::move(shift);
}
/**********************************************************************
* TEXT_REGION::serialise_asc() Convert to ascii file.
*
**********************************************************************/
void TEXT_REGION::serialise_asc( //convert to ascii
FILE *f //file to use
) {
((POLY_BLOCK *) this)->serialise_asc (f);
serialise_INT32(f, id_number); //unique id
//horizontal, vertical, skewed
serialise_INT32(f, horizontal);
serialise_INT32(f, text); //text, table, form
serialise_INT32(f, serif); //serif, sansserif
//proportional, fixed
serialise_INT32(f, proportional);
serialise_INT32(f, normal); //normal, bold
serialise_INT32(f, upright); //upright, italic
serialise_INT32(f, solid); //solid, outline
serialise_INT32(f, black); //black, coloured, white,
//not underlined, underlined
serialise_INT32(f, underlined);
serialise_INT32(f, dropcaps); //not dropcaps, dropcaps
txt_regions.serialise_asc (f);
}
/**********************************************************************
* TEXT_REGION::de_serialise_asc() Convert from ascii file.
*
**********************************************************************/
void TEXT_REGION::de_serialise_asc( //convert from ascii
FILE *f //file to use
) {
((POLY_BLOCK *) this)->de_serialise_asc (f);
//unique id
id_number = de_serialise_INT32 (f);
//horizontal, vertical, skewed
horizontal = de_serialise_INT32 (f);
text = de_serialise_INT32 (f); //text, table, form
serif = de_serialise_INT32 (f);//serif, sansserif
//proportional, fixed
proportional = de_serialise_INT32 (f);
//normal, bold
normal = de_serialise_INT32 (f);
//upright, italic
upright = de_serialise_INT32 (f);
solid = de_serialise_INT32 (f);//solid, outline
black = de_serialise_INT32 (f);//black, coloured, white,
//not underlined, underlined
underlined = de_serialise_INT32 (f);
//not dropcaps, dropcaps
dropcaps = de_serialise_INT32 (f);
txt_regions.de_serialise_asc (f);
}
|