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 /* cpyw.c 1.9 - Fujitsu source for CDEnext 96/10/30 13:31:40 */
24 /* $XConsortium: cpyw.c /main/7 1996/11/08 01:53:38 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
36 #include <X11/Intrinsic.h>
38 #include "xoakufont.h"
42 extern Resource resource ;
43 extern Widget cpyDialog;
46 ** create and display the "User defined character ecitor :Copy" window
47 ** ==================================================================
55 /* static */ TextField SrcTf;
56 /* static */ TextField DestTf;
60 ** contents : initialize the "Copy" window
61 ** --------------------
69 /* initialize font infomation */
74 ** contents : create and pop up the "Copy" window
75 ** ----------------------------------
82 extern void CpyPtnXLFD();
88 ** contents : pop down the "Copy" window
89 ** ----------------------
95 ForcePopdownDialog(cpyDialog);
100 ** get the character strings of source code area from the input field
101 ** --------------------------------------
107 return(GetTextFieldValue(&SrcTf));
112 ** get the character strings of destination code area from input field
113 ** --------------------------------------
119 return(GetTextFieldValue(&DestTf));
124 ** contents : pop up the copy confirmation window
125 ** --------------------------------
129 PopupCpyNotice( message )
134 static NoticeButton buttons[] = {
135 NBTNARGS( DoCpyProc, NULL, NULL, True, False ),
136 NBTNARGS( NULL, NULL, NULL, True, False ),
138 static NButton BTN = NBUTTONS( buttons );
140 strcpy( bmsg, resource.mn_cpy_lost );
141 strcat( bmsg, message );
142 SetItemLabel(&BTN, 0, resource.l_ok);
143 SetItemLabel(&BTN, 1, resource.l_cancel);
144 PopupNotice( cpyPtnW, bmsg, D_WARNING, &BTN, False, resource.l_warning_title);
149 ** contents : "Copy" button callback
150 ** ------------------------
151 ** execute the copy processing
160 extern Boolean BeforeCpyCheck();
161 if (BeforeCpyCheck(cdata)){
170 ** "Add/Delete" window
171 ** ===================================================================
175 ** contents : pop down the "Add/Delete" window
176 ** ------------------------------
182 PopdownDialog(mngPtnW);
186 ** contents : "Add" button callback
187 ** ------------------------
194 extern Boolean BeforeMngCheck();
195 extern void DoAddProc();
197 if (BeforeMngCheck(&s_code, &e_code)){
198 DoAddProc(s_code, e_code);
204 ** contents : "Delete" button callback
205 ** ------------------------
212 extern void DoDelProc();
213 extern Boolean BeforeMngCheck();
215 if (BeforeMngCheck(&s_code, &e_code)){
216 DoDelProc(s_code, e_code);
220 static ButtonItems add_btn[] = {
221 BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) AddCB, NULL, NULL, True, True ),
222 BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelCB, NULL, NULL, True, False ),
223 BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) PopdownMngPtn, NULL, NULL, True, False ),
225 static Button AddBTN = BUTTONS( add_btn );
227 static TextField MngCodeTf;
230 ** contents : create and pop up the "Add/Delete" window
231 ** ------------------------------------
240 SetItemLabel(&AddBTN, 0, resource.l_add);
241 SetItemLabel(&AddBTN, 1, resource.l_delete);
242 SetItemLabel(&AddBTN, 2, resource.l_cancel);
244 CreateDialogAndButtons( toplevel, resource.l_add_title,
246 NULL, &AddBTN, XtNumber(add_btn), &mngPtnW);
248 CreateTextField(rowcol, "wgkTxtF",
249 resource.l_manage_code, &MngCodeTf, 4);
251 PopupDialog(mngPtnW);
258 ** contents : get the character strings of code for add or delete from the input field
259 ** --------------------------------------------
265 return(GetTextFieldValue(&MngCodeTf));
271 ** the delete confirmation window
272 ** ===================================================================
275 static Widget CreateDelNotice();
276 static void drawDelPtn();
277 static void drawDelCode();
278 static void CBdnOblB_del();
279 static void EHdnBulB_disp();
280 void EHStaT_disp(); /* add 1995.09.20 */
282 static Widget dnStaT_code[D_MAX], dnBulB_disp[D_MAX], dnPopW;
285 ** contents : pop up the delete confirmation window
286 ** --------------------------
290 PopupDelNotice( owner )
294 Widget delNoticeW = NULL;
296 delNoticeW = CreateDelNotice(owner);
297 XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, False, NULL);
298 XtManageChild(delNoticeW);
300 for ( i=0 ; i < dn.disp_num ; i++ ) {
301 /* moved from paneDelNotice body */
302 dl[i].disp_winID = XtWindow( dnBulB_disp[i] );
307 XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, True, NULL);
309 XBell(XtDisplayOfObject(delNoticeW), 0);
314 ** contents : clear the image of deleted character
315 ** ----------------------------------------------
323 for ( i=0; i<dn.disp_num; i++ ){
324 XFree((char *) dl[i].dispImage);
330 ** contents : "OK" button callback
331 ** ----------------------------
343 ** contents : callback of the delete list
344 ** ------------------------------------
352 extern int RelToAbsSq();
354 dn.sq_top = RelToAbsSq( dn.sq_start, value - dn.sq_start);
355 for ( i=0 ; i < dn.disp_num ; i++ ) {
363 ** contents : create the delete confirmation window
364 ** --------------------------
368 CreateDelNotice(owner)
371 Widget form, listBase, itemform[D_MAX];
373 int i, val, min, max;
375 extern int AbsSqToRel();
376 extern void AddDestroyProc();
378 static NoticeButton buttons[] = {
379 NBTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelOkCB, NULL, NULL, True, False ),
380 NBTNARGS( NULL, NULL, NULL, True, False ),
382 static NButton BTN = NBUTTONS( buttons );
383 c = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
385 sprintf(buf, "%s(%d %s)", resource.mg_start_del_s,
386 c, resource.mg_start_del_cs );
388 sprintf(buf, "%s(%d %s)", resource.mg_start_del_m,
389 c, resource.mg_start_del_cm );
391 SetItemLabel(&BTN, 0, resource.l_ok);
392 SetItemLabel(&BTN, 1, resource.l_cancel);
393 form = CreateTemplateDialog( owner, buf, D_QUESTION, &BTN,
394 resource.l_question_title, &dnPopW);
395 AddDestroyProc(dnPopW, dstrypaneDelNotice);
397 if ( dn.disp_num < (AbsSqToRel( dn.sq_start, dn.sq_end) + 1)) {
399 val = AbsSqToRel( dn.sq_start, dn.sq_top) + dn.sq_start;
401 max = AbsSqToRel( dn.sq_start, dn.sq_end) + dn.sq_start +1;
402 listBase = CreateScrollBase( form, "listBase",
403 min, max, val, dn.disp_num, delScProc );
407 CreateRowColumn( form, "listBase", L_VERTICAL, 4,2,2 );
410 for(i=0; i<dn.disp_num; i++) {
411 /* create form for the codes and fonts to be deleted */
412 itemform[i] = CreateForm( listBase, "listBase" );
414 /* create widgets for the codes to be deleted in the list */
415 dnStaT_code[i] = CreateLabel( itemform[i], "label", " " );
416 AddTopAttachForm( dnStaT_code[i], 0 );
417 AddLeftAttachForm( dnStaT_code[i], 0 );
418 AddBottomAttachForm( dnStaT_code[i], 0 );
420 /* create widgets for the image of the codes to be deleted in the list */
421 dnBulB_disp[i] = CreateDrawingArea( itemform[i], "image",
422 edg.width, edg.height, EHdnBulB_disp, i);
423 AddLeftAttachWidget( dnBulB_disp[i], dnStaT_code[i], 0 );
426 dl[i].dispImage = XCreateImage( xl.display,
427 DefaultVisual( xl.display, DefaultScreen(xl.display) ),
428 1, XYBitmap, 0, dl[i].ptn, dn.ptn_w, dn.ptn_h, 8, 0);
429 dl[i].dispImage->bitmap_bit_order = MSBFirst;
430 dl[i].dispImage->byte_order = MSBFirst;
433 XtManageChildren( itemform, dn.disp_num );
439 ** contents : delete characters from editor
440 ** -----------------------------------------
447 int code; /* code number for check */
448 int ncode; /* sequential number in the codeset system area */
449 int sq_now; /* sequential number in the editor */
450 char mode; /* notify the modification of the edit list */
451 extern void chgEdCode();
453 XtSetSensitive( dnPopW, FALSE );
455 for( sq_now=dn.sq_end ; sq_now >= dn.sq_start ; sq_now-- ) {
456 ncode = ptnSqToNo(sq_now);
457 if ( codeCheck( noToCode(ncode)))
459 if (ptnSense( noToCode(ncode) ) == 1) {
460 ptnDel( noToCode(ncode) );
467 /* update the current character */
470 for ( ; sq_now < (edlist.sqstart + edlist.nptn); sq_now++) {
471 ncode = ptnSqToNo(sq_now);
472 if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0))
475 if(sq_now > (edlist.sqstart + edlist.nptn -1)) {
477 for ( ; sq_now >= edlist.sqstart; sq_now--) {
478 ncode = ptnSqToNo(sq_now);
479 if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0))
484 /* check the existence of the current character */
485 if( (sq_now != -1) && ((ncode = ptnSqToNo(sq_now)) != -1) ){
486 code = noToCode( ncode );
488 /* There is no characters on the editor, dtudcfonted does not
489 * display any character on the editing pane and forbid users
491 * It can realize to put 0 to the first parameter of chgEdCode().
495 if(codeCheck( code )) {
500 if( ptnSense( edg.code ) == 1 ) {
501 ptnAdd( edg.code, edg.ptn );
504 /* renew the current character */
506 chgEdCode( code, mode );
508 XtSetSensitive( dnPopW, TRUE );
513 ** contents : display the image of the character to be deleted
514 ** ------------------------
520 int i; /* window number */
522 if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) {
523 ptnGet( noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))),
525 XPutImage(xl.display, dl[i].disp_winID, xl.borderGC,
526 dl[i].dispImage, 0,0,0,0, dn.ptn_w, dn.ptn_h );
534 ** contents : display the code of the character to be deleted
535 ** ----------------------
541 int i; /* window number */
545 if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) {
546 sprintf(str, "%4x ", noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))));
547 SetLabelString(dnStaT_code[i], str);
555 ** contents : re-display the code of the character to be deleted
556 ** --------------------------------------------------------------
561 EHdnBulB_disp( widget, i )
563 int i; /* widget that have some ivent */
571 ** notify error message
572 ** ===================================================================
577 ** contents : inner functions of DispMngErrorMessage()
578 ** ----------------------------------
582 DispErrorMessage( owner, title, msg )
587 static NoticeButton buttons[] = {
588 NBTNARGS( NULL, NULL, NULL, True, False ),
590 static NButton BTN = NBUTTONS( buttons );
592 SetItemLabel(&BTN, 0, resource.l_ok);
593 PopupNotice( owner, msg, D_ERROR, &BTN, False, title );
598 ** contents : display "Add" or "Delete" error
599 ** --------------------------------
603 DispMngErrorMessage( msg )
606 DispErrorMessage( mngPtnW, resource.l_error_title, msg );
611 ** contents : display "Copy" error
612 ** --------------------------
616 DispCpyErrorMessage( msg )
619 DispErrorMessage( cpyPtnW, resource.l_error_title, msg );