DEFINITION MODULE WPFINDER;

(***************************************************************************
  OS/2 2.1 Workplace class interface for WPFinder

  Copyright (c) 1994 by Juergen Neuhoff
****************************************************************************)

(*$XL+       Modula-2 language extensions: '_' allowed for symbol names *)
(*$CDECL+    C-style procedures                                         *)
(*$A         default alignment for record fields                        *)

IMPORT SOM;
IMPORT WPFILTER;
IMPORT OS2DEF;
IMPORT WPOBJECT;

TYPE PSOMClass              = SOM.PSOMClass;
TYPE INTEGER4               = SOM.INTEGER4;
TYPE somMToken              = SOM.somMToken;
TYPE somDToken              = SOM.somDToken;
TYPE somMethodProc          = SOM.somMethodProc;
TYPE PWPFinder              = POINTER TO WPFinder;
TYPE PM_WPFinder            = POINTER TO M_WPFinder;

(************************************************************************
  Additional TYPE- and CONST-declarations supporting WPFinder
*************************************************************************)

TYPE LHANDLE                = OS2DEF.LHANDLE;
TYPE OBJECT                 = WPOBJECT.OBJECT;
TYPE HWND                   = OS2DEF.HWND;
TYPE PWPFolder              = WPOBJECT.PWPObject;
TYPE PWPObject              = WPOBJECT.PWPObject;

CONST
  SATTR_INCLUDE_SUBFOLDERS   = 0001H;
  SATTR_INCLUDE_FINDRESULTS  = 0002H;
  SATTR_MULTIPLE_SELECT      = 0004H;
  SATTR_APPEND_RESULTS       = 0008H;

CONST
  FRESULTS_BUFSIZE           = 32;

TYPE
  HFOBJ                      = LHANDLE;

TYPE
  PFINDRESULTS = POINTER TO FINDRESULTS;
  FINDRESULTS  = RECORD
    pNext        : PFINDRESULTS; (* Next struct pointer *)
    cObjects     : LONGCARD;     (* Count of found objs *)
    Object       : ARRAY [0..FRESULTS_BUFSIZE-1] OF OBJECT; (* Object list *)
    SelectState  : ARRAY [0..FRESULTS_BUFSIZE-1] OF CHAR;   (* Selection list *)
                 END;

TYPE
  PFOBJ        = POINTER TO FOBJ;
  FOBJ         = RECORD
    pNext        : PFOBJ;           
    pFResults    : PFINDRESULTS;       (* Current results struct *)
    Index        : LONGCARD;           (* Index in current object list *)
                 END;

CONST
  HANDLE_MAGIC = 99999999H;


(*************************************************************************
  SOM class API for WPFinder, including type-bound procedures
**************************************************************************)

CONST
  WPFinder_MajorVersion     = 1;
  WPFinder_MinorVersion     = 2;

TYPE
  WPFinderClassDataStructure     = RECORD
    classObject                    : PSOMClass;
    wpFind                         : somMToken;
    wpSetFindAttrs                 : somMToken;
    wpQueryFindAttrs               : somMToken;
    wpSetStartFolder               : somMToken;
    wpQueryStartFolder             : somMToken;
    wpBeginEnumFoundObj            : somMToken;
    wpEndEnumFoundObj              : somMToken;
    wpGetNextFoundObj              : somMToken;
    wpFindParametersDialog         : somMToken;
    wpSelectionListDialog          : somMToken;
    wpCreateFindResultsFolder      : somMToken;
    wpSetSelectionState            : somMToken;
    wpAllocResultBlock             : somMToken;
    wpFreeResultBlock              : somMToken;
    wpCleanupFindResults           : somMToken;
                                   END;

VAR
  WPFinderClassData : WPFinderClassDataStructure;

TYPE
  (*$SOM+ *)
  WPFinder = RECORD( WPFILTER.WPFilter ) END;
  (*$SOM- *)


PROCEDURE WPFinderNewClass
(
  majorVersion  : INTEGER4;
  minorVersion  : INTEGER4
)               : PSOMClass;

PROCEDURE( Self : PWPFinder ) wpSetFindAttrs
(
  ulAttrs       : LONGCARD
)               : BOOLEAN;

PROCEDURE( Self : PWPFinder ) wpQueryFindAttrs( ) : LONGCARD;

PROCEDURE( Self : PWPFinder ) wpFind
(
  hwndOwner     : HWND;
  fShowCriteria : BOOLEAN
)               : BOOLEAN;

PROCEDURE( Self : PWPFinder ) wpSetStartFolder
(
  Folder        : PWPFolder
)               : BOOLEAN;

PROCEDURE( Self : PWPFinder ) wpQueryStartFolder( ) : PWPFolder;

PROCEDURE( Self : PWPFinder ) wpBeginEnumFoundObj( ) : HFOBJ;

PROCEDURE( Self : PWPFinder ) wpEndEnumFoundObj
(
  hfo           : HFOBJ
)               : BOOLEAN;

PROCEDURE( Self : PWPFinder ) wpGetNextFoundObj
(
  hfo           : HFOBJ;
  fSelected     : BOOLEAN
)               : PWPObject;

PROCEDURE( Self : PWPFinder ) wpFindParametersDialog
(
  hwndOwner     : HWND
)               : BOOLEAN;

PROCEDURE( Self : PWPFinder ) wpSelectionListDialog
(
  hwndOwner     : HWND
)               : BOOLEAN;

PROCEDURE( Self : PWPFinder ) wpCreateFindResultsFolder
(
  Location      : PWPFolder;
  szTitle       : ARRAY OF CHAR
)               : PWPFolder;


(*************************************************************************
  SOM class API for M_WPFinder, including type-bound procedures
**************************************************************************)

CONST
  M_WPFinder_MajorVersion   = 1;
  M_WPFinder_MinorVersion   = 2;

TYPE
  M_WPFinderClassDataStructure   = RECORD
    classObject                    : PSOMClass;
                                   END;

VAR
  M_WPFinderClassData : M_WPFinderClassDataStructure;

TYPE
  (*$SOM+ *)
  M_WPFinder = RECORD( WPFILTER.M_WPFilter ) END;
  (*$SOM- *)


PROCEDURE M_WPFinderNewClass
(
  majorVersion : INTEGER4;
  minorVersion : INTEGER4
)              : PSOMClass;


END WPFINDER.
