0
|
1 /*
|
|
2 * $Id: xw_touroku.c,v 1.2 2001/06/14 18:16:13 ura Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
10 * Copyright 1991, 1992 by Massachusetts Institute of Technology
|
|
11 *
|
|
12 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
|
|
13 *
|
|
14 * This program is free software; you can redistribute it and/or modify
|
|
15 * it under the terms of the GNU General Public License as published by
|
|
16 * the Free Software Foundation; either version 2, or (at your option)
|
|
17 * any later version.
|
|
18 *
|
|
19 * This program is distributed in the hope that it will be useful,
|
|
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22 * GNU General Public License for more details.
|
|
23 *
|
|
24 * You should have received a copy of the GNU General Public License
|
|
25 * along with GNU Emacs; see the file COPYING. If not, write to the
|
|
26 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
27 *
|
|
28 * Commentary:
|
|
29 *
|
|
30 * Change log:
|
|
31 *
|
|
32 * Last modified date: 8,Feb.1999
|
|
33 *
|
|
34 * Code:
|
|
35 *
|
|
36 */
|
|
37
|
|
38 #include <stdio.h>
|
|
39 #include <string.h>
|
|
40 #include "commonhd.h"
|
|
41 #include "sdefine.h"
|
|
42 #include "xjutil.h"
|
|
43 #include "sxheader.h"
|
|
44 #include "xext.h"
|
|
45
|
|
46 void
|
|
47 xw_jutil_write_msg (msg)
|
|
48 unsigned char *msg;
|
|
49 {
|
|
50 int wc_len;
|
|
51
|
|
52 while (1)
|
|
53 {
|
|
54 wc_len = char_to_wchar (xjutil->xlc, msg, wc_buf, strlen ((char *) msg), wc_buf_max);
|
|
55 if (wc_len < -1)
|
|
56 {
|
|
57 return;
|
|
58 }
|
|
59 else if (wc_len == -1)
|
|
60 {
|
|
61 if (realloc_wc_buf () < 0)
|
|
62 return;
|
|
63 }
|
|
64 else
|
|
65 {
|
|
66 break;
|
|
67 }
|
|
68 }
|
|
69 JW1Mputwc (wc_buf, wc_len);
|
|
70 if (cur_text->currentcol > cur_text->max_pos)
|
|
71 {
|
|
72 cur_text->max_pos = cur_text->currentcol;
|
|
73 }
|
|
74 XFlush (dpy);
|
|
75 }
|
|
76
|
|
77 void
|
|
78 init_jutil (title, exec_t, cnt, t1, mes1)
|
|
79 unsigned char *title, *exec_t;
|
|
80 int cnt;
|
|
81 unsigned char *t1[];
|
|
82 unsigned char *mes1[];
|
|
83 {
|
|
84 register JutilRec *jutil = cur_root->jutil;
|
|
85 register BoxRec *box;
|
|
86 register JutilTextRec *text;
|
|
87 int width, height, x_cood, y_cood;
|
|
88 #ifdef nodef
|
|
89 int save_x, save_y;
|
|
90 Window root, child;
|
|
91 int win_x, win_y;
|
|
92 unsigned int keys_buttons;
|
|
93 #endif
|
|
94 int i;
|
|
95 int len_t, max_mes_t;
|
|
96 int max_columns;
|
|
97
|
|
98 xjutil->mode |= JUTIL_MODE;
|
|
99
|
|
100 jutil->title->string = title;
|
|
101 jutil->button[EXEC_W]->string = exec_t;
|
|
102 jutil->max_mes = cnt;
|
|
103 for (i = 0; i < jutil->max_mes; i++)
|
|
104 jutil->mes_button[i]->string = NULL;
|
|
105
|
|
106 moveresize_box (jutil->title, FontWidth, FontHeight / 2, (FontWidth * (len_t = strlen ((char *) title)) + IN_BORDER * 2), (FontHeight + IN_BORDER * 2));
|
|
107 len_t += 1;
|
|
108 moveresize_box (jutil->button[CANCEL_W],
|
|
109 (FontWidth * (len_t += SPACING)), FontHeight / 2, (FontWidth * strlen ((char *) jutil->button[CANCEL_W]->string) + IN_BORDER * 2), FontHeight + IN_BORDER * 2);
|
|
110 len_t += strlen ((char *) jutil->button[CANCEL_W]->string);
|
|
111 moveresize_box (jutil->button[EXEC_W], (FontWidth * (len_t += SPACING)), FontHeight / 2, (FontWidth * strlen ((char *) jutil->button[EXEC_W]->string) + IN_BORDER * 2), FontHeight + IN_BORDER * 2);
|
|
112 XSetWindowBackground (dpy, jutil->w, cur_root->bg);
|
|
113 changecolor_box (jutil->title, cur_root->fg, cur_root->bg, cur_root->fg, BoxAll);
|
|
114 changecolor_box (jutil->button[CANCEL_W], cur_root->fg, cur_root->bg, cur_root->fg, BoxAll);
|
|
115 changecolor_box (jutil->button[EXEC_W], cur_root->fg, cur_root->bg, cur_root->fg, BoxAll);
|
|
116
|
|
117 jutil->mode = MESSAGE1;
|
|
118 max_mes_t = 0;
|
|
119 for (i = 0; i < jutil->max_mes; i++)
|
|
120 {
|
|
121 box = jutil->mes_button[i];
|
|
122 box->string = t1[i];
|
|
123 if (jutil->max_mes > 1)
|
|
124 {
|
|
125 box->cb = jutil_mode_set;
|
|
126 box->cb_data = (int *) i;
|
|
127 box->do_ret = True;
|
|
128 }
|
|
129 else
|
|
130 {
|
|
131 freeze_box (box);
|
|
132 box->cb = NULL;
|
|
133 box->cb_data = NULL;
|
|
134 box->do_ret = False;
|
|
135 }
|
|
136 moveresize_box (box, (FontWidth - IN_BORDER), (FontHeight * (3 + i * 2) - IN_BORDER), (FontWidth * (len_t = strlen ((char *) box->string)) + IN_BORDER * 2), (FontHeight + IN_BORDER * 2));
|
|
137 changecolor_box (box, cur_root->fg, cur_root->bg, cur_root->bg, BoxAll);
|
|
138 map_box (box);
|
|
139
|
|
140 len_t += SPACING;
|
|
141 if (len_t > max_mes_t)
|
|
142 max_mes_t = len_t;
|
|
143 }
|
|
144
|
|
145 width = FontWidth * (TEXT_WIDTH + max_mes_t + SPACING);
|
|
146 height = FontHeight * (3 + cnt * 2);
|
|
147 if (width >= DisplayWidth (dpy, cur_root->screen) - cur_root->bw)
|
|
148 {
|
|
149 width = DisplayWidth (dpy, cur_root->screen) - cur_root->bw;
|
|
150 max_columns = width / FontWidth - (max_mes_t + SPACING);
|
|
151 }
|
|
152 else
|
|
153 {
|
|
154 max_columns = TEXT_WIDTH;
|
|
155 }
|
|
156
|
|
157 for (i = 0; i < jutil->max_mes; i++)
|
|
158 {
|
|
159 text = jutil->mes_text[i];
|
|
160 text->max_columns = max_columns;
|
|
161 text->width = max_columns * FontWidth;
|
|
162 XMoveResizeWindow (dpy, text->wp, (FontWidth * max_mes_t), (FontHeight * (3 + i * 2)), (FontWidth * text->max_columns), FontHeight);
|
|
163 XSetWindowBackground (dpy, text->wp, cur_root->bg);
|
|
164 XClearWindow (dpy, text->wp);
|
|
165 resize_text (text);
|
|
166 XMapWindow (dpy, text->wp);
|
|
167 cur_text = text;
|
|
168 JWMline_clear (0);
|
|
169 if (mes1 && mes1[i] && *mes1[i])
|
|
170 {
|
|
171 xw_jutil_write_msg (mes1[i]);
|
|
172 }
|
|
173 }
|
|
174
|
|
175 moveresize_box (jutil->rk_mode, (width - FontWidth * (MHL0 + SPACING)), FontHeight / 2, (FontWidth * MHL0 + IN_BORDER * 2), (FontHeight + IN_BORDER * 2));
|
|
176 changecolor_box (jutil->rk_mode, cur_root->fg, cur_root->bg, cur_root->fg, BoxAll);
|
|
177 decide_position (width, height, cur_root->bw, &x_cood, &y_cood);
|
|
178 #ifdef nodef
|
|
179 XQueryPointer (dpy, cur_root->root_window, &root, &child, &save_x, &save_y, &win_x, &win_y, &keys_buttons);
|
|
180 jutil->save_p.x = (short) save_x;
|
|
181 jutil->save_p.y = (short) save_y;
|
|
182 XWarpPointer (dpy, None, cur_root->root_window, 0, 0, 0, 0, x_cood + FontWidth * 2, y_cood + FontHeight);
|
|
183 #endif
|
|
184
|
|
185 XMoveResizeWindow (dpy, jutil->w, x_cood - 2, y_cood - 2, width, height);
|
|
186 set_wm_properties (jutil->w, x_cood - 2, y_cood - 2, width, height, CenterGravity, NULL, NULL, 0, 0, 0, 0, 0);
|
|
187 XRaiseWindow (dpy, jutil->w);
|
|
188 XMapWindow (dpy, jutil->w);
|
|
189
|
|
190 disp_mode ();
|
|
191 XFlush (dpy);
|
|
192
|
|
193 }
|
|
194
|
|
195 static void
|
|
196 clear_jutil_buf (buf)
|
|
197 int *buf;
|
|
198 {
|
|
199 register int *x;
|
|
200
|
|
201 x = buf;
|
|
202 for (; *x != 0; x++)
|
|
203 {
|
|
204 *x = 0;
|
|
205 }
|
|
206 }
|
|
207
|
|
208 void
|
|
209 end_jutil ()
|
|
210 {
|
|
211 int i;
|
|
212 JutilRec *jutil = cur_root->jutil;
|
|
213
|
|
214 for (i = 0; i < jutil->max_mes; i++)
|
|
215 {
|
|
216 clear_jutil_buf (jutil->mes_text[i]->buf);
|
|
217 unmap_box (jutil->mes_button[i]);
|
|
218 XUnmapWindow (dpy, jutil->mes_text[i]->wp);
|
|
219 }
|
|
220 XWithdrawWindow (dpy, jutil->w, DefaultScreen (dpy));
|
|
221 /*
|
|
222 XUnmapWindow(dpy, jutil->w);
|
|
223 */
|
|
224 #ifdef nodef
|
|
225 if (jutil->save_p.x > -1)
|
|
226 {
|
|
227 XWarpPointer (dpy, None, cur_root->root_window, 0, 0, 0, 0, jutil->save_p.x, jutil->save_p.y);
|
|
228 jutil->save_p.x = jutil->save_p.y = -1;
|
|
229 }
|
|
230 XFlush (dpy);
|
|
231 #endif
|
|
232 jutil->button[EXEC_W]->in = jutil->button[CANCEL_W]->in = 0;
|
|
233 xjutil->mode &= ~JUTIL_MODE;
|
|
234 xjutil->sel_ret = -1;
|
|
235 }
|
|
236
|
|
237 void
|
|
238 change_cur_jutil (cur)
|
|
239 int cur;
|
|
240 {
|
|
241 cur_text = cur_root->jutil->mes_text[cur];
|
|
242 }
|
|
243
|
|
244 void
|
|
245 hanten_jutil_mes_title (mes, rev)
|
|
246 int mes;
|
|
247 int rev;
|
|
248 {
|
|
249 cur_root->jutil->mes_button[mes]->in = rev;
|
|
250 redraw_box (cur_root->jutil->mes_button[mes]);
|
|
251 }
|
|
252
|
|
253 void
|
|
254 change_mes_title (mes, msg, rev)
|
|
255 int mes;
|
|
256 unsigned char *msg;
|
|
257 int rev;
|
|
258 {
|
|
259 cur_root->jutil->mes_button[mes]->string = msg;
|
|
260 hanten_jutil_mes_title (mes, rev);
|
|
261
|
|
262 }
|