/*
   --------------------------------------------------------
   Filename.....: colorDlg.cc
   ClassName....: colorDlg
   Purpose......: ChooseColor dialog.
   Programmer...: Rick Miller -  www.treturn.com/dbase
   Date.........: November 07, 2003
   Notes........: See Notes.
   Written for..: dB2K 0.1 and newer.
   Rev. History.: See Revisions.
   Dependencies.: VStruct32Ex.cc or VStruct.cc, VStruct.h.
   Usage........: set procedure to colorDlg.cc additive
   HelpFile.....: None.
   Example:.....: See Example.
   --------------------------------------------------------
   Example:
   --------------------------------------------------------
      oRef  =  new colorDlg()
      // assign property values as desired.
      // to assign an initial color:
      oRef.set("Color", any dbase color)
      // to change a custom color for 1 - 16:
      oRef.set("color1", <int> a window's color)
      // to display the dialog:
      oRef.show()
      // make selections.
      oRef.inspect()
      oRef.release()
   --------------------------------------------------------
   Notes:
   --------------------------------------------------------
      This file and it's dependencies
         are closed when calling release.
      Error messages do not take place in runtime.
      This class has built-in property value conversion
         for the different Color properties.
      Conversion of all Color properties takes place when
         either of the 2 cases below take place:
         1) a set("Color property name") is made and the
            return value is true.
            ie:
               oRef.set("htmlColor", "408080")
         2) a programmatic Color property assignment is made
            and a call to show() are made.
            ie:
               oRef.htmlColor := "408080"
               oRef.show()
   --------------------------------------------------------
   Properties:          type:       default:
   --------------------------------------------------------
      Color             <char>      "black"
         a dBASE compatible color.
      colorStyle        <int>          0
         0 = Java, 1 = dBASE, 2 = System, 3 = Hex.
         preferred style of Color property.
      fullOpen          <bool>      true
         open with custom selection.
      hexColor          <char>      "000000"
         hexColor is a (window's color in hex (bgr)).
      htmlColor         <char>      "000000"
         htmlColor is a (window's color in hex (rgb).
      htmlColorSafe     <char>      "000000"
         nearest color safe htmlColor.
      iniFile           <char>      _app.exe + ".ini"
      javaColor         <char>      "black"
         format is either "#408080"
         or a java color name "teal"
      messages          <bool>      true
         enable/disable error messages.
      ownerHandle       <handle>    activeWindow.
      preventFullOpen   <bool>      false
         allow custom selection ?
      showHelp          <bool>      false
         display the help button ?
      winColor          <int>          0
         window's color.
   --------------------------------------------------------
   Methods:
   --------------------------------------------------------
      get(<char> property name)
         get a property or member value.
      getColor([<char> dBASE color])  display dialog.
         return "" or this.color.
      inspect()   display object in the inspector.
      loadIni()   adds custom colors from iniFile.
      release()   release and close procedure files.
      saveIni()   writes custom colors to iniFile.
      set(<char> property name, <pValu> new value)
         change a property or member.
      show()      display dialog.
   --------------------------------------------------------
   Revisions:
   --------------------------------------------------------
      February 10, 2005
         1) renamed all external functions.
      November 15, 2004
         1) added getColor method.
            displays dialog and returns either
            an empty string or this.color.
         2) modified code to insure the integrity of
            custom colors.
         3) added "messages" property to enable and disable
            error messages.
         4) default folder for the iniFile property
            using set("iniFile", "filename") without
            any pathing defaults the folder to:
               a) _dbwinhome folder in runtime.
               b) set("directory") folder in the dBASE IDE.
         5) added better error handling when Vstruct file
            is not available during instantiation.
      October 04, 2004
         1) changed to a dynamic lookup for system colors.
      October 02, 2004
         1) bug fix for x_IsDbaseColor.
         2) improved integrity in the set method.
      October 01, 2004
         1) added property colorStyle <int> 0-3.
            used for determining the preferred style
            of the Color property.
            ie: Java name, dBASE name, System name, Hex.
      September 30, 2004
         1) added property javaColor.
            javaColor is formatted as:
            either:
               a) a java color name ie: "teal"
            or:
               b) a color value ie: "#408080"
         2) updated all methods for support
            of the javaColor property.
      September 29, 2004
         1) added code to handle an assignment to "Color"
            that may have a "/" in the string.
            the string before the "/" is used.
      September 28, 2004
         Thanks to Rich Mueller (AutoTraker)
            for code samples.
         I Apologize for any inconvenience caused by the
            changes below.
         The changes were made in an effort for the control
            to be more friendly to the dBASE developer.
         Thought it would be best to make the changes now.
         1) added property "Color" supporting a dBASE color.
            a dBASE color.
         2) changed property name from "rgbColor" to "winColor".
         3) added property "iniFile".
            ini file to manage custom colors.
         4) added method loadIni.
            a loadIni() call is made in the constructor.
         5) added method saveIni.
            a saveIni() call is made in the release method.
         6) added compatibility to :dUFLP:Vstruct.prg.
         7) changed "isvalid_rgb" macro to "isvalid_win".
         8) adjusted code for these changes.
      September 27, 2004
         1) added property htmlColorSafe.
            closest html colorSafe color to the selection
            (thanks to Michael Nuwer).
         2) added code to insure that when a color is
            programmatically assigned that the color item
            is in the dialog for selection.
            when the color is not already in the dialog,
            it is placed in the custom color palette at
            position 16.
      September 26, 2004
         1) added get, set, x_CustomColor methods.
            these methods provide the oppurtunity to
            add and retrieve custom colors.
         2) changed code for compatibility with VStruct.cc.
      September 25, 2004
         1) updated code in x_UpdateColor function
            to deal with a programmatic change to
            the hexColor, htmlColor, or winColor.
            property value.
         2) reviewed and updated comments.
   */