home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xtici.zip / xtici / layout.c < prev    next >
C/C++ Source or Header  |  1991-08-28  |  7KB  |  208 lines

  1. /*
  2.  * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
  3.  *     All Rights Reserved
  4.  * 
  5.  * This file is a component of an X Window System client which uses the Xcms 
  6.  * Color Management System.  TekColor is a trademark of Tektronix, Inc.  The
  7.  * TekColor Editor is the subject of U.S. and foreign patents pending.  The
  8.  * term "TekHVC" designates a particular color space that is the subject of
  9.  * U.S. Patent No. 4,985,853 (equivalent foreign patents pending).
  10.  * Permission is hereby granted to use, copy, modify, sell, and otherwise
  11.  * distribute this software and its documentation for the X Window System
  12.  * environment, for any purpose and without fee, provided that:
  13.  * 
  14.  * 1.    The code and documentation are only used to implement a 
  15.  *      TekColor Editor in an X Window System environment; and
  16.  * 2.    This copyright and permission notice is reproduced in all copies
  17.  *     of the code and in supporting documentation.
  18.  * 
  19.  * Permission is granted to modify this code as required to allow it to
  20.  * be compiled on any host computer, provided that the functionality of
  21.  * the TekColor Editor is not modified in any way.  A description of any 
  22.  * modifications must be sent to Tektronix, Inc.  Contact 
  23.  * Tektronix Inc., P.O. Box 1000, Mail Station 60-850, 
  24.  * Network Displays Division Engineering, Wilsonville, OR 97070.
  25.  *
  26.  * Tektronix makes no representation about the suitability of this software
  27.  * for any purpose.  It is provided "as is" and with all faults.
  28.  * 
  29.  * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
  30.  * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  31.  * PARTICULAR PURPOSE.  IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY
  32.  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  33.  * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF
  34.  * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  35.  * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
  36.  * 
  37.  *    NAME
  38.  *        layout - create the overall layout of the interface
  39.  *
  40.  *    DESCRIPTION
  41.  *        Create and position top levels of the interface.
  42.  *        Other creation routines within packages deal with lower
  43.  *        level pieces, such as the hue bar and leaf,
  44.  *        auxiliary window, etc.
  45.  */
  46. #ifndef LINT
  47. static char *copy_notice = "Copyright 1991 Tektronix, Inc.";
  48. #ifdef RCS_ID
  49. static char *rcsid=  "$Header: layout.c,v 1.2 91/08/22 11:33:46 adamsc Exp $";
  50. #endif /* RCS_ID */
  51. #endif /* LINT */
  52.  
  53. /*
  54.  *      EXTERNAL INCLUDES
  55.  */
  56.  
  57. /*
  58.  *      INTERNAL INCLUDES
  59.  */
  60. #include "xtici.h"
  61.  
  62. #include <X11/Intrinsic.h>
  63. #include <X11/Xaw/Form.h>
  64. #include <X11/Xaw/Text.h>    /* has XtNwrap definition */
  65.  
  66. #include "widgets/VShellP.h"
  67. #include "widgets/ColorS.h"
  68.  
  69. /*
  70.  *      EXTERNS
  71.  */
  72. extern char *exeName;
  73.  
  74. /*
  75.  *      GLOBALS
  76.  */
  77. #ifdef DEC
  78. #  define GLOBAL    global
  79. #else
  80. #  define GLOBAL
  81. #endif
  82.  
  83. GLOBAL Widget primary;
  84. /* interface widget children */
  85. GLOBAL Widget menubar, colormap, huebar, leaf, patch, hvcShow,uvyShow,rgbShow;
  86.  
  87. /*
  88.  *      LOCAL DEFINES
  89.  */
  90.  
  91. /*
  92.  *      LOCAL TYPEDEFS
  93.  */
  94.  
  95. /*
  96.  *      LOCALS VARIABLES
  97.  */
  98. #ifdef DEBUG
  99. #  define STATIC
  100. #else
  101. #  define STATIC        static
  102. #endif
  103.  
  104. STATIC Arg mapArgs[] = {
  105.     {XtNmaximum, 255},
  106.     {XtNzoom, 32},
  107.     {XtNwidth, 185},
  108.     {XtNlabel, (XtArgVal)"Colormap\nScale"},
  109. };
  110.  
  111. STATIC Arg hueArgs[] = {
  112.     {XtNbase, 0},
  113.     {XtNlength, 1},
  114.     {XtNlabel, (XtArgVal)"HUE"},
  115.     {XtNmaximum, 3599},
  116.     {XtNincrement, 10},
  117.     {XtNwrap, True},
  118.     {XtNwidth, 95},
  119. };
  120.  
  121.  
  122. /************************************************************************
  123.  *                                    *
  124.  *            PRIVATE ROUTINES                *
  125.  *                                    *
  126.  ************************************************************************/
  127. STATIC void CreateIfWindow(parent)
  128. Widget parent;
  129. {
  130. #define WidgetCt 6
  131.     Widget CreateLeafForm(), CreatePatch(), CreateShowWidgets();
  132.     Widget CreateHueForm();
  133.     void ChangedIndex();        /* callback */
  134.     Widget wlist[WidgetCt];
  135.     Pixel back;
  136.     Arg barg;
  137.  
  138.     mapArgs[0].value = (XtArgVal)(mapSize - 1);
  139.     /* shows 32 colors in the zoom bar */
  140.     mapArgs[1].value = (XtArgVal)(mapSize / 32);
  141.     colormap = XtCreateManagedWidget("scale", colorScaleWidgetClass, parent,
  142.                     mapArgs, XtNumber(mapArgs));
  143.     XtAddCallback(colormap, XtNvalueChangedCallback, ChangedIndex,
  144.           (XtPointer)ColormapWidget);
  145.     wlist[ColormapWidget] = colormap;
  146.  
  147.     /* set real widget attachment values */
  148.     wlist[ShowWidget] = CreateShowWidgets(parent);
  149.  
  150.     wlist[PatchWidget] = patch = CreatePatch(parent);
  151.  
  152.     /* If huebar starts empty set the base to the background of the widget */
  153.     if (huebarState == HuebarEmpty) {
  154.     XtSetArg(barg, XtNbackground, &back);
  155.     XtGetValues(parent, &barg, 1);
  156.     hueArgs[0].value = (XtArgVal)back;
  157.     } else /* if (huebarState == HuebarConstant) */ {
  158.     HuebarRangeSave();
  159.     HuebarRangeLoad((Pixel *)&hueArgs[0].value, (int *)&hueArgs[1].value);
  160.     }
  161.     wlist[HuebarWidget] = huebar = CreateHueForm(parent, "huebar", 
  162.                          hueArgs, XtNumber(hueArgs));
  163.  
  164.     wlist[LeafWidget] = leaf = CreateLeafForm(parent, "leaf");
  165. }
  166.  
  167. /************************************************************************
  168.  *                                    *
  169.  *            PUBLIC ROUTINES                 *
  170.  *                                    *
  171.  ************************************************************************/
  172. Widget LayoutWidgets()
  173. {
  174.     Arg shellArgs[15];
  175.     Widget CreateMenuBar();
  176.     Widget toplevel;
  177.     int argCt = 0;
  178.  
  179.     /* Create a shell widget and its main window child */
  180.     XtSetArg(shellArgs[argCt], XtNcolormap, cmap);            argCt++;
  181.     XtSetArg(shellArgs[argCt], XtNdepth, visInfo.depth);        argCt++;
  182.     XtSetArg(shellArgs[argCt], XtNvisual, visInfo.visual);        argCt++;
  183.     XtSetArg(shellArgs[argCt], XtNtitle, "TekColor Editor");        argCt++;
  184.     XtSetArg(shellArgs[argCt], XtNiconPixmap, MakeIcon());        argCt++;
  185.     XtSetArg(shellArgs[argCt], XtNiconName, exeName);            argCt++;
  186.     /**********************************************************************
  187.      * I know you expect the user to be able to set all this
  188.      * But no inorder to maintain the aspect ratio of the widgets
  189.      * and the minimum size so there is no overlap I will not allow you
  190.      * to reset these resources.
  191.      **********************************************************************/
  192.     XtSetArg(shellArgs[argCt], XtNwidth, 560);                argCt++;
  193.     XtSetArg(shellArgs[argCt], XtNheight, 450);                argCt++;
  194.     toplevel = XtAppCreateShell(exeName, "TekHVC", visualShellWidgetClass,
  195.                     dpy, shellArgs, argCt);
  196.  
  197.     primary = XtCreateManagedWidget("main", tekBoxWidgetClass, toplevel, 
  198.                     NULL, 0);
  199.  
  200.     /* Create the menu bar, including all menus and dialogs */
  201.     menubar = CreateMenuBar(primary);
  202.  
  203.     /* Create the working area form widget */
  204.     CreateIfWindow(primary);
  205.  
  206.     return(toplevel);
  207. }
  208.