home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IFILEDLG.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
20KB
|
410 lines
#ifndef _IFILEDLG_
#define _IFILEDLG_
/*******************************************************************************
* FILE NAME: ifiledlg.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* IFiledlg - *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or *
* disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
*******************************************************************************/
#ifndef _IBASE_
#include <ibase.hpp>
#endif
// forward declarations here
class IFileDialog;
class StringSeq;
class IResourceId;
struct _FILEDLG;
#ifndef _IFRAME_
#include <iframe.hpp>
#endif
#ifndef _IBITFLAG_
#include <ibitflag.hpp>
#endif
#ifndef _ISTRING_
#include <istring.hpp>
#endif
#ifndef _IRESLIB_
#include <ireslib.hpp>
#endif
#ifndef _IPOINT_
#include <ipoint.hpp>
#endif
/*----------------------------------------------------------------------------*/
/* Align classes on four byte boundary. */
/*----------------------------------------------------------------------------*/
#pragma pack(4)
/*----------------------------------------------------------------------------*/
/* Turn off warning for compiler generated copy/assignment */
/*----------------------------------------------------------------------------*/
#pragma info(nocpy)
class IFileDialog : public IFrameWindow {
typedef IFrameWindow Inherited;
/*******************************************************************************
* The IFIleDialog class displays a file dialog for the user to choose a file. *
* Once the user has chosen a file, accessor methods allow you to retrieve *
* information about the chosen file. *
* *
* *
* Example: *
* // Modal Open Dialog with default behavior *
* IFileDialog fd(desktopWindow(), this); *
* // selected file will contain fully qualified file name chosen by user *
* if (fd.pressedOK()) *
* IString selectedFile(fd.fileName()); *
* *
* // SaveAs modeless dialog with Title *
* IFileDialog::Settings settings; *
* settings.setTitle("Example").setFileName("c:\\iclui\\read.me"); *
* IFileDialog fd(desktopWindow(), this, fdSettings, IFileDialog::modeless); *
* MyFileDlgHandler fdHandler; // derived from IFileDialogHandler *
* fdHandler.handleEventsFor(fd); *
* // selected file can be obtained in MyFileDlgHandler::modelessResults. *
* *
*******************************************************************************/
public:
/*-------------------------------- Style ---------------------------------------
| The following functions provide a means to set and query file dialog |
| styles: |
| |
| Style - Nested class that provides static members that define the set of |
| valid file dialog styles. For example, you could define an |
| instance of this class and initialize it like: |
| IFileDialog::Style |
| style = IFileDialog::modeless | IFileDialog::applyButton; |
| An object of this type is provided when the file dialog is |
| created. A customizable default is used if no styles are |
| specified. Once the object is constructed, IFileDialog member |
| functions can be used to set or query the object's style. |
| |
| The declaration of the IFileDialog::Style nested class is |
| generated by the INESTEDBITFLAGCLASSDEF0 macro. |
| |
| The valid file dialog styles are: |
| |
| classDefaultStyle - Original default style for this class, which is |
| noStyle. |
| noStyle - None of the valid styles are enabled when noStyle is |
| set. |
| modeless - When this style is specified, the dialog is modeless. |
| The constructor for a modeless dialog will return |
| immediately. To determine the file chosen by the
| user, you should create an IFileDialogHandler and use
| the modelessResults function.
| applyButton - Adds an Apply push button to the dialog. This is
| useful in a modeless dialog.
| includeEAS - If this style is specified, the dialog will always |
| query extended attribute information for files as it |
| fills the Files list box. The default is to not |
| query the information unless the user has selected |
| an extened attribute type filter from the dialog. |
| helpButton - A Help push button is added to the dialog. It will |
| send a Help message to the owner of the dialog.|
| filter - When this style is specified, the dialog uses the |
| union of the string filter and the extended-attribute |
| type filter when filtering files for the Files list |
| box. When this style is not specified, the list box, |
| by default, uses the intersection of the two. |
| multiSelection - When this style is specified, the Files list box for |
| the dialog is a multiple selection list box. When |
| this style is not specified, the default is a |
| single-selection list box. |
| selectableListbox - When this style is specified, the Files list box on a |
| Save As dialog is enabled. When this style is not |
| specified, the Files list box is not enabled for a |
| Save As dialog. This is the default. |
| preload - If this style is specified, the dialog will preload |
| the volume information for the drives and will |
| preset the current default directory for each drive. |
| The default behavior is for the volume label to be |
| blank and the initial directory will be the root |
| directory for each drive. |
| |
| The following functions provide a means of getting and setting the default |
| style for this class: |
| |
| defaultStyle - Returns the current default style. This is the same as |
| classDefaultStyle unless setDefaultStyle has been |
| called. |
| setDefaultStyle - Sets the default style for all subsequent file dialogs. |
------------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF0(Style, IFileDialog);
static Style
classDefaultStyle;
static const Style
noStyle,
modeless,
applyButton,
includeEAS,
helpButton,
filter,
multiSelection,
selectableListbox,
preload;
static void
setDefaultStyle ( Style newDefault);
static Style
defaultStyle ( );
class Settings : public IBase
/*******************************************************************************
| The IFileDialog::Settings class is nested within the IFileDialog class. It |
| is used to pass input to the file dialog. The file dialog will be |
| displayed with the items specified in the settings. If no Settings object |
| is passed into the IFileDialog constructor, a default Settings object is |
| constructed for you. The default Settings object provides an Open Dialog |
| with none of the other settings in effect. |
*******************************************************************************/
{
public:
/*------------------------- Constructor/Destructor ----------------------------
| The only way to construct instances of this class is by using the default |
| constructor. |
------------------------------------------------------------------------------*/
Settings();
~Settings();
/*---------------- Setting Information About the Dialog ------------------------
|These functions provide ways to set information about the dialog: |
| setOpenDialog - Creates an Open File dialog (default). |
| setSaveAsDialog - Creates a Save As dialog. |
| setTitle - Sets the dialog's title. |
| setOKButtonText - Sets the text that appears on the OK button. |
| setFileName - Sets a default file name selection. |
| setInitialFileType - Extended attribute that is used to filter the initial |
| display of files. If this function is not specified, |
| the default is <All Files>. This type need not be |
| used on an addFileType call. |
| addFileType - Adds a specified type to the drop-down box of |
| extended-attribute types. |
| setInitialDrive - Drive for which initial information is displayed. If |
| this function is not called, the dialog displays |
| information for the current drive. This drive need |
| not be used on an addDrive call. |
| addDrive - Adds a drive or network identifier to the Drive list |
| in the initial dialog. If this function is invoked, |
| then the Drive List will be limited to the drives |
| specified on addDrive calls. |
| setDialogTemplate - Specifies a dialog template resource to be used in |
| place of the OS/2-supplied default font dialog. |
| setPosition - Sets the initial placement of the dialog within the |
| parent window. If this is not set, the dialog is |
| centered in the parent window. |
------------------------------------------------------------------------------*/
Settings
&setOpenDialog ( ),
&setSaveAsDialog ( ),
&setTitle (char* newTitle),
&setTitle (const IResourceId& resId),
&setOKButtonText (char* newText),
&setOKButtonText (const IResourceId& resId),
&setInitialFileType (char* fileType),
&setFileName (char* fileName),
&addFileType (char* fileType),
&setInitialDrive (char* drive),
&addDrive (char* drive),
&setDialogTemplate (const IResourceId& resId),
&setPosition (const IPoint& pos);
private: /*------------------------ PRIVATE ----------------------------------*/
IString
title ( ) const,
OKButtonText ( ) const,
fileName ( ) const,
initialDrive ( ) const,
initialFileType ( ) const;
StringSeq
*fileTypes ( ) const,
*drives ( ) const;
IPoint
position ( ) const;
Boolean
isOpenDialog ( ) const,
isPositionSet ( ) const,
isDialogTemplateSet ( ) const;
friend IFileDialog;
IString
_title,
_OKButtonText,
_fileName,
_initialDrive,
_initialFileType;
StringSeq
*_fileTypes,
*_drives;
unsigned long
_dlgId;
IModuleHandle
_dlgHandle;
IPoint
_position;
Boolean
_isOpenDialog,
_isPositionSet,
_isDialogTemplateSet;
}; /* Settings */
/*------------------------ Constructors/Destructor -----------------------------
| You can construct an instance of this class in the following ways: |
| - Using constructors that take a parent, owner, Style, and Settings. |
| For these, the Style and Settings are optional and can be specified |
| in any order following the parent and owner. |
| - Using a constructor that takes a pointer to an IHandler object. You |
| would use this if you wanted to add an IFileDialogHandler to a modal |
| IFileDialog. The handler must be passed on the constructor because |
| once a modal IFileDialog is created, the program will not return to |
| you until the user has dismissed the dialog. At that time, it is too |
| late to add a handler. |
| |
| All of the constructors cause a modal dialog to be created by default. |
| If you require a modeless dialog, you must set the modeless style bit |
| in the Style argument of the constructor. |
| |
| NOTE: Due to the way the Presentation Manager works, a dialog with modal |
| style will behave modeless if its parent is not the desktop. However, |
| if you pass 0 as the parent argument, the desktop will automatically |
| be made the parent of the dialog. |
|------------------------------------------------------------------------------*/
IFileDialog(IWindow* parent,
IWindow* owner,
Style style = defaultStyle() );
IFileDialog(IWindow* parent,
IWindow* owner,
const Settings& settings,
Style style = defaultStyle() );
IFileDialog(IWindow* parent,
IWindow* owner,
Style style,
const Settings& settings );
IFileDialog(IWindow* parent,
IWindow* owner,
IHandler* handler,
Style style = defaultStyle(),
const Settings& settings = Settings() );
~IFileDialog( );
/*---------------- Getting Information About the Dialog ------------------------
| These functions provide ways to get information about the dialog: |
| isModeless - Returns true if this is a modeless dialog. |
| pressedOK - Returns true if the user ended the dialog by pressing |
| the OK push button. |
| buttonPressedId - Returns the ID of the push button that was used to |
| dismiss the dialog. |
| returnValue - Returns the return code, if an error occurred. |
------------------------------------------------------------------------------*/
Boolean
isModeless ( ) const,
pressedOK ( ) const;
long
buttonPressedId ( ) const,
returnValue ( ) const;
/*----------- Getting Information About the Chosen File ------------------------
| These functions provide ways to get information about the font that was |
| selected in the font dialog: |
| selectedFileCount - Returns the number of files selected by the user. |
| This number can be more than one if the dialog was |
| created with IFileDialog::multiSelection. |
| fileName - Returns the fully qualified file name selected by |
| the user. When multiSelection is used, you should |
| call this function with the fileNumber parameter set |
| from 0 to selectedFileCount - 1, to ensure the |
| correct number of files is returned. |
| saveAsEAType - Returns the extended-attribute for a Save As dialog. |
| This is the type the user chose from the drop-down |
| list of EA types. If <All Files> was the chosen EA |
| type, then this returns a 0-length IString. |
------------------------------------------------------------------------------*/
unsigned
selectedFileCount ( ) const;
IString
fileName (unsigned fileNumber = 0) const,
saveAsEAType ( ) const;
private: /*------------------------ Private ----------------------------------*/
static Style currentDefaultStyle;
friend void* _System
_IFileDlgProc(unsigned long hwnd, unsigned long ulMsg, void* mp1, void* mp2);
struct _FILEDLG*
pData;
IHandler*
handlerToAdd;
void IFileDialog :: initialize (IWindow* parent,
IWindow* owner,
Style style,
IHandler* handler,
const Settings& settings);
}; /* IFileDialog */
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing and warning messages. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#pragma info(restore)
#ifndef I_NO_INLINES
#include <ifiledlg.inl>
#endif
#endif // _IFILEDLG_