Toggle button as Indicator only - Motif

This is a discussion on Toggle button as Indicator only - Motif ; How do I get the look of a radiobutton, but only have the functionality of an indicator that shows different colors for different states?...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Toggle button as Indicator only

  1. Toggle button as Indicator only

    How do I get the look of a radiobutton, but only have the functionality
    of an indicator that shows different colors for different states?


  2. Re: Toggle button as Indicator only


    wrote in message
    news:1146669422.891672.236750@g10g2000cwb.googlegr oups.com...
    > How do I get the look of a radiobutton, but only have the functionality
    > of an indicator that shows different colors for different states?
    >

    In Motif 2.x, Use a ToggleButton, setting XmNindicatorType as desired.
    Showing different COLORS is a bit more difficult, depending on how many
    states you have.
    You could just set XmNforeground, but that also changes the color of the
    text, unless you
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project
    use a RenderTable to set text colors.



  3. Re: Toggle button as Indicator only


    jfortiz62@gmail.com wrote:
    > How do I get the look of a radiobutton, but only have the functionality
    > of an indicator that shows different colors for different states?


    #include

    static const String color_list[] = {
    "Red", "Green", "Blue", "Cyan", "Magenta", "Yellow"
    };

    static Pixel pixel_list[XtNumber(color_list)];

    static const Cardinal num_colors = XtNumber(color_list);

    static void valueChangedCallback(Widget w, XtPointer client_data,
    XtPointer call_data)
    {
    XtPointer p;
    int i;

    XtVaGetValues(w, XmNuserData, &p, NULL);
    i = ((int) p + 1) % num_colors;
    XtVaSetValues(w,
    XmNset, XmUNSET,
    XmNunselectColor, pixel_list[i],
    XmNuserData, (XtPointer) i,
    NULL);
    }

    int main(int argc, char **argv)
    {
    XtAppContext app;
    Widget shell, button;
    Display *dpy;
    Screen *scr;
    Colormap cmap;
    XColor color, exact_color;
    int i;

    shell = XtAppInitialize(&app, "XmTest", NULL, 0, &argc, argv, NULL,
    NULL, 0);
    dpy = XtDisplay(shell);
    scr = XtScreen(shell);
    cmap = DefaultColormapOfScreen(scr);
    for (i = 0; i < num_colors; i++) {
    pixel_list[i] = XAllocNamedColor(dpy, cmap, color_list[i],
    &color, &exact_color) ?
    color.pixel : WhitePixelOfScreen(scr);
    }
    button = XmCreateToggleButton(shell, "button", NULL, 0);
    XtAddCallback(button, XmNvalueChangedCallback,
    valueChangedCallback, NULL);
    XtVaSetValues(button,
    XmNunselectColor, pixel_list[0],
    XmNindicatorType, XmONE_OF_MANY,
    XmNuserData, (XtPointer) 0,
    NULL);
    XtManageChild(button);
    XtRealizeWidget(shell);
    XtAppMainLoop(app);

    return 0;
    }

    I hope it helps.

    --- Casantos


+ Reply to Thread