QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1636|回复: 1

有谁知道redhat下motif程序如何显示中文吗?

[复制链接]
发表于 2006-8-18 20:31:23 | 显示全部楼层 |阅读模式
我的motif程序代码如下:希望把红色英文改成中文,但直接修改后中文显示为乱码,求大家解决以下这个别问题

#include "demgen.h"
#include "graphics.h"
#include <X11/cursorfont.h>
#include <Xm/CascadeB.h>
#include <Xm/SeparatoG.h>
#include <Xm/Separator.h>
#include <Xm/ToggleBG.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <stdlib.h>
#include "gcn.h" /* for the cps_div and min_con_len parameters for _segment */

/* Function prototypes */
Boolean
read_file(char * filename, enum FILETYPE file_type);

void
do_plot(enum FILETYPE file_type),
elm_setup();

/* Callback prototypes */
/* static XtCallbackProc */
static void
projectname_CB(Widget w, XtPointer client_data, XtPointer call_data),
display_CB(Widget w, XtPointer client_data,
    XtPointer call_data ),
  /*    XmPushButtonCallbackStruct *call_data), */
run_splin2h_CB(Widget w, XtPointer client_data,
    XtPointer call_data ),
        /*        XmPushButtonCallbackStruct *call_data), */
run_grdcon_CB(Widget w, XtPointer client_data,
    XtPointer call_data ),
       /*       XmPushButtonCallbackStruct *call_data), */
run_element_CB(Widget w, XtPointer client_data,
    XtPointer call_data ),
        /*        XmPushButtonCallbackStruct *call_data), */
control_help_CB(Widget w, XtPointer client_data,
    XtPointer call_data ),
  /*  XmPushButtonCallbackStruct *call_data), */
quit_CB(Widget w, XtPointer client_data,
    XtPointer call_data );
/*  XmPushButtonCallbackStruct *call_data); */

/* XtCallbackProc */
void
spl_CB(Widget w, XtPointer client_data,
       XtPointer call_data ),
  /*       XmPushButtonCallbackStruct *call_data), */
gcn_CB(Widget w, XtPointer client_data,
       XtPointer call_data ),
  /*       XmPushButtonCallbackStruct *call_data), */
zoom_CB(Widget w, XtPointer client_data,
XtPointer call_data );
  /* XmPushButtonCallbackStruct *call_data); */

/* Widget definitions */
static Widget project_l; /* Label for the project name */
static Widget menubar; /* The menu bar for the pulldown menus */

/* Widgets used in the construction of the pulldown menus used to control
   the system */
static Widget display_cascade, build_cascade, run_cascade;
static Widget display_submenu, build_submenu, run_submenu;
static Widget display_button[6], build_button[3], run_button[3];

/* These are used for zoom/pan on ths display window */
Widget zoom_pan_button, zoom_pan_message;

/* Field seperators for the control window */
static Widget control_sep1, control_sep2;

/* Other buttons used in the control window */
static Widget clear_button, help_button, quit_button;
static Widget control_help;

/* Message boxes used when waiting for processing */
Widget io_wait_box, splin2h_wait_box, grdcon_wait_box;

enum FILETYPE file_type;

Widget create_control(void)
     /* Create the control window, and it's associated menus and buttons */
{
    Widget control;  /* holds return value for the function */
    /*    Widget button; */ /* to allow us to unmanage the working box buttons */
    Arg args[20];
    int n;
    XmString string, title;

/* controls  */
    title = XmStringCreateLtoR("Demgen Control Menu", XmSTRING_DEFAULT_CHARSET);
    n = 0;
    XtSetArg(args[n], XmNdefaultPosition, False); n++;
    XtSetArg(args[n], XmNdialogTitle, title); n++;
    XtSetArg(args[n], XmNautoUnmanage, False); n++;
    control = XmCreateFormDialog(toplevel, "control_form", args, n);
    XmStringFree(title);

/* project name - label gadget and text field widget */
    n = 0;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
    XtSetArg (args[n], XmNlabelString,
        XmStringCreateLtoR("Project Name", XmSTRING_DEFAULT_CHARSET)); n++;
    project_l = XmCreateLabel(control, "project_label", args, n);
    /* XmCreateLabelGadget changed to XmCreateLabel */

    XtManageChild(project_l);

    n = 0;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, project_l); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg (args[n], XmNcolumns, (short) 15); n++;
    XtSetArg (args[n], XmNresizeWidth, True); n++;
    XtSetArg (args[n], XmNnavigationType, XmNONE); n++;
    project_t = XmCreateTextField(control, "project_text", args, n);
    XtManageChild(project_t);

    /* If the textfield is activated, or loses focus, call the projectname_CB
       callback, to save the projectname */
    XtAddCallback(project_t, XmNactivateCallback, projectname_CB, NULL);
    XtAddCallback(project_t, XmNlosingFocusCallback, projectname_CB, NULL);
    if (projectname)
        XmTextSetString(project_t, projectname);

/* the menubar
   used to hold the pulldown menus */
    n = 0;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, project_t); n++;
    XtSetArg(args[n], XmNtopOffset, 10); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
    XtSetArg(args[n], XmNentryBorder, (Dimension) 1); n++;
    XtSetArg(args[n], XmNspacing, (Dimension) 2); n++;
    menubar = XmCreateMenuBar(control, "control_menubar", args, n);
    XtManageChild(menubar);

/* the display menu
   used to display different datafiles */
    n = 0;
    display_submenu = XmCreatePulldownMenu(menubar, "display_submenu",
args, n);
    n = 0;
    display_button[0] = XmCreatePushButton(display_submenu,
"Spot heights(.xyz)", args, n);
    XtAddCallback(display_button[0], XmNactivateCallback, display_CB,
    (XtPointer) xyz);
    display_button[1] = XmCreatePushButton(display_submenu,
"Raw contours(.cns)", args, n);
    XtAddCallback(display_button[1], XmNactivateCallback, display_CB,
    (XtPointer) cns);
    display_button[2] = XmCreatePushButton(display_submenu,
        "Fitted grid(.grd)", args, n);
    XtAddCallback(display_button[2], XmNactivateCallback, display_CB,
    (XtPointer) grd);
    display_button[3] = XmCreatePushButton(display_submenu,
        "Gcn contours(.con)", args, n);
    XtAddCallback(display_button[3], XmNactivateCallback, display_CB,
    (XtPointer) con);
    display_button[4] = XmCreatePushButton(display_submenu,
        "DEM contours(.tcn)", args, n);
    XtAddCallback(display_button[4], XmNactivateCallback, display_CB,
    (XtPointer) tcn);
    display_button[5] = XmCreatePushButton(display_submenu,
        "Element File(.elm)", args, n);
    XtAddCallback(display_button[5], XmNactivateCallback, display_CB,
    (XtPointer) elm);
    XtManageChildren(display_button, 6);

    string = XmStringCreate("Display ", XmSTRING_DEFAULT_CHARSET);
    n = 0;
    XtSetArg(args[n], XmNlabelString, string); n++;
    XtSetArg(args[n], XmNsubMenuId, display_submenu); n++;
    display_cascade = XmCreateCascadeButton(menubar, "display_cascade",
         args, n);
    XtManageChild(display_cascade);
    XmStringFree(string);

    /* the build menu
       used to popup the different parameter file dialogs */
    n = 0;
    build_submenu = XmCreatePulldownMenu(menubar, "build_submenu",
     args, n);
    n = 0;
    build_button[0] = XmCreatePushButton(build_submenu,
            "spl file", args, n);
    XtAddCallback(build_button[0], XmNactivateCallback, spl_CB, NULL);
    build_button[1] = XmCreatePushButton(build_submenu,
            "gcn file", args, n);
    XtAddCallback(build_button[1], XmNactivateCallback, gcn_CB, NULL);
    XtManageChildren(build_button, 2);

    n = 0;
/* positional arguments */
    string = XmStringCreate("Build   ", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, string); n++;
    XtSetArg(args[n], XmNsubMenuId, build_submenu); n++;
    build_cascade = XmCreateCascadeButton(menubar, "build_cascade",
      args, n);
    XmStringFree(string);
    XtManageChild(build_cascade);

    /* the run menu
       used to run _splin2h, _grdcon, and _element */
    n = 0;
    run_submenu = XmCreatePulldownMenu(menubar, "run_submenu",
args, n);
    n = 0;
    run_button[0] = XmCreatePushButton(run_submenu,
"_splin2h ", args, n);
    XtAddCallback(run_button[0], XmNactivateCallback, run_splin2h_CB, NULL);
    run_button[1] = XmCreatePushButton(run_submenu,
"_grdcon  ", args, n);
    XtAddCallback(run_button[1], XmNactivateCallback, run_grdcon_CB, NULL);
    run_button[2] = XmCreatePushButton(run_submenu,
"_element", args, n);
    XtAddCallback(run_button[2], XmNactivateCallback, run_element_CB, NULL);
    XtManageChildren(run_button, 3);

    n = 0;
/* positional arguments */
    string = XmStringCreate("Run     ", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, string); n++;
    XtSetArg(args[n], XmNsubMenuId, run_submenu); n++;
    run_cascade = XmCreateCascadeButton(menubar, "run_cascade", args, n);
    XmStringFree(string);
    XtManageChild(run_cascade);

    /* controls separator gadget */
    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, menubar); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 2); n++;
    XtSetArg(args[n], XmNrightOffset, 2); n++;
    control_sep1 =
      XmCreateSeparator(control, "control_sep1", args, n);
    XtManageChild(control_sep1);

    /* the graphics utilities toggle button
       this controls the zoom/pan functions */
    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, control_sep1); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg(args[n], XmNindicatorOn, False); n++;
    XtSetArg(args[n], XmNshadowThickness, (Dimension) 2); n++;
    zoom_pan_button =
      XmCreateToggleButton(control, "Zoom/Pan", args, n);
    XtAddCallback(zoom_pan_button, XmNvalueChangedCallback, zoom_CB, NULL);
    XtManageChild(zoom_pan_button);

    zoom_pan_message =
      create_help_box(control, "zoom_pan_message", "Zoom/Pan", "", False);
   
    /* controls separator gadget */
    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, zoom_pan_button); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 2); n++;
    XtSetArg(args[n], XmNrightOffset, 2); n++;
    control_sep2 =
      XmCreateSeparator(control, "control_sep2", args, n);
    XtManageChild(control_sep2);

    /* the clear button */
    n = 0;
    /* positional arguments */
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, menubar); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, control_sep2); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg(args[n], XmNlabelString,
        XmStringCreateLtoR("Clear   ", XmSTRING_DEFAULT_CHARSET)); n++;
    clear_button = XmCreatePushButton(control, "Clear", args, n);
    XtAddCallback(clear_button, XmNactivateCallback, clear_CB, NULL);
    XtManageChild(clear_button);

    /* the help button */
    n = 0;
    /* positional arguments */
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, menubar); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, clear_button); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg(args[n], XmNlabelString,
        XmStringCreateLtoR("Help    ", XmSTRING_DEFAULT_CHARSET)); n++;
    help_button = XmCreatePushButton(control, "Help", args, n);
    XtAddCallback(help_button, XmNactivateCallback, control_help_CB, NULL);
    XtManageChild(help_button);

    /* the help box */
    control_help = create_help_box(control, "control_help", "", "", False);

    /* the quit button */
    n = 0;
    /* positional arguments */
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, menubar); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, help_button); n++;
    XtSetArg(args[n], XmNtopOffset, 5); n++;
    XtSetArg(args[n], XmNbottomOffset, 5); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    XtSetArg(args[n], XmNlabelString,
        XmStringCreateLtoR("Quit    ", XmSTRING_DEFAULT_CHARSET)); n++;
    quit_button = XmCreatePushButton(control, "Quit", args, n);
    XtAddCallback(quit_button, XmNactivateCallback, quit_CB, NULL);
    XtManageChild(quit_button);

    /* the file read wait box */
    io_wait_box = create_wait_box(control, "FileWait", "IO Wait",
      "Reading the data file\nPlease wait...");

    /* the splin2h wait box */
    splin2h_wait_box = create_wait_box(control, "splin2hWait", "splin2h Wait",
           "Running _splin2h\nPlease wait...");

    /* the grdcon wait box */
    grdcon_wait_box =
      create_wait_box(control, "grdconWait", "grdcon Wait",
        "Running _grdcon and _segment\nPlease wait...");

/*    XmAddTabGroup(control); ZZZ */
    XtManageChild(control);

    return control;
}

/* static XtCallbackProc */
static void
display_CB(Widget w,
    XtPointer client_data, /* filetype to display*/
    XtPointer call_data )
     /*    XmPushButtonCallbackStruct *call_data) */
     /* Call do_plot for the requested datafile type.
The datafile type is passed in client_data */
{
  do_plot((enum FILETYPE) client_data);
}

/* static XtCallbackProc */
static void
run_splin2h_CB(Widget w,
        XtPointer client_data,
        XtPointer call_data )
  /*        XmPushButtonCallbackStruct *call_data) */
     /* Run _splin2h using the system function call */
{
    char string[50] = "_splin2h < ";
    XtManageChild(splin2h_wait_box);
    XmUpdateDisplay(splin2h_wait_box);
#ifndef hp
    usleep(250000);
#endif
    strcat(string, projectname);
    strcat(string, ".spl");
    printf("%s\n", string);
    XmUpdateDisplay(splin2h_wait_box);
    system(string);
    XtUnmanageChild(splin2h_wait_box);
}


/* static XtCallbackProc */
static void
run_grdcon_CB(Widget w,
       XtPointer client_data,
       XtPointer call_data )
  /*       XmPushButtonCallbackStruct *call_data) */
     /* Run grdcon and segment using the system function call */
{
    char string[50] = "_grdcon < ";
    char param[20];
    int rc;
    gcn_rec gcn_seg_data;

    XtManageChild(grdcon_wait_box);
    XmUpdateDisplay(grdcon_wait_box);
#ifndef hp
    usleep(250000);
#endif

/* get the segment parameters */
    gcn_read(projectname, &gcn_seg_data);

/* run _grdcon */
    strcat(string, projectname);
    strcat(string, ".gcn");
    printf("Running %s\n", string);
    printf("%s\n", string);
    XmUpdateDisplay(grdcon_wait_box);
    rc = system(string);
    if (rc) return; /* if error, then return */
    /* run _segment via segment.sh
       segment.sh is used to feed the parameters into the segment program */
    strcpy(string, "segment.sh ");
    strcat(string, projectname);
    sprintf(param," %d %d", gcn_seg_data.cps_div, gcn_seg_data.min_con_len);
    strcat(string, param);
    printf("Running %s\n", string);
    rc = system(string);
    /* remove the con file
       it is not needed after segment has been run */
    strcpy(string, "/bin/rm -f ");
    strcat(string, projectname);
    strcat(string, ".con");
    rc = system(string);
    XtUnmanageChild(grdcon_wait_box);
}

/* static XtCallbackProc */
static void
run_element_CB(Widget w, XtPointer client_data,
        XtPointer call_data )
  /*             XmPushButtonCallbackStruct *call_data) */
     /* Start the terrain analysis - element */
{
  elm_setup();
}

/* static XtCallbackProc */
static void
quit_CB(Widget w, XtPointer client_data,
XtPointer call_data )
     /* XmPushButtonCallbackStruct *call_data) */
     /* Quit the application */
{
    exit(0);
}

void
do_plot(enum FILETYPE file_type)
     /* Plot the requested datafile type.
The file is read (read_file), and then the screen is redrawn to
display it. */
{
  /* Set the wait cursor */
  XDefineCursor(display, XtWindow(drawing), waitcursor);
  XDefineCursor(display, XtWindow(control), waitcursor);
  /* Popup the wait box, then wait briefly to encourage the text in the box
     to appear. This does not always work. */
     
  XtManageChild(io_wait_box);
  XmUpdateDisplay(io_wait_box);
#ifndef hp
  usleep(250000);
#endif
  XmUpdateDisplay(io_wait_box);
  read_file(projectname, file_type);
  XtUnmanageChild(io_wait_box);
  XmUpdateDisplay(io_wait_box);
  /* clear the drawing window, and draw in it */
  draw_screen(True);
  /* Unset the wait cursor */
  XUndefineCursor(display, XtWindow(drawing));
  XUndefineCursor(display, XtWindow(control));
}

/* static XtCallbackProc */
static void
projectname_CB(Widget w, XtPointer client_data, XtPointer call_data)
     /* projectname callback -
gets the text value of projectname from the projectname widget */
{
    projectname = XmTextGetString(w);
}

/* static XtCallbackProc */
static void
control_help_CB(Widget w, /* widget id */
  XtPointer client_data, /* data from application */
  XtPointer call_data )
     /*  XmPushButtonCallbackStruct *call_data) */
     /* data from widget class */

     /* Display the help window for the control screen.
Context sensitive help has not been implemented for theis screen yet,
although skeleton code is included here as comments */
{
/*  static Widget help_for;
  printf("Before tracking locate\n");
  help_for = XmTrackingLocate(control, helpcursor, True);
  printf("After tracking locate\n");
  if ((help_for == project_l) || (help_for == project_t))
    printf("Help for project name field\n");
  else if (help_for == display_cascade)
    printf("Help for display menu\n");
  else if (help_for == build_cascade)
    printf("Help for build menu\n");
  else if (help_for == run_cascade)
    printf("Help for run menu\n");
  else
    printf("Unknown help for control panel\n");*/
  XtManageChild(control_help);
}
发表于 2006-8-18 23:19:19 | 显示全部楼层
不能,openmotif2.3可以,motifzone上有详细的信息
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-15 09:12 , Processed in 0.033033 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表