home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / Microline3.0 / examples / grid5.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.2 KB  |  203 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * The following source code is part of the Microline Widget Library.
  21.  * The Microline widget library is made available to Mozilla developers
  22.  * under the Netscape Public License (NPL) by Neuron Data.  To learn
  23.  * more about Neuron Data, please visit the Neuron Data Home Page at
  24.  * http://www.neurondata.com.
  25.  */
  26.  
  27.  
  28. #include <Xm/Xm.h>
  29. #include <XmL/Grid.h>
  30.  
  31. #define TITLEFONT "-*-helvetica-bold-r-*--*-140-*-*-*-*-iso8859-1"
  32. #define BOLDFONT "-*-helvetica-bold-r-*--*-120-*-*-*-*-iso8859-1"
  33. #define TEXTFONT "-*-helvetica-medium-r-*--*-100-*-*-*-*-iso8859-1"
  34.  
  35. static char *data =
  36. "|1996 Income Summary\n\
  37. |Shampoo|Conditioner|Soap|Total\n\
  38. Revenues:\n\
  39. Sales|$ 1,600,000|$ 1,000,000|$  800,000|$ 3,400,000\n\
  40. Less Discounts|(16,000)|(10,000)|(8,000)|(34,000)\n\
  41. Less Return Allowance|(8,000)|(5,000)|(4,000)|(17,000)\n\
  42.   Net Revenue|1,576,000|985,000|792,000|3,349,000\n\
  43. \n\
  44. Less Expenses:\n\
  45. Cost of Goods Sold|(640,000)|(330,000)|(264,000)|(1,234,000)\n\
  46. Salary Expense|(380,000)|(280,000)|(180,000)|(840,000)\n\
  47. Marketing Expense|(157,600)|(98,500)|(79,200)|(335,300)\n\
  48. Rent Expense|(36,000)|(36,000)|(36,000)|(108,000)\n\
  49. Misc. Other Expense|(36,408)|(22,335)|(16,776)|(75,519)\n\
  50.   Total Expenses|(1,250,008)|(766,835)|(575,976)|(2,592,819)\n\
  51. \n\
  52. Income Tax Expense|(130,397)|(87,266)|(86,410)|(304,072)\n\
  53. Net Income|195,595|130,899|129,614|456,109";
  54.  
  55. main(argc, argv)
  56. int argc;
  57. char *argv[];
  58. {
  59.     XtAppContext app;
  60.     Widget shell, grid;
  61.     int i, r;
  62.  
  63.     shell =  XtAppInitialize(&app, "Grid5", NULL, 0,
  64.         &argc, argv, NULL, NULL, 0);
  65.  
  66.     grid = XtVaCreateManagedWidget("grid",
  67.         xmlGridWidgetClass, shell,
  68.         XtVaTypedArg, XmNbackground, XmRString, "#C0C0C0", 8,
  69.         XtVaTypedArg, XmNforeground, XmRString, "black", 6,
  70.         XmNheadingColumns, 1,
  71.         XmNcolumns, 3,
  72.         XmNfooterColumns, 1,
  73.         XmNsimpleWidths, "24c 11c 11c 11c 11c",
  74.         XmNvisibleColumns, 10,
  75.         XmNvisibleRows, 14,
  76.         XtVaTypedArg, XmNfontList, XmRString, TEXTFONT,
  77.         strlen(TEXTFONT) + 1,
  78.         XmNselectionPolicy, XmSELECT_NONE,
  79.         NULL);
  80.  
  81.     XtVaSetValues(grid,
  82.         XmNlayoutFrozen, True,
  83.         NULL);
  84.  
  85.     /* Add 'Income Summary' heading row with yellow background */
  86.     XtVaSetValues(grid, 
  87.         XmNcellDefaults, True,
  88.         XtVaTypedArg, XmNcellBackground, XmRString, "#FFFF00", 8,
  89.         XtVaTypedArg, XmNcellForeground, XmRString, "#000080", 8,
  90.         XmNcellLeftBorderType, XmBORDER_NONE,
  91.         XmNcellRightBorderType, XmBORDER_NONE,
  92.         XmNcellTopBorderType, XmBORDER_NONE,
  93.         XtVaTypedArg, XmNcellBottomBorderColor, XmRString, "black", 6,
  94.         XmNcellAlignment, XmALIGNMENT_CENTER,
  95.         NULL);
  96.     XmLGridAddRows(grid, XmHEADING, -1, 1);
  97.  
  98.     /* Set span on '1996 Income Summary' cell in heading row */
  99.     XtVaSetValues(grid,
  100.         XmNrowType, XmHEADING,
  101.         XmNrow, 0,
  102.         XmNcolumn, 0,
  103.         XmNcellColumnSpan, 2,
  104.         XtVaTypedArg, XmNcellFontList, XmRString, TITLEFONT,
  105.         strlen(TITLEFONT) + 1,
  106.         NULL);
  107.  
  108.     /* Add 'Shampoo Conditioner Soap' heading row with white background */
  109.     XtVaSetValues(grid, 
  110.         XmNcellDefaults, True,
  111.         XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
  112.         strlen(BOLDFONT) + 1,
  113.         XtVaTypedArg, XmNcellBackground, XmRString, "white", 6,
  114.         XtVaTypedArg, XmNcellForeground, XmRString, "black", 6,
  115.         XmNcellBottomBorderType, XmBORDER_NONE,
  116.         NULL);
  117.     XmLGridAddRows(grid, XmHEADING, -1, 1);
  118.  
  119.     /* Add content and footer rows with heading column 0 left justified */
  120.     XtVaSetValues(grid,
  121.         XmNcellDefaults, True,
  122.         XmNcellAlignment, XmALIGNMENT_RIGHT,
  123.         XtVaTypedArg, XmNcellFontList, XmRString, TEXTFONT,
  124.         strlen(TEXTFONT) + 1,
  125.         NULL);
  126.     XtVaSetValues(grid,
  127.         XmNcellDefaults, True,
  128.         XmNcolumnType, XmHEADING,
  129.         XmNcolumn, 0,
  130.         XmNcellAlignment, XmALIGNMENT_LEFT,
  131.         NULL);
  132.     XmLGridAddRows(grid, XmCONTENT, -1, 15);
  133.  
  134.     /* Add footer row with blue background */
  135.     XtVaSetValues(grid,
  136.         XmNcellDefaults, True,
  137.         XtVaTypedArg, XmNcellForeground, XmRString, "white", 6,
  138.         XtVaTypedArg, XmNcellBackground, XmRString, "#000080", 8,
  139.         XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
  140.         strlen(BOLDFONT) + 1,
  141.         NULL);
  142.     XmLGridAddRows(grid, XmFOOTER, -1, 1);
  143.  
  144.     /* Bold 'Revenues' cell */
  145.     XtVaSetValues(grid,
  146.         XmNcolumnType, XmHEADING,
  147.         XmNcolumn, 0,
  148.         XmNrow, 0,
  149.         XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
  150.         strlen(BOLDFONT) + 1,
  151.         NULL);
  152.  
  153.     /* Bold 'Less Expenses' cell */
  154.     XtVaSetValues(grid,
  155.         XmNcolumnType, XmHEADING,
  156.         XmNcolumn, 0,
  157.         XmNrow, 6,
  158.         XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
  159.         strlen(BOLDFONT) + 1,
  160.         NULL);
  161.  
  162.     /* Grey middle and footer content column */
  163.     XtVaSetValues(grid,
  164.         XmNcolumnType, XmALL_TYPES,
  165.         XmNcolumnRangeStart, 2,
  166.         XmNcolumnRangeEnd, 4,
  167.         XmNcolumnStep, 2,
  168.         XtVaTypedArg, XmNcellBackground, XmRString, "#E8E8E8", 8,
  169.         NULL);
  170.  
  171.     /* Grey 'Conditioner' and 'Total' cell in heading row 1 */
  172.     XtVaSetValues(grid,
  173.         XmNrowType, XmHEADING,
  174.         XmNrow, 1,
  175.         XmNcolumnType, XmALL_TYPES,
  176.         XmNcolumnRangeStart, 2,
  177.         XmNcolumnRangeEnd, 4,
  178.         XmNcolumnStep, 2,
  179.         XtVaTypedArg, XmNcellBackground, XmRString, "#E8E8E8", 8,
  180.         NULL);
  181.  
  182.     /* Blue and bold 'Net Revenue' and 'Total Expenses' rows */
  183.     XtVaSetValues(grid,
  184.         XmNrowRangeStart, 4,
  185.         XmNrowRangeEnd, 12,
  186.         XmNrowStep, 8,
  187.         XmNcolumnType, XmALL_TYPES,
  188.         XtVaTypedArg, XmNcellForeground, XmRString, "white", 6,
  189.         XtVaTypedArg, XmNcellBackground, XmRString, "#000080", 8,
  190.         XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
  191.         strlen(BOLDFONT) + 1,
  192.         NULL);
  193.  
  194.     XtVaSetValues(grid,
  195.         XmNlayoutFrozen, False,
  196.         NULL);
  197.  
  198.     XmLGridSetStrings(grid, data);
  199.  
  200.     XtRealizeWidget(shell);
  201.     XtAppMainLoop(app);
  202. }
  203.