HMG-UNICODE
 Documentation of Changes, Additions and Improvements

 

1

Updated: May 21, 2013

 

Since version HMG.3.1.0 (2012/11/25), HMG at the same time supports ANSI and Unicode character set, or only ANSI character set (for compatibility with previous versions) depending on the choice of compilation in the build of the library. By default HMG supports ANSI and Unicode character set (see INCLUDE\SET_COMPILE_HMG_UNICODE.CH). HMG-UNICODE required set 'Encoding in UTF-8' in your text editor for all the source code files which contain strings in languages using Unicode characters. See Main.UNI.Demo in SAMPLES folder for Unicode characters in Tamil language.

 

 

   # General Functions/Commands

 

  

- HMG_SupportUnicode()  - Return .T. or .F.

- Return true only if HMG is compiled for support the ANSI and Unicode character set.

 

- HMG_CharSetName()     - Return "UNICODE" --> if HMG is compiled for support the ANSI and Unicode character set.

- Return "ANSI"    --> if HMG is compiled for support ONLY the ANSI character set.

 

- SET CODEPAGE TO UNICODE    - Sets the character code page to UTF-8 (Unicode).

- If HMG is compiled for support ANSI/Unicode character set: UTF-8 is default code page.

 

      - IF HMG SUPPORT UNICODE [ RUN | STOP] --> This is a security command for avoid error in program execution/compilation for

programmers that used HMG library with and without support for the Unicode character set.

- RUN  --> Only run the program if HMG library supports the Unicode character set.

- STOP --> Stop the execution of the program if HMG library supports the Unicode character set (useful when deactivate the COMPILE_HMG_UNICODE directive to build the HMG library).

 

      - Note: The programs written entirely in ANSI can be compiled easily with HMG-UNICODE, adding to the beginning of the

  function MAIN() the appropriate ANSI code page, eg. SET CODEPAGE TO SPANISH, without need to disabling

  the COMPILE_HMG_UNICODE directive (in file INCLUDE\SET_COMPILE_HMG_UNICODE.CH) and rebuild the HMG library.

  The hybrid programs must alternate the appropriate ANSI code page with UTF-8 code page according to the needs.

 

      - Remember: To develop applications that support the ANSI/UNICODE character set, you should replace in your

                  programs ALL functions that ONLY support the ANSI character set, by ANSI/UNICODE equivalent functions.

 

 

   # Alternative string functions that support ANSI/Unicode character set

 

 

                     ANSI/UNICODE               ANSI Only

 

-          HMG_LEN()             <=>   LEN()

-          HMG_LOWER()           <=>   LOWER()

-          HMG_UPPER()           <=>   UPPER()

-          HMG_PADC()            <=>   PADC()

-          HMG_PADL()            <=>   PADL()

-          HMG_PADR()            <=>   PADR()

-          HMG_ISALPHA()         <=>   ISALPHA()

-          HMG_ISDIGIT()         <=>   ISDIGIT()

-          HMG_ISLOWER()         <=>   ISLOWER()

-          HMG_ISUPPER()         <=>   ISUPPER()

-          HMG_ISALPHANUMERIC()  <=>   RETURN (ISALPHA(c) .OR. ISDIGIT(c))

 

-          (*) HB_USUBSTR()      <=>   SUBSTR()

-          (*) HB_ULEFT()        <=>   LEFT()

-          (*) HB_URIGHT()       <=>   RIGHT()

-          (*) HB_UAT()          <=>   AT()

-          (*) HB_UTF8RAT()      <=>   RAT()

-          (*) HB_UTF8STUFF()    <=>   STUFF()

           (*) Harbour native functions

 

 

   # It has improved the capacity of message boxes (MsgBox, MsgExclamation, MsgInfo, MsgOkCancel, MsgRetryCancel, MsgStop, MsgYesNo)

     now accept as a parameter any data type or an array of any data type

 

 

-    Example:

MsgInfo ( { "Today is: ", DATE(), " - ", TIME() } , "Title")

MsgInfo ( .T., "Title")

MsgInfo ( 33 )

 

 

   # New function to display debugging information:

 

 

-    MsgDebug ( xData1, xData2, ... )  --> Accepts as a parameters any data type, elements or objects.

 Returns a string with the message displayed on the screen.

 

-    Example:

Num   := 10

aData := { "Number", 38, "aRGB", YELLOW, "Hello" }

cMsg  := MsgDebug ( TIME(), aData, {|| NIL}, Num == 3 )

 

 

 

   # Adding TIMEPICKER Control

 

 

 

   # New Time-related functions

 

- HMG_TimeToValue ( cTime )                     --> Return aTimeValue array

      - HMG_ValueToTime ( aTimeValue , cTimeFormat )  --> Return cTime string

      - HMG_TimeToTime  ( cTime , cNewTimeFormat )    --> Returns cTime string with the time format specified

      - HMG_IsTimeAMPM  ( cTime )                     --> Return .T. if cTime contains the substring "am" or "pm"

 

- aTimeValue  = { nHour, nMinute, nSecond } --> nHour is always in the 24-hour format

          (nHour = 0..23, nMinute = 0..59, nSecond = 0..59)

- cTimeFormat | cNewTimeFormat = _TIMELONG24H | _TIMELONG12H | _TIMESHORT24H | _TIMESHORT12H

- cTime -->  eg.                   "13:37:21" , "01:37:21 pm",       "13:37" ,    "01:37 pm"

 

 

   # Now you can DEFINE/RELEASE at runtime the MAIN/CONTEXT/NOTIFY/DROPDOWN MENU

 

 

-    RELEASE MAIN MENU OF FormName

-    RELEASE MAINMENU OF FormName

-    ReleaseMainMenu ( cFormName )

-    IsMainMenuDefined ( cFormName ) --> lBoolean

 

 

-    RELEASE CONTEXT MENU OF FormName

-    RELEASE CONTEXTMENU OF FormName

-    ReleaseContextMenu ( cFormName )

-    IsContextMenuDefined ( cFormName ) --> lBoolean

 

 

-    RELEASE NOTIFY MENU OF FormName

-    RELEASE NOTIFYMENU OF FormName

-    ReleaseNotifyMenu ( cFormName )

-    IsNotifyMenuDefined ( cFormName ) --> lBoolean

 

 

-    RELEASE DROPDOWN MENU BUTTON ButtonName OF FormName

-    RELEASE DROPDOWNMENU OWNERBUTTON ButtonName OF FormName

-    ReleaseDropDownMenu ( cButtonName, cFormName )

-    IsDropDownMenuDefined ( cButtonName,  cFormName ) --> lBoolean

 

 

   # GRID Control improvement

 

      - New Get Properties:

 

            <ParentWindowName>.<GridControlName>.ColumnCOUNT                           --> nColumnCount

            <ParentWindowName>.<GridControlName>.ColumnHEADER           ( nColIndex )  --> cColumnHeader

            <ParentWindowName>.<GridControlName>.ColumnWIDTH            ( nColIndex )  --> nColumnWidth

            <ParentWindowName>.<GridControlName>.ColumnJUSTIFY          ( nColIndex )  --> nColumnJustify

            <ParentWindowName>.<GridControlName>.ColumnCONTROL          ( nColIndex )  --> aColumnControl

            <ParentWindowName>.<GridControlName>.ColumnDYNAMICBACKCOLOR ( nColIndex )  --> bColumnDynamicBackColor

            <ParentWindowName>.<GridControlName>.ColumnDYNAMICFORECOLOR ( nColIndex )  --> bColumnDynamicForeColor

            <ParentWindowName>.<GridControlName>.ColumnVALID            ( nColIndex )  --> bColumnValid

            <ParentWindowName>.<GridControlName>.ColumnWHEN             ( nColIndex )  --> bColumnWhen

            <ParentWindowName>.<GridControlName>.ColumnONHEADCLICK      ( nColIndex )  --> bColumnOnHeadClick

            <ParentWindowName>.<GridControlName>.ColumnDISPLAYPOSITION  ( nColIndex )  --> nColumnDisplayPosition

            <ParentWindowName>.<GridControlName>.CellEx      ( nRowIndex, nColIndex )  --> xValue (very more fast that .Cell)

           

      - New Set Properties:

 

            <ParentWindowName>.<GridControlName>.ColumnHEADER           ( nColIndex )  := cColumnHeader

            <ParentWindowName>.<GridControlName>.ColumnWIDTH            ( nColIndex )  := [ nColumnWidth ] |

                                                                                          [ GRID_WIDTH_AUTOSIZE ] |

                                                                                          [ GRID_WIDTH_AUTOSIZEHEADER ]

            <ParentWindowName>.<GridControlName>.ColumnJUSTIFY          ( nColIndex )  := nColumnJustify

            <ParentWindowName>.<GridControlName>.ColumnCONTROL          ( nColIndex )  := aColumnControl

            <ParentWindowName>.<GridControlName>.ColumnDYNAMICBACKCOLOR ( nColIndex )  := bColumnDynamicBackColor

            <ParentWindowName>.<GridControlName>.ColumnDYNAMICFORECOLOR ( nColIndex )  := bColumnDynamicForeColor

            <ParentWindowName>.<GridControlName>.ColumnVALID            ( nColIndex )  := bColumnValid

            <ParentWindowName>.<GridControlName>.ColumnWHEN             ( nColIndex )  := bColumnWhen

            <ParentWindowName>.<GridControlName>.ColumnONHEADCLICK      ( nColIndex )  := bColumnOnHeadClick

            <ParentWindowName>.<GridControlName>.ColumnDISPLAYPOSITION  ( nColIndex )  := nColumnDisplayPosition

            <ParentWindowName>.<GridControlName>.CellEx      ( nRowIndex, nColIndex )  := xValue (very more fast that .Cell)

            <ParentWindowName>.<GridControlName>.BackGroundImage ( nAction, cPicture, nRow, nCol )

                                                                   nAction = GRID_SETBKIMAGE_NONE | GRID_SETBKIMAGE_NORMAL |

                                                                             GRID_SETBKIMAGE_TILE | GRID_SETBKIMAGE_WATERMARK

 

 

      - New Methods:

 

            <ParentWindowName>.<GridControlName>.AddColumnEx ( [ nColIndex ],[ cCaption ],[ nWidth ],[ nJustify ],[aColumnControl] )

            <ParentWindowName>.<GridControlName>.AddItemEx ( aItem, nRow )

 

 

      - Set/Get Grid New Properties/Methods with equivalent syntax:

 

            - THIS.XXX  --> where XXX is the name of the new Grid Properties/Methods

 

 

      - AddColumn, AddColumnEx and DeleteColumn properties now NOT clean the Grid (NOT Delete all items),

        for compatibility with old behavior of ADDCOLUMN and DELETECOLUMN:

 

            - SET GridDeleteAllItems [ TRUE|ON ] | [ FALSE|OFF ]

            - IsGridDeleteAllItems() --> Return .T. or .F.

 

 

      - Set colors and display mode in GRID cell navigation mode:

 

         CellNavigationColor ( _SELECTEDCELL_FORECOLOR, aRGBcolor )

         CellNavigationColor ( _SELECTEDCELL_BACKCOLOR, aRGBcolor )

         CellNavigationColor ( _SELECTEDCELL_DISPLAYCOLOR, lBoolean )

 

         CellNavigationColor ( _SELECTEDROW_FORECOLOR, aRGBcolor )

         CellNavigationColor ( _SELECTEDROW_BACKCOLOR, aRGBcolor )

         CellNavigationColor ( _SELECTEDROW_DISPLAYCOLOR, lBoolean )

 

        

      - Get colors in GRID cell navigation mode:

 

         aRGBcolor := CellNavigationColor ( _SELECTEDCELL_FORECOLOR )

         aRGBcolor := CellNavigationColor ( _SELECTEDCELL_BACKCOLOR )

 

         aRGBcolor := CellNavigationColor ( _SELECTEDROW_FORECOLOR )

         aRGBcolor := CellNavigationColor ( _SELECTEDROW_BACKCOLOR )

 

 

   # This commands/function prevents re-entry while processing the events of a control or window allowing the use of other

     controls/functions that generate messages of re-called of events

 

 

-    DISABLE [ CONTROL ] EVENT ControlName OF FormName

-    ENABLE  [ CONTROL ] EVENT ControlName OF FormName

-    StopControlEventProcedure ( cControlName, cFormName, lStop )

 

-    DISABLE [ WINDOW ] EVENT OF FormName

-    ENABLE  [ WINDOW ] EVENT OF FormName

-    StopWindowEventProcedure ( cFormName, lStop )

 

-    GetLastActiveFormIndex ()       --> Return nFormIndex

-    GetLastActiveControlIndex ()    --> Return nControlIndex

 

-    GetFormNameByIndex ( nFormIndex )       ---> Return cFormName

-    GetControlNameByIndex ( nControlIndex ) ---> Return cControlName

 

 

-    Example:

 

#include "hmg.ch"

 

FUNCTION Main

   DEFINE WINDOW Form_1;

      AT 0,0;

      WIDTH 400;

      HEIGHT 300;

      ON GOTFOCUS Form_ONGOTFOCUS();

      MAIN

 

      @ 50,  50 BUTTON Button_1 CAPTION "Click" ACTION MsgInfo ("Hello")

      @ 100, 50 BUTTON Button_2 CAPTION "Minimize" ACTION Form_1.Minimize

      @ 150, 50 TIMEPICKER TimePicker_1 ON GOTFOCUS Control_ONGOTFOCUS ()

 

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

RETURN

 

PROCEDURE Form_ONGOTFOCUS

LOCAL i := GetLastActiveControlIndex ()

   DISABLE WINDOW EVENT OF Form_1

   MsgInfo ("ON GOTFOCUS: Form_1 " + IIF (i > 0," - Last Control Focused: "+ GetControlNameByIndex(i), ""))

   ENABLE WINDOW EVENT OF Form_1

RETURN

 

PROCEDURE Control_ONGOTFOCUS

LOCAL i := GetLastActiveFormIndex ()

      DISABLE WINDOW EVENT OF Form_1                  //   -->   StopWindowEventProcedure ("Form_1", .T.)

      DISABLE CONTROL EVENT TimePicker_1 OF Form_1    //   -->   StopControlEventProcedure ("TimePicker_1", "Form_1", .T.)

 

      MsgInfo ("ON GOTFOCUS: TimePicker_1" + IIF (i > 0," - Last Form Focused: "+ GetFormNameByIndex(i), ""))

 

      ENABLE CONTROL EVENT TimePicker_1 OF Form_1     //   -->   StopControlEventProcedure ("TimePicker_1", "Form_1", .F.)

      ENABLE WINDOW EVENT OF Form_1                   //   -->   StopWindowEventProcedure ("Form_1", .F.)

RETURN

 

 

 

   # IDE-Unicode: supports the Unicode character set and allows at runtime change the language

 

 

 

   # IMAGE Control improvement

-    It increased the quality of the resized images.

-    Now is possible to automatically load an image at its original size.

-    Added properties:

-    TRANSPARENT lValue

-    BACKGROUNDCOLOR aRGBcolor

-    ADJUSTIMAGE lValue

 

 

 

Contributed by:

Dr. Claudio Soto

http://srvet.blogspot.com

srvet@adinet.com.uy