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 /* 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"
42 void CBeOblB_aEnd(Widget widget, caddr_t clientData, caddr_t callData);
43 void EHeStaT_list(Widget widget, int select, XEvent *e);
44 void CBeScro(Widget widget, caddr_t clientData, caddr_t callData);
45 void EHeBulB_eMEv(Widget widget, caddr_t clientData, XEvent *e);
46 void EHeBulB_eExp(Widget widget, caddr_t clientData, XEvent *e);
47 void EHeBulB_dExp(Widget widget, caddr_t clientData);
48 static void EHStaT_disp(Widget widget, int i);
50 extern Resource resource;
52 extern int efctPtnNum(void);
53 extern char *char_set(char *str);
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(Widget owner);
81 void OpenCB(Widget w, XtPointer client_data, XtPointer call_data);
84 void CBeRecB_obj(Widget widget, int obj, XmToggleButtonCallbackStruct *call);
85 void CBeOblB_aAdd(void);
86 void CBeOblB_rCmd(Widget widget, int proc, caddr_t callData);
87 void CBeOblB_rCmdp(Widget widget, int proc, caddr_t callData);
88 void CBeOblB_rCan(Widget widget, caddr_t clientData, caddr_t callData);
92 ** contents : manage the codes list
93 ** ===================================================================
103 XmString cs, cs1, cs2;
105 sprintf(mess, "%s : %s", resource.file_name, fullpath);
106 cs = XmStringCreateLocalized(mess);
107 cs1 = XmStringSeparatorCreate();
108 cs2 = XmStringConcat(cs, cs1);
111 sprintf(mess, "%s : %s", resource.xlfd_name, fullFontData.xlfdname);
112 cs1 = XmStringCreateLocalized(mess);
113 cs = XmStringConcat(cs2, cs1);
116 XtSetArg (args[n], XmNtitle, resource.l_xlfd_title); n++;
117 XtSetArg (args[n], XmNmessageString, cs); n++;
118 XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
119 dialog = XmCreateInformationDialog (toplevel, "Xlfd_name", args, n);
120 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
121 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
122 XtManageChild (dialog);
136 sprintf(mess, "%s : ", resource.codearea);
137 switch (fullFontData.cd_set) {
139 strcat(mess, "CS0:");
142 strcat(mess, "CS1:");
145 strcat(mess, "CS2:");
148 strcat(mess, "CS3:");
152 for (n=0; CodeArea[n].start != -1; n++) {
153 sprintf(tmp, " %X - %X ", CodeArea[n].start, CodeArea[n].end);
156 cs = XmStringCreateLocalized(mess);
158 XtSetArg (args[n], XmNtitle, resource.l_codearea_title); n++;
159 XtSetArg (args[n], XmNmessageString, cs); n++;
160 XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
161 XtSetArg (args[n], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON); n++;
162 dialog = XmCreateInformationDialog (toplevel, "UDCarea", args, n);
163 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
164 XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
165 XtManageChild (dialog);
170 ListSetLabelStr(int i, String str)
172 SetLabelString( wgeStaT_list[i], str );
176 ListSelectItem(int i)
178 XtVaSetValues( wgeStaT_list[i],
179 XmNbackground, (XtArgVal) resource.foreground,
180 XmNforeground, (XtArgVal) resource.background,
182 xl.list_winID = XtWindow( wgeStaT_disp[i] ) ;
186 ListUnselectItem(int i)
188 XtVaSetValues( wgeStaT_list[i],
189 XmNbackground, (XtArgVal) resource.background,
190 XmNforeground, (XtArgVal) resource.foreground,
196 ListSetGlyphImage( int i )
200 dl_glyph[i].disp_winID = XtWindow(wgeStaT_disp[i]);
201 code = noToCode(ptnSqToNo(sq_disp[i]));
202 if (codeCheck(code)) {
203 XClearWindow(xl.display, dl_glyph[i].disp_winID);
206 if (code == edg.code && xl.dispImage != NULL) {
207 XPutImage(xl.display, dl_glyph[i].disp_winID, xl.borderGC,
208 xl.dispImage, 0,0,0,0, edg.width, edg.height );
210 if (dl_glyph[i].dispImage)
211 XFree((char *)dl_glyph[i].dispImage);
212 if (ptnGet(code, dl_glyph[i].ptn))
214 dl_glyph[i].dispImage = XCreateImage( xl.display,
215 DefaultVisual(xl.display, DefaultScreen(xl.display)), 1,
216 XYBitmap, 0, dl_glyph[i].ptn, edg.width, edg.height, 8, 0);
217 dl_glyph[i].dispImage->bitmap_bit_order = MSBFirst;
218 dl_glyph[i].dispImage->byte_order = MSBFirst;
220 XPutImage(xl.display, dl_glyph[i].disp_winID, xl.borderGC,
221 dl_glyph[i].dispImage, 0,0,0,0, edg.width, edg.height);
227 EHStaT_disp( Widget widget, int i /* widget that have some ivent */ )
229 ListSetGlyphImage( i );
233 ** contents : create the icon
234 ** ===================================================================
239 ** contents : set callback functions for UDC editor window
240 ** ===================================================================
243 static void _create_editptn_after();
245 static Widget FooterMessage;
246 static Widget codeLabel;
248 static menuButtonItems menu_btn[] = {
254 static MButton MenuBTN = MBUTTONS( menu_btn );
256 static ButtonItems file_btn[] = {
257 BTNARGS( OpenCB, NULL, 'O', True, False),
258 BTNARGS( CBeOblB_aAdd, NULL, 'S', True, False),
259 BTNARGS( NULL, NULL, NULL, NULL, NULL),
260 BTNARGS( CBeOblB_aEnd, NULL, 'E', True, False),
262 static Button FileBTN = BUTTONS( file_btn );
264 static ButtonItems edit_btn[] = {
265 BTNARGS( CBeOblB_rCmd, PROC_CLS, 'C', True, False),
266 BTNARGS( CBeOblB_rCmd, PROC_SET, 'S', True, False),
267 BTNARGS( CBeOblB_rCmd, PROC_REV, 'R', True, False),
268 BTNARGS( CBeOblB_rCmdp, PROC_CUT, 'U', True, False),
269 BTNARGS( CBeOblB_rCmdp, PROC_CPY, 'O', True, False),
270 BTNARGS( CBeOblB_rCmdp, PROC_PASTE,'P', True, False),
271 BTNARGS( CBeOblB_rCmd, PROC_ROLL, 'A', True, False),
272 BTNARGS( CBeOblB_rCmd, PROC_SYMV, 'V', True, False),
273 BTNARGS( CBeOblB_rCmd, PROC_SYMH, 'H', True, False),
274 BTNARGS( CBeOblB_rCan, NULL, 'N', True, False),
276 static Button EditBTN = BUTTONS( edit_btn );
278 static ButtonItems char_btn[] = {
279 BTNARGS( MngPtnCB, NULL, 'A', True, False ),
280 BTNARGS( CpyPtnCB, NULL, 'C', True, False ),
282 static Button CharBTN = BUTTONS( char_btn );
284 static ButtonItems info_btn[] = {
285 BTNARGS( XlfdCB, NULL, 'X', True, False ),
286 BTNARGS( CodeAreaCB, NULL, 'C', True, False ),
288 static Button InfoBTN = BUTTONS( info_btn );
290 static ExclusiveItems draw_ex[] = {
291 EXARGS( PROC_POINT, "pencil", True, CBeRecB_obj, True ),
292 EXARGS( PROC_LINE, "line", True, CBeRecB_obj, False ),
293 EXARGS( PROC_RECT, "rectangle", True, CBeRecB_obj, False ),
294 EXARGS( PROC_CIRCLE, "circle", True, CBeRecB_obj, False ),
295 EXARGS( PROC_ERASE, "erase", True, CBeRecB_obj, False ),
296 EXARGS( PROC_SELECT, "select", True, CBeRecB_obj, False ),
298 static Exclusive DrawEX = EXCLUSIVE( draw_ex );
303 XtSetSensitive(EditBTN.w[0], False);
304 XtSetSensitive(EditBTN.w[1], False);
305 XtSetSensitive(EditBTN.w[2], False);
306 XtSetSensitive(EditBTN.w[3], False);
307 XtSetSensitive(EditBTN.w[4], False);
308 XtSetSensitive(EditBTN.w[5], False);
309 XtSetSensitive(EditBTN.w[6], False);
310 XtSetSensitive(EditBTN.w[7], False);
311 XtSetSensitive(EditBTN.w[8], False);
312 XtSetSensitive(EditBTN.w[9], False);
318 XtSetSensitive(EditBTN.w[0], True);
319 XtSetSensitive(EditBTN.w[1], True);
320 XtSetSensitive(EditBTN.w[2], True);
321 XtSetSensitive(EditBTN.w[3], True);
322 XtSetSensitive(EditBTN.w[4], True);
323 XtSetSensitive(EditBTN.w[6], True);
324 XtSetSensitive(EditBTN.w[7], True);
325 XtSetSensitive(EditBTN.w[8], True);
331 XtSetSensitive(EditBTN.w[0], False);
332 XtSetSensitive(EditBTN.w[1], False);
333 XtSetSensitive(EditBTN.w[2], False);
334 XtSetSensitive(EditBTN.w[3], False);
335 XtSetSensitive(EditBTN.w[4], False);
336 XtSetSensitive(EditBTN.w[6], False);
337 XtSetSensitive(EditBTN.w[7], False);
338 XtSetSensitive(EditBTN.w[8], False);
344 XtSetSensitive(EditBTN.w[5], True);
350 XtSetSensitive(EditBTN.w[9], True);
356 XtSetSensitive(EditBTN.w[9], False);
360 ** contents : create the UDC editor window
361 ** --------------------------------
365 PopupEditPtn(Widget owner)
368 editPtnW = CreateEditPtn(owner);
369 _create_editptn_after();
371 XtPopup(editPtnW, XtGrabNone);
375 CreateEditPtn(Widget owner)
379 Widget baseForm, pop, font_menu, edit_menu, char_menu, info_menu;
380 Widget listBase, listFrame, rc, editFrame, figure_w;
381 Widget imageFrame, imageForm, editPane, image;
382 extern Widget CreateFrame();
383 extern Widget CreatePixButton();
388 SetItemLabel(&MenuBTN, 0, resource.l_font);
389 SetItemLabel(&MenuBTN, 1, resource.l_edit);
390 SetItemLabel(&MenuBTN, 2, resource.l_manage);
391 SetItemLabel(&MenuBTN, 3, resource.l_info);
393 CreateMenuBarAndFooterMessageForm( owner, "dtudcfonted",
394 &MenuBTN, XtNumber(menu_btn), &pop, &FooterMessage );
398 AddDeleteProc(pop, CBeOblB_aEnd);
400 font_menu = GetMenuWidget( &MenuBTN, 0 );
401 edit_menu = GetMenuWidget( &MenuBTN, 1 );
402 char_menu = GetMenuWidget( &MenuBTN, 2 );
403 info_menu = GetMenuWidget( &MenuBTN, 3 );
405 SetItemLabel(&FileBTN, 0, resource.l_open_w);
406 SetItemLabel(&FileBTN, 1, resource.l_save);
407 SetItemLabel(&FileBTN, 3, resource.l_exit);
409 SetItemLabel(&EditBTN, 0, resource.l_clear);
410 SetItemLabel(&EditBTN, 1, resource.l_set);
411 SetItemLabel(&EditBTN, 2, resource.l_reverse);
412 SetItemLabel(&EditBTN, 3, resource.l_cut);
413 SetItemLabel(&EditBTN, 4, resource.l_Copy);
414 SetItemLabel(&EditBTN, 5, resource.l_paste);
415 SetItemLabel(&EditBTN, 6, resource.l_roll);
416 SetItemLabel(&EditBTN, 7, resource.l_updown_roll);
417 SetItemLabel(&EditBTN, 8, resource.l_leftright_roll);
418 SetItemLabel(&EditBTN, 9, resource.l_undo);
420 SetItemLabel(&CharBTN, 0, resource.l_manage_w);
421 SetItemLabel(&CharBTN, 1, resource.l_copy_w);
423 SetItemLabel(&InfoBTN, 0, resource.l_xlfd);
424 SetItemLabel(&InfoBTN, 1, resource.l_codearea);
426 CreateMenuButtons( font_menu, &FileBTN, XtNumber(file_btn));
427 CreateMenuButtons( edit_menu, &EditBTN, XtNumber(edit_btn));
429 CreateMenuButtons( char_menu, &CharBTN, XtNumber(char_btn));
430 CreateMenuButtons( info_menu, &InfoBTN, XtNumber(info_btn));
432 /* create "Character list" */
435 CreateFrame( baseForm, "listFrame", XmSHADOW_IN, 2);
436 AddTopAttachForm(listFrame, resource.ed_wge_topoff);
437 AddLeftAttachForm(listFrame, resource.ed_wge_lftoff);
438 AddBottomAttachForm(listFrame, resource.ed_wge_btmoff);
441 CreateRowColumn( listFrame, "listFrame", L_VERTICAL, 4, 2, 2);
443 for( i=0 ; i < edlist.nlist ; i++ ) {
444 wgeStaT_form[i] = CreateForm( listBase, "listform" );
446 CreateLabel( wgeStaT_form[i], "label", "0000" );
447 wgeStaT_disp[i] = CreateDrawingArea( wgeStaT_form[i], "image",
448 edg.width, edg.height, EHStaT_disp, i ) ;
449 AddLeftAttachWidget( wgeStaT_disp[i], wgeStaT_list[i], 0 ) ;
450 XtAddEventHandler( wgeStaT_list[i],
451 ButtonPressMask|ButtonReleaseMask,
452 False, EHeStaT_list, (XtPointer) (intptr_t) i );
453 XtAddEventHandler( wgeStaT_disp[i],
454 ButtonPressMask|ButtonReleaseMask,
455 False, EHeStaT_list, (XtPointer) (intptr_t) i );
458 XtVaGetValues(wgeStaT_disp[i],
459 XmNheight, &(edlist.elem_h),
460 XmNwidth, &(edlist.elem_w), NULL);
462 edlist.back = resource.pane_background;
463 edlist.border = resource.pane_foreground;
465 dn.elem_h = edlist.elem_h;
466 dn.elem_w = edlist.elem_w;
470 edpane.pix_w = edpane.width / edg.width;
471 edpane.pix_h = edpane.height / edg.height;
472 if(edpane.pix_w > edpane.pix_h)
473 edpane.pix_w = edpane.pix_h;
475 edpane.pix_h = edpane.pix_w;
477 edpane.pix_w = ( edpane.pix_w < 8 ) ? 8 : edpane.pix_w;
478 edpane.pix_h = ( edpane.pix_h < 8 ) ? 8 : edpane.pix_h;
481 edpane.width = edpane.pix_w * edg.width - 1;
482 edpane.height = edpane.pix_h * edg.height - 1;
484 edlist.nlist = (edpane.height +2)/(int)(edlist.elem_h +8);
486 (edlist.nlist<EDLIST_MAX)?edlist.nlist:EDLIST_MAX;
490 XtManageChildren( wgeStaT_form, edlist.nlist );
491 for( i=0 ; i < edlist.nlist ; i++ ) {
492 XtManageChild( wgeStaT_list[i] );
493 XtManageChild( wgeStaT_disp[i] );
496 /* create the scroll bar for Charcter list */
497 XtVaGetValues( listBase, XmNheight, &(edlist.list_h), NULL);
499 if (( slimax = efctPtnNum()) < edlist.nlist)
500 slimax = edlist.nlist;
501 wgeScro = CreateScrollBar( baseForm, "scrollBar", (edpane.height+2),
502 edlist.nlist, 0, slimax, CBeScro);
503 AddLeftAttachWidget( wgeScro, listFrame, 4 );
504 AddTopAttachForm( wgeScro, resource.ed_wge_topoff );
505 AddBottomAttachForm( wgeScro, resource.ed_wge_btmoff );
508 CreateForm( baseForm, "rc" );
509 AddTopAttachForm( rc, resource.ed_wge_topoff );
510 AddRightAttachForm( rc, resource.ed_wge_rghoff );
511 AddBottomAttachForm( rc, resource.ed_wge_btmoff );
514 CreateFrame( baseForm, "editFrame", XmSHADOW_IN, 2);
515 AddTopAttachForm(editFrame, resource.ed_wge_topoff);
516 AddLeftAttachWidget(editFrame, wgeScro, 4);
517 AddRightAttachWidget(editFrame, rc, 10);
520 CreatePixButton(rc, "Draw", &DrawEX);
521 AddTopAttachForm(figure_w, 0);
522 AddLeftAttachForm(figure_w, 0);
523 AddRightAttachForm(figure_w, 0);
526 CreateCaptionFrame( rc, "Frame", " ", XmSHADOW_IN, 1);
527 AddTopAttachWidget(XtParent(imageFrame), figure_w, 4);
528 AddLeftAttachForm(XtParent(imageFrame), 0);
529 AddRightAttachForm(XtParent(imageFrame), 0);
530 AddBottomAttachForm(XtParent(imageFrame), 0);
533 CreateForm( imageFrame, "separator" );
535 /* create the Editing pane */
536 wgeBulB_edit = editPane =
537 CreateDrawingArea( editFrame, "editPane",
538 edpane.width, edpane.height, EHeBulB_eExp, 0);
540 XtAddEventHandler( editPane,
541 ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
542 False, EHeBulB_eMEv, NULL );
543 AddTopAttachForm( editPane, 2 );
544 AddLeftAttachForm( editPane, 2 );
546 /* create character image */
547 codeLabel = CreateLabel( imageForm, "codeLabel", "0000" );
548 AddTopAttachForm( codeLabel, 3 );
549 AddLeftAttachForm( codeLabel, 3 );
551 wgeBulB_disp = image = CreateDrawingArea( imageForm, "image", edg.width,
552 edg.height, EHeBulB_dExp, 0);
553 AddTopAttachWidget( image, codeLabel, 3 );
554 AddLeftAttachForm( image, 6 );
556 XtRealizeWidget( editPopW );
565 SetCodeString(int code)
573 sprintf( str, "%4x:", code );
575 SetLabelString(codeLabel, str);
581 _create_editptn_after(void)
584 static char dashPtn[] = {1,1}; /* Editing pane's border pattern */
585 extern void chgEdList();
589 * set X-library interface
591 xl.display = XtDisplayOfObject( editPopW );
592 xl.root_winID = RootWindow( xl.display, DefaultScreen(xl.display) );
593 xl.edit_winID = XtWindow( wgeBulB_edit );
594 xl.disp_winID = XtWindow( wgeBulB_disp );
595 xl.list_winID = XtWindow( wgeStaT_disp[0] );
598 * Graphic Context ( Pixel clear )
600 xl.backGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
601 XSetForeground( xl.display, xl.backGC, edpane.back );
602 XSetBackground( xl.display, xl.backGC, edpane.border );
605 * Graphic Context ( Pixel set )
607 xl.borderGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
608 XSetForeground( xl.display, xl.borderGC, edpane.border );
609 XSetBackground( xl.display, xl.borderGC, edpane.back );
612 * Graphic Context ( rubber band )
614 xl.rubGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
615 XSetForeground(xl.display, xl.rubGC, edpane.border ^ edpane.back);
617 XSetFunction ( xl.display, xl.rubGC, GXxor );
620 * Graphc Context ( lattice of Editing pane )
622 xl.dashGC = XCreateGC( xl.display, xl.root_winID, 0, 0 );
623 XSetForeground( xl.display, xl.dashGC, edpane.border );
624 XSetBackground( xl.display, xl.dashGC, edpane.back );
626 XSetLineAttributes( xl.display, xl.dashGC, 0,
627 LineDoubleDash, CapButt, JoinMiter );
628 XSetDashes ( xl.display, xl.dashGC, 0, dashPtn, 2 );
631 * display Editing pane
633 xl.dispImage = XCreateImage( xl.display,
634 DefaultVisual( xl.display, DefaultScreen(xl.display) ),
635 1, XYBitmap, 0, edg.ptn, edg.width, edg.height, 8, 0 );
636 xl.dispImage->bitmap_bit_order = MSBFirst;
637 xl.dispImage->byte_order = MSBFirst;
643 edpane.obj = PROC_POINT;
644 em.proc = PROC_POINT;
646 if(efctPtnNum() > 0){
648 SetCodeString(edg.code);
653 chgEdList( 0, slctloc, ON );
658 UpdateMessage(String str)
660 static Boolean nomsg = False;
662 if (! str || ! *str){
673 SetFooterString(FooterMessage, str);