home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * Module Name: TEXTFLDR
- *
- * OS/2 Work Place Shell Sample Program
- *
- * Copyright (C) 1993 IBM Corporation
- *
- * DISCLAIMER OF WARRANTIES. The following [enclosed] code is
- * sample code created by IBM Corporation. This sample code is not
- * part of any standard or IBM product and is provided to you solely
- * for the purpose of assisting you in the development of your
- * applications. The code is provided "AS IS", without
- * warranty of any kind. IBM shall not be liable for any damages
- * arising out of your use of the sample code, even if they have been
- * advised of the possibility of such damages.
- *
- ******************************************************************************/
-
- ### Note: The header preceding this comment will be emitted in all files.
- ###
- ### Any comments to go public should be preceded with '--'
- ### Any comments to remain private should be preceded with '#'
-
- #******************************************************************************
- # Include the class definition file for the parent class
- #******************************************************************************
- include <wpfolder.sc>
-
- #******************************************************************************
- # Define the new class
- #******************************************************************************
- class: TextFolder,
- external stem = TextFolderwps,
- local,
- external prefix = TextFolderwps_,
- classprefix = TextFolderM_,
- major version = 1,
- minor version = 2;
-
- --
- -- CLASS: TextFolder
- --
- -- CLASS HIERARCHY:
- --
- -- SOMObject
- -- └── WPObject
- -- └── WPFileSystem
- -- └── WPFolder
- -- └── TextFolder
- --
- -- DESCRIPTION:
- --
- -- This is the TextFolder object class. This object is similar to
- -- normal folders. The text folder rejects any object that isn't
- -- a file system object that only contains text. The TextFolder accepts
- -- file system objects that have a type of 'Plain Text' or have no type
- -- and contain text characters only.
- --
- -- An instance of this class can be created as a Workplace object.
- --
-
- #******************************************************************************
- # Specify the parent class
- #******************************************************************************
- parent: WPFolder;
-
- #******************************************************************************
- # Specify the release order of new methods. This ensures binary
- # compatability if we change the order of our methods in .c and .csc files.
- #******************************************************************************
- release order:
- IsTextFile,
- ValidateDragAndDrop;
-
- #******************************************************************************
- # Passthru PRIVATE definitions to the .ph file
- #******************************************************************************
- passthru: C.ph;
- endpassthru;
-
- #******************************************************************************
- # Passthru IMPLEMENTATION definitions to the .ih file
- #******************************************************************************
- passthru: C.ih;
-
- #define INCL_WIN
- #define INCL_DOSERRORS
- #define INCL_DOSMODULEMGR
- #include <os2.h>
-
- #define INCL_WPCLASS
- #include <pmwp.h>
-
- #include "string.h"
-
- #define ID_ICON 100
-
- #define FIRST_TEXT_CHAR 0x20
- #define LAST_TEXT_CHAR 0x7e
- #define CHAR_CARRIAGE_RETURN '\r'
- #define CHAR_LINE_FEED '\n'
- #define CHAR_TAB '\t'
- #define CHAR_END_OF_FILE 0x1a
-
- endpassthru;
-
- #******************************************************************************
- # Passthru PUBLIC definitions to the .h file
- #******************************************************************************
- passthru: C.h, after;
- endpassthru;
-
- #******************************************************************************
- # Define instance data
- #******************************************************************************
- data:
-
- #******************************************************************************
- # Define methods
- #******************************************************************************
- methods:
-
- BOOL IsTextFile( PSZ pszFileName), private;
- --
- -- METHOD: IsTextFile (X) PRIVATE
- -- ( ) PUBLIC
- -- DESCRIPTION:
- --
- -- This method checks the first 'n' characters of a file to determine
- -- if it is or is not text. This method is invoked by the
- -- ValidateDragAndDrop method. It is invoked only if no type is specified
- -- for the object being manipulated. A file is considered to be text if
- -- the first 'n' bytes are in the range of ASCII 32 (20 Hex) to ASCII 126
- -- (7E Hex), or is a carriage return (ASCII 10, Hex 0A), line feed
- -- (ASCII 13, Hex 0D), tab (ASCII 8, HEX 08), or end of file marker
- -- (ASCII 26, Hex 1A).
- --
- -- NOTE: The value used for 'n' is stored in the variable ulSampleSize
- -- which is local to the IsTextFile method.
- --
- -- RETURN:
- --
- -- TRUE - the object is a text file.
- -- FALSE - the object is not a text file.
- --
- -- HOW TO OVERRIDE:
- --
- -- n/a
- --
-
- BOOL ValidateDragAndDrop( PDRAGINFO pdrgInfo), private;
- --
- -- METHOD: ValidateDragAndDrop (X) PRIVATE
- -- ( ) PUBLIC
- -- DESCRIPTION:
- --
- -- This method determines if an object can be dragged/dropped on the
- -- TextFolder. It is invoked by the wpDrag and wpDragOver methods.
- --
- -- The ValidateDragAndDrop method first checks the type of the object
- -- being manipulated. If a type is specified, and it is Plain Text,
- -- the operation is considered to be valid. If a type is specified and
- -- it is not Plain Text the operation is considered invalid. If no
- -- type is specified the IsTextFile() method is invoked to determine
- -- if the object is or is not a text object.
- --
- -- RETURN:
- --
- -- TRUE - The object can be dragged/dropped on the TextFolder.
- -- FALSE - The object can not be dragged/dropped on the TextFolder.
- --
- -- HOW TO OVERRIDE:
- --
- -- n/a
- --
-
- #******************************************************************************
- # Specify methods being overridden
- #******************************************************************************
-
- -----------------------------------------------------------------------------
- -- Methods from the WPFileSystem class
- -----------------------------------------------------------------------------
- override wpFilterPopupMenu;
- --
- -- METHOD: wpFilterPopupMenu ( ) PRIVATE
- -- (X) PUBLIC
- -- DESCRIPTION:
- --
- -- Removes the Tree view option from the Open popup menu.
- --
-
-
- -----------------------------------------------------------------------------
- -- Methods from the WPFolder class
- -----------------------------------------------------------------------------
- override wpAddFolderView2Page;
- --
- -- METHOD: wpAddFolderView2Page ( ) PRIVATE
- -- (X) PUBLIC
- -- DESCRIPTION:
- --
- -- Removes the tree view settings page for the TextFolder.
- --
-
- override wpAddFolderIncludePage;
- --
- -- METHOD: wpAddFolderIncludePage ( ) PRIVATE
- -- (X) PUBLIC
- -- DESCRIPTION:
- --
- -- Removes the Include Page from the TextFolder's settings.
- --
-
- override wpDragOver;
- --
- -- METHOD: wpDragOver ( ) PRIVATE
- -- (X) PUBLIC
- -- DESCRIPTION:
- --
- -- Allows or disallows an object to be dragged over the TextFolder.
- --
-
- override wpDrop;
- --
- -- METHOD: wpDrop ( ) PRIVATE
- -- (X) PUBLIC
- -- DESCRIPTION:
- --
- -- Allows or disallows an object to be dropped on the TextFolder.
- --
-
-
- #******************************************************************************
- # Specify class methods being overridden
- #******************************************************************************
- override wpclsQueryTitle, class;
- --
- -- METHOD: wpclsQueryTitle
- --
- -- DESCRIPTION:
- --
- -- Provides a default name of Text Folder for TextFolder.
- --
-
- override wpclsQueryIconData, class;
- --
- -- METHOD: wpclsQueryIconData
- --
- -- DESCRIPTION:
- --
- -- Provides an icon for the TextFolder.
- --