From: cuzin@imag.fr (Rene Cuzin)
Newsgroups: comp.windows.x.motif,imag.osf.motif
Subject: X11R5 Motif colormap ----> HELP
Keywords: colormap X motif
Date: 31 Aug 92 10:36:21 GMT
Followup-To: poster
Organization: IMAG Institute, University of Grenoble, France

Hello !!!!

I don't known very well X11/Motif with colors and I have some problems.
So I would need some help.

I work on SUN4 workstation with UNIX 4.1.1,
X11R5, Motif 1.1.4.

I wrote a small programm (source = UIL and C)which changes
background and foreground colors with XtSetArg and XSetValues functions
after changing the colormap.


Here follows :
	- the UIL program
	- the C program

I don't get any error display and my program run correctly except
for the background and foreground colors.

After running the program, the background and foreground colors
which are displayed are the coulors specified in the UIL program
and not in the C program
**************************************************************
/*****************/
/*THE UIL PROGRAM*/
/*****************/
module general
    version = 'v1.0'
    names = case_sensitive

include file 'uil/XmAppl.uil';

value
		    n_main_interface            :  1;

object
      main_interface : XmMainWindow
      {
         arguments 
         {
            XmNunitType  = XmPIXELS;
            XmNx = 310;
            XmNy = 30;
            XmNwidth = 460;
            XmNheight = 500;
            XmNbackground = rgb (34560,52736,60160);
            XmNforeground = rgb (65280,65280,65280);
            XmNborderWidth = 1;
          };
         controls
         {
            XmForm       format;
         };
         callbacks
         {
            MrmNcreateCallback = procedure recup_obj_id(n_main_interface);
         };
      };

    format: XmForm
    {
         arguments
         {
            XmNborderWidth = 1;
            XmNx = 5;
            XmNy = 5;
            XmNwidth  = 460;
            XmNheight = 500;
            XmNbackground = rgb (34560,52736,60160);
            XmNforeground = rgb (65280,65280,65280);
         };
         controls
         {
            XmDrawnButton db_rectangle;
            XmDrawnButton db_gomme;
            XmScale s_luminosite;
            XmPushButton pb_sauve;      !sauve sous fichier unix meme nom
            XmText txt_ligne2_gs;
         };
     };

etc. etc. etc. etc. etc. etc. etc. etc. etc. etc. etc. etc. 


end module;

/******************************************************************/
/***************/
/*THE C PROGRAM*/
/***************/

#include <stdio.h>
#include <Mrm/MrmAppl.h>
#include <Mrm/MrmWidget.h>
#include <Xm/Xm.h>
#include <errno.h>
#include <strings.h>
#include <dicicone.h>
#include <X11/cursorfont.h>       /* pour la definition des curseurs */

#define n_main_interface            1

MrmHierarchy hierarchy;
Widget top_level, main_window_widget;
Widget tab_obj_id[MAX_ID];

/******************************************************************/
/*this function store the identification number of the widget*/

void recup_obj_id(w, tag, reason)
    Widget w;
    int *tag;
    unsigned long *reason;
{
    int widget_num = *tag;

    tab_obj_id[widget_num] = w;
}
/******************************************************************/
/*this function changes the foreground and background colors and the
  width of the window.
  after running, the width of the window is set as specified but colors
  are not
*/
void change_color ()
{
        Arg list_arg[3];
        char *blanc,*vert;

        blanc = (char *)malloc(sizeof(char) * 20);
        vert = (char *)malloc(sizeof(char) * 20);
        strcpy(blanc,"rgb(0,0,0)");
        strcpy(vert,"rgb(77,255,179)");

        XtSetArg(list_arg[0],XmNbackground,blanc);/*change backgroundcolor*/
        XtSetArg(list_arg[1],XmNforeground,vert);/*change foregroundcolor*/
        XtSetArg(list_arg[2],XmNwidth,200);/*change width*/

        XtSetValues(tab_obj_id[n_main_interface],list_arg,3);
}
/******************************************************************/

main(argc, argv)
    unsigned int argc;
    char *argv[];

{
    /*
     * variables locales
     */

    short ind_event;
    XEvent *next_event;    /* evenement a traiter */



    MrmInitialize();                 /* Initialise MRM avant initialisation */
                                        /* de la X Toolkit. */


    /* Initialise la X Toolkit. On recupere un top_level shell widget en retour*/

    top_level = XtInitialize("edim",
                                        /*   Main window banner text. */
      "Interface",                    /*   Root class name. */
      NULL,                           /*   No option list. */
      0,                              /*   Number of options. */
      &argc,                          /*   Address of argc */
      argv);                          /*   argv */

    MrmRegisterNames(reglist,NB_REG(reglist));

    affichage=XtDisplay(top_level);
    ecran= XtScreen(top_level);

    init_couleurs(); /*this function change the color table*/

    main_window_widget = NULL; 

    if (MrmFetchWidget(hierarchy, "main_interface", top_level,
      &main_window_widget, &dummy_class) != MrmSUCCESS)
        s_error("can't fetch main window");

    change_color(affichage,map,hierarchy);/*call to the function*/
                                          /**********************/
    XtManageChild(main_window_widget);
    XtRealizeWidget(top_level);

    XtMainLoop();

}
/******************************************************************/

If somebody can help me, I will be very happy.
Thank you in advance.

Rene Cuzin - Imag - Grenoble - France
E.Mail: cuzin@imag.fr  -  bureau B302
Tel (33)76-51-45-26    -  Fax (33)76-44-66-75 
-------------------------------------------------------


-- 
Rene Cuzin - stagiaire ingenieur CNAM - Imag - Grenoble - France
E.Mail: cuzin@imag.fr      -  bureau B302
Tel (33)76-51-45-26        -  Fax (33)76-44-66-75 
---------------------------------------------------------------
Newsgroups: comp.windows.x.motif