home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 45 / PCGAMER45.bin / netware / msie4pp / ie4_s3.cab / IE4_3.CAB / MSHTMENU.DLL / 2110 / FORCHAR.DLG < prev    next >
Text File  |  1997-04-04  |  41KB  |  1,256 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
  2. <HTML id=dlgFont STYLE="font-family: 'ms sans serif'; font-size: '8pt';
  3. width: '45.1em'; height: '38.99em'">
  4. <HEAD>
  5. <TITLE id=dialogTitle>
  6. Font
  7. </TITLE>
  8. </HEAD>
  9.  
  10. <SCRIPT LANGUAGE="JavaScript" defer>
  11.  
  12. //+-------------------------------------------------------------------------
  13. //
  14. //  This section contains code to be moved into a GLOBAL MODULE outside
  15. //  of this particular dialog.
  16. //
  17. //--------------------------------------------------------------------------
  18.  
  19.  
  20.     //----------------------------------------------------------------------
  21.     //
  22.     //  Synopsis:   Turns on the document's expando property.  When this
  23.     //              property is on, it is possible to create new expando
  24.     //              properties or assign to existing ones.
  25.     //
  26.     //  Arguments:  none
  27.     //
  28.     //  Returns:    Nothing
  29.     //
  30.     //----------------------------------------------------------------------
  31.  
  32.     function expandoOn()
  33.     {
  34.         document.expando = true;
  35.     }   //  expandoOn
  36.  
  37.  
  38.     //----------------------------------------------------------------------
  39.     //
  40.     //  Synopsis:   Turns off the document's expando property.  When this
  41.     //              property is off, it is possible to read the value of
  42.     //              existing expando properties, but not possible to create
  43.     //              new ones or modify existing ones.
  44.     //
  45.     //              EXPANDO SHOULD BE OFF EXCEPT WHEN CREATING/MODIFYING
  46.     //              EXPANDO PROPERTIES.  This will save hours debugging
  47.     //              accidentally created expando properties.
  48.     //
  49.     //  Arguments:  none
  50.     //
  51.     //  Returns:    Nothing.
  52.     //
  53.     //----------------------------------------------------------------------
  54.  
  55.     function expandoOff()
  56.     {
  57.         document.expando = false;
  58.     }   //  expandoOff
  59.  
  60.  
  61.     //+----------------------------------------------------------------------
  62.     //
  63.     //  Synopsis:   Sets the state of a checkbox based on a range and a
  64.     //              command id. The command ID comes from the VALUE of
  65.     //              the checkbox.
  66.     //
  67.     //  Arguments:  checkbox    The checkbox we're partying on
  68.     //              range       The range we're querying the status of
  69.     //
  70.     //  Returns:    nothing
  71.     //
  72.     //-----------------------------------------------------------------------
  73.  
  74.     function getCheckStateCmd(checkbox, range)
  75.     {
  76.         checkbox.checked = (true == range.queryCommandState(checkbox.value));
  77.     }   //  getCheckStateCmd
  78.  
  79.  
  80.     //+----------------------------------------------------------------------
  81.     //
  82.     //  Synopsis:   Sets the state of a select box based on a range and a
  83.     //              command id. The command ID comes from the ID of the
  84.     //              select box. (It's prefixed by "cmd".) NOTE: The VALUEs
  85.     //              of OPTIONs of the SELECT box must be set to the possible
  86.     //              return values of the queryCommandValue method.
  87.     //
  88.     //  Arguments:  radio   The select box we're partying on
  89.     //              range   The range we're querying the status of
  90.     //
  91.     //  Returns:    nothing
  92.     //
  93.     //-----------------------------------------------------------------------
  94.  
  95.     function getSelectStateCmd(select, range)
  96.     {
  97.         var index;
  98.  
  99.         for (index = 0; index < select.options.length; index++)
  100.         {
  101.             if ((select.options[index].value) ==
  102.                 (range.queryCommandValue(select.id.substring(3))))
  103.             {
  104.                 select.selectedIndex = index;
  105.                 break;
  106.             }
  107.         }
  108.     }   //  getSelectStateCmd
  109.  
  110.  
  111.     //-----------------------------------------------------------------------
  112.     //
  113.     //  Synopsis:   Takes an element and a range and sets the state of the
  114.     //              element based on the state of the range.
  115.     //              HOW IT WORKS: See comments in the code.
  116.     //
  117.     //  Arguments:  element     The element we're setting
  118.     //              range       The range we're querying the status of.
  119.     //
  120.     //  Returns:    nothing
  121.     //
  122.     //-----------------------------------------------------------------------
  123.  
  124.     function getStateCmd(element, range)
  125.     {
  126.         //
  127.         //  Checkboxes with a name of "setCmdId" are set based on the command
  128.         //  id in their VALUE attribute.
  129.         //
  130.         if (("checkbox" == element.type) && ("setCmdID" == element.name))
  131.         {
  132.             getCheckStateCmd(element, range);
  133.         }
  134.  
  135.         //
  136.         //  SELECT boxes with the name "setCmdID" are set based on the command
  137.         //  id in their ID property (minus the "cmd" prefix). See the notes in
  138.         //  the getSelectStateCmd function for more info.
  139.         //
  140.         else if (("SELECT" == element.tagName) && ("setCmdID" == element.name))
  141.         {
  142.             getSelectStateCmd(element, range);
  143.         }
  144.     }   //  getStateCmd
  145.  
  146.  
  147.     //+----------------------------------------------------------------------
  148.     //
  149.     //  Synopsis:   Loops through all the elements in the dialog and sets the
  150.     //              appropriate elements based on the type and properties of
  151.     //              the element.
  152.     //
  153.     //  Arguments:  none
  154.     //
  155.     //  Returns:    nothing
  156.     //
  157.     //-----------------------------------------------------------------------
  158.  
  159.     function initDialogCmd()
  160.     {
  161.         var index;
  162.  
  163.         for (index = 0; index < document.all["setCmdID"].length; index++)
  164.         {
  165.             getStateCmd(document.all["setCmdID"][index],
  166.                 globalDoc.selection.createRange());
  167.         }
  168.  
  169.     }   //  initDialogCmd
  170.  
  171.  
  172.     //+----------------------------------------------------------------------
  173.     //
  174.     //  Synopsis:   Sets the state of a range based on the state of a checkbox
  175.     //              and a command id. The command id comes from the VALUE of
  176.     //              the checkbox.
  177.     //
  178.     //  Arguments:  checkbox:   The checkbox we're querying the status of.
  179.     //              range:      The range we're partying on.
  180.     //
  181.     //  Returns:    nothing
  182.     //
  183.     //-----------------------------------------------------------------------
  184.  
  185.     function setCheckStateCmd(checkbox, range)
  186.     {
  187.         if (checkbox.checked !=
  188.             (true == range.queryCommandState(checkbox.value)))
  189.         {
  190.             range.execCommand(checkbox.value, false);
  191.         }
  192.     }   //  setCheckStateCmd
  193.  
  194.  
  195.     //+---------------------------------------------------------------------
  196.     //
  197.     //  Synopsis:   Sets the state of a range based on the selection in a
  198.     //              SELECT box and a command id. The command id comes from
  199.     //              the ID of the SELECT box (minus the "cmd" prefix).
  200.     //              NOTE: The VALUEs of the OPTIONs of the SELECT box must
  201.     //              be set to the possible values for the execCommand
  202.     //              method.
  203.     //
  204.     //  Arguments:  select  The select box we're querying the value of.
  205.     //              range   The range we're partying on.
  206.     //
  207.     //  Returns:    nothing
  208.     //
  209.     //-----------------------------------------------------------------------
  210.  
  211.     function setSelectStateCmd(select, range)
  212.     {
  213.         range.execCommand(select.id.substring(3), false,
  214.             select.options[select.selectedIndex].value);
  215.     }   //  setSelectStateCmd
  216.  
  217.  
  218.     //------------------------------------------------------------------------
  219.     //
  220.     //  Synopsis:   Takes an element and a range and sets the state of the
  221.     //              range based on the state of the element.
  222.     //              HOW IT WORKS: See comments in the code.
  223.     //
  224.     //  Arguments:  element     The element we're querying the status of.
  225.     //              range       The range we're partying on.
  226.     //
  227.     //  Returns:    nothing
  228.     //
  229.     //------------------------------------------------------------------------
  230.  
  231.     function setStateCmd(element, range)
  232.     {
  233.         //
  234.         //  Checkboxes with a name of "setCmdID" effect the range based on
  235.         //  the command id in their VALUE attribute.
  236.         //
  237.         if (("checkbox" == element.type) && ("setCmdID" == element.name))
  238.         {
  239.             setCheckStateCmd(element, range);
  240.         }
  241.  
  242.         //
  243.         //  SELECT boxes with a name of "setCmdID" effect the range based on
  244.         //  the command id in their ID property (minus the "cmd" prefix).
  245.         //  See the notes in the setSelectStateCmd function for more info.
  246.         //
  247.         else if (("SELECT" == element.tagName) && ("setCmdID" == element.name))
  248.         {
  249.             setSelectStateCmd(element, range);
  250.         }
  251.     }   //  setStateCmd
  252.  
  253.  
  254.     //+----------------------------------------------------------------------
  255.     //
  256.     //  Synopsis:   Loops through all the elements in the dialog and sets the
  257.     //              properties of the document based on the type and properties
  258.     //              of the element.
  259.     //
  260.     //  Arguments:  none
  261.     //
  262.     //  Returns:    nothing
  263.     //
  264.     //-----------------------------------------------------------------------
  265.  
  266.     function closeDialogCmd()
  267.     {
  268.         var index;
  269.  
  270.         for (index = 0; index < document.all["setCmdID"].length; index++)
  271.         {
  272.             setStateCmd(document.all["setCmdID"][index],
  273.                 globalDoc.selection.createRange());
  274.         }
  275.     }   //  closeDialogCmd
  276.  
  277.  
  278.     //----------------------------------------------------------------------
  279.     //
  280.     //  Synopsis:   Sort a one dimensional array alphabetically.
  281.     //
  282.     //  Arguments:  arr     The array to be sorted
  283.     //
  284.     //  Returns:    The sorted array.
  285.     //
  286.     //----------------------------------------------------------------------
  287.  
  288.     function sortArray(arr)
  289.     {
  290.         var     index1;
  291.         var     index2;
  292.         var     arrLength = 0;
  293.         var     tempValue;
  294.  
  295.         for (index1 in arr)
  296.         {
  297.             arrLength++
  298.         }
  299.  
  300.         for (index1 = 1; index1 < arrLength; index1++)
  301.         {
  302.             tempValue = arr[index1]
  303.  
  304.             for (index2 = index1 - 1;
  305.                  index2 >= 0 && tempValue < arr[index2];
  306.                  index2--)
  307.             {
  308.                 arr[index2 + 1] = arr[index2];
  309.             }
  310.  
  311.             arr[index2 + 1] = tempValue
  312.         }
  313.  
  314.         return arr;
  315.     }   //  sortArray
  316.  
  317.  
  318.     //+--------------------------------------------------------------------
  319.     //
  320.     //  Synopsis:   Selects the text in the control
  321.     //
  322.     //  Arguments:  ctl     The control we're selecting the text in
  323.     //
  324.     //  Returns:    nothing
  325.     //
  326.     //---------------------------------------------------------------------
  327.  
  328.     function selectText(ctl)
  329.     {
  330.         // ctl.select();
  331.     }   //  selectText
  332.  
  333.  
  334. //+------------------------------------------------------------------------
  335. //
  336. //  This section contains variables that need to be LOCALIZED
  337. //
  338. //-------------------------------------------------------------------------
  339.  
  340. var L_NoHelp_Text = "No help topic available.";
  341.  
  342. //+-------------------------------------------------------------------------
  343. //
  344. //  This section contains code LOCAL to this particular dialog.
  345. //
  346. //--------------------------------------------------------------------------
  347.  
  348.     expandoOff();
  349.  
  350.     //  Constants
  351.         var cmdForeColor    = 55;
  352.         var cmdFontSize     = 19;
  353.         var cmdBold         = "Bold";
  354.         var cmdItalic       = "Italic";
  355.         var cmdFontName     = 18;
  356.  
  357.     //  Global variables
  358.         var globalDoc = window.dialogArgs.document;    //  The document we're
  359.                                                        //   working on.
  360.         var gintCustomColor                     //  If the font is a custom
  361.                                                 //  color, store it here.
  362.         var gstrFontNormal      ="";            //  The font of the text when
  363.                                                 //  the dialog is selected.
  364.         var gboolUpdateText                     //  Whether to update textboxes
  365.         var gboolUpdateColor                    //  Whether to update the
  366.                                                 //  font color
  367.         var gboolUpdateSize                     //  Whether to update the
  368.                                                 //  font size
  369.  
  370.  
  371.     //+-----------------------------------------------------------------------
  372.     //
  373.     //  Synopsis:   Fills the passed in select box with all the fonts installed
  374.     //              on the system.
  375.     //
  376.     //  Arguments:  select  The select box we're filling with the font names
  377.     //
  378.     //  Returns:    nothing
  379.     //
  380.     //------------------------------------------------------------------------
  381.  
  382.     function fillFontSelect(select)
  383.     {
  384.         var index;
  385.         var range = globalDoc.selection.createRange();
  386.         var fontList = new Array();
  387.         var optFontName;
  388.  
  389.         for (index = 0; index < window.dialogArgs.fonts.length; index++)
  390.         {
  391.             fontList[index] = window.dialogArgs.fonts.item(index);
  392.         }
  393.  
  394.         fontList = sortArray(fontList);
  395.  
  396.         for (index = 0; index < window.dialogArgs.fonts.length; index++)
  397.         {
  398.             optFontName = new Option();
  399.             optFontName.value = fontList[index];
  400.             optFontName.text = fontList[index];
  401.  
  402.             select.options[index + 1] = optFontName;
  403.         }
  404.     }   //  fillFontSelect
  405.  
  406.  
  407.     //+-----------------------------------------------------------------------
  408.     //
  409.     //  Synopsis:   Looks at the currently selected text and set selFontStyle
  410.     //              appropriately
  411.     //
  412.     //  Arguments:  none.
  413.     //
  414.     //  Returns:    nothing
  415.     //
  416.     //------------------------------------------------------------------------
  417.  
  418.     function getFontStyle()
  419.     {
  420.         var range = globalDoc.selection.createRange();
  421.  
  422.         with range
  423.         {
  424.             if (queryCommandState(cmdBold) && queryCommandState(cmdItalic))
  425.             {
  426.                 selFontStyle.value = "Bold-Italic";
  427.             }
  428.             else if (queryCommandState(cmdBold))
  429.             {
  430.                 selFontStyle.value = "Bold";
  431.             }
  432.             else if (queryCommandState(cmdItalic))
  433.             {
  434.                 selFontStyle.value = "Italic";
  435.             }
  436.             else
  437.             {
  438.                 selFontStyle.value = "Regular";
  439.             }
  440.         }
  441.     }   //  getFontStyle
  442.  
  443.  
  444.     //+-----------------------------------------------------------------------
  445.     //
  446.     //  Synopsis:   Sets the current selection to bold or italic based on the
  447.     //              setting of selFontStyle.
  448.     //
  449.     //  Arguments:  range   The range we're partying on.
  450.     //
  451.     //  Returns:    nothing
  452.     //
  453.     //------------------------------------------------------------------------
  454.  
  455.     function setFontStyle(range)
  456.     {
  457.         with range
  458.         {
  459.             if ("Bold-Italic" == selFontStyle.value)
  460.             {
  461.                 if (true != queryCommandState(cmdBold))
  462.                 {
  463.                     execCommand(cmdBold, false);
  464.                 }
  465.                 if (true != queryCommandState(cmdItalic))
  466.                 {
  467.                     execCommand(cmdItalic, false);
  468.                 }
  469.             }
  470.             else if ("Bold" == selFontStyle.value)
  471.             {
  472.                 if (true != queryCommandState(cmdBold))
  473.                 {
  474.                     execCommand(cmdBold, false);
  475.                 }
  476.                 if (true == queryCommandState(cmdItalic))
  477.                 {
  478.                     execCommand(cmdItalic, false);
  479.                 }
  480.             }
  481.             else if ("Italic" == selFontStyle.value)
  482.             {
  483.                 if (true == queryCommandState(cmdBold))
  484.                 {
  485.                     execCommand(cmdBold, false);
  486.                 }
  487.                 if (true != queryCommandState(cmdItalic))
  488.                 {
  489.                     execCommand(cmdItalic, false);
  490.                 }
  491.             }
  492.             else
  493.             {
  494.                 if (true == queryCommandState(cmdBold))
  495.                 {
  496.                     execCommand(cmdBold, false);
  497.                 }
  498.                 if (true == queryCommandState(cmdItalic))
  499.                 {
  500.                     execCommand(cmdItalic, false);
  501.                 }
  502.             }
  503.         }
  504.     }   //  setFontStyle
  505.  
  506.  
  507.     //+----------------------------------------------------------------------
  508.     //
  509.     //  Synopsis:   Sets the state of selColor based on the color of the
  510.     //              selected font.
  511.     //
  512.     //  Arguments:  none
  513.     //
  514.     //  Returns:    nothing
  515.     //
  516.     //-----------------------------------------------------------------------
  517.  
  518.     function getFontColor()
  519.     {
  520.         var range = globalDoc.selection.createRange();
  521.         var intColor = range.queryCommandValue(cmdForeColor);
  522.  
  523.         if (-1 != intColor)
  524.         {
  525.             gboolUpdateColor = true;
  526.             selColor.value = intColor;
  527.  
  528.             if (parseInt(selColor.value) != parseInt(intColor))
  529.             {
  530.                 gintCustomColor = intColor;
  531.                 selColor.value = "custom";
  532.             }
  533.         }
  534.     }   //  getFontColor
  535.  
  536.  
  537.     //+--------------------------------------------------------------------------
  538.     //
  539.     //  Synopsis:   Sets the color of the selected text based on the selection
  540.     //              in selColor.
  541.     //
  542.     //  Arguments:  range   The range we're partying on.
  543.     //
  544.     //  Returns:    nothing
  545.     //
  546.     //---------------------------------------------------------------------------
  547.  
  548.     function setFontColor(range)
  549.     {
  550.         var intDefaultColor = 33554432;
  551.  
  552.         if (gboolUpdateColor)
  553.         {
  554.             if ("custom" == selColor.value)
  555.             {
  556.                 range.execCommand(cmdForeColor, false,
  557.                     parseInt(gintCustomColor));
  558.                 return;
  559.             }
  560.             else if ("default" == selColor.value)
  561.             {
  562.                 range.execCommand(cmdForeColor, false, intDefaultColor);
  563.                 return;
  564.             }
  565.             else
  566.             {
  567.                 range.execCommand(cmdForeColor, false,
  568.                     parseInt(selColor.value));
  569.             }
  570.         }
  571.     }   //  setFontColor
  572.  
  573.  
  574.     //+----------------------------------------------------------------------
  575.     //
  576.     //  Synopsis:   Sets selFontSize to the size of the selected text.
  577.     //
  578.     //  Arguments:  none
  579.     //
  580.     //  returns:    nothing
  581.     //
  582.     //-----------------------------------------------------------------------
  583.  
  584.     function getFontSize()
  585.     {
  586.         var range = globalDoc.selection.createRange();
  587.         var arrSize = new Array();
  588.  
  589.         //
  590.         //  Set up arrSize
  591.         //
  592.         arrSize[-2] = "Smallest";
  593.         arrSize[-1] = "Smaller";
  594.         arrSize[0]  = "Normal";
  595.         arrSize[1]  = "Large";
  596.         arrSize[2]  = "Larger";
  597.         arrSize[3]  = "Largest";
  598.         arrSize[4]  = "Huge";
  599.  
  600.         if ((range.queryCommandValue(cmdFontSize) <= 4) &&
  601.             (range.queryCommandValue(cmdFontSize) >= -2))
  602.         {
  603.             selFontSize.value = arrSize[range.queryCommandValue(cmdFontSize)];
  604.             gboolUpdateSize = true;
  605.         }
  606.  
  607.     }   //  getFontSize
  608.  
  609.  
  610.     //+----------------------------------------------------------------------
  611.     //
  612.     //  Synopsis:   Sets the size of the selected text to the current
  613.     //              selection in selFontSize
  614.     //
  615.     //  Arguments:  Why can't we all just get along? (none)
  616.     //
  617.     //  Returns:    At the customer service desk. (nothing)
  618.     //
  619.     //-----------------------------------------------------------------------
  620.  
  621.     function setFontSize(range)
  622.     {
  623.         var arrSize = new Array();
  624.  
  625.         //
  626.         //  Set up arrSize
  627.         //
  628.         arrSize["Smallest"] = -2;
  629.         arrSize["Smaller"]  = -1;
  630.         arrSize["Normal"]   = 0;
  631.         arrSize["Large"]    = 1;
  632.         arrSize["Larger"]   = 2;
  633.         arrSize["Largest"]  = 3;
  634.         arrSize["Huge"]     = 4;
  635.  
  636.         if (gboolUpdateSize)
  637.         {
  638.             range.execCommand(cmdFontSize, false, arrSize[selFontSize.value]);
  639.         }
  640.     }   //  setFontSize()
  641.  
  642.  
  643.     //+----------------------------------------------------------------------
  644.     //
  645.     //  Synopsis:   Check to see if "Custom" is selected in selColor. If it
  646.     //              is, launch the choose color dialog.
  647.     //
  648.     //  Arguments:  None
  649.     //
  650.     //  Returns:    nothing
  651.     //
  652.     //-----------------------------------------------------------------------
  653.  
  654.     function customColor()
  655.     {
  656.         if ("custom" == selColor.value)
  657.         {
  658.             gintCustomColor = window.dialogArgs.choosecolordlg(gintCustomColor);
  659.         }
  660.     }   //  customColor
  661.  
  662.  
  663.     //+----------------------------------------------------------------------
  664.     //
  665.     //  Synopsis:   Fills a text box with the value of the calling control
  666.     //              (which should be a select box).
  667.     //
  668.     //  Arguments:  ctlSelect   The select box we're getting the value from
  669.     //              ctlText     The text box we're filling
  670.     //
  671.     //  Returns:    nothing
  672.     //
  673.     //-----------------------------------------------------------------------
  674.  
  675.     function syncSelect(ctlSelect, ctlText)
  676.     {
  677.         if (gboolUpdateText)
  678.         {
  679.             ctlText.value = ctlSelect.options[ctlSelect.selectedIndex].text;
  680.         }
  681.     }   //  syncSelect
  682.  
  683.  
  684.     //+-----------------------------------------------------------------------
  685.     //
  686.     //  Synopsis:   Takes a string and an options collection and finds the
  687.     //              index of the option whose VALUE best matches the string
  688.     //
  689.     //  Arguments:  strMatch        The string we're looking for a match to
  690.     //              optionsList     The options collection we're looking for
  691.     //                              the match in
  692.     //
  693.     //  Returns:    an integer representing the index of option that best
  694.     //              matches the string.
  695.     //
  696.     //------------------------------------------------------------------------
  697.  
  698.     function findMatch (strMatch, optionsList)
  699.     {
  700.         var index;
  701.         var index2;
  702.         var bestChar    =   0;
  703.         var bestMatch   =   0;
  704.  
  705.         for (index = 0; index < optionsList.length; index++)
  706.         {
  707.             for (index2 = bestChar; index2 < strMatch.length; index2++)
  708.             {
  709.                 if (strMatch.substring(0, index2 + 1).toLowerCase() ==
  710.                     optionsList.options[index].text.substring(0, index2 + 1)
  711.                         .toLowerCase())
  712.                 {
  713.                     bestChar = index2 + 1;
  714.                     bestMatch = index;
  715.                 }
  716.                 else
  717.                 {
  718.                     break;
  719.                 }
  720.             }
  721.         }
  722.         return bestMatch;
  723.     }   //  findMatch
  724.  
  725.  
  726.     //+----------------------------------------------------------------------
  727.     //
  728.     //  Synopsis:   Loops through all the controls in the dialog and updates
  729.     //              the sample appropriately.
  730.     //
  731.     //  Arguments:  none
  732.     //
  733.     //  Returns:    nothing
  734.     //
  735.     //-----------------------------------------------------------------------
  736.  
  737.     function updateSample()
  738.     {
  739.         var rngSample = document.rangeFromElement(elmSample);
  740.         var index;
  741.  
  742.         //
  743.         //  Let's take advantage of the the dialog exit routines to set
  744.         //  font face, underline, superscipt, and subscript.
  745.         //
  746.         for (index = 0; index < document.all["setCmdID"].length; index++)
  747.         {
  748.             setStateCmd(document.all["setCmdID"][index], rngSample);
  749.         }
  750.  
  751.         setFontStyle(rngSample);
  752.         setFontColor(rngSample);
  753.         setFontSize(rngSample);
  754.     }   //  updateSample
  755.  
  756.  
  757.     //+-----------------------------------------------------------------------
  758.     //
  759.     //  Synopsis:   Looks at the currently selected text and fills the dialog
  760.     //              options appropriately
  761.     //
  762.     //  Arguments:  None
  763.     //
  764.     //  Returns:    Nothing
  765.     //
  766.     //------------------------------------------------------------------------
  767.  
  768.     function loadBdy()
  769.     {
  770.         //
  771.         //  bind event to controls
  772.         //
  773.         document.onhelp     = new Function("callHelp()");
  774.         document.onkeypress = new Function("defaultActions()");
  775.  
  776.         txtFontName.onblur      = new Function("gboolUpdateText = true;" +
  777.             "syncSelect(cmd18, txtFontName)");
  778.         txtFontName.onfocus     = new Function("gboolUpdateText = false;" +
  779.             "selectText(txtFontName)");
  780.         txtFontName.onchange    = new Function("setSelectStateCmd(cmd18," +
  781.             "document.rangeFromElement(elmSample))");
  782.         txtFontName.onkeyup    = new Function("synchText()");
  783.  
  784.         txtFontStyle.onblur     = new Function("gboolUpdateText = true;" +
  785.             "syncSelect(selFontStyle, txtFontStyle)");
  786.         txtFontStyle.onfocus    = new Function("gboolUpdateText = false;" +
  787.             "selectText(txtFontStyle)");
  788.         txtFontStyle.onchange   = new Function("setFontStyle" +
  789.             "(document.rangeFromElement(elmSample))");
  790.         txtFontStyle.onkeyup    = new Function("synchText()");
  791.  
  792.         txtFontSize.onblur      = new Function("gboolUpdateText = true;" +
  793.             "syncSelect(selFontSize, txtFontSize)");
  794.         txtFontSize.onfocus     = new Function("gboolUpdateText = false;" +
  795.             "selectText(txtFontSize)");
  796.         txtFontSize.onchange    = new Function("gboolUpdateSize = true;" +
  797.             "setFontSize(document.rangeFromElement(elmSample))");
  798.         txtFontSize.onkeyup    = new Function("synchText()");
  799.  
  800.         //
  801.         //  cmd18 is the font list
  802.         //
  803.         cmd18.onchange = new Function("syncSelect(cmd18, txtFontName);" +
  804.             "setSelectStateCmd(cmd18, document.rangeFromElement(elmSample))");
  805.  
  806.         selFontStyle.onchange = new Function("syncSelect(selFontStyle," +
  807.             "txtFontStyle);" +
  808.             "setFontStyle(document.rangeFromElement(elmSample))");
  809.  
  810.         selFontSize.onchange = new Function("gboolUpdateSize = true;" +
  811.             "syncSelect(selFontSize, txtFontSize);" +
  812.             "setFontSize(document.rangeFromElement(elmSample))");
  813.  
  814.         chkUnderline.onclick = new Function("setCheckStateCmd(chkUnderline," +
  815.             "document.rangeFromElement(elmSample))");
  816.  
  817.         chkStrike.onclick = new Function("setCheckStateCmd(chkStrike," +
  818.             "document.rangeFromElement(elmSample))");
  819.  
  820.         chkSuperscript.onclick = new Function("setCheckStateCmd" +
  821.             "(chkSuperscript," +
  822.             "document.rangeFromElement(elmSample))");
  823.  
  824.         chkSubscript.onclick = new Function("setCheckStateCmd(chkSuperscript," +
  825.             "document.rangeFromElement(elmSample))");
  826.  
  827.         selColor.onchange = new Function("gboolUpdateColor = true;" +
  828.             "customColor();" +
  829.             "setFontColor(document.rangeFromElement(elmSample))");
  830.  
  831.         btnOK.onclick           = new Function("btnOKClick()");
  832.         btnClear.onclick        = new Function("btnClearClick()");
  833.         btnCancel.onclick       = new Function("btnCancelClick()");
  834.  
  835.         fillFontSelect(cmd18);
  836.         initDialogCmd();
  837.  
  838.         getFontColor();
  839.         getFontStyle();
  840.         getFontSize();
  841.  
  842.         txtFontSize.focus();
  843.         txtFontStyle.focus();
  844.         txtFontName.focus();
  845.  
  846.         updateSample();
  847.  
  848.         //
  849.         //  These global variables must be set here because binding
  850.         //  the events set them to the wrong state.
  851.         //
  852.         gintCustomColor     = 0;
  853.         gboolUpdateText     = true;
  854.         gboolUpdateColor    = false;
  855.         gboolUpdateSize     = false;
  856.  
  857.     }   //loadBdy
  858.  
  859.  
  860.     //-----------------------------------------------------------------------
  861.     //
  862.     //  Synopsis:   Closes the dialog without doing anything.
  863.     //
  864.     //  Arguments:  none.
  865.     //
  866.     //  Returns:    nothing
  867.     //
  868.     //-----------------------------------------------------------------------
  869.  
  870.     function btnCancelClick()
  871.     {
  872.         window.close();
  873.     }   //  btnCancelClick
  874.  
  875.  
  876.     //+-----------------------------------------------------------------------
  877.     //
  878.     //  Synopsis:   Goes through all the controls on the dialog and sets them
  879.     //              to their default values.
  880.     //
  881.     //  Arguments:  none.
  882.     //
  883.     //  returns:    nothing.
  884.     //
  885.     //------------------------------------------------------------------------
  886.  
  887.     function btnClearClick()
  888.     {
  889.  
  890.         //
  891.         //  First, the style
  892.         //
  893.         selFontStyle.value = "Regular";
  894.  
  895.         //
  896.         //  Then the font and font size
  897.         //
  898.         cmd18.value = gstrFontNormal;
  899.         selFontSize.value = "Normal";
  900.  
  901.         //
  902.         //  Then the effects BUGBUG: this is not needed until the appropriate
  903.         //                          command ids are supported
  904.         //
  905.         chkUnderline.checked = false;
  906.         //chkSuperscript.checked = false;
  907.         //chkSubscript.checked = false;
  908.  
  909.         //
  910.         //  Then the color
  911.         //
  912.         selColor.value = "default";
  913.  
  914.         //
  915.         //  Now update everything
  916.         //
  917.         txtFontSize.focus();
  918.         txtFontStyle.focus();
  919.         txtFontName.focus();
  920.  
  921.         updateSample();
  922.  
  923.         //
  924.         //  set focus back to clear button (just in case)
  925.         //
  926.         btnClear.focus();
  927.     }   //  btnClearClick
  928.  
  929.  
  930.     //+----------------------------------------------------------------------
  931.     //
  932.     //  Synopsis:   Closes the dialog after applying the user's selections
  933.     //              to the document
  934.     //
  935.     //  Arguments:  none
  936.     //
  937.     //  Returns:    nothing
  938.     //
  939.     //-----------------------------------------------------------------------
  940.  
  941.     function btnOKClick()
  942.     {
  943.         var range = globalDoc.selection.createRange();
  944.  
  945.         closeDialogCmd();
  946.         setFontColor(range);
  947.         setFontStyle(range);
  948.         setFontSize(range);
  949.         window.close();
  950.     }   //  btnOKClick
  951.  
  952.  
  953.     //+---------------------------------------------------------------------
  954.     //
  955.     //  Synopsis:   Looks for the ENTER and ESCAPE keypresses and runs
  956.     //              the default action.
  957.     //
  958.     //  Arguments:  see OM spec
  959.     //
  960.     //  Returns:    nothing
  961.     //
  962.     //-----------------------------------------------------------------------
  963.  
  964.     function defaultActions()
  965.     {
  966.         var htmlKeyReturn = 13;
  967.         var htmlKeyEscape = 27;
  968.  
  969.         if (event.keyCode == htmlKeyReturn)
  970.         {
  971.             btnOK.focus();
  972.             btnOKClick();
  973.         }
  974.  
  975.         else if (event.keyCode == htmlKeyEscape)
  976.         {
  977.             btnCancelClick();
  978.         }
  979.     }   //  defaultActions
  980.  
  981.  
  982.     //+---------------------------------------------------------------------
  983.     //
  984.     //  Synopsis:   Looks to see if current element is a text box. If it is,
  985.     //              calls findMatch with the corresponding select box.
  986.     //
  987.     //  Arguments:  none
  988.     //
  989.     //  Returns:    nothing
  990.     //
  991.     //----------------------------------------------------------------------
  992.  
  993.     function synchText()
  994.     {
  995.         var elmSource = window.event.srcElement;
  996.         var arrSelect = new Array();
  997.  
  998.         //
  999.         //  Set up select boxes with corresponding text boxes
  1000.         //
  1001.         arrSelect["txtFontName"]    = cmd18;
  1002.         arrSelect["txtFontStyle"]   = selFontStyle;
  1003.         arrSelect["txtFontSize"]    = selFontSize;
  1004.  
  1005.         if ("INPUT" == elmSource.tagName)
  1006.         {
  1007.             if ("text" == elmSource.type)
  1008.             {
  1009.                 arrSelect[elmSource.id].selectedIndex
  1010.                     = findMatch(elmSource.value, arrSelect[elmSource.id].options);
  1011.             }
  1012.         }
  1013.     }   //  synchText
  1014.  
  1015.  
  1016.     //+-------------------------------------------------------------------------
  1017.     //
  1018.     //  Synopsis:   Opens the help file with the appropriate helpid
  1019.     //
  1020.     //  Arguments:  none
  1021.     //
  1022.     //  Returns:    nothing
  1023.     //
  1024.     //--------------------------------------------------------------------------
  1025.  
  1026.     function callHelp()
  1027.     {
  1028.         //  BUGBUG  Once we get help for the editing dialogs, this function
  1029.         //          will have to change.
  1030.         alert(L_NoHelp_Text);
  1031.     }   //  callHelp
  1032.  
  1033. </SCRIPT>
  1034.  
  1035. <BODY onload="loadBdy()" style="font-family: 'ms sans serif'; font-size: '8pt';
  1036. background: buttonface;">
  1037.  
  1038. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1039. HEIGHT: '2em'; LEFT: '1em';
  1040. TOP: '1em'; WIDTH: '20em';">
  1041. <LABEL for=txtFontName tabIndex=-1><u>F</u>ont:</LABEL>
  1042. </DIV>
  1043.  
  1044. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1045. HEIGHT: '2em'; LEFT: '21.5em';
  1046. TOP: '1em'; WIDTH: '18.2em'">
  1047. <LABEL for=txtFontStyle tabIndex=-1>Font St<u>y</u>le:</LABEL>
  1048. </DIV>
  1049.  
  1050. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1051. HEIGHT: '2em'; LEFT: '33.5em';
  1052. TOP: '1em'; WIDTH: '9.9em'">
  1053. <LABEL for=txtFontSize tabIndex=-1><u>S</u>ize:</LABEL>
  1054. </DIV>
  1055.  
  1056. <INPUT type=text ID=txtFontName ACCESSKEY=f tabIndex=5
  1057. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1058. HEIGHT: '2.1em'; LEFT: '1em';
  1059. TOP: '2.4em'; WIDTH: '19.25em'">
  1060.  
  1061. <INPUT type=text ID=txtFontStyle ACCESSKEY=y tabIndex=10
  1062. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1063. HEIGHT: '2.1em'; LEFT: '21.5em';
  1064. TOP: '2.4em'; WIDTH: '11em'">
  1065.  
  1066. <INPUT type=text ID=txtFontSize ACCESSKEY=s tabIndex=15
  1067. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1068. HEIGHT: '2.1em'; LEFT: '33.5em';
  1069. TOP: '2.4em'; WIDTH: '10em'">
  1070.  
  1071. <!--
  1072. cmd18 is the font list
  1073. -->
  1074. <SELECT style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1075. LEFT: '1em'; TOP: '4.9em';
  1076. WIDTH: '19.25em'; HEIGHT: '11.1em'"
  1077. ID=cmd18 name=setCmdID ACCESSKEY=f tabIndex=17 size=7>
  1078. <OPTION value="">Default</OPTION>
  1079. </SELECT>
  1080.  
  1081. <SELECT ID=selFontStyle  ACCESSKEY=y size=7 tabIndex=20
  1082. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1083. HEIGHT: '11.1em'; LEFT: '21.5em';
  1084. TOP: '4.9em'; WIDTH: '11em'">
  1085. <OPTION VALUE=Regular SELECTED>   Regular     </OPTION>
  1086. <OPTION VALUE=Italic>             Italic      </OPTION>
  1087. <OPTION VALUE=Bold>               Bold        </OPTION>
  1088. <OPTION VALUE=Bold-Italic>        Bold Italic </OPTION>
  1089. </SELECT>
  1090.  
  1091. <SELECT ID=selFontSize ACCESSKEY=s size=7 tabIndex=30
  1092. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1093. HEIGHT: '11.1em'; LEFT: '33.5em';
  1094. TOP: '4.9em'; WIDTH: '10em'">
  1095. <OPTION VALUE=Smallest>           Smallest    </OPTION>
  1096. <OPTION VALUE=Smaller>            Smaller     </OPTION>
  1097. <OPTION VALUE=Normal SELECTED>    Normal      </OPTION>
  1098. <OPTION VALUE=Large>              Large       </OPTION>
  1099. <OPTION VALUE=Larger>             Larger      </OPTION>
  1100. <OPTION VALUE=Largest>            Largest     </OPTION>
  1101. <OPTION VALUE=Huge>               Huge        </OPTION>
  1102. </SELECT>
  1103.  
  1104. <table cellspacing borderColorDark=buttonhighlight
  1105. borderColorLight=buttonshadow border noshade="yes" cellpadding=10
  1106. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1107. HEIGHT: '15.3em'; LEFT: '1em';
  1108. TOP: '17.5em'; WIDTH: '15em'">
  1109. <tr>
  1110. <td>
  1111. <DIV style="color: buttonface;">a</DIV>
  1112. </td></tr>
  1113.  
  1114. </table>
  1115.  
  1116. <INPUT ID=chkUnderline ACCESSKEY=u type=checkbox  tabIndex=35 value=Underline
  1117. name=setCmdID
  1118. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1119. top: '20em'; left: '3em';
  1120. width: '1em'; height: '1em'">
  1121.  
  1122. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1123. top: '20em'; left: '4.5em';
  1124. width: '6em'; height: '1em'">
  1125. <LABEL style="font-family: 'ms sans serif'; font-size: '8pt';" for=chkUnderline
  1126. tabIndex=-1><u>U</u>nderline
  1127. </LABEL>
  1128. </DIV>
  1129.  
  1130. <!--
  1131. BUGBUG
  1132. When the command IDs for strikethrough, superscript, and subscript get
  1133. implemented, change the names of the next three checkboxes from 0setCmdID to
  1134. setcmdID. And they will have to be reenabled.
  1135. -->
  1136.  
  1137. <INPUT ID=chkStrike ACCESSKEY=k value=StrikeThrough type=checkbox tabIndex=40
  1138. DISABLED name=0setCmdID
  1139. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1140. top: '22em'; left: '3em';
  1141. width: '1em'; height: '1em'">
  1142.  
  1143. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1144. top: '22em'; left: '4.5em';
  1145. width: '6em'; height: '1em'">
  1146. <LABEL style="font-family: 'ms sans serif'; font-size: '8pt';" for=chkStrike
  1147. tabIndex=-1>Stri<u>k</u>ethrough
  1148. </LABEL>
  1149. </DIV>
  1150.  
  1151. <INPUT ID=chkSuperscript ACCESSKEY=p type=checkbox tabIndex=45
  1152. value=Superscript DISABLED name=0setCmdID
  1153. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1154. top: '24em'; left: '3em';
  1155. width: '1em'; height: '1em'">
  1156.  
  1157. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1158. top: '24em'; left: '4.5em';
  1159. width: '6em'; height: '1em'">
  1160. <LABEL style="font-family: 'ms sans serif'; font-size: '8pt';" for=chkSuper
  1161. tabIndex=-1>Su<u>p</u>erscript
  1162. </LABEL>
  1163. </DIV>
  1164.  
  1165. <INPUT ID=chkSubscript ACCESSKEY=b type=checkbox tabIndex=50 value=Subscript
  1166. DISABLED name=0setCmdID
  1167. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1168. top: '26em'; left: '3em';
  1169. width: '1em'; height: '1em'">
  1170.  
  1171. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1172. top: '26em'; left: '4.5em';
  1173. width: '6em'; height: '1em'">
  1174. <LABEL style="font-family: 'ms sans serif'; font-size: '8pt';" for=chkSubscript
  1175. tabIndex=-1>Su<u>b</u>script
  1176. </LABEL>
  1177. </DIV>
  1178.  
  1179. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1180. top: '28em'; left: '3em';
  1181. width: '6em'; height: '1em'">
  1182. <LABEL style="font-family: 'ms sans serif'; font-size: '8pt';" for=selColor
  1183. tabIndex=-1><u>C</u>olor:</LABEL>
  1184. </DIV>
  1185.  
  1186. <SELECT ID=selColor ACCESSKEY=c tabIndex=55
  1187. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1188. top: '29.5em'; left: '3em';
  1189. width: '11em'; height: '2.1em'">
  1190. <OPTION value=default>              </OPTION>
  1191. <OPTION value=33554432>     Black   </OPTION>
  1192. <OPTION value=50331647>     White   </OPTION>
  1193. <OPTION value=33587200>     Green   </OPTION>
  1194. <OPTION value=33554560>     Maroon  </OPTION>
  1195. <OPTION value=33587328>     Olive   </OPTION>
  1196. <OPTION value=41943040>     Navy    </OPTION>
  1197. <OPTION value=41943168>     Purple  </OPTION>
  1198. <OPTION value=41975936>     Gray    </OPTION>
  1199. <OPTION value=33619967>     Yellow  </OPTION>
  1200. <OPTION value=33619712>     Lime    </OPTION>
  1201. <OPTION value=50331392>     Aqua    </OPTION>
  1202. <OPTION value=50266367>     Fuchsia </OPTION>
  1203. <OPTION value=46186688>     Silver  </OPTION>
  1204. <OPTION value=33554687>     Red     </OPTION>
  1205. <OPTION value=50266112>     Blue    </OPTION>
  1206. <OPTION value=41975808>     Teal    </OPTION>
  1207. <OPTION value=custom>     Custom  </OPTION>
  1208. </SELECT>
  1209.  
  1210. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1211. background: buttonface;
  1212. COLOR: buttontext; HEIGHT: '1em'; LEFT: '2em'; TOP: '17em'; WIDTH: '3.5em';">
  1213. <LABEL tabIndex=-1>Effects</LABEL>
  1214. </DIV>
  1215.  
  1216. <table cellspacing borderColorDark=buttonhighlight
  1217. borderColorLight=buttonshadow border noshade="yes" border=1
  1218. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1219. HEIGHT: '15.3em'; LEFT: '17em';
  1220. TOP: '17.5em'; WIDTH: '26.5em'">
  1221. <tr>
  1222.     <td style="font-family: 'ms sans serif'; font-size: '8pt'; position: relative;
  1223.     width: '16em';
  1224.     height: '10em'">
  1225.         <CENTER id=elmSample><NOBR>__  AaBbYyGgLlJj   __</NOBR></CENTER>
  1226.     </td>
  1227. </tr>
  1228. </table>
  1229.  
  1230. <DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1231. background: buttonface;
  1232. HEIGHT: '1em'; LEFT: '18em'; TOP: '17em'; WIDTH: '3.5em'">
  1233. <LABEL>Sample</LABEL>
  1234. </DIV>
  1235.  
  1236. <BUTTON id=btnOk tabIndex=60
  1237. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1238. LEFT: '21.5em'; TOP: '33.5em';
  1239. WIDTH: '6.8em'; HEIGHT: '2.1em'">
  1240. OK</BUTTON>
  1241.  
  1242. <BUTTON id=btnClear tabIndex=65 ACCESSKEY=a
  1243. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1244. LEFT: '29.1em'; TOP: '33.5em';
  1245. WIDTH: '6.8em'; HEIGHT: '2.1em'">
  1246. Clear <U>A</U>ll</BUTTON>
  1247.  
  1248. <BUTTON id=btnCancel tabIndex=70
  1249. style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;
  1250. LEFT: '36.7em'; TOP: '33.5em';
  1251. WIDTH: '6.8em'; HEIGHT: '2.1em'">
  1252. Cancel</BUTTON>
  1253.  
  1254. </BODY>
  1255. </HTML>
  1256.