This appendix contains example programs for some of the SGI extended IRIS IM widgets.
Makefiles are provided for some of these examples, but to use these examples, you need to:
Link with -lXm and -lSgm, making sure to put the -lSgm before -lXm. (To replace an unenhanced widget with the enhanced version of that widget in an existing program, you need to re-link.)
LLDLIBS = -lSgm -lXm -lXt -lX11 -lPW |
You must include -lSgm to get the enhanced look and the new widgets. If you do not include -lfileicon, you will get a runtime error, since the runtime loader won't be able to find needed symbols. The -lXm represents the enhanced version of libXm (IRIS IM).
Run the program with these resources:
*sgiMode: true *useSchemes: all |
Set them in your .Xdefaults file or create a file for your application in /usr/lib/X11/app-defaults.
This appendix provides example programs for:
To run this program, add these lines to your .Xdefaults file:
fsb*sgiMode: true fsb*useSchemes: all |
then type:
xrdb -load |
Here's the sample program:
/*------- fsb.c -------*/ #include <Xm/RowColumn.h> #include <Xm/Form.h> #include <Xm/PushB.h> #include <stdlib.h> #include <stdio.h> #include <Xm/FileSB.h> void printDirF( Widget w, XtPointer clientData, XmFileSelectionBoxCallbackStruct * cbs) { char * filename = NULL, * dirname = NULL; XmStringGetLtoR( cbs->value, XmFONTLIST_DEFAULT_TAG, &filename); XmStringGetLtoR( cbs->dir, XmFONTLIST_DEFAULT_TAG, &dirname); printf(“Filename selected: %s\n”, filename); if (filename) XtFree( filename ); if (dirname) XtFree( dirname ); } static void showDialog( Widget w, XtPointer clientData, XtPointer callData) { Widget dialog = (Widget) clientData; XtManageChild( dialog ); } main (int argc, char *argv[]) { Widget toplevel, fsb, b1, b2, rc; XtAppContext app; XmString textStr; XtSetLanguageProc( NULL, (XtLanguageProc)NULL, NULL); toplevel = XtVaAppInitialize( &app, “Fsb”, NULL, 0, &argc, argv, NULL, NULL); rc = XtVaCreateManagedWidget( “rc”, xmFormWidgetClass, toplevel, NULL); /* Set up a dialog */ if (argc > 1) { b1 = XtVaCreateManagedWidget( “FSB”, xmPushButtonWidgetClass, rc, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); fsb = XmCreateFileSelectionDialog( b1, “FSB Dialog”, NULL, 0); XtAddCallback( b1, XmNactivateCallback, showDialog, fsb); } else { fsb = XmCreateFileSelectionBox( rc, “Select A File”, NULL, 0); XtVaSetValues( fsb, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtManageChild( fsb ); } XtAddCallback( fsb, XmNokCallback, (XtCallbackProc)printDirF, fsb); XtAddCallback( fsb, XmNcancelCallback, (XtCallbackProc)exit, NULL); XtRealizeWidget( toplevel ); XtAppMainLoop( app ); } |
The following code produces a simple motif scale widget:
/* progress.c */ /* cc -o progress progress.c -lXm -lXt */ #include <Xm/Scale.h> void main(int argc, char** argv) { Widget toplevel, scale; XtAppContext app_context; Arg args[5]; int nargs=0; toplevel = XtAppInitialize(&app_context, “Progress”, NULL, 0, &argc, argv, NULL, NULL, 0); XtSetArg(args[nargs], XmNvalue, 50); nargs++; XtSetArg(args[nargs], XmNorientation, XmHORIZONTAL); nargs++; scale = XmCreateScale(toplevel, “scale”, args, nargs); XtManageChild(scale); XtRealizeWidget(toplevel); XtAppMainLoop(app_context); } |
The following resource file (named “Progress”) produces the slanted, thermometer look of the SGI percent done indicator. Also see the IRIS Viewkit VkProgressDialog class.
!Progress - App-default resources for the progress sample program *sgiMode: true *useSchemes: all !Change the appearance o the slider *scale.sliderVisual: flat_foreground *scale.slidingMode: thermometer *scale.slanted: true !Set the correct scheme colors Progress*scale*foreground: SGI_DYNAMIC BasicBackground Progress*scale*troughColor: SGI_DYNAMIC TextFieldBackground |