| 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 |
#include <fontforge-config.h> |
| 29 |
|
| 30 |
#include "cvundoes.h" |
| 31 |
#include "fontforgeui.h" |
| 32 |
#include "gkeysym.h" |
| 33 |
#include "gresedit.h" |
| 34 |
#include "splineutil.h" |
| 35 |
#include "ttf.h" |
| 36 |
#include "ttfinstrs.h" |
| 37 |
#include "ustring.h" |
| 38 |
#include "utype.h" |
| 39 |
|
| 40 |
extern GBox _ggadget_Default_Box; |
| 41 |
#define ACTIVE_BORDER (_ggadget_Default_Box.active_border) |
| 42 |
#define MAIN_FOREGROUND (_ggadget_Default_Box.main_foreground) |
| 43 |
|
| 44 |
GResFont cvt_font = GRESFONT_INIT("400 12px " MONO_UI_FAMILIES) ; |
| 45 |
GResFont ttinstruction_font = GRESFONT_INIT("400 12px " MONO_UI_FAMILIES); |
| 46 |
|
| 47 |
extern int _GScrollBar_Width; |
| 48 |
#define EDGE_SPACING 2 |
| 49 |
|
| 50 |
#define ttf_width 16 |
| 51 |
#define ttf_height 16 |
| 52 |
static unsigned char ttf_bits[] = { |
| 53 |
0xff, 0x07, 0x21, 0x04, 0x20, 0x00, 0xfc, 0x7f, 0x24, 0x40, 0xf4, 0x5e, |
| 54 |
0xbc, 0x72, 0xa0, 0x02, 0xa0, 0x02, 0xa0, 0x02, 0xf0, 0x02, 0x80, 0x02, |
| 55 |
0xc0, 0x06, 0x40, 0x04, 0xc0, 0x07, 0x00, 0x00}; |
| 56 |
GWindow ttf_icon = NULL; |
| 57 |
|
| 58 |
static char *instrhelppopup[256]; |
| 59 |
|
| 60 |
static void ihaddr(int bottom,int top,char *msg) { |
| 61 |
while ( bottom<=top ) |
| 62 |
instrhelppopup[bottom++] = msg; |
| 63 |
} |
| 64 |
|
| 65 |
static void ihadd(int p,char *msg) { |
| 66 |
ihaddr(p,p,msg); |
| 67 |
} |
| 68 |
|
| 69 |
static void instrhelpsetup(void) { |
| 70 |
if ( instrhelppopup[0]!=NULL ) |
| 71 |
return; |
| 72 |
ihadd(0x7f,N_("Adjust Angle\nObsolete instruction\nPops one value")); |
| 73 |
ihadd(0x64,N_("ABSolute Value\nReplaces top of stack with its abs")); |
| 74 |
ihadd(0x60,N_("ADD\nPops two 26.6 fixed numbers from stack\nadds them, pushes result")); |
| 75 |
ihadd(0x27,N_("ALIGN PoinTS\nAligns (&pops) the two points which are on the stack\nby moving along freedom vector to the average of their\npositions on projection vector")); |
| 76 |
ihadd(0x3c,N_("ALIGN to Reference Point\nPops as many points as specified in loop counter\nAligns points with RP0 by moving each\nalong freedom vector until distance to\nRP0 on projection vector is 0")); |
| 77 |
ihadd(0x5a,N_("logical AND\nPops two values, ands them, pushes result")); |
| 78 |
ihadd(0x2b,N_("CALL function\nPops a value, calls the function represented by it")); |
| 79 |
ihadd(0x67,N_("CEILING\nPops one 26.6 value, rounds upward to an int\npushes result")); |
| 80 |
ihadd(0x25,N_("Copy INDEXed element to stack\nPops an index & copies stack\nelement[index] to top of stack")); |
| 81 |
ihadd(0x22,N_("CLEAR\nPops all elements on stack")); |
| 82 |
ihadd(0x4f,N_("DEBUG call\nPops a value and executes a debugging interpreter\n(if available)")); |
| 83 |
ihadd(0x73,N_("DELTA exception C1\nPops a value n & then n exception specifications & cvt entries\nchanges each cvt entry at a given size by the pixel amount")); |
| 84 |
ihadd(0x74,N_("DELTA exception C2\nPops a value n & then n exception specifications & cvt entries\nchanges each cvt entry at a given size by the amount")); |
| 85 |
ihadd(0x75,N_("DELTA exception C3\nPops a value n & then n exception specifications & cvt entries\nchanges each cvt entry at a given size by the amount")); |
| 86 |
ihadd(0x5D,N_("DELTA exception P1\nPops a value n & then n exception specifications & points\nmoves each point at a given size by the amount")); |
| 87 |
ihadd(0x71,N_("DELTA exception P2\nPops a value n & then n exception specifications & points\nmoves each point at a given size by the amount")); |
| 88 |
ihadd(0x72,N_("DELTA exception P3\nPops a value n & then n exception specifications & points\nmoves each point at a given size by the amount")); |
| 89 |
ihadd(0x24,N_("DEPTH of stack\nPushes the number of elements on the stack")); |
| 90 |
ihadd(0x62,N_("DIVide\nPops two 26.6 numbers, divides them, pushes result")); |
| 91 |
ihadd(0x20,N_("DUPlicate top stack element\nPushes the top stack element again")); |
| 92 |
ihadd(0x59,N_("End IF\nEnds an IF or IF-ELSE sequence")); |
| 93 |
ihadd(0x1b,N_("ELSE clause\nStart of Else clause of preceding IF")); |
| 94 |
ihadd(0x2d,N_("END Function definition")); |
| 95 |
ihadd(0x54,N_("EQual\nPops two values, tests for equality, pushes result(0/1)")); |
| 96 |
ihadd(0x57,N_("EVEN\nPops one value, rounds it and tests if it is even(0/1)")); |
| 97 |
ihadd(0x2C,N_("Function DEFinition\nPops a value (n) and starts the nth\nfunction definition")); |
| 98 |
ihadd(0x4e,N_("set the auto FLIP boolean to OFF")); |
| 99 |
ihadd(0x4d,N_("set the auto FLIP boolean to ON")); |
| 100 |
ihadd(0x80,N_("FLIP PoinT\nPops as many points as specified in loop counter\nFlips whether each point is on/off curve")); |
| 101 |
ihadd(0x82,N_("FLIP RanGe OFF\nPops two point numbers\nsets all points between to be off curve points")); |
| 102 |
ihadd(0x81,N_("FLIP RanGe ON\nPops two point numbers\nsets all points between to be on curve points")); |
| 103 |
ihadd(0x66,N_("FLOOR\nPops a value, rounds to lowest int, pushes result")); |
| 104 |
ihaddr(0x46,0x47,N_("Get Coordinate[a] projected onto projection vector\n 0=>use current pos\n 1=>use original pos\nPops one point, pushes the coordinate of\nthe point along projection vector")); |
| 105 |
ihadd(0x88,N_("GET INFOrmation\nPops information type, pushes result")); |
| 106 |
ihadd(0x0d,N_("Get Freedom Vector\nDecomposes freedom vector, pushes its\ntwo coordinates onto stack as 2.14")); |
| 107 |
ihadd(0x0c,N_("Get Projection Vector\nDecomposes projection vector, pushes its\ntwo coordinates onto stack as 2.14")); |
| 108 |
ihadd(0x52,N_("Greater Than\nPops two values, pushes (0/1) if bottom el > top")); |
| 109 |
ihadd(0x53,N_("Greater Than or EQual\nPops two values, pushes (0/1) if bottom el >= top")); |
| 110 |
ihadd(0x89,N_("Instruction DEFinition\nPops a value which becomes the opcode\nand begins definition of new instruction")); |
| 111 |
ihadd(0x58,N_("IF test\nPops an integer,\nif 0 (false) next instruction is ELSE or EIF\nif non-0 execution continues normally\n(unless there's an ELSE)")); |
| 112 |
ihadd(0x8e,N_("INSTRuction execution ConTRoL\nPops a selector and value\nSets a state variable")); |
| 113 |
ihadd(0x39,N_("Interpolate Point\nPops as many points as specified in loop counter\nInterpolates each point to preserve original status\nwith respect to RP1 and RP2")); |
| 114 |
ihadd(0x0f,N_("moves point to InterSECTion of two lines\nPops start,end start,end points of two lines\nand a point to move. Point is moved to\nintersection")); |
| 115 |
ihaddr(0x30,0x31,N_("Interpolate Untouched Points[a]\n 0=> interpolate in y direction\n 1=> x direction")); |
| 116 |
ihadd(0x1c,N_("JuMP Relative\nPops offset (in bytes) to move the instruction pointer")); |
| 117 |
ihadd(0x79,N_("Jump Relative On False\nPops a boolean and an offset\nChanges instruction pointer by offset bytes\nif boolean is false")); |
| 118 |
ihadd(0x78,N_("Jump Relative On True\nPops a boolean and an offset\nChanges instruction pointer by offset bytes\nif boolean is true")); |
| 119 |
ihadd(0x2a,N_("LOOP and CALL function\nPops a function number & count\nCalls function count times")); |
| 120 |
ihadd(0x50,N_("Less Than\nPops two values, pushes (0/1) if bottom el < top")); |
| 121 |
ihadd(0x51,N_("Less Than or EQual\nPops two values, pushes (0/1) if bottom el <= top")); |
| 122 |
ihadd(0x8b,N_("MAXimum of top two stack entries\nPops two values, pushes the maximum back")); |
| 123 |
ihaddr(0x49,0x4a,N_("Measure Distance[a]\n 0=>distance with current positions\n 1=>distance with original positions\nPops two point numbers, pushes distance between them")); |
| 124 |
ihaddr(0x2e,0x2f,N_("Move Direct Absolute Point[a]\n 0=>do not round\n 1=>round\nPops a point number, touches that point\nand perhaps rounds it to the grid along\nthe projection vector. Sets rp0&rp1 to the point")); |
| 125 |
ihaddr(0xc0,0xdf,N_("Move Direct Relative Point[abcde]\n a=0=>don't set rp0\n a=1=>set rp0 to p\n b=0=>do not keep distance more than minimum\n b=1=>keep distance at least minimum\n c=0 do not round\n c=1 round\n de=0 => grey distance\n de=1 => black distance\n de=2 => white distance\nPops a point moves it so that it maintains\nits original distance to the rp0. Sets\nrp1 to rp0, rp2 to point, sometimes rp0 to point")); |
| 126 |
ihaddr(0x3e,0x3f,N_("Move Indirect Absolute Point[a]\n 0=>do not round, don't use cvt cutin\n 1=>round\nPops a point number & a cvt entry,\ntouches the point and moves it to the coord\nspecified in the cvt (along the projection vector).\nSets rp0&rp1 to the point")); |
| 127 |
ihadd(0x8c,N_("Minimum of top two stack entries\nPops two values, pushes the minimum back")); |
| 128 |
ihadd(0x26,N_("Move INDEXed element to stack\nPops an index & moves stack\nelement[index] to top of stack\n(removing it from where it was)")); |
| 129 |
ihaddr(0xe0,0xff,N_("Move Indirect Relative Point[abcde]\n a=0=>don't set rp0\n a=1=>set rp0 to p\n b=0=>do not keep distance more than minimum\n b=1=>keep distance at least minimum\n c=0 do not round nor use cvt cutin\n c=1 round & use cvt cutin\n de=0 => grey distance\n de=1 => black distance\n de=2 => white distance\nPops a cvt index and a point moves it so that it\nis cvt[index] from rp0. Sets\nrp1 to rp0, rp2 to point, sometimes rp0 to point")); |
| 130 |
ihadd(0x4b,N_("Measure Pixels Per EM\nPushs the pixels per em (for current rasterization)")); |
| 131 |
ihadd(0x4c,N_("Measure Point Size\nPushes the current point size")); |
| 132 |
ihaddr(0x3a,0x3b,N_("Move Stack Indirect Relative Point[a]\n 0=>do not set rp0\n 1=>set rp0 to point\nPops a 26.6 distance and a point\nMoves point so it is distance from rp0")); |
| 133 |
ihadd(0x63,N_("MULtiply\nPops two 26.6 numbers, multiplies them, pushes result")); |
| 134 |
ihadd(0x65,N_("NEGate\nNegates the top of the stack")); |
| 135 |
ihadd(0x55,N_("Not EQual\nPops two values, tests for inequality, pushes result(0/1)")); |
| 136 |
ihadd(0x5c,N_("logical NOT\nPops a number, if 0 pushes 1, else pushes 0")); |
| 137 |
ihadd(0x40,N_("N PUSH Bytes\nReads an (unsigned) count byte from the\ninstruction stream, then reads and pushes\nthat many unsigned bytes")); |
| 138 |
ihadd(0x41,N_("N PUSH Words\nReads an (unsigned) count byte from the\ninstruction stream, then reads and pushes\nthat many signed 2byte words")); |
| 139 |
ihaddr(0x6c,0x6f,N_("No ROUNDing of value[ab]\n ab=0 => grey distance\n ab=1 => black distance\n ab=2 => white distance\nPops a coordinate (26.6), changes it (without\nrounding) to compensate for engine effects\npushes it back")); |
| 140 |
ihadd(0x56,N_("ODD\nPops one value, rounds it and tests if it is odd(0/1)")); |
| 141 |
ihadd(0x5b,N_("logical OR\nPops two values, ors them, pushes result")); |
| 142 |
ihadd(0x21,N_("POP top stack element")); |
| 143 |
ihaddr(0xb0,0xb7,N_("PUSH Byte[abc]\n abc is the number-1 of bytes to push\nReads abc+1 unsigned bytes from\nthe instruction stream and pushes them")); |
| 144 |
ihaddr(0xb8,0xbf,N_("PUSH Word[abc]\n abc is the number-1 of words to push\nReads abc+1 signed words from\nthe instruction stream and pushes them")); |
| 145 |
ihadd(0x45,N_("Read Control Value Table entry\nPops an index to the CVT and\npushes it in 26.6 format")); |
| 146 |
ihadd(0x7d,N_("Round Down To Grid\n\nSets round state to the obvious")); |
| 147 |
ihadd(0x7a,N_("Round OFF\nSets round state so that no rounding occurs\nbut engine compensation does")); |
| 148 |
ihadd(0x8a,N_("ROLL the top three stack elements")); |
| 149 |
ihaddr(0x68,0x6b,N_("ROUND value[ab]\n ab=0 => grey distance\n ab=1 => black distance\n ab=2 => white distance\nRounds a coordinate (26.6) at top of stack\nand compensates for engine effects")); |
| 150 |
ihadd(0x43,N_("Read Store\nPops an index into store array\nPushes value at that index")); |
| 151 |
ihadd(0x3d,N_("Round To Double Grid\nSets the round state (round to closest .5/int)")); |
| 152 |
ihadd(0x18,N_("Round To Grid\nSets the round state")); |
| 153 |
ihadd(0x19,N_("Round To Half Grid\nSets the round state (round to closest .5 not int)")); |
| 154 |
ihadd(0x7c,N_("Round Up To Grid\nSets the round state")); |
| 155 |
ihadd(0x77,N_("Super 45\302\260 ROUND\nToo complicated. Look it up")); |
| 156 |
ihadd(0x7e,N_("Set ANGle Weight\nPops an int, and sets the angle\nweight state variable to it\nObsolete")); |
| 157 |
ihadd(0x85,N_("SCAN conversion ConTRoL\nPops a number which sets the\ndropout control mode")); |
| 158 |
ihadd(0x8d,N_("SCANTYPE\nPops number which sets which scan\nconversion rules to use")); |
| 159 |
ihadd(0x48,N_("Sets Coordinate From Stack using projection & freedom vectors\nPops a coordinate 26.6 and a point\nMoves point to given coordinate")); |
| 160 |
ihadd(0x1d,N_("Sets Control Value Table Cut-In\nPops 26.6 from stack, sets cvt cutin")); |
| 161 |
ihadd(0x5e,N_("Set Delta Base\nPops value sets delta base")); |
| 162 |
ihaddr(0x86,0x87,N_("Set Dual Projection Vector To Line[a]\n 0 => parallel to line\n 1=>orthogonal to line\nPops two points used to establish the line\nSets a second projection vector based on original\npositions of points")); |
| 163 |
ihadd(0x5F,N_("Set Delta Shift\nPops a new value for delta shift")); |
| 164 |
ihadd(0x0b,N_("Set Freedom Vector From Stack\npops 2 2.14 values (x,y) from stack\nmust be a unit vector")); |
| 165 |
ihaddr(0x04,0x05,N_("Set Freedom Vector To Coordinate Axis[a]\n 0=>y axis\n 1=>x axis\n")); |
| 166 |
ihaddr(0x08,0x09,N_("Set Freedom Vector To Line[a]\n 0 => parallel to line\n 1=>orthogonal to line\nPops two points used to establish the line\nSets the freedom vector")); |
| 167 |
ihadd(0x0e,N_("Set Freedom Vector To Projection Vector")); |
| 168 |
ihaddr(0x34,0x35,N_("SHift Contour using reference point[a]\n 0=>uses rp2 in zp1\n 1=>uses rp1 in zp0\nPops number of contour to be shifted\nShifts the entire contour by the amount\nreference point was shifted")); |
| 169 |
ihaddr(0x32,0x33,N_("SHift Point using reference point[a]\n 0=>uses rp2 in zp1\n 1=>uses rp1 in zp0\nPops as many points as specified by the loop count\nShifts each by the amount the reference\npoint was shifted")); |
| 170 |
ihadd(0x38,N_("SHift point by a PIXel amount\nPops an amount (26.6) and as many points\nas the loop counter specifies\neach point is shifted along the FREEDOM vector")); |
| 171 |
ihaddr(0x36,0x37,N_("SHift Zone using reference point[a]\n 0=>uses rp2 in zp1\n 1=>uses rp1 in zp0\nPops the zone to be shifted\nShifts all points in zone by the amount\nthe reference point was shifted")); |
| 172 |
ihadd(0x17,N_("Set LOOP variable\nPops the new value for the loop counter\nDefaults to 1 after each use")); |
| 173 |
ihadd(0x1a,N_("Set Minimum Distance\nPops a 26.6 value from stack to be new minimum distance")); |
| 174 |
ihadd(0x0a,N_("Set Projection Vector From Stack\npops 2 2.14 values (x,y) from stack\nmust be a unit vector")); |
| 175 |
ihaddr(0x02,0x03,N_("Set Projection Vector To Coordinate Axis[a]\n 0=>y axis\n 1=>x axis\n" )); |
| 176 |
ihaddr(0x06,0x07,N_("Set Projection Vector To Line[a]\n 0 => parallel to line\n 1=>orthogonal to line\nPops two points used to establish the line\nSets the projection vector" )); |
| 177 |
ihadd(0x76,N_("Super ROUND\nToo complicated. Look it up")); |
| 178 |
ihadd(0x10,N_("Set Reference Point 0\nPops a point which becomes the new rp0")); |
| 179 |
ihadd(0x11,N_("Set Reference Point 1\nPops a point which becomes the new rp1")); |
| 180 |
ihadd(0x12,N_("Set Reference Point 2\nPops a point which becomes the new rp2")); |
| 181 |
ihadd(0x1f,N_("Set Single Width\nPops value for single width value (FUnit)")); |
| 182 |
ihadd(0x1e,N_("Set Single Width Cut-In\nPops value for single width cut-in value (26.6)")); |
| 183 |
ihadd(0x61,N_("SUBtract\nPops two 26.6 fixed numbers from stack\nsubtracts them, pushes result")); |
| 184 |
ihaddr(0x00,0x01,N_("Set freedom & projection Vectors To Coordinate Axis[a]\n 0=>both to y axis\n 1=>both to x axis\n" )); |
| 185 |
ihadd(0x23,N_("SWAP top two elements on stack")); |
| 186 |
ihadd(0x13,N_("Set Zone Pointer 0\nPops the zone number into zp0")); |
| 187 |
ihadd(0x14,N_("Set Zone Pointer 1\nPops the zone number into zp1")); |
| 188 |
ihadd(0x15,N_("Set Zone Pointer 2\nPops the zone number into zp2")); |
| 189 |
ihadd(0x16,N_("Set Zone PointerS\nPops the zone number into zp0,zp1 and zp2")); |
| 190 |
ihadd(0x29,N_("UnTouch Point\nPops a point number and marks it untouched")); |
| 191 |
ihadd(0x70,N_("Write Control Value Table in Funits\nPops a number(Funits) and a\nCVT index and writes the number to cvt[index]")); |
| 192 |
ihadd(0x44,N_("Write Control Value Table in Pixel units\nPops a number(26.6) and a\nCVT index and writes the number to cvt[index]")); |
| 193 |
ihadd(0x42,N_("Write Store\nPops a value and an index and writes the value to storage[index]")); |
| 194 |
} |
| 195 |
|
| 196 |
typedef struct instrdlg { |
| 197 |
unsigned int inedit: 1; |
| 198 |
struct instrdata *instrdata; |
| 199 |
struct instrinfo instrinfo; |
| 200 |
int oc_height; |
| 201 |
GWindow gw, v; |
| 202 |
GGadget *ok, *cancel, *edit, *parse, *text, *topbox; |
| 203 |
} InstrDlg; |
| 204 |
|
| 205 |
static void instr_info_init(struct instrinfo *instrinfo) { |
| 206 |
|
| 207 |
instrinfo->lheight = instr_typify(instrinfo->instrdata); |
| 208 |
if ( instrinfo->fh!=0 ) { |
| 209 |
if ( instrinfo->lpos > instrinfo->lheight-instrinfo->vheight/instrinfo->fh ) |
| 210 |
instrinfo->lpos = instrinfo->lheight-instrinfo->vheight/instrinfo->fh; |
| 211 |
if ( instrinfo->lpos<0 ) |
| 212 |
instrinfo->lpos = 0; |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
static void instr_resize(InstrDlg *iv,GEvent *event) { |
| 217 |
GRect size; |
| 218 |
int lh; |
| 219 |
struct instrinfo *ii = &iv->instrinfo; |
| 220 |
|
| 221 |
GGadgetGetSize(iv->text,&size); |
| 222 |
GDrawMove(ii->v,size.x,size.y); |
| 223 |
GDrawResize(ii->v,size.width,size.height); |
| 224 |
ii->vheight = size.height; ii->vwidth = size.width; |
| 225 |
lh = ii->lheight; |
| 226 |
|
| 227 |
GScrollBarSetBounds(ii->vsb,0,lh+2,ii->vheight<ii->fh ? 1 : ii->vheight/ii->fh); |
| 228 |
if ( ii->lpos + ii->vheight/ii->fh > lh ) |
| 229 |
ii->lpos = lh-ii->vheight/ii->fh; |
| 230 |
if ( ii->lpos<0 ) ii->lpos = 0; |
| 231 |
GScrollBarSetPos(ii->vsb,ii->lpos); |
| 232 |
GDrawRequestExpose(iv->gw,NULL,false); |
| 233 |
} |
| 234 |
|
| 235 |
static void IVError(void *_iv,char *msg,int offset) { |
| 236 |
InstrDlg *iv = _iv; |
| 237 |
|
| 238 |
if ( iv!=NULL ) { |
| 239 |
GTextFieldSelect(iv->text,offset,offset); |
| 240 |
GTextFieldShow(iv->text,offset); |
| 241 |
GWidgetIndicateFocusGadget(iv->text); |
| 242 |
} |
| 243 |
ff_post_error(_("Parse Error"),msg); |
| 244 |
} |
| 245 |
|
| 246 |
static int IVParse(InstrDlg *iv) { |
| 247 |
char *text = GGadgetGetTitle8(iv->text); |
| 248 |
int icnt=0, i; |
| 249 |
uint8_t *instrs; |
| 250 |
|
| 251 |
instrs = _IVParse(iv->instrdata->sf, text, &icnt, IVError, iv); |
| 252 |
free(text); |
| 253 |
|
| 254 |
if ( instrs==NULL ) |
| 255 |
return( false ); |
| 256 |
if ( icnt!=iv->instrdata->instr_cnt ) |
| 257 |
iv->instrdata->changed = true; |
| 258 |
else { |
| 259 |
for ( i=0; i<icnt; ++i ) |
| 260 |
if ( instrs[i]!=iv->instrdata->instrs[i]) |
| 261 |
break; |
| 262 |
if ( i==icnt ) { |
| 263 |
free(instrs); |
| 264 |
return( true ); |
| 265 |
} |
| 266 |
} |
| 267 |
free( iv->instrdata->instrs ); |
| 268 |
iv->instrdata->instrs = instrs; |
| 269 |
iv->instrdata->instr_cnt = icnt; |
| 270 |
iv->instrdata->max = icnt; |
| 271 |
iv->instrdata->changed = true; |
| 272 |
free(iv->instrdata->bts ); |
| 273 |
iv->instrdata->bts = NULL; |
| 274 |
instr_info_init(&iv->instrinfo); |
| 275 |
GScrollBarSetBounds(iv->instrinfo.vsb,0,iv->instrinfo.lheight+2, |
| 276 |
iv->instrinfo.vheight<iv->instrinfo.fh? 1 : iv->instrinfo.vheight/iv->instrinfo.fh); |
| 277 |
return( true ); |
| 278 |
} |
| 279 |
|
| 280 |
static void IVOk(InstrDlg *iv) { |
| 281 |
struct instrdata *id = iv->instrdata; |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
if ( true ) { |
| 286 |
if ( id->sc!=NULL ) { |
| 287 |
SplineChar *sc = id->sc; |
| 288 |
CharView *cv; |
| 289 |
free(sc->ttf_instrs); |
| 290 |
sc->ttf_instrs_len = id->instr_cnt; |
| 291 |
if ( id->instr_cnt==0 ) |
| 292 |
sc->ttf_instrs = NULL; |
| 293 |
else { |
| 294 |
sc->ttf_instrs = malloc( id->instr_cnt ); |
| 295 |
memcpy(sc->ttf_instrs,id->instrs,id->instr_cnt ); |
| 296 |
} |
| 297 |
for ( cv=(CharView *) (sc->views); cv!=NULL; cv=(CharView *) (cv->b.next) ) |
| 298 |
cv->showpointnumbers = false; |
| 299 |
sc->instructions_out_of_date = true; |
| 300 |
SCCharChangedUpdate(sc,ly_none); |
| 301 |
sc->instructions_out_of_date = false; |
| 302 |
FVRefreshAll(sc->parent); |
| 303 |
} else { |
| 304 |
struct ttf_table *tab, *prev; |
| 305 |
if ( id->instr_cnt==0 ) { |
| 306 |
for ( prev=NULL, tab=id->sf->ttf_tables; tab!=NULL && tab->tag!=id->tag; prev=tab, tab=tab->next ); |
| 307 |
if ( tab==NULL ) |
| 308 |
; |
| 309 |
else if ( prev==NULL ) |
| 310 |
id->sf->ttf_tables = tab->next; |
| 311 |
else |
| 312 |
prev->next = tab->next; |
| 313 |
if ( tab!=NULL ) { |
| 314 |
tab->next = NULL; |
| 315 |
TtfTablesFree(tab); |
| 316 |
} |
| 317 |
} else { |
| 318 |
tab = SFFindTable(id->sf,id->tag); |
| 319 |
if ( tab==NULL ) { |
| 320 |
tab = chunkalloc(sizeof(struct ttf_table)); |
| 321 |
tab->next = id->sf->ttf_tables; |
| 322 |
id->sf->ttf_tables = tab; |
| 323 |
tab->tag = id->tag; |
| 324 |
} |
| 325 |
free( tab->data ); |
| 326 |
tab->data = malloc( id->instr_cnt ); |
| 327 |
memcpy(tab->data,id->instrs,id->instr_cnt ); |
| 328 |
tab->len = id->instr_cnt; |
| 329 |
} |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
} |
| 334 |
|
| 335 |
static void IVBuildEdit(InstrDlg *iv) { |
| 336 |
char *ret; |
| 337 |
ret = __IVUnParseInstrs((InstrBase *) iv); |
| 338 |
if ( iv->text!=NULL ) { |
| 339 |
GGadgetSetTitle8(iv->text,ret); |
| 340 |
GTextFieldSelect(iv->text,iv->instrinfo.offset-ret,iv->instrinfo.offset-ret); |
| 341 |
GTextFieldShow(iv->text,iv->instrinfo.scroll-ret); |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
static void instr_expose(struct instrinfo *ii,GWindow pixmap,GRect *rect) { |
| 346 |
int low, high; |
| 347 |
int i,x,y; |
| 348 |
char loc[12], ins[8], val[8]; unichar_t uins[8], uname[30]; |
| 349 |
int addr_end, num_end; |
| 350 |
static unichar_t nums[] = { '0', '0', '0', '0', '0', '0', '\0' }; |
| 351 |
int indent; |
| 352 |
|
| 353 |
Color warnfg = GDrawGetWarningForeground(NULL); |
| 354 |
|
| 355 |
GDrawSetFont(pixmap,ii->gfont); |
| 356 |
GDrawSetLineWidth(pixmap,0); |
| 357 |
addr_end = 0; |
| 358 |
if ( ii->showaddr ) |
| 359 |
addr_end = GDrawGetTextWidth(pixmap,nums,4)+EDGE_SPACING; |
| 360 |
num_end = addr_end; |
| 361 |
if ( ii->showhex ) |
| 362 |
num_end = addr_end + GDrawGetTextWidth(pixmap,nums,5)+4; |
| 363 |
else if ( addr_end<36+2*EDGE_SPACING ) |
| 364 |
num_end = addr_end = 36+2*EDGE_SPACING; |
| 365 |
|
| 366 |
low = ( (rect->y-EDGE_SPACING)/ii->fh ) * ii->fh +EDGE_SPACING; |
| 367 |
high = ( (rect->y+rect->height+ii->fh-1-EDGE_SPACING)/ii->fh ) * ii->fh +EDGE_SPACING; |
| 368 |
|
| 369 |
if ( ii->isel_pos!=-1 ) { |
| 370 |
GRect r; |
| 371 |
r.x = 0; r.width = ii->vwidth; |
| 372 |
r.y = (ii->isel_pos-ii->lpos)*ii->fh+EDGE_SPACING; r.height = ii->fh; |
| 373 |
GDrawFillRect(pixmap,&r,ACTIVE_BORDER); |
| 374 |
} |
| 375 |
|
| 376 |
if ( ii->showaddr ) |
| 377 |
GDrawDrawLine(pixmap,addr_end,rect->y,addr_end,rect->y+rect->height,MAIN_FOREGROUND); |
| 378 |
if ( ii->showhex ) |
| 379 |
GDrawDrawLine(pixmap,num_end,rect->y,num_end,rect->y+rect->height,MAIN_FOREGROUND); |
| 380 |
|
| 381 |
indent = 0; |
| 382 |
for ( i=0, y=EDGE_SPACING-ii->lpos*ii->fh; y<low && i<ii->instrdata->instr_cnt; ++i ) { |
| 383 |
if ( ii->instrdata->bts[i]==bt_instr ) { |
| 384 |
int instr = ii->instrdata->instrs[i]; |
| 385 |
if ( instr == ttf_if || instr==ttf_idef || instr == ttf_fdef ) |
| 386 |
++indent; |
| 387 |
else if ( instr == ttf_eif || instr==ttf_endf ) |
| 388 |
--indent; |
| 389 |
} else if ( ii->instrdata->bts[i]==bt_wordhi ) |
| 390 |
++i; |
| 391 |
y += ii->fh; |
| 392 |
} |
| 393 |
if ( y<=high && ii->instrdata->instr_cnt==0 && i==0 ) { |
| 394 |
if ( ii->instrdata->in_composit ) { |
| 395 |
GDrawDrawText8(pixmap,num_end+EDGE_SPACING,y+ii->as,_("<instrs inherited>"),-1,warnfg); |
| 396 |
y += ii->fh; |
| 397 |
} |
| 398 |
GDrawDrawText8(pixmap,num_end+EDGE_SPACING,y+ii->as,_("<no instrs>"),-1,warnfg); |
| 399 |
} else { |
| 400 |
int temp_indent; |
| 401 |
for ( ; y<=high && i<ii->instrdata->instr_cnt+1; ++i ) { |
| 402 |
temp_indent = indent; |
| 403 |
sprintf( loc, "%d", i ); |
| 404 |
if ( ii->instrdata->bts[i]==bt_wordhi ) { |
| 405 |
sprintf( ins, " %02x%02x", ii->instrdata->instrs[i], ii->instrdata->instrs[i+1]); uc_strcpy(uins,ins); |
| 406 |
sprintf( val, " %d", (short) ((ii->instrdata->instrs[i]<<8) | ii->instrdata->instrs[i+1]) ); |
| 407 |
uc_strcpy(uname,val); |
| 408 |
++i; |
| 409 |
} else if ( ii->instrdata->bts[i]==bt_cnt || ii->instrdata->bts[i]==bt_byte ) { |
| 410 |
sprintf( ins, " %02x", ii->instrdata->instrs[i] ); uc_strcpy(uins,ins); |
| 411 |
sprintf( val, " %d", ii->instrdata->instrs[i]); |
| 412 |
uc_strcpy(uname,val); |
| 413 |
} else if ( ii->instrdata->bts[i]==bt_impliedreturn ) { |
| 414 |
uc_strcpy(uname,_("<return>")); |
| 415 |
uins[0] = '\0'; |
| 416 |
} else { |
| 417 |
int instr = ii->instrdata->instrs[i]; |
| 418 |
if ( instr == ttf_eif || instr==ttf_endf ) |
| 419 |
--indent; |
| 420 |
temp_indent = indent; |
| 421 |
if ( instr == ttf_else ) |
| 422 |
--temp_indent; |
| 423 |
sprintf( ins, "%02x", instr ); uc_strcpy(uins,ins); |
| 424 |
uc_strcpy(uname, ff_ttf_instrnames[instr]); |
| 425 |
if ( instr == ttf_if || instr==ttf_idef || instr == ttf_fdef ) |
| 426 |
++indent; |
| 427 |
} |
| 428 |
|
| 429 |
if ( ii->showaddr ) { |
| 430 |
GRect size; |
| 431 |
GDrawLayoutInit(pixmap,loc,-1,NULL); |
| 432 |
GDrawLayoutExtents(pixmap,&size); |
| 433 |
x = addr_end - EDGE_SPACING - size.width; |
| 434 |
GDrawLayoutDraw(pixmap,x,y+ii->as,MAIN_FOREGROUND); |
| 435 |
if ( ii->bpcheck && ii->bpcheck(ii,i)) |
| 436 |
GDrawDrawImage(pixmap,&GIcon_Stop,NULL,EDGE_SPACING, |
| 437 |
y+(ii->fh-8)/2-5); |
| 438 |
} |
| 439 |
x = addr_end + EDGE_SPACING; |
| 440 |
if ( ii->showhex ) |
| 441 |
GDrawDrawText(pixmap,x,y+ii->as,uins,-1,MAIN_FOREGROUND); |
| 442 |
GDrawDrawText(pixmap,num_end+EDGE_SPACING+temp_indent*4,y+ii->as,uname,-1,MAIN_FOREGROUND); |
| 443 |
y += ii->fh; |
| 444 |
} |
| 445 |
if ( ii->showaddr && ii->lstopped!=-1 ) { |
| 446 |
GDrawDrawImage(pixmap,&GIcon_Stopped,NULL,EDGE_SPACING, |
| 447 |
(ii->lstopped-ii->lpos)*ii->fh+(ii->fh-8)/2); |
| 448 |
} |
| 449 |
} |
| 450 |
} |
| 451 |
|
| 452 |
static void instr_mousedown(struct instrinfo *ii,int pos) { |
| 453 |
int i,l; |
| 454 |
|
| 455 |
pos = (pos-2)/ii->fh + ii->lpos; |
| 456 |
if ( pos>=ii->lheight ) |
| 457 |
pos = -1; |
| 458 |
|
| 459 |
for ( i=l=0; l<pos && i<ii->instrdata->instr_cnt; ++i, ++l ) { |
| 460 |
if ( ii->instrdata->bts[i]==bt_wordhi ) |
| 461 |
++i; |
| 462 |
} |
| 463 |
|
| 464 |
ii->isel_pos=pos; |
| 465 |
if ( ii->selection_callback!=NULL ) |
| 466 |
(ii->selection_callback)(ii,i); |
| 467 |
GDrawRequestExpose(ii->v,NULL,false); |
| 468 |
} |
| 469 |
|
| 470 |
static void instr_mousemove(struct instrinfo *ii,int pos) { |
| 471 |
int i,y; |
| 472 |
char *msg; |
| 473 |
|
| 474 |
if ( ii->mousedown ) { |
| 475 |
instr_mousedown(ii,pos); |
| 476 |
return; |
| 477 |
} |
| 478 |
if ( ii->instrdata->bts==NULL ) |
| 479 |
return; |
| 480 |
|
| 481 |
pos = ((pos-2)/ii->fh) * ii->fh + 2; |
| 482 |
|
| 483 |
for ( i=0, y=2-ii->lpos*ii->fh; y<pos && i<ii->instrdata->instr_cnt; ++i ) { |
| 484 |
if ( ii->instrdata->bts[i]==bt_wordhi ) |
| 485 |
++i; |
| 486 |
y += ii->fh; |
| 487 |
} |
| 488 |
switch ( ii->instrdata->bts[i] ) { |
| 489 |
case bt_wordhi: case bt_wordlo: |
| 490 |
msg = _("A short to be pushed on the stack"); |
| 491 |
break; |
| 492 |
case bt_cnt: |
| 493 |
msg = _("A count specifying how many bytes/shorts\nshould be pushed on the stack"); |
| 494 |
break; |
| 495 |
case bt_byte: |
| 496 |
msg = _("An unsigned byte to be pushed on the stack"); |
| 497 |
break; |
| 498 |
case bt_instr: |
| 499 |
msg = _(instrhelppopup[ii->instrdata->instrs[i]]); |
| 500 |
if ( msg==NULL ) msg = "???"; |
| 501 |
break; |
| 502 |
default: |
| 503 |
msg = "???"; |
| 504 |
break; |
| 505 |
} |
| 506 |
GGadgetPreparePopup8(GDrawGetParentWindow(ii->v),msg); |
| 507 |
} |
| 508 |
|
| 509 |
void instr_scroll(struct instrinfo *ii,struct sbevent *sb) { |
| 510 |
int newpos = ii->lpos; |
| 511 |
|
| 512 |
switch( sb->type ) { |
| 513 |
case et_sb_top: |
| 514 |
newpos = 0; |
| 515 |
break; |
| 516 |
case et_sb_uppage: |
| 517 |
newpos -= ii->vheight/ii->fh; |
| 518 |
break; |
| 519 |
case et_sb_up: |
| 520 |
--newpos; |
| 521 |
break; |
| 522 |
case et_sb_down: |
| 523 |
++newpos; |
| 524 |
break; |
| 525 |
case et_sb_downpage: |
| 526 |
newpos += ii->vheight/ii->fh; |
| 527 |
break; |
| 528 |
case et_sb_bottom: |
| 529 |
newpos = ii->lheight-ii->vheight/ii->fh; |
| 530 |
break; |
| 531 |
case et_sb_thumb: |
| 532 |
case et_sb_thumbrelease: |
| 533 |
newpos = sb->pos; |
| 534 |
break; |
| 535 |
case et_sb_halfup: case et_sb_halfdown: break; |
| 536 |
} |
| 537 |
if ( newpos>ii->lheight+1-ii->vheight/ii->fh ) |
| 538 |
newpos = ii->lheight+1-ii->vheight/ii->fh; |
| 539 |
if ( newpos<0 ) newpos =0; |
| 540 |
if ( newpos!=ii->lpos ) { |
| 541 |
GRect r; |
| 542 |
int diff = newpos-ii->lpos; |
| 543 |
ii->lpos = newpos; |
| 544 |
GScrollBarSetPos(ii->vsb,ii->lpos); |
| 545 |
r.x=0; r.y = EDGE_SPACING; r.width=ii->vwidth; r.height=ii->vheight-2*EDGE_SPACING; |
| 546 |
GDrawScroll(ii->v,&r,0,diff*ii->fh); |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
static int IIChar(struct instrinfo *ii,GEvent *event) { |
| 551 |
int pos = ii->isel_pos; |
| 552 |
|
| 553 |
if ( ii->handle_char ) |
| 554 |
return( (ii->handle_char)(ii,event)); |
| 555 |
|
| 556 |
if ( event->u.chr.keysym == GK_Up || event->u.chr.keysym == GK_KP_Up ) |
| 557 |
--pos; |
| 558 |
else if ( event->u.chr.keysym == GK_Down || event->u.chr.keysym == GK_KP_Down ) |
| 559 |
++pos; |
| 560 |
else if ( event->u.chr.keysym == GK_Home || event->u.chr.keysym == GK_KP_Home || |
| 561 |
event->u.chr.keysym == GK_Begin || event->u.chr.keysym == GK_KP_Begin ) |
| 562 |
pos = 0; |
| 563 |
else if ( event->u.chr.keysym == GK_End || event->u.chr.keysym == GK_KP_End ) { |
| 564 |
pos = ii->lheight-1; |
| 565 |
} else |
| 566 |
return( false ); |
| 567 |
if ( pos==-2 ) pos = -1; |
| 568 |
if ( pos!=ii->isel_pos ) { |
| 569 |
ii->isel_pos = pos; |
| 570 |
if ( pos!=-1 && (pos<ii->lpos || pos>=ii->lpos+ii->vheight/ii->fh )) { |
| 571 |
ii->lpos = pos-(ii->vheight/(3*ii->fh)); |
| 572 |
if ( ii->lpos>=ii->lheight-ii->vheight/ii->fh ) |
| 573 |
ii->lpos = ii->lheight-ii->vheight/ii->fh-1; |
| 574 |
if ( ii->lpos<0 ) ii->lpos = 0; |
| 575 |
GScrollBarSetPos(ii->vsb,ii->lpos); |
| 576 |
} |
| 577 |
} |
| 578 |
if ( ii->selection_callback!=NULL ) { |
| 579 |
int i,l; |
| 580 |
for ( i=l=0; l<pos && i<ii->instrdata->instr_cnt; ++i, ++l ) { |
| 581 |
if ( ii->instrdata->bts[i]==bt_wordhi ) |
| 582 |
++i; |
| 583 |
} |
| 584 |
(ii->selection_callback)(ii,i); |
| 585 |
} |
| 586 |
GDrawRequestExpose(ii->v,NULL,false); |
| 587 |
return( true ); |
| 588 |
} |
| 589 |
|
| 590 |
int ii_v_e_h(GWindow gw, GEvent *event) { |
| 591 |
struct instrinfo *ii = (struct instrinfo *) GDrawGetUserData(gw); |
| 592 |
|
| 593 |
switch ( event->type ) { |
| 594 |
case et_expose: |
| 595 |
instr_expose(ii,gw,&event->u.expose.rect); |
| 596 |
break; |
| 597 |
case et_char: |
| 598 |
if ( IIChar(ii,event)) { |
| 599 |
|
| 600 |
; |
| 601 |
} else if ( event->u.chr.keysym == GK_Help || event->u.chr.keysym == GK_F1 ) { |
| 602 |
help("ui/dialogs/ttfinstrs.html", NULL); |
| 603 |
} |
| 604 |
break; |
| 605 |
case et_mousemove: case et_mousedown: case et_mouseup: |
| 606 |
GGadgetEndPopup(); |
| 607 |
if ( event->type==et_mousemove ) { |
| 608 |
instr_mousemove(ii,event->u.mouse.y); |
| 609 |
} else if ( event->type==et_mousedown ) { |
| 610 |
instr_mousedown(ii,event->u.mouse.y); |
| 611 |
if ( event->u.mouse.clicks==2 ) { |
| 612 |
|
| 613 |
; |
| 614 |
} |
| 615 |
} else { |
| 616 |
instr_mousemove(ii,event->u.mouse.y); |
| 617 |
ii->mousedown = false; |
| 618 |
} |
| 619 |
break; |
| 620 |
case et_timer: |
| 621 |
break; |
| 622 |
case et_focus: |
| 623 |
break; |
| 624 |
default: break; |
| 625 |
} |
| 626 |
return( true ); |
| 627 |
} |
| 628 |
|
| 629 |
static int iv_e_h(GWindow gw, GEvent *event) { |
| 630 |
InstrDlg *iv = (InstrDlg *) GDrawGetUserData(gw); |
| 631 |
|
| 632 |
switch ( event->type ) { |
| 633 |
case et_expose: |
| 634 |
break; |
| 635 |
case et_resize: |
| 636 |
instr_resize(iv,event); |
| 637 |
break; |
| 638 |
case et_char: |
| 639 |
if ( event->u.chr.keysym == GK_Help || event->u.chr.keysym == GK_F1 ) |
| 640 |
help("ui/dialogs/ttfinstrs.html", NULL); |
| 641 |
break; |
| 642 |
case et_controlevent: |
| 643 |
switch ( event->u.control.subtype ) { |
| 644 |
case et_scrollbarchange: |
| 645 |
instr_scroll(&iv->instrinfo,&event->u.control.u.sb); |
| 646 |
break; |
| 647 |
case et_buttonactivate: |
| 648 |
if ( event->u.control.g==iv->ok || event->u.control.g==iv->cancel ) { |
| 649 |
if ( event->u.control.g == iv->ok ) { |
| 650 |
if ( iv->inedit ) |
| 651 |
if ( !IVParse(iv)) |
| 652 |
break; |
| 653 |
IVOk(iv); |
| 654 |
} |
| 655 |
GDrawDestroyWindow(iv->gw); |
| 656 |
} else if ( event->u.control.g==iv->edit || event->u.control.g==iv->parse ) { |
| 657 |
int toedit = event->u.control.g==iv->edit; |
| 658 |
GRect size; |
| 659 |
if ( toedit ) { |
| 660 |
IVBuildEdit(iv); |
| 661 |
GGadgetGetSize(iv->instrinfo.vsb,&size); |
| 662 |
size.width = -1; |
| 663 |
GGadgetSetDesiredSize(iv->text,&size,NULL); |
| 664 |
} else if ( !IVParse(iv)) |
| 665 |
break; |
| 666 |
GGadgetSetVisible(iv->parse,toedit); |
| 667 |
|
| 668 |
GGadgetSetVisible(iv->edit,!toedit); |
| 669 |
GGadgetSetVisible(iv->instrinfo.vsb,!toedit); |
| 670 |
GDrawSetVisible(iv->instrinfo.v,!toedit); |
| 671 |
GHVBoxFitWindow(iv->topbox); |
| 672 |
iv->inedit = toedit; |
| 673 |
} |
| 674 |
break; |
| 675 |
default: break; |
| 676 |
} |
| 677 |
break; |
| 678 |
case et_close: |
| 679 |
GDrawDestroyWindow(iv->gw); |
| 680 |
break; |
| 681 |
case et_destroy: { |
| 682 |
SplineFont *sf = iv->instrdata->sf; |
| 683 |
struct instrdata *id, *prev; |
| 684 |
for ( prev = NULL, id=sf->instr_dlgs; id!=iv->instrdata && id!=NULL; prev=id, id=id->next ); |
| 685 |
if ( prev==NULL ) |
| 686 |
sf->instr_dlgs = iv->instrdata->next; |
| 687 |
else |
| 688 |
prev->next = iv->instrdata->next; |
| 689 |
free(iv->instrdata->instrs); |
| 690 |
free(iv->instrdata->bts); |
| 691 |
free(iv->instrdata); |
| 692 |
free(iv); |
| 693 |
} break; |
| 694 |
default: break; |
| 695 |
} |
| 696 |
return( true ); |
| 697 |
} |
| 698 |
|
| 699 |
static void InstrDlgCreate(struct instrdata *id,char *title) { |
| 700 |
InstrDlg *iv = calloc(1,sizeof(*iv)); |
| 701 |
GRect pos; |
| 702 |
GWindow gw; |
| 703 |
GWindowAttrs wattrs; |
| 704 |
int as,ds,ld, lh; |
| 705 |
GGadgetCreateData gcd[11], *butarray[9], *harray[3], *varray[8]; |
| 706 |
GTextInfo label[6]; |
| 707 |
|
| 708 |
instrhelpsetup(); |
| 709 |
|
| 710 |
id->next = id->sf->instr_dlgs; |
| 711 |
id->sf->instr_dlgs = id; |
| 712 |
id->id = iv; |
| 713 |
|
| 714 |
iv->instrdata = id; |
| 715 |
iv->instrinfo.instrdata = id; |
| 716 |
iv->instrinfo.showhex = iv->instrinfo.showaddr = true; |
| 717 |
iv->instrinfo.lstopped = -1; |
| 718 |
instr_info_init(&iv->instrinfo); |
| 719 |
|
| 720 |
if ( ttf_icon==NULL ) |
| 721 |
ttf_icon = GDrawCreateBitmap(NULL,ttf_width,ttf_height,ttf_bits); |
| 722 |
|
| 723 |
memset(&wattrs,0,sizeof(wattrs)); |
| 724 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_icon; |
| 725 |
wattrs.event_masks = ~(1<<et_charup); |
| 726 |
wattrs.restrict_input_to_me = 1; |
| 727 |
wattrs.undercursor = 1; |
| 728 |
wattrs.cursor = ct_pointer; |
| 729 |
wattrs.utf8_window_title = title; |
| 730 |
wattrs.icon = ttf_icon; |
| 731 |
pos.x = pos.y = 0; |
| 732 |
if ( GIntGetResource(_NUM_Buttonsize)>65 ) |
| 733 |
pos.width = GDrawPointsToPixels(NULL,3*GIntGetResource(_NUM_Buttonsize)+40); |
| 734 |
else |
| 735 |
pos.width = GDrawPointsToPixels(NULL,250); |
| 736 |
iv->oc_height = GDrawPointsToPixels(NULL,37); |
| 737 |
pos.height = GDrawPointsToPixels(NULL,100) + iv->oc_height; |
| 738 |
iv->gw = gw = GDrawCreateTopWindow(NULL,&pos,iv_e_h,iv,&wattrs); |
| 739 |
|
| 740 |
memset(&label,0,sizeof(label)); |
| 741 |
memset(&gcd,0,sizeof(gcd)); |
| 742 |
gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 105; |
| 743 |
gcd[0].gd.pos.width = -1; |
| 744 |
label[0].text = (unichar_t *) _("_OK"); |
| 745 |
label[0].text_is_1byte = true; |
| 746 |
label[0].text_in_resource = true; |
| 747 |
gcd[0].gd.label = &label[0]; |
| 748 |
gcd[0].gd.flags = gg_visible|gg_enabled|gg_but_default; |
| 749 |
gcd[0].creator = GButtonCreate; |
| 750 |
gcd[0].data = iv; |
| 751 |
|
| 752 |
gcd[1].gd.pos.x = -8; gcd[1].gd.pos.y = 3; |
| 753 |
gcd[1].gd.pos.width = -1; |
| 754 |
label[1].text = (unichar_t *) _("_Cancel"); |
| 755 |
label[1].text_is_1byte = true; |
| 756 |
label[1].text_in_resource = true; |
| 757 |
gcd[1].gd.label = &label[1]; |
| 758 |
gcd[1].gd.flags = gg_visible|gg_enabled|gg_but_cancel; |
| 759 |
gcd[1].creator = GButtonCreate; |
| 760 |
gcd[1].data = iv; |
| 761 |
|
| 762 |
gcd[2] = gcd[1]; |
| 763 |
label[2].text = (unichar_t *) _("_Edit"); |
| 764 |
label[2].text_is_1byte = true; |
| 765 |
label[2].text_in_resource = true; |
| 766 |
gcd[2].gd.flags = gg_visible|gg_enabled; |
| 767 |
gcd[2].gd.label = &label[2]; |
| 768 |
gcd[2].creator = GButtonCreate; |
| 769 |
gcd[2].data = iv; |
| 770 |
|
| 771 |
gcd[3] = gcd[1]; |
| 772 |
label[3] = label[2]; |
| 773 |
label[3].text = (unichar_t *) _("_Parse"); |
| 774 |
gcd[3].gd.flags = gg_enabled; |
| 775 |
gcd[3].gd.label = &label[3]; |
| 776 |
gcd[3].creator = GButtonCreate; |
| 777 |
gcd[3].data = iv; |
| 778 |
|
| 779 |
butarray[0] = GCD_Glue; butarray[1] = &gcd[0]; |
| 780 |
butarray[2] = GCD_Glue; butarray[3] = &gcd[2]; |
| 781 |
butarray[4] = &gcd[3]; butarray[5] = GCD_Glue; |
| 782 |
butarray[6] = &gcd[1]; butarray[7] = GCD_Glue; |
| 783 |
butarray[8] = NULL; |
| 784 |
gcd[4].gd.flags = gg_enabled|gg_visible; |
| 785 |
gcd[4].gd.u.boxelements = butarray; |
| 786 |
gcd[4].creator = GHBoxCreate; |
| 787 |
|
| 788 |
gcd[5].gd.pos.x = 0; gcd[5].gd.pos.y = 0; |
| 789 |
gcd[5].gd.pos.width = pos.width; gcd[5].gd.pos.height = pos.height-GDrawPointsToPixels(NULL,40); |
| 790 |
gcd[5].gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_textarea_wrap|gg_pos_use0; |
| 791 |
gcd[5].creator = GTextAreaCreate; |
| 792 |
gcd[5].data = iv; |
| 793 |
harray[0] = &gcd[5]; |
| 794 |
|
| 795 |
gcd[6].gd.pos.y = 0; gcd[6].gd.pos.height = pos.height-GDrawPointsToPixels(NULL,40); |
| 796 |
gcd[6].gd.pos.width = GDrawPointsToPixels(gw,_GScrollBar_Width); |
| 797 |
gcd[6].gd.pos.x = pos.width-gcd[6].gd.pos.width; |
| 798 |
gcd[6].gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_sb_vert; |
| 799 |
gcd[6].creator = GScrollBarCreate; |
| 800 |
gcd[6].data = iv; |
| 801 |
harray[1] = &gcd[6]; harray[2] = NULL; |
| 802 |
|
| 803 |
gcd[7].gd.flags = gg_enabled|gg_visible; |
| 804 |
gcd[7].gd.u.boxelements = harray; |
| 805 |
gcd[7].creator = GHBoxCreate; |
| 806 |
|
| 807 |
varray[0] = &gcd[7]; varray[1] = NULL; |
| 808 |
varray[2] = &gcd[8]; varray[3] = NULL; |
| 809 |
varray[4] = &gcd[4]; varray[5] = NULL; |
| 810 |
varray[6] = NULL; |
| 811 |
|
| 812 |
gcd[8].gd.flags = gg_enabled|gg_visible; |
| 813 |
gcd[8].gd.pos.width = 100; |
| 814 |
gcd[8].creator = GLineCreate; |
| 815 |
|
| 816 |
gcd[9].gd.pos.x = gcd[9].gd.pos.y = 2; |
| 817 |
gcd[9].gd.flags = gg_enabled|gg_visible; |
| 818 |
gcd[9].gd.u.boxelements = varray; |
| 819 |
gcd[9].creator = GHVGroupCreate; |
| 820 |
|
| 821 |
GGadgetsCreate(gw,&gcd[9]); |
| 822 |
GHVBoxSetExpandableRow(gcd[9].ret,0); |
| 823 |
GHVBoxSetExpandableCol(gcd[7].ret,0); |
| 824 |
GHVBoxSetExpandableCol(gcd[4].ret,gb_expandgluesame); |
| 825 |
|
| 826 |
iv->ok = gcd[0].ret; |
| 827 |
iv->cancel = gcd[1].ret; |
| 828 |
iv->edit = gcd[2].ret; |
| 829 |
iv->parse = gcd[3].ret; |
| 830 |
iv->text = gcd[5].ret; |
| 831 |
iv->instrinfo.vsb = gcd[6].ret; |
| 832 |
iv->topbox = gcd[9].ret; |
| 833 |
|
| 834 |
wattrs.mask = wam_events|wam_cursor; |
| 835 |
pos = gcd[5].gd.pos; |
| 836 |
iv->instrinfo.v = GWidgetCreateSubWindow(gw,&pos,ii_v_e_h,&iv->instrinfo,&wattrs); |
| 837 |
GDrawSetVisible(iv->instrinfo.v,true); |
| 838 |
|
| 839 |
iv->instrinfo.gfont = ttinstruction_font.fi; |
| 840 |
GDrawSetFont(iv->instrinfo.v,iv->instrinfo.gfont); |
| 841 |
GGadgetSetFont(iv->text,iv->instrinfo.gfont); |
| 842 |
GDrawWindowFontMetrics(iv->instrinfo.v,iv->instrinfo.gfont,&as,&ds,&ld); |
| 843 |
iv->instrinfo.as = as+1; |
| 844 |
iv->instrinfo.fh = iv->instrinfo.as+ds; |
| 845 |
iv->instrinfo.isel_pos = -1; |
| 846 |
|
| 847 |
lh = iv->instrinfo.lheight; |
| 848 |
if ( lh>40 ) lh = 40; |
| 849 |
if ( lh<4 ) lh = 4; |
| 850 |
GDrawResize(iv->gw,pos.width+gcd[6].gd.pos.width,iv->oc_height+lh*iv->instrinfo.fh+4); |
| 851 |
|
| 852 |
GDrawSetVisible(gw,true); |
| 853 |
} |
| 854 |
|
| 855 |
void SCEditInstructions(SplineChar *sc) { |
| 856 |
struct instrdata *id; |
| 857 |
char title[100]; |
| 858 |
CharView *cv; |
| 859 |
RefChar *ref; |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
if ( sc->parent->mm!=NULL && sc->parent->mm->apple ) |
| 865 |
sc = sc->parent->mm->normal->glyphs[sc->orig_pos]; |
| 866 |
|
| 867 |
for ( id = sc->parent->instr_dlgs; id!=NULL && id->sc!=sc; id=id->next ); |
| 868 |
if ( id!=NULL ) { |
| 869 |
GDrawSetVisible(id->id->gw,true); |
| 870 |
GDrawRaise(id->id->gw); |
| 871 |
return; |
| 872 |
} |
| 873 |
|
| 874 |
if ( sc->layers[ly_fore].refs!=NULL && sc->layers[ly_fore].splines!=NULL ) { |
| 875 |
ff_post_error(_("Can't instruct this glyph"), |
| 876 |
_("TrueType does not support mixed references and contours.\nIf you want instructions for %.30s you should either:\n * Unlink the reference(s)\n * Copy the inline contours into their own (unencoded\n glyph) and make a reference to that."), |
| 877 |
sc->name ); |
| 878 |
return; |
| 879 |
} |
| 880 |
for ( ref = sc->layers[ly_fore].refs; ref!=NULL; ref=ref->next ) { |
| 881 |
if ( ref->transform[0]>=2 || ref->transform[0]<-2 || |
| 882 |
ref->transform[1]>=2 || ref->transform[1]<-2 || |
| 883 |
ref->transform[2]>=2 || ref->transform[2]<-2 || |
| 884 |
ref->transform[3]>=2 || ref->transform[3]<-2 ) |
| 885 |
break; |
| 886 |
} |
| 887 |
if ( ref!=NULL ) { |
| 888 |
ff_post_error(_("Can't instruct this glyph"), |
| 889 |
_("TrueType does not support references which\nare scaled by more than 200%%. But %1$.30s\nhas been in %2$.30s. Any instructions\nadded would be meaningless."), |
| 890 |
ref->sc->name, sc->name ); |
| 891 |
return; |
| 892 |
} |
| 893 |
|
| 894 |
for ( cv=(CharView *) (sc->views); cv!=NULL; cv=(CharView *) (cv->b.next) ) { |
| 895 |
sc = cv->b.sc; |
| 896 |
cv->showpointnumbers = true; |
| 897 |
SCNumberPoints(sc,CVLayer((CharViewBase *) cv)); |
| 898 |
GDrawRequestExpose(cv->v,NULL,false); |
| 899 |
} |
| 900 |
id = calloc(1,sizeof(*id)); |
| 901 |
id->instr_cnt = id->max = sc->ttf_instrs_len; |
| 902 |
id->sf = sc->parent; |
| 903 |
id->sc = sc; |
| 904 |
id->instrs = malloc(id->max+1); |
| 905 |
if ( sc->ttf_instrs!=NULL ) |
| 906 |
memcpy(id->instrs,sc->ttf_instrs,id->instr_cnt); |
| 907 |
sprintf(title,_("TrueType Instructions for %.50s"),sc->name); |
| 908 |
InstrDlgCreate(id,title); |
| 909 |
} |
| 910 |
|
| 911 |
void SC_MarkInstrDlgAsChanged(SplineChar *sc) { |
| 912 |
struct instrdata *id; |
| 913 |
|
| 914 |
for ( id = sc->parent->instr_dlgs; id!=NULL && id->sc!=sc; id=id->next ); |
| 915 |
if ( id!=NULL ) |
| 916 |
id->changed = true; |
| 917 |
} |
| 918 |
|
| 919 |
void IIScrollTo(struct instrinfo *ii,int ip,int mark_stop) { |
| 920 |
int l, i; |
| 921 |
|
| 922 |
for ( i=l=0; i<ip && i<ii->instrdata->instr_cnt; ++i, ++l ) { |
| 923 |
if ( ii->instrdata->bts[i]==bt_wordhi || ii->instrdata->bts[i]==bt_wordlo ) |
| 924 |
++i; |
| 925 |
} |
| 926 |
if ( ip==-1 ) |
| 927 |
ii->lstopped = -1; |
| 928 |
else { |
| 929 |
if ( mark_stop ) |
| 930 |
ii->lstopped = l; |
| 931 |
if ( l<ii->lpos || l>=ii->lpos+ii->vheight/ii->fh-1 ) { |
| 932 |
if ( l+ii->vheight/ii->fh-1 >= ii->lheight+1 ) |
| 933 |
l = ii->lheight+2-(ii->vheight/ii->fh); |
| 934 |
if ( l<0 ) |
| 935 |
l = 0; |
| 936 |
ii->lpos = l; |
| 937 |
GScrollBarSetPos(ii->vsb,l); |
| 938 |
} |
| 939 |
} |
| 940 |
GDrawRequestExpose(ii->v,NULL,false); |
| 941 |
} |
| 942 |
|
| 943 |
void IIReinit(struct instrinfo *ii,int ip) { |
| 944 |
instrhelpsetup(); |
| 945 |
free(ii->instrdata->bts); |
| 946 |
ii->instrdata->bts = NULL; |
| 947 |
instr_info_init(ii); |
| 948 |
GScrollBarSetBounds(ii->vsb,0,ii->lheight+2, ii->vheight<ii->fh ? 1 : ii->vheight/ii->fh); |
| 949 |
IIScrollTo(ii,ip,true); |
| 950 |
} |
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
#define ADDR_SPACER 4 |
| 957 |
#define EDGE_SPACER 2 |
| 958 |
|
| 959 |
typedef struct shortview { |
| 960 |
struct ttf_table *table; |
| 961 |
GWindow gw, v; |
| 962 |
SplineFont *sf; |
| 963 |
unsigned int destroyed: 1; |
| 964 |
unsigned int changed: 1; |
| 965 |
GGadget *vsb, *tf; |
| 966 |
GGadget *ok, *cancel, *setsize; |
| 967 |
int lpos, lheight; |
| 968 |
int16_t as, fh; |
| 969 |
int16_t vheight, vwidth; |
| 970 |
int16_t sbw, bh; |
| 971 |
GFont *gfont; |
| 972 |
int16_t chrlen, addrend, valend; |
| 973 |
int16_t active; |
| 974 |
int16_t which; |
| 975 |
int16_t *edits; |
| 976 |
char **comments; |
| 977 |
uint8_t *data; |
| 978 |
int32_t len; |
| 979 |
uint32_t tag; |
| 980 |
} ShortView; |
| 981 |
|
| 982 |
static int sfinishup(ShortView *sv,int showerr) { |
| 983 |
const unichar_t *ret = _GGadgetGetTitle(sv->tf); |
| 984 |
unichar_t *end; |
| 985 |
int val, oldval; |
| 986 |
|
| 987 |
if ( sv->active==-1 ) |
| 988 |
return( true ); |
| 989 |
|
| 990 |
if ( sv->which ) { |
| 991 |
if ( *ret=='\0' ) { |
| 992 |
if ( sv->comments[sv->active]!=NULL ) { |
| 993 |
free(sv->comments[sv->active]); |
| 994 |
sv->comments[sv->active] = NULL; |
| 995 |
sv->changed = true; |
| 996 |
} |
| 997 |
} else { |
| 998 |
char *new = GGadgetGetTitle8(sv->tf); |
| 999 |
if ( sv->comments[sv->active]==NULL ) { |
| 1000 |
sv->changed = true; |
| 1001 |
} else { |
| 1002 |
if ( strcmp(sv->comments[sv->active],new)!=0 ) |
| 1003 |
sv->changed = true; |
| 1004 |
free(sv->comments[sv->active]); |
| 1005 |
} |
| 1006 |
sv->comments[sv->active] = new; |
| 1007 |
} |
| 1008 |
} else { |
| 1009 |
val = u_strtol(ret,&end,10); |
| 1010 |
if ( *ret=='\0' || *end!='\0' || val<-32768 || val>32767 ) { |
| 1011 |
if ( showerr ) |
| 1012 |
ff_post_error(_("Bad Number"),_("Bad Number")); |
| 1013 |
return( false ); |
| 1014 |
} |
| 1015 |
oldval = sv->edits[sv->active]; |
| 1016 |
if ( val != oldval ) { |
| 1017 |
sv->changed = true; |
| 1018 |
sv->edits[sv->active] = val; |
| 1019 |
} |
| 1020 |
} |
| 1021 |
sv->active = -1; |
| 1022 |
GGadgetMove(sv->tf,sv->addrend,-100); |
| 1023 |
return( true ); |
| 1024 |
} |
| 1025 |
|
| 1026 |
static void SV_SetScrollBar(ShortView *sv) { |
| 1027 |
int lh; |
| 1028 |
sv->lheight = lh = sv->len/2; |
| 1029 |
|
| 1030 |
GScrollBarSetBounds(sv->vsb,0,lh,sv->vheight<sv->fh ? 1 : sv->vheight/sv->fh); |
| 1031 |
if ( sv->lpos + sv->vheight/sv->fh > lh ) { |
| 1032 |
int lpos = lh-sv->vheight/sv->fh; |
| 1033 |
if ( lpos<0 ) lpos = 0; |
| 1034 |
if ( sv->lpos!=lpos && sv->active!=-1 ) |
| 1035 |
GGadgetMove(sv->tf,sv->addrend,(sv->active-lpos)*sv->fh); |
| 1036 |
sv->lpos = lpos; |
| 1037 |
} |
| 1038 |
GScrollBarSetPos(sv->vsb,sv->lpos); |
| 1039 |
} |
| 1040 |
|
| 1041 |
static int SV_ChangeLength(GGadget *g, GEvent *e) { |
| 1042 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 1043 |
ShortView *sv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1044 |
char buffer[12]; |
| 1045 |
char *ret, *e; |
| 1046 |
int val,i; |
| 1047 |
|
| 1048 |
sprintf( buffer, "%d", (int) (sv->len/2) ); |
| 1049 |
ret = gwwv_ask_string(_("Change Length"), buffer,_("How many entries should there be in the cvt table?")); |
| 1050 |
if ( ret==NULL ) |
| 1051 |
return( true ); |
| 1052 |
val = strtol(ret,&e,10); |
| 1053 |
if ( *e || val<0 || val>65535 ) { |
| 1054 |
free(ret); |
| 1055 |
ff_post_error(_("Bad Number"),_("Bad Number")); |
| 1056 |
return( false ); |
| 1057 |
} |
| 1058 |
free(ret); |
| 1059 |
if ( val*2>sv->len ) { |
| 1060 |
sv->edits = realloc(sv->edits,val*2); |
| 1061 |
for ( i=sv->len/2; i<val; ++i ) |
| 1062 |
sv->edits[i] = 0; |
| 1063 |
sv->comments = realloc(sv->comments,val*sizeof(char *)); |
| 1064 |
for ( i=sv->len/2; i<val; ++i ) |
| 1065 |
sv->comments[i] = NULL; |
| 1066 |
} else { |
| 1067 |
for ( i=val; i<sv->len/2; ++i ) { |
| 1068 |
free(sv->comments[i]); |
| 1069 |
sv->comments[i] = NULL; |
| 1070 |
} |
| 1071 |
} |
| 1072 |
sv->len = 2*val; |
| 1073 |
SV_SetScrollBar(sv); |
| 1074 |
GDrawRequestExpose(sv->v,NULL,true); |
| 1075 |
} |
| 1076 |
return( true ); |
| 1077 |
} |
| 1078 |
|
| 1079 |
static void _SV_DoClose(ShortView *sv) { |
| 1080 |
|
| 1081 |
sv->destroyed = true; |
| 1082 |
GDrawDestroyWindow(sv->gw); |
| 1083 |
} |
| 1084 |
|
| 1085 |
static int SV_Cancel(GGadget *g, GEvent *e) { |
| 1086 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 1087 |
ShortView *sv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1088 |
|
| 1089 |
_SV_DoClose(sv); |
| 1090 |
} |
| 1091 |
return( true ); |
| 1092 |
} |
| 1093 |
|
| 1094 |
static int SV_OK(GGadget *g, GEvent *e) { |
| 1095 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 1096 |
ShortView *sv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1097 |
int i; |
| 1098 |
struct ttf_table *prev, *tab; |
| 1099 |
SplineFont *sf = sv->sf; |
| 1100 |
|
| 1101 |
if ( !sfinishup(sv,true) ) |
| 1102 |
return( true ); |
| 1103 |
if ( sf->cvt_names!=NULL ) { |
| 1104 |
for ( i=0; sf->cvt_names[i]!=END_CVT_NAMES; ++i ) |
| 1105 |
free(sf->cvt_names[i]); |
| 1106 |
free(sf->cvt_names); |
| 1107 |
sf->cvt_names = NULL; |
| 1108 |
} |
| 1109 |
if ( sv->len==0 ) { |
| 1110 |
if ( sv->table!=NULL ) { |
| 1111 |
prev = NULL; |
| 1112 |
for ( tab=sf->ttf_tables; tab!=NULL && tab!=sv->table; prev=tab, tab=tab->next ); |
| 1113 |
if ( prev!=NULL ) |
| 1114 |
prev->next = tab->next; |
| 1115 |
else |
| 1116 |
sf->ttf_tables = tab->next; |
| 1117 |
free(sv->table->data); |
| 1118 |
chunkfree(sv->table,sizeof(struct ttf_table)); |
| 1119 |
sv->table = NULL; |
| 1120 |
} |
| 1121 |
} else { |
| 1122 |
if ( sv->table!=NULL ) |
| 1123 |
free(sv->table->data); |
| 1124 |
else { |
| 1125 |
tab = chunkalloc(sizeof(struct ttf_table)); |
| 1126 |
tab->next = sf->ttf_tables; |
| 1127 |
sf->ttf_tables = tab; |
| 1128 |
tab->tag = sv->tag; |
| 1129 |
sv->table = tab; |
| 1130 |
} |
| 1131 |
sv->table->data = malloc(sv->len); |
| 1132 |
sf->cvt_names = malloc(((sv->len>>1)+1)*sizeof(char *)); |
| 1133 |
for ( i=0; i<sv->len/2; ++i ) { |
| 1134 |
sv->table->data[i<<1] = (sv->edits[i]>>8)&0xff; |
| 1135 |
sv->table->data[(i<<1)+1] = sv->edits[i]&0xff; |
| 1136 |
sf->cvt_names[i] = sv->comments[i]; |
| 1137 |
sv->comments[i] = NULL; |
| 1138 |
} |
| 1139 |
sf->cvt_names[i] = END_CVT_NAMES; |
| 1140 |
sv->table->len = sv->len; |
| 1141 |
} |
| 1142 |
sf->changed = true; |
| 1143 |
_SV_DoClose(sv); |
| 1144 |
} |
| 1145 |
return( true ); |
| 1146 |
} |
| 1147 |
|
| 1148 |
static void short_resize(ShortView *sv,GEvent *event) { |
| 1149 |
GRect pos, gsize; |
| 1150 |
int width; |
| 1151 |
|
| 1152 |
|
| 1153 |
if ( (event->u.resize.size.height-2*EDGE_SPACER-sv->bh)%sv->fh!=0 || |
| 1154 |
(event->u.resize.size.height-2*EDGE_SPACER-sv->fh-sv->bh)<0 ) { |
| 1155 |
int lc = (event->u.resize.size.height+sv->fh/2-EDGE_SPACER)/sv->fh; |
| 1156 |
if ( lc<=0 ) lc = 1; |
| 1157 |
GDrawResize(sv->gw, event->u.resize.size.width, |
| 1158 |
lc*sv->fh+2*EDGE_SPACER+sv->bh); |
| 1159 |
return; |
| 1160 |
} |
| 1161 |
|
| 1162 |
pos.width = GDrawPointsToPixels(sv->gw,_GScrollBar_Width); |
| 1163 |
pos.height = event->u.resize.size.height-sv->bh-sv->fh; |
| 1164 |
pos.x = event->u.resize.size.width-pos.width; pos.y = sv->fh; |
| 1165 |
GGadgetResize(sv->vsb,pos.width,pos.height+1); |
| 1166 |
GGadgetMove(sv->vsb,pos.x,pos.y); |
| 1167 |
pos.width = pos.x; pos.x = 0; |
| 1168 |
GDrawResize(sv->v,pos.width,pos.height); |
| 1169 |
GDrawMove(sv->v,0,sv->fh); |
| 1170 |
|
| 1171 |
sv->vheight = pos.height; sv->vwidth = pos.width; |
| 1172 |
SV_SetScrollBar(sv); |
| 1173 |
|
| 1174 |
width = pos.width-sv->addrend; |
| 1175 |
if ( width < 5 ) width = 5; |
| 1176 |
GGadgetResize(sv->tf,width,sv->fh); |
| 1177 |
|
| 1178 |
GGadgetGetSize(sv->ok,&gsize); |
| 1179 |
GGadgetMove(sv->ok,gsize.x,event->u.resize.size.height-GDrawPointsToPixels(sv->gw,33)); |
| 1180 |
GGadgetMove(sv->cancel,event->u.resize.size.width-gsize.x-gsize.width,event->u.resize.size.height-GDrawPointsToPixels(sv->gw,30)); |
| 1181 |
GGadgetGetSize(sv->setsize,&gsize); |
| 1182 |
GGadgetMove(sv->setsize,(event->u.resize.size.width-gsize.width)/2, |
| 1183 |
event->u.resize.size.height-GDrawPointsToPixels(sv->gw,60)); |
| 1184 |
|
| 1185 |
GDrawRequestExpose(sv->gw,NULL,true); |
| 1186 |
} |
| 1187 |
|
| 1188 |
static void short_expose(ShortView *sv,GWindow pixmap,GRect *rect) { |
| 1189 |
int low, high; |
| 1190 |
int x,y; |
| 1191 |
char cval[8], caddr[12]; |
| 1192 |
int index; |
| 1193 |
|
| 1194 |
GDrawSetFont(pixmap,sv->gfont); |
| 1195 |
|
| 1196 |
low = ( (rect->y-EDGE_SPACER)/sv->fh ) * sv->fh + EDGE_SPACER; |
| 1197 |
high = ( (rect->y+rect->height+sv->fh-1-EDGE_SPACER)/sv->fh ) * sv->fh +EDGE_SPACER; |
| 1198 |
if ( high>sv->vheight-EDGE_SPACER ) high = sv->vheight-EDGE_SPACER; |
| 1199 |
|
| 1200 |
GDrawDrawLine(pixmap,sv->addrend-ADDR_SPACER/2,rect->y,sv->addrend-ADDR_SPACER/2,rect->y+rect->height,MAIN_FOREGROUND); |
| 1201 |
GDrawDrawLine(pixmap,sv->valend-ADDR_SPACER/2,rect->y,sv->valend-ADDR_SPACER/2,rect->y+rect->height,MAIN_FOREGROUND); |
| 1202 |
|
| 1203 |
index = (sv->lpos+(low-EDGE_SPACER)/sv->fh); |
| 1204 |
y = low; |
| 1205 |
for ( ; y<=high && index<sv->len/2; ++index ) { |
| 1206 |
sprintf( caddr, "%d", index ); |
| 1207 |
x = sv->addrend - ADDR_SPACER - GDrawGetText8Width(pixmap,caddr,-1); |
| 1208 |
GDrawDrawText8(pixmap,x,y+sv->as,caddr,-1,MAIN_FOREGROUND); |
| 1209 |
|
| 1210 |
sprintf( cval, "%d", sv->edits[index] ); |
| 1211 |
GDrawDrawText8(pixmap,sv->addrend,y+sv->as,cval,-1,MAIN_FOREGROUND); |
| 1212 |
|
| 1213 |
if ( sv->comments[index]!=NULL ) |
| 1214 |
GDrawDrawText8(pixmap,sv->valend,y+sv->as,sv->comments[index],-1,MAIN_FOREGROUND); |
| 1215 |
y += sv->fh; |
| 1216 |
} |
| 1217 |
} |
| 1218 |
|
| 1219 |
static void short_mousemove(ShortView *sv,int pos) { |
| 1220 |
|
| 1221 |
} |
| 1222 |
|
| 1223 |
static void short_scroll(ShortView *sv,struct sbevent *sb) { |
| 1224 |
int newpos = sv->lpos; |
| 1225 |
|
| 1226 |
switch( sb->type ) { |
| 1227 |
case et_sb_top: |
| 1228 |
newpos = 0; |
| 1229 |
break; |
| 1230 |
case et_sb_uppage: |
| 1231 |
newpos -= sv->vheight/sv->fh; |
| 1232 |
break; |
| 1233 |
case et_sb_up: |
| 1234 |
--newpos; |
| 1235 |
break; |
| 1236 |
case et_sb_down: |
| 1237 |
++newpos; |
| 1238 |
break; |
| 1239 |
case et_sb_downpage: |
| 1240 |
newpos += sv->vheight/sv->fh; |
| 1241 |
break; |
| 1242 |
case et_sb_bottom: |
| 1243 |
newpos = sv->lheight-sv->vheight/sv->fh; |
| 1244 |
break; |
| 1245 |
case et_sb_thumb: |
| 1246 |
case et_sb_thumbrelease: |
| 1247 |
newpos = sb->pos; |
| 1248 |
break; |
| 1249 |
case et_sb_halfup: case et_sb_halfdown: break; |
| 1250 |
} |
| 1251 |
if ( newpos>sv->lheight-sv->vheight/sv->fh ) |
| 1252 |
newpos = sv->lheight-sv->vheight/sv->fh; |
| 1253 |
if ( newpos<0 ) newpos =0; |
| 1254 |
if ( newpos!=sv->lpos ) { |
| 1255 |
int diff = newpos-sv->lpos; |
| 1256 |
sv->lpos = newpos; |
| 1257 |
GScrollBarSetPos(sv->vsb,sv->lpos); |
| 1258 |
if ( sv->active!=-1 ) { |
| 1259 |
GRect pos; |
| 1260 |
GGadgetGetSize(sv->tf,&pos); |
| 1261 |
GGadgetMove(sv->tf,sv->addrend,pos.y+diff*sv->fh); |
| 1262 |
} |
| 1263 |
GDrawScroll(sv->v,NULL,0,diff*sv->fh); |
| 1264 |
} |
| 1265 |
} |
| 1266 |
|
| 1267 |
static void ShortViewFree(ShortView *sv) { |
| 1268 |
sv->sf->cvt_dlg = NULL; |
| 1269 |
free(sv->edits); |
| 1270 |
free(sv); |
| 1271 |
} |
| 1272 |
|
| 1273 |
static int sv_v_e_h(GWindow gw, GEvent *event) { |
| 1274 |
ShortView *sv = (ShortView *) GDrawGetUserData(gw); |
| 1275 |
|
| 1276 |
switch ( event->type ) { |
| 1277 |
case et_expose: |
| 1278 |
short_expose(sv,gw,&event->u.expose.rect); |
| 1279 |
break; |
| 1280 |
case et_char: |
| 1281 |
if ( event->u.chr.keysym == GK_Help || event->u.chr.keysym == GK_F1 ) |
| 1282 |
help("ui/dialogs/ttfinstrs.html", "#ttfinstrs-cvt"); |
| 1283 |
break; |
| 1284 |
case et_mousemove: case et_mousedown: case et_mouseup: |
| 1285 |
GGadgetEndPopup(); |
| 1286 |
if ( event->type==et_mousemove ) |
| 1287 |
short_mousemove(sv,event->u.mouse.y); |
| 1288 |
else if ( event->type == et_mousedown ) { |
| 1289 |
int l = (event->u.mouse.y-EDGE_SPACER)/sv->fh + sv->lpos; |
| 1290 |
int which = event->u.mouse.x > sv->valend; |
| 1291 |
char buf[20]; |
| 1292 |
int old = sv->active; |
| 1293 |
if ( sfinishup(sv,true) && event->u.mouse.x>sv->addrend && |
| 1294 |
l<sv->len/2 && l!=old ) { |
| 1295 |
sv->active = l; |
| 1296 |
sv->which = which; |
| 1297 |
if ( !which ) { |
| 1298 |
|
| 1299 |
GGadgetResize(sv->tf,sv->valend-sv->addrend-EDGE_SPACER,sv->fh); |
| 1300 |
GGadgetMove(sv->tf, sv->addrend, |
| 1301 |
(l-sv->lpos)*sv->fh+EDGE_SPACER+1); |
| 1302 |
sprintf( buf, "%d", sv->edits[sv->active] ); |
| 1303 |
GGadgetSetTitle8(sv->tf,buf); |
| 1304 |
} else { |
| 1305 |
GGadgetResize(sv->tf,sv->vwidth-sv->valend-EDGE_SPACER,sv->fh); |
| 1306 |
GGadgetMove(sv->tf, sv->valend, |
| 1307 |
(l-sv->lpos)*sv->fh+EDGE_SPACER+1); |
| 1308 |
GGadgetSetTitle8(sv->tf,sv->comments[l]==NULL?"":sv->comments[l]); |
| 1309 |
} |
| 1310 |
GDrawRequestExpose(sv->v,NULL,true); |
| 1311 |
GDrawPostEvent(event); |
| 1312 |
} |
| 1313 |
} |
| 1314 |
break; |
| 1315 |
case et_resize: |
| 1316 |
GDrawRequestExpose(gw,NULL,true); |
| 1317 |
break; |
| 1318 |
case et_timer: |
| 1319 |
break; |
| 1320 |
case et_focus: |
| 1321 |
break; |
| 1322 |
default: break; |
| 1323 |
} |
| 1324 |
return( true ); |
| 1325 |
} |
| 1326 |
|
| 1327 |
static int sv_e_h(GWindow gw, GEvent *event) { |
| 1328 |
ShortView *sv = (ShortView *) GDrawGetUserData(gw); |
| 1329 |
GRect r; |
| 1330 |
int x; |
| 1331 |
|
| 1332 |
Color fg = GDrawGetDefaultForeground(NULL); |
| 1333 |
|
| 1334 |
switch ( event->type ) { |
| 1335 |
case et_expose: |
| 1336 |
r.x = r.y = 0; r.width = sv->vwidth+40; r.height = sv->fh-1; |
| 1337 |
GDrawSetFont(gw,sv->gfont); |
| 1338 |
x = sv->addrend - ADDR_SPACER - 2 - GDrawGetText8Width(gw,_("Index"),-1); |
| 1339 |
GDrawDrawText8(gw,x,sv->as,_("Index"),-1,fg); |
| 1340 |
GDrawDrawText8(gw,sv->addrend,sv->as,_("Value"),-1,fg); |
| 1341 |
GDrawDrawText8(gw,sv->valend,sv->as,_("Comment"),-1,fg); |
| 1342 |
|
| 1343 |
GDrawDrawLine(gw,0,sv->fh-1,r.width,sv->fh-1,fg); |
| 1344 |
GDrawDrawLine(gw,0,sv->vheight+sv->fh,sv->vwidth,sv->vheight+sv->fh,fg); |
| 1345 |
break; |
| 1346 |
case et_resize: |
| 1347 |
short_resize(sv,event); |
| 1348 |
break; |
| 1349 |
case et_char: |
| 1350 |
if ( event->u.chr.keysym == GK_Help || event->u.chr.keysym == GK_F1 ) |
| 1351 |
help("ui/dialogs/ttfinstrs.html", "#ttfinstrs-cvt"); |
| 1352 |
break; |
| 1353 |
case et_controlevent: |
| 1354 |
switch ( event->u.control.subtype ) { |
| 1355 |
case et_scrollbarchange: |
| 1356 |
short_scroll(sv,&event->u.control.u.sb); |
| 1357 |
break; |
| 1358 |
default: break; |
| 1359 |
} |
| 1360 |
break; |
| 1361 |
case et_close: |
| 1362 |
_SV_DoClose(sv); |
| 1363 |
break; |
| 1364 |
case et_destroy: |
| 1365 |
ShortViewFree(sv); |
| 1366 |
break; |
| 1367 |
default: break; |
| 1368 |
} |
| 1369 |
return( true ); |
| 1370 |
} |
| 1371 |
|
| 1372 |
|
| 1373 |
static void cvtCreateEditor(struct ttf_table *tab,SplineFont *sf,uint32_t tag) { |
| 1374 |
ShortView *sv = calloc(1,sizeof(ShortView)); |
| 1375 |
char title[60]; |
| 1376 |
GRect pos, subpos, gsize; |
| 1377 |
GWindow gw; |
| 1378 |
GWindowAttrs wattrs; |
| 1379 |
int as,ds,ld, lh; |
| 1380 |
GGadgetCreateData gcd[9], *butarray[8], *harray[4], *harray2[3], *varray[7]; |
| 1381 |
GTextInfo label[5], lab; |
| 1382 |
GGadgetData gd; |
| 1383 |
static unichar_t num[] = { '0', '\0' }; |
| 1384 |
int numlen; |
| 1385 |
static GBox tfbox; |
| 1386 |
int i; |
| 1387 |
|
| 1388 |
sv->table = tab; |
| 1389 |
sv->sf = sf; |
| 1390 |
sf->cvt_dlg = sv; |
| 1391 |
sv->tag = tag; |
| 1392 |
|
| 1393 |
if ( tab==NULL && sf->mm!=NULL && sf->mm->apple ) |
| 1394 |
tab = SFFindTable(sf->mm->normal,tag); |
| 1395 |
if ( tab!=NULL ) { |
| 1396 |
sv->len = tab->len; |
| 1397 |
sv->edits = malloc(tab->len+1); |
| 1398 |
sv->comments = calloc((tab->len/2+1),sizeof(char *)); |
| 1399 |
for ( i=0; i<tab->len/2; ++i ) |
| 1400 |
sv->edits[i] = (tab->data[i<<1]<<8) | tab->data[(i<<1)+1]; |
| 1401 |
if ( sf->cvt_names!=NULL ) |
| 1402 |
for ( i=0; i<tab->len/2 && sf->cvt_names[i]!=END_CVT_NAMES; ++i ) |
| 1403 |
sv->comments[i] = copy(sf->cvt_names[i]); |
| 1404 |
} else { |
| 1405 |
sv->edits = malloc(2); |
| 1406 |
sv->len = 0; |
| 1407 |
sv->comments = calloc(1,sizeof(char *)); |
| 1408 |
} |
| 1409 |
|
| 1410 |
title[0] = (tag>>24)&0xff; |
| 1411 |
title[1] = (tag>>16)&0xff; |
| 1412 |
title[2] = (tag>>8 )&0xff; |
| 1413 |
title[3] = (tag )&0xff; |
| 1414 |
title[4] = ' '; |
| 1415 |
strncpy(title+5, sf->fontname, sizeof(title)/sizeof(title[0])-6); |
| 1416 |
|
| 1417 |
memset(&wattrs,0,sizeof(wattrs)); |
| 1418 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_icon; |
| 1419 |
wattrs.event_masks = ~(1<<et_charup); |
| 1420 |
wattrs.undercursor = 1; |
| 1421 |
wattrs.cursor = ct_pointer; |
| 1422 |
wattrs.utf8_window_title = title; |
| 1423 |
wattrs.icon = ttf_icon; |
| 1424 |
pos.x = pos.y = 0; |
| 1425 |
if ( GIntGetResource(_NUM_Buttonsize)>60 ) |
| 1426 |
pos.width = GDrawPointsToPixels(NULL,2*GIntGetResource(_NUM_Buttonsize)+30); |
| 1427 |
else |
| 1428 |
pos.width = GDrawPointsToPixels(NULL,150); |
| 1429 |
pos.height = GDrawPointsToPixels(NULL,200); |
| 1430 |
sv->gw = gw = GDrawCreateTopWindow(NULL,&pos,sv_e_h,sv,&wattrs); |
| 1431 |
|
| 1432 |
memset(&gcd,0,sizeof(gcd)); |
| 1433 |
memset(&label,0,sizeof(label)); |
| 1434 |
|
| 1435 |
gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 105; |
| 1436 |
gcd[0].gd.pos.width = -1; |
| 1437 |
label[0].text = (unichar_t *) _("_OK"); |
| 1438 |
label[0].text_is_1byte = true; |
| 1439 |
label[0].text_in_resource = true; |
| 1440 |
gcd[0].gd.label = &label[0]; |
| 1441 |
gcd[0].gd.flags = gg_visible|gg_enabled|gg_but_default; |
| 1442 |
gcd[0].creator = GButtonCreate; |
| 1443 |
gcd[0].data = sv; |
| 1444 |
gcd[0].gd.handle_controlevent = SV_OK; |
| 1445 |
|
| 1446 |
gcd[1].gd.pos.x = -8; gcd[1].gd.pos.y = 3; |
| 1447 |
gcd[1].gd.pos.width = -1; |
| 1448 |
label[1].text = (unichar_t *) _("_Cancel"); |
| 1449 |
label[1].text_is_1byte = true; |
| 1450 |
label[1].text_in_resource = true; |
| 1451 |
gcd[1].gd.label = &label[1]; |
| 1452 |
gcd[1].gd.flags = gg_visible|gg_enabled|gg_but_cancel; |
| 1453 |
gcd[1].creator = GButtonCreate; |
| 1454 |
gcd[1].data = sv; |
| 1455 |
gcd[1].gd.handle_controlevent = SV_Cancel; |
| 1456 |
|
| 1457 |
gcd[2] = gcd[1]; |
| 1458 |
label[2].text = (unichar_t *) _("Change Length"); |
| 1459 |
label[2].text_is_1byte = true; |
| 1460 |
label[2].text_in_resource = true; |
| 1461 |
gcd[2].gd.flags = gg_visible|gg_enabled; |
| 1462 |
gcd[2].gd.label = &label[2]; |
| 1463 |
gcd[2].creator = GButtonCreate; |
| 1464 |
gcd[2].data = sv; |
| 1465 |
gcd[2].gd.handle_controlevent = SV_ChangeLength; |
| 1466 |
|
| 1467 |
butarray[0] = GCD_Glue; butarray[1] = &gcd[0]; butarray[2] = GCD_Glue; |
| 1468 |
butarray[3] = GCD_Glue; butarray[4] = &gcd[1]; butarray[5] = GCD_Glue; |
| 1469 |
butarray[6] = NULL; |
| 1470 |
|
| 1471 |
harray[0] = GCD_Glue; harray[1] = &gcd[2]; harray[2] = GCD_Glue; |
| 1472 |
harray[3] = NULL; |
| 1473 |
|
| 1474 |
gcd[3].gd.flags = gg_enabled|gg_visible; |
| 1475 |
gcd[3].gd.u.boxelements = butarray; |
| 1476 |
gcd[3].creator = GHBoxCreate; |
| 1477 |
|
| 1478 |
gcd[4].gd.flags = gg_enabled|gg_visible; |
| 1479 |
gcd[4].gd.u.boxelements = harray; |
| 1480 |
gcd[4].creator = GHBoxCreate; |
| 1481 |
|
| 1482 |
sv->bh = GDrawPointsToPixels(gw,64); |
| 1483 |
|
| 1484 |
gcd[5].gd.pos.y = sv->fh; gcd[5].gd.pos.height = pos.height-sv->bh; |
| 1485 |
gcd[5].gd.pos.width = GDrawPointsToPixels(gw,_GScrollBar_Width); |
| 1486 |
gcd[5].gd.pos.x = pos.width-gcd[5].gd.pos.width; |
| 1487 |
gcd[5].gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_sb_vert; |
| 1488 |
gcd[5].gd.handle_controlevent = NULL; |
| 1489 |
gcd[5].creator = GScrollBarCreate; |
| 1490 |
gcd[5].data = sv; |
| 1491 |
harray2[0] = GCD_Glue; harray2[1] = &gcd[5]; harray2[2] = NULL; |
| 1492 |
|
| 1493 |
gcd[6].gd.flags = gg_enabled|gg_visible; |
| 1494 |
gcd[6].gd.u.boxelements = harray2; |
| 1495 |
gcd[6].creator = GHBoxCreate; |
| 1496 |
|
| 1497 |
varray[0] = &gcd[6]; varray[1] = NULL; |
| 1498 |
varray[2] = &gcd[4]; varray[3] = NULL; |
| 1499 |
varray[4] = &gcd[3]; varray[5] = NULL; |
| 1500 |
varray[6] = NULL; |
| 1501 |
|
| 1502 |
|
| 1503 |
gcd[7].gd.flags = gg_enabled|gg_visible; |
| 1504 |
gcd[7].gd.u.boxelements = varray; |
| 1505 |
gcd[7].creator = GHVBoxCreate; |
| 1506 |
|
| 1507 |
GGadgetsCreate(gw,&gcd[7]); |
| 1508 |
GHVBoxSetExpandableRow(gcd[7].ret,0); |
| 1509 |
GHVBoxSetExpandableCol(gcd[6].ret,0); |
| 1510 |
GHVBoxSetExpandableCol(gcd[3].ret,gb_expandgluesame); |
| 1511 |
GHVBoxSetExpandableCol(gcd[4].ret,gb_expandglue); |
| 1512 |
|
| 1513 |
sv->vsb = gcd[5].ret; |
| 1514 |
sv->ok = gcd[0].ret; |
| 1515 |
sv->cancel = gcd[1].ret; |
| 1516 |
sv->setsize = gcd[2].ret; |
| 1517 |
GGadgetGetSize(sv->vsb,&gsize); |
| 1518 |
sv->sbw = gsize.width; |
| 1519 |
|
| 1520 |
wattrs.mask = wam_events|wam_cursor; |
| 1521 |
subpos.x = 0; subpos.y = sv->fh; |
| 1522 |
subpos.width = 100; subpos.height = pos.height - sv->bh - sv->fh; |
| 1523 |
sv->v = GWidgetCreateSubWindow(gw,&subpos,sv_v_e_h,sv,&wattrs); |
| 1524 |
GDrawSetVisible(sv->v,true); |
| 1525 |
|
| 1526 |
sv->gfont = cvt_font.fi; |
| 1527 |
GDrawSetFont(sv->v,sv->gfont); |
| 1528 |
GDrawSetFont(sv->gw,sv->gfont); |
| 1529 |
GDrawWindowFontMetrics(sv->gw,sv->gfont,&as,&ds,&ld); |
| 1530 |
sv->as = as+1; |
| 1531 |
sv->fh = sv->as+ds; |
| 1532 |
|
| 1533 |
sv->chrlen = numlen = GDrawGetTextWidth(sv->v,num,1); |
| 1534 |
sv->addrend = 6*numlen + ADDR_SPACER + EDGE_SPACER; |
| 1535 |
sv->valend = sv->addrend + 7*numlen + ADDR_SPACER + EDGE_SPACER; |
| 1536 |
|
| 1537 |
tfbox.main_background = tfbox.main_foreground = COLOR_DEFAULT; |
| 1538 |
memset(&gd,0,sizeof(gd)); |
| 1539 |
gd.pos.y = -100; gd.pos.height = sv->fh; |
| 1540 |
gd.pos.x = sv->addrend; |
| 1541 |
memset(&lab,'\0',sizeof(lab)); |
| 1542 |
lab.text = num+1; |
| 1543 |
lab.font = sv->gfont; |
| 1544 |
gd.label = &lab; |
| 1545 |
gd.box = &tfbox; |
| 1546 |
gd.flags = gg_visible|gg_enabled|gg_sb_vert|gg_dontcopybox; |
| 1547 |
sv->tf = GTextFieldCreate(sv->v,&gd,NULL); |
| 1548 |
sv->active = -1; |
| 1549 |
|
| 1550 |
lh = sv->len/2; |
| 1551 |
if ( lh>40 ) lh = 40; |
| 1552 |
if ( lh<4 ) lh = 4; |
| 1553 |
if ( pos.width<sv->valend+6*numlen+EDGE_SPACER+sv->sbw ) |
| 1554 |
pos.width = sv->valend+6*numlen+EDGE_SPACER+sv->sbw; |
| 1555 |
GDrawResize(sv->gw,pos.width,lh*sv->fh+2*EDGE_SPACER); |
| 1556 |
|
| 1557 |
GDrawSetVisible(gw,true); |
| 1558 |
} |
| 1559 |
|
| 1560 |
int SF_CloseAllInstrs(SplineFont *sf) { |
| 1561 |
struct instrdata *id, *next; |
| 1562 |
int changed; |
| 1563 |
char name[12], *npt; |
| 1564 |
static char *buts[3]; |
| 1565 |
static int done = false; |
| 1566 |
|
| 1567 |
if ( !done ) { |
| 1568 |
buts[0] = _("_OK"); |
| 1569 |
buts[1] = _("_Cancel"); |
| 1570 |
done = true; |
| 1571 |
} |
| 1572 |
|
| 1573 |
for ( id = sf->instr_dlgs; id!=NULL; id=next ) { |
| 1574 |
next = id->next; |
| 1575 |
changed = id->changed; |
| 1576 |
if ( !changed && id->id->inedit ) { |
| 1577 |
if ( !IVParse(id->id)) |
| 1578 |
changed = true; |
| 1579 |
else |
| 1580 |
changed = id->changed; |
| 1581 |
} |
| 1582 |
if ( changed ) { |
| 1583 |
if ( id->tag==0 ) |
| 1584 |
npt = id->sc->name; |
| 1585 |
else { |
| 1586 |
name[0] = name[5] = '\''; |
| 1587 |
name[1] = id->tag>>24; name[2] = (id->tag>>16)&0xff; name[3] = (id->tag>>8)&0xff; name[4] = id->tag&0xff; |
| 1588 |
name[6] = 0; |
| 1589 |
npt = name; |
| 1590 |
} |
| 1591 |
GDrawRaise(id->id->gw); |
| 1592 |
if ( gwwv_ask(_("Instructions were changed"),(const char **) buts,0,1,_("The instructions for %.80s have changed. Do you want to lose those changes?"),npt)==1 ) |
| 1593 |
return( false ); |
| 1594 |
} |
| 1595 |
GDrawDestroyWindow(id->id->gw); |
| 1596 |
} |
| 1597 |
if ( sf->cvt_dlg!=NULL ) { |
| 1598 |
if ( sf->cvt_dlg->changed ) { |
| 1599 |
name[0] = name[5] = '\''; |
| 1600 |
name[1] = id->tag>>24; name[2] = (id->tag>>16)&0xff; name[3] = (id->tag>>8)&0xff; name[4] = id->tag&0xff; |
| 1601 |
name[6] = 0; |
| 1602 |
npt = name; |
| 1603 |
GDrawRaise(sf->cvt_dlg->gw); |
| 1604 |
if ( gwwv_ask(_("Instructions were changed"),(const char **) buts,0,1,_("The instructions for %.80s have changed. Do you want to lose those changes?"),npt)==1 ) |
| 1605 |
return( false ); |
| 1606 |
} |
| 1607 |
GDrawDestroyWindow(sf->cvt_dlg->gw); |
| 1608 |
} |
| 1609 |
if ( !no_windowing_ui ) { |
| 1610 |
GDrawSync(NULL); |
| 1611 |
GDrawProcessPendingEvents(NULL); |
| 1612 |
} |
| 1613 |
return( true ); |
| 1614 |
} |
| 1615 |
|
| 1616 |
|
| 1617 |
struct maxp_data { |
| 1618 |
GWindow gw; |
| 1619 |
SplineFont *sf; |
| 1620 |
struct ttf_table *tab; |
| 1621 |
int done; |
| 1622 |
}; |
| 1623 |
|
| 1624 |
#define CID_Zones 1006 |
| 1625 |
#define CID_TPoints 1007 |
| 1626 |
#define CID_Storage 1008 |
| 1627 |
#define CID_FDefs 1009 |
| 1628 |
#define CID_IDefs 1010 |
| 1629 |
#define CID_SEl 1011 |
| 1630 |
|
| 1631 |
static void MP_DoClose(struct maxp_data *mp) { |
| 1632 |
mp->done = true; |
| 1633 |
} |
| 1634 |
|
| 1635 |
static int Maxp_Cancel(GGadget *g, GEvent *e) { |
| 1636 |
|
| 1637 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 1638 |
MP_DoClose(GDrawGetUserData(GGadgetGetWindow(g))); |
| 1639 |
} |
| 1640 |
return( true ); |
| 1641 |
} |
| 1642 |
|
| 1643 |
static int Maxp_OK(GGadget *g, GEvent *e) { |
| 1644 |
struct maxp_data *mp; |
| 1645 |
int zones, tp, store, stack, fd, id, err=0; |
| 1646 |
|
| 1647 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 1648 |
mp = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1649 |
zones = GetInt8(mp->gw,CID_Zones,_("Zones"),&err); |
| 1650 |
tp = GetInt8(mp->gw,CID_TPoints,_("Twilight Zone Point Count"),&err); |
| 1651 |
store = GetInt8(mp->gw,CID_Storage,_("Storage"),&err); |
| 1652 |
stack = GetInt8(mp->gw,CID_SEl,_("Max Stack Depth"),&err); |
| 1653 |
fd = GetInt8(mp->gw,CID_FDefs,_("Max # Functions"),&err); |
| 1654 |
id = GetInt8(mp->gw,CID_IDefs,_("Max Instruction Defines"),&err); |
| 1655 |
if ( err ) |
| 1656 |
return( true ); |
| 1657 |
mp->done = true; |
| 1658 |
if ( mp->tab==NULL ) { |
| 1659 |
mp->tab = chunkalloc(sizeof(struct ttf_table)); |
| 1660 |
mp->tab->tag = CHR('m','a','x','p'); |
| 1661 |
mp->tab->len = 32; |
| 1662 |
mp->tab->data = calloc(32,1); |
| 1663 |
mp->tab->next = mp->sf->ttf_tables; |
| 1664 |
mp->sf->ttf_tables = mp->tab; |
| 1665 |
} else if ( mp->tab->len<32 ) { |
| 1666 |
free(mp->tab->data); |
| 1667 |
mp->tab->len = 32; |
| 1668 |
mp->tab->data = calloc(32,1); |
| 1669 |
} |
| 1670 |
mp->tab->data[14] = zones>>8; mp->tab->data[15] = zones&0xff; |
| 1671 |
mp->tab->data[16] = tp>>8; mp->tab->data[17] = tp&0xff; |
| 1672 |
mp->tab->data[18] = store>>8; mp->tab->data[19] = store&0xff; |
| 1673 |
mp->tab->data[20] = fd>>8; mp->tab->data[21] = fd&0xff; |
| 1674 |
mp->tab->data[22] = id>>8; mp->tab->data[23] = id&0xff; |
| 1675 |
mp->tab->data[24] = stack>>8; mp->tab->data[25] = stack&0xff; |
| 1676 |
mp->sf->changed = true; |
| 1677 |
mp->done = true; |
| 1678 |
} |
| 1679 |
return( true ); |
| 1680 |
} |
| 1681 |
|
| 1682 |
static int mp_e_h(GWindow gw, GEvent *event) { |
| 1683 |
struct maxp_data *mp = (struct maxp_data *) GDrawGetUserData(gw); |
| 1684 |
|
| 1685 |
switch ( event->type ) { |
| 1686 |
case et_char: |
| 1687 |
if ( event->u.chr.keysym == GK_Help || event->u.chr.keysym == GK_F1 ) |
| 1688 |
help("ui/dialogs/ttfinstrs.html", "#ttfinstrs-maxp"); |
| 1689 |
else |
| 1690 |
return( false ); |
| 1691 |
break; |
| 1692 |
case et_close: |
| 1693 |
MP_DoClose(mp); |
| 1694 |
break; |
| 1695 |
default: break; |
| 1696 |
} |
| 1697 |
return( true ); |
| 1698 |
} |
| 1699 |
|
| 1700 |
static void maxpCreateEditor(struct ttf_table *tab,SplineFont *sf,uint32_t tag) { |
| 1701 |
char title[60]; |
| 1702 |
GRect pos; |
| 1703 |
GWindow gw; |
| 1704 |
GWindowAttrs wattrs; |
| 1705 |
struct maxp_data mp; |
| 1706 |
GGadgetCreateData gcd[17], boxes[4], *hvarray[16], *butarray[8], *varray[7]; |
| 1707 |
GTextInfo label[17]; |
| 1708 |
uint8_t dummy[32], *data; |
| 1709 |
char buffer[6][20]; |
| 1710 |
int k, hv; |
| 1711 |
|
| 1712 |
if ( tab==NULL && sf->mm!=NULL && sf->mm->apple ) { |
| 1713 |
sf = sf->mm->normal; |
| 1714 |
tab = SFFindTable(sf,tag); |
| 1715 |
} |
| 1716 |
memset(&mp,0,sizeof(mp)); |
| 1717 |
mp.sf = sf; |
| 1718 |
mp.tab = tab; |
| 1719 |
if ( tab==NULL || tab->len<32 ) { |
| 1720 |
memset(dummy,0,sizeof(dummy)); |
| 1721 |
dummy[15]=2; |
| 1722 |
data = dummy; |
| 1723 |
} else |
| 1724 |
data = tab->data; |
| 1725 |
|
| 1726 |
title[0] = (tag>>24)&0xff; |
| 1727 |
title[1] = (tag>>16)&0xff; |
| 1728 |
title[2] = (tag>>8 )&0xff; |
| 1729 |
title[3] = (tag )&0xff; |
| 1730 |
title[4] = ' '; |
| 1731 |
strncpy(title+5, sf->fontname, sizeof(title)-6); |
| 1732 |
|
| 1733 |
memset(&wattrs,0,sizeof(wattrs)); |
| 1734 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict; |
| 1735 |
wattrs.event_masks = ~(1<<et_charup); |
| 1736 |
wattrs.undercursor = 1; |
| 1737 |
wattrs.cursor = ct_pointer; |
| 1738 |
wattrs.utf8_window_title = title; |
| 1739 |
wattrs.restrict_input_to_me = 1; |
| 1740 |
wattrs.undercursor = 1; |
| 1741 |
wattrs.is_dlg = true; |
| 1742 |
pos.x = pos.y = 0; |
| 1743 |
pos.width = GDrawPointsToPixels(NULL,260); |
| 1744 |
pos.height = GDrawPointsToPixels(NULL,125); |
| 1745 |
mp.gw = gw = GDrawCreateTopWindow(NULL,&pos,mp_e_h,&mp,&wattrs); |
| 1746 |
|
| 1747 |
memset(label,0,sizeof(label)); |
| 1748 |
memset(gcd,0,sizeof(gcd)); |
| 1749 |
memset(boxes,0,sizeof(boxes)); |
| 1750 |
|
| 1751 |
k=hv=0; |
| 1752 |
label[k].text = (unichar_t *) _("_Zones:"); |
| 1753 |
label[k].text_is_1byte = true; |
| 1754 |
label[k].text_in_resource = true; |
| 1755 |
gcd[k].gd.label = &label[k]; |
| 1756 |
gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = 16; |
| 1757 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1758 |
gcd[k].gd.cid = CID_Zones+1000; |
| 1759 |
gcd[k++].creator = GLabelCreate; |
| 1760 |
hvarray[hv++] = &gcd[k-1]; |
| 1761 |
|
| 1762 |
sprintf( buffer[0], "%d", (data[14]<<8)|data[14+1] ); |
| 1763 |
label[k].text = (unichar_t *) buffer[0]; |
| 1764 |
label[k].text_is_1byte = true; |
| 1765 |
gcd[k].gd.label = &label[k]; |
| 1766 |
gcd[k].gd.pos.x = 60; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-6; |
| 1767 |
gcd[k].gd.pos.width = 50; |
| 1768 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1769 |
gcd[k].gd.cid = CID_Zones; |
| 1770 |
gcd[k++].creator = GTextFieldCreate; |
| 1771 |
hvarray[hv++] = &gcd[k-1]; |
| 1772 |
|
| 1773 |
label[k].text = (unichar_t *) _("_Twilight Pnt Cnt:"); |
| 1774 |
label[k].text_is_1byte = true; |
| 1775 |
label[k].text_in_resource = true; |
| 1776 |
gcd[k].gd.label = &label[k]; |
| 1777 |
gcd[k].gd.pos.x = 120; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y; |
| 1778 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1779 |
gcd[k].gd.cid = CID_TPoints+1000; |
| 1780 |
gcd[k++].creator = GLabelCreate; |
| 1781 |
hvarray[hv++] = &gcd[k-1]; |
| 1782 |
|
| 1783 |
sprintf( buffer[1], "%d", (data[16]<<8)|data[16+1] ); |
| 1784 |
label[k].text = (unichar_t *) buffer[1]; |
| 1785 |
label[k].text_is_1byte = true; |
| 1786 |
gcd[k].gd.label = &label[k]; |
| 1787 |
gcd[k].gd.pos.x = 202; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-6; |
| 1788 |
gcd[k].gd.pos.width = 50; |
| 1789 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1790 |
gcd[k].gd.cid = CID_TPoints; |
| 1791 |
gcd[k++].creator = GTextFieldCreate; |
| 1792 |
hvarray[hv++] = &gcd[k-1]; hvarray[hv++] = NULL; |
| 1793 |
|
| 1794 |
label[k].text = (unichar_t *) _("St_orage:"); |
| 1795 |
label[k].text_in_resource = true; |
| 1796 |
label[k].text_is_1byte = true; |
| 1797 |
gcd[k].gd.label = &label[k]; |
| 1798 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-3].gd.pos.y+24+6; |
| 1799 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1800 |
gcd[k].gd.cid = CID_Storage; |
| 1801 |
gcd[k++].creator = GLabelCreate; |
| 1802 |
hvarray[hv++] = &gcd[k-1]; |
| 1803 |
|
| 1804 |
sprintf( buffer[2], "%d", (data[18]<<8)|data[18+1] ); |
| 1805 |
label[k].text = (unichar_t *) buffer[2]; |
| 1806 |
label[k].text_is_1byte = true; |
| 1807 |
gcd[k].gd.label = &label[k]; |
| 1808 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-6; |
| 1809 |
gcd[k].gd.pos.width = 50; |
| 1810 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1811 |
gcd[k].gd.cid = CID_Storage; |
| 1812 |
gcd[k++].creator = GTextFieldCreate; |
| 1813 |
hvarray[hv++] = &gcd[k-1]; |
| 1814 |
|
| 1815 |
label[k].text = (unichar_t *) _("Max _Stack Depth:"); |
| 1816 |
label[k].text_in_resource = true; |
| 1817 |
label[k].text_is_1byte = true; |
| 1818 |
gcd[k].gd.label = &label[k]; |
| 1819 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y; |
| 1820 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1821 |
gcd[k].gd.cid = CID_SEl+1000; |
| 1822 |
gcd[k++].creator = GLabelCreate; |
| 1823 |
hvarray[hv++] = &gcd[k-1]; |
| 1824 |
|
| 1825 |
sprintf( buffer[3], "%d", (data[24]<<8)|data[24+1] ); |
| 1826 |
label[k].text = (unichar_t *) buffer[3]; |
| 1827 |
label[k].text_is_1byte = true; |
| 1828 |
gcd[k].gd.label = &label[k]; |
| 1829 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y; |
| 1830 |
gcd[k].gd.pos.width = 50; |
| 1831 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1832 |
gcd[k].gd.cid = CID_SEl; |
| 1833 |
gcd[k++].creator = GTextFieldCreate; |
| 1834 |
hvarray[hv++] = &gcd[k-1]; hvarray[hv++] = NULL; |
| 1835 |
|
| 1836 |
label[k].text = (unichar_t *) _("_FDEF"); |
| 1837 |
label[k].text_in_resource = true; |
| 1838 |
label[k].text_is_1byte = true; |
| 1839 |
gcd[k].gd.label = &label[k]; |
| 1840 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-3].gd.pos.y+24+6; |
| 1841 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1842 |
gcd[k].gd.cid = CID_FDefs+1000; |
| 1843 |
gcd[k++].creator = GLabelCreate; |
| 1844 |
hvarray[hv++] = &gcd[k-1]; |
| 1845 |
|
| 1846 |
sprintf( buffer[4], "%d", (data[20]<<8)|data[20+1] ); |
| 1847 |
label[k].text = (unichar_t *) buffer[4]; |
| 1848 |
label[k].text_is_1byte = true; |
| 1849 |
gcd[k].gd.label = &label[k]; |
| 1850 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-6; gcd[k].gd.pos.width = 50; |
| 1851 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1852 |
gcd[k].gd.cid = CID_FDefs; |
| 1853 |
gcd[k++].creator = GTextFieldCreate; |
| 1854 |
hvarray[hv++] = &gcd[k-1]; |
| 1855 |
|
| 1856 |
label[k].text = (unichar_t *) _("_IDEFs"); |
| 1857 |
label[k].text_in_resource = true; |
| 1858 |
label[k].text_is_1byte = true; |
| 1859 |
gcd[k].gd.label = &label[k]; |
| 1860 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y; |
| 1861 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1862 |
gcd[k].gd.cid = CID_IDefs+1000; |
| 1863 |
gcd[k++].creator = GLabelCreate; |
| 1864 |
hvarray[hv++] = &gcd[k-1]; |
| 1865 |
|
| 1866 |
sprintf( buffer[5], "%d", (data[22]<<8)|data[22+1] ); |
| 1867 |
label[k].text = (unichar_t *) buffer[5]; |
| 1868 |
label[k].text_is_1byte = true; |
| 1869 |
gcd[k].gd.label = &label[k]; |
| 1870 |
gcd[k].gd.pos.x = gcd[k-4].gd.pos.x; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y; gcd[k].gd.pos.width = 50; |
| 1871 |
gcd[k].gd.flags = gg_enabled|gg_visible; |
| 1872 |
gcd[k].gd.cid = CID_IDefs; |
| 1873 |
gcd[k++].creator = GTextFieldCreate; |
| 1874 |
hvarray[hv++] = &gcd[k-1]; hvarray[hv++] = NULL; hvarray[hv++] = NULL; |
| 1875 |
|
| 1876 |
boxes[2].gd.flags = gg_enabled|gg_visible; |
| 1877 |
boxes[2].gd.u.boxelements = hvarray; |
| 1878 |
boxes[2].creator = GHVBoxCreate; |
| 1879 |
varray[0] = &boxes[2]; varray[1] = NULL; |
| 1880 |
varray[2] = GCD_Glue; varray[3] = NULL; |
| 1881 |
|
| 1882 |
gcd[k].gd.pos.x = 20-3; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+35-3; |
| 1883 |
gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0; |
| 1884 |
gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_default; |
| 1885 |
label[k].text = (unichar_t *) _("_OK"); |
| 1886 |
label[k].text_in_resource = true; |
| 1887 |
label[k].text_is_1byte = true; |
| 1888 |
gcd[k].gd.label = &label[k]; |
| 1889 |
gcd[k].gd.handle_controlevent = Maxp_OK; |
| 1890 |
gcd[k++].creator = GButtonCreate; |
| 1891 |
butarray[0] = GCD_Glue; butarray[1] = &gcd[k-1]; butarray[2] = GCD_Glue; |
| 1892 |
|
| 1893 |
gcd[k].gd.pos.x = -20; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+3; |
| 1894 |
gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0; |
| 1895 |
gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_cancel; |
| 1896 |
label[k].text = (unichar_t *) _("_Cancel"); |
| 1897 |
label[k].text_is_1byte = true; |
| 1898 |
label[k].text_in_resource = true; |
| 1899 |
gcd[k].gd.label = &label[k]; |
| 1900 |
gcd[k].gd.handle_controlevent = Maxp_Cancel; |
| 1901 |
gcd[k++].creator = GButtonCreate; |
| 1902 |
butarray[3] = GCD_Glue; butarray[4] = &gcd[k-1]; butarray[5] = GCD_Glue; |
| 1903 |
butarray[6] = NULL; |
| 1904 |
|
| 1905 |
boxes[3].gd.flags = gg_enabled|gg_visible; |
| 1906 |
boxes[3].gd.u.boxelements = butarray; |
| 1907 |
boxes[3].creator = GHBoxCreate; |
| 1908 |
varray[4] = &boxes[3]; varray[5] = NULL; |
| 1909 |
varray[6] = NULL; |
| 1910 |
|
| 1911 |
boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; |
| 1912 |
boxes[0].gd.flags = gg_enabled|gg_visible; |
| 1913 |
boxes[0].gd.u.boxelements = varray; |
| 1914 |
boxes[0].creator = GHVGroupCreate; |
| 1915 |
|
| 1916 |
GGadgetsCreate(gw,boxes); |
| 1917 |
GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue); |
| 1918 |
GHVBoxSetExpandableCol(boxes[3].ret,gb_expandgluesame); |
| 1919 |
GHVBoxFitWindow(boxes[0].ret); |
| 1920 |
GDrawSetVisible(gw,true); |
| 1921 |
while ( !mp.done ) |
| 1922 |
GDrawProcessOneEvent(NULL); |
| 1923 |
GDrawDestroyWindow(gw); |
| 1924 |
} |
| 1925 |
|
| 1926 |
void SFEditTable(SplineFont *sf, uint32_t tag) { |
| 1927 |
struct instrdata *id; |
| 1928 |
struct ttf_table *tab; |
| 1929 |
char name[12]; |
| 1930 |
char title[100]; |
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
if ( tag!=CHR('c','v','t',' ') ) |
| 1936 |
if ( sf->mm!=NULL && sf->mm->apple ) |
| 1937 |
sf = sf->mm->normal; |
| 1938 |
|
| 1939 |
tab = SFFindTable(sf,tag); |
| 1940 |
if ( tag==CHR('m','a','x','p') ) { |
| 1941 |
maxpCreateEditor(tab,sf,tag); |
| 1942 |
} else if ( tag!=CHR('c','v','t',' ') ) { |
| 1943 |
for ( id = sf->instr_dlgs; id!=NULL && id->tag!=tag; id=id->next ); |
| 1944 |
if ( id!=NULL ) { |
| 1945 |
GDrawSetVisible(id->id->gw,true); |
| 1946 |
GDrawRaise(id->id->gw); |
| 1947 |
return; |
| 1948 |
} |
| 1949 |
|
| 1950 |
id = calloc(1,sizeof(*id)); |
| 1951 |
id->sf = sf; |
| 1952 |
id->tag = tag; |
| 1953 |
id->instr_cnt = id->max = tab==NULL ? 0 : tab->len; |
| 1954 |
id->instrs = malloc(id->max+1); |
| 1955 |
if ( tab!=NULL && tab->data!=NULL ) |
| 1956 |
memcpy(id->instrs,tab->data,id->instr_cnt); |
| 1957 |
else |
| 1958 |
id->instrs[0]='\0'; |
| 1959 |
name[0] = name[5] = '\''; |
| 1960 |
name[1] = tag>>24; name[2] = (tag>>16)&0xff; name[3] = (tag>>8)&0xff; name[4] = tag&0xff; |
| 1961 |
name[6] = 0; |
| 1962 |
sprintf(title,_("TrueType Instructions for %.50s"),name); |
| 1963 |
InstrDlgCreate(id,title); |
| 1964 |
} else { |
| 1965 |
if ( sf->cvt_dlg!=NULL ) { |
| 1966 |
GDrawSetVisible(sf->cvt_dlg->gw,true); |
| 1967 |
GDrawRaise(sf->cvt_dlg->gw); |
| 1968 |
return; |
| 1969 |
} |
| 1970 |
cvtCreateEditor(tab,sf,tag); |
| 1971 |
} |
| 1972 |
} |