Module Help_mx.pkg

     1//************************************************************************
     2//
     3// Confidential Trade Secret.
     4// Copyright (c) 1997 Data Access Corporation, Miami Florida
     5// as an unpublished work.  All rights reserved.
     6// DataFlex is a registered trademark of Data Access Corporation.
     7//
     8//************************************************************************/
     9
    10//************************************************************************
    11// help_mx.pkg
    12// Version: 1.0
    13//  12-07-1994 : Created
    14//
    15// Author: John J. Tuohy
    16//
    17// Use package provides help support to DEO objects.
    18//
    19//
    20//************************************************************************
    21// 03/29/95 JJT - Converted back to mixin class from include for 3.1
    22//************************************************************************
    23// 8/29/2002 JJT - Added the various help messages for VDF8.3 This gets these
    24//                 messages out of "for desktop" and into each class. This provides
    25//                 each object with interface support for windows & html help.
    26//************************************************************************
    27
    28Use HelpSystemConstants.pkg
    29Use LanguageText.pkg
    30
    31// These methods exist in other packages that may or may not be included
    32// in the application. They must be registered here.
    33Register_procedure View_context_help
    34Register_procedure View_Help_for_help
    35Register_procedure View_Help_Index
    36Register_procedure View_Files_Help
    37Register_procedure View_Keys_Help
    38Register_procedure View_Error_Help
    39Register_procedure View_Help_on_topic
    40Register_Function  peHelpType returns integer
    41Register_procedure DoDisplayTOC
    42Register_procedure DoDisplayKeyword
    43Register_procedure DoShowMapId
    44Register_procedure DoDisplayTopic
    45
    46
    47Class Help_Mixin is a Mixin
    48
    49    { MethodType=Event Visibility=Private }
    50    Procedure Define_Help_Mixin
    51        { Category=Help }
    52        Property Integer Help_Id         0
    53        { Category=Help }
    54        Property String  Help_Keyword    ''
    55        // added in 11.1 - this will be the recommended method for finding a page (instead of help_id and mapping)
    56        { Category=Help }
    57        Property String  psHtmlHelpTopic ""
    58    End_Procedure // Define_Help_Mixin
    59
    60    Procedure DoHtmlHelp
    61        String  sContext
    62        Integer eContextFound
    63
    64        If (ghoHtmlHelp =0) Begin
    65            Error DFERR_HELP_SYSTEM C_$ThereIsNoHelpSystem
    66        End
    67        Else begin
    68            Get HtmlHelpContext HELP_CONTEXT_ANY (&sContext) to eContextFound
    69            Case Begin
    70                Case (eContextFound=HELP_CONTEXT_HTMLPAGE)
    71                    send DoDisplayTopic of ghoHtmlHelp sContext
    72                    Case Break
    73                Case (eContextFound=HELP_CONTEXT_ID)
    74                    Send DoShowMapId of ghoHtmlHelp (integer(sContext)) // it's a map id system
    75                    Case Break
    76                Case (eContextFound=HELP_CONTEXT_KEYWORD)
    77                    Send DoDisplayKeyword of ghoHtmlHelp sContext // If a non-numeric (string), goto keyword
    78                    Case Break
    79                Case else
    80                    Send DoDisplayTOC of ghoHtmlHelp   // if no context, go to TOC
    81            Case End
    82        end
    83    End_Procedure // DoHtmlHelp
    84
    85    { Obsolete=True }
    86    procedure Extended_Help
    87        send Exec_help msg_View_Context_Help
    88    end_procedure
    89
    90    { Obsolete=True }
    91    procedure Help_For_Help
    92        send Exec_help msg_View_Help_For_Help
    93    end_procedure
    94
    95    { Obsolete=True }
    96    procedure Help_Index
    97        send Exec_help msg_View_Help_Index
    98    end_procedure
    99
   100    { Obsolete=True }
   101    procedure Keys_Help
   102        send Exec_help msg_View_keys_help
   103    end_procedure
   104
   105    { Obsolete=True }
   106    procedure File_Help
   107        send Exec_help msg_View_Files_help
   108    end_procedure
   109
   110    { Obsolete=True }
   111    procedure Error_Help
   112        send Exec_help msg_View_Error_help
   113    end_procedure
   114
   115    { Obsolete=True }
   116    Procedure Help_on_Topic
   117        send Exec_help msg_View_Help_on_topic
   118    End_Procedure // Help_on_topic
   119
   120    procedure Help
   121        integer eHelpType
   122        If ghoApplication Begin
   123            Get peHelpType of ghoApplication to eHelpType
   124            If (eHelpType=htWinHelp) ;
   125                Send Extended_help
   126            else if (eHelpType=htHtmlHelp) ;
   127                Send DoHtmlHelp
   128            // else do nothing
   129        end
   130        Else begin
   131            If ghoHtmlHelp Send DoHtmlHelp
   132            Else send extended_help  // for WinHelp
   133        end
   134    end_procedure
   135
   136    // Protected Message:
   137    //    Send passed message to the help object passing the self
   138    //
   139    { Visibility=Private }
   140    Procedure Exec_Help integer iHelpMessage
   141        If Help_object_Id le 0 ;
   142            Error DFERR_HELP_SYSTEM C_$ThereIsNoHelpSystem
   143        Else ;
   144            send iHelpMessage of Help_object_Id self
   145    End_Procedure // Help_on_topic
   146
   147
   148   //  Dummy. Only data-file awre object do this automatically.
   149   { Visibility=Private Obsolete=True }
   150   Function Help_Datafile Returns string
   151   End_Function // Help_Datafile
   152
   153   //
   154   // Function Help_Context Integer Context_type returns String
   155   //
   156   // This message is sent to an object by the help system. It is up to
   157   // the object to return a context value. Depending on the type of
   158   // context requested (context_type) different values are returned.
   159   //
   160   //     Context_type = HELP_CONTEXT_ID
   161   //       Returns the object's help context Id. Will delegate to the
   162   //       desktop searching for an id. Uses Help_ID property
   163   //
   164   //     Context_type = HELP_CONTEXT_KEYWORD
   165   //       Returns the object's help keyword Id. Will delegate to the
   166   //       desktop searching for an id. Uses Help_Keyword property
   167   //
   168   //     Context_type = HELP_CONTEXT_ID_OR_KEY
   169   //       Returns the object's help ID. This can be a context integer ID or
   170   //       a keyword string id. It first looks for the object context_id. If
   171   //       this is non-zero, it returns the id. Otherwise, it checks the object
   172   //       keyword id. If an Id exists it returns it. Else it delegates. Uses
   173   //       properties help_id and help_keyword.
   174   //
   175   //     Context_type = HELP_CONTEXT_DATAFILE
   176   //       returns the data file and field for the object requesting help.
   177   //       It returns a string in "FILE.FIELD" format. Blank if no File
   178   //
   179   //     Context_type = HELP_CONTEXT_ERROR
   180   //       Not actually used by DEOs (although it could be). It returns
   181   //       error context (most likely an error number). Is used by the
   182   //       error system.
   183   //
   184   { Visibility=Private }
   185   Function Help_Context Integer Context_Type Returns String
   186
   187     Integer ID
   188     String  rVal
   189
   190     If Context_Type eq HELP_CONTEXT_ID Begin
   191        Get Help_ID to ID
   192        if ID eq 0 Delegate Get Help_Context Context_type to ID
   193        Move ID to rVal
   194     End
   195     else If Context_Type eq HELP_CONTEXT_KEYWORD Begin
   196        Get Help_Keyword to rVal
   197        if rval eq '' Delegate Get Help_Context Context_Type to rVal
   198     End
   199     else If Context_Type eq HELP_CONTEXT_ID_OR_KEY Begin
   200        Get Help_ID to ID         // 1st try for a context integer ID.
   201        If ID eq 0 Begin          // If no ID check for a keyword.
   202           Get Help_Keyword to rVal
   203           if rVal eq '' Delegate Get Help_Context Context_Type to rVal
   204        End
   205        Else Move ID to rVal
   206     End
   207     else if Context_Type eq HELP_CONTEXT_DATAFILE Begin
   208        Get Help_DataFile to rVal
   209     End
   210
   211     Function_Return rVal
   212
   213   End_Function // Help_Context
   214
   215    // return context-type and the context string (by ref) for this one object. The content type to search for is determined by
   216    // eContext. Usually it will be HELP_CONTEXT_ANY which returns any help context (html page first, id next, keyword last).
   217    //
   218    { Visibility=Private }
   219    Function HtmlHelpObjectContext Integer eContext String BYREF sContext Returns Integer
   220        Integer eContextFound iId
   221        String  sTopic sKeyword
   222
   223        Get psHtmlHelpTopic to sTopic
   224        Get Help_ID         to iId
   225        Get Help_Keyword    to sKeyword
   226
   227        If (sTopic<>"" and (eContext = HELP_CONTEXT_ANY or eContext = HELP_CONTEXT_HTMLPAGE)) Begin
   228            Move HELP_CONTEXT_HTMLPAGE to eContextFound
   229            Move sTopic to sContext
   230        End
   231        Else If (iId<>0 and (eContext = HELP_CONTEXT_ANY or eContext = HELP_CONTEXT_ID)) Begin
   232            Move HELP_CONTEXT_ID to eContextFound
   233            Move (String(iId)) to sContext
   234        End
   235        Else If (sKeyword<>"" and (eContext = HELP_CONTEXT_ANY or eContext = HELP_CONTEXT_KEYWORD)) Begin
   236            Move HELP_CONTEXT_KEYWORD to eContextFound
   237            Move sKeyword to sContext
   238        End
   239        Else Begin
   240            Move HELP_CONTEXT_NONE to eContextFound
   241            Move "" to sContext
   242        end
   243        Function_Return eContextFound // and sContext is returned by reference
   244    End_Function // HtmlHelpObjectContext
   245
   246    // Return context-type and the context string (by ref). Delegate until some kind of context is found
   247    // This message gets augmented at the desktop and at the panel class to stop delegation
   248    // This is what is no called when you request html help.
   249    { Visibility=Private }
   250    Function HtmlHelpContext Integer eContext String BYREF sContext Returns Integer
   251        Integer eContextFound
   252        Get HtmlHelpObjectContext eContext (&sContext) to eContextFound // context for this one object
   253        If (eContextFound=HELP_CONTEXT_NONE) begin
   254            Delegate Get HtmlHelpContext eContext (&sContext) to eContextFound
   255        end
   256        Function_return eContextFound  // and sContext is returned by reference
   257   end_function
   258
   259
   260End_class // Help_Mixin
   261
   262
   263Class DataFile_Help_Mixin is a Mixin
   264   { Obsolete=True }
   265   Function Help_Datafile Returns string
   266       integer file# field#
   267       String rVal
   268       Get Data_file item current to file#
   269       If file# ne 0 Begin
   270          Get Data_field item current to field#
   271          Move ( string(file#) - '.' - string(field#) ) to rVal
   272       end
   273       Function_return rVal
   274   End_Function // Help_Datafile
   275End_Class
   276
   277