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();
137 static int setRealDelArea();
139 /****************************************************************
141 ***************************************************************/
147 /****************************************************************
148 * callback routines *
149 ***************************************************************/
151 static void CancelCB();
166 for ( cnt = 0, sq = edlist.sqstart;
167 sq < (edlist.sqstart + edlist.nptn); sq++) {
169 if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
176 Error_message(widget, message)
180 static NoticeButton is_lock[] = {
181 NBTNARGS( ExitCB, NULL, 'E', True, False ),
182 NBTNARGS( CancelCB, NULL, 'C', True, True )
184 static NButton LockBTN = NBUTTONS( is_lock );
186 SetItemLabel(&LockBTN, 0, resource.l_exit);
187 SetItemLabel(&LockBTN, 1, resource.l_cancel);
188 PopupNotice( (widget), message,
192 resource.l_question_title);
196 Error_message2(widget, message)
200 static NoticeButton is_lock[] = {
201 NBTNARGS( CancelCB, NULL, 'C', True, True )
203 static NButton LockBTN = NBUTTONS( is_lock );
208 SetItemLabel(&LockBTN, 0, resource.l_ok);
209 PopupNotice( (widget), message,
213 resource.l_question_title);
217 * contents : read a character pattern from SNF file
221 CBmOblB_edit( widget, clientData, callData )
233 extern int begin_code;
235 extern int ptnGetInfo();
236 extern void PopupEditPtn();
238 /* open font file and get informations of character to be edited */
240 ret = readSNF( &(edg.fdata), &(edg.width), &(edg.height), err);
243 Error_message(widget, err);
246 dn.ptn_w = (Dimension) edg.width;
247 dn.ptn_h = (Dimension) edg.height;
250 if( xlfdDialog != NULL )
251 PopdownDialog(xlfdDialog);
254 ptnGetInfo( &ptn_n, &ptn_w, &ptn_h );
255 for( i=0 ; i<ptn_n ; i++ ) {
256 code = noToCode( ptnSqToNo(i) );
257 if( begin_code > code){
258 edlist.sqstart = i+1;
263 if( efctPtnNum() > 0) {
264 for ( i=edlist.sqstart; i<(edlist.sqstart+edlist.nptn); i++){
265 if ( codeCheck( noToCode( ptnSqToNo(i))) == 0)
268 edg.ncode = ptnSqToNo( i );
269 edg.code = noToCode( edg.ncode );
270 ptnGet( edg.code, edg.ptn );
272 PopupEditPtn(toplevel);
279 static Boolean do_read = False;
280 static Boolean do_end = False;
282 static void CancelCB() { }
284 static void ContReadCB(w)
287 FalCloseFont(font_id);
290 PopupSelectXLFD(toplevel);
293 static void SaveReadCB()
297 PopupSelectXLFD(toplevel);
301 static void ContEndCB()
303 FalCloseFont(font_id);
307 static void SaveEndCB()
315 * contents : quit editting
321 QuitEditPtn( widget, clientData, callData )
326 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
329 ptnAdd( edg.code, edg.ptn );
331 if( edg.flag == ON ){
340 OpenCB(w, client_data, call_data)
342 XtPointer client_data;
345 static NoticeButton is_save_read_btn1[] = {
346 NBTNARGS( SaveReadCB, NULL, 'S', True, False ),
347 NBTNARGS( ContReadCB, NULL, 'O', True, False ),
348 NBTNARGS( CancelCB, NULL, 'C', True, True ),
350 static NoticeButton is_save_read_btn2[] = {
351 NBTNARGS( ContReadCB, NULL, 'O', True, False ),
352 NBTNARGS( CancelCB, NULL, 'C', True, True ),
354 static NButton SaveReadBTN1 = NBUTTONS( is_save_read_btn1 );
355 static NButton SaveReadBTN2 = NBUTTONS( is_save_read_btn2 );
357 if (QuitEditPtn((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL)){
358 FalCloseFont(font_id);
361 PopupSelectXLFD(toplevel);
364 if (! fullFontData.prm) {
365 SetItemLabel(&SaveReadBTN1, 0, resource.l_do_save_exit);
366 SetItemLabel(&SaveReadBTN1, 1, resource.l_dont_save_exit);
367 SetItemLabel(&SaveReadBTN1, 2, resource.l_cancel);
368 PopupNotice( (w), resource.mn_saved_open ,
372 resource.l_question_title);
374 SetItemLabel(&SaveReadBTN2, 0, resource.l_dont_save_exit);
375 SetItemLabel(&SaveReadBTN2, 1, resource.l_cancel);
376 PopupNotice( (w), resource.mn_saved_open ,
380 resource.l_question_title);
387 ReadCB(w, client_data, call_data)
389 XtPointer client_data;
392 if (fullFontData.xlfdname == NULL) {
395 if (fullFontData.xlfdname == (char *) -1) {
396 Error_message(w, resource.mn_prop_font);
399 CBmOblB_edit( w, client_data, call_data );
402 /****************************************************************
403 * callback routines and event handler *
404 ***************************************************************/
407 * contents : write character patterns to SNF file
411 WPwriteSNF( restart )
415 char str[MG_MAXSIZE];
417 switch( rc = writeSNF( restart, &err ) ) {
420 XtSetSensitive( dnPopW, TRUE );
423 sprintf(str, "%s(permission denied)", resource.me_write_snf);
426 sprintf(str, "%s(disk full)", resource.me_write_snf);
429 sprintf(str, "%s(pipe error)", resource.me_write_snf);
432 sprintf(str, "%s(fork error)", resource.me_write_snf);
435 sprintf(str, "%s(execv error)", resource.me_write_snf);
438 sprintf(str, "%s(data error)", resource.me_write_snf);
441 sprintf(str, "%s", resource.me_write_snf);
443 SetString( wgeStaT, str );
447 UpdateMessage( resource.mg_register );
453 ContReadCB((Widget)NULL);
462 sprintf( str, "%s", resource.me_wait );
464 sprintf( str, "%s(%3d%%)", resource.mg_write_snf , rc-1000 );
466 SetString( wgeStaT, str );
467 XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)ON );
469 XSync( xl.display,0 );
478 * contents : write character patterns to SNF file
484 char str[MG_MAXSIZE];
486 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
487 SetString( wgeStaT, resource.mg_write_snf );
490 ptnAdd( edg.code, edg.ptn );
492 if( edg.flag == ON ) {
493 sprintf( str, "%s", resource.mg_write_snf );
495 XtSetSensitive( dnPopW, FALSE );
497 XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)OFF );
501 SetString( wgeStaT, "" );
508 * contents : destroy the editor window
521 * contents : close dtudcfonted
526 CBeOblB_aEnd( widget, clientData, callData )
531 static NoticeButton is_save_exit_btn[] = {
532 NBTNARGS( SaveEndCB, NULL, 'S', True, False ),
533 NBTNARGS( ContEndCB, NULL, 'E', True, False ),
534 NBTNARGS( CancelCB, NULL, 'C', True, True ),
536 static NButton SaveEndBTN = NBUTTONS( is_save_exit_btn );
538 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
541 ptnAdd( edg.code, edg.ptn );
542 if( edg.flag == ON ) {
544 SetItemLabel(&SaveEndBTN, 0, resource.l_do_save);
545 SetItemLabel(&SaveEndBTN, 1, resource.l_dont_save);
546 SetItemLabel(&SaveEndBTN, 2, resource.l_cancel);
547 PopupNotice( widget, resource.mn_saved_exit, D_QUESTION,
548 &SaveEndBTN, True, resource.l_question_title);
551 FalCloseFont(font_id);
561 CBeOblB_rCmd( widget, proc, callData )
566 extern void SelectUnset();
567 extern void UndoSet();
568 if (!select_x && !select_y && !select_w && !select_h)
571 bitPtnCopy( em.rsv_ptn, edg.ptn );
572 rubBand( r1_x, r1_y, r2_x, r2_y );
575 bitDrawCls (edg.ptn, select_x, select_y, select_w, select_h );
578 bitDrawSet (edg.ptn, select_x, select_y, select_w, select_h );
581 bitDrawRev (edg.ptn, select_x, select_y, select_w, select_h );
584 bitDrawRoll(edg.ptn, select_x, select_y, select_w, select_h);
587 bitDrawSymV(edg.ptn, select_x, select_y, select_w, select_h );
590 bitDrawSymH(edg.ptn, select_x, select_y, select_w, select_h );
594 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
596 select_x = select_y = select_w = select_h = 0;
603 CBeOblB_rCmdp( widget, proc, callData )
608 extern Widget wgeBulB_edit;
609 extern void CopySet();
610 extern void UndoSet();
611 extern void SelectUnset();
615 if (!select_x && !select_y && !select_w && !select_h)
617 rubBand( r1_x, r1_y, r2_x, r2_y );
618 bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, False);
621 select_x = select_y = select_w = select_h = 0;
626 if (!select_x && !select_y && !select_w && !select_h)
629 rubBand( r1_x, r1_y, r2_x, r2_y );
630 bitPtnCopy( em.rsv_ptn, edg.ptn );
631 bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, True);
635 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
637 select_x = select_y = select_w = select_h = 0;
643 XtAddEventHandler(wgeBulB_edit,
644 ButtonReleaseMask|PointerMotionMask,
645 False, musPasteProc, NULL );
653 * contents : cancel all editting
658 CBeOblB_rCan( widget, clientData, callData )
663 extern void UndoUnset();
665 resetEditMode( RES_MSG | RES_PROC | RES_SLCT );
667 if( em.rsv_f == ON ) {
668 bitPtnCopy( edg.ptn, em.rsv_ptn );
671 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
682 * contents : get a sequential number of the editor
685 RelToAbsSq( from, cnt)
693 for ( i = -1; from < (edlist.sqstart + edlist.nptn) ; from++) {
694 no = ptnSqToNo(from);
695 if (( no >= 0) && ( noToCode( no) >= 0) ) {
703 for ( i = -1; from >= edlist.sqstart; from--) {
704 no = ptnSqToNo(from);
705 if (( no >= 0) && ( noToCode( no) >= 0) ) {
716 * contents : get a relative number of the system area
719 AbsSqToRel( from, to)
735 for ( cnt = -1, sq = from; sq <= to; sq++) {
737 if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
752 * contents : be the character list selected
757 EHeStaT_list( widget, select, e )
760 XEvent *e; /* X Event */
765 resetEditMode( RES_MSG|RES_PROC|RES_SLCT|RES_RSV );
767 if( (e->xbutton.button != 1) || (e->type != ButtonRelease) ||
768 (e->xbutton.x < 0) || ((int)edlist.elem_w < e->xbutton.x) ||
769 (e->xbutton.y < 0) || ((int)edlist.elem_h < e->xbutton.y)
773 if( edlist.slctloc == select )
777 sq = RelToAbsSq( edlist.sqstart + edlist.statloc, select);
779 if( (no = ptnSqToNo(sq)) == -1 )
782 code = noToCode( no );
783 if( codeCheck( code ) == -1 )
786 if( ptnSense( code) == 0 )
789 chgEdList( edlist.statloc, select, OFF );
790 if( ptnSense(edg.code) == 1 )
791 ptnAdd(edg.code, edg.ptn );
799 * contents : update the character list
804 CBeScro( widget, clientData, callData )
814 XtSetArg( arg[n], XmNvalue, (XtArgVal)&newl ); n++;
815 XtGetValues( wgeScro , arg, n );
817 if (( new_statloc = RelToAbsSq( edlist.sqstart, newl)) < 0) {
820 new_statloc -= edlist.sqstart;
824 new_slct = edlist.slctloc
825 - AbsSqToRel( edlist.sqstart + edlist.statloc,
826 edlist.sqstart + new_statloc);
827 chgEdList( new_statloc, new_slct, OFF);
834 * contents : select the edit items by mouse
839 EHeBulB_eMEv( widget, clientData, e )
842 XEvent *e; /* X Event */
847 if (edpane.pix_w * edpane.pix_h == 0 ) {
851 if( e->type == ButtonPress ){
854 if( (edg.code == 0) || (em.drag_f == OFF) )
856 if( e->type == ButtonRelease ){
860 px = e->xbutton.x / edpane.pix_w;
861 py = e->xbutton.y / edpane.pix_h;
863 if (( e->type == ButtonPress) || (e->type == ButtonRelease)){
864 downbutton = e->xbutton.button;
865 }else if ( e->type == MotionNotify ){
866 if ( e->xmotion.state & Button1Mask ){
867 downbutton = 1; /* select button */
868 }else if ( e->xmotion.state & Button2Mask ){
869 downbutton = 2; /* adjust button */
875 switch( downbutton ) {
879 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
880 musPoint( e->type, px, py );
883 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
884 musLine( e->type, px, py );
887 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
888 musCircle( e->type, px, py );
891 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
892 musRect( em.proc, e->type, px, py );
895 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
896 musPoint( e->type, px, py );
899 musRegionProc( em.proc, e->type, px, py );
907 if( (0 <= px) && (px < edg.width) && (0 <= py) && (py < edg.height) ) {
908 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
912 if( (em.adj_px == px) && (em.adj_py == py) )
918 if( bitRead(edg.ptn, px, py) == 0 ) {
919 bitSet( edg.ptn, px, py );
920 DrawPointEdPn( px,py, 1 );
921 DrawPointDpPn( px,py, 1 );
924 bitReset( edg.ptn, px, py );
925 DrawPointEdPn( px,py, 0 );
926 DrawPointDpPn( px,py, 0 );
943 * contents : restore the editting pane
948 EHeBulB_eExp( widget, clientData, e )
951 XEvent *e; /* X Event */
956 if (edpane.pix_w * edpane.pix_h == 0 ) {
960 x1 = e->xexpose.x / edpane.pix_w;
961 y1 = e->xexpose.y / edpane.pix_h;
962 x2 = (e->xexpose.x + e->xexpose.width - 1) / edpane.pix_w;
963 y2 = (e->xexpose.y + e->xexpose.height - 1) / edpane.pix_h;
965 DrawRectEdPn( x1, y1, x2, y2 );
966 DrawBorderEdPn( x1, y1, x2, y2 );
973 * contents : specifies the drawing operation (Pont/Line/Rectangle/Circle)
978 CBeRecB_obj( widget, obj, call)
981 XmToggleButtonCallbackStruct *call;
983 extern void SelectUnset();
985 if (call->set == False)
988 resetEditMode( RES_MSG | RES_RSV | RES_SLCT );
990 if (obj == PROC_ERASE)
996 if (obj != PROC_SELECT) {
997 if (select_x || select_y || select_w || select_h) {
998 rubBand( r1_x, r1_y, r2_x, r2_y );
999 select_x = select_y = select_w = select_h = 0;
1009 * contents : restore the displaying pane
1014 EHeBulB_dExp( widget, clientData )
1018 if (xl.display == NULL ){
1026 * contents : set the range to be add or deleted
1030 codeAreaSet(s_code,e_code)
1037 str = MngCodeTfValue();
1044 sscanf( str, "%x %c %x", s_code, &delm, e_code );
1045 if (str) free( str );
1055 if( codeCheck(*s_code) || codeCheck(*e_code) ||
1056 (*s_code > *e_code) ) {
1063 /****************************************************************
1064 * callback routines (character management window) *
1065 ***************************************************************/
1068 BeforeMngCheck(s_code, e_code)
1072 if(codeAreaSet(s_code, e_code) == -1) {
1073 DispMngErrorMessage( resource.me_illegal_code );
1080 DoAddProc(s_code, e_code)
1088 char ptn[MAXPTNBYTE];
1092 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1095 s_ncode = codeToNo( s_code );
1096 e_ncode = codeToNo( e_code );
1099 for( i=s_ncode ; i <= e_ncode ; i++ ) {
1101 if ( codeCheck( code))
1103 if (ptnSense(code) == 0) {
1104 if(ptnAdd(code, ptn) != 1) {
1105 SetString( wgeStaT, resource.me_non_memory );
1115 if( ptnSense( edg.code ) == 1 ) {
1116 ptnAdd( edg.code, edg.ptn );
1120 chgEdCode( s_code, mode );
1123 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1128 void PopupDelNotice();
1129 Widget CreateDelNotice();
1133 DoDelProc( s_code, e_code )
1137 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1139 if( ptnSense( edg.code) == 1 )
1140 ptnAdd( edg.code, edg.ptn );
1142 dn.s_ncode = codeToNo( s_code );
1143 dn.e_ncode = codeToNo( e_code );
1145 if (setRealDelArea(&dn.s_ncode, &dn.e_ncode, &dn.sq_start, &dn.sq_end) == -1) {
1146 DispMngErrorMessage( resource.me_nodelete_code );
1149 dn.sq_top = dn.sq_start;
1150 dn.disp_num = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
1151 dn.disp_num = (dn.disp_num <= D_MAX) ? dn.disp_num : D_MAX;
1153 PopupDelNotice( mngPtnW );
1161 * contents : get the real range to be add or delete
1166 setRealDelArea(s_ncode, e_ncode, sq_start, sq_end )
1167 int *s_ncode, *e_ncode;
1168 int *sq_start, *sq_end;
1178 for( i=*s_ncode ; i <= ncode ; i++ ) {
1179 if (((sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i)) == 0)) {
1185 *s_ncode = ptnSqToNo( sq );
1194 for( i=*e_ncode ; i >= ncode ; i-- ) {
1195 if ((( sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i) ) == 0)) {
1200 *e_ncode = ptnSqToNo( sq );
1210 /****************************************************************
1211 * callback routines (Copy) *
1212 ****************************************************************/
1220 str = CpySrcCodeTfValue();
1230 sscanf( str, "%x %c %x", &cpm.s1_code,&delm, &cpm.s2_code );
1234 cpm.s2_code = cpm.s1_code;
1241 if (cpm.s1_code > cpm.s2_code)
1251 str = CpyDestCodeTfValue();
1259 sscanf( str, "%x", &cpm.d1_code );
1262 if( codeCheck(cpm.d1_code) ) {
1269 BeforeCpyCheck( proc )
1272 int s_ncode, e_ncode;
1273 int r1_code, r2_code;
1277 extern void PopupCpyNotice();
1279 if (copyFontData.xlfdname == NULL) {
1280 DispCpyErrorMessage(resource.me_non_srcfile);
1284 if (CpySrcCodeCheck() == -1){
1285 DispCpyErrorMessage( resource.me_illegal_srccode );
1289 if (CpyDestCodeCheck() == -1){
1290 DispCpyErrorMessage( resource.me_illegal_destcode );
1294 s_ncode = codeToNo( cpm.d1_code );
1295 e_ncode = codeToNo( cpm.d1_code + cpm.s2_code - cpm.s1_code);
1296 r1_code = r2_code = 0;
1297 for( i=s_ncode ; i <= e_ncode ; i++ ) {
1299 if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) {
1301 r1_code = noToCode(i);
1302 r2_code = noToCode(i);
1308 if( r1_code != 0 ) {
1309 if( r1_code == r2_code ) {
1310 sprintf( rstr, "%s %x¡¡", resource.l_code, r1_code );
1311 } else if ( codeCheck(r1_code) && codeCheck(r2_code)){
1312 sprintf( rstr, " %x - %x", r1_code, r2_code );
1314 sprintf( rstr, "%s %x - %x ", resource.l_code_range, r1_code, r2_code );
1316 PopupCpyNotice(rstr);
1326 extern void PopdownCpyPtn();
1330 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1332 copyPatterns( cpm.fdata, cpm.s1_code, cpm.s2_code, cpm.d1_code, cpm.proc );
1335 /****************************************************************
1337 ****************************************************************/
1338 #define R(name, class, member,def) { \
1343 XtOffsetOf(Resource, member), \
1347 #define RBoolean(name, class, member,def) \
1348 { name, class, XtRBoolean, sizeof(XtRBoolean), \
1349 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1351 #define RDimension(name, class, member,def) \
1352 { name, class, XtRDimension, sizeof(XtRDimension), \
1353 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1355 #define Rint(name, class, member,def) \
1356 { name, class, XtRInt, sizeof(XtRInt), \
1357 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1359 #define RPixel(name, class, member,def) \
1360 { name, class, XtRPixel, sizeof(XtRPixel), \
1361 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1363 static XtResource app_resources[] = {
1364 RBoolean("Codepoint", "codepoint", codepoint, "False"),
1366 R( "lptog", "Lptog", l_ptog, DFLTPATH ),
1367 R( "lptogCmd", "LptogCmd", l_ptog_cmd, DFLTCMD ),
1369 /* CreateCaptionFrame() */
1370 RBoolean( "captResize", "CaptResize", capt_resize, "True" ) ,
1371 Rint( "captLftoff", "CaptLftoff", capt_lftoff, "2" ) ,
1372 Rint( "captTopoff", "CaptTopoff", capt_topoff, "2" ) ,
1373 Rint( "captRghoff", "CaptRghoff", capt_rghoff, "2" ) ,
1375 RPixel( "paneBackground", "paneBackground", pane_background, "white" ),
1376 RPixel( "paneForeground", "PaneForeground", pane_foreground, "black" ),
1377 RPixel( "background", "Background", background, "white" ),
1378 RPixel( "foreground", "Foreground", foreground, "black" ),
1380 /* CreateMenuButtons() */
1381 RDimension( "menuMargin", "MenuMargin", menu_margin, "0" ) ,
1383 /* CreateDialogAndButtons() */
1384 RBoolean( "diaTmAutomng", "DiaTmAutomng", dia_tm_automng, "False" ) ,
1385 RDimension( "diaTmWidth", "DiaTmWidth", dia_tm_width, "4" ) ,
1386 RDimension( "diaTmHeight", "DiaTmHeight", dia_tm_height, "4" ) ,
1387 RBoolean( "diaTmResize", "DiaTmResize", dia_tm_resize, "True" ) ,
1388 RBoolean( "diaTmMinimize", "DiaTmMinimize", dia_tm_minimize, "True" ) ,
1390 RDimension( "diaRwWidth", "DiaRwWidth", dia_rw_width, "6" ) ,
1391 RDimension( "diaRwHeight", "DiaRwHeight", dia_rw_height, "6" ) ,
1392 RDimension( "diaRwSpacing", "DiaRwSpacing", dia_rw_spacing, "4" ) ,
1394 /* CreateDrawingArea() */
1395 RDimension( "drawBorder", "DrawBorder", draw_border, "1" ) ,
1396 Rint( "drawTopoff", "DrawTopoff", draw_topoff, "2" ) ,
1397 Rint( "drawLftoff", "DrawLftoff", draw_lftoff, "2" ) ,
1400 RBoolean( "popResize", "PopResize", pop_resize , "True" ) ,
1401 RBoolean( "popMinimize", "PopMinimize", pop_minimize , "True" ) ,
1403 /* CreateTemplateDialog() */
1404 RBoolean( "tempResize", "TempResize", temp_resize, "True" ) ,
1405 RBoolean( "tempMinimize", "TempMinimize", temp_minimize, "True" ) ,
1407 RDimension( "tempWidth", "TempWidth", temp_width, "1" ) ,
1408 RDimension( "tempHeight", "TempHeight", temp_height, "1" ) ,
1410 /* CreateMenuBarAndFooterMessageForm() */
1411 Rint( "edBarTopoff", "EdBarTopoff", ed_bar_topoff, "1" ) ,
1412 Rint( "edBarLftoff", "EdBarLftoff", ed_bar_lftoff, "1" ) ,
1413 Rint( "edBarRghoff", "EdBarRghoff", ed_bar_rghoff, "1" ) ,
1415 Rint( "edFrmBtmoff", "EdFrmBtmoff", ed_frm_btmoff, "3" ) ,
1416 Rint( "edFrmLftoff", "EdFrmLftoff", ed_frm_lftoff, "3" ) ,
1417 Rint( "edFrmRghoff", "EdFrmRghoff", ed_frm_rghoff, "3" ) ,
1419 RDimension( "edMsgMargintop", "EdMsgMargintop", ed_msg_margintop, "3" ) ,
1420 RDimension( "edMsgMarginbtm", "EdMsgMarginbtm", ed_msg_marginbtm, "3" ) ,
1422 RDimension( "edMesgMargintop", "EdMesgMargintop", ed_mesg_margintop, "3" ) ,
1423 RDimension( "edMesgMarginbtm", "EdMesgMarginbtm", ed_mesg_marginbtm, "3" ) ,
1425 Rint( "edSepBtmoff", "EdSepBtmoff", ed_sep_btmoff, "3" ) ,
1426 Rint( "edSepLftoff", "EdSepLftoff", ed_sep_lftoff, "0" ) ,
1427 Rint( "edSepRghoff", "EdSepRghoff", ed_sep_rghoff, "0" ) ,
1428 RDimension( "edSepMargin", "EdSepMargin", ed_sep_margin, "0" ) ,
1430 Rint( "edWgeTopoff", "EdWgeTopoff", ed_wge_topoff, "10" ) ,
1431 Rint( "edWgeLftoff", "EdWgeLftoff", ed_wge_lftoff, "10" ) ,
1432 Rint( "edWgeRghoff", "EdWgeRghoff", ed_wge_rghoff, "10" ) ,
1433 Rint( "edWgeBtmoff", "EdWgeBtmoff", ed_wge_btmoff, "10" ) ,
1436 RBoolean( "frameResize", "FrameResize", frame_resize, "False" ) ,
1438 /* CreateScrollBase() */
1439 RDimension( "scllFrWidth", "ScllFrWidth", scll_fr_width, "500" ) ,
1441 RDimension( "scllFrThick", "ScllFrThick", scll_fr_thick, "2" ) ,
1443 Rint( "scllBarLftoff", "ScllBarLftoff", scll_bar_lftoff, "4" ) ,
1451 int CodePoint = False;
1457 register XErrorEvent *ev;
1459 fprintf (stderr, "dtudcfonted: warning, error event receieved.\n");
1468 static char class_name[] = "Dtudcfonted";
1471 /* initialize GUI */
1472 toplevel = (Widget)GuiInitialize(&app, class_name, &argc, argv);
1474 /* get application's resources */
1475 XtGetApplicationResources( toplevel, &resource,
1476 app_resources, XtNumber(app_resources), NULL, 0);
1478 if (resource.codepoint)
1480 /* initialize the code range */
1481 for( i=1 ; i < argc ; i++ ) {
1482 if( !strcmp(argv[i],"-pane_size") ) {
1484 edpane_size = atoi( argv[i] );
1485 } else if( !strcmp(argv[i],"-codepoint") ) {
1490 resource.mg_write_snf = GETMESSAGE(2, 2, "Registration processing inside.");
1491 resource.me_write_snf = GETMESSAGE(2, 4, "Failed in the registration of the character.");
1492 resource.me_illegal_code = GETMESSAGE(2, 6, "Illegal code.");
1493 resource.me_non_memory = GETMESSAGE(2, 8, "Because the memory allocation cannot be done, it is not possible to add.");
1494 resource.mg_non_code = GETMESSAGE(2, 10, "There is no character of the specified code.");
1495 resource.me_illegal_srccode = GETMESSAGE(2, 12, "The mistake is found in the specified copy origin code.");
1496 resource.me_illegal_destcode = GETMESSAGE(2, 14, "The mistake is found in the specified copy target code.");
1497 resource.me_nodelete_code = GETMESSAGE(2, 16, "There is no character in the specified area.");
1498 resource.me_wait = GETMESSAGE(2, 18, "Please wait for a while.");
1499 resource.me_non_srcfile = GETMESSAGE(2, 20, "No copy origin code file is specified.");
1500 resource.mn_no_font = GETMESSAGE(2, 22, "Informations of user defined character cannot collect.\nThere is no font specified.");
1501 resource.mn_plural_font = GETMESSAGE(2, 24, "Informations of user defined character cannot collect.\nThere are plural fonts specified.");
1502 resource.mn_not_udc = GETMESSAGE(2, 26, "The specified font do not have any UDCs areas.");
1503 resource.mn_no_mem = GETMESSAGE(2, 28, "There are no memories any more.");
1504 resource.mn_illegal_area = GETMESSAGE(2, 30, "The information of UDCs area is illegal.");
1505 resource.mn_no_read = GETMESSAGE(2, 32, "The font file cannot read.\nPattern area was broken.");
1506 resource.mn_prop_font = GETMESSAGE(2, 34, "Dtudcfonted cannot edit proportional character font.");
1507 resource.mn_saved_open = GETMESSAGE(2, 36, "There are unsaved edits.\nDo you want to save them before opening?");
1508 resource.mn_saved_exit = GETMESSAGE(2, 38, "There are unsaved edits.\nDo you want to save them before exiting?");
1509 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");
1510 resource.mn_no_perm = GETMESSAGE(2, 42, "No write permission for this font. You should change the file access mode before saving.\n");
1512 resource.l_selectitem = GETMESSAGE(2, 100, "Select Items"); /* font open */
1513 resource.l_codeset = GETMESSAGE(2, 102, " CodeSet:");
1514 resource.l_style = GETMESSAGE(2, 104, " Style:");
1515 resource.l_width = GETMESSAGE(2, 106, " Width:");
1516 resource.l_height = GETMESSAGE(2, 108, " Height:");
1517 resource.exec_label = GETMESSAGE(2, 110, "Open");
1518 resource.quit_label = GETMESSAGE(2, 112, "Quit");
1520 resource.l_font = GETMESSAGE(2, 114, "Font"); /* menu bar */
1521 resource.l_edit = GETMESSAGE(2, 116, "Edit");
1522 resource.l_manage = GETMESSAGE(2, 118, "Character");
1523 resource.l_info = GETMESSAGE(2, 120, "Information");
1525 resource.l_open_w = GETMESSAGE(2, 122, "Open"); /* font menu */
1526 resource.l_save = GETMESSAGE(2, 124, "Save");
1527 resource.l_exit = GETMESSAGE(2, 126, "Exit");
1529 resource.l_clear = GETMESSAGE(2, 128, "Clear"); /* edit menu */
1530 resource.l_set = GETMESSAGE(2, 130, "Set");
1531 resource.l_reverse = GETMESSAGE(2, 132, "Reverse");
1532 resource.l_cut = GETMESSAGE(2, 134, "Cut");
1533 resource.l_Copy = GETMESSAGE(2, 135, "Copy");
1534 resource.l_paste = GETMESSAGE(2, 136, "Paste");
1535 resource.l_roll = GETMESSAGE(2, 138, "Rotate");
1536 resource.l_updown_roll = GETMESSAGE(2, 140, "Vertical Roll");
1537 resource.l_leftright_roll = GETMESSAGE(2, 142, "Horizontal Roll");
1538 resource.l_undo = GETMESSAGE(2, 144, "Undo");
1540 resource.l_manage_w = GETMESSAGE(2, 146, "Add/Delete..."); /* character menu */
1541 resource.l_copy_w = GETMESSAGE(2, 148, "Copy...");
1543 resource.l_xlfd = GETMESSAGE(2, 150, "XLFD name..."); /* information menu */
1544 resource.l_codearea = GETMESSAGE(2, 152, "Code Area...");
1546 resource.l_add = GETMESSAGE(2, 154, "Add"); /* add/delete dialog */
1547 resource.l_delete = GETMESSAGE(2, 156, "Delete");
1548 resource.l_cancel = GETMESSAGE(2, 158, "Cancel");
1550 resource.l_manage_code = GETMESSAGE(2, 160, "Code(hex):"); /* copy dialog */
1551 resource.l_copy_src_code = GETMESSAGE(2, 162, " Copy origin code(hex):");
1552 resource.l_copy_dest_code = GETMESSAGE(2, 164, "Copy target code(hex):");
1553 resource.l_copy = GETMESSAGE(2, 166, "Copy");
1554 resource.l_overlay = GETMESSAGE(2, 168, "Overlay");
1555 resource.l_ok = GETMESSAGE(2, 170, "OK");
1557 resource.l_do_save = GETMESSAGE(2, 172, "Save"); /* unsaved edits */
1558 resource.l_dont_save = GETMESSAGE(2, 174, "Do not Save");
1559 resource.l_do_save_exit = GETMESSAGE(2, 176, "Save and Exit");
1560 resource.l_dont_save_exit = GETMESSAGE(2, 178, "Do not Save and Exit");
1562 resource.mg_start_del_s = GETMESSAGE(2, 180, "The following character will be deleted."); /* delete notice dialog */
1563 resource.mg_start_del_cs = GETMESSAGE(2, 182, "character");
1564 resource.mg_start_del_m = GETMESSAGE(2, 184, "The following characters will be deleted.");
1565 resource.mg_start_del_cm = GETMESSAGE(2, 186, "characters");
1566 resource.mg_register = GETMESSAGE(2, 188, "Register completed");
1567 resource.l_code = GETMESSAGE(2, 190, " Code : ");
1568 resource.l_code_range = GETMESSAGE(2, 192, " Code range : ");
1570 resource.message = GETMESSAGE(2, 194, "Message : ");
1572 resource.code = GETMESSAGE(2, 196, "code..."); /* code dialog */
1573 resource.previous = GETMESSAGE(2, 198, "Page up");
1574 resource.next = GETMESSAGE(2, 200, "Page down");
1575 resource.apply = GETMESSAGE(2, 202, "Apply");
1577 resource.l_question_title = GETMESSAGE(2, 204, "dtudcfonted - Question");
1578 resource.l_warning_title = GETMESSAGE(2, 206, "dtudcfonted - Warning");
1579 resource.l_error_title = GETMESSAGE(2, 208, "dtudcfonted - Error");
1580 resource.l_copy_title = GETMESSAGE(2, 210, "dtudcfonted - Copy");
1581 resource.l_open_title = GETMESSAGE(2, 212, "dtudcfonted - Open");
1582 resource.l_add_title = GETMESSAGE(2, 214, "dtudcfonted - Add/Delete");
1583 resource.l_xlfd_title = GETMESSAGE(2, 216, "dtudcfonted - XLFD");
1584 resource.l_codearea_title = GETMESSAGE(2, 218, "dtudcfonted - CodeArea");
1586 resource.file_name = GETMESSAGE(2, 230, "File name");
1587 resource.xlfd_name = GETMESSAGE(2, 232, "XLFD name");
1588 resource.codearea = GETMESSAGE(2, 234, "Code area");
1590 resource.falerrmsg[0] = GETMESSAGE(2, 300, "Fatal error occurred.");
1591 resource.falerrmsg[1] = GETMESSAGE(2, 301, "Cannot open the font file.");
1592 resource.falerrmsg[2] = GETMESSAGE(2, 302, "Cannot read the font file.");
1593 resource.falerrmsg[3] = GETMESSAGE(2, 303, "There is no more memory.");
1594 resource.falerrmsg[4] = GETMESSAGE(2, 304, "Fatal error occurred.");
1595 resource.falerrmsg[5] = GETMESSAGE(2, 305, "The specified font file does not exist.");
1596 resource.falerrmsg[6] = GETMESSAGE(2, 306, "This font is not a pcf or snf font.");
1597 resource.falerrmsg[7] = GETMESSAGE(2, 307, "Cannot open fonts.list file.");
1598 resource.falerrmsg[8] = GETMESSAGE(2, 308, "The format of fonts.list file is illegal.");
1599 resource.falerrmsg[9] = GETMESSAGE(2, 309, "The descriptions of the fonts.list file are incorrect.");
1600 resource.falerrmsg[10] = GETMESSAGE(2, 310, "The format of fonts.list file is illegal.");
1601 resource.falerrmsg[11] = GETMESSAGE(2, 311, "Cannot open fonts.dir file.");
1602 resource.falerrmsg[12] = GETMESSAGE(2, 312, "Cannot read fonts.dir file.");
1603 resource.falerrmsg[13] = GETMESSAGE(2, 313, "Cannot read font properties.");
1604 resource.falerrmsg[14] = GETMESSAGE(2, 314, "Cannot get FONT property.");
1605 resource.falerrmsg[15] = GETMESSAGE(2, 315, "Cannot get FAMILY_NAME property.");
1606 resource.falerrmsg[16] = GETMESSAGE(2, 316, "This font file is already opened by other application.");
1607 resource.falerrmsg[17] = GETMESSAGE(2, 317, "Cannot lock font file.");
1608 resource.falerrmsg[18] = GETMESSAGE(2, 318, "Cannot unlock font file.");
1609 resource.falerrmsg[19] = GETMESSAGE(2, 319, "Cannot get lock information from the font file.");
1610 resource.falerrmsg[20] = GETMESSAGE(2, 320, "Cannot find the specified font file.");
1611 resource.falerrmsg[21] = GETMESSAGE(2, 321, "Cannot read NLS database.");
1612 resource.falerrmsg[22] = GETMESSAGE(2, 322, "Cannot get charset names from NLS database.");
1613 resource.falerrmsg[23] = GETMESSAGE(2, 323, "Charset name not defined in NLS database.");
1614 resource.falerrmsg[24] = GETMESSAGE(2, 324, "The specified font has not been opened.");
1615 resource.falerrmsg[25] = GETMESSAGE(2, 325, "Fatal error occurred.");
1620 /* initialize the global values and allocate the memories */
1624 /* displays the selection window */
1625 PopupSelectXLFD(toplevel);
1627 XSetErrorHandler((XErrorHandler)xerror);
1628 XSetIOErrorHandler((XIOErrorHandler)xerror);
1638 * contents : initialize the global values
1646 edg.code = edg.ncode = 0;
1647 bitPtnClear( edg.ptn );
1650 edlist.nlist = EDLIST_MAX;
1651 edlist.statloc = edlist.slctloc = 0;
1654 edlist.list_h = edlist.elem_w = edlist.elem_h = (Dimension)0;
1655 edlist.back = resource.pane_background;
1656 edlist.border = resource.pane_foreground;
1659 edpane.width = edpane_size;
1660 edpane.height = edpane_size;
1662 edpane.width = EDPANE_SIZE;
1663 edpane.height = EDPANE_SIZE;
1665 edpane.pix_w = edpane.pix_h = 0;
1668 edpane.back = resource.pane_background;
1669 edpane.border = resource.pane_foreground;
1672 xl.root_winID = xl.edit_winID = xl.disp_winID = xl.list_winID =
1674 xl.borderGC = xl.backGC = xl.rubGC = xl.dashGC = (GC)NULL;
1675 xl.dispImage = NULL;
1677 dn.elem_w = dn.elem_h = (Dimension)0;
1678 dn.ptn_w = dn.ptn_h = (Dimension)0;
1679 dn.list_h = (Dimension)0;
1680 dn.s_ncode = dn.e_ncode = 0;
1681 dn.sq_top = dn.sq_start = dn.sq_end = 0;
1684 for ( i=0 ; i<D_MAX ; i++ ) {
1685 dl[i].disp_winID = (Window)NULL;
1686 dl[i].dispImage = NULL;
1687 bitPtnClear( dl[i].ptn );
1689 for ( i=0 ; i<EDLIST_MAX ; i++ ) {
1690 dl_glyph[i].disp_winID = (Window)NULL;
1691 dl_glyph[i].dispImage = NULL;
1692 bitPtnClear( dl_glyph[i].ptn );
1696 em.adj_px = em.adj_py = 0;
1697 em.proc = em.slct_f = 0;
1698 em.src1_px = em.src1_py = 0;
1699 em.src2_px = em.src2_py = 0;
1700 em.dest_px = em.dest_py = 0;
1702 bitPtnClear( em.rsv_ptn );
1704 cpm.s1_code = cpm.s2_code = cpm.d1_code = 0;
1712 /****************************************************************
1713 * distroy the "User defined character editor" window *
1714 ****************************************************************/
1717 * contents : destroy the editting window
1727 XFree( (char *)xl.dispImage );
1728 XFreeGC( xl.display, xl.borderGC );
1729 XFreeGC( xl.display, xl.backGC );
1730 XFreeGC( xl.display, xl.rubGC );
1731 XFreeGC( xl.display, xl.dashGC );
1733 for( i=0; i<EDLIST_MAX; i++ ){
1734 if( dl_glyph[i].dispImage ){
1735 XFree( (char *)dl_glyph[i].dispImage );
1736 dl_glyph[i].dispImage = NULL ;
1740 XtPopdown( editPopW );
1741 XtDestroyWidget( editPopW );
1747 /****************************************************************
1748 * update character list *
1749 ***************************************************************/
1752 * contents : add the specified code to the character list
1756 chgEdCode( code, mode )
1769 ncode = codeToNo( code );
1770 esq = ptnNoToSq( ncode ) - edlist.sqstart;
1775 } else if (efctPtnNum() <= edlist.nlist) {
1777 slctloc = AbsSqToRel(edlist.sqstart, ptnNoToSq( ncode));
1779 if ((esq >= edlist.statloc)
1780 && (esq <= (RelToAbsSq( edlist.sqstart + edlist.statloc,
1781 edlist.nlist - 1) - edlist.sqstart))){
1782 statloc = edlist.statloc;
1783 slctloc = AbsSqToRel(edlist.sqstart+statloc,
1784 edlist.sqstart + esq);
1789 while( RelToAbsSq(edlist.sqstart+statloc, edlist.nlist - 1) < 0)
1790 statloc = RelToAbsSq( edlist.sqstart + statloc, -1)
1792 slctloc = AbsSqToRel( edlist.sqstart + statloc, edlist.sqstart + esq);
1796 if (( slimax = efctPtnNum()) < edlist.nlist)
1797 slimax = edlist.nlist;
1798 XtSetArg( arg[n], XmNmaximum, (XtArgVal)slimax ); n++;
1799 XtSetArg( arg[n], XmNvalue, (XtArgVal)AbsSqToRel( edlist.sqstart, edlist.sqstart + statloc) ); n++;
1800 XtSetValues( wgeScro , arg, n );
1802 chgEdList( statloc, slctloc, mode );
1808 * contents : rewrite the character list
1812 chgEdList( statloc, slctloc, mode )
1822 extern void ListSetLabelStr();
1823 extern void ListSetGlyphImage();
1824 extern void ListUnselectItem();
1825 extern void ListSelectItem();
1827 if((mode == ON) || (edlist.statloc != statloc)){
1828 for (i=0, sq=edlist.sqstart+statloc; i < edlist.nlist; sq++){
1832 if ((no >= 0) && (code = noToCode(no)) >= 0 ){
1833 sprintf(str, "%4x", code);
1834 ListSetLabelStr(i, str);
1835 ListSetGlyphImage(i) ;
1837 edlist.statloc = sq - edlist.sqstart;
1839 } else if (sq > ( edlist.sqstart + edlist.nptn - 1)){
1841 ListSetLabelStr(i, str);
1842 ListSetGlyphImage(i) ;
1848 if( (mode == ON) || (edlist.slctloc != slctloc) ) {
1849 if((0 <= edlist.slctloc) && (edlist.slctloc < edlist.nlist)){
1850 ListUnselectItem(edlist.slctloc);
1852 if((0 <= slctloc) && (slctloc < edlist.nlist)){
1853 ListSelectItem(slctloc);
1855 edlist.slctloc = slctloc;
1861 * contents : rewrite the editting pane
1868 extern void SetCodeString();
1870 if (xl.display == NULL ){
1875 XClearWindow( xl.display, xl.edit_winID );
1876 DrawBorderEdPn( 0, 0, edg.width - 1, edg.height - 1 );
1877 XClearWindow( xl.display, xl.disp_winID );
1878 XClearWindow( xl.display, xl.list_winID );
1879 bitPtnClear( edg.ptn );
1885 if( ptnGet( code, edg.ptn) == 0 ) {
1887 edg.ncode = codeToNo( code );
1888 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
1890 SetCodeString(code);
1899 /****************************************************************
1900 * draw patterns to the editting pane *
1901 ***************************************************************/
1904 * contents : draw a rectangle
1909 DrawRectEdPn( x1, y1, x2, y2 )
1916 short cx1, cy1, cx2, cy2;
1917 XRectangle recOn[MAXPTNSIZE*MAXPTNSIZE];
1918 XRectangle recOff[MAXPTNSIZE*MAXPTNSIZE];
1921 if (xl.display == NULL ){
1937 for( j=y1 ; j <= y2 ; j++ ) {
1938 for( i=x1 ; i <= x2 ; i++ ) {
1939 cx1 = (short)(edpane.pix_w * i);
1940 cy1 = (short)(edpane.pix_h * j);
1941 cx2 = (short)(cx1 + edpane.pix_w - 1);
1942 cy2 = (short)(cy1 + edpane.pix_h - 1);
1944 if( bitRead( edg.ptn, i, j ) != 0 ) {
1945 recOn[nron].x = cx1;
1946 recOn[nron].y = cy1;
1947 recOn[nron].width = (USHORT)(cx2 - cx1);
1948 recOn[nron].height = (USHORT)(cy2 - cy1);
1952 recOff[nroff].x = cx1;
1953 recOff[nroff].y = cy1;
1954 recOff[nroff].width = (USHORT)(cx2 - cx1);
1955 recOff[nroff].height = (USHORT)(cy2 - cy1);
1961 XFillRectangles( xl.display, xl.edit_winID, xl.borderGC, recOn, nron );
1963 XFillRectangles( xl.display, xl.edit_winID, xl.backGC, recOff, nroff );
1968 * contents : draw a lattice inside of the editting pane
1972 DrawBorderEdPn( x1, y1, x2, y2 )
1982 XSegment dseg[MAXPTNSIZE*2];
1984 if (xl.display == NULL ){
2001 cx1 = (short)(edpane.pix_w * x1);
2002 cx2 = (short)(edpane.pix_w * x2 + edpane.pix_w - 1);
2003 for( i=y1 ; i <= y2 ; i++ ) {
2004 cy1 = (short)(edpane.pix_h * i + edpane.pix_h - 1);
2005 dseg[ndseg].x1 = cx1;
2006 dseg[ndseg].y1 = cy1;
2007 dseg[ndseg].x2 = cx2;
2008 dseg[ndseg].y2 = cy1;
2011 cy1 = (short)(edpane.pix_h * y1);
2012 cy2 = (short)(edpane.pix_h * y2 + edpane.pix_h - 1);
2013 for( i=x1 ; i <= x2 ; i++ ) {
2014 cx1 = (short)(edpane.pix_w * i + edpane.pix_w - 1);
2015 dseg[ndseg].x1 = cx1;
2016 dseg[ndseg].y1 = cy1;
2017 dseg[ndseg].x2 = cx1;
2018 dseg[ndseg].y2 = cy2;
2023 XDrawSegments( xl.display, xl.edit_winID, xl.dashGC, dseg, ndseg);
2029 * contents : draw a dot
2033 DrawPointEdPn( x, y, mode )
2041 if (xl.display == NULL ){
2045 x1 = edpane.pix_w * x;
2046 y1 = edpane.pix_h * y;
2047 x2 = x1 + edpane.pix_w - 1;
2048 y2 = y1 + edpane.pix_h - 1;
2051 XFillRectangle( xl.display, xl.edit_winID, xl.borderGC,
2052 x1, y1, x2-x1, y2-y1 );
2054 XFillRectangle( xl.display, xl.edit_winID, xl.backGC,
2055 x1, y1, x2-x1, y2-y1 );
2062 * contents : draw a current character pattern to the display pane
2068 if (xl.display == NULL ){
2072 XPutImage( xl.display, xl.disp_winID, xl.borderGC, xl.dispImage,
2073 0, 0, 0, 0, edg.width, edg.height );
2074 if( xl.list_winID ) {
2075 XPutImage( xl.display, xl.list_winID, xl.borderGC,
2076 xl.dispImage, 0, 0, 0, 0, edg.width, edg.height );
2083 * contents : draw a dot
2087 DrawPointDpPn( x, y, mode )
2093 if (xl.display == NULL ){
2097 XDrawPoint( xl.display, xl.disp_winID, xl.borderGC, x, y );
2099 XDrawPoint( xl.display, xl.list_winID, xl.borderGC, x, y );
2101 XDrawPoint( xl.display, xl.disp_winID, xl.backGC, x, y );
2103 XDrawPoint( xl.display, xl.list_winID, xl.backGC, x, y );
2109 /****************************************************************
2110 * draw patterns by mouse *
2111 ****************************************************************/
2115 * contents : draw a dot
2119 musPoint( evtype, px, py )
2126 if( (em.src1_px == px) && (em.src1_py == py) )
2137 if( edpane.color == ON )
2138 bitSet( edg.ptn, px, py );
2140 bitReset( edg.ptn, px, py );
2142 DrawPointEdPn( px, py, edpane.color );
2143 DrawPointDpPn( px, py, edpane.color );
2148 * contents : draw a line
2152 musLine( evtype, px, py )
2163 harf_pix_w = edpane.pix_w / 2;
2164 harf_pix_h = edpane.pix_h / 2;
2165 r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
2166 r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
2167 r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
2168 r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
2169 rx = px * edpane.pix_w + harf_pix_w;
2170 ry = py * edpane.pix_h + harf_pix_h;
2174 if( (em.src2_px == px) && (em.src2_py == py) )
2176 rubLine( r1_x, r1_y, r2_x, r2_y );
2177 rubLine( r1_x, r1_y, rx, ry );
2182 em.src1_px = em.src2_px = px;
2183 em.src1_py = em.src2_py = py;
2186 if( (r1_x == r2_x) && (r1_y == r2_y) )
2188 rubLine( r1_x, r1_y, r2_x, r2_y );
2190 if ((em.src2_px < 0) || (em.src2_py < 0) ||
2191 (edg.width <= em.src2_px) || (edg.height <= em.src2_py))
2194 bitDrawLine( edg.ptn, em.src1_px, em.src1_py,
2195 em.src2_px, em.src2_py, edpane.color );
2197 DrawRectEdPn( em.src1_px, em.src1_py, em.src2_px, em.src2_py );
2205 * contents : draw a circle
2209 musCircle( evtype, px, py )
2219 extern int bitDrawCircle();
2221 harf_pix_w = edpane.pix_w / 2;
2222 harf_pix_h = edpane.pix_h / 2;
2224 r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
2225 r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
2226 r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
2227 r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
2228 rx = px * edpane.pix_w + harf_pix_w;
2229 ry = py * edpane.pix_h + harf_pix_h;
2233 if( (em.src2_px == px) && (em.src2_py == py) ) {
2236 rubCircle( r1_x, r1_y, r2_x, r2_y );
2237 rubCircle( r1_x, r1_y, rx, ry );
2242 em.src1_px = em.src2_px = px;
2243 em.src1_py = em.src2_py = py;
2246 if( (em.src1_px == px) && (em.src1_py == py) ) {
2249 rubCircle( r1_x, r1_y, r2_x, r2_y );
2251 if( (px < 0) || (py < 0) || (edg.width <= px) || (edg.height <= py) ) {
2254 bitDrawCircle( edg.ptn, em.src1_px, em.src1_py, px, py, edpane.color);
2257 DrawRectEdPn( 0, 0, edg.width -1, edg.height -1 );
2264 * contents : draw a rectangle
2268 musRect( proc, evtype, px, py )
2281 if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
2282 dpx = px - em.src1_px;
2283 dpy = py - em.src1_py;
2284 dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
2287 px = em.src1_px + dpx/abs(dpx) * dp;
2289 py = em.src1_py + dpy/abs(dpy) * dp;
2292 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2293 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2294 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2295 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2296 rx = px * edpane.pix_w + edpane.pix_w / 2;
2297 ry = py * edpane.pix_h + edpane.pix_h / 2;
2301 if( (em.src2_px == px) && (em.src2_py == py) )
2303 rubBand( r1_x, r1_y, r2_x, r2_y );
2304 rubBand( r1_x, r1_y, rx, ry );
2309 resetEditMode( RES_SLCT );
2310 em.src1_px = em.src2_px = px;
2311 em.src1_py = em.src2_py = py;
2314 resetEditMode( RES_MSG | RES_PROC );
2315 rubBand( r1_x, r1_y, r2_x, r2_y );
2316 if( (r1_x == r2_x) || (r1_y == r2_y) )
2318 if( (em.src2_px < 0) || (em.src2_py < 0) ||
2319 (edg.width <= em.src2_px) || (edg.height <= em.src2_py) )
2322 lux = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
2323 luy = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
2324 width = abs( em.src1_px - em.src2_px ) + 1;
2325 height = abs( em.src1_py - em.src2_py ) + 1;
2327 bitDrawRect(edg.ptn, lux, luy, width, height, edpane.color);
2330 DrawRectEdPn( em.src1_px, em.src1_py, px, py );
2337 * contents : edit inside of the specified area (clear, reverse, rotate,etc.)
2341 musRegionProc( proc, evtype, px, py )
2349 extern void SelectSet();
2351 if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
2352 dpx = px - em.src1_px;
2353 dpy = py - em.src1_py;
2354 dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
2357 px = em.src1_px + dpx/abs(dpx) * dp;
2359 py = em.src1_py + dpy/abs(dpy) * dp;
2362 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2363 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2364 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2365 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2366 rx = px * edpane.pix_w + edpane.pix_w / 2;
2367 ry = py * edpane.pix_h + edpane.pix_h / 2;
2371 if( (em.src2_px == px) && (em.src2_py == py) )
2373 rubBand( r1_x, r1_y, r2_x, r2_y );
2374 rubBand( r1_x, r1_y, rx, ry );
2379 if (select_x || select_y || select_w || select_h) {
2380 rubBand( r1_x, r1_y, r2_x, r2_y );
2382 resetEditMode( RES_SLCT );
2383 em.src1_px = em.src2_px = px;
2384 em.src1_py = em.src2_py = py;
2387 resetEditMode( RES_MSG | RES_PROC );
2388 select_x = select_y = select_w = select_h = 0;
2389 if( (r1_x == r2_x) || (r1_y == r2_y) ) {
2390 rubBand( r1_x, r1_y, r2_x, r2_y );
2393 if( (em.src2_px < 0) || (em.src2_py < 0) ||
2394 (edg.width <= em.src2_px) || (edg.height <= em.src2_py) ) {
2395 rubBand( r1_x, r1_y, r2_x, r2_y );
2399 select_x = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
2400 select_y = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
2401 select_w = abs( em.src1_px - em.src2_px ) + 1;
2402 select_h = abs( em.src1_py - em.src2_py ) + 1;
2410 musPasteProc(w, client_data, event)
2412 XtPointer client_data;
2415 static int ox=0, oy=0;
2417 extern void UndoSet();
2418 extern Widget wgeBulB_edit;
2419 extern int bitDrawPaste();
2421 switch(event->type) {
2423 tx = (event->xmotion.x / edpane.pix_w) * edpane.pix_w + edpane.pix_w / 2;
2424 ty = (event->xmotion.y / edpane.pix_h) * edpane.pix_h + edpane.pix_h / 2;
2425 if (tx == ox && ty == oy)
2428 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2432 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2435 XtRemoveEventHandler(wgeBulB_edit,
2436 ButtonReleaseMask|PointerMotionMask,
2437 False, (XtEventHandler)musPasteProc, NULL );
2438 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2441 bitPtnCopy( em.rsv_ptn, edg.ptn );
2443 tx = event->xbutton.x / edpane.pix_w;
2444 ty = event->xbutton.y / edpane.pix_h;
2445 rc = bitDrawPaste(edg.ptn, tx, ty);
2450 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
2462 rubLine( x1, y1, x2, y2 )
2468 if( x1==x2 && y1==y2 ) return;
2470 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1,y1, x2,y2 );
2476 rubBand( x1, y1, x2, y2 )
2482 if( x1==x2 && y1==y2 )
2485 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x2, y1 );
2486 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x1, y2 );
2487 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x2, y1, x2, y2 );
2488 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y2, x2, y2 );
2494 rubCircle( ox, oy, rx, ry )
2503 if( ox==rx && oy==ry ) return;
2507 r = (unsigned int)sqrt( (double)(x*x + y*y) );
2508 if ( r == 0 ) return;
2512 XDrawArc( xl.display, xl.edit_winID, xl.rubGC,
2521 resetEditMode( flag )
2527 if( flag & RES_MSG )
2528 SetString( wgeStaT, "" );
2530 if( flag & RES_PROC )
2531 em.proc = edpane.obj;
2533 if( (flag & RES_SLCT) && (em.slct_f) ) {
2534 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2535 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2536 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2537 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2538 rubBand( r1_x, r1_y, r2_x, r2_y );
2542 if( flag & RES_RSV )
2547 /****************************************************************
2548 * copy character pattern *
2549 ***************************************************************/
2552 * contents : copy or overlay the new character pattern to the current pattern
2557 copyPatterns( fdata, s1_code, s2_code, d1_code, proc )
2565 int d1_ncode, d2_ncode;
2573 char ptn2[MAXPTNBYTE];
2575 extern int last_code;
2577 ret = copySNF(s1_code, s2_code, &ptn, &num, err);
2579 Error_message2((Widget)NULL, err);
2583 if (last_code < (d1_code + num))
2584 last_code = d1_code + num;
2586 if( ptnSense(edg.code) == 1 )
2587 ptnAdd( edg.code, edg.ptn );
2589 d1_ncode = codeToNo( d1_code );
2591 for (i_d=d1_ncode, i_s=0; i_s < num; i_d++) {
2592 if ( codeCheck( noToCode( i_d)))
2594 bitPtnClear( ptn2 );
2595 code_d = noToCode( i_d );
2596 grc_d = ptnGet( code_d, ptn2 );
2599 if( proc == CPY_OVERLAY ) {
2600 for( i=0 ; i < edg.height*((edg.width+7)/8) ; i++ ) {
2601 ptn[i_s][i] |= ptn2[i];
2604 ptnAdd( code_d, ptn[i_s] );
2607 if( ptnAdd( code_d, ptn[i_s] ) != 1 ) {
2608 SetString( wgeStaT, resource.me_non_memory );
2619 for( i=d1_ncode ; i <= d2_ncode; i++ ) {
2620 if ( codeCheck( noToCode(i) ) )
2622 if( ptnSense( noToCode( i ) ) == 1 ) {
2623 code_disp = noToCode( i );
2629 if( (code_disp == 0) && (efctPtnNum() > 0))
2630 code_disp = noToCode( ptnSqToNo(edlist.sqstart) );
2632 chgEdCode( code_disp, ON );
2634 resetEditMode( (UINT) (RES_MSG | RES_PROC | RES_SLCT | RES_RSV) );