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 /* code.c 1.37 - Fujitsu source for CDEnext 96/10/30 13:13:47 */
24 /* $XConsortium: code.c /main/6 1996/11/08 01:57:21 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
33 #include <X11/keysym.h>
37 #include <Xm/RowColumn.h>
38 #include <Xm/SeparatoG.h>
43 #include <Xm/MwmUtil.h>
44 #include <X11/Intrinsic.h>
46 #include "xoakufont.h"
50 static Display *display=NULL;
52 static Boolean open_font;
53 static Widget toggle[NUM];
56 static Widget set_widget;
57 static Widget code_w=0;
58 static int font_w, font_h;
59 static unsigned long fg, bg;
60 static unsigned char *ptn, *clr;
62 static int len, code1;
63 static char *FontName=NULL;
66 extern FalFontID font_id;
68 extern Resource resource;
74 FalFontData font_data;
75 static FalFontDataList *copylist;
76 extern FalFontData fullFontData;
78 if(strcmp(FontName, fullFontData.xlfdname) == 0) {
82 mask = FAL_FONT_MASK_XLFDNAME | FAL_FONT_MASK_DEFINED |
83 FAL_FONT_MASK_UNDEFINED;
84 font_data.xlfdname = FontName;
86 mask |= FAL_FONT_MASK_GLYPH_INDEX;
89 fid = FalOpenSysFont(&font_data, mask, ©list);
102 DrawCode(w, low_code)
109 GC gc = XDefaultGC(display, 0);
111 hi_code = (code1 & 0xff) << 8;
112 image.width = font_w;
113 image.height = font_h;
115 image.format = XYBitmap;
116 image.byte_order = LSBFirst;
117 image.bitmap_unit = 8;
118 image.bitmap_bit_order = MSBFirst;
119 image.bitmap_pad = 8;
121 image.bytes_per_line = (font_w - 1) / 8 + 1;
122 XSetForeground(display, gc, fg);
123 XSetBackground(display, gc, bg);
126 f = (char *)FalReadFont(fid, hi_code | low_code, font_w, font_h);
127 if(f == (char *)FAL_ERROR)
129 if( EXISTS_FLAG == 0 ) {
131 image.data = (char *)ptn;
133 image.data = (char *)clr;
135 XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
137 if (ptnGet(hi_code | low_code, ptn) == 0) {
138 image.data = (char *)ptn;
140 image.data = (char *)clr;
142 XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
147 SetPixmap(start_code)
149 int hi_code, low_code;
152 GC gc = XDefaultGC(display, 0);
154 hi_code = (start_code & 0xff) << 8;
155 image.width = font_w;
156 image.height = font_h;
158 image.format = XYBitmap;
159 image.byte_order = LSBFirst;
160 image.bitmap_unit = 8;
161 image.bitmap_bit_order = MSBFirst;
162 image.bitmap_pad = 8;
164 image.bytes_per_line = (font_w - 1) / 8 + 1;
165 XSetForeground(display, gc, fg);
166 XSetBackground(display, gc, bg);
169 for (low_code=0; low_code < NUM; low_code++) {
170 f = (char *)FalReadFont(fid, hi_code | low_code, font_w, font_h);
171 if(f == (char *)FAL_ERROR)
173 if( EXISTS_FLAG == 0 ) {
175 image.data = (char *)ptn;
177 image.data = (char *)clr;
179 XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
182 for (low_code=0; low_code < NUM; low_code++) {
183 if (ptnGet(hi_code | low_code, ptn) == 0) {
184 image.data = (char *)ptn;
186 image.data = (char *)clr;
188 XPutImage(display, XtWindow(toggle[low_code]), gc, &image, 0, 0, 6, 6, font_w, font_h);
194 Code1Call(w, start_code, data)
197 XmListCallbackStruct *data;
199 code1 = start_code + data->item_position -1;
204 Code2Call(w, code2, data)
207 XmPushButtonCallbackStruct *data;
210 sprintf(asc, "%2.2X%2.2X", code1, code2);
211 XtVaSetValues(text, XmNvalue, asc, NULL);
221 if (XmListGetSelectedPos(scroll, &list, &num)) {
223 XmListSelectPos(scroll, list[0] - 1, True);
224 XmListSetPos(scroll, list[0] - 1);
235 XtVaGetValues(scroll, XmNitemCount, &item, NULL);
236 if (XmListGetSelectedPos(scroll, &list, &num)) {
238 XmListSelectPos(scroll, list[0] + 1, True);
239 XmListSetBottomPos(scroll, list[0] + 1);
247 XtUnmapWidget(XtParent(code_w));
254 XtVaGetValues(text, XmNvalue, &asc, NULL);
255 XtVaSetValues(set_widget, XmNvalue, asc, NULL);
261 CreateItem(item, item_count, start_code)
270 extern int begin_code, last_code;
273 if (FalQueryFont(fid, &finfo) == FAL_ERROR) {
278 font_w = finfo.width;
279 font_h = finfo.height;
280 start = (finfo.top & 0xff00) >> 8;
281 end = (finfo.bottom & 0xff00) >> 8;
285 start = (begin_code & 0xff00) >> 8;
286 end = (last_code & 0xff00) >> 8;
300 for (count=0;start <= end; start++, count++) {
301 sprintf(str, "%X", start);
302 item[count] = XmStringCreateLocalized(str);
311 Widget top, base1, base2, base3, base4;
312 Widget frame, scroll, label, sep, form;
313 Widget push1, push2, push3, push4;
318 int item_count, start_code, add_c;
322 XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_CLOSE |
323 MWM_FUNC_RESIZE); n++;
324 XtSetArg(args[n], XmNmwmDecorations, MWM_DECOR_ALL); n++;
325 top = XmCreateFormDialog(w, "code", args, n);
327 base1 = XtVaCreateManagedWidget("base1", xmRowColumnWidgetClass, top,
328 XmNorientation, XmVERTICAL, NULL);
330 frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, base1,
333 base2 = XtVaCreateManagedWidget("base2", xmRowColumnWidgetClass, frame,
334 XmNorientation, XmHORIZONTAL, NULL);
336 CreateItem(item, &item_count, &start_code);
339 XtSetArg(args[n], XmNitems, item); n++;
340 XtSetArg(args[n], XmNitemCount, item_count); n++;
341 XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); n++;
342 scroll = XmCreateScrolledList(base2, "scroll", args, n);
343 XtManageChild(scroll);
344 XtAddCallback(scroll, XmNbrowseSelectionCallback,
345 (XtCallbackProc)Code1Call, (XtPointer)start_code);
346 XtAddCallback(scroll, XmNdefaultActionCallback,
347 (XtCallbackProc)Code1Call, (XtPointer)start_code);
348 XmListSelectPos(scroll, 1, False);
350 base3 = XtVaCreateManagedWidget("base3", xmRowColumnWidgetClass, base2,
351 XmNorientation, XmHORIZONTAL,
352 XmNpacking, XmPACK_COLUMN,
353 XmNradioAlwaysOne, True,
354 XmNradioBehavior , True,
358 XmNnumColumns, 9, NULL);
361 len = (font_w / 8 + 1) * font_h;
362 ptn = (unsigned char *) malloc(len);
363 clr = (unsigned char *) malloc(len);
365 XtVaGetValues(w, XmNforeground, &fg, XmNbackground, &bg, NULL);
366 no_pix = XCreatePixmapFromBitmapData(display, BaseW, (char *)clr,
367 font_w, font_h, fg, bg, DefaultDepth(display, screen));
369 XtVaCreateManagedWidget("", xmLabelWidgetClass, base3, NULL);
370 for (i=0; i < 16; i++) {
371 sprintf(add, "%2.1X", i);
372 XtVaCreateManagedWidget(add, xmLabelWidgetClass, base3, NULL);
378 for (i=0; i < NUM; i++) {
380 sprintf(add, "%2.1X", add_c++);
381 XtVaCreateManagedWidget(add, xmLabelWidgetClass, base3, NULL);
383 toggle[i] = XtVaCreateWidget("toggle",
384 xmPushButtonWidgetClass, base3,
387 XmNlabelType, XmPIXMAP,
388 XmNlabelPixmap, no_pix, NULL);
389 XtAddCallback(toggle[i], XmNactivateCallback,
390 (XtCallbackProc)Code2Call, (XtPointer)i);
391 XtAddCallback(toggle[i], XmNarmCallback,
392 (XtCallbackProc)DrawCode, (XtPointer)i);
393 XtAddCallback(toggle[i], XmNdisarmCallback,
394 (XtCallbackProc)DrawCode, (XtPointer)i);
395 XtAddEventHandler(toggle[i], ExposureMask, False,
396 (XtEventHandler)DrawCode, (XtPointer)i);
398 XtManageChildren(toggle, NUM);
400 base4 = XtVaCreateManagedWidget("base4", xmFormWidgetClass, base1, NULL);
402 xcs = XmStringCreateLocalized(resource.l_code);
403 label = XtVaCreateManagedWidget("code", xmLabelWidgetClass, base4,
405 XmNleftAttachment, XmATTACH_POSITION,
406 XmNleftPosition, 30, NULL);
408 text = XtVaCreateManagedWidget("text", xmTextWidgetClass, base4,
410 XmNcursorPositionVisible, False,
412 XmNleftAttachment, XmATTACH_WIDGET,
413 XmNleftWidget, label, NULL);
415 sep = XtVaCreateManagedWidget("sep", xmSeparatorGadgetClass, base1,
416 XmNorientation, XmHORIZONTAL, NULL);
418 form = XtVaCreateManagedWidget("sep", xmFormWidgetClass, base1, NULL);
420 xcs = XmStringCreateLocalized(resource.previous);
421 push1 = XtVaCreateManagedWidget("PreviousPage", xmPushButtonWidgetClass, form,
422 XmNleftAttachment, XmATTACH_POSITION,
424 XmNleftPosition, 10, NULL);
425 XtAddCallback(push1, XmNactivateCallback,
426 (XtCallbackProc)PrevPage, (XtPointer)scroll);
429 xcs = XmStringCreateLocalized(resource.next);
430 push2 = XtVaCreateManagedWidget("NextPage", xmPushButtonWidgetClass, form,
431 XmNleftAttachment, XmATTACH_POSITION,
433 XmNleftPosition, 35, NULL);
434 XtAddCallback(push2, XmNactivateCallback,
435 (XtCallbackProc)NextPage, (XtPointer)scroll);
438 xcs = XmStringCreateLocalized(resource.apply);
439 push3 = XtVaCreateManagedWidget("Apply", xmPushButtonWidgetClass, form,
440 XmNleftAttachment, XmATTACH_POSITION,
442 XmNleftPosition, 60, NULL);
443 XtAddCallback(push3, XmNactivateCallback, (XtCallbackProc)Apply, NULL);
446 xcs = XmStringCreateLocalized(resource.l_cancel);
447 push4 = XtVaCreateManagedWidget("Cancel", xmPushButtonWidgetClass, form,
448 XmNleftAttachment, XmATTACH_POSITION,
450 XmNleftPosition, 80, NULL);
451 XtAddCallback(push4, XmNactivateCallback, (XtCallbackProc)Cancel, NULL);
458 CodeWindow(widget, font_name, load_font)
463 static Boolean old_load_font;
464 extern int CodePoint;
468 BaseW = XtWindow(widget);
469 display = XtDisplay(widget);
470 screen = DefaultScreen(display);
471 if (FontName == NULL || strcmp(font_name, FontName) ||
472 load_font != old_load_font) {
473 old_load_font = load_font;
475 XtDestroyWidget(code_w);
485 FontName = (char *)malloc(strlen(font_name)+1);
486 strcpy(FontName, font_name);
497 code_w = CreateCodeWindow(widget);
498 XtManageChild(code_w);
500 XtMapWidget(XtParent(code_w));