ufont.c 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* ufont.c 1.45 - Fujitsu source for CDEnext 96/12/03 18:34:11 */
  24. /* $XConsortium: ufont.c /main/14 1996/12/17 19:30:16 cde-fuj $ */
  25. /*
  26. * (c) Copyright 1995 FUJITSU LIMITED
  27. * This is source code modified by FUJITSU LIMITED under the Joint
  28. * Development Agreement for the CDEnext PST.
  29. * This is unpublished proprietary source code of FUJITSU LIMITED
  30. */
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <math.h>
  34. #include <X11/Intrinsic.h>
  35. #include "xoakufont.h"
  36. #include "util.h"
  37. #define _CLIENT_CAT_NAME "dtudcfonted"
  38. extern char *_DtGetMessage(char *filename, int set, int n, char *s);
  39. #define GETMESSAGE(set, number, string) GetMessage(set, number, string)
  40. static char *
  41. GetMessage(int set, int number, char *string)
  42. {
  43. char *tmp, *ret;
  44. tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string);
  45. ret = malloc(strlen(tmp) + 1);
  46. strcpy(ret, tmp);
  47. return (ret);
  48. }
  49. /****************************************************************
  50. * Widgets *
  51. ***************************************************************/
  52. Widget toplevel;
  53. Widget editPtnW;
  54. Widget cpyPtnW;
  55. Widget mngPtnW;
  56. EditChar edg;
  57. EditList edlist;
  58. EditPane edpane;
  59. XlibInf xl;
  60. DelInf dn;
  61. DelPtnInf dl[D_MAX] ;
  62. DelPtnInf dl_glyph[EDLIST_MAX]; /* add dl_disp 1995.09.20 */
  63. int sq_disp[EDLIST_MAX]; /* add sq_disp 1995.09.20 */
  64. EditPtnInf em;
  65. CopyPtnInf cpm;
  66. static Widget dnPopW;
  67. Widget wgeScro, editPopW;
  68. static int select_x, select_y, select_w, select_h;
  69. static int r1_x, r1_y, r2_x, r2_y, cut_w, cut_h;
  70. extern Widget xlfdDialog, cpyDialog;
  71. extern FalFontID font_id;
  72. Pixmap arrow_pix=0;
  73. static XtAppContext app; /* application context */
  74. static int edpane_size=0;
  75. static void OtherFontSelect(void);
  76. void drawDelCode(int i);
  77. void drawDelPtn(int i);
  78. static void xeg_init(void);
  79. static void dstrypaneEditPtn(void);
  80. void chgEdCode(int code, char mode);
  81. void chgEdList(int statloc, int slctloc, char mode);
  82. static void chgEdPtn(int code);
  83. static void DrawRectEdPn(int x1, int y1, int x2, int y2);
  84. static void DrawBorderEdPn(int x1, int y1, int x2, int y2);
  85. static void DrawPointEdPn(int x, int y, int mode);
  86. static void DrawDpPn(void);
  87. static void DrawPointDpPn(int x, int y, int mode);
  88. static void musPoint(int evtype, int px, int py);
  89. static void musLine(int evtype, int px, int py);
  90. static void musCircle(int evtype, int px, int py);
  91. static void musRect(int proc, int evtype, int px, int py);
  92. static void musRegionProc(int proc, int evtype, int px, int py);
  93. #ifdef __linux__
  94. static void musPasteProc(Widget w, XtPointer client_data, XEvent *event, Boolean*);
  95. #else
  96. static void musPasteProc(Widget w, XtPointer client_data, XEvent *event);
  97. #endif
  98. static void rubLine(int x1, int y1, int x2, int y2);
  99. static void rubBand(int x1, int y1, int x2, int y2);
  100. static void rubCircle(int ox, int oy, int rx, int ry);
  101. static void resetEditMode(unsigned int flag);
  102. static void copyPatterns(FalFontData *fdata,
  103. int s1_code,
  104. int s2_code,
  105. int d1_code,
  106. int proc);
  107. extern String MngCodeTfValue(void);
  108. extern String CpySrcCodeTfValue(void);
  109. extern String CpyDestCodeTfValue(void);
  110. char *get_cmd_path(char *path, char *cmd);
  111. extern FalFontData fullFontData;
  112. extern FalFontData copyFontData;
  113. extern void PopupSelectXLFD(Widget top);
  114. extern void UpdateMessage(String str);
  115. extern void DispMngErrorMessage(String msg);
  116. extern void DispCpyErrorMessage(String msg);
  117. static int setRealDelArea(int *s_ncode,
  118. int *e_ncode,
  119. int *sq_start,
  120. int *sq_end);
  121. /****************************************************************
  122. * parameters *
  123. ***************************************************************/
  124. static Arg arg[30];
  125. static int n;
  126. Resource resource;
  127. /****************************************************************
  128. * callback routines *
  129. ***************************************************************/
  130. static void CancelCB(void);
  131. static void
  132. ExitCB(void)
  133. {
  134. exit(0);
  135. }
  136. int
  137. efctPtnNum(void)
  138. {
  139. int no;
  140. int sq;
  141. int cnt;
  142. for ( cnt = 0, sq = edlist.sqstart;
  143. sq < (edlist.sqstart + edlist.nptn); sq++) {
  144. no = ptnSqToNo(sq);
  145. if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
  146. cnt++;
  147. }
  148. return( cnt);
  149. }
  150. void
  151. Error_message(Widget widget, char *message)
  152. {
  153. static NoticeButton is_lock[] = {
  154. NBTNARGS( ExitCB, NULL, 'E', True, False ),
  155. NBTNARGS( CancelCB, NULL, 'C', True, True )
  156. };
  157. static NButton LockBTN = NBUTTONS( is_lock );
  158. SetItemLabel(&LockBTN, 0, resource.l_exit);
  159. SetItemLabel(&LockBTN, 1, resource.l_cancel);
  160. PopupNotice( (widget), message,
  161. D_ERROR,
  162. &LockBTN,
  163. True,
  164. resource.l_question_title);
  165. }
  166. void
  167. Error_message2(Widget widget, char *message)
  168. {
  169. static NoticeButton is_lock[] = {
  170. NBTNARGS( CancelCB, NULL, 'C', True, True )
  171. };
  172. static NButton LockBTN = NBUTTONS( is_lock );
  173. if (widget == NULL)
  174. widget = toplevel;
  175. SetItemLabel(&LockBTN, 0, resource.l_ok);
  176. PopupNotice( (widget), message,
  177. D_ERROR,
  178. &LockBTN,
  179. True,
  180. resource.l_question_title);
  181. }
  182. /*
  183. * contents : read a character pattern from SNF file
  184. */
  185. /*ARGSUSED*/
  186. static void
  187. CBmOblB_edit( Widget widget, caddr_t clientData, caddr_t callData )
  188. {
  189. int ptn_n;
  190. int ptn_w;
  191. int ptn_h;
  192. int code;
  193. int i;
  194. int ret;
  195. char err[128];
  196. extern int begin_code;
  197. extern int ptnGetInfo();
  198. extern void PopupEditPtn();
  199. /* open font file and get informations of character to be edited */
  200. ret = readSNF( &(edg.fdata), &(edg.width), &(edg.height), err);
  201. if( ret == -1 ) {
  202. Error_message(widget, err);
  203. return;
  204. }
  205. dn.ptn_w = (Dimension) edg.width;
  206. dn.ptn_h = (Dimension) edg.height;
  207. if( xlfdDialog != NULL )
  208. PopdownDialog(xlfdDialog);
  209. ptnGetInfo( &ptn_n, &ptn_w, &ptn_h );
  210. for( i=0 ; i<ptn_n ; i++ ) {
  211. code = noToCode( ptnSqToNo(i) );
  212. if( begin_code > code){
  213. edlist.sqstart = i+1;
  214. } else {
  215. edlist.nptn++;
  216. }
  217. }
  218. if( efctPtnNum() > 0) {
  219. for ( i=edlist.sqstart; i<(edlist.sqstart+edlist.nptn); i++){
  220. if ( codeCheck( noToCode( ptnSqToNo(i))) == 0)
  221. break;
  222. }
  223. edg.ncode = ptnSqToNo( i );
  224. edg.code = noToCode( edg.ncode );
  225. ptnGet( edg.code, edg.ptn );
  226. }
  227. PopupEditPtn(toplevel);
  228. }
  229. void CBeOblB_aAdd(void);
  230. static Boolean do_read = False;
  231. static Boolean do_end = False;
  232. static void CancelCB(void) { }
  233. static void ContReadCB(Widget w)
  234. {
  235. FalCloseFont(font_id);
  236. editPtnW = NULL;
  237. OtherFontSelect();
  238. PopupSelectXLFD(toplevel);
  239. }
  240. static void SaveReadCB(void)
  241. {
  242. CBeOblB_aAdd();
  243. do_read = True;
  244. PopupSelectXLFD(toplevel);
  245. }
  246. static void ContEndCB(void)
  247. {
  248. FalCloseFont(font_id);
  249. exit(0);
  250. }
  251. static void SaveEndCB(void)
  252. {
  253. CBeOblB_aAdd();
  254. do_end = True;
  255. }
  256. /*
  257. * contents : quit editting
  258. */
  259. /*ARGSUSED*/
  260. static int
  261. QuitEditPtn( Widget widget, caddr_t clientData, caddr_t callData )
  262. {
  263. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  264. if( edg.code != 0 ){
  265. ptnAdd( edg.code, edg.ptn );
  266. }
  267. if( edg.flag == ON ){
  268. return(0);
  269. }
  270. return(1);
  271. }
  272. void
  273. OpenCB(Widget w, XtPointer client_data, XtPointer call_data)
  274. {
  275. static NoticeButton is_save_read_btn1[] = {
  276. NBTNARGS( SaveReadCB, NULL, 'S', True, False ),
  277. NBTNARGS( ContReadCB, NULL, 'O', True, False ),
  278. NBTNARGS( CancelCB, NULL, 'C', True, True ),
  279. };
  280. static NoticeButton is_save_read_btn2[] = {
  281. NBTNARGS( ContReadCB, NULL, 'O', True, False ),
  282. NBTNARGS( CancelCB, NULL, 'C', True, True ),
  283. };
  284. static NButton SaveReadBTN1 = NBUTTONS( is_save_read_btn1 );
  285. static NButton SaveReadBTN2 = NBUTTONS( is_save_read_btn2 );
  286. if (QuitEditPtn((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL)){
  287. FalCloseFont(font_id);
  288. editPtnW = NULL;
  289. OtherFontSelect();
  290. PopupSelectXLFD(toplevel);
  291. }
  292. else{
  293. if (! fullFontData.prm) {
  294. SetItemLabel(&SaveReadBTN1, 0, resource.l_do_save_exit);
  295. SetItemLabel(&SaveReadBTN1, 1, resource.l_dont_save_exit);
  296. SetItemLabel(&SaveReadBTN1, 2, resource.l_cancel);
  297. PopupNotice( (w), resource.mn_saved_open ,
  298. D_QUESTION,
  299. &SaveReadBTN1,
  300. True,
  301. resource.l_question_title);
  302. } else {
  303. SetItemLabel(&SaveReadBTN2, 0, resource.l_dont_save_exit);
  304. SetItemLabel(&SaveReadBTN2, 1, resource.l_cancel);
  305. PopupNotice( (w), resource.mn_saved_open ,
  306. D_QUESTION,
  307. &SaveReadBTN2,
  308. True,
  309. resource.l_question_title);
  310. }
  311. }
  312. }
  313. void
  314. ReadCB(Widget w, XtPointer client_data, XtPointer call_data)
  315. {
  316. if (fullFontData.xlfdname == NULL) {
  317. return;
  318. }
  319. if (fullFontData.xlfdname == (char *) -1) {
  320. Error_message(w, resource.mn_prop_font);
  321. return;
  322. }
  323. CBmOblB_edit( w, client_data, call_data );
  324. }
  325. /****************************************************************
  326. * callback routines and event handler *
  327. ***************************************************************/
  328. /*
  329. * contents : write character patterns to SNF file
  330. */
  331. static Boolean
  332. WPwriteSNF( int restart )
  333. {
  334. int rc, err;
  335. char str[MG_MAXSIZE];
  336. switch( rc = writeSNF( restart, &err ) ) {
  337. case -1:
  338. if (dnPopW)
  339. XtSetSensitive( dnPopW, TRUE );
  340. switch( err ) {
  341. case 001:
  342. sprintf(str, "%s(permission denied)", resource.me_write_snf);
  343. break;
  344. case 002:
  345. sprintf(str, "%s(disk full)", resource.me_write_snf);
  346. break;
  347. case 101:
  348. sprintf(str, "%s(pipe error)", resource.me_write_snf);
  349. break;
  350. case 102:
  351. sprintf(str, "%s(fork error)", resource.me_write_snf);
  352. break;
  353. case 103:
  354. sprintf(str, "%s(execv error)", resource.me_write_snf);
  355. break;
  356. case 104:
  357. sprintf(str, "%s(data error)", resource.me_write_snf);
  358. break;
  359. default:
  360. sprintf(str, "%s", resource.me_write_snf);
  361. }
  362. UpdateMessage( str );
  363. return( TRUE );
  364. case 0:
  365. edg.flag = 0;
  366. UpdateMessage( resource.mg_register );
  367. sleep(1);
  368. UpdateMessage("");
  369. if (do_read){
  370. do_read = False;
  371. ContReadCB((Widget)NULL);
  372. }
  373. if (do_end){
  374. do_read = False;
  375. ContEndCB();
  376. }
  377. return(TRUE);
  378. default:
  379. if( rc == 1101 )
  380. sprintf( str, "%s", resource.me_wait );
  381. else
  382. sprintf( str, "%s(%3d%%)", resource.mg_write_snf , rc-1000 );
  383. UpdateMessage( str );
  384. XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)ON );
  385. if( rc == 1101 ){
  386. XSync( xl.display,0 );
  387. }
  388. return( TRUE );
  389. }
  390. }
  391. /*
  392. * contents : write character patterns to SNF file
  393. */
  394. void
  395. CBeOblB_aAdd(void)
  396. {
  397. char str[MG_MAXSIZE];
  398. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  399. UpdateMessage( resource.mg_write_snf );
  400. if( edg.code != 0 )
  401. ptnAdd( edg.code, edg.ptn );
  402. if( edg.flag == ON ) {
  403. sprintf( str, "%s", resource.mg_write_snf );
  404. if (dnPopW)
  405. XtSetSensitive( dnPopW, FALSE );
  406. XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)OFF );
  407. return;
  408. }
  409. else{
  410. UpdateMessage( "" );
  411. }
  412. }
  413. /*
  414. * contents : destroy the editor window
  415. */
  416. static void
  417. OtherFontSelect(void)
  418. {
  419. dstrypaneEditPtn();
  420. xeg_init();
  421. }
  422. /*
  423. * contents : close dtudcfonted
  424. */
  425. /*ARGSUSED*/
  426. void
  427. CBeOblB_aEnd( Widget widget, caddr_t clientData, caddr_t callData )
  428. {
  429. static NoticeButton is_save_exit_btn[] = {
  430. NBTNARGS( SaveEndCB, NULL, 'S', True, False ),
  431. NBTNARGS( ContEndCB, NULL, 'E', True, False ),
  432. NBTNARGS( CancelCB, NULL, 'C', True, True ),
  433. };
  434. static NButton SaveEndBTN = NBUTTONS( is_save_exit_btn );
  435. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  436. if( edg.code != 0 )
  437. ptnAdd( edg.code, edg.ptn );
  438. if( edg.flag == ON ) {
  439. SetItemLabel(&SaveEndBTN, 0, resource.l_do_save);
  440. SetItemLabel(&SaveEndBTN, 1, resource.l_dont_save);
  441. SetItemLabel(&SaveEndBTN, 2, resource.l_cancel);
  442. PopupNotice( widget, resource.mn_saved_exit, D_QUESTION,
  443. &SaveEndBTN, True, resource.l_question_title);
  444. return;
  445. } else {
  446. FalCloseFont(font_id);
  447. }
  448. exit(0);
  449. }
  450. /*ARGSUSED*/
  451. void
  452. CBeOblB_rCmd( Widget widget, int proc, caddr_t callData )
  453. {
  454. extern void SelectUnset();
  455. extern void UndoSet();
  456. if (!select_x && !select_y && !select_w && !select_h)
  457. return;
  458. em.rsv_f = ON;
  459. bitPtnCopy( em.rsv_ptn, edg.ptn );
  460. rubBand( r1_x, r1_y, r2_x, r2_y );
  461. switch( proc ) {
  462. case PROC_CLS:
  463. bitDrawCls (edg.ptn, select_x, select_y, select_w, select_h );
  464. break;
  465. case PROC_SET:
  466. bitDrawSet (edg.ptn, select_x, select_y, select_w, select_h );
  467. break;
  468. case PROC_REV:
  469. bitDrawRev (edg.ptn, select_x, select_y, select_w, select_h );
  470. break;
  471. case PROC_ROLL:
  472. bitDrawRoll(edg.ptn, select_x, select_y, select_w, select_h);
  473. break;
  474. case PROC_SYMV:
  475. bitDrawSymV(edg.ptn, select_x, select_y, select_w, select_h );
  476. break;
  477. case PROC_SYMH:
  478. bitDrawSymH(edg.ptn, select_x, select_y, select_w, select_h );
  479. break;
  480. }
  481. edg.flag = ON;
  482. DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
  483. DrawDpPn();
  484. select_x = select_y = select_w = select_h = 0;
  485. SelectUnset();
  486. UndoSet();
  487. }
  488. /*ARGSUSED*/
  489. void
  490. CBeOblB_rCmdp( Widget widget, int proc, caddr_t callData )
  491. {
  492. extern Widget wgeBulB_edit;
  493. extern void CopySet();
  494. extern void UndoSet();
  495. extern void SelectUnset();
  496. switch( proc ) {
  497. case PROC_CPY:
  498. if (!select_x && !select_y && !select_w && !select_h)
  499. return;
  500. rubBand( r1_x, r1_y, r2_x, r2_y );
  501. bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, False);
  502. cut_w = select_w;
  503. cut_h = select_h;
  504. select_x = select_y = select_w = select_h = 0;
  505. CopySet();
  506. SelectUnset();
  507. break;
  508. case PROC_CUT:
  509. if (!select_x && !select_y && !select_w && !select_h)
  510. return;
  511. em.rsv_f = ON;
  512. rubBand( r1_x, r1_y, r2_x, r2_y );
  513. bitPtnCopy( em.rsv_ptn, edg.ptn );
  514. bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, True);
  515. cut_w = select_w;
  516. cut_h = select_h;
  517. edg.flag = ON;
  518. DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
  519. DrawDpPn();
  520. select_x = select_y = select_w = select_h = 0;
  521. CopySet();
  522. UndoSet();
  523. SelectUnset();
  524. break;
  525. case PROC_PASTE:
  526. XtAddEventHandler(wgeBulB_edit,
  527. ButtonReleaseMask|PointerMotionMask,
  528. False, musPasteProc, NULL );
  529. }
  530. }
  531. /*
  532. * contents : cancel all editting
  533. */
  534. /*ARGSUSED*/
  535. void
  536. CBeOblB_rCan( Widget widget, caddr_t clientData, caddr_t callData )
  537. {
  538. extern void UndoUnset();
  539. resetEditMode( RES_MSG | RES_PROC | RES_SLCT );
  540. if( em.rsv_f == ON ) {
  541. bitPtnCopy( edg.ptn, em.rsv_ptn );
  542. em.rsv_f = OFF;
  543. DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
  544. DrawDpPn();
  545. UndoUnset();
  546. }
  547. }
  548. /*
  549. *
  550. * contents : get a sequential number of the editor
  551. */
  552. int
  553. RelToAbsSq( int from, int cnt)
  554. {
  555. int i;
  556. int no;
  557. if ( cnt >= 0) {
  558. for ( i = -1; from < (edlist.sqstart + edlist.nptn) ; from++) {
  559. no = ptnSqToNo(from);
  560. if (( no >= 0) && ( noToCode( no) >= 0) ) {
  561. i++;
  562. if ( i >= cnt)
  563. return( from);
  564. }
  565. }
  566. } else {
  567. cnt *= -1;
  568. for ( i = -1; from >= edlist.sqstart; from--) {
  569. no = ptnSqToNo(from);
  570. if (( no >= 0) && ( noToCode( no) >= 0) ) {
  571. i++;
  572. if ( i >= cnt)
  573. return(from);
  574. }
  575. }
  576. }
  577. return( -1);
  578. }
  579. /*
  580. * contents : get a relative number of the system area
  581. */
  582. int
  583. AbsSqToRel( int from, int to)
  584. {
  585. int sq;
  586. int cnt;
  587. int sign = 1;
  588. int no;
  589. if ( from > to) {
  590. sq = from;
  591. from = to;
  592. to = sq;
  593. sign = -1;
  594. }
  595. for ( cnt = -1, sq = from; sq <= to; sq++) {
  596. no = ptnSqToNo(sq);
  597. if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
  598. cnt++;
  599. }
  600. if ( cnt < 0)
  601. cnt = 0;
  602. cnt *= sign;
  603. return( cnt);
  604. }
  605. /*
  606. * contents : be the character list selected
  607. */
  608. /*ARGSUSED*/
  609. void
  610. EHeStaT_list( Widget widget, int select, XEvent *e )
  611. {
  612. int sq, no;
  613. int code;
  614. resetEditMode( RES_MSG|RES_PROC|RES_SLCT|RES_RSV );
  615. if( (e->xbutton.button != 1) || (e->type != ButtonRelease) ||
  616. (e->xbutton.x < 0) || ((int)edlist.elem_w < e->xbutton.x) ||
  617. (e->xbutton.y < 0) || ((int)edlist.elem_h < e->xbutton.y)
  618. )
  619. return;
  620. if( edlist.slctloc == select )
  621. return;
  622. sq = RelToAbsSq( edlist.sqstart + edlist.statloc, select);
  623. if( (no = ptnSqToNo(sq)) == -1 )
  624. return;
  625. code = noToCode( no );
  626. if( codeCheck( code ) == -1 )
  627. return;
  628. if( ptnSense( code) == 0 )
  629. return ;
  630. chgEdList( edlist.statloc, select, OFF );
  631. if( ptnSense(edg.code) == 1 )
  632. ptnAdd(edg.code, edg.ptn );
  633. chgEdPtn( code );
  634. }
  635. /*
  636. * contents : update the character list
  637. */
  638. /*ARGSUSED*/
  639. void
  640. CBeScro( Widget widget, caddr_t clientData, caddr_t callData )
  641. {
  642. int newl;
  643. int new_statloc;
  644. int new_slct;
  645. n = 0;
  646. XtSetArg( arg[n], XmNvalue, (XtArgVal)&newl ); n++;
  647. XtGetValues( wgeScro , arg, n );
  648. if (( new_statloc = RelToAbsSq( edlist.sqstart, newl)) < 0) {
  649. new_statloc = 0;
  650. } else {
  651. new_statloc -= edlist.sqstart;
  652. }
  653. /*
  654. */
  655. new_slct = edlist.slctloc
  656. - AbsSqToRel( edlist.sqstart + edlist.statloc,
  657. edlist.sqstart + new_statloc);
  658. chgEdList( new_statloc, new_slct, OFF);
  659. }
  660. /*
  661. * contents : select the edit items by mouse
  662. */
  663. /*ARGSUSED*/
  664. void
  665. EHeBulB_eMEv( Widget widget, caddr_t clientData, XEvent *e )
  666. {
  667. int px, py;
  668. int downbutton;
  669. if (edpane.pix_w * edpane.pix_h == 0 ) {
  670. return;
  671. }
  672. if( e->type == ButtonPress ){
  673. em.drag_f = ON;
  674. }
  675. if( (edg.code == 0) || (em.drag_f == OFF) )
  676. return;
  677. if( e->type == ButtonRelease ){
  678. em.drag_f = OFF;
  679. }
  680. px = e->xbutton.x / edpane.pix_w;
  681. py = e->xbutton.y / edpane.pix_h;
  682. if (( e->type == ButtonPress) || (e->type == ButtonRelease)){
  683. downbutton = e->xbutton.button;
  684. }else if ( e->type == MotionNotify ){
  685. if ( e->xmotion.state & Button1Mask ){
  686. downbutton = 1; /* select button */
  687. }else if ( e->xmotion.state & Button2Mask ){
  688. downbutton = 2; /* adjust button */
  689. } else {
  690. downbutton = 0;
  691. }
  692. }
  693. switch( downbutton ) {
  694. case 1:
  695. switch( em.proc ) {
  696. case PROC_POINT:
  697. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  698. musPoint( e->type, px, py );
  699. break;
  700. case PROC_LINE:
  701. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  702. musLine( e->type, px, py );
  703. break;
  704. case PROC_CIRCLE:
  705. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  706. musCircle( e->type, px, py );
  707. break;
  708. case PROC_RECT:
  709. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  710. musRect( em.proc, e->type, px, py );
  711. break;
  712. case PROC_ERASE:
  713. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  714. musPoint( e->type, px, py );
  715. break;
  716. case PROC_SELECT:
  717. musRegionProc( em.proc, e->type, px, py );
  718. break;
  719. default:
  720. break;
  721. }
  722. break;
  723. case 2:
  724. if( (0 <= px) && (px < edg.width) && (0 <= py) && (py < edg.height) ) {
  725. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  726. switch( e->type ) {
  727. case MotionNotify:
  728. if( (em.adj_px == px) && (em.adj_py == py) )
  729. return;
  730. break;
  731. case ButtonPress:
  732. em.adj_px = px;
  733. em.adj_py = py;
  734. if( bitRead(edg.ptn, px, py) == 0 ) {
  735. bitSet( edg.ptn, px, py );
  736. DrawPointEdPn( px,py, 1 );
  737. DrawPointDpPn( px,py, 1 );
  738. }
  739. else {
  740. bitReset( edg.ptn, px, py );
  741. DrawPointEdPn( px,py, 0 );
  742. DrawPointDpPn( px,py, 0 );
  743. }
  744. edg.flag = ON;
  745. break;
  746. default:
  747. return;
  748. }
  749. }
  750. default:
  751. break;
  752. }
  753. }
  754. /*
  755. * contents : restore the editting pane
  756. */
  757. /*ARGSUSED*/
  758. void
  759. EHeBulB_eExp( Widget widget, caddr_t clientData, XEvent *e )
  760. {
  761. int x1, y1;
  762. int x2, y2;
  763. if (edpane.pix_w * edpane.pix_h == 0 ) {
  764. return;
  765. }
  766. x1 = e->xexpose.x / edpane.pix_w;
  767. y1 = e->xexpose.y / edpane.pix_h;
  768. x2 = (e->xexpose.x + e->xexpose.width - 1) / edpane.pix_w;
  769. y2 = (e->xexpose.y + e->xexpose.height - 1) / edpane.pix_h;
  770. DrawRectEdPn( x1, y1, x2, y2 );
  771. DrawBorderEdPn( x1, y1, x2, y2 );
  772. }
  773. /*
  774. * contents : specifies the drawing operation (Pont/Line/Rectangle/Circle)
  775. */
  776. /*ARGSUSED*/
  777. void
  778. CBeRecB_obj( Widget widget, int obj, XmToggleButtonCallbackStruct *call)
  779. {
  780. extern void SelectUnset();
  781. if (call->set == False)
  782. return;
  783. resetEditMode( RES_MSG | RES_RSV | RES_SLCT );
  784. if (obj == PROC_ERASE)
  785. edpane.color = OFF;
  786. else
  787. edpane.color = ON;
  788. edpane.obj = obj;
  789. em.proc = obj;
  790. if (obj != PROC_SELECT) {
  791. if (select_x || select_y || select_w || select_h) {
  792. rubBand( r1_x, r1_y, r2_x, r2_y );
  793. select_x = select_y = select_w = select_h = 0;
  794. SelectUnset();
  795. }
  796. }
  797. }
  798. /*
  799. * contents : restore the displaying pane
  800. */
  801. /*ARGSUSED*/
  802. void
  803. EHeBulB_dExp( Widget widget, caddr_t clientData )
  804. {
  805. if (xl.display == NULL ){
  806. return;
  807. }
  808. DrawDpPn();
  809. }
  810. /*
  811. * contents : set the range to be add or deleted
  812. */
  813. static int
  814. codeAreaSet(int *s_code, int *e_code)
  815. {
  816. char *str;
  817. char delm;
  818. str = MngCodeTfValue();
  819. delm = '\0';
  820. *s_code = 0;
  821. *e_code = 0;
  822. if (!str || !*str){
  823. return(-1);
  824. }
  825. sscanf( str, "%x %c %x", s_code, &delm, e_code );
  826. if (str) free( str );
  827. switch( delm ) {
  828. case '\0':
  829. *e_code = *s_code;
  830. break;
  831. case '-':
  832. break;
  833. default:
  834. return(-1);
  835. }
  836. if( codeCheck(*s_code) || codeCheck(*e_code) ||
  837. (*s_code > *e_code) ) {
  838. return(-1);
  839. }
  840. return(0);
  841. }
  842. /****************************************************************
  843. * callback routines (character management window) *
  844. ***************************************************************/
  845. Boolean
  846. BeforeMngCheck(int *s_code, int *e_code)
  847. {
  848. if(codeAreaSet(s_code, e_code) == -1) {
  849. DispMngErrorMessage( resource.me_illegal_code );
  850. return(False);
  851. }
  852. return(True);
  853. }
  854. void
  855. DoAddProc(int s_code, int e_code)
  856. {
  857. int code;
  858. int s_ncode;
  859. int e_ncode;
  860. char ptn[MAXPTNBYTE];
  861. char mode;
  862. int i;
  863. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  864. s_ncode = codeToNo( s_code );
  865. e_ncode = codeToNo( e_code );
  866. mode = OFF;
  867. bitPtnClear( ptn );
  868. for( i=s_ncode ; i <= e_ncode ; i++ ) {
  869. code = noToCode(i);
  870. if ( codeCheck( code))
  871. continue;
  872. if (ptnSense(code) == 0) {
  873. if(ptnAdd(code, ptn) != 1) {
  874. UpdateMessage( resource.me_non_memory );
  875. return;
  876. }
  877. edg.flag = ON;
  878. mode = ON;
  879. edlist.nptn++;
  880. }
  881. }
  882. if( ptnSense( edg.code ) == 1 ) {
  883. ptnAdd( edg.code, edg.ptn );
  884. }
  885. if(mode == ON) {
  886. chgEdCode( s_code, mode );
  887. }
  888. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  889. }
  890. void PopupDelNotice();
  891. Widget CreateDelNotice();
  892. void
  893. DoDelProc( int s_code, int e_code )
  894. {
  895. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  896. if( ptnSense( edg.code) == 1 )
  897. ptnAdd( edg.code, edg.ptn );
  898. dn.s_ncode = codeToNo( s_code );
  899. dn.e_ncode = codeToNo( e_code );
  900. if (setRealDelArea(&dn.s_ncode, &dn.e_ncode, &dn.sq_start, &dn.sq_end) == -1) {
  901. DispMngErrorMessage( resource.me_nodelete_code );
  902. return;
  903. }
  904. dn.sq_top = dn.sq_start;
  905. dn.disp_num = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
  906. dn.disp_num = (dn.disp_num <= D_MAX) ? dn.disp_num : D_MAX;
  907. PopupDelNotice( mngPtnW );
  908. }
  909. /*
  910. * contents : get the real range to be add or delete
  911. */
  912. static int
  913. setRealDelArea(int *s_ncode, int *e_ncode, int *sq_start, int *sq_end )
  914. {
  915. int ncode;
  916. int flg;
  917. int sq;
  918. int i;
  919. /* first code */
  920. flg = 0;
  921. ncode = *e_ncode;
  922. for( i=*s_ncode ; i <= ncode ; i++ ) {
  923. if (((sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i)) == 0)) {
  924. flg = 1;
  925. break;
  926. }
  927. }
  928. if (flg == 1) {
  929. *s_ncode = ptnSqToNo( sq );
  930. *sq_start = sq;
  931. } else {
  932. return(-1);
  933. }
  934. /* last code */
  935. flg = 0;
  936. ncode = *s_ncode;
  937. for( i=*e_ncode ; i >= ncode ; i-- ) {
  938. if ((( sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i) ) == 0)) {
  939. flg = 1;
  940. break;
  941. }
  942. }
  943. *e_ncode = ptnSqToNo( sq );
  944. *sq_end = sq;
  945. return(0);
  946. }
  947. /****************************************************************
  948. * callback routines (Copy) *
  949. ****************************************************************/
  950. static int
  951. CpySrcCodeCheck(void)
  952. {
  953. char *str;
  954. char delm;
  955. str = CpySrcCodeTfValue();
  956. if (!str)
  957. return(-1);
  958. if (!*str) {
  959. free(str);
  960. return(-1);
  961. }
  962. delm = '\0';
  963. cpm.s1_code = 0;
  964. cpm.s2_code = 0;
  965. sscanf( str, "%x %c %x", &cpm.s1_code,&delm, &cpm.s2_code );
  966. free( str );
  967. switch( delm ) {
  968. case '\0':
  969. cpm.s2_code = cpm.s1_code;
  970. break;
  971. case '-':
  972. break;
  973. default:
  974. return(-1);
  975. }
  976. if (cpm.s1_code > cpm.s2_code)
  977. return(-1);
  978. return(0);
  979. }
  980. static int
  981. CpyDestCodeCheck(void)
  982. {
  983. char *str;
  984. str = CpyDestCodeTfValue();
  985. if (!str)
  986. return(-1);
  987. if (!*str){
  988. free(str);
  989. return(-1);
  990. }
  991. cpm.d1_code = 0;
  992. sscanf( str, "%x", &cpm.d1_code );
  993. free( str );
  994. if( codeCheck(cpm.d1_code) ) {
  995. return(-1);
  996. }
  997. return(0);
  998. }
  999. Boolean
  1000. BeforeCpyCheck( int proc )
  1001. {
  1002. int s_ncode, e_ncode;
  1003. int r1_code, r2_code;
  1004. int no;
  1005. int i;
  1006. char rstr[30];
  1007. extern void PopupCpyNotice();
  1008. if (copyFontData.xlfdname == NULL) {
  1009. DispCpyErrorMessage(resource.me_non_srcfile);
  1010. return(False);
  1011. }
  1012. if (CpySrcCodeCheck() == -1){
  1013. DispCpyErrorMessage( resource.me_illegal_srccode );
  1014. return(False);
  1015. }
  1016. if (CpyDestCodeCheck() == -1){
  1017. DispCpyErrorMessage( resource.me_illegal_destcode );
  1018. return(False);
  1019. }
  1020. s_ncode = codeToNo( cpm.d1_code );
  1021. e_ncode = codeToNo( cpm.d1_code + cpm.s2_code - cpm.s1_code);
  1022. r1_code = r2_code = 0;
  1023. for( i=s_ncode ; i <= e_ncode ; i++ ) {
  1024. no = ptnSqToNo(i);
  1025. if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) {
  1026. if(r1_code == 0)
  1027. r1_code = noToCode(i);
  1028. r2_code = noToCode(i);
  1029. }
  1030. }
  1031. cpm.proc = proc;
  1032. if( r1_code != 0 ) {
  1033. if( r1_code == r2_code ) {
  1034. sprintf( rstr, "%s %x¡¡", resource.l_code, r1_code );
  1035. } else if ( codeCheck(r1_code) && codeCheck(r2_code)){
  1036. sprintf( rstr, " %x - %x", r1_code, r2_code );
  1037. } else {
  1038. sprintf( rstr, "%s %x - %x ", resource.l_code_range, r1_code, r2_code );
  1039. }
  1040. PopupCpyNotice(rstr);
  1041. return(False);
  1042. }
  1043. return(True);
  1044. }
  1045. void
  1046. DoCpyProc(void)
  1047. {
  1048. extern void PopdownCpyPtn();
  1049. PopdownCpyPtn();
  1050. resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
  1051. copyPatterns( cpm.fdata, cpm.s1_code, cpm.s2_code, cpm.d1_code, cpm.proc );
  1052. }
  1053. /****************************************************************
  1054. * main routine *
  1055. ****************************************************************/
  1056. #define R(name, class, member,def) { \
  1057. name, \
  1058. class, \
  1059. XtRString, \
  1060. sizeof(char *), \
  1061. XtOffsetOf(Resource, member), \
  1062. XtRString, \
  1063. (XtPointer)def }
  1064. #define RBoolean(name, class, member,def) \
  1065. { name, class, XtRBoolean, sizeof(XtRBoolean), \
  1066. XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
  1067. #define RDimension(name, class, member,def) \
  1068. { name, class, XtRDimension, sizeof(XtRDimension), \
  1069. XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
  1070. #define Rint(name, class, member,def) \
  1071. { name, class, XtRInt, sizeof(XtRInt), \
  1072. XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
  1073. #define RPixel(name, class, member,def) \
  1074. { name, class, XtRPixel, sizeof(XtRPixel), \
  1075. XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
  1076. static XtResource app_resources[] = {
  1077. RBoolean("Codepoint", "codepoint", codepoint, "False"),
  1078. R( "lptog", "Lptog", l_ptog, DFLTPATH ),
  1079. R( "lptogCmd", "LptogCmd", l_ptog_cmd, DFLTCMD ),
  1080. /* CreateCaptionFrame() */
  1081. RBoolean( "captResize", "CaptResize", capt_resize, "True" ) ,
  1082. Rint( "captLftoff", "CaptLftoff", capt_lftoff, "2" ) ,
  1083. Rint( "captTopoff", "CaptTopoff", capt_topoff, "2" ) ,
  1084. Rint( "captRghoff", "CaptRghoff", capt_rghoff, "2" ) ,
  1085. RPixel( "paneBackground", "paneBackground", pane_background, "white" ),
  1086. RPixel( "paneForeground", "PaneForeground", pane_foreground, "black" ),
  1087. RPixel( "background", "Background", background, "white" ),
  1088. RPixel( "foreground", "Foreground", foreground, "black" ),
  1089. /* CreateMenuButtons() */
  1090. RDimension( "menuMargin", "MenuMargin", menu_margin, "0" ) ,
  1091. /* CreateDialogAndButtons() */
  1092. RBoolean( "diaTmAutomng", "DiaTmAutomng", dia_tm_automng, "False" ) ,
  1093. RDimension( "diaTmWidth", "DiaTmWidth", dia_tm_width, "4" ) ,
  1094. RDimension( "diaTmHeight", "DiaTmHeight", dia_tm_height, "4" ) ,
  1095. RBoolean( "diaTmResize", "DiaTmResize", dia_tm_resize, "True" ) ,
  1096. RBoolean( "diaTmMinimize", "DiaTmMinimize", dia_tm_minimize, "True" ) ,
  1097. RDimension( "diaRwWidth", "DiaRwWidth", dia_rw_width, "6" ) ,
  1098. RDimension( "diaRwHeight", "DiaRwHeight", dia_rw_height, "6" ) ,
  1099. RDimension( "diaRwSpacing", "DiaRwSpacing", dia_rw_spacing, "4" ) ,
  1100. /* CreateDrawingArea() */
  1101. RDimension( "drawBorder", "DrawBorder", draw_border, "1" ) ,
  1102. Rint( "drawTopoff", "DrawTopoff", draw_topoff, "2" ) ,
  1103. Rint( "drawLftoff", "DrawLftoff", draw_lftoff, "2" ) ,
  1104. /* PopupNotice() */
  1105. RBoolean( "popResize", "PopResize", pop_resize , "True" ) ,
  1106. RBoolean( "popMinimize", "PopMinimize", pop_minimize , "True" ) ,
  1107. /* CreateTemplateDialog() */
  1108. RBoolean( "tempResize", "TempResize", temp_resize, "True" ) ,
  1109. RBoolean( "tempMinimize", "TempMinimize", temp_minimize, "True" ) ,
  1110. RDimension( "tempWidth", "TempWidth", temp_width, "1" ) ,
  1111. RDimension( "tempHeight", "TempHeight", temp_height, "1" ) ,
  1112. /* CreateMenuBarAndFooterMessageForm() */
  1113. Rint( "edBarTopoff", "EdBarTopoff", ed_bar_topoff, "1" ) ,
  1114. Rint( "edBarLftoff", "EdBarLftoff", ed_bar_lftoff, "1" ) ,
  1115. Rint( "edBarRghoff", "EdBarRghoff", ed_bar_rghoff, "1" ) ,
  1116. Rint( "edFrmBtmoff", "EdFrmBtmoff", ed_frm_btmoff, "3" ) ,
  1117. Rint( "edFrmLftoff", "EdFrmLftoff", ed_frm_lftoff, "3" ) ,
  1118. Rint( "edFrmRghoff", "EdFrmRghoff", ed_frm_rghoff, "3" ) ,
  1119. RDimension( "edMsgMargintop", "EdMsgMargintop", ed_msg_margintop, "3" ) ,
  1120. RDimension( "edMsgMarginbtm", "EdMsgMarginbtm", ed_msg_marginbtm, "3" ) ,
  1121. RDimension( "edMesgMargintop", "EdMesgMargintop", ed_mesg_margintop, "3" ) ,
  1122. RDimension( "edMesgMarginbtm", "EdMesgMarginbtm", ed_mesg_marginbtm, "3" ) ,
  1123. Rint( "edSepBtmoff", "EdSepBtmoff", ed_sep_btmoff, "3" ) ,
  1124. Rint( "edSepLftoff", "EdSepLftoff", ed_sep_lftoff, "0" ) ,
  1125. Rint( "edSepRghoff", "EdSepRghoff", ed_sep_rghoff, "0" ) ,
  1126. RDimension( "edSepMargin", "EdSepMargin", ed_sep_margin, "0" ) ,
  1127. Rint( "edWgeTopoff", "EdWgeTopoff", ed_wge_topoff, "10" ) ,
  1128. Rint( "edWgeLftoff", "EdWgeLftoff", ed_wge_lftoff, "10" ) ,
  1129. Rint( "edWgeRghoff", "EdWgeRghoff", ed_wge_rghoff, "10" ) ,
  1130. Rint( "edWgeBtmoff", "EdWgeBtmoff", ed_wge_btmoff, "10" ) ,
  1131. /* CreateFrame() */
  1132. RBoolean( "frameResize", "FrameResize", frame_resize, "False" ) ,
  1133. /* CreateScrollBase() */
  1134. RDimension( "scllFrWidth", "ScllFrWidth", scll_fr_width, "500" ) ,
  1135. RDimension( "scllFrThick", "ScllFrThick", scll_fr_thick, "2" ) ,
  1136. Rint( "scllBarLftoff", "ScllBarLftoff", scll_bar_lftoff, "4" ) ,
  1137. };
  1138. #undef R
  1139. #undef RBoolean
  1140. #undef RDimension
  1141. #undef Rint
  1142. #undef RPixel
  1143. int CodePoint = False;
  1144. /*ARGSUSED*/
  1145. static void
  1146. xerror(Display *d, XErrorEvent *ev)
  1147. {
  1148. fprintf (stderr, "dtudcfonted: warning, error event receieved.\n");
  1149. exit(-1);
  1150. }
  1151. int
  1152. main(int argc, char *argv[])
  1153. {
  1154. static char class_name[] = "Dtudcfonted";
  1155. int i;
  1156. /* initialize GUI */
  1157. toplevel = GuiInitialize(&app, class_name, &argc, argv);
  1158. /* get application's resources */
  1159. XtGetApplicationResources( toplevel, &resource,
  1160. app_resources, XtNumber(app_resources), NULL, 0);
  1161. if (resource.codepoint)
  1162. CodePoint = True;
  1163. /* initialize the code range */
  1164. for( i=1 ; i < argc ; i++ ) {
  1165. if( !strcmp(argv[i],"-pane_size") ) {
  1166. i++;
  1167. edpane_size = atoi( argv[i] );
  1168. } else if( !strcmp(argv[i],"-codepoint") ) {
  1169. CodePoint = True;
  1170. }
  1171. }
  1172. resource.mg_write_snf = GETMESSAGE(2, 2, "Registration processing inside.");
  1173. resource.me_write_snf = GETMESSAGE(2, 4, "Failed in the registration of the character.");
  1174. resource.me_illegal_code = GETMESSAGE(2, 6, "Illegal code.");
  1175. resource.me_non_memory = GETMESSAGE(2, 8, "Because the memory allocation cannot be done, it is not possible to add.");
  1176. resource.mg_non_code = GETMESSAGE(2, 10, "There is no character of the specified code.");
  1177. resource.me_illegal_srccode = GETMESSAGE(2, 12, "The mistake is found in the specified copy origin code.");
  1178. resource.me_illegal_destcode = GETMESSAGE(2, 14, "The mistake is found in the specified copy target code.");
  1179. resource.me_nodelete_code = GETMESSAGE(2, 16, "There is no character in the specified area.");
  1180. resource.me_wait = GETMESSAGE(2, 18, "Please wait for a while.");
  1181. resource.me_non_srcfile = GETMESSAGE(2, 20, "No copy origin code file is specified.");
  1182. resource.mn_no_font = GETMESSAGE(2, 22, "Informations of user defined character cannot collect.\nThere is no font specified.");
  1183. resource.mn_plural_font = GETMESSAGE(2, 24, "Informations of user defined character cannot collect.\nThere are plural fonts specified.");
  1184. resource.mn_not_udc = GETMESSAGE(2, 26, "The specified font do not have any UDCs areas.");
  1185. resource.mn_no_mem = GETMESSAGE(2, 28, "There are no memories any more.");
  1186. resource.mn_illegal_area = GETMESSAGE(2, 30, "The information of UDCs area is illegal.");
  1187. resource.mn_no_read = GETMESSAGE(2, 32, "The font file cannot read.\nPattern area was broken.");
  1188. resource.mn_prop_font = GETMESSAGE(2, 34, "Dtudcfonted cannot edit proportional character font.");
  1189. resource.mn_saved_open = GETMESSAGE(2, 36, "There are unsaved edits.\nDo you want to save them before opening?");
  1190. resource.mn_saved_exit = GETMESSAGE(2, 38, "There are unsaved edits.\nDo you want to save them before exiting?");
  1191. resource.mn_cpy_lost = GETMESSAGE(2, 40, "When the copy processing is done, the glyph\nimage within the following ranges is changed.\nDo you want to do the copy processing?\n\n");
  1192. resource.mn_no_perm = GETMESSAGE(2, 42, "No write permission for this font. You should change the file access mode before saving.\n");
  1193. resource.l_selectitem = GETMESSAGE(2, 100, "Select Items"); /* font open */
  1194. resource.l_codeset = GETMESSAGE(2, 102, " CodeSet:");
  1195. resource.l_style = GETMESSAGE(2, 104, " Style:");
  1196. resource.l_width = GETMESSAGE(2, 106, " Width:");
  1197. resource.l_height = GETMESSAGE(2, 108, " Height:");
  1198. resource.exec_label = GETMESSAGE(2, 110, "Open");
  1199. resource.quit_label = GETMESSAGE(2, 112, "Quit");
  1200. resource.l_font = GETMESSAGE(2, 114, "Font"); /* menu bar */
  1201. resource.l_edit = GETMESSAGE(2, 116, "Edit");
  1202. resource.l_manage = GETMESSAGE(2, 118, "Character");
  1203. resource.l_info = GETMESSAGE(2, 120, "Information");
  1204. resource.l_open_w = GETMESSAGE(2, 122, "Open"); /* font menu */
  1205. resource.l_save = GETMESSAGE(2, 124, "Save");
  1206. resource.l_exit = GETMESSAGE(2, 126, "Exit");
  1207. resource.l_clear = GETMESSAGE(2, 128, "Clear"); /* edit menu */
  1208. resource.l_set = GETMESSAGE(2, 130, "Set");
  1209. resource.l_reverse = GETMESSAGE(2, 132, "Reverse");
  1210. resource.l_cut = GETMESSAGE(2, 134, "Cut");
  1211. resource.l_Copy = GETMESSAGE(2, 135, "Copy");
  1212. resource.l_paste = GETMESSAGE(2, 136, "Paste");
  1213. resource.l_roll = GETMESSAGE(2, 138, "Rotate");
  1214. resource.l_updown_roll = GETMESSAGE(2, 140, "Vertical Roll");
  1215. resource.l_leftright_roll = GETMESSAGE(2, 142, "Horizontal Roll");
  1216. resource.l_undo = GETMESSAGE(2, 144, "Undo");
  1217. resource.l_manage_w = GETMESSAGE(2, 146, "Add/Delete..."); /* character menu */
  1218. resource.l_copy_w = GETMESSAGE(2, 148, "Copy...");
  1219. resource.l_xlfd = GETMESSAGE(2, 150, "XLFD name..."); /* information menu */
  1220. resource.l_codearea = GETMESSAGE(2, 152, "Code Area...");
  1221. resource.l_add = GETMESSAGE(2, 154, "Add"); /* add/delete dialog */
  1222. resource.l_delete = GETMESSAGE(2, 156, "Delete");
  1223. resource.l_cancel = GETMESSAGE(2, 158, "Cancel");
  1224. resource.l_manage_code = GETMESSAGE(2, 160, "Code(hex):"); /* copy dialog */
  1225. resource.l_copy_src_code = GETMESSAGE(2, 162, " Copy origin code(hex):");
  1226. resource.l_copy_dest_code = GETMESSAGE(2, 164, "Copy target code(hex):");
  1227. resource.l_copy = GETMESSAGE(2, 166, "Copy");
  1228. resource.l_overlay = GETMESSAGE(2, 168, "Overlay");
  1229. resource.l_ok = GETMESSAGE(2, 170, "OK");
  1230. resource.l_do_save = GETMESSAGE(2, 172, "Save"); /* unsaved edits */
  1231. resource.l_dont_save = GETMESSAGE(2, 174, "Do not Save");
  1232. resource.l_do_save_exit = GETMESSAGE(2, 176, "Save and Exit");
  1233. resource.l_dont_save_exit = GETMESSAGE(2, 178, "Do not Save and Exit");
  1234. resource.mg_start_del_s = GETMESSAGE(2, 180, "The following character will be deleted."); /* delete notice dialog */
  1235. resource.mg_start_del_cs = GETMESSAGE(2, 182, "character");
  1236. resource.mg_start_del_m = GETMESSAGE(2, 184, "The following characters will be deleted.");
  1237. resource.mg_start_del_cm = GETMESSAGE(2, 186, "characters");
  1238. resource.mg_register = GETMESSAGE(2, 188, "Register completed");
  1239. resource.l_code = GETMESSAGE(2, 190, " Code : ");
  1240. resource.l_code_range = GETMESSAGE(2, 192, " Code range : ");
  1241. resource.message = GETMESSAGE(2, 194, "Message : ");
  1242. resource.code = GETMESSAGE(2, 196, "code..."); /* code dialog */
  1243. resource.previous = GETMESSAGE(2, 198, "Page up");
  1244. resource.next = GETMESSAGE(2, 200, "Page down");
  1245. resource.apply = GETMESSAGE(2, 202, "Apply");
  1246. resource.l_question_title = GETMESSAGE(2, 204, "dtudcfonted - Question");
  1247. resource.l_warning_title = GETMESSAGE(2, 206, "dtudcfonted - Warning");
  1248. resource.l_error_title = GETMESSAGE(2, 208, "dtudcfonted - Error");
  1249. resource.l_copy_title = GETMESSAGE(2, 210, "dtudcfonted - Copy");
  1250. resource.l_open_title = GETMESSAGE(2, 212, "dtudcfonted - Open");
  1251. resource.l_add_title = GETMESSAGE(2, 214, "dtudcfonted - Add/Delete");
  1252. resource.l_xlfd_title = GETMESSAGE(2, 216, "dtudcfonted - XLFD");
  1253. resource.l_codearea_title = GETMESSAGE(2, 218, "dtudcfonted - CodeArea");
  1254. resource.file_name = GETMESSAGE(2, 230, "File name");
  1255. resource.xlfd_name = GETMESSAGE(2, 232, "XLFD name");
  1256. resource.codearea = GETMESSAGE(2, 234, "Code area");
  1257. resource.falerrmsg[0] = GETMESSAGE(2, 300, "Fatal error occurred.");
  1258. resource.falerrmsg[1] = GETMESSAGE(2, 301, "Cannot open the font file.");
  1259. resource.falerrmsg[2] = GETMESSAGE(2, 302, "Cannot read the font file.");
  1260. resource.falerrmsg[3] = GETMESSAGE(2, 303, "There is no more memory.");
  1261. resource.falerrmsg[4] = GETMESSAGE(2, 304, "Fatal error occurred.");
  1262. resource.falerrmsg[5] = GETMESSAGE(2, 305, "The specified font file does not exist.");
  1263. resource.falerrmsg[6] = GETMESSAGE(2, 306, "This font is not a pcf or snf font.");
  1264. resource.falerrmsg[7] = GETMESSAGE(2, 307, "Cannot open fonts.list file.");
  1265. resource.falerrmsg[8] = GETMESSAGE(2, 308, "The format of fonts.list file is illegal.");
  1266. resource.falerrmsg[9] = GETMESSAGE(2, 309, "The descriptions of the fonts.list file are incorrect.");
  1267. resource.falerrmsg[10] = GETMESSAGE(2, 310, "The format of fonts.list file is illegal.");
  1268. resource.falerrmsg[11] = GETMESSAGE(2, 311, "Cannot open fonts.dir file.");
  1269. resource.falerrmsg[12] = GETMESSAGE(2, 312, "Cannot read fonts.dir file.");
  1270. resource.falerrmsg[13] = GETMESSAGE(2, 313, "Cannot read font properties.");
  1271. resource.falerrmsg[14] = GETMESSAGE(2, 314, "Cannot get FONT property.");
  1272. resource.falerrmsg[15] = GETMESSAGE(2, 315, "Cannot get FAMILY_NAME property.");
  1273. resource.falerrmsg[16] = GETMESSAGE(2, 316, "This font file is already opened by other application.");
  1274. resource.falerrmsg[17] = GETMESSAGE(2, 317, "Cannot lock font file.");
  1275. resource.falerrmsg[18] = GETMESSAGE(2, 318, "Cannot unlock font file.");
  1276. resource.falerrmsg[19] = GETMESSAGE(2, 319, "Cannot get lock information from the font file.");
  1277. resource.falerrmsg[20] = GETMESSAGE(2, 320, "Cannot find the specified font file.");
  1278. resource.falerrmsg[21] = GETMESSAGE(2, 321, "Cannot read NLS database.");
  1279. resource.falerrmsg[22] = GETMESSAGE(2, 322, "Cannot get charset names from NLS database.");
  1280. resource.falerrmsg[23] = GETMESSAGE(2, 323, "Charset name not defined in NLS database.");
  1281. resource.falerrmsg[24] = GETMESSAGE(2, 324, "The specified font has not been opened.");
  1282. resource.falerrmsg[25] = GETMESSAGE(2, 325, "Fatal error occurred.");
  1283. xlfdDialog = NULL ;
  1284. cpyDialog = NULL ;
  1285. /* initialize the global values and allocate the memories */
  1286. xeg_init();
  1287. /* displays the selection window */
  1288. PopupSelectXLFD(toplevel);
  1289. XSetErrorHandler((XErrorHandler)xerror);
  1290. XSetIOErrorHandler((XIOErrorHandler)xerror);
  1291. /* main loop */
  1292. XtAppMainLoop(app);
  1293. return(-1);
  1294. }
  1295. /*
  1296. * contents : initialize the global values
  1297. */
  1298. static void
  1299. xeg_init(void)
  1300. {
  1301. int i;
  1302. edg.code = edg.ncode = 0;
  1303. bitPtnClear( edg.ptn );
  1304. edg.flag = (char)0;
  1305. edlist.nlist = EDLIST_MAX;
  1306. edlist.statloc = edlist.slctloc = 0;
  1307. edlist.nptn = 0;
  1308. edlist.sqstart = 0;
  1309. edlist.list_h = edlist.elem_w = edlist.elem_h = (Dimension)0;
  1310. edlist.back = resource.pane_background;
  1311. edlist.border = resource.pane_foreground;
  1312. if ( edpane_size ){
  1313. edpane.width = edpane_size;
  1314. edpane.height = edpane_size;
  1315. } else {
  1316. edpane.width = EDPANE_SIZE;
  1317. edpane.height = EDPANE_SIZE;
  1318. }
  1319. edpane.pix_w = edpane.pix_h = 0;
  1320. edpane.color = 0;
  1321. edpane.obj = 0;
  1322. edpane.back = resource.pane_background;
  1323. edpane.border = resource.pane_foreground;
  1324. xl.display = NULL;
  1325. xl.root_winID = xl.edit_winID = xl.disp_winID = xl.list_winID =
  1326. (Window)NULL;
  1327. xl.borderGC = xl.backGC = xl.rubGC = xl.dashGC = (GC)NULL;
  1328. xl.dispImage = NULL;
  1329. dn.elem_w = dn.elem_h = (Dimension)0;
  1330. dn.ptn_w = dn.ptn_h = (Dimension)0;
  1331. dn.list_h = (Dimension)0;
  1332. dn.s_ncode = dn.e_ncode = 0;
  1333. dn.sq_top = dn.sq_start = dn.sq_end = 0;
  1334. dn.disp_num = 0;
  1335. for ( i=0 ; i<D_MAX ; i++ ) {
  1336. dl[i].disp_winID = (Window)NULL;
  1337. dl[i].dispImage = NULL;
  1338. bitPtnClear( dl[i].ptn );
  1339. }
  1340. for ( i=0 ; i<EDLIST_MAX ; i++ ) {
  1341. dl_glyph[i].disp_winID = (Window)NULL;
  1342. dl_glyph[i].dispImage = NULL;
  1343. bitPtnClear( dl_glyph[i].ptn );
  1344. sq_disp[i] = 0 ;
  1345. }
  1346. em.drag_f = OFF;
  1347. em.adj_px = em.adj_py = 0;
  1348. em.proc = em.slct_f = 0;
  1349. em.src1_px = em.src1_py = 0;
  1350. em.src2_px = em.src2_py = 0;
  1351. em.dest_px = em.dest_py = 0;
  1352. em.rsv_f = (char)0;
  1353. bitPtnClear( em.rsv_ptn );
  1354. cpm.s1_code = cpm.s2_code = cpm.d1_code = 0;
  1355. cpm.proc = 0;
  1356. return;
  1357. }
  1358. /****************************************************************
  1359. * distroy the "User defined character editor" window *
  1360. ****************************************************************/
  1361. /*
  1362. * contents : destroy the editting window
  1363. */
  1364. static void
  1365. dstrypaneEditPtn(void)
  1366. {
  1367. int i ;
  1368. ptnClose();
  1369. XFree( (char *)xl.dispImage );
  1370. XFreeGC( xl.display, xl.borderGC );
  1371. XFreeGC( xl.display, xl.backGC );
  1372. XFreeGC( xl.display, xl.rubGC );
  1373. XFreeGC( xl.display, xl.dashGC );
  1374. for( i=0; i<EDLIST_MAX; i++ ){
  1375. if( dl_glyph[i].dispImage ){
  1376. XFree( (char *)dl_glyph[i].dispImage );
  1377. dl_glyph[i].dispImage = NULL ;
  1378. }
  1379. }
  1380. XtPopdown( editPopW );
  1381. XtDestroyWidget( editPopW );
  1382. return;
  1383. }
  1384. /****************************************************************
  1385. * update character list *
  1386. ***************************************************************/
  1387. /*
  1388. * contents : add the specified code to the character list
  1389. */
  1390. void
  1391. chgEdCode( int code, char mode )
  1392. {
  1393. int ncode;
  1394. int esq;
  1395. int statloc;
  1396. int slctloc;
  1397. int slimax;
  1398. if( code == 0 ) {
  1399. esq = -1;
  1400. } else {
  1401. ncode = codeToNo( code );
  1402. esq = ptnNoToSq( ncode ) - edlist.sqstart;
  1403. }
  1404. if( esq < 0 ) {
  1405. slctloc = -1;
  1406. statloc = 0;
  1407. } else if (efctPtnNum() <= edlist.nlist) {
  1408. statloc = 0;
  1409. slctloc = AbsSqToRel(edlist.sqstart, ptnNoToSq( ncode));
  1410. } else {
  1411. if ((esq >= edlist.statloc)
  1412. && (esq <= (RelToAbsSq( edlist.sqstart + edlist.statloc,
  1413. edlist.nlist - 1) - edlist.sqstart))){
  1414. statloc = edlist.statloc;
  1415. slctloc = AbsSqToRel(edlist.sqstart+statloc,
  1416. edlist.sqstart + esq);
  1417. } else {
  1418. statloc = esq;
  1419. slctloc = 0;
  1420. }
  1421. while( RelToAbsSq(edlist.sqstart+statloc, edlist.nlist - 1) < 0)
  1422. statloc = RelToAbsSq( edlist.sqstart + statloc, -1)
  1423. - edlist.sqstart;
  1424. slctloc = AbsSqToRel( edlist.sqstart + statloc, edlist.sqstart + esq);
  1425. }
  1426. n = 0;
  1427. if (( slimax = efctPtnNum()) < edlist.nlist)
  1428. slimax = edlist.nlist;
  1429. XtSetArg( arg[n], XmNmaximum, (XtArgVal)slimax ); n++;
  1430. XtSetArg( arg[n], XmNvalue, (XtArgVal)AbsSqToRel( edlist.sqstart, edlist.sqstart + statloc) ); n++;
  1431. XtSetValues( wgeScro , arg, n );
  1432. chgEdList( statloc, slctloc, mode );
  1433. chgEdPtn( code );
  1434. }
  1435. /*
  1436. * contents : rewrite the character list
  1437. */
  1438. void
  1439. chgEdList( int statloc, int slctloc, char mode )
  1440. {
  1441. int sq;
  1442. int i;
  1443. char str[6];
  1444. int no;
  1445. int code;
  1446. extern void ListSetLabelStr();
  1447. extern void ListSetGlyphImage();
  1448. extern void ListUnselectItem();
  1449. extern void ListSelectItem();
  1450. if((mode == ON) || (edlist.statloc != statloc)){
  1451. for (i=0, sq=edlist.sqstart+statloc; i < edlist.nlist; sq++){
  1452. no = ptnSqToNo(sq);
  1453. sq_disp[i] = sq ;
  1454. if ((no >= 0) && (code = noToCode(no)) >= 0 ){
  1455. sprintf(str, "%4x", code);
  1456. ListSetLabelStr(i, str);
  1457. ListSetGlyphImage(i) ;
  1458. if (i == 0)
  1459. edlist.statloc = sq - edlist.sqstart;
  1460. i++;
  1461. } else if (sq > ( edlist.sqstart + edlist.nptn - 1)){
  1462. strcpy(str, " ");
  1463. ListSetLabelStr(i, str);
  1464. ListSetGlyphImage(i) ;
  1465. i++;
  1466. }
  1467. }
  1468. }
  1469. if( (mode == ON) || (edlist.slctloc != slctloc) ) {
  1470. if((0 <= edlist.slctloc) && (edlist.slctloc < edlist.nlist)){
  1471. ListUnselectItem(edlist.slctloc);
  1472. }
  1473. if((0 <= slctloc) && (slctloc < edlist.nlist)){
  1474. ListSelectItem(slctloc);
  1475. }
  1476. edlist.slctloc = slctloc;
  1477. }
  1478. }
  1479. /*
  1480. * contents : rewrite the editting pane
  1481. */
  1482. static void
  1483. chgEdPtn( int code )
  1484. {
  1485. extern void SetCodeString();
  1486. if (xl.display == NULL ){
  1487. return;
  1488. }
  1489. if( code == 0 ) {
  1490. XClearWindow( xl.display, xl.edit_winID );
  1491. DrawBorderEdPn( 0, 0, edg.width - 1, edg.height - 1 );
  1492. XClearWindow( xl.display, xl.disp_winID );
  1493. XClearWindow( xl.display, xl.list_winID );
  1494. bitPtnClear( edg.ptn );
  1495. edg.code = 0;
  1496. edg.ncode = 0;
  1497. SetCodeString(0);
  1498. }
  1499. if( ptnGet( code, edg.ptn) == 0 ) {
  1500. edg.code = code;
  1501. edg.ncode = codeToNo( code );
  1502. DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
  1503. SetCodeString(code);
  1504. DrawDpPn();
  1505. }
  1506. }
  1507. /****************************************************************
  1508. * draw patterns to the editting pane *
  1509. ***************************************************************/
  1510. /*
  1511. * contents : draw a rectangle
  1512. *
  1513. */
  1514. static void
  1515. DrawRectEdPn( int x1, int y1, int x2, int y2 )
  1516. {
  1517. int i, j, wk;
  1518. short cx1, cy1, cx2, cy2;
  1519. XRectangle recOn[MAXPTNSIZE*MAXPTNSIZE];
  1520. XRectangle recOff[MAXPTNSIZE*MAXPTNSIZE];
  1521. int nron, nroff;
  1522. if (xl.display == NULL ){
  1523. return;
  1524. }
  1525. if( x2 < x1 ) {
  1526. wk = x2;
  1527. x2 = x1;
  1528. x1 = wk;
  1529. }
  1530. if( y2 < y1 ) {
  1531. wk = y2;
  1532. y2 = y1;
  1533. y1 = wk;
  1534. }
  1535. nron = nroff = 0;
  1536. for( j=y1 ; j <= y2 ; j++ ) {
  1537. for( i=x1 ; i <= x2 ; i++ ) {
  1538. cx1 = (short)(edpane.pix_w * i);
  1539. cy1 = (short)(edpane.pix_h * j);
  1540. cx2 = (short)(cx1 + edpane.pix_w - 1);
  1541. cy2 = (short)(cy1 + edpane.pix_h - 1);
  1542. if( bitRead( edg.ptn, i, j ) != 0 ) {
  1543. recOn[nron].x = cx1;
  1544. recOn[nron].y = cy1;
  1545. recOn[nron].width = (unsigned short)(cx2 - cx1);
  1546. recOn[nron].height = (unsigned short)(cy2 - cy1);
  1547. nron++;
  1548. }
  1549. else {
  1550. recOff[nroff].x = cx1;
  1551. recOff[nroff].y = cy1;
  1552. recOff[nroff].width = (unsigned short)(cx2 - cx1);
  1553. recOff[nroff].height = (unsigned short)(cy2 - cy1);
  1554. nroff++;
  1555. }
  1556. }
  1557. }
  1558. if( nron )
  1559. XFillRectangles( xl.display, xl.edit_winID, xl.borderGC, recOn, nron );
  1560. if( nroff )
  1561. XFillRectangles( xl.display, xl.edit_winID, xl.backGC, recOff, nroff );
  1562. }
  1563. /*
  1564. * contents : draw a lattice inside of the editting pane
  1565. */
  1566. static void
  1567. DrawBorderEdPn( int x1, int y1, int x2, int y2 )
  1568. {
  1569. short cx1, cy1;
  1570. short cx2, cy2;
  1571. int ndseg;
  1572. int wk, i;
  1573. XSegment dseg[MAXPTNSIZE*2];
  1574. if (xl.display == NULL ){
  1575. return;
  1576. }
  1577. if( x2 < x1 ) {
  1578. wk = x2;
  1579. x2 = x1;
  1580. x1 = wk;
  1581. }
  1582. if( y2 < y1 ) {
  1583. wk = y2;
  1584. y2 = y1;
  1585. y1 = wk;
  1586. }
  1587. ndseg = 0;
  1588. cx1 = (short)(edpane.pix_w * x1);
  1589. cx2 = (short)(edpane.pix_w * x2 + edpane.pix_w - 1);
  1590. for( i=y1 ; i <= y2 ; i++ ) {
  1591. cy1 = (short)(edpane.pix_h * i + edpane.pix_h - 1);
  1592. dseg[ndseg].x1 = cx1;
  1593. dseg[ndseg].y1 = cy1;
  1594. dseg[ndseg].x2 = cx2;
  1595. dseg[ndseg].y2 = cy1;
  1596. ndseg++;
  1597. }
  1598. cy1 = (short)(edpane.pix_h * y1);
  1599. cy2 = (short)(edpane.pix_h * y2 + edpane.pix_h - 1);
  1600. for( i=x1 ; i <= x2 ; i++ ) {
  1601. cx1 = (short)(edpane.pix_w * i + edpane.pix_w - 1);
  1602. dseg[ndseg].x1 = cx1;
  1603. dseg[ndseg].y1 = cy1;
  1604. dseg[ndseg].x2 = cx1;
  1605. dseg[ndseg].y2 = cy2;
  1606. ndseg++;
  1607. }
  1608. if( ndseg ) {
  1609. XDrawSegments( xl.display, xl.edit_winID, xl.dashGC, dseg, ndseg);
  1610. }
  1611. }
  1612. /*
  1613. * contents : draw a dot
  1614. */
  1615. static void
  1616. DrawPointEdPn( int x, int y, int mode )
  1617. {
  1618. int x1, y1;
  1619. int x2, y2;
  1620. if (xl.display == NULL ){
  1621. return;
  1622. }
  1623. x1 = edpane.pix_w * x;
  1624. y1 = edpane.pix_h * y;
  1625. x2 = x1 + edpane.pix_w - 1;
  1626. y2 = y1 + edpane.pix_h - 1;
  1627. if( mode != 0 ) {
  1628. XFillRectangle( xl.display, xl.edit_winID, xl.borderGC,
  1629. x1, y1, x2-x1, y2-y1 );
  1630. } else {
  1631. XFillRectangle( xl.display, xl.edit_winID, xl.backGC,
  1632. x1, y1, x2-x1, y2-y1 );
  1633. }
  1634. }
  1635. /*
  1636. * contents : draw a current character pattern to the display pane
  1637. */
  1638. static void
  1639. DrawDpPn(void)
  1640. {
  1641. if (xl.display == NULL ){
  1642. return;
  1643. }
  1644. XPutImage( xl.display, xl.disp_winID, xl.borderGC, xl.dispImage,
  1645. 0, 0, 0, 0, edg.width, edg.height );
  1646. if( xl.list_winID ) {
  1647. XPutImage( xl.display, xl.list_winID, xl.borderGC,
  1648. xl.dispImage, 0, 0, 0, 0, edg.width, edg.height );
  1649. }
  1650. }
  1651. /*
  1652. * contents : draw a dot
  1653. */
  1654. static void
  1655. DrawPointDpPn( int x, int y, int mode )
  1656. {
  1657. if (xl.display == NULL ){
  1658. return;
  1659. }
  1660. if( mode != 0 ){
  1661. XDrawPoint( xl.display, xl.disp_winID, xl.borderGC, x, y );
  1662. if (xl.list_winID)
  1663. XDrawPoint( xl.display, xl.list_winID, xl.borderGC, x, y );
  1664. } else {
  1665. XDrawPoint( xl.display, xl.disp_winID, xl.backGC, x, y );
  1666. if (xl.list_winID)
  1667. XDrawPoint( xl.display, xl.list_winID, xl.backGC, x, y );
  1668. }
  1669. }
  1670. /****************************************************************
  1671. * draw patterns by mouse *
  1672. ****************************************************************/
  1673. /*
  1674. * contents : draw a dot
  1675. */
  1676. static void
  1677. musPoint( int evtype, int px, int py )
  1678. {
  1679. switch( evtype ) {
  1680. case MotionNotify:
  1681. if( (em.src1_px == px) && (em.src1_py == py) )
  1682. return;
  1683. break;
  1684. case ButtonPress:
  1685. em.src1_px = px;
  1686. em.src1_py = py;
  1687. break;
  1688. default:
  1689. return;
  1690. }
  1691. if( edpane.color == ON )
  1692. bitSet( edg.ptn, px, py );
  1693. else
  1694. bitReset( edg.ptn, px, py );
  1695. edg.flag = ON;
  1696. DrawPointEdPn( px, py, edpane.color );
  1697. DrawPointDpPn( px, py, edpane.color );
  1698. }
  1699. /*
  1700. * contents : draw a line
  1701. */
  1702. static void
  1703. musLine( int evtype, int px, int py )
  1704. {
  1705. int r1_x, r1_y;
  1706. int r2_x, r2_y;
  1707. int rx, ry;
  1708. int harf_pix_w;
  1709. int harf_pix_h;
  1710. harf_pix_w = edpane.pix_w / 2;
  1711. harf_pix_h = edpane.pix_h / 2;
  1712. r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
  1713. r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
  1714. r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
  1715. r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
  1716. rx = px * edpane.pix_w + harf_pix_w;
  1717. ry = py * edpane.pix_h + harf_pix_h;
  1718. switch( evtype ) {
  1719. case MotionNotify:
  1720. if( (em.src2_px == px) && (em.src2_py == py) )
  1721. return;
  1722. rubLine( r1_x, r1_y, r2_x, r2_y );
  1723. rubLine( r1_x, r1_y, rx, ry );
  1724. em.src2_px = px;
  1725. em.src2_py = py;
  1726. return;
  1727. case ButtonPress:
  1728. em.src1_px = em.src2_px = px;
  1729. em.src1_py = em.src2_py = py;
  1730. return;
  1731. default:
  1732. if( (r1_x == r2_x) && (r1_y == r2_y) )
  1733. return;
  1734. rubLine( r1_x, r1_y, r2_x, r2_y );
  1735. if ((em.src2_px < 0) || (em.src2_py < 0) ||
  1736. (edg.width <= em.src2_px) || (edg.height <= em.src2_py))
  1737. return;
  1738. bitDrawLine( edg.ptn, em.src1_px, em.src1_py,
  1739. em.src2_px, em.src2_py, edpane.color );
  1740. edg.flag = ON;
  1741. DrawRectEdPn( em.src1_px, em.src1_py, em.src2_px, em.src2_py );
  1742. DrawDpPn();
  1743. }
  1744. }
  1745. /*
  1746. * contents : draw a circle
  1747. */
  1748. static void
  1749. musCircle( int evtype, int px, int py )
  1750. {
  1751. int r1_x, r1_y;
  1752. int r2_x, r2_y;
  1753. int rx, ry;
  1754. int harf_pix_w;
  1755. int harf_pix_h;
  1756. extern int bitDrawCircle();
  1757. harf_pix_w = edpane.pix_w / 2;
  1758. harf_pix_h = edpane.pix_h / 2;
  1759. r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
  1760. r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
  1761. r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
  1762. r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
  1763. rx = px * edpane.pix_w + harf_pix_w;
  1764. ry = py * edpane.pix_h + harf_pix_h;
  1765. switch( evtype ) {
  1766. case MotionNotify:
  1767. if( (em.src2_px == px) && (em.src2_py == py) ) {
  1768. return;
  1769. }
  1770. rubCircle( r1_x, r1_y, r2_x, r2_y );
  1771. rubCircle( r1_x, r1_y, rx, ry );
  1772. em.src2_px = px;
  1773. em.src2_py = py;
  1774. return;
  1775. case ButtonPress:
  1776. em.src1_px = em.src2_px = px;
  1777. em.src1_py = em.src2_py = py;
  1778. return;
  1779. default:
  1780. if( (em.src1_px == px) && (em.src1_py == py) ) {
  1781. return;
  1782. }
  1783. rubCircle( r1_x, r1_y, r2_x, r2_y );
  1784. if( (px < 0) || (py < 0) || (edg.width <= px) || (edg.height <= py) ) {
  1785. return;
  1786. }
  1787. bitDrawCircle( edg.ptn, em.src1_px, em.src1_py, px, py, edpane.color);
  1788. edg.flag = ON;
  1789. DrawRectEdPn( 0, 0, edg.width -1, edg.height -1 );
  1790. DrawDpPn();
  1791. }
  1792. }
  1793. /*
  1794. * contents : draw a rectangle
  1795. */
  1796. static void
  1797. musRect( int proc, int evtype, int px, int py )
  1798. {
  1799. int r1_x, r1_y;
  1800. int r2_x, r2_y;
  1801. int rx, ry;
  1802. int lux, luy;
  1803. int width, height;
  1804. int dpx, dpy, dp;
  1805. if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
  1806. dpx = px - em.src1_px;
  1807. dpy = py - em.src1_py;
  1808. dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
  1809. if( dpx != 0 )
  1810. px = em.src1_px + dpx/abs(dpx) * dp;
  1811. if( dpy != 0 )
  1812. py = em.src1_py + dpy/abs(dpy) * dp;
  1813. }
  1814. r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
  1815. r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
  1816. r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
  1817. r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
  1818. rx = px * edpane.pix_w + edpane.pix_w / 2;
  1819. ry = py * edpane.pix_h + edpane.pix_h / 2;
  1820. switch( evtype ) {
  1821. case MotionNotify:
  1822. if( (em.src2_px == px) && (em.src2_py == py) )
  1823. return;
  1824. rubBand( r1_x, r1_y, r2_x, r2_y );
  1825. rubBand( r1_x, r1_y, rx, ry );
  1826. em.src2_px = px;
  1827. em.src2_py = py;
  1828. return;
  1829. case ButtonPress:
  1830. resetEditMode( RES_SLCT );
  1831. em.src1_px = em.src2_px = px;
  1832. em.src1_py = em.src2_py = py;
  1833. return;
  1834. default:
  1835. resetEditMode( RES_MSG | RES_PROC );
  1836. rubBand( r1_x, r1_y, r2_x, r2_y );
  1837. if( (r1_x == r2_x) || (r1_y == r2_y) )
  1838. return;
  1839. if( (em.src2_px < 0) || (em.src2_py < 0) ||
  1840. (edg.width <= em.src2_px) || (edg.height <= em.src2_py) )
  1841. return;
  1842. lux = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
  1843. luy = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
  1844. width = abs( em.src1_px - em.src2_px ) + 1;
  1845. height = abs( em.src1_py - em.src2_py ) + 1;
  1846. bitDrawRect(edg.ptn, lux, luy, width, height, edpane.color);
  1847. edg.flag = ON;
  1848. DrawRectEdPn( em.src1_px, em.src1_py, px, py );
  1849. DrawDpPn();
  1850. }
  1851. }
  1852. /*
  1853. * contents : edit inside of the specified area (clear, reverse, rotate,etc.)
  1854. */
  1855. static void
  1856. musRegionProc( int proc, int evtype, int px, int py )
  1857. {
  1858. int rx, ry;
  1859. int dpx, dpy, dp;
  1860. extern void SelectSet();
  1861. if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
  1862. dpx = px - em.src1_px;
  1863. dpy = py - em.src1_py;
  1864. dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
  1865. if( dpx != 0 )
  1866. px = em.src1_px + dpx/abs(dpx) * dp;
  1867. if( dpy != 0 )
  1868. py = em.src1_py + dpy/abs(dpy) * dp;
  1869. }
  1870. r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
  1871. r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
  1872. r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
  1873. r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
  1874. rx = px * edpane.pix_w + edpane.pix_w / 2;
  1875. ry = py * edpane.pix_h + edpane.pix_h / 2;
  1876. switch( evtype ) {
  1877. case MotionNotify:
  1878. if( (em.src2_px == px) && (em.src2_py == py) )
  1879. return;
  1880. rubBand( r1_x, r1_y, r2_x, r2_y );
  1881. rubBand( r1_x, r1_y, rx, ry );
  1882. em.src2_px = px;
  1883. em.src2_py = py;
  1884. return;
  1885. case ButtonPress:
  1886. if (select_x || select_y || select_w || select_h) {
  1887. rubBand( r1_x, r1_y, r2_x, r2_y );
  1888. }
  1889. resetEditMode( RES_SLCT );
  1890. em.src1_px = em.src2_px = px;
  1891. em.src1_py = em.src2_py = py;
  1892. return;
  1893. default:
  1894. resetEditMode( RES_MSG | RES_PROC );
  1895. select_x = select_y = select_w = select_h = 0;
  1896. if( (r1_x == r2_x) || (r1_y == r2_y) ) {
  1897. rubBand( r1_x, r1_y, r2_x, r2_y );
  1898. return;
  1899. }
  1900. if( (em.src2_px < 0) || (em.src2_py < 0) ||
  1901. (edg.width <= em.src2_px) || (edg.height <= em.src2_py) ) {
  1902. rubBand( r1_x, r1_y, r2_x, r2_y );
  1903. return;
  1904. }
  1905. select_x = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
  1906. select_y = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
  1907. select_w = abs( em.src1_px - em.src2_px ) + 1;
  1908. select_h = abs( em.src1_py - em.src2_py ) + 1;
  1909. SelectSet();
  1910. }
  1911. }
  1912. /*ARGSUSED*/
  1913. static void
  1914. #ifdef __linux__
  1915. musPasteProc(Widget w, XtPointer client_data, XEvent *event, Boolean* continue_to_dispatch)
  1916. #else
  1917. musPasteProc(Widget w, XtPointer client_data, XEvent *event)
  1918. #endif
  1919. {
  1920. static int ox=0, oy=0;
  1921. int rc, tx, ty;
  1922. extern void UndoSet();
  1923. extern Widget wgeBulB_edit;
  1924. extern int bitDrawPaste();
  1925. switch(event->type) {
  1926. case MotionNotify:
  1927. tx = (event->xmotion.x / edpane.pix_w) * edpane.pix_w + edpane.pix_w / 2;
  1928. ty = (event->xmotion.y / edpane.pix_h) * edpane.pix_h + edpane.pix_h / 2;
  1929. if (tx == ox && ty == oy)
  1930. return;
  1931. if(ox) {
  1932. rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
  1933. }
  1934. ox = tx;
  1935. oy = ty;
  1936. rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
  1937. break;
  1938. case ButtonRelease:
  1939. XtRemoveEventHandler(wgeBulB_edit,
  1940. ButtonReleaseMask|PointerMotionMask,
  1941. False, (XtEventHandler)musPasteProc, NULL );
  1942. rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
  1943. ox = 0;
  1944. oy = 0;
  1945. bitPtnCopy( em.rsv_ptn, edg.ptn );
  1946. tx = event->xbutton.x / edpane.pix_w;
  1947. ty = event->xbutton.y / edpane.pix_h;
  1948. rc = bitDrawPaste(edg.ptn, tx, ty);
  1949. if( rc == -1 )
  1950. return;
  1951. edg.flag = ON;
  1952. em.rsv_f = ON;
  1953. DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
  1954. DrawDpPn();
  1955. UndoSet();
  1956. break;
  1957. }
  1958. }
  1959. static void
  1960. rubLine( int x1, int y1, int x2, int y2 )
  1961. {
  1962. if( x1==x2 && y1==y2 ) return;
  1963. XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1,y1, x2,y2 );
  1964. }
  1965. static void
  1966. rubBand( int x1, int y1, int x2, int y2 )
  1967. {
  1968. if( x1==x2 && y1==y2 )
  1969. return;
  1970. XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x2, y1 );
  1971. XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x1, y2 );
  1972. XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x2, y1, x2, y2 );
  1973. XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y2, x2, y2 );
  1974. }
  1975. static void
  1976. rubCircle( int ox, int oy, int rx, int ry )
  1977. {
  1978. unsigned int r;
  1979. int x, y;
  1980. if( ox==rx && oy==ry ) return;
  1981. x = rx - ox;
  1982. y = ry - oy;
  1983. r = (unsigned int)sqrt( (double)(x*x + y*y) );
  1984. if ( r == 0 ) return;
  1985. x = ox - (int)r;
  1986. y = oy - (int)r;
  1987. XDrawArc( xl.display, xl.edit_winID, xl.rubGC,
  1988. x, y, 2*r-1, 2*r-1,
  1989. 0, 360*64
  1990. );
  1991. }
  1992. static void
  1993. resetEditMode( unsigned int flag )
  1994. {
  1995. int r1_x, r1_y;
  1996. int r2_x, r2_y;
  1997. if( flag & RES_MSG )
  1998. UpdateMessage( "" );
  1999. if( flag & RES_PROC )
  2000. em.proc = edpane.obj;
  2001. if( (flag & RES_SLCT) && (em.slct_f) ) {
  2002. r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
  2003. r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
  2004. r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
  2005. r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
  2006. rubBand( r1_x, r1_y, r2_x, r2_y );
  2007. em.slct_f = OFF;
  2008. }
  2009. if( flag & RES_RSV )
  2010. em.rsv_f = OFF;
  2011. }
  2012. /****************************************************************
  2013. * copy character pattern *
  2014. ***************************************************************/
  2015. /*
  2016. * contents : copy or overlay the new character pattern to the current pattern
  2017. */
  2018. /*ARGSUSED*/
  2019. static void
  2020. copyPatterns(
  2021. FalFontData *fdata,
  2022. int s1_code,
  2023. int s2_code,
  2024. int d1_code,
  2025. int proc)
  2026. {
  2027. int ret;
  2028. int d1_ncode, d2_ncode;
  2029. int code_d;
  2030. int code_disp;
  2031. char err[128];
  2032. int i_s, i_d;
  2033. int i;
  2034. char grc_d;
  2035. char **ptn;
  2036. char ptn2[MAXPTNBYTE];
  2037. int num;
  2038. extern int last_code;
  2039. ret = copySNF(s1_code, s2_code, &ptn, &num, err);
  2040. if( ret == -1 ) {
  2041. Error_message2((Widget)NULL, err);
  2042. return;
  2043. }
  2044. if (last_code < (d1_code + num))
  2045. last_code = d1_code + num;
  2046. if( ptnSense(edg.code) == 1 )
  2047. ptnAdd( edg.code, edg.ptn );
  2048. d1_ncode = codeToNo( d1_code );
  2049. for (i_d=d1_ncode, i_s=0; i_s < num; i_d++) {
  2050. if ( codeCheck( noToCode( i_d)))
  2051. continue;
  2052. bitPtnClear( ptn2 );
  2053. code_d = noToCode( i_d );
  2054. grc_d = ptnGet( code_d, ptn2 );
  2055. if (grc_d == 0) {
  2056. if( proc == CPY_OVERLAY ) {
  2057. for( i=0 ; i < edg.height*((edg.width+7)/8) ; i++ ) {
  2058. ptn[i_s][i] |= ptn2[i];
  2059. }
  2060. }
  2061. ptnAdd( code_d, ptn[i_s] );
  2062. edg.flag = ON;
  2063. } else {
  2064. if( ptnAdd( code_d, ptn[i_s] ) != 1 ) {
  2065. UpdateMessage( resource.me_non_memory );
  2066. break;
  2067. }
  2068. edlist.nptn++;
  2069. edg.flag = ON;
  2070. }
  2071. i_s ++;
  2072. }
  2073. d2_ncode = i_d - 1;
  2074. code_disp = 0;
  2075. for( i=d1_ncode ; i <= d2_ncode; i++ ) {
  2076. if ( codeCheck( noToCode(i) ) )
  2077. continue;
  2078. if( ptnSense( noToCode( i ) ) == 1 ) {
  2079. code_disp = noToCode( i );
  2080. break;
  2081. }
  2082. }
  2083. freeSNF(ptn, num);
  2084. if( (code_disp == 0) && (efctPtnNum() > 0))
  2085. code_disp = noToCode( ptnSqToNo(edlist.sqstart) );
  2086. chgEdCode( code_disp, ON );
  2087. resetEditMode( (unsigned int) (RES_MSG | RES_PROC | RES_SLCT | RES_RSV) );
  2088. }