...
325 M17N_INIT ();
326 if (merror_code != MERROR_NONE)
327 FATAL_ERROR ("%s\n", "Fail to initialize the m17n library.");
328
329 /* Decide how to decode the input stream. */
330 if (coding_name)
331 {
332 coding = mconv_resolve_coding (msymbol (coding_name));
333 if (coding == Mnil)
334 FATAL_ERROR ("Invalid coding: %s\n", coding_name);
335 }
336 else
337 coding = Mcoding_utf_8;
338
339 mt = mconv_decode_stream (coding, fp);
340 fclose (fp);
341 if (! mt)
342 FATAL_ERROR ("%s\n", "Fail to decode the input file or stream!");
343
344 {
345 MPlist *param = mplist ();
346 MFace *face = mface ();
347
348 if (fontsize)
349 mface_put_prop (face, Msize, (void *) fontsize);
350 mplist_put (param, Mwidget, shell);
351 mplist_put (param, Mface, face);
352 frame = mframe (param);
353 m17n_object_unref (param);
354 m17n_object_unref (face);
355 }
356
357 /* Create this widget hierarchy.
358 Shell - form -+- quit
359 |
360 +- viewport - text */
361
362 form = XtCreateManagedWidget ("form", formWidgetClass, shell, NULL, 0);
363 XtSetArg (arg[0], XtNleft, XawChainLeft);
364 XtSetArg (arg[1], XtNright, XawChainLeft);
365 XtSetArg (arg[2], XtNtop, XawChainTop);
366 XtSetArg (arg[3], XtNbottom, XawChainTop);
367 XtSetArg (arg[4], XtNaccelerators, XtParseAcceleratorTable (quit_action));
368 quit = XtCreateManagedWidget ("quit", commandWidgetClass, form, arg, 5);
369 XtAddCallback (quit, XtNcallback, QuitProc, NULL);
370
371 viewport_width = (int) mframe_get_prop (frame, Mfont_width) * 80;
372 viewport_height
373 = ((int) mframe_get_prop (frame, Mfont_ascent)
374 + (int) mframe_get_prop (frame, Mfont_descent)) * 24;
375 XtSetArg (arg[0], XtNallowVert, True);
376 XtSetArg (arg[1], XtNforceBars, False);
377 XtSetArg (arg[2], XtNfromVert, quit);
378 XtSetArg (arg[3], XtNtop, XawChainTop);
379 XtSetArg (arg[4], XtNbottom, XawChainBottom);
380 XtSetArg (arg[5], XtNright, XawChainRight);
381 XtSetArg (arg[6], XtNwidth, viewport_width);
382 XtSetArg (arg[7], XtNheight, viewport_height);
383 viewport = XtCreateManagedWidget ("viewport", viewportWidgetClass, form,
384 arg, 8);
385
386 /* Before creating the text widget, we must calculate the height of
387 the M-text to draw. */
388 control.two_dimensional = 1;
389 control.enable_bidi = 1;
390 control.disable_caching = 1;
391 control.max_line_width = viewport_width;
392 mdraw_text_extents (frame, mt, 0, mtext_len (mt), &control,
393 NULL, NULL, &metric);
...
|