2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
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 $ */
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
34 #define substance_source
39 #include <X11/Intrinsic.h>
41 #include "xoakufont.h"
44 #ifndef NO_MESSAGE_CAT
46 #define _CLIENT_CAT_NAME "dtudcfonted.cat"
48 #define _CLIENT_CAT_NAME "dtudcfonted"
51 extern char *_DtGetMessage();
53 extern char *_DtGetMessage(
58 #endif /* _NO_PROTO */
59 #define GETMESSAGE(set, number, string) GetMessage(set, number, string)
61 GetMessage(set, number, string)
66 tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string);
67 ret = malloc(strlen(tmp) + 1);
71 #else /* NO_MESSAGE_CAT */
72 #define GETMESSAGE(set, number, string)\
74 #endif /* NO_MESSAGE_CAT */
76 /****************************************************************
78 ***************************************************************/
79 /* Widget toplevel; */
81 Widget wgeScro, editPopW;
83 static int select_x, select_y, select_w, select_h;
84 static int r1_x, r1_y, r2_x, r2_y, cut_w, cut_h;
86 extern Widget xlfdDialog, cpyDialog ;
88 extern FalFontID font_id;
95 static XtAppContext app; /* application context */
96 static int edpane_size=0;
97 void CB_set_wait_msg();
100 static void OtherFontSelect();
103 static void xeg_init();
106 static void dstrypaneEditPtn();
109 static void chgEdPtn();
110 static void DrawRectEdPn();
111 static void DrawBorderEdPn();
112 static void DrawPointEdPn();
113 static void DrawDpPn();
114 static void DrawPointDpPn();
115 static void musPoint();
116 static void musLine();
117 static void musCircle();
118 static void musRect();
119 static void musRegionProc();
120 static void musPasteProc();
121 static void rubLine();
122 static void rubBand();
123 static void rubCircle();
124 static void resetEditMode();
125 static void copyPatterns();
126 extern String MngCodeTfValue();
127 extern String CpySrcCodeTfValue();
128 extern String CpyDestCodeTfValue();
129 char *get_cmd_path() ;
130 extern FalFontData fullFontData;
131 extern FalFontData copyFontData;
133 extern void PopupSelectXLFD();
134 extern void UpdateMessage();
135 extern void DispMngErrorMessage();
136 extern void DispCpyErrorMessage();
138 /****************************************************************
140 ***************************************************************/
146 /****************************************************************
147 * callback routines *
148 ***************************************************************/
150 static void CancelCB();
165 for ( cnt = 0, sq = edlist.sqstart;
166 sq < (edlist.sqstart + edlist.nptn); sq++) {
168 if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
175 Error_message(widget, message)
179 static NoticeButton is_lock[] = {
180 NBTNARGS( ExitCB, NULL, 'E', True, False ),
181 NBTNARGS( CancelCB, NULL, 'C', True, True )
183 static NButton LockBTN = NBUTTONS( is_lock );
185 SetItemLabel(&LockBTN, 0, resource.l_exit);
186 SetItemLabel(&LockBTN, 1, resource.l_cancel);
187 PopupNotice( (widget), message,
191 resource.l_question_title);
195 Error_message2(widget, message)
199 static NoticeButton is_lock[] = {
200 NBTNARGS( CancelCB, NULL, 'C', True, True )
202 static NButton LockBTN = NBUTTONS( is_lock );
207 SetItemLabel(&LockBTN, 0, resource.l_ok);
208 PopupNotice( (widget), message,
212 resource.l_question_title);
216 * contents : read a character pattern from SNF file
220 CBmOblB_edit( widget, clientData, callData )
232 extern int begin_code;
234 extern int ptnGetInfo();
235 extern void PopupEditPtn();
237 /* open font file and get informations of character to be edited */
239 ret = readSNF( &(edg.fdata), &(edg.width), &(edg.height), err);
242 Error_message(widget, err);
245 dn.ptn_w = (Dimension) edg.width;
246 dn.ptn_h = (Dimension) edg.height;
249 if( xlfdDialog != NULL )
250 PopdownDialog(xlfdDialog);
253 ptnGetInfo( &ptn_n, &ptn_w, &ptn_h );
254 for( i=0 ; i<ptn_n ; i++ ) {
255 code = noToCode( ptnSqToNo(i) );
256 if( begin_code > code){
257 edlist.sqstart = i+1;
262 if( efctPtnNum() > 0) {
263 for ( i=edlist.sqstart; i<(edlist.sqstart+edlist.nptn); i++){
264 if ( codeCheck( noToCode( ptnSqToNo(i))) == 0)
267 edg.ncode = ptnSqToNo( i );
268 edg.code = noToCode( edg.ncode );
269 ptnGet( edg.code, edg.ptn );
271 PopupEditPtn(toplevel);
278 static Boolean do_read = False;
279 static Boolean do_end = False;
281 static void CancelCB() { }
283 static void ContReadCB(w)
286 FalCloseFont(font_id);
289 PopupSelectXLFD(toplevel);
292 static void SaveReadCB()
296 PopupSelectXLFD(toplevel);
300 static void ContEndCB()
302 FalCloseFont(font_id);
306 static void SaveEndCB()
314 * contents : quit editting
320 QuitEditPtn( widget, clientData, callData )
325 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
328 ptnAdd( edg.code, edg.ptn );
330 if( edg.flag == ON ){
339 OpenCB(w, client_data, call_data)
341 XtPointer client_data;
344 static NoticeButton is_save_read_btn1[] = {
345 NBTNARGS( SaveReadCB, NULL, 'S', True, False ),
346 NBTNARGS( ContReadCB, NULL, 'O', True, False ),
347 NBTNARGS( CancelCB, NULL, 'C', True, True ),
349 static NoticeButton is_save_read_btn2[] = {
350 NBTNARGS( ContReadCB, NULL, 'O', True, False ),
351 NBTNARGS( CancelCB, NULL, 'C', True, True ),
353 static NButton SaveReadBTN1 = NBUTTONS( is_save_read_btn1 );
354 static NButton SaveReadBTN2 = NBUTTONS( is_save_read_btn2 );
356 if (QuitEditPtn((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL)){
357 FalCloseFont(font_id);
360 PopupSelectXLFD(toplevel);
363 if (! fullFontData.prm) {
364 SetItemLabel(&SaveReadBTN1, 0, resource.l_do_save_exit);
365 SetItemLabel(&SaveReadBTN1, 1, resource.l_dont_save_exit);
366 SetItemLabel(&SaveReadBTN1, 2, resource.l_cancel);
367 PopupNotice( (w), resource.mn_saved_open ,
371 resource.l_question_title);
373 SetItemLabel(&SaveReadBTN2, 0, resource.l_dont_save_exit);
374 SetItemLabel(&SaveReadBTN2, 1, resource.l_cancel);
375 PopupNotice( (w), resource.mn_saved_open ,
379 resource.l_question_title);
386 ReadCB(w, client_data, call_data)
388 XtPointer client_data;
391 if (fullFontData.xlfdname == NULL) {
394 if (fullFontData.xlfdname == (char *) -1) {
395 Error_message(w, resource.mn_prop_font);
398 CBmOblB_edit( w, client_data, call_data );
401 /****************************************************************
402 * callback routines and event handler *
403 ***************************************************************/
406 * contents : write character patterns to SNF file
410 WPwriteSNF( restart )
414 char str[MG_MAXSIZE];
416 switch( rc = writeSNF( restart, &err ) ) {
419 XtSetSensitive( dnPopW, TRUE );
422 sprintf(str, "%s(permission denied)", resource.me_write_snf);
425 sprintf(str, "%s(disk full)", resource.me_write_snf);
428 sprintf(str, "%s(pipe error)", resource.me_write_snf);
431 sprintf(str, "%s(fork error)", resource.me_write_snf);
434 sprintf(str, "%s(execv error)", resource.me_write_snf);
437 sprintf(str, "%s(data error)", resource.me_write_snf);
440 sprintf(str, "%s", resource.me_write_snf);
442 SetString( wgeStaT, str );
446 UpdateMessage( resource.mg_register );
452 ContReadCB((Widget)NULL);
461 sprintf( str, "%s", resource.me_wait );
463 sprintf( str, "%s(%3d%%)", resource.mg_write_snf , rc-1000 );
465 SetString( wgeStaT, str );
466 XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)ON );
468 XSync( xl.display,0 );
477 * contents : write character patterns to SNF file
483 char str[MG_MAXSIZE];
485 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
486 SetString( wgeStaT, resource.mg_write_snf );
489 ptnAdd( edg.code, edg.ptn );
491 if( edg.flag == ON ) {
492 sprintf( str, "%s", resource.mg_write_snf );
494 XtSetSensitive( dnPopW, FALSE );
496 XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)OFF );
500 SetString( wgeStaT, "" );
507 * contents : destroy the editor window
520 * contents : close dtudcfonted
525 CBeOblB_aEnd( widget, clientData, callData )
530 static NoticeButton is_save_exit_btn[] = {
531 NBTNARGS( SaveEndCB, NULL, 'S', True, False ),
532 NBTNARGS( ContEndCB, NULL, 'E', True, False ),
533 NBTNARGS( CancelCB, NULL, 'C', True, True ),
535 static NButton SaveEndBTN = NBUTTONS( is_save_exit_btn );
537 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
540 ptnAdd( edg.code, edg.ptn );
541 if( edg.flag == ON ) {
543 SetItemLabel(&SaveEndBTN, 0, resource.l_do_save);
544 SetItemLabel(&SaveEndBTN, 1, resource.l_dont_save);
545 SetItemLabel(&SaveEndBTN, 2, resource.l_cancel);
546 PopupNotice( widget, resource.mn_saved_exit, D_QUESTION,
547 &SaveEndBTN, True, resource.l_question_title);
550 FalCloseFont(font_id);
560 CBeOblB_rCmd( widget, proc, callData )
565 extern void SelectUnset();
566 extern void UndoSet();
567 if (!select_x && !select_y && !select_w && !select_h)
570 bitPtnCopy( em.rsv_ptn, edg.ptn );
571 rubBand( r1_x, r1_y, r2_x, r2_y );
574 bitDrawCls (edg.ptn, select_x, select_y, select_w, select_h );
577 bitDrawSet (edg.ptn, select_x, select_y, select_w, select_h );
580 bitDrawRev (edg.ptn, select_x, select_y, select_w, select_h );
583 bitDrawRoll(edg.ptn, select_x, select_y, select_w, select_h);
586 bitDrawSymV(edg.ptn, select_x, select_y, select_w, select_h );
589 bitDrawSymH(edg.ptn, select_x, select_y, select_w, select_h );
593 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
595 select_x = select_y = select_w = select_h = 0;
602 CBeOblB_rCmdp( widget, proc, callData )
607 extern Widget wgeBulB_edit;
608 extern void CopySet();
609 extern void UndoSet();
610 extern void SelectUnset();
614 if (!select_x && !select_y && !select_w && !select_h)
616 rubBand( r1_x, r1_y, r2_x, r2_y );
617 bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, False);
620 select_x = select_y = select_w = select_h = 0;
625 if (!select_x && !select_y && !select_w && !select_h)
628 rubBand( r1_x, r1_y, r2_x, r2_y );
629 bitPtnCopy( em.rsv_ptn, edg.ptn );
630 bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, True);
634 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
636 select_x = select_y = select_w = select_h = 0;
642 XtAddEventHandler(wgeBulB_edit,
643 ButtonReleaseMask|PointerMotionMask,
644 False, musPasteProc, NULL );
652 * contents : cancel all editting
657 CBeOblB_rCan( widget, clientData, callData )
662 extern void UndoUnset();
664 resetEditMode( RES_MSG | RES_PROC | RES_SLCT );
666 if( em.rsv_f == ON ) {
667 bitPtnCopy( edg.ptn, em.rsv_ptn );
670 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
681 * contents : get a sequential number of the editor
684 RelToAbsSq( from, cnt)
692 for ( i = -1; from < (edlist.sqstart + edlist.nptn) ; from++) {
693 no = ptnSqToNo(from);
694 if (( no >= 0) && ( noToCode( no) >= 0) ) {
702 for ( i = -1; from >= edlist.sqstart; from--) {
703 no = ptnSqToNo(from);
704 if (( no >= 0) && ( noToCode( no) >= 0) ) {
715 * contents : get a relative number of the system area
718 AbsSqToRel( from, to)
734 for ( cnt = -1, sq = from; sq <= to; sq++) {
736 if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
751 * contents : be the character list selected
756 EHeStaT_list( widget, select, e )
759 XEvent *e; /* X Event */
764 resetEditMode( RES_MSG|RES_PROC|RES_SLCT|RES_RSV );
766 if( (e->xbutton.button != 1) || (e->type != ButtonRelease) ||
767 (e->xbutton.x < 0) || ((int)edlist.elem_w < e->xbutton.x) ||
768 (e->xbutton.y < 0) || ((int)edlist.elem_h < e->xbutton.y)
772 if( edlist.slctloc == select )
776 sq = RelToAbsSq( edlist.sqstart + edlist.statloc, select);
778 if( (no = ptnSqToNo(sq)) == -1 )
781 code = noToCode( no );
782 if( codeCheck( code ) == -1 )
785 if( ptnSense( code) == 0 )
788 chgEdList( edlist.statloc, select, OFF );
789 if( ptnSense(edg.code) == 1 )
790 ptnAdd(edg.code, edg.ptn );
798 * contents : update the character list
803 CBeScro( widget, clientData, callData )
813 XtSetArg( arg[n], XmNvalue, (XtArgVal)&newl ); n++;
814 XtGetValues( wgeScro , arg, n );
816 if (( new_statloc = RelToAbsSq( edlist.sqstart, newl)) < 0) {
819 new_statloc -= edlist.sqstart;
823 new_slct = edlist.slctloc
824 - AbsSqToRel( edlist.sqstart + edlist.statloc,
825 edlist.sqstart + new_statloc);
826 chgEdList( new_statloc, new_slct, OFF);
833 * contents : select the edit items by mouse
838 EHeBulB_eMEv( widget, clientData, e )
841 XEvent *e; /* X Event */
846 if (edpane.pix_w * edpane.pix_h == 0 ) {
850 if( e->type == ButtonPress ){
853 if( (edg.code == 0) || (em.drag_f == OFF) )
855 if( e->type == ButtonRelease ){
859 px = e->xbutton.x / edpane.pix_w;
860 py = e->xbutton.y / edpane.pix_h;
862 if (( e->type == ButtonPress) || (e->type == ButtonRelease)){
863 downbutton = e->xbutton.button;
864 }else if ( e->type == MotionNotify ){
865 if ( e->xmotion.state & Button1Mask ){
866 downbutton = 1; /* select button */
867 }else if ( e->xmotion.state & Button2Mask ){
868 downbutton = 2; /* adjust button */
874 switch( downbutton ) {
878 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
879 musPoint( e->type, px, py );
882 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
883 musLine( e->type, px, py );
886 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
887 musCircle( e->type, px, py );
890 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
891 musRect( em.proc, e->type, px, py );
894 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
895 musPoint( e->type, px, py );
898 musRegionProc( em.proc, e->type, px, py );
906 if( (0 <= px) && (px < edg.width) && (0 <= py) && (py < edg.height) ) {
907 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
911 if( (em.adj_px == px) && (em.adj_py == py) )
917 if( bitRead(edg.ptn, px, py) == 0 ) {
918 bitSet( edg.ptn, px, py );
919 DrawPointEdPn( px,py, 1 );
920 DrawPointDpPn( px,py, 1 );
923 bitReset( edg.ptn, px, py );
924 DrawPointEdPn( px,py, 0 );
925 DrawPointDpPn( px,py, 0 );
942 * contents : restore the editting pane
947 EHeBulB_eExp( widget, clientData, e )
950 XEvent *e; /* X Event */
955 if (edpane.pix_w * edpane.pix_h == 0 ) {
959 x1 = e->xexpose.x / edpane.pix_w;
960 y1 = e->xexpose.y / edpane.pix_h;
961 x2 = (e->xexpose.x + e->xexpose.width - 1) / edpane.pix_w;
962 y2 = (e->xexpose.y + e->xexpose.height - 1) / edpane.pix_h;
964 DrawRectEdPn( x1, y1, x2, y2 );
965 DrawBorderEdPn( x1, y1, x2, y2 );
972 * contents : specifies the drawing operation (Pont/Line/Rectangle/Circle)
977 CBeRecB_obj( widget, obj, call)
980 XmToggleButtonCallbackStruct *call;
982 extern void SelectUnset();
984 if (call->set == False)
987 resetEditMode( RES_MSG | RES_RSV | RES_SLCT );
989 if (obj == PROC_ERASE)
995 if (obj != PROC_SELECT) {
996 if (select_x || select_y || select_w || select_h) {
997 rubBand( r1_x, r1_y, r2_x, r2_y );
998 select_x = select_y = select_w = select_h = 0;
1008 * contents : restore the displaying pane
1013 EHeBulB_dExp( widget, clientData )
1017 if (xl.display == NULL ){
1025 * contents : set the range to be add or deleted
1029 codeAreaSet(s_code,e_code)
1036 str = MngCodeTfValue();
1043 sscanf( str, "%x %c %x", s_code, &delm, e_code );
1044 if (str) free( str );
1054 if( codeCheck(*s_code) || codeCheck(*e_code) ||
1055 (*s_code > *e_code) ) {
1062 /****************************************************************
1063 * callback routines (character management window) *
1064 ***************************************************************/
1067 BeforeMngCheck(s_code, e_code)
1071 if(codeAreaSet(s_code, e_code) == -1) {
1072 DispMngErrorMessage( resource.me_illegal_code );
1079 DoAddProc(s_code, e_code)
1087 char ptn[MAXPTNBYTE];
1091 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1094 s_ncode = codeToNo( s_code );
1095 e_ncode = codeToNo( e_code );
1098 for( i=s_ncode ; i <= e_ncode ; i++ ) {
1100 if ( codeCheck( code))
1102 if (ptnSense(code) == 0) {
1103 if(ptnAdd(code, ptn) != 1) {
1104 SetString( wgeStaT, resource.me_non_memory );
1114 if( ptnSense( edg.code ) == 1 ) {
1115 ptnAdd( edg.code, edg.ptn );
1119 chgEdCode( s_code, mode );
1122 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1127 void PopupDelNotice();
1128 Widget CreateDelNotice();
1132 DoDelProc( s_code, e_code )
1136 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1138 if( ptnSense( edg.code) == 1 )
1139 ptnAdd( edg.code, edg.ptn );
1141 dn.s_ncode = codeToNo( s_code );
1142 dn.e_ncode = codeToNo( e_code );
1144 if (setRealDelArea(&dn.s_ncode, &dn.e_ncode, &dn.sq_start, &dn.sq_end) == -1) {
1145 DispMngErrorMessage( resource.me_nodelete_code );
1148 dn.sq_top = dn.sq_start;
1149 dn.disp_num = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
1150 dn.disp_num = (dn.disp_num <= D_MAX) ? dn.disp_num : D_MAX;
1152 PopupDelNotice( mngPtnW );
1160 * contents : get the real range to be add or delete
1165 setRealDelArea(s_ncode, e_ncode, sq_start, sq_end )
1166 int *s_ncode, *e_ncode;
1167 int *sq_start, *sq_end;
1177 for( i=*s_ncode ; i <= ncode ; i++ ) {
1178 if (((sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i)) == 0)) {
1184 *s_ncode = ptnSqToNo( sq );
1193 for( i=*e_ncode ; i >= ncode ; i-- ) {
1194 if ((( sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i) ) == 0)) {
1199 *e_ncode = ptnSqToNo( sq );
1209 /****************************************************************
1210 * callback routines (Copy) *
1211 ****************************************************************/
1219 str = CpySrcCodeTfValue();
1229 sscanf( str, "%x %c %x", &cpm.s1_code,&delm, &cpm.s2_code );
1233 cpm.s2_code = cpm.s1_code;
1240 if (cpm.s1_code > cpm.s2_code)
1250 str = CpyDestCodeTfValue();
1258 sscanf( str, "%x", &cpm.d1_code );
1261 if( codeCheck(cpm.d1_code) ) {
1268 BeforeCpyCheck( proc )
1271 int s_ncode, e_ncode;
1272 int r1_code, r2_code;
1276 extern void PopupCpyNotice();
1278 if (copyFontData.xlfdname == NULL) {
1279 DispCpyErrorMessage(resource.me_non_srcfile);
1283 if (CpySrcCodeCheck() == -1){
1284 DispCpyErrorMessage( resource.me_illegal_srccode );
1288 if (CpyDestCodeCheck() == -1){
1289 DispCpyErrorMessage( resource.me_illegal_destcode );
1293 s_ncode = codeToNo( cpm.d1_code );
1294 e_ncode = codeToNo( cpm.d1_code + cpm.s2_code - cpm.s1_code);
1295 r1_code = r2_code = 0;
1296 for( i=s_ncode ; i <= e_ncode ; i++ ) {
1298 if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) {
1300 r1_code = noToCode(i);
1301 r2_code = noToCode(i);
1307 if( r1_code != 0 ) {
1308 if( r1_code == r2_code ) {
1309 sprintf( rstr, "%s %x¡¡", resource.l_code, r1_code );
1310 } else if ( codeCheck(r1_code) && codeCheck(r2_code)){
1311 sprintf( rstr, " %x - %x", r1_code, r2_code );
1313 sprintf( rstr, "%s %x - %x ", resource.l_code_range, r1_code, r2_code );
1315 PopupCpyNotice(rstr);
1325 extern void PopdownCpyPtn();
1329 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1331 copyPatterns( cpm.fdata, cpm.s1_code, cpm.s2_code, cpm.d1_code, cpm.proc );
1334 /****************************************************************
1336 ****************************************************************/
1337 #define R(name, class, member,def) { \
1342 XtOffsetOf(Resource, member), \
1346 #define RBoolean(name, class, member,def) \
1347 { name, class, XtRBoolean, sizeof(XtRBoolean), \
1348 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1350 #define RDimension(name, class, member,def) \
1351 { name, class, XtRDimension, sizeof(XtRDimension), \
1352 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1354 #define Rint(name, class, member,def) \
1355 { name, class, XtRInt, sizeof(XtRInt), \
1356 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1358 #define RPixel(name, class, member,def) \
1359 { name, class, XtRPixel, sizeof(XtRPixel), \
1360 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1362 static XtResource app_resources[] = {
1363 RBoolean("Codepoint", "codepoint", codepoint, "False"),
1365 R( "lptog", "Lptog", l_ptog, DFLTPATH ),
1366 R( "lptogCmd", "LptogCmd", l_ptog_cmd, DFLTCMD ),
1368 /* CreateCaptionFrame() */
1369 RBoolean( "captResize", "CaptResize", capt_resize, "True" ) ,
1370 Rint( "captLftoff", "CaptLftoff", capt_lftoff, "2" ) ,
1371 Rint( "captTopoff", "CaptTopoff", capt_topoff, "2" ) ,
1372 Rint( "captRghoff", "CaptRghoff", capt_rghoff, "2" ) ,
1374 RPixel( "paneBackground", "paneBackground", pane_background, "white" ),
1375 RPixel( "paneForeground", "PaneForeground", pane_foreground, "black" ),
1376 RPixel( "background", "Background", background, "white" ),
1377 RPixel( "foreground", "Foreground", foreground, "black" ),
1379 /* CreateMenuButtons() */
1380 RDimension( "menuMargin", "MenuMargin", menu_margin, "0" ) ,
1382 /* CreateDialogAndButtons() */
1383 RBoolean( "diaTmAutomng", "DiaTmAutomng", dia_tm_automng, "False" ) ,
1384 RDimension( "diaTmWidth", "DiaTmWidth", dia_tm_width, "4" ) ,
1385 RDimension( "diaTmHeight", "DiaTmHeight", dia_tm_height, "4" ) ,
1386 RBoolean( "diaTmResize", "DiaTmResize", dia_tm_resize, "True" ) ,
1387 RBoolean( "diaTmMinimize", "DiaTmMinimize", dia_tm_minimize, "True" ) ,
1389 RDimension( "diaRwWidth", "DiaRwWidth", dia_rw_width, "6" ) ,
1390 RDimension( "diaRwHeight", "DiaRwHeight", dia_rw_height, "6" ) ,
1391 RDimension( "diaRwSpacing", "DiaRwSpacing", dia_rw_spacing, "4" ) ,
1393 /* CreateDrawingArea() */
1394 RDimension( "drawBorder", "DrawBorder", draw_border, "1" ) ,
1395 Rint( "drawTopoff", "DrawTopoff", draw_topoff, "2" ) ,
1396 Rint( "drawLftoff", "DrawLftoff", draw_lftoff, "2" ) ,
1399 RBoolean( "popResize", "PopResize", pop_resize , "True" ) ,
1400 RBoolean( "popMinimize", "PopMinimize", pop_minimize , "True" ) ,
1402 /* CreateTemplateDialog() */
1403 RBoolean( "tempResize", "TempResize", temp_resize, "True" ) ,
1404 RBoolean( "tempMinimize", "TempMinimize", temp_minimize, "True" ) ,
1406 RDimension( "tempWidth", "TempWidth", temp_width, "1" ) ,
1407 RDimension( "tempHeight", "TempHeight", temp_height, "1" ) ,
1409 /* CreateMenuBarAndFooterMessageForm() */
1410 Rint( "edBarTopoff", "EdBarTopoff", ed_bar_topoff, "1" ) ,
1411 Rint( "edBarLftoff", "EdBarLftoff", ed_bar_lftoff, "1" ) ,
1412 Rint( "edBarRghoff", "EdBarRghoff", ed_bar_rghoff, "1" ) ,
1414 Rint( "edFrmBtmoff", "EdFrmBtmoff", ed_frm_btmoff, "3" ) ,
1415 Rint( "edFrmLftoff", "EdFrmLftoff", ed_frm_lftoff, "3" ) ,
1416 Rint( "edFrmRghoff", "EdFrmRghoff", ed_frm_rghoff, "3" ) ,
1418 RDimension( "edMsgMargintop", "EdMsgMargintop", ed_msg_margintop, "3" ) ,
1419 RDimension( "edMsgMarginbtm", "EdMsgMarginbtm", ed_msg_marginbtm, "3" ) ,
1421 RDimension( "edMesgMargintop", "EdMesgMargintop", ed_mesg_margintop, "3" ) ,
1422 RDimension( "edMesgMarginbtm", "EdMesgMarginbtm", ed_mesg_marginbtm, "3" ) ,
1424 Rint( "edSepBtmoff", "EdSepBtmoff", ed_sep_btmoff, "3" ) ,
1425 Rint( "edSepLftoff", "EdSepLftoff", ed_sep_lftoff, "0" ) ,
1426 Rint( "edSepRghoff", "EdSepRghoff", ed_sep_rghoff, "0" ) ,
1427 RDimension( "edSepMargin", "EdSepMargin", ed_sep_margin, "0" ) ,
1429 Rint( "edWgeTopoff", "EdWgeTopoff", ed_wge_topoff, "10" ) ,
1430 Rint( "edWgeLftoff", "EdWgeLftoff", ed_wge_lftoff, "10" ) ,
1431 Rint( "edWgeRghoff", "EdWgeRghoff", ed_wge_rghoff, "10" ) ,
1432 Rint( "edWgeBtmoff", "EdWgeBtmoff", ed_wge_btmoff, "10" ) ,
1435 RBoolean( "frameResize", "FrameResize", frame_resize, "False" ) ,
1437 /* CreateScrollBase() */
1438 RDimension( "scllFrWidth", "ScllFrWidth", scll_fr_width, "500" ) ,
1440 RDimension( "scllFrThick", "ScllFrThick", scll_fr_thick, "2" ) ,
1442 Rint( "scllBarLftoff", "ScllBarLftoff", scll_bar_lftoff, "4" ) ,
1450 int CodePoint = False;
1456 register XErrorEvent *ev;
1458 fprintf (stderr, "dtudcfonted: warning, error event receieved.\n");
1467 static char class_name[] = "Dtudcfonted";
1470 /* initialize GUI */
1471 toplevel = (Widget)GuiInitialize(&app, class_name, &argc, argv);
1473 /* get application's resources */
1474 XtGetApplicationResources( toplevel, &resource,
1475 app_resources, XtNumber(app_resources), NULL, 0);
1477 if (resource.codepoint)
1479 /* initialize the code range */
1480 for( i=1 ; i < argc ; i++ ) {
1481 if( !strcmp(argv[i],"-pane_size") ) {
1483 edpane_size = atoi( argv[i] );
1484 } else if( !strcmp(argv[i],"-codepoint") ) {
1489 resource.mg_write_snf = GETMESSAGE(2, 2, "Registration processing inside.");
1490 resource.me_write_snf = GETMESSAGE(2, 4, "Failed in the registration of the character.");
1491 resource.me_illegal_code = GETMESSAGE(2, 6, "Illegal code.");
1492 resource.me_non_memory = GETMESSAGE(2, 8, "Because the memory allocation cannot be done, it is not possible to add.");
1493 resource.mg_non_code = GETMESSAGE(2, 10, "There is no character of the specified code.");
1494 resource.me_illegal_srccode = GETMESSAGE(2, 12, "The mistake is found in the specified copy origin code.");
1495 resource.me_illegal_destcode = GETMESSAGE(2, 14, "The mistake is found in the specified copy target code.");
1496 resource.me_nodelete_code = GETMESSAGE(2, 16, "There is no character in the specified area.");
1497 resource.me_wait = GETMESSAGE(2, 18, "Please wait for a while.");
1498 resource.me_non_srcfile = GETMESSAGE(2, 20, "No copy origin code file is specified.");
1499 resource.mn_no_font = GETMESSAGE(2, 22, "Informations of user defined character cannot collect.\nThere is no font specified.");
1500 resource.mn_plural_font = GETMESSAGE(2, 24, "Informations of user defined character cannot collect.\nThere are plural fonts specified.");
1501 resource.mn_not_udc = GETMESSAGE(2, 26, "The specified font do not have any UDCs areas.");
1502 resource.mn_no_mem = GETMESSAGE(2, 28, "There are no memories any more.");
1503 resource.mn_illegal_area = GETMESSAGE(2, 30, "The information of UDCs area is illegal.");
1504 resource.mn_no_read = GETMESSAGE(2, 32, "The font file cannot read.\nPattern area was broken.");
1505 resource.mn_prop_font = GETMESSAGE(2, 34, "Dtudcfonted cannot edit proportional character font.");
1506 resource.mn_saved_open = GETMESSAGE(2, 36, "There are unsaved edits.\nDo you want to save them before opening?");
1507 resource.mn_saved_exit = GETMESSAGE(2, 38, "There are unsaved edits.\nDo you want to save them before exiting?");
1508 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");
1509 resource.mn_no_perm = GETMESSAGE(2, 42, "No write permission for this font. You should change the file access mode before saving.\n");
1511 resource.l_selectitem = GETMESSAGE(2, 100, "Select Items"); /* font open */
1512 resource.l_codeset = GETMESSAGE(2, 102, " CodeSet:");
1513 resource.l_style = GETMESSAGE(2, 104, " Style:");
1514 resource.l_width = GETMESSAGE(2, 106, " Width:");
1515 resource.l_height = GETMESSAGE(2, 108, " Height:");
1516 resource.exec_label = GETMESSAGE(2, 110, "Open");
1517 resource.quit_label = GETMESSAGE(2, 112, "Quit");
1519 resource.l_font = GETMESSAGE(2, 114, "Font"); /* menu bar */
1520 resource.l_edit = GETMESSAGE(2, 116, "Edit");
1521 resource.l_manage = GETMESSAGE(2, 118, "Character");
1522 resource.l_info = GETMESSAGE(2, 120, "Information");
1524 resource.l_open_w = GETMESSAGE(2, 122, "Open"); /* font menu */
1525 resource.l_save = GETMESSAGE(2, 124, "Save");
1526 resource.l_exit = GETMESSAGE(2, 126, "Exit");
1528 resource.l_clear = GETMESSAGE(2, 128, "Clear"); /* edit menu */
1529 resource.l_set = GETMESSAGE(2, 130, "Set");
1530 resource.l_reverse = GETMESSAGE(2, 132, "Reverse");
1531 resource.l_cut = GETMESSAGE(2, 134, "Cut");
1532 resource.l_Copy = GETMESSAGE(2, 135, "Copy");
1533 resource.l_paste = GETMESSAGE(2, 136, "Paste");
1534 resource.l_roll = GETMESSAGE(2, 138, "Rotate");
1535 resource.l_updown_roll = GETMESSAGE(2, 140, "Vertical Roll");
1536 resource.l_leftright_roll = GETMESSAGE(2, 142, "Horizontal Roll");
1537 resource.l_undo = GETMESSAGE(2, 144, "Undo");
1539 resource.l_manage_w = GETMESSAGE(2, 146, "Add/Delete..."); /* character menu */
1540 resource.l_copy_w = GETMESSAGE(2, 148, "Copy...");
1542 resource.l_xlfd = GETMESSAGE(2, 150, "XLFD name..."); /* information menu */
1543 resource.l_codearea = GETMESSAGE(2, 152, "Code Area...");
1545 resource.l_add = GETMESSAGE(2, 154, "Add"); /* add/delete dialog */
1546 resource.l_delete = GETMESSAGE(2, 156, "Delete");
1547 resource.l_cancel = GETMESSAGE(2, 158, "Cancel");
1549 resource.l_manage_code = GETMESSAGE(2, 160, "Code(hex):"); /* copy dialog */
1550 resource.l_copy_src_code = GETMESSAGE(2, 162, " Copy origin code(hex):");
1551 resource.l_copy_dest_code = GETMESSAGE(2, 164, "Copy target code(hex):");
1552 resource.l_copy = GETMESSAGE(2, 166, "Copy");
1553 resource.l_overlay = GETMESSAGE(2, 168, "Overlay");
1554 resource.l_ok = GETMESSAGE(2, 170, "OK");
1556 resource.l_do_save = GETMESSAGE(2, 172, "Save"); /* unsaved edits */
1557 resource.l_dont_save = GETMESSAGE(2, 174, "Do not Save");
1558 resource.l_do_save_exit = GETMESSAGE(2, 176, "Save and Exit");
1559 resource.l_dont_save_exit = GETMESSAGE(2, 178, "Do not Save and Exit");
1561 resource.mg_start_del_s = GETMESSAGE(2, 180, "The following character will be deleted."); /* delete notice dialog */
1562 resource.mg_start_del_cs = GETMESSAGE(2, 182, "character");
1563 resource.mg_start_del_m = GETMESSAGE(2, 184, "The following characters will be deleted.");
1564 resource.mg_start_del_cm = GETMESSAGE(2, 186, "characters");
1565 resource.mg_register = GETMESSAGE(2, 188, "Register completed");
1566 resource.l_code = GETMESSAGE(2, 190, " Code : ");
1567 resource.l_code_range = GETMESSAGE(2, 192, " Code range : ");
1569 resource.message = GETMESSAGE(2, 194, "Message : ");
1571 resource.code = GETMESSAGE(2, 196, "code..."); /* code dialog */
1572 resource.previous = GETMESSAGE(2, 198, "Page up");
1573 resource.next = GETMESSAGE(2, 200, "Page down");
1574 resource.apply = GETMESSAGE(2, 202, "Apply");
1576 resource.l_question_title = GETMESSAGE(2, 204, "dtudcfonted - Question");
1577 resource.l_warning_title = GETMESSAGE(2, 206, "dtudcfonted - Warning");
1578 resource.l_error_title = GETMESSAGE(2, 208, "dtudcfonted - Error");
1579 resource.l_copy_title = GETMESSAGE(2, 210, "dtudcfonted - Copy");
1580 resource.l_open_title = GETMESSAGE(2, 212, "dtudcfonted - Open");
1581 resource.l_add_title = GETMESSAGE(2, 214, "dtudcfonted - Add/Delete");
1582 resource.l_xlfd_title = GETMESSAGE(2, 216, "dtudcfonted - XLFD");
1583 resource.l_codearea_title = GETMESSAGE(2, 218, "dtudcfonted - CodeArea");
1585 resource.file_name = GETMESSAGE(2, 230, "File name");
1586 resource.xlfd_name = GETMESSAGE(2, 232, "XLFD name");
1587 resource.codearea = GETMESSAGE(2, 234, "Code area");
1589 resource.falerrmsg[0] = GETMESSAGE(2, 300, "Fatal error occurred.");
1590 resource.falerrmsg[1] = GETMESSAGE(2, 301, "Cannot open the font file.");
1591 resource.falerrmsg[2] = GETMESSAGE(2, 302, "Cannot read the font file.");
1592 resource.falerrmsg[3] = GETMESSAGE(2, 303, "There is no more memory.");
1593 resource.falerrmsg[4] = GETMESSAGE(2, 304, "Fatal error occurred.");
1594 resource.falerrmsg[5] = GETMESSAGE(2, 305, "The specified font file does not exist.");
1595 resource.falerrmsg[6] = GETMESSAGE(2, 306, "This font is not a pcf or snf font.");
1596 resource.falerrmsg[7] = GETMESSAGE(2, 307, "Cannot open fonts.list file.");
1597 resource.falerrmsg[8] = GETMESSAGE(2, 308, "The format of fonts.list file is illegal.");
1598 resource.falerrmsg[9] = GETMESSAGE(2, 309, "The descriptions of the fonts.list file are incorrect.");
1599 resource.falerrmsg[10] = GETMESSAGE(2, 310, "The format of fonts.list file is illegal.");
1600 resource.falerrmsg[11] = GETMESSAGE(2, 311, "Cannot open fonts.dir file.");
1601 resource.falerrmsg[12] = GETMESSAGE(2, 312, "Cannot read fonts.dir file.");
1602 resource.falerrmsg[13] = GETMESSAGE(2, 313, "Cannot read font properties.");
1603 resource.falerrmsg[14] = GETMESSAGE(2, 314, "Cannot get FONT property.");
1604 resource.falerrmsg[15] = GETMESSAGE(2, 315, "Cannot get FAMILY_NAME property.");
1605 resource.falerrmsg[16] = GETMESSAGE(2, 316, "This font file is already opened by other application.");
1606 resource.falerrmsg[17] = GETMESSAGE(2, 317, "Cannot lock font file.");
1607 resource.falerrmsg[18] = GETMESSAGE(2, 318, "Cannot unlock font file.");
1608 resource.falerrmsg[19] = GETMESSAGE(2, 319, "Cannot get lock information from the font file.");
1609 resource.falerrmsg[20] = GETMESSAGE(2, 320, "Cannot find the specified font file.");
1610 resource.falerrmsg[21] = GETMESSAGE(2, 321, "Cannot read NLS database.");
1611 resource.falerrmsg[22] = GETMESSAGE(2, 322, "Cannot get charset names from NLS database.");
1612 resource.falerrmsg[23] = GETMESSAGE(2, 323, "Charset name not defined in NLS database.");
1613 resource.falerrmsg[24] = GETMESSAGE(2, 324, "The specified font has not been opened.");
1614 resource.falerrmsg[25] = GETMESSAGE(2, 325, "Fatal error occurred.");
1619 /* initialize the global values and allocate the memories */
1623 /* displays the selection window */
1624 PopupSelectXLFD(toplevel);
1626 XSetErrorHandler((XErrorHandler)xerror);
1627 XSetIOErrorHandler((XIOErrorHandler)xerror);
1637 * contents : initialize the global values
1645 edg.code = edg.ncode = 0;
1646 bitPtnClear( edg.ptn );
1649 edlist.nlist = EDLIST_MAX;
1650 edlist.statloc = edlist.slctloc = 0;
1653 edlist.list_h = edlist.elem_w = edlist.elem_h = (Dimension)0;
1654 edlist.back = resource.pane_background;
1655 edlist.border = resource.pane_foreground;
1658 edpane.width = edpane_size;
1659 edpane.height = edpane_size;
1661 edpane.width = EDPANE_SIZE;
1662 edpane.height = EDPANE_SIZE;
1664 edpane.pix_w = edpane.pix_h = 0;
1667 edpane.back = resource.pane_background;
1668 edpane.border = resource.pane_foreground;
1671 xl.root_winID = xl.edit_winID = xl.disp_winID = xl.list_winID =
1673 xl.borderGC = xl.backGC = xl.rubGC = xl.dashGC = (GC)NULL;
1674 xl.dispImage = NULL;
1676 dn.elem_w = dn.elem_h = (Dimension)0;
1677 dn.ptn_w = dn.ptn_h = (Dimension)0;
1678 dn.list_h = (Dimension)0;
1679 dn.s_ncode = dn.e_ncode = 0;
1680 dn.sq_top = dn.sq_start = dn.sq_end = 0;
1683 for ( i=0 ; i<D_MAX ; i++ ) {
1684 dl[i].disp_winID = (Window)NULL;
1685 dl[i].dispImage = NULL;
1686 bitPtnClear( dl[i].ptn );
1688 for ( i=0 ; i<EDLIST_MAX ; i++ ) {
1689 dl_glyph[i].disp_winID = (Window)NULL;
1690 dl_glyph[i].dispImage = NULL;
1691 bitPtnClear( dl_glyph[i].ptn );
1695 em.adj_px = em.adj_py = 0;
1696 em.proc = em.slct_f = 0;
1697 em.src1_px = em.src1_py = 0;
1698 em.src2_px = em.src2_py = 0;
1699 em.dest_px = em.dest_py = 0;
1701 bitPtnClear( em.rsv_ptn );
1703 cpm.s1_code = cpm.s2_code = cpm.d1_code = 0;
1711 /****************************************************************
1712 * distroy the "User defined character editor" window *
1713 ****************************************************************/
1716 * contents : destroy the editting window
1726 XFree( (char *)xl.dispImage );
1727 XFreeGC( xl.display, xl.borderGC );
1728 XFreeGC( xl.display, xl.backGC );
1729 XFreeGC( xl.display, xl.rubGC );
1730 XFreeGC( xl.display, xl.dashGC );
1732 for( i=0; i<EDLIST_MAX; i++ ){
1733 if( dl_glyph[i].dispImage ){
1734 XFree( (char *)dl_glyph[i].dispImage );
1735 dl_glyph[i].dispImage = NULL ;
1739 XtPopdown( editPopW );
1740 XtDestroyWidget( editPopW );
1746 /****************************************************************
1747 * update character list *
1748 ***************************************************************/
1751 * contents : add the specified code to the character list
1755 chgEdCode( code, mode )
1768 ncode = codeToNo( code );
1769 esq = ptnNoToSq( ncode ) - edlist.sqstart;
1774 } else if (efctPtnNum() <= edlist.nlist) {
1776 slctloc = AbsSqToRel(edlist.sqstart, ptnNoToSq( ncode));
1778 if ((esq >= edlist.statloc)
1779 && (esq <= (RelToAbsSq( edlist.sqstart + edlist.statloc,
1780 edlist.nlist - 1) - edlist.sqstart))){
1781 statloc = edlist.statloc;
1782 slctloc = AbsSqToRel(edlist.sqstart+statloc,
1783 edlist.sqstart + esq);
1788 while( RelToAbsSq(edlist.sqstart+statloc, edlist.nlist - 1) < 0)
1789 statloc = RelToAbsSq( edlist.sqstart + statloc, -1)
1791 slctloc = AbsSqToRel( edlist.sqstart + statloc, edlist.sqstart + esq);
1795 if (( slimax = efctPtnNum()) < edlist.nlist)
1796 slimax = edlist.nlist;
1797 XtSetArg( arg[n], XmNmaximum, (XtArgVal)slimax ); n++;
1798 XtSetArg( arg[n], XmNvalue, (XtArgVal)AbsSqToRel( edlist.sqstart, edlist.sqstart + statloc) ); n++;
1799 XtSetValues( wgeScro , arg, n );
1801 chgEdList( statloc, slctloc, mode );
1807 * contents : rewrite the character list
1811 chgEdList( statloc, slctloc, mode )
1821 extern void ListSetLabelStr();
1822 extern void ListSetGlyphImage();
1823 extern void ListUnselectItem();
1824 extern void ListSelectItem();
1826 if((mode == ON) || (edlist.statloc != statloc)){
1827 for (i=0, sq=edlist.sqstart+statloc; i < edlist.nlist; sq++){
1831 if ((no >= 0) && (code = noToCode(no)) >= 0 ){
1832 sprintf(str, "%4x", code);
1833 ListSetLabelStr(i, str);
1834 ListSetGlyphImage(i) ;
1836 edlist.statloc = sq - edlist.sqstart;
1838 } else if (sq > ( edlist.sqstart + edlist.nptn - 1)){
1840 ListSetLabelStr(i, str);
1841 ListSetGlyphImage(i) ;
1847 if( (mode == ON) || (edlist.slctloc != slctloc) ) {
1848 if((0 <= edlist.slctloc) && (edlist.slctloc < edlist.nlist)){
1849 ListUnselectItem(edlist.slctloc);
1851 if((0 <= slctloc) && (slctloc < edlist.nlist)){
1852 ListSelectItem(slctloc);
1854 edlist.slctloc = slctloc;
1860 * contents : rewrite the editting pane
1867 extern void SetCodeString();
1869 if (xl.display == NULL ){
1874 XClearWindow( xl.display, xl.edit_winID );
1875 DrawBorderEdPn( 0, 0, edg.width - 1, edg.height - 1 );
1876 XClearWindow( xl.display, xl.disp_winID );
1877 XClearWindow( xl.display, xl.list_winID );
1878 bitPtnClear( edg.ptn );
1884 if( ptnGet( code, edg.ptn) == 0 ) {
1886 edg.ncode = codeToNo( code );
1887 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
1889 SetCodeString(code);
1898 /****************************************************************
1899 * draw patterns to the editting pane *
1900 ***************************************************************/
1903 * contents : draw a rectangle
1908 DrawRectEdPn( x1, y1, x2, y2 )
1915 short cx1, cy1, cx2, cy2;
1916 XRectangle recOn[MAXPTNSIZE*MAXPTNSIZE];
1917 XRectangle recOff[MAXPTNSIZE*MAXPTNSIZE];
1920 if (xl.display == NULL ){
1936 for( j=y1 ; j <= y2 ; j++ ) {
1937 for( i=x1 ; i <= x2 ; i++ ) {
1938 cx1 = (short)(edpane.pix_w * i);
1939 cy1 = (short)(edpane.pix_h * j);
1940 cx2 = (short)(cx1 + edpane.pix_w - 1);
1941 cy2 = (short)(cy1 + edpane.pix_h - 1);
1943 if( bitRead( edg.ptn, i, j ) != 0 ) {
1944 recOn[nron].x = cx1;
1945 recOn[nron].y = cy1;
1946 recOn[nron].width = (USHORT)(cx2 - cx1);
1947 recOn[nron].height = (USHORT)(cy2 - cy1);
1951 recOff[nroff].x = cx1;
1952 recOff[nroff].y = cy1;
1953 recOff[nroff].width = (USHORT)(cx2 - cx1);
1954 recOff[nroff].height = (USHORT)(cy2 - cy1);
1960 XFillRectangles( xl.display, xl.edit_winID, xl.borderGC, recOn, nron );
1962 XFillRectangles( xl.display, xl.edit_winID, xl.backGC, recOff, nroff );
1967 * contents : draw a lattice inside of the editting pane
1971 DrawBorderEdPn( x1, y1, x2, y2 )
1981 XSegment dseg[MAXPTNSIZE*2];
1983 if (xl.display == NULL ){
2000 cx1 = (short)(edpane.pix_w * x1);
2001 cx2 = (short)(edpane.pix_w * x2 + edpane.pix_w - 1);
2002 for( i=y1 ; i <= y2 ; i++ ) {
2003 cy1 = (short)(edpane.pix_h * i + edpane.pix_h - 1);
2004 dseg[ndseg].x1 = cx1;
2005 dseg[ndseg].y1 = cy1;
2006 dseg[ndseg].x2 = cx2;
2007 dseg[ndseg].y2 = cy1;
2010 cy1 = (short)(edpane.pix_h * y1);
2011 cy2 = (short)(edpane.pix_h * y2 + edpane.pix_h - 1);
2012 for( i=x1 ; i <= x2 ; i++ ) {
2013 cx1 = (short)(edpane.pix_w * i + edpane.pix_w - 1);
2014 dseg[ndseg].x1 = cx1;
2015 dseg[ndseg].y1 = cy1;
2016 dseg[ndseg].x2 = cx1;
2017 dseg[ndseg].y2 = cy2;
2022 XDrawSegments( xl.display, xl.edit_winID, xl.dashGC, dseg, ndseg);
2028 * contents : draw a dot
2032 DrawPointEdPn( x, y, mode )
2040 if (xl.display == NULL ){
2044 x1 = edpane.pix_w * x;
2045 y1 = edpane.pix_h * y;
2046 x2 = x1 + edpane.pix_w - 1;
2047 y2 = y1 + edpane.pix_h - 1;
2050 XFillRectangle( xl.display, xl.edit_winID, xl.borderGC,
2051 x1, y1, x2-x1, y2-y1 );
2053 XFillRectangle( xl.display, xl.edit_winID, xl.backGC,
2054 x1, y1, x2-x1, y2-y1 );
2061 * contents : draw a current character pattern to the display pane
2067 if (xl.display == NULL ){
2071 XPutImage( xl.display, xl.disp_winID, xl.borderGC, xl.dispImage,
2072 0, 0, 0, 0, edg.width, edg.height );
2073 if( xl.list_winID ) {
2074 XPutImage( xl.display, xl.list_winID, xl.borderGC,
2075 xl.dispImage, 0, 0, 0, 0, edg.width, edg.height );
2082 * contents : draw a dot
2086 DrawPointDpPn( x, y, mode )
2092 if (xl.display == NULL ){
2096 XDrawPoint( xl.display, xl.disp_winID, xl.borderGC, x, y );
2098 XDrawPoint( xl.display, xl.list_winID, xl.borderGC, x, y );
2100 XDrawPoint( xl.display, xl.disp_winID, xl.backGC, x, y );
2102 XDrawPoint( xl.display, xl.list_winID, xl.backGC, x, y );
2108 /****************************************************************
2109 * draw patterns by mouse *
2110 ****************************************************************/
2114 * contents : draw a dot
2118 musPoint( evtype, px, py )
2125 if( (em.src1_px == px) && (em.src1_py == py) )
2136 if( edpane.color == ON )
2137 bitSet( edg.ptn, px, py );
2139 bitReset( edg.ptn, px, py );
2141 DrawPointEdPn( px, py, edpane.color );
2142 DrawPointDpPn( px, py, edpane.color );
2147 * contents : draw a line
2151 musLine( evtype, px, py )
2162 harf_pix_w = edpane.pix_w / 2;
2163 harf_pix_h = edpane.pix_h / 2;
2164 r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
2165 r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
2166 r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
2167 r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
2168 rx = px * edpane.pix_w + harf_pix_w;
2169 ry = py * edpane.pix_h + harf_pix_h;
2173 if( (em.src2_px == px) && (em.src2_py == py) )
2175 rubLine( r1_x, r1_y, r2_x, r2_y );
2176 rubLine( r1_x, r1_y, rx, ry );
2181 em.src1_px = em.src2_px = px;
2182 em.src1_py = em.src2_py = py;
2185 if( (r1_x == r2_x) && (r1_y == r2_y) )
2187 rubLine( r1_x, r1_y, r2_x, r2_y );
2189 if ((em.src2_px < 0) || (em.src2_py < 0) ||
2190 (edg.width <= em.src2_px) || (edg.height <= em.src2_py))
2193 bitDrawLine( edg.ptn, em.src1_px, em.src1_py,
2194 em.src2_px, em.src2_py, edpane.color );
2196 DrawRectEdPn( em.src1_px, em.src1_py, em.src2_px, em.src2_py );
2204 * contents : draw a circle
2208 musCircle( evtype, px, py )
2218 extern int bitDrawCircle();
2220 harf_pix_w = edpane.pix_w / 2;
2221 harf_pix_h = edpane.pix_h / 2;
2223 r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
2224 r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
2225 r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
2226 r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
2227 rx = px * edpane.pix_w + harf_pix_w;
2228 ry = py * edpane.pix_h + harf_pix_h;
2232 if( (em.src2_px == px) && (em.src2_py == py) ) {
2235 rubCircle( r1_x, r1_y, r2_x, r2_y );
2236 rubCircle( r1_x, r1_y, rx, ry );
2241 em.src1_px = em.src2_px = px;
2242 em.src1_py = em.src2_py = py;
2245 if( (em.src1_px == px) && (em.src1_py == py) ) {
2248 rubCircle( r1_x, r1_y, r2_x, r2_y );
2250 if( (px < 0) || (py < 0) || (edg.width <= px) || (edg.height <= py) ) {
2253 bitDrawCircle( edg.ptn, em.src1_px, em.src1_py, px, py, edpane.color);
2256 DrawRectEdPn( 0, 0, edg.width -1, edg.height -1 );
2263 * contents : draw a rectangle
2267 musRect( proc, evtype, px, py )
2280 if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
2281 dpx = px - em.src1_px;
2282 dpy = py - em.src1_py;
2283 dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
2286 px = em.src1_px + dpx/abs(dpx) * dp;
2288 py = em.src1_py + dpy/abs(dpy) * dp;
2291 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2292 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2293 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2294 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2295 rx = px * edpane.pix_w + edpane.pix_w / 2;
2296 ry = py * edpane.pix_h + edpane.pix_h / 2;
2300 if( (em.src2_px == px) && (em.src2_py == py) )
2302 rubBand( r1_x, r1_y, r2_x, r2_y );
2303 rubBand( r1_x, r1_y, rx, ry );
2308 resetEditMode( RES_SLCT );
2309 em.src1_px = em.src2_px = px;
2310 em.src1_py = em.src2_py = py;
2313 resetEditMode( RES_MSG | RES_PROC );
2314 rubBand( r1_x, r1_y, r2_x, r2_y );
2315 if( (r1_x == r2_x) || (r1_y == r2_y) )
2317 if( (em.src2_px < 0) || (em.src2_py < 0) ||
2318 (edg.width <= em.src2_px) || (edg.height <= em.src2_py) )
2321 lux = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
2322 luy = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
2323 width = abs( em.src1_px - em.src2_px ) + 1;
2324 height = abs( em.src1_py - em.src2_py ) + 1;
2326 bitDrawRect(edg.ptn, lux, luy, width, height, edpane.color);
2329 DrawRectEdPn( em.src1_px, em.src1_py, px, py );
2336 * contents : edit inside of the specified area (clear, reverse, rotate,etc.)
2340 musRegionProc( proc, evtype, px, py )
2348 extern void SelectSet();
2350 if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
2351 dpx = px - em.src1_px;
2352 dpy = py - em.src1_py;
2353 dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
2356 px = em.src1_px + dpx/abs(dpx) * dp;
2358 py = em.src1_py + dpy/abs(dpy) * dp;
2361 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2362 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2363 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2364 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2365 rx = px * edpane.pix_w + edpane.pix_w / 2;
2366 ry = py * edpane.pix_h + edpane.pix_h / 2;
2370 if( (em.src2_px == px) && (em.src2_py == py) )
2372 rubBand( r1_x, r1_y, r2_x, r2_y );
2373 rubBand( r1_x, r1_y, rx, ry );
2378 if (select_x || select_y || select_w || select_h) {
2379 rubBand( r1_x, r1_y, r2_x, r2_y );
2381 resetEditMode( RES_SLCT );
2382 em.src1_px = em.src2_px = px;
2383 em.src1_py = em.src2_py = py;
2386 resetEditMode( RES_MSG | RES_PROC );
2387 select_x = select_y = select_w = select_h = 0;
2388 if( (r1_x == r2_x) || (r1_y == r2_y) ) {
2389 rubBand( r1_x, r1_y, r2_x, r2_y );
2392 if( (em.src2_px < 0) || (em.src2_py < 0) ||
2393 (edg.width <= em.src2_px) || (edg.height <= em.src2_py) ) {
2394 rubBand( r1_x, r1_y, r2_x, r2_y );
2398 select_x = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
2399 select_y = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
2400 select_w = abs( em.src1_px - em.src2_px ) + 1;
2401 select_h = abs( em.src1_py - em.src2_py ) + 1;
2409 musPasteProc(w, client_data, event)
2411 XtPointer client_data;
2414 static int ox=0, oy=0;
2416 extern void UndoSet();
2417 extern Widget wgeBulB_edit;
2418 extern int bitDrawPaste();
2420 switch(event->type) {
2422 tx = (event->xmotion.x / edpane.pix_w) * edpane.pix_w + edpane.pix_w / 2;
2423 ty = (event->xmotion.y / edpane.pix_h) * edpane.pix_h + edpane.pix_h / 2;
2424 if (tx == ox && ty == oy)
2427 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2431 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2434 XtRemoveEventHandler(wgeBulB_edit,
2435 ButtonReleaseMask|PointerMotionMask,
2436 False, (XtEventHandler)musPasteProc, NULL );
2437 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2440 bitPtnCopy( em.rsv_ptn, edg.ptn );
2442 tx = event->xbutton.x / edpane.pix_w;
2443 ty = event->xbutton.y / edpane.pix_h;
2444 rc = bitDrawPaste(edg.ptn, tx, ty);
2449 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
2461 rubLine( x1, y1, x2, y2 )
2467 if( x1==x2 && y1==y2 ) return;
2469 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1,y1, x2,y2 );
2475 rubBand( x1, y1, x2, y2 )
2481 if( x1==x2 && y1==y2 )
2484 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x2, y1 );
2485 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x1, y2 );
2486 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x2, y1, x2, y2 );
2487 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y2, x2, y2 );
2493 rubCircle( ox, oy, rx, ry )
2502 if( ox==rx && oy==ry ) return;
2506 r = (unsigned int)sqrt( (double)(x*x + y*y) );
2507 if ( r == 0 ) return;
2511 XDrawArc( xl.display, xl.edit_winID, xl.rubGC,
2520 resetEditMode( flag )
2526 if( flag & RES_MSG )
2527 SetString( wgeStaT, "" );
2529 if( flag & RES_PROC )
2530 em.proc = edpane.obj;
2532 if( (flag & RES_SLCT) && (em.slct_f) ) {
2533 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2534 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2535 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2536 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2537 rubBand( r1_x, r1_y, r2_x, r2_y );
2541 if( flag & RES_RSV )
2546 /****************************************************************
2547 * copy character pattern *
2548 ***************************************************************/
2551 * contents : copy or overlay the new character pattern to the current pattern
2556 copyPatterns( fdata, s1_code, s2_code, d1_code, proc )
2564 int d1_ncode, d2_ncode;
2572 char ptn2[MAXPTNBYTE];
2574 extern int last_code;
2576 ret = copySNF(s1_code, s2_code, &ptn, &num, err);
2578 Error_message2((Widget)NULL, err);
2582 if (last_code < (d1_code + num))
2583 last_code = d1_code + num;
2585 if( ptnSense(edg.code) == 1 )
2586 ptnAdd( edg.code, edg.ptn );
2588 d1_ncode = codeToNo( d1_code );
2590 for (i_d=d1_ncode, i_s=0; i_s < num; i_d++) {
2591 if ( codeCheck( noToCode( i_d)))
2593 bitPtnClear( ptn2 );
2594 code_d = noToCode( i_d );
2595 grc_d = ptnGet( code_d, ptn2 );
2598 if( proc == CPY_OVERLAY ) {
2599 for( i=0 ; i < edg.height*((edg.width+7)/8) ; i++ ) {
2600 ptn[i_s][i] |= ptn2[i];
2603 ptnAdd( code_d, ptn[i_s] );
2606 if( ptnAdd( code_d, ptn[i_s] ) != 1 ) {
2607 SetString( wgeStaT, resource.me_non_memory );
2618 for( i=d1_ncode ; i <= d2_ncode; i++ ) {
2619 if ( codeCheck( noToCode(i) ) )
2621 if( ptnSense( noToCode( i ) ) == 1 ) {
2622 code_disp = noToCode( i );
2628 if( (code_disp == 0) && (efctPtnNum() > 0))
2629 code_disp = noToCode( ptnSqToNo(edlist.sqstart) );
2631 chgEdCode( code_disp, ON );
2633 resetEditMode( (UINT) (RES_MSG | RES_PROC | RES_SLCT | RES_RSV) );