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 libraries 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
37 #include <X11/Intrinsic.h>
39 #include "xoakufont.h"
42 #define _CLIENT_CAT_NAME "dtudcfonted"
43 extern char *_DtGetMessage(char *filename, int set, int n, char *s);
44 #define GETMESSAGE(set, number, string) GetMessage(set, number, string)
46 GetMessage(int set, int number, char *string)
49 tmp = _DtGetMessage(_CLIENT_CAT_NAME, set, number, string);
50 ret = malloc(strlen(tmp) + 1);
55 /****************************************************************
57 ***************************************************************/
60 Widget wgeScro, editPopW;
62 static int select_x, select_y, select_w, select_h;
63 static int r1_x, r1_y, r2_x, r2_y, cut_w, cut_h;
65 extern Widget xlfdDialog, cpyDialog;
67 extern FalFontID font_id;
72 static XtAppContext app; /* application context */
73 static int edpane_size=0;
75 static void OtherFontSelect(void);
76 void drawDelCode(int i);
77 void drawDelPtn(int i);
78 static void xeg_init(void);
81 static void dstrypaneEditPtn(void);
82 void chgEdCode(int code, char mode);
83 void chgEdList(int statloc, int slctloc, char mode);
84 static void chgEdPtn(int code);
85 static void DrawRectEdPn(int x1, int y1, int x2, int y2);
86 static void DrawBorderEdPn(int x1, int y1, int x2, int y2);
87 static void DrawPointEdPn(int x, int y, int mode);
88 static void DrawDpPn(void);
89 static void DrawPointDpPn(int x, int y, int mode);
90 static void musPoint(int evtype, int px, int py);
91 static void musLine(int evtype, int px, int py);
92 static void musCircle(int evtype, int px, int py);
93 static void musRect(int proc, int evtype, int px, int py);
94 static void musRegionProc(int proc, int evtype, int px, int py);
95 static void musPasteProc(Widget w, XtPointer client_data, XEvent *event);
96 static void rubLine(int x1, int y1, int x2, int y2);
97 static void rubBand(int x1, int y1, int x2, int y2);
98 static void rubCircle(int ox, int oy, int rx, int ry);
99 static void resetEditMode(unsigned int flag);
100 static void copyPatterns(FalFontData *fdata,
105 extern String MngCodeTfValue(void);
106 extern String CpySrcCodeTfValue(void);
107 extern String CpyDestCodeTfValue(void);
108 char *get_cmd_path(char *path, char *cmd);
109 extern FalFontData fullFontData;
110 extern FalFontData copyFontData;
112 extern void PopupSelectXLFD(Widget top);
113 extern void UpdateMessage(String str);
114 extern void DispMngErrorMessage(String msg);
115 extern void DispCpyErrorMessage(String msg);
116 static int setRealDelArea(int *s_ncode,
121 /****************************************************************
123 ***************************************************************/
129 /****************************************************************
130 * callback routines *
131 ***************************************************************/
133 static void CancelCB(void);
148 for ( cnt = 0, sq = edlist.sqstart;
149 sq < (edlist.sqstart + edlist.nptn); sq++) {
151 if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
158 Error_message(Widget widget, char *message)
160 static NoticeButton is_lock[] = {
161 NBTNARGS( ExitCB, NULL, 'E', True, False ),
162 NBTNARGS( CancelCB, NULL, 'C', True, True )
164 static NButton LockBTN = NBUTTONS( is_lock );
166 SetItemLabel(&LockBTN, 0, resource.l_exit);
167 SetItemLabel(&LockBTN, 1, resource.l_cancel);
168 PopupNotice( (widget), message,
172 resource.l_question_title);
176 Error_message2(Widget widget, char *message)
178 static NoticeButton is_lock[] = {
179 NBTNARGS( CancelCB, NULL, 'C', True, True )
181 static NButton LockBTN = NBUTTONS( is_lock );
186 SetItemLabel(&LockBTN, 0, resource.l_ok);
187 PopupNotice( (widget), message,
191 resource.l_question_title);
195 * contents : read a character pattern from SNF file
199 CBmOblB_edit( Widget widget, caddr_t clientData, caddr_t callData )
208 extern int begin_code;
210 extern int ptnGetInfo();
211 extern void PopupEditPtn();
213 /* open font file and get informations of character to be edited */
215 ret = readSNF( &(edg.fdata), &(edg.width), &(edg.height), err);
218 Error_message(widget, err);
221 dn.ptn_w = (Dimension) edg.width;
222 dn.ptn_h = (Dimension) edg.height;
225 if( xlfdDialog != NULL )
226 PopdownDialog(xlfdDialog);
228 ptnGetInfo( &ptn_n, &ptn_w, &ptn_h );
229 for( i=0 ; i<ptn_n ; i++ ) {
230 code = noToCode( ptnSqToNo(i) );
231 if( begin_code > code){
232 edlist.sqstart = i+1;
237 if( efctPtnNum() > 0) {
238 for ( i=edlist.sqstart; i<(edlist.sqstart+edlist.nptn); i++){
239 if ( codeCheck( noToCode( ptnSqToNo(i))) == 0)
242 edg.ncode = ptnSqToNo( i );
243 edg.code = noToCode( edg.ncode );
244 ptnGet( edg.code, edg.ptn );
246 PopupEditPtn(toplevel);
251 void CBeOblB_aAdd(void);
253 static Boolean do_read = False;
254 static Boolean do_end = False;
256 static void CancelCB(void) { }
258 static void ContReadCB(Widget w)
260 FalCloseFont(font_id);
263 PopupSelectXLFD(toplevel);
266 static void SaveReadCB(void)
270 PopupSelectXLFD(toplevel);
274 static void ContEndCB(void)
276 FalCloseFont(font_id);
280 static void SaveEndCB(void)
288 * contents : quit editting
294 QuitEditPtn( Widget widget, caddr_t clientData, caddr_t callData )
296 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
299 ptnAdd( edg.code, edg.ptn );
301 if( edg.flag == ON ){
310 OpenCB(Widget w, XtPointer client_data, XtPointer call_data)
312 static NoticeButton is_save_read_btn1[] = {
313 NBTNARGS( SaveReadCB, NULL, 'S', True, False ),
314 NBTNARGS( ContReadCB, NULL, 'O', True, False ),
315 NBTNARGS( CancelCB, NULL, 'C', True, True ),
317 static NoticeButton is_save_read_btn2[] = {
318 NBTNARGS( ContReadCB, NULL, 'O', True, False ),
319 NBTNARGS( CancelCB, NULL, 'C', True, True ),
321 static NButton SaveReadBTN1 = NBUTTONS( is_save_read_btn1 );
322 static NButton SaveReadBTN2 = NBUTTONS( is_save_read_btn2 );
324 if (QuitEditPtn((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL)){
325 FalCloseFont(font_id);
328 PopupSelectXLFD(toplevel);
331 if (! fullFontData.prm) {
332 SetItemLabel(&SaveReadBTN1, 0, resource.l_do_save_exit);
333 SetItemLabel(&SaveReadBTN1, 1, resource.l_dont_save_exit);
334 SetItemLabel(&SaveReadBTN1, 2, resource.l_cancel);
335 PopupNotice( (w), resource.mn_saved_open ,
339 resource.l_question_title);
341 SetItemLabel(&SaveReadBTN2, 0, resource.l_dont_save_exit);
342 SetItemLabel(&SaveReadBTN2, 1, resource.l_cancel);
343 PopupNotice( (w), resource.mn_saved_open ,
347 resource.l_question_title);
354 ReadCB(Widget w, XtPointer client_data, XtPointer call_data)
356 if (fullFontData.xlfdname == NULL) {
359 if (fullFontData.xlfdname == (char *) -1) {
360 Error_message(w, resource.mn_prop_font);
363 CBmOblB_edit( w, client_data, call_data );
366 /****************************************************************
367 * callback routines and event handler *
368 ***************************************************************/
371 * contents : write character patterns to SNF file
375 WPwriteSNF( int restart )
378 char str[MG_MAXSIZE];
380 switch( rc = writeSNF( restart, &err ) ) {
383 XtSetSensitive( dnPopW, TRUE );
386 sprintf(str, "%s(permission denied)", resource.me_write_snf);
389 sprintf(str, "%s(disk full)", resource.me_write_snf);
392 sprintf(str, "%s(pipe error)", resource.me_write_snf);
395 sprintf(str, "%s(fork error)", resource.me_write_snf);
398 sprintf(str, "%s(execv error)", resource.me_write_snf);
401 sprintf(str, "%s(data error)", resource.me_write_snf);
404 sprintf(str, "%s", resource.me_write_snf);
406 UpdateMessage( str );
410 UpdateMessage( resource.mg_register );
416 ContReadCB((Widget)NULL);
425 sprintf( str, "%s", resource.me_wait );
427 sprintf( str, "%s(%3d%%)", resource.mg_write_snf , rc-1000 );
429 UpdateMessage( str );
430 XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)ON );
432 XSync( xl.display,0 );
441 * contents : write character patterns to SNF file
447 char str[MG_MAXSIZE];
449 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
450 UpdateMessage( resource.mg_write_snf );
453 ptnAdd( edg.code, edg.ptn );
455 if( edg.flag == ON ) {
456 sprintf( str, "%s", resource.mg_write_snf );
458 XtSetSensitive( dnPopW, FALSE );
460 XtAppAddWorkProc( app, (XtWorkProc)WPwriteSNF, (XtPointer)OFF );
471 * contents : destroy the editor window
475 OtherFontSelect(void)
484 * contents : close dtudcfonted
489 CBeOblB_aEnd( Widget widget, caddr_t clientData, caddr_t callData )
491 static NoticeButton is_save_exit_btn[] = {
492 NBTNARGS( SaveEndCB, NULL, 'S', True, False ),
493 NBTNARGS( ContEndCB, NULL, 'E', True, False ),
494 NBTNARGS( CancelCB, NULL, 'C', True, True ),
496 static NButton SaveEndBTN = NBUTTONS( is_save_exit_btn );
498 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
501 ptnAdd( edg.code, edg.ptn );
502 if( edg.flag == ON ) {
504 SetItemLabel(&SaveEndBTN, 0, resource.l_do_save);
505 SetItemLabel(&SaveEndBTN, 1, resource.l_dont_save);
506 SetItemLabel(&SaveEndBTN, 2, resource.l_cancel);
507 PopupNotice( widget, resource.mn_saved_exit, D_QUESTION,
508 &SaveEndBTN, True, resource.l_question_title);
511 FalCloseFont(font_id);
521 CBeOblB_rCmd( Widget widget, int proc, caddr_t callData )
523 extern void SelectUnset();
524 extern void UndoSet();
525 if (!select_x && !select_y && !select_w && !select_h)
528 bitPtnCopy( em.rsv_ptn, edg.ptn );
529 rubBand( r1_x, r1_y, r2_x, r2_y );
532 bitDrawCls (edg.ptn, select_x, select_y, select_w, select_h );
535 bitDrawSet (edg.ptn, select_x, select_y, select_w, select_h );
538 bitDrawRev (edg.ptn, select_x, select_y, select_w, select_h );
541 bitDrawRoll(edg.ptn, select_x, select_y, select_w, select_h);
544 bitDrawSymV(edg.ptn, select_x, select_y, select_w, select_h );
547 bitDrawSymH(edg.ptn, select_x, select_y, select_w, select_h );
551 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
553 select_x = select_y = select_w = select_h = 0;
560 CBeOblB_rCmdp( Widget widget, int proc, caddr_t callData )
562 extern Widget wgeBulB_edit;
563 extern void CopySet();
564 extern void UndoSet();
565 extern void SelectUnset();
569 if (!select_x && !select_y && !select_w && !select_h)
571 rubBand( r1_x, r1_y, r2_x, r2_y );
572 bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, False);
575 select_x = select_y = select_w = select_h = 0;
580 if (!select_x && !select_y && !select_w && !select_h)
583 rubBand( r1_x, r1_y, r2_x, r2_y );
584 bitPtnCopy( em.rsv_ptn, edg.ptn );
585 bitDrawCpy(edg.ptn, select_x, select_y, select_w, select_h, True);
589 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
591 select_x = select_y = select_w = select_h = 0;
597 XtAddEventHandler(wgeBulB_edit,
598 ButtonReleaseMask|PointerMotionMask,
599 False, musPasteProc, NULL );
607 * contents : cancel all editting
612 CBeOblB_rCan( Widget widget, caddr_t clientData, caddr_t callData )
614 extern void UndoUnset();
616 resetEditMode( RES_MSG | RES_PROC | RES_SLCT );
618 if( em.rsv_f == ON ) {
619 bitPtnCopy( edg.ptn, em.rsv_ptn );
622 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
633 * contents : get a sequential number of the editor
636 RelToAbsSq( int from, int cnt)
642 for ( i = -1; from < (edlist.sqstart + edlist.nptn) ; from++) {
643 no = ptnSqToNo(from);
644 if (( no >= 0) && ( noToCode( no) >= 0) ) {
652 for ( i = -1; from >= edlist.sqstart; from--) {
653 no = ptnSqToNo(from);
654 if (( no >= 0) && ( noToCode( no) >= 0) ) {
665 * contents : get a relative number of the system area
668 AbsSqToRel( int from, int to)
682 for ( cnt = -1, sq = from; sq <= to; sq++) {
684 if (( no >= 0) && (codeCheck( noToCode( no)) == 0))
697 * contents : be the character list selected
702 EHeStaT_list( Widget widget, int select, XEvent *e )
707 resetEditMode( RES_MSG|RES_PROC|RES_SLCT|RES_RSV );
709 if( (e->xbutton.button != 1) || (e->type != ButtonRelease) ||
710 (e->xbutton.x < 0) || ((int)edlist.elem_w < e->xbutton.x) ||
711 (e->xbutton.y < 0) || ((int)edlist.elem_h < e->xbutton.y)
715 if( edlist.slctloc == select )
718 sq = RelToAbsSq( edlist.sqstart + edlist.statloc, select);
720 if( (no = ptnSqToNo(sq)) == -1 )
723 code = noToCode( no );
724 if( codeCheck( code ) == -1 )
727 if( ptnSense( code) == 0 )
730 chgEdList( edlist.statloc, select, OFF );
731 if( ptnSense(edg.code) == 1 )
732 ptnAdd(edg.code, edg.ptn );
740 * contents : update the character list
745 CBeScro( Widget widget, caddr_t clientData, caddr_t callData )
752 XtSetArg( arg[n], XmNvalue, (XtArgVal)&newl ); n++;
753 XtGetValues( wgeScro , arg, n );
755 if (( new_statloc = RelToAbsSq( edlist.sqstart, newl)) < 0) {
758 new_statloc -= edlist.sqstart;
762 new_slct = edlist.slctloc
763 - AbsSqToRel( edlist.sqstart + edlist.statloc,
764 edlist.sqstart + new_statloc);
765 chgEdList( new_statloc, new_slct, OFF);
772 * contents : select the edit items by mouse
777 EHeBulB_eMEv( Widget widget, caddr_t clientData, XEvent *e )
782 if (edpane.pix_w * edpane.pix_h == 0 ) {
786 if( e->type == ButtonPress ){
789 if( (edg.code == 0) || (em.drag_f == OFF) )
791 if( e->type == ButtonRelease ){
795 px = e->xbutton.x / edpane.pix_w;
796 py = e->xbutton.y / edpane.pix_h;
798 if (( e->type == ButtonPress) || (e->type == ButtonRelease)){
799 downbutton = e->xbutton.button;
800 }else if ( e->type == MotionNotify ){
801 if ( e->xmotion.state & Button1Mask ){
802 downbutton = 1; /* select button */
803 }else if ( e->xmotion.state & Button2Mask ){
804 downbutton = 2; /* adjust button */
810 switch( downbutton ) {
814 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
815 musPoint( e->type, px, py );
818 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
819 musLine( e->type, px, py );
822 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
823 musCircle( e->type, px, py );
826 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
827 musRect( em.proc, e->type, px, py );
830 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
831 musPoint( e->type, px, py );
834 musRegionProc( em.proc, e->type, px, py );
842 if( (0 <= px) && (px < edg.width) && (0 <= py) && (py < edg.height) ) {
843 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
847 if( (em.adj_px == px) && (em.adj_py == py) )
853 if( bitRead(edg.ptn, px, py) == 0 ) {
854 bitSet( edg.ptn, px, py );
855 DrawPointEdPn( px,py, 1 );
856 DrawPointDpPn( px,py, 1 );
859 bitReset( edg.ptn, px, py );
860 DrawPointEdPn( px,py, 0 );
861 DrawPointDpPn( px,py, 0 );
878 * contents : restore the editting pane
883 EHeBulB_eExp( Widget widget, caddr_t clientData, XEvent *e )
888 if (edpane.pix_w * edpane.pix_h == 0 ) {
892 x1 = e->xexpose.x / edpane.pix_w;
893 y1 = e->xexpose.y / edpane.pix_h;
894 x2 = (e->xexpose.x + e->xexpose.width - 1) / edpane.pix_w;
895 y2 = (e->xexpose.y + e->xexpose.height - 1) / edpane.pix_h;
897 DrawRectEdPn( x1, y1, x2, y2 );
898 DrawBorderEdPn( x1, y1, x2, y2 );
905 * contents : specifies the drawing operation (Pont/Line/Rectangle/Circle)
910 CBeRecB_obj( Widget widget, int obj, XmToggleButtonCallbackStruct *call)
912 extern void SelectUnset();
914 if (call->set == False)
917 resetEditMode( RES_MSG | RES_RSV | RES_SLCT );
919 if (obj == PROC_ERASE)
925 if (obj != PROC_SELECT) {
926 if (select_x || select_y || select_w || select_h) {
927 rubBand( r1_x, r1_y, r2_x, r2_y );
928 select_x = select_y = select_w = select_h = 0;
938 * contents : restore the displaying pane
943 EHeBulB_dExp( Widget widget, caddr_t clientData )
945 if (xl.display == NULL ){
953 * contents : set the range to be add or deleted
957 codeAreaSet(int *s_code, int *e_code)
962 str = MngCodeTfValue();
969 sscanf( str, "%x %c %x", s_code, &delm, e_code );
970 if (str) free( str );
980 if( codeCheck(*s_code) || codeCheck(*e_code) ||
981 (*s_code > *e_code) ) {
988 /****************************************************************
989 * callback routines (character management window) *
990 ***************************************************************/
993 BeforeMngCheck(int *s_code, int *e_code)
995 if(codeAreaSet(s_code, e_code) == -1) {
996 DispMngErrorMessage( resource.me_illegal_code );
1003 DoAddProc(int s_code, int e_code)
1009 char ptn[MAXPTNBYTE];
1013 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1015 s_ncode = codeToNo( s_code );
1016 e_ncode = codeToNo( e_code );
1019 for( i=s_ncode ; i <= e_ncode ; i++ ) {
1021 if ( codeCheck( code))
1023 if (ptnSense(code) == 0) {
1024 if(ptnAdd(code, ptn) != 1) {
1025 UpdateMessage( resource.me_non_memory );
1034 if( ptnSense( edg.code ) == 1 ) {
1035 ptnAdd( edg.code, edg.ptn );
1039 chgEdCode( s_code, mode );
1042 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1047 void PopupDelNotice();
1048 Widget CreateDelNotice();
1052 DoDelProc( int s_code, int e_code )
1054 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1056 if( ptnSense( edg.code) == 1 )
1057 ptnAdd( edg.code, edg.ptn );
1059 dn.s_ncode = codeToNo( s_code );
1060 dn.e_ncode = codeToNo( e_code );
1062 if (setRealDelArea(&dn.s_ncode, &dn.e_ncode, &dn.sq_start, &dn.sq_end) == -1) {
1063 DispMngErrorMessage( resource.me_nodelete_code );
1066 dn.sq_top = dn.sq_start;
1067 dn.disp_num = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
1068 dn.disp_num = (dn.disp_num <= D_MAX) ? dn.disp_num : D_MAX;
1070 PopupDelNotice( mngPtnW );
1078 * contents : get the real range to be add or delete
1083 setRealDelArea(int *s_ncode, int *e_ncode, int *sq_start, int *sq_end )
1093 for( i=*s_ncode ; i <= ncode ; i++ ) {
1094 if (((sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i)) == 0)) {
1100 *s_ncode = ptnSqToNo( sq );
1109 for( i=*e_ncode ; i >= ncode ; i-- ) {
1110 if ((( sq = ptnNoToSq(i)) != -1) && (codeCheck( noToCode(i) ) == 0)) {
1115 *e_ncode = ptnSqToNo( sq );
1125 /****************************************************************
1126 * callback routines (Copy) *
1127 ****************************************************************/
1130 CpySrcCodeCheck(void)
1135 str = CpySrcCodeTfValue();
1145 sscanf( str, "%x %c %x", &cpm.s1_code,&delm, &cpm.s2_code );
1149 cpm.s2_code = cpm.s1_code;
1156 if (cpm.s1_code > cpm.s2_code)
1162 CpyDestCodeCheck(void)
1166 str = CpyDestCodeTfValue();
1174 sscanf( str, "%x", &cpm.d1_code );
1177 if( codeCheck(cpm.d1_code) ) {
1184 BeforeCpyCheck( int proc )
1186 int s_ncode, e_ncode;
1187 int r1_code, r2_code;
1191 extern void PopupCpyNotice();
1193 if (copyFontData.xlfdname == NULL) {
1194 DispCpyErrorMessage(resource.me_non_srcfile);
1198 if (CpySrcCodeCheck() == -1){
1199 DispCpyErrorMessage( resource.me_illegal_srccode );
1203 if (CpyDestCodeCheck() == -1){
1204 DispCpyErrorMessage( resource.me_illegal_destcode );
1208 s_ncode = codeToNo( cpm.d1_code );
1209 e_ncode = codeToNo( cpm.d1_code + cpm.s2_code - cpm.s1_code);
1210 r1_code = r2_code = 0;
1211 for( i=s_ncode ; i <= e_ncode ; i++ ) {
1213 if (( no >= 0) && (codeCheck( noToCode( no)) == 0)) {
1215 r1_code = noToCode(i);
1216 r2_code = noToCode(i);
1222 if( r1_code != 0 ) {
1223 if( r1_code == r2_code ) {
1224 sprintf( rstr, "%s %x¡¡", resource.l_code, r1_code );
1225 } else if ( codeCheck(r1_code) && codeCheck(r2_code)){
1226 sprintf( rstr, " %x - %x", r1_code, r2_code );
1228 sprintf( rstr, "%s %x - %x ", resource.l_code_range, r1_code, r2_code );
1230 PopupCpyNotice(rstr);
1240 extern void PopdownCpyPtn();
1244 resetEditMode( RES_MSG | RES_PROC | RES_SLCT | RES_RSV );
1246 copyPatterns( cpm.fdata, cpm.s1_code, cpm.s2_code, cpm.d1_code, cpm.proc );
1249 /****************************************************************
1251 ****************************************************************/
1252 #define R(name, class, member,def) { \
1257 XtOffsetOf(Resource, member), \
1261 #define RBoolean(name, class, member,def) \
1262 { name, class, XtRBoolean, sizeof(XtRBoolean), \
1263 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1265 #define RDimension(name, class, member,def) \
1266 { name, class, XtRDimension, sizeof(XtRDimension), \
1267 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1269 #define Rint(name, class, member,def) \
1270 { name, class, XtRInt, sizeof(XtRInt), \
1271 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1273 #define RPixel(name, class, member,def) \
1274 { name, class, XtRPixel, sizeof(XtRPixel), \
1275 XtOffsetOf(Resource, member), XtRString, (XtPointer)def }
1277 static XtResource app_resources[] = {
1278 RBoolean("Codepoint", "codepoint", codepoint, "False"),
1280 R( "lptog", "Lptog", l_ptog, DFLTPATH ),
1281 R( "lptogCmd", "LptogCmd", l_ptog_cmd, DFLTCMD ),
1283 /* CreateCaptionFrame() */
1284 RBoolean( "captResize", "CaptResize", capt_resize, "True" ) ,
1285 Rint( "captLftoff", "CaptLftoff", capt_lftoff, "2" ) ,
1286 Rint( "captTopoff", "CaptTopoff", capt_topoff, "2" ) ,
1287 Rint( "captRghoff", "CaptRghoff", capt_rghoff, "2" ) ,
1289 RPixel( "paneBackground", "paneBackground", pane_background, "white" ),
1290 RPixel( "paneForeground", "PaneForeground", pane_foreground, "black" ),
1291 RPixel( "background", "Background", background, "white" ),
1292 RPixel( "foreground", "Foreground", foreground, "black" ),
1294 /* CreateMenuButtons() */
1295 RDimension( "menuMargin", "MenuMargin", menu_margin, "0" ) ,
1297 /* CreateDialogAndButtons() */
1298 RBoolean( "diaTmAutomng", "DiaTmAutomng", dia_tm_automng, "False" ) ,
1299 RDimension( "diaTmWidth", "DiaTmWidth", dia_tm_width, "4" ) ,
1300 RDimension( "diaTmHeight", "DiaTmHeight", dia_tm_height, "4" ) ,
1301 RBoolean( "diaTmResize", "DiaTmResize", dia_tm_resize, "True" ) ,
1302 RBoolean( "diaTmMinimize", "DiaTmMinimize", dia_tm_minimize, "True" ) ,
1304 RDimension( "diaRwWidth", "DiaRwWidth", dia_rw_width, "6" ) ,
1305 RDimension( "diaRwHeight", "DiaRwHeight", dia_rw_height, "6" ) ,
1306 RDimension( "diaRwSpacing", "DiaRwSpacing", dia_rw_spacing, "4" ) ,
1308 /* CreateDrawingArea() */
1309 RDimension( "drawBorder", "DrawBorder", draw_border, "1" ) ,
1310 Rint( "drawTopoff", "DrawTopoff", draw_topoff, "2" ) ,
1311 Rint( "drawLftoff", "DrawLftoff", draw_lftoff, "2" ) ,
1314 RBoolean( "popResize", "PopResize", pop_resize , "True" ) ,
1315 RBoolean( "popMinimize", "PopMinimize", pop_minimize , "True" ) ,
1317 /* CreateTemplateDialog() */
1318 RBoolean( "tempResize", "TempResize", temp_resize, "True" ) ,
1319 RBoolean( "tempMinimize", "TempMinimize", temp_minimize, "True" ) ,
1321 RDimension( "tempWidth", "TempWidth", temp_width, "1" ) ,
1322 RDimension( "tempHeight", "TempHeight", temp_height, "1" ) ,
1324 /* CreateMenuBarAndFooterMessageForm() */
1325 Rint( "edBarTopoff", "EdBarTopoff", ed_bar_topoff, "1" ) ,
1326 Rint( "edBarLftoff", "EdBarLftoff", ed_bar_lftoff, "1" ) ,
1327 Rint( "edBarRghoff", "EdBarRghoff", ed_bar_rghoff, "1" ) ,
1329 Rint( "edFrmBtmoff", "EdFrmBtmoff", ed_frm_btmoff, "3" ) ,
1330 Rint( "edFrmLftoff", "EdFrmLftoff", ed_frm_lftoff, "3" ) ,
1331 Rint( "edFrmRghoff", "EdFrmRghoff", ed_frm_rghoff, "3" ) ,
1333 RDimension( "edMsgMargintop", "EdMsgMargintop", ed_msg_margintop, "3" ) ,
1334 RDimension( "edMsgMarginbtm", "EdMsgMarginbtm", ed_msg_marginbtm, "3" ) ,
1336 RDimension( "edMesgMargintop", "EdMesgMargintop", ed_mesg_margintop, "3" ) ,
1337 RDimension( "edMesgMarginbtm", "EdMesgMarginbtm", ed_mesg_marginbtm, "3" ) ,
1339 Rint( "edSepBtmoff", "EdSepBtmoff", ed_sep_btmoff, "3" ) ,
1340 Rint( "edSepLftoff", "EdSepLftoff", ed_sep_lftoff, "0" ) ,
1341 Rint( "edSepRghoff", "EdSepRghoff", ed_sep_rghoff, "0" ) ,
1342 RDimension( "edSepMargin", "EdSepMargin", ed_sep_margin, "0" ) ,
1344 Rint( "edWgeTopoff", "EdWgeTopoff", ed_wge_topoff, "10" ) ,
1345 Rint( "edWgeLftoff", "EdWgeLftoff", ed_wge_lftoff, "10" ) ,
1346 Rint( "edWgeRghoff", "EdWgeRghoff", ed_wge_rghoff, "10" ) ,
1347 Rint( "edWgeBtmoff", "EdWgeBtmoff", ed_wge_btmoff, "10" ) ,
1350 RBoolean( "frameResize", "FrameResize", frame_resize, "False" ) ,
1352 /* CreateScrollBase() */
1353 RDimension( "scllFrWidth", "ScllFrWidth", scll_fr_width, "500" ) ,
1355 RDimension( "scllFrThick", "ScllFrThick", scll_fr_thick, "2" ) ,
1357 Rint( "scllBarLftoff", "ScllBarLftoff", scll_bar_lftoff, "4" ) ,
1365 int CodePoint = False;
1369 xerror(Display *d, XErrorEvent *ev)
1371 fprintf (stderr, "dtudcfonted: warning, error event receieved.\n");
1376 main(int argc, char *argv[])
1378 static char class_name[] = "Dtudcfonted";
1381 /* initialize GUI */
1382 toplevel = GuiInitialize(&app, class_name, &argc, argv);
1384 /* get application's resources */
1385 XtGetApplicationResources( toplevel, &resource,
1386 app_resources, XtNumber(app_resources), NULL, 0);
1388 if (resource.codepoint)
1390 /* initialize the code range */
1391 for( i=1 ; i < argc ; i++ ) {
1392 if( !strcmp(argv[i],"-pane_size") ) {
1394 edpane_size = atoi( argv[i] );
1395 } else if( !strcmp(argv[i],"-codepoint") ) {
1400 resource.mg_write_snf = GETMESSAGE(2, 2, "Registration processing inside.");
1401 resource.me_write_snf = GETMESSAGE(2, 4, "Failed in the registration of the character.");
1402 resource.me_illegal_code = GETMESSAGE(2, 6, "Illegal code.");
1403 resource.me_non_memory = GETMESSAGE(2, 8, "Because the memory allocation cannot be done, it is not possible to add.");
1404 resource.mg_non_code = GETMESSAGE(2, 10, "There is no character of the specified code.");
1405 resource.me_illegal_srccode = GETMESSAGE(2, 12, "The mistake is found in the specified copy origin code.");
1406 resource.me_illegal_destcode = GETMESSAGE(2, 14, "The mistake is found in the specified copy target code.");
1407 resource.me_nodelete_code = GETMESSAGE(2, 16, "There is no character in the specified area.");
1408 resource.me_wait = GETMESSAGE(2, 18, "Please wait for a while.");
1409 resource.me_non_srcfile = GETMESSAGE(2, 20, "No copy origin code file is specified.");
1410 resource.mn_no_font = GETMESSAGE(2, 22, "Informations of user defined character cannot collect.\nThere is no font specified.");
1411 resource.mn_plural_font = GETMESSAGE(2, 24, "Informations of user defined character cannot collect.\nThere are plural fonts specified.");
1412 resource.mn_not_udc = GETMESSAGE(2, 26, "The specified font do not have any UDCs areas.");
1413 resource.mn_no_mem = GETMESSAGE(2, 28, "There are no memories any more.");
1414 resource.mn_illegal_area = GETMESSAGE(2, 30, "The information of UDCs area is illegal.");
1415 resource.mn_no_read = GETMESSAGE(2, 32, "The font file cannot read.\nPattern area was broken.");
1416 resource.mn_prop_font = GETMESSAGE(2, 34, "Dtudcfonted cannot edit proportional character font.");
1417 resource.mn_saved_open = GETMESSAGE(2, 36, "There are unsaved edits.\nDo you want to save them before opening?");
1418 resource.mn_saved_exit = GETMESSAGE(2, 38, "There are unsaved edits.\nDo you want to save them before exiting?");
1419 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");
1420 resource.mn_no_perm = GETMESSAGE(2, 42, "No write permission for this font. You should change the file access mode before saving.\n");
1422 resource.l_selectitem = GETMESSAGE(2, 100, "Select Items"); /* font open */
1423 resource.l_codeset = GETMESSAGE(2, 102, " CodeSet:");
1424 resource.l_style = GETMESSAGE(2, 104, " Style:");
1425 resource.l_width = GETMESSAGE(2, 106, " Width:");
1426 resource.l_height = GETMESSAGE(2, 108, " Height:");
1427 resource.exec_label = GETMESSAGE(2, 110, "Open");
1428 resource.quit_label = GETMESSAGE(2, 112, "Quit");
1430 resource.l_font = GETMESSAGE(2, 114, "Font"); /* menu bar */
1431 resource.l_edit = GETMESSAGE(2, 116, "Edit");
1432 resource.l_manage = GETMESSAGE(2, 118, "Character");
1433 resource.l_info = GETMESSAGE(2, 120, "Information");
1435 resource.l_open_w = GETMESSAGE(2, 122, "Open"); /* font menu */
1436 resource.l_save = GETMESSAGE(2, 124, "Save");
1437 resource.l_exit = GETMESSAGE(2, 126, "Exit");
1439 resource.l_clear = GETMESSAGE(2, 128, "Clear"); /* edit menu */
1440 resource.l_set = GETMESSAGE(2, 130, "Set");
1441 resource.l_reverse = GETMESSAGE(2, 132, "Reverse");
1442 resource.l_cut = GETMESSAGE(2, 134, "Cut");
1443 resource.l_Copy = GETMESSAGE(2, 135, "Copy");
1444 resource.l_paste = GETMESSAGE(2, 136, "Paste");
1445 resource.l_roll = GETMESSAGE(2, 138, "Rotate");
1446 resource.l_updown_roll = GETMESSAGE(2, 140, "Vertical Roll");
1447 resource.l_leftright_roll = GETMESSAGE(2, 142, "Horizontal Roll");
1448 resource.l_undo = GETMESSAGE(2, 144, "Undo");
1450 resource.l_manage_w = GETMESSAGE(2, 146, "Add/Delete..."); /* character menu */
1451 resource.l_copy_w = GETMESSAGE(2, 148, "Copy...");
1453 resource.l_xlfd = GETMESSAGE(2, 150, "XLFD name..."); /* information menu */
1454 resource.l_codearea = GETMESSAGE(2, 152, "Code Area...");
1456 resource.l_add = GETMESSAGE(2, 154, "Add"); /* add/delete dialog */
1457 resource.l_delete = GETMESSAGE(2, 156, "Delete");
1458 resource.l_cancel = GETMESSAGE(2, 158, "Cancel");
1460 resource.l_manage_code = GETMESSAGE(2, 160, "Code(hex):"); /* copy dialog */
1461 resource.l_copy_src_code = GETMESSAGE(2, 162, " Copy origin code(hex):");
1462 resource.l_copy_dest_code = GETMESSAGE(2, 164, "Copy target code(hex):");
1463 resource.l_copy = GETMESSAGE(2, 166, "Copy");
1464 resource.l_overlay = GETMESSAGE(2, 168, "Overlay");
1465 resource.l_ok = GETMESSAGE(2, 170, "OK");
1467 resource.l_do_save = GETMESSAGE(2, 172, "Save"); /* unsaved edits */
1468 resource.l_dont_save = GETMESSAGE(2, 174, "Do not Save");
1469 resource.l_do_save_exit = GETMESSAGE(2, 176, "Save and Exit");
1470 resource.l_dont_save_exit = GETMESSAGE(2, 178, "Do not Save and Exit");
1472 resource.mg_start_del_s = GETMESSAGE(2, 180, "The following character will be deleted."); /* delete notice dialog */
1473 resource.mg_start_del_cs = GETMESSAGE(2, 182, "character");
1474 resource.mg_start_del_m = GETMESSAGE(2, 184, "The following characters will be deleted.");
1475 resource.mg_start_del_cm = GETMESSAGE(2, 186, "characters");
1476 resource.mg_register = GETMESSAGE(2, 188, "Register completed");
1477 resource.l_code = GETMESSAGE(2, 190, " Code : ");
1478 resource.l_code_range = GETMESSAGE(2, 192, " Code range : ");
1480 resource.message = GETMESSAGE(2, 194, "Message : ");
1482 resource.code = GETMESSAGE(2, 196, "code..."); /* code dialog */
1483 resource.previous = GETMESSAGE(2, 198, "Page up");
1484 resource.next = GETMESSAGE(2, 200, "Page down");
1485 resource.apply = GETMESSAGE(2, 202, "Apply");
1487 resource.l_question_title = GETMESSAGE(2, 204, "dtudcfonted - Question");
1488 resource.l_warning_title = GETMESSAGE(2, 206, "dtudcfonted - Warning");
1489 resource.l_error_title = GETMESSAGE(2, 208, "dtudcfonted - Error");
1490 resource.l_copy_title = GETMESSAGE(2, 210, "dtudcfonted - Copy");
1491 resource.l_open_title = GETMESSAGE(2, 212, "dtudcfonted - Open");
1492 resource.l_add_title = GETMESSAGE(2, 214, "dtudcfonted - Add/Delete");
1493 resource.l_xlfd_title = GETMESSAGE(2, 216, "dtudcfonted - XLFD");
1494 resource.l_codearea_title = GETMESSAGE(2, 218, "dtudcfonted - CodeArea");
1496 resource.file_name = GETMESSAGE(2, 230, "File name");
1497 resource.xlfd_name = GETMESSAGE(2, 232, "XLFD name");
1498 resource.codearea = GETMESSAGE(2, 234, "Code area");
1500 resource.falerrmsg[0] = GETMESSAGE(2, 300, "Fatal error occurred.");
1501 resource.falerrmsg[1] = GETMESSAGE(2, 301, "Cannot open the font file.");
1502 resource.falerrmsg[2] = GETMESSAGE(2, 302, "Cannot read the font file.");
1503 resource.falerrmsg[3] = GETMESSAGE(2, 303, "There is no more memory.");
1504 resource.falerrmsg[4] = GETMESSAGE(2, 304, "Fatal error occurred.");
1505 resource.falerrmsg[5] = GETMESSAGE(2, 305, "The specified font file does not exist.");
1506 resource.falerrmsg[6] = GETMESSAGE(2, 306, "This font is not a pcf or snf font.");
1507 resource.falerrmsg[7] = GETMESSAGE(2, 307, "Cannot open fonts.list file.");
1508 resource.falerrmsg[8] = GETMESSAGE(2, 308, "The format of fonts.list file is illegal.");
1509 resource.falerrmsg[9] = GETMESSAGE(2, 309, "The descriptions of the fonts.list file are incorrect.");
1510 resource.falerrmsg[10] = GETMESSAGE(2, 310, "The format of fonts.list file is illegal.");
1511 resource.falerrmsg[11] = GETMESSAGE(2, 311, "Cannot open fonts.dir file.");
1512 resource.falerrmsg[12] = GETMESSAGE(2, 312, "Cannot read fonts.dir file.");
1513 resource.falerrmsg[13] = GETMESSAGE(2, 313, "Cannot read font properties.");
1514 resource.falerrmsg[14] = GETMESSAGE(2, 314, "Cannot get FONT property.");
1515 resource.falerrmsg[15] = GETMESSAGE(2, 315, "Cannot get FAMILY_NAME property.");
1516 resource.falerrmsg[16] = GETMESSAGE(2, 316, "This font file is already opened by other application.");
1517 resource.falerrmsg[17] = GETMESSAGE(2, 317, "Cannot lock font file.");
1518 resource.falerrmsg[18] = GETMESSAGE(2, 318, "Cannot unlock font file.");
1519 resource.falerrmsg[19] = GETMESSAGE(2, 319, "Cannot get lock information from the font file.");
1520 resource.falerrmsg[20] = GETMESSAGE(2, 320, "Cannot find the specified font file.");
1521 resource.falerrmsg[21] = GETMESSAGE(2, 321, "Cannot read NLS database.");
1522 resource.falerrmsg[22] = GETMESSAGE(2, 322, "Cannot get charset names from NLS database.");
1523 resource.falerrmsg[23] = GETMESSAGE(2, 323, "Charset name not defined in NLS database.");
1524 resource.falerrmsg[24] = GETMESSAGE(2, 324, "The specified font has not been opened.");
1525 resource.falerrmsg[25] = GETMESSAGE(2, 325, "Fatal error occurred.");
1530 /* initialize the global values and allocate the memories */
1534 /* displays the selection window */
1535 PopupSelectXLFD(toplevel);
1537 XSetErrorHandler((XErrorHandler)xerror);
1538 XSetIOErrorHandler((XIOErrorHandler)xerror);
1548 * contents : initialize the global values
1556 edg.code = edg.ncode = 0;
1557 bitPtnClear( edg.ptn );
1560 edlist.nlist = EDLIST_MAX;
1561 edlist.statloc = edlist.slctloc = 0;
1564 edlist.list_h = edlist.elem_w = edlist.elem_h = (Dimension)0;
1565 edlist.back = resource.pane_background;
1566 edlist.border = resource.pane_foreground;
1569 edpane.width = edpane_size;
1570 edpane.height = edpane_size;
1572 edpane.width = EDPANE_SIZE;
1573 edpane.height = EDPANE_SIZE;
1575 edpane.pix_w = edpane.pix_h = 0;
1578 edpane.back = resource.pane_background;
1579 edpane.border = resource.pane_foreground;
1582 xl.root_winID = xl.edit_winID = xl.disp_winID = xl.list_winID =
1584 xl.borderGC = xl.backGC = xl.rubGC = xl.dashGC = (GC)NULL;
1585 xl.dispImage = NULL;
1587 dn.elem_w = dn.elem_h = (Dimension)0;
1588 dn.ptn_w = dn.ptn_h = (Dimension)0;
1589 dn.list_h = (Dimension)0;
1590 dn.s_ncode = dn.e_ncode = 0;
1591 dn.sq_top = dn.sq_start = dn.sq_end = 0;
1594 for ( i=0 ; i<D_MAX ; i++ ) {
1595 dl[i].disp_winID = (Window)NULL;
1596 dl[i].dispImage = NULL;
1597 bitPtnClear( dl[i].ptn );
1599 for ( i=0 ; i<EDLIST_MAX ; i++ ) {
1600 dl_glyph[i].disp_winID = (Window)NULL;
1601 dl_glyph[i].dispImage = NULL;
1602 bitPtnClear( dl_glyph[i].ptn );
1606 em.adj_px = em.adj_py = 0;
1607 em.proc = em.slct_f = 0;
1608 em.src1_px = em.src1_py = 0;
1609 em.src2_px = em.src2_py = 0;
1610 em.dest_px = em.dest_py = 0;
1612 bitPtnClear( em.rsv_ptn );
1614 cpm.s1_code = cpm.s2_code = cpm.d1_code = 0;
1622 /****************************************************************
1623 * distroy the "User defined character editor" window *
1624 ****************************************************************/
1627 * contents : destroy the editting window
1631 dstrypaneEditPtn(void)
1637 XFree( (char *)xl.dispImage );
1638 XFreeGC( xl.display, xl.borderGC );
1639 XFreeGC( xl.display, xl.backGC );
1640 XFreeGC( xl.display, xl.rubGC );
1641 XFreeGC( xl.display, xl.dashGC );
1643 for( i=0; i<EDLIST_MAX; i++ ){
1644 if( dl_glyph[i].dispImage ){
1645 XFree( (char *)dl_glyph[i].dispImage );
1646 dl_glyph[i].dispImage = NULL ;
1650 XtPopdown( editPopW );
1651 XtDestroyWidget( editPopW );
1657 /****************************************************************
1658 * update character list *
1659 ***************************************************************/
1662 * contents : add the specified code to the character list
1666 chgEdCode( int code, char mode )
1677 ncode = codeToNo( code );
1678 esq = ptnNoToSq( ncode ) - edlist.sqstart;
1683 } else if (efctPtnNum() <= edlist.nlist) {
1685 slctloc = AbsSqToRel(edlist.sqstart, ptnNoToSq( ncode));
1687 if ((esq >= edlist.statloc)
1688 && (esq <= (RelToAbsSq( edlist.sqstart + edlist.statloc,
1689 edlist.nlist - 1) - edlist.sqstart))){
1690 statloc = edlist.statloc;
1691 slctloc = AbsSqToRel(edlist.sqstart+statloc,
1692 edlist.sqstart + esq);
1697 while( RelToAbsSq(edlist.sqstart+statloc, edlist.nlist - 1) < 0)
1698 statloc = RelToAbsSq( edlist.sqstart + statloc, -1)
1700 slctloc = AbsSqToRel( edlist.sqstart + statloc, edlist.sqstart + esq);
1704 if (( slimax = efctPtnNum()) < edlist.nlist)
1705 slimax = edlist.nlist;
1706 XtSetArg( arg[n], XmNmaximum, (XtArgVal)slimax ); n++;
1707 XtSetArg( arg[n], XmNvalue, (XtArgVal)AbsSqToRel( edlist.sqstart, edlist.sqstart + statloc) ); n++;
1708 XtSetValues( wgeScro , arg, n );
1710 chgEdList( statloc, slctloc, mode );
1716 * contents : rewrite the character list
1720 chgEdList( int statloc, int slctloc, char mode )
1727 extern void ListSetLabelStr();
1728 extern void ListSetGlyphImage();
1729 extern void ListUnselectItem();
1730 extern void ListSelectItem();
1732 if((mode == ON) || (edlist.statloc != statloc)){
1733 for (i=0, sq=edlist.sqstart+statloc; i < edlist.nlist; sq++){
1737 if ((no >= 0) && (code = noToCode(no)) >= 0 ){
1738 sprintf(str, "%4x", code);
1739 ListSetLabelStr(i, str);
1740 ListSetGlyphImage(i) ;
1742 edlist.statloc = sq - edlist.sqstart;
1744 } else if (sq > ( edlist.sqstart + edlist.nptn - 1)){
1746 ListSetLabelStr(i, str);
1747 ListSetGlyphImage(i) ;
1753 if( (mode == ON) || (edlist.slctloc != slctloc) ) {
1754 if((0 <= edlist.slctloc) && (edlist.slctloc < edlist.nlist)){
1755 ListUnselectItem(edlist.slctloc);
1757 if((0 <= slctloc) && (slctloc < edlist.nlist)){
1758 ListSelectItem(slctloc);
1760 edlist.slctloc = slctloc;
1766 * contents : rewrite the editting pane
1770 chgEdPtn( int code )
1772 extern void SetCodeString();
1774 if (xl.display == NULL ){
1779 XClearWindow( xl.display, xl.edit_winID );
1780 DrawBorderEdPn( 0, 0, edg.width - 1, edg.height - 1 );
1781 XClearWindow( xl.display, xl.disp_winID );
1782 XClearWindow( xl.display, xl.list_winID );
1783 bitPtnClear( edg.ptn );
1789 if( ptnGet( code, edg.ptn) == 0 ) {
1791 edg.ncode = codeToNo( code );
1792 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
1794 SetCodeString(code);
1803 /****************************************************************
1804 * draw patterns to the editting pane *
1805 ***************************************************************/
1808 * contents : draw a rectangle
1813 DrawRectEdPn( int x1, int y1, int x2, int y2 )
1816 short cx1, cy1, cx2, cy2;
1817 XRectangle recOn[MAXPTNSIZE*MAXPTNSIZE];
1818 XRectangle recOff[MAXPTNSIZE*MAXPTNSIZE];
1821 if (xl.display == NULL ){
1837 for( j=y1 ; j <= y2 ; j++ ) {
1838 for( i=x1 ; i <= x2 ; i++ ) {
1839 cx1 = (short)(edpane.pix_w * i);
1840 cy1 = (short)(edpane.pix_h * j);
1841 cx2 = (short)(cx1 + edpane.pix_w - 1);
1842 cy2 = (short)(cy1 + edpane.pix_h - 1);
1844 if( bitRead( edg.ptn, i, j ) != 0 ) {
1845 recOn[nron].x = cx1;
1846 recOn[nron].y = cy1;
1847 recOn[nron].width = (unsigned short)(cx2 - cx1);
1848 recOn[nron].height = (unsigned short)(cy2 - cy1);
1852 recOff[nroff].x = cx1;
1853 recOff[nroff].y = cy1;
1854 recOff[nroff].width = (unsigned short)(cx2 - cx1);
1855 recOff[nroff].height = (unsigned short)(cy2 - cy1);
1861 XFillRectangles( xl.display, xl.edit_winID, xl.borderGC, recOn, nron );
1863 XFillRectangles( xl.display, xl.edit_winID, xl.backGC, recOff, nroff );
1868 * contents : draw a lattice inside of the editting pane
1872 DrawBorderEdPn( int x1, int y1, int x2, int y2 )
1878 XSegment dseg[MAXPTNSIZE*2];
1880 if (xl.display == NULL ){
1897 cx1 = (short)(edpane.pix_w * x1);
1898 cx2 = (short)(edpane.pix_w * x2 + edpane.pix_w - 1);
1899 for( i=y1 ; i <= y2 ; i++ ) {
1900 cy1 = (short)(edpane.pix_h * i + edpane.pix_h - 1);
1901 dseg[ndseg].x1 = cx1;
1902 dseg[ndseg].y1 = cy1;
1903 dseg[ndseg].x2 = cx2;
1904 dseg[ndseg].y2 = cy1;
1907 cy1 = (short)(edpane.pix_h * y1);
1908 cy2 = (short)(edpane.pix_h * y2 + edpane.pix_h - 1);
1909 for( i=x1 ; i <= x2 ; i++ ) {
1910 cx1 = (short)(edpane.pix_w * i + edpane.pix_w - 1);
1911 dseg[ndseg].x1 = cx1;
1912 dseg[ndseg].y1 = cy1;
1913 dseg[ndseg].x2 = cx1;
1914 dseg[ndseg].y2 = cy2;
1919 XDrawSegments( xl.display, xl.edit_winID, xl.dashGC, dseg, ndseg);
1925 * contents : draw a dot
1929 DrawPointEdPn( int x, int y, int mode )
1934 if (xl.display == NULL ){
1938 x1 = edpane.pix_w * x;
1939 y1 = edpane.pix_h * y;
1940 x2 = x1 + edpane.pix_w - 1;
1941 y2 = y1 + edpane.pix_h - 1;
1944 XFillRectangle( xl.display, xl.edit_winID, xl.borderGC,
1945 x1, y1, x2-x1, y2-y1 );
1947 XFillRectangle( xl.display, xl.edit_winID, xl.backGC,
1948 x1, y1, x2-x1, y2-y1 );
1955 * contents : draw a current character pattern to the display pane
1961 if (xl.display == NULL ){
1965 XPutImage( xl.display, xl.disp_winID, xl.borderGC, xl.dispImage,
1966 0, 0, 0, 0, edg.width, edg.height );
1967 if( xl.list_winID ) {
1968 XPutImage( xl.display, xl.list_winID, xl.borderGC,
1969 xl.dispImage, 0, 0, 0, 0, edg.width, edg.height );
1976 * contents : draw a dot
1980 DrawPointDpPn( int x, int y, int mode )
1983 if (xl.display == NULL ){
1987 XDrawPoint( xl.display, xl.disp_winID, xl.borderGC, x, y );
1989 XDrawPoint( xl.display, xl.list_winID, xl.borderGC, x, y );
1991 XDrawPoint( xl.display, xl.disp_winID, xl.backGC, x, y );
1993 XDrawPoint( xl.display, xl.list_winID, xl.backGC, x, y );
1999 /****************************************************************
2000 * draw patterns by mouse *
2001 ****************************************************************/
2005 * contents : draw a dot
2009 musPoint( int evtype, int px, int py )
2013 if( (em.src1_px == px) && (em.src1_py == py) )
2024 if( edpane.color == ON )
2025 bitSet( edg.ptn, px, py );
2027 bitReset( edg.ptn, px, py );
2029 DrawPointEdPn( px, py, edpane.color );
2030 DrawPointDpPn( px, py, edpane.color );
2035 * contents : draw a line
2039 musLine( int evtype, int px, int py )
2047 harf_pix_w = edpane.pix_w / 2;
2048 harf_pix_h = edpane.pix_h / 2;
2049 r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
2050 r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
2051 r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
2052 r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
2053 rx = px * edpane.pix_w + harf_pix_w;
2054 ry = py * edpane.pix_h + harf_pix_h;
2058 if( (em.src2_px == px) && (em.src2_py == py) )
2060 rubLine( r1_x, r1_y, r2_x, r2_y );
2061 rubLine( r1_x, r1_y, rx, ry );
2066 em.src1_px = em.src2_px = px;
2067 em.src1_py = em.src2_py = py;
2070 if( (r1_x == r2_x) && (r1_y == r2_y) )
2072 rubLine( r1_x, r1_y, r2_x, r2_y );
2074 if ((em.src2_px < 0) || (em.src2_py < 0) ||
2075 (edg.width <= em.src2_px) || (edg.height <= em.src2_py))
2078 bitDrawLine( edg.ptn, em.src1_px, em.src1_py,
2079 em.src2_px, em.src2_py, edpane.color );
2081 DrawRectEdPn( em.src1_px, em.src1_py, em.src2_px, em.src2_py );
2089 * contents : draw a circle
2093 musCircle( int evtype, int px, int py )
2100 extern int bitDrawCircle();
2102 harf_pix_w = edpane.pix_w / 2;
2103 harf_pix_h = edpane.pix_h / 2;
2105 r1_x = em.src1_px * edpane.pix_w + harf_pix_w;
2106 r1_y = em.src1_py * edpane.pix_h + harf_pix_h;
2107 r2_x = em.src2_px * edpane.pix_w + harf_pix_w;
2108 r2_y = em.src2_py * edpane.pix_h + harf_pix_h;
2109 rx = px * edpane.pix_w + harf_pix_w;
2110 ry = py * edpane.pix_h + harf_pix_h;
2114 if( (em.src2_px == px) && (em.src2_py == py) ) {
2117 rubCircle( r1_x, r1_y, r2_x, r2_y );
2118 rubCircle( r1_x, r1_y, rx, ry );
2123 em.src1_px = em.src2_px = px;
2124 em.src1_py = em.src2_py = py;
2127 if( (em.src1_px == px) && (em.src1_py == py) ) {
2130 rubCircle( r1_x, r1_y, r2_x, r2_y );
2132 if( (px < 0) || (py < 0) || (edg.width <= px) || (edg.height <= py) ) {
2135 bitDrawCircle( edg.ptn, em.src1_px, em.src1_py, px, py, edpane.color);
2138 DrawRectEdPn( 0, 0, edg.width -1, edg.height -1 );
2145 * contents : draw a rectangle
2149 musRect( int proc, int evtype, int px, int py )
2158 if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
2159 dpx = px - em.src1_px;
2160 dpy = py - em.src1_py;
2161 dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
2164 px = em.src1_px + dpx/abs(dpx) * dp;
2166 py = em.src1_py + dpy/abs(dpy) * dp;
2169 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2170 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2171 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2172 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2173 rx = px * edpane.pix_w + edpane.pix_w / 2;
2174 ry = py * edpane.pix_h + edpane.pix_h / 2;
2178 if( (em.src2_px == px) && (em.src2_py == py) )
2180 rubBand( r1_x, r1_y, r2_x, r2_y );
2181 rubBand( r1_x, r1_y, rx, ry );
2186 resetEditMode( RES_SLCT );
2187 em.src1_px = em.src2_px = px;
2188 em.src1_py = em.src2_py = py;
2191 resetEditMode( RES_MSG | RES_PROC );
2192 rubBand( r1_x, r1_y, r2_x, r2_y );
2193 if( (r1_x == r2_x) || (r1_y == r2_y) )
2195 if( (em.src2_px < 0) || (em.src2_py < 0) ||
2196 (edg.width <= em.src2_px) || (edg.height <= em.src2_py) )
2199 lux = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
2200 luy = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
2201 width = abs( em.src1_px - em.src2_px ) + 1;
2202 height = abs( em.src1_py - em.src2_py ) + 1;
2204 bitDrawRect(edg.ptn, lux, luy, width, height, edpane.color);
2207 DrawRectEdPn( em.src1_px, em.src1_py, px, py );
2214 * contents : edit inside of the specified area (clear, reverse, rotate,etc.)
2218 musRegionProc( int proc, int evtype, int px, int py )
2222 extern void SelectSet();
2224 if( (proc == PROC_ROLL) && (evtype != ButtonPress) ) {
2225 dpx = px - em.src1_px;
2226 dpy = py - em.src1_py;
2227 dp = (abs(dpx) > abs(dpy) ) ? abs(dpx) : abs(dpy);
2230 px = em.src1_px + dpx/abs(dpx) * dp;
2232 py = em.src1_py + dpy/abs(dpy) * dp;
2235 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2236 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2237 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2238 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2239 rx = px * edpane.pix_w + edpane.pix_w / 2;
2240 ry = py * edpane.pix_h + edpane.pix_h / 2;
2244 if( (em.src2_px == px) && (em.src2_py == py) )
2246 rubBand( r1_x, r1_y, r2_x, r2_y );
2247 rubBand( r1_x, r1_y, rx, ry );
2252 if (select_x || select_y || select_w || select_h) {
2253 rubBand( r1_x, r1_y, r2_x, r2_y );
2255 resetEditMode( RES_SLCT );
2256 em.src1_px = em.src2_px = px;
2257 em.src1_py = em.src2_py = py;
2260 resetEditMode( RES_MSG | RES_PROC );
2261 select_x = select_y = select_w = select_h = 0;
2262 if( (r1_x == r2_x) || (r1_y == r2_y) ) {
2263 rubBand( r1_x, r1_y, r2_x, r2_y );
2266 if( (em.src2_px < 0) || (em.src2_py < 0) ||
2267 (edg.width <= em.src2_px) || (edg.height <= em.src2_py) ) {
2268 rubBand( r1_x, r1_y, r2_x, r2_y );
2272 select_x = (em.src1_px < em.src2_px ) ? em.src1_px : em.src2_px;
2273 select_y = (em.src1_py < em.src2_py ) ? em.src1_py : em.src2_py;
2274 select_w = abs( em.src1_px - em.src2_px ) + 1;
2275 select_h = abs( em.src1_py - em.src2_py ) + 1;
2283 musPasteProc(Widget w, XtPointer client_data, XEvent *event)
2285 static int ox=0, oy=0;
2287 extern void UndoSet();
2288 extern Widget wgeBulB_edit;
2289 extern int bitDrawPaste();
2291 switch(event->type) {
2293 tx = (event->xmotion.x / edpane.pix_w) * edpane.pix_w + edpane.pix_w / 2;
2294 ty = (event->xmotion.y / edpane.pix_h) * edpane.pix_h + edpane.pix_h / 2;
2295 if (tx == ox && ty == oy)
2298 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2302 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2305 XtRemoveEventHandler(wgeBulB_edit,
2306 ButtonReleaseMask|PointerMotionMask,
2307 False, (XtEventHandler)musPasteProc, NULL );
2308 rubBand(ox, oy, ox + cut_w * edpane.pix_w, oy + cut_h * edpane.pix_h);
2311 bitPtnCopy( em.rsv_ptn, edg.ptn );
2313 tx = event->xbutton.x / edpane.pix_w;
2314 ty = event->xbutton.y / edpane.pix_h;
2315 rc = bitDrawPaste(edg.ptn, tx, ty);
2320 DrawRectEdPn( 0, 0, edg.width - 1, edg.height - 1 );
2330 rubLine( int x1, int y1, int x2, int y2 )
2332 if( x1==x2 && y1==y2 ) return;
2334 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1,y1, x2,y2 );
2340 rubBand( int x1, int y1, int x2, int y2 )
2342 if( x1==x2 && y1==y2 )
2345 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x2, y1 );
2346 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y1, x1, y2 );
2347 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x2, y1, x2, y2 );
2348 XDrawLine( xl.display, xl.edit_winID, xl.rubGC, x1, y2, x2, y2 );
2354 rubCircle( int ox, int oy, int rx, int ry )
2359 if( ox==rx && oy==ry ) return;
2363 r = (unsigned int)sqrt( (double)(x*x + y*y) );
2364 if ( r == 0 ) return;
2368 XDrawArc( xl.display, xl.edit_winID, xl.rubGC,
2377 resetEditMode( unsigned int flag )
2382 if( flag & RES_MSG )
2383 UpdateMessage( "" );
2385 if( flag & RES_PROC )
2386 em.proc = edpane.obj;
2388 if( (flag & RES_SLCT) && (em.slct_f) ) {
2389 r1_x = em.src1_px * edpane.pix_w + edpane.pix_w / 2;
2390 r1_y = em.src1_py * edpane.pix_h + edpane.pix_h / 2;
2391 r2_x = em.src2_px * edpane.pix_w + edpane.pix_w / 2;
2392 r2_y = em.src2_py * edpane.pix_h + edpane.pix_h / 2;
2393 rubBand( r1_x, r1_y, r2_x, r2_y );
2397 if( flag & RES_RSV )
2402 /****************************************************************
2403 * copy character pattern *
2404 ***************************************************************/
2407 * contents : copy or overlay the new character pattern to the current pattern
2420 int d1_ncode, d2_ncode;
2428 char ptn2[MAXPTNBYTE];
2430 extern int last_code;
2432 ret = copySNF(s1_code, s2_code, &ptn, &num, err);
2434 Error_message2((Widget)NULL, err);
2438 if (last_code < (d1_code + num))
2439 last_code = d1_code + num;
2441 if( ptnSense(edg.code) == 1 )
2442 ptnAdd( edg.code, edg.ptn );
2444 d1_ncode = codeToNo( d1_code );
2446 for (i_d=d1_ncode, i_s=0; i_s < num; i_d++) {
2447 if ( codeCheck( noToCode( i_d)))
2449 bitPtnClear( ptn2 );
2450 code_d = noToCode( i_d );
2451 grc_d = ptnGet( code_d, ptn2 );
2454 if( proc == CPY_OVERLAY ) {
2455 for( i=0 ; i < edg.height*((edg.width+7)/8) ; i++ ) {
2456 ptn[i_s][i] |= ptn2[i];
2459 ptnAdd( code_d, ptn[i_s] );
2462 if( ptnAdd( code_d, ptn[i_s] ) != 1 ) {
2463 UpdateMessage( resource.me_non_memory );
2474 for( i=d1_ncode ; i <= d2_ncode; i++ ) {
2475 if ( codeCheck( noToCode(i) ) )
2477 if( ptnSense( noToCode( i ) ) == 1 ) {
2478 code_disp = noToCode( i );
2484 if( (code_disp == 0) && (efctPtnNum() > 0))
2485 code_disp = noToCode( ptnSqToNo(edlist.sqstart) );
2487 chgEdCode( code_disp, ON );
2489 resetEditMode( (unsigned int) (RES_MSG | RES_PROC | RES_SLCT | RES_RSV) );