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 /* mtfgui.c 1.21 - Fujitsu source for CDEnext 96/10/30 13:13:46 */
24 /* $XConsortium: mtfgui.c /main/11 1996/11/08 01:55:01 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>
37 #include <Xm/MessageB.h>
39 #include "xoakufont.h"
48 static void EHStaT_disp();
50 extern Resource resource;
52 extern int efctPtnNum();
53 extern char *char_set();
55 extern char *fullpath;
56 extern FalFontData fullFontData;
58 extern FalCodeRegion CodeArea[16];
60 /********************************************************************
62 ********************************************************************/
63 extern Widget toplevel;
67 static Widget wgeStaT_form[EDLIST_MAX],
68 wgeStaT_disp[EDLIST_MAX],
69 wgeStaT_list[EDLIST_MAX],
72 /**********************************************************************
74 **********************************************************************/
77 * contents : displays the "User Defined Charactrer editor" window
80 static Widget CreateEditPtn();
93 ** contents : manage the codes list
94 ** ===================================================================
104 XmString cs, cs1, cs2;
106 sprintf(mess, "%s : %s", resource.file_name, fullpath);
107 cs = XmStringCreateLocalized(mess);
108 cs1 = XmStringSeparatorCreate();
109 cs2 = XmStringConcat(cs, cs1);
112 sprintf(mess, "%s : %s", resource.xlfd_name, fullFontData.xlfdname);
113 cs1 = XmStringCreateLocalized(mess);
114 cs = XmStringConcat(cs2, cs1);
118 XtSetArg (args[n], XmNtitle, resource.l_xlfd_title); n++;
119 XtSetArg (args[n], XmNmessageString, cs); n++;
120 XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
121 dialog = XmCreateInformationDialog (toplevel, "Xlfd_name", args, n);
122 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
123 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
124 XtManageChild (dialog);
138 sprintf(mess, "%s : ", resource.codearea);
139 switch (fullFontData.cd_set) {
141 strcat(mess, "CS0:");
144 strcat(mess, "CS1:");
147 strcat(mess, "CS2:");
150 strcat(mess, "CS3:");
154 for (n=0; CodeArea[n].start != -1; n++) {
155 sprintf(tmp, " %X - %X ", CodeArea[n].start, CodeArea[n].end);
158 cs = XmStringCreateLocalized(mess);
160 XtSetArg (args[n], XmNtitle, resource.l_codearea_title); n++;
161 XtSetArg (args[n], XmNmessageString, cs); n++;
162 XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
163 XtSetArg (args[n], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON); n++;
164 dialog = XmCreateInformationDialog (toplevel, "UDCarea", args, n);
165 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
166 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
167 XtManageChild (dialog);
172 ListSetLabelStr(i, str)
176 SetLabelString( wgeStaT_list[i], str );
183 XtVaSetValues( wgeStaT_list[i],
184 XmNbackground, (XtArgVal) resource.foreground,
185 XmNforeground, (XtArgVal) resource.background,
187 xl.list_winID = XtWindow( wgeStaT_disp[i] ) ;
194 XtVaSetValues( wgeStaT_list[i],
195 XmNbackground, (XtArgVal) resource.background,
196 XmNforeground, (XtArgVal) resource.foreground,
202 ListSetGlyphImage( i )
207 dl_glyph[i].disp_winID = XtWindow(wgeStaT_disp[i]);
208 code = noToCode(ptnSqToNo(sq_disp[i]));
209 if (codeCheck(code)) {
210 XClearWindow(xl.display, dl_glyph[i].disp_winID);
213 if (code == edg.code && xl.dispImage != NULL) {
214 XPutImage(xl.display, dl_glyph[i].disp_winID, xl.borderGC,
215 xl.dispImage, 0,0,0,0, edg.width, edg.height );
217 if (dl_glyph[i].dispImage)
218 XFree((char *)dl_glyph[i].dispImage);
219 if (ptnGet(code, dl_glyph[i].ptn))
221 dl_glyph[i].dispImage = XCreateImage( xl.display,
222 DefaultVisual(xl.display, DefaultScreen(xl.display)), 1,
223 XYBitmap, 0, dl_glyph[i].ptn, edg.width, edg.height, 8, 0);
224 dl_glyph[i].dispImage->bitmap_bit_order = MSBFirst;
225 dl_glyph[i].dispImage->byte_order = MSBFirst;
227 XPutImage(xl.display, dl_glyph[i].disp_winID, xl.borderGC,
228 dl_glyph[i].dispImage, 0,0,0,0, edg.width, edg.height);
234 EHStaT_disp( widget, i )
236 int i; /* widget that have some ivent */
238 ListSetGlyphImage( i );
242 ** contents : create the icon
243 ** ===================================================================
248 ** contents : set callback functions for UDC editor window
249 ** ===================================================================
252 static void _create_editptn_after();
254 static Widget FooterMessage;
255 static Widget codeLabel;
257 static menuButtonItems menu_btn[] = {
263 static MButton MenuBTN = MBUTTONS( menu_btn );
265 static ButtonItems file_btn[] = {
266 BTNARGS( OpenCB, NULL, 'O', True, False),
267 BTNARGS( CBeOblB_aAdd, NULL, 'S', True, False),
268 BTNARGS( NULL, NULL, NULL, NULL, NULL),
269 BTNARGS( CBeOblB_aEnd, NULL, 'E', True, False),
271 static Button FileBTN = BUTTONS( file_btn );
273 static ButtonItems edit_btn[] = {
274 BTNARGS( CBeOblB_rCmd, PROC_CLS, 'C', True, False),
275 BTNARGS( CBeOblB_rCmd, PROC_SET, 'S', True, False),
276 BTNARGS( CBeOblB_rCmd, PROC_REV, 'R', True, False),
277 BTNARGS( CBeOblB_rCmdp, PROC_CUT, 'U', True, False),
278 BTNARGS( CBeOblB_rCmdp, PROC_CPY, 'O', True, False),
279 BTNARGS( CBeOblB_rCmdp, PROC_PASTE,'P', True, False),
280 BTNARGS( CBeOblB_rCmd, PROC_ROLL, 'A', True, False),
281 BTNARGS( CBeOblB_rCmd, PROC_SYMV, 'V', True, False),
282 BTNARGS( CBeOblB_rCmd, PROC_SYMH, 'H', True, False),
283 BTNARGS( CBeOblB_rCan, NULL, 'N', True, False),
285 static Button EditBTN = BUTTONS( edit_btn );
287 static ButtonItems char_btn[] = {
288 BTNARGS( MngPtnCB, NULL, 'A', True, False ),
289 BTNARGS( CpyPtnCB, NULL, 'C', True, False ),
291 static Button CharBTN = BUTTONS( char_btn );
293 static ButtonItems info_btn[] = {
294 BTNARGS( XlfdCB, NULL, 'X', True, False ),
295 BTNARGS( CodeAreaCB, NULL, 'C', True, False ),
297 static Button InfoBTN = BUTTONS( info_btn );
299 static ExclusiveItems draw_ex[] = {
300 EXARGS( PROC_POINT, "pencil", True, CBeRecB_obj, True ),
301 EXARGS( PROC_LINE, "line", True, CBeRecB_obj, False ),
302 EXARGS( PROC_RECT, "rectangle", True, CBeRecB_obj, False ),
303 EXARGS( PROC_CIRCLE, "circle", True, CBeRecB_obj, False ),
304 EXARGS( PROC_ERASE, "erase", True, CBeRecB_obj, False ),
305 EXARGS( PROC_SELECT, "select", True, CBeRecB_obj, False ),
307 static Exclusive DrawEX = EXCLUSIVE( draw_ex );
312 XtSetSensitive(EditBTN.w[0], False);
313 XtSetSensitive(EditBTN.w[1], False);
314 XtSetSensitive(EditBTN.w[2], False);
315 XtSetSensitive(EditBTN.w[3], False);
316 XtSetSensitive(EditBTN.w[4], False);
317 XtSetSensitive(EditBTN.w[5], False);
318 XtSetSensitive(EditBTN.w[6], False);
319 XtSetSensitive(EditBTN.w[7], False);
320 XtSetSensitive(EditBTN.w[8], False);
321 XtSetSensitive(EditBTN.w[9], False);
327 XtSetSensitive(EditBTN.w[0], True);
328 XtSetSensitive(EditBTN.w[1], True);
329 XtSetSensitive(EditBTN.w[2], True);
330 XtSetSensitive(EditBTN.w[3], True);
331 XtSetSensitive(EditBTN.w[4], True);
332 XtSetSensitive(EditBTN.w[6], True);
333 XtSetSensitive(EditBTN.w[7], True);
334 XtSetSensitive(EditBTN.w[8], True);
340 XtSetSensitive(EditBTN.w[0], False);
341 XtSetSensitive(EditBTN.w[1], False);
342 XtSetSensitive(EditBTN.w[2], False);
343 XtSetSensitive(EditBTN.w[3], False);
344 XtSetSensitive(EditBTN.w[4], False);
345 XtSetSensitive(EditBTN.w[6], False);
346 XtSetSensitive(EditBTN.w[7], False);
347 XtSetSensitive(EditBTN.w[8], False);
353 XtSetSensitive(EditBTN.w[5], True);
359 XtSetSensitive(EditBTN.w[9], True);
365 XtSetSensitive(EditBTN.w[9], False);
369 ** contents : create the UDC editor window
370 ** --------------------------------
378 editPtnW = CreateEditPtn(owner);
379 _create_editptn_after();
381 XtPopup(editPtnW, XtGrabNone);
390 Widget baseForm, pop, font_menu, edit_menu, char_menu, info_menu;
391 Widget listBase, listFrame, rc, editFrame, figure_w;
392 Widget imageFrame, imageForm, editPane, image;
393 extern Widget CreateFrame();
394 extern Widget CreatePixButton();
399 SetItemLabel(&MenuBTN, 0, resource.l_font);
400 SetItemLabel(&MenuBTN, 1, resource.l_edit);
401 SetItemLabel(&MenuBTN, 2, resource.l_manage);
402 SetItemLabel(&MenuBTN, 3, resource.l_info);
404 CreateMenuBarAndFooterMessageForm( owner, "dtudcfonted",
405 &MenuBTN, XtNumber(menu_btn), &pop, &FooterMessage );
409 AddDeleteProc(pop, CBeOblB_aEnd);
411 font_menu = GetMenuWidget( &MenuBTN, 0 );
412 edit_menu = GetMenuWidget( &MenuBTN, 1 );
413 char_menu = GetMenuWidget( &MenuBTN, 2 );
414 info_menu = GetMenuWidget( &MenuBTN, 3 );
416 SetItemLabel(&FileBTN, 0, resource.l_open_w);
417 SetItemLabel(&FileBTN, 1, resource.l_save);
418 SetItemLabel(&FileBTN, 3, resource.l_exit);
420 SetItemLabel(&EditBTN, 0, resource.l_clear);
421 SetItemLabel(&EditBTN, 1, resource.l_set);
422 SetItemLabel(&EditBTN, 2, resource.l_reverse);
423 SetItemLabel(&EditBTN, 3, resource.l_cut);
424 SetItemLabel(&EditBTN, 4, resource.l_Copy);
425 SetItemLabel(&EditBTN, 5, resource.l_paste);
426 SetItemLabel(&EditBTN, 6, resource.l_roll);
427 SetItemLabel(&EditBTN, 7, resource.l_updown_roll);
428 SetItemLabel(&EditBTN, 8, resource.l_leftright_roll);
429 SetItemLabel(&EditBTN, 9, resource.l_undo);
431 SetItemLabel(&CharBTN, 0, resource.l_manage_w);
432 SetItemLabel(&CharBTN, 1, resource.l_copy_w);
434 SetItemLabel(&InfoBTN, 0, resource.l_xlfd);
435 SetItemLabel(&InfoBTN, 1, resource.l_codearea);
437 CreateMenuButtons( font_menu, &FileBTN, XtNumber(file_btn));
438 CreateMenuButtons( edit_menu, &EditBTN, XtNumber(edit_btn));
440 CreateMenuButtons( char_menu, &CharBTN, XtNumber(char_btn));
441 CreateMenuButtons( info_menu, &InfoBTN, XtNumber(info_btn));
443 /* create "Character list" */
446 CreateFrame( baseForm, "listFrame", XmSHADOW_IN, 2);
447 AddTopAttachForm(listFrame, resource.ed_wge_topoff);
448 AddLeftAttachForm(listFrame, resource.ed_wge_lftoff);
449 AddBottomAttachForm(listFrame, resource.ed_wge_btmoff);
452 CreateRowColumn( listFrame, "listFrame", L_VERTICAL, 4, 2, 2);
454 for( i=0 ; i < edlist.nlist ; i++ ) {
455 wgeStaT_form[i] = CreateForm( listBase, "listform" );
457 CreateLabel( wgeStaT_form[i], "label", "0000" );
458 wgeStaT_disp[i] = CreateDrawingArea( wgeStaT_form[i], "image",
459 edg.width, edg.height, EHStaT_disp, i ) ;
460 AddLeftAttachWidget( wgeStaT_disp[i], wgeStaT_list[i], 0 ) ;
461 XtAddEventHandler( wgeStaT_list[i],
462 ButtonPressMask|ButtonReleaseMask,
463 False, EHeStaT_list, (XtPointer)i );
464 XtAddEventHandler( wgeStaT_disp[i],
465 ButtonPressMask|ButtonReleaseMask,
466 False, EHeStaT_list, (XtPointer)i );
469 XtVaGetValues(wgeStaT_disp[i],
470 XmNheight, &(edlist.elem_h),
471 XmNwidth, &(edlist.elem_w), NULL);
473 edlist.back = resource.pane_background;
474 edlist.border = resource.pane_foreground;
476 dn.elem_h = edlist.elem_h;
477 dn.elem_w = edlist.elem_w;
481 edpane.pix_w = edpane.width / edg.width;
482 edpane.pix_h = edpane.height / edg.height;
483 if(edpane.pix_w > edpane.pix_h)
484 edpane.pix_w = edpane.pix_h;
486 edpane.pix_h = edpane.pix_w;
488 edpane.pix_w = ( edpane.pix_w < 8 ) ? 8 : edpane.pix_w;
489 edpane.pix_h = ( edpane.pix_h < 8 ) ? 8 : edpane.pix_h;
492 edpane.width = edpane.pix_w * edg.width - 1;
493 edpane.height = edpane.pix_h * edg.height - 1;
495 edlist.nlist = (edpane.height +2)/(int)(edlist.elem_h +8);
497 (edlist.nlist<EDLIST_MAX)?edlist.nlist:EDLIST_MAX;
501 XtManageChildren( wgeStaT_form, edlist.nlist );
502 for( i=0 ; i < edlist.nlist ; i++ ) {
503 XtManageChild( wgeStaT_list[i] );
504 XtManageChild( wgeStaT_disp[i] );
507 /* create the scroll bar for Charcter list */
508 XtVaGetValues( listBase, XmNheight, &(edlist.list_h), NULL);
510 if (( slimax = efctPtnNum()) < edlist.nlist)
511 slimax = edlist.nlist;
512 wgeScro = CreateScrollBar( baseForm, "scrollBar", (edpane.height+2),
513 edlist.nlist, 0, slimax, CBeScro);
514 AddLeftAttachWidget( wgeScro, listFrame, 4 );
515 AddTopAttachForm( wgeScro, resource.ed_wge_topoff );
516 AddBottomAttachForm( wgeScro, resource.ed_wge_btmoff );
519 CreateForm( baseForm, "rc" );
520 AddTopAttachForm( rc, resource.ed_wge_topoff );
521 AddRightAttachForm( rc, resource.ed_wge_rghoff );
522 AddBottomAttachForm( rc, resource.ed_wge_btmoff );
525 CreateFrame( baseForm, "editFrame", XmSHADOW_IN, 2);
526 AddTopAttachForm(editFrame, resource.ed_wge_topoff);
527 AddLeftAttachWidget(editFrame, wgeScro, 4);
528 AddRightAttachWidget(editFrame, rc, 10);
531 CreatePixButton(rc, "Draw", &DrawEX);
532 AddTopAttachForm(figure_w, 0);
533 AddLeftAttachForm(figure_w, 0);
534 AddRightAttachForm(figure_w, 0);
537 CreateCaptionFrame( rc, "Frame", " ", XmSHADOW_IN, 1);
538 AddTopAttachWidget(XtParent(imageFrame), figure_w, 4);
539 AddLeftAttachForm(XtParent(imageFrame), 0);
540 AddRightAttachForm(XtParent(imageFrame), 0);
541 AddBottomAttachForm(XtParent(imageFrame), 0);
544 CreateForm( imageFrame, "separator" );
546 /* create the Editing pane */
547 wgeBulB_edit = editPane =
548 CreateDrawingArea( editFrame, "editPane",
549 edpane.width, edpane.height, EHeBulB_eExp, 0);
551 XtAddEventHandler( editPane,
552 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
553 False, EHeBulB_eMEv, NULL );
554 AddTopAttachForm( editPane, 2 );
555 AddLeftAttachForm( editPane, 2 );
557 /* create character image */
558 codeLabel = CreateLabel( imageForm, "codeLabel", "0000" );
559 AddTopAttachForm( codeLabel, 3 );
560 AddLeftAttachForm( codeLabel, 3 );
562 wgeBulB_disp = image = CreateDrawingArea( imageForm, "image", edg.width,
563 edg.height, EHeBulB_dExp, 0);
564 AddTopAttachWidget( image, codeLabel, 3 );
565 AddLeftAttachForm( image, 6 );
567 XtRealizeWidget( editPopW );
585 sprintf( str, "%4x:", code );
587 SetLabelString(codeLabel, str);
593 _create_editptn_after()
596 static char dashPtn[] = {1,1}; /* Editing pane's border pattern */
597 extern void chgEdList();
601 * set X-library interface
603 xl.display = XtDisplayOfObject( editPopW );
604 xl.root_winID = RootWindow( xl.display, DefaultScreen(xl.display) );
605 xl.edit_winID = XtWindow( wgeBulB_edit );
606 xl.disp_winID = XtWindow( wgeBulB_disp );
607 xl.list_winID = XtWindow( wgeStaT_disp[0] );
610 * Graphic Context ( Pixel clear )
612 xl.backGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
613 XSetForeground( xl.display, xl.backGC, edpane.back );
614 XSetBackground( xl.display, xl.backGC, edpane.border );
617 * Graphic Context ( Pixel set )
619 xl.borderGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
620 XSetForeground( xl.display, xl.borderGC, edpane.border );
621 XSetBackground( xl.display, xl.borderGC, edpane.back );
624 * Graphic Context ( rubber band )
626 xl.rubGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
627 XSetForeground(xl.display, xl.rubGC, edpane.border ^ edpane.back);
629 XSetFunction ( xl.display, xl.rubGC, GXxor );
632 * Graphc Context ( lattice of Editing pane )
634 xl.dashGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
635 XSetForeground( xl.display, xl.dashGC, edpane.border );
636 XSetBackground( xl.display, xl.dashGC, edpane.back );
638 XSetLineAttributes( xl.display, xl.dashGC, 0,
639 LineDoubleDash, CapButt, JoinMiter );
640 XSetDashes ( xl.display, xl.dashGC, 0, dashPtn, 2 );
643 * display Editing pane
645 xl.dispImage = XCreateImage( xl.display,
646 DefaultVisual( xl.display, DefaultScreen(xl.display) ),
647 1, XYBitmap, 0, edg.ptn, edg.width, edg.height, 8, 0 );
648 xl.dispImage->bitmap_bit_order = MSBFirst;
649 xl.dispImage->byte_order = MSBFirst;
655 edpane.obj = PROC_POINT;
656 em.proc = PROC_POINT;
658 if(efctPtnNum() > 0){
660 SetCodeString(edg.code);
665 chgEdList( 0, slctloc, ON );
673 static Boolean nomsg = False;
675 if (! str || ! *str){
686 SetFooterString(FooterMessage, str);