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 /* 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 ** ==================================================================
50 void PopdownCpyPtn(void);
53 void CpyCB(Widget w, XtPointer cdata);
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 ** --------------------------------------
105 CpySrcCodeTfValue(void)
107 return(GetTextFieldValue(&SrcTf));
112 ** get the character strings of destination code area from input field
113 ** --------------------------------------
117 CpyDestCodeTfValue(void)
119 return(GetTextFieldValue(&DestTf));
124 ** contents : pop up the copy confirmation window
125 ** --------------------------------
129 PopupCpyNotice( String message )
133 static NoticeButton buttons[] = {
134 NBTNARGS( DoCpyProc, NULL, NULL, True, False ),
135 NBTNARGS( NULL, NULL, NULL, True, False ),
137 static NButton BTN = NBUTTONS( buttons );
139 snprintf(bmsg, sizeof(bmsg), "%s%s", resource.mn_cpy_lost, message);
140 SetItemLabel(&BTN, 0, resource.l_ok);
141 SetItemLabel(&BTN, 1, resource.l_cancel);
142 PopupNotice( cpyPtnW, bmsg, D_WARNING, &BTN, False, resource.l_warning_title);
147 ** contents : "Copy" button callback
148 ** ------------------------
149 ** execute the copy processing
154 CpyCB(Widget w, XtPointer cdata)
156 extern Boolean BeforeCpyCheck();
157 if (BeforeCpyCheck(cdata)){
166 ** "Add/Delete" window
167 ** ===================================================================
171 ** contents : pop down the "Add/Delete" window
172 ** ------------------------------
178 PopdownDialog(mngPtnW);
182 ** contents : "Add" button callback
183 ** ------------------------
190 extern Boolean BeforeMngCheck();
191 extern void DoAddProc();
193 if (BeforeMngCheck(&s_code, &e_code)){
194 DoAddProc(s_code, e_code);
200 ** contents : "Delete" button callback
201 ** ------------------------
208 extern void DoDelProc();
209 extern Boolean BeforeMngCheck();
211 if (BeforeMngCheck(&s_code, &e_code)){
212 DoDelProc(s_code, e_code);
216 static ButtonItems add_btn[] = {
217 BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) AddCB, NULL, NULL, True, True ),
218 BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelCB, NULL, NULL, True, False ),
219 BTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) PopdownMngPtn, NULL, NULL, True, False ),
221 static Button AddBTN = BUTTONS( add_btn );
223 static TextField MngCodeTf;
226 ** contents : create and pop up the "Add/Delete" window
227 ** ------------------------------------
236 SetItemLabel(&AddBTN, 0, resource.l_add);
237 SetItemLabel(&AddBTN, 1, resource.l_delete);
238 SetItemLabel(&AddBTN, 2, resource.l_cancel);
240 CreateDialogAndButtons( toplevel, resource.l_add_title,
242 NULL, &AddBTN, XtNumber(add_btn), &mngPtnW);
244 CreateTextField(rowcol, "wgkTxtF",
245 resource.l_manage_code, &MngCodeTf, 4);
247 PopupDialog(mngPtnW);
254 ** contents : get the character strings of code for add or delete from the
256 ** --------------------------------------------
262 return(GetTextFieldValue(&MngCodeTf));
268 ** the delete confirmation window
269 ** ===================================================================
272 static Widget CreateDelNotice();
273 static void drawDelPtn();
274 static void drawDelCode();
275 static void CBdnOblB_del();
276 static void EHdnBulB_disp();
277 void EHStaT_disp(); /* add 1995.09.20 */
279 static Widget dnStaT_code[D_MAX], dnBulB_disp[D_MAX], dnPopW;
282 ** contents : pop up the delete confirmation window
283 ** --------------------------
287 PopupDelNotice( Widget owner )
290 Widget delNoticeW = NULL;
292 delNoticeW = CreateDelNotice(owner);
293 XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, False, NULL);
294 XtManageChild(delNoticeW);
296 for ( i=0 ; i < dn.disp_num ; i++ ) {
297 /* moved from paneDelNotice body */
298 dl[i].disp_winID = XtWindow( dnBulB_disp[i] );
303 XtVaSetValues(XtParent(delNoticeW), XmNmappedWhenManaged, True, NULL);
305 XBell(XtDisplayOfObject(delNoticeW), 0);
310 ** contents : clear the image of deleted character
311 ** ----------------------------------------------
315 dstrypaneDelNotice(void)
319 for ( i=0; i<dn.disp_num; i++ ){
320 XFree((char *) dl[i].dispImage);
326 ** contents : "OK" button callback
327 ** ----------------------------
339 ** contents : callback of the delete list
340 ** ------------------------------------
344 delScProc( int value )
347 extern int RelToAbsSq();
349 dn.sq_top = RelToAbsSq( dn.sq_start, value - dn.sq_start);
350 for ( i=0 ; i < dn.disp_num ; i++ ) {
358 ** contents : create the delete confirmation window
359 ** --------------------------
363 CreateDelNotice(Widget owner)
365 Widget form, listBase, itemform[D_MAX];
367 int i, val, min, max;
369 extern int AbsSqToRel();
370 extern void AddDestroyProc();
372 static NoticeButton buttons[] = {
373 NBTNARGS( (void(*)(struct _WidgetRec*,void*,void*)) DelOkCB, NULL, NULL, True, False ),
374 NBTNARGS( NULL, NULL, NULL, True, False ),
376 static NButton BTN = NBUTTONS( buttons );
377 c = AbsSqToRel( dn.sq_start, dn.sq_end) + 1;
379 sprintf(buf, "%s(%d %s)", resource.mg_start_del_s,
380 c, resource.mg_start_del_cs );
382 sprintf(buf, "%s(%d %s)", resource.mg_start_del_m,
383 c, resource.mg_start_del_cm );
385 SetItemLabel(&BTN, 0, resource.l_ok);
386 SetItemLabel(&BTN, 1, resource.l_cancel);
387 form = CreateTemplateDialog( owner, buf, D_QUESTION, &BTN,
388 resource.l_question_title, &dnPopW);
389 AddDestroyProc(dnPopW, dstrypaneDelNotice);
391 if ( dn.disp_num < (AbsSqToRel( dn.sq_start, dn.sq_end) + 1)) {
393 val = AbsSqToRel( dn.sq_start, dn.sq_top) + dn.sq_start;
395 max = AbsSqToRel( dn.sq_start, dn.sq_end) + dn.sq_start +1;
396 listBase = CreateScrollBase( form, "listBase",
397 min, max, val, dn.disp_num, delScProc );
401 CreateRowColumn( form, "listBase", L_VERTICAL, 4,2,2 );
404 for(i=0; i<dn.disp_num; i++) {
405 /* create form for the codes and fonts to be deleted */
406 itemform[i] = CreateForm( listBase, "listBase" );
408 /* create widgets for the codes to be deleted in the list */
409 dnStaT_code[i] = CreateLabel( itemform[i], "label", " " );
410 AddTopAttachForm( dnStaT_code[i], 0 );
411 AddLeftAttachForm( dnStaT_code[i], 0 );
412 AddBottomAttachForm( dnStaT_code[i], 0 );
414 /* create widgets for the image of the codes to be deleted in the list */
415 dnBulB_disp[i] = CreateDrawingArea( itemform[i], "image",
416 edg.width, edg.height, EHdnBulB_disp, i);
417 AddLeftAttachWidget( dnBulB_disp[i], dnStaT_code[i], 0 );
420 dl[i].dispImage = XCreateImage( xl.display,
421 DefaultVisual( xl.display, DefaultScreen(xl.display) ),
422 1, XYBitmap, 0, dl[i].ptn, dn.ptn_w, dn.ptn_h, 8, 0);
423 dl[i].dispImage->bitmap_bit_order = MSBFirst;
424 dl[i].dispImage->byte_order = MSBFirst;
427 XtManageChildren( itemform, dn.disp_num );
433 ** contents : delete characters from editor
434 ** -----------------------------------------
441 int code; /* code number for check */
442 int ncode; /* sequential number in the codeset system area */
443 int sq_now; /* sequential number in the editor */
444 char mode; /* notify the modification of the edit list */
445 extern void chgEdCode();
447 XtSetSensitive( dnPopW, FALSE );
449 for( sq_now=dn.sq_end ; sq_now >= dn.sq_start ; sq_now-- ) {
450 ncode = ptnSqToNo(sq_now);
451 if ( codeCheck( noToCode(ncode)))
453 if (ptnSense( noToCode(ncode) ) == 1) {
454 ptnDel( noToCode(ncode) );
461 /* update the current character */
464 for ( ; sq_now < (edlist.sqstart + edlist.nptn); sq_now++) {
465 ncode = ptnSqToNo(sq_now);
466 if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0))
469 if(sq_now > (edlist.sqstart + edlist.nptn -1)) {
471 for ( ; sq_now >= edlist.sqstart; sq_now--) {
472 ncode = ptnSqToNo(sq_now);
473 if (( ncode >= 0) && ( codeCheck( noToCode( ncode)) == 0))
478 /* check the existence of the current character */
479 if( (sq_now != -1) && ((ncode = ptnSqToNo(sq_now)) != -1) ){
480 code = noToCode( ncode );
482 /* There is no characters on the editor, dtudcfonted does not
483 * display any character on the editing pane and forbid users
485 * It can realize to put 0 to the first parameter of chgEdCode().
489 if(codeCheck( code )) {
494 if( ptnSense( edg.code ) == 1 ) {
495 ptnAdd( edg.code, edg.ptn );
498 /* renew the current character */
500 chgEdCode( code, mode );
502 XtSetSensitive( dnPopW, TRUE );
507 ** contents : display the image of the character to be deleted
508 ** ------------------------
513 drawDelPtn( int i /* window number */)
515 if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) {
516 ptnGet( noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))),
518 XPutImage(xl.display, dl[i].disp_winID, xl.borderGC,
519 dl[i].dispImage, 0,0,0,0, dn.ptn_w, dn.ptn_h );
527 ** contents : display the code of the character to be deleted
528 ** ----------------------
533 drawDelCode( int i /* window number */)
537 if ( RelToAbsSq( dn.sq_top, i) <= dn.sq_end) {
538 sprintf(str, "%4x ", noToCode(ptnSqToNo(RelToAbsSq( dn.sq_top, i))));
539 SetLabelString(dnStaT_code[i], str);
547 ** contents : re-display the code of the character to be deleted
548 ** --------------------------------------------------------------
553 EHdnBulB_disp( Widget widget, int i /* widget that have some ivent */ )
561 ** notify error message
562 ** ===================================================================
567 ** contents : inner functions of DispMngErrorMessage()
568 ** ----------------------------------
572 DispErrorMessage( Widget owner, String title, String msg )
574 static NoticeButton buttons[] = {
575 NBTNARGS( NULL, NULL, NULL, True, False ),
577 static NButton BTN = NBUTTONS( buttons );
579 SetItemLabel(&BTN, 0, resource.l_ok);
580 PopupNotice( owner, msg, D_ERROR, &BTN, False, title );
585 ** contents : display "Add" or "Delete" error
586 ** --------------------------------
590 DispMngErrorMessage( String msg )
592 DispErrorMessage( mngPtnW, resource.l_error_title, msg );
597 ** contents : display "Copy" error
598 ** --------------------------
602 DispCpyErrorMessage( String msg )
604 DispErrorMessage( cpyPtnW, resource.l_error_title, msg );