home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IFONTDLG.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-22
|
19KB
|
376 lines
#ifndef _IFONTDLG_
#define _IFONTDLG_
/*******************************************************************************
* FILE NAME: IFONTDLG.HPP *
* *
* DESCRIPTION: *
* Declaration of the class(es): *
* IFontPkg - Package of font information for the font dialog. *
* IFontDialog - A dialog box to select a font. *
* *
* COPYRIGHT: *
* (C) Copyright IBM Corporation 1992 *
* All Rights Reserved *
* Licensed Materials * Property of IBM *
* *
* HISTORY: *
*******************************************************************************/
#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)
// Forward declarations for other classes:
class IString;
class IFont;
class IFontHandler;
struct _FONTDLG;
struct _FATTRS;
class IFontDialog : public IFrameWindow
{
typedef IFrameWindow Inherited;
/*******************************************************************************
* The IFontDialog class displays a font dialog for the user to choose a font. *
* Once the user has chosen a font, accessor methods allow you to retrieve *
* information about the chosen font. *
* *
* The easiest way to use this class is to pass an IFont object on the *
* IFontDialog::Settings constructor. (Settings is nested within IFontDialog.) *
* This causes the following to happen: *
* - The passed in IFont will be used as the initially displayed font *
* choice in the dialog. *
* - If the user dismisses the dialog by pressing the OK push button, the *
* passed in IFont object is automatically changed to what the user *
* selected. *
* *
* Example: *
* IFont curFont("Tms Rmn", 24); *
* // Font Dialog displayed with Tms Rmn 24 as initial selection *
* IFontDialog::Settings fdSettings(&curFont); *
* IFontDialog fd(desktopWindow(), this, fdSettings); *
* // curFont now set to user's selection *
* } *
*******************************************************************************/
public:
/*------------------------ Style -----------------------------------------------
| The following functions provide a means to set and query font dialog |
| styles: |
| |
| Style - Nested class that provides static members that define the set of |
| valid font dialog styles. For example, you could define an |
| instance of this class and initialize it like: |
| IFontDialog::Style |
| style = IFontDialog::modeless | IFontDialog::applyButton; |
| An object of this type is provided when the font dialog is |
| created. A customizable default is used if no styles are |
| specified. Once the object is constructed, IFontDialog member |
| functions can be used to set or query the object's style. |
| |
| The declaration of the IFontDialog::Style nested class is |
| generated by the INESTEDBITFLAGCLASSDEF0 macro. |
| |
| The valid font dialog styles are: |
| |
| classDefaultStyle - Static variable that is set to 0. This means that no |
| style flags are set. |
| noStyle - None of the valid styles are enabled when noStyle is |
| set. |
| applyButton - An Apply push button is added to the dialog. This is |
| useful in a modeless dialog. |
| bitmapOnly - The dialog presents bit-map fonts only. |
| fixedWidthOnly - The dialog presents fixed-width (monospace) fonts |
| only. |
| helpButton - A Help push button is added to the dialog. It will |
| send a Help message to the owner of the dialog. |
| modeless - When this style is specified, the dialog is modeless. |
| The constructor for a modeless dialog will return |
| immediately. To determine the font chosen by the |
| user, you should create an IFontDialogHandler and use |
| the modelessResults function. |
| noSynthesize - The dialog will not manipulate bit-map fonts to |
| synthesize features, such as italics and bold. |
| proportionalOnly - The dialog presents proportionally spaced fonts only. |
| resetButton - A Reset push button is added to the dialog. When |
| this push button is pressed, the values for the |
| dialog are restored to their initial values. |
| vectorOnly - The dialog presents vector fonts only. |
------------------------------------------------------------------------------*/
INESTEDBITFLAGCLASSDEF0(Style, IFontDialog);
static Style
classDefaultStyle;
static const Style
noStyle,
applyButton,
bitmapOnly,
fixedWidthOnly,
helpButton,
modeless,
noSynthesize,
proportionalOnly,
resetButton,
vectorOnly;
class Settings : public IBase
/*******************************************************************************
| The IFontDialog::Settings class is nested within IFontDialog. It is used |
| to pass input to the IFontDialog. The font dialog will be displayed with |
| the items specified in the settings. If no Settings object is passed into |
| the IFontDialog constructor, a default Settings object is constructed for |
| you. The default is to set nothing. |
*******************************************************************************/
{
public:
/*------------------------ Constructor/Destructor ------------------------------
| The only way you can construct an instance of this class is by using a |
| constructor that takes an optional IFont* argument. The optional IFont* |
| specifies a font to be displayed as the initial selection in the dialog. |
| If the OK push button is pressed, the passed in font is changed to the |
| font selected by the user. |
------------------------------------------------------------------------------*/
Settings(IFont* pfont = 0);
~Settings();
/*---------------- Setting Information About the Dialog ------------------------
| These functions provide ways to customize the font dialog: |
| setTitle - Sets the font dialog's title. |
| setPreviewText - Sets the text to display in the font sample box. |
| setSizeList - Sets the list of point size choices. This only |
| affects dialogs for vector fonts. A dialog for a |
| bit-map font will have the size list automatically |
| set to the available sizes for the bit-map font. |
| 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
&setTitle (const char* title),
&setTitle (const IResourceId& resId),
&setPreviewText (const char* previewText),
&setSizeList (const char* sizeList),
&setDialogTemplate (const IResourceId& resId),
&setPosition (const IPoint& pos);
/*------------------- Setting the Presentation Space ---------------------------
| These functions provide ways to set the presentation space that will be |
| used to determine which fonts are available. |
| setDisplayPS - Sets the display's presentation space. |
| setPrinterPS - Sets the printer's presentation space. |
| NOTE: If the presentation space is not specified in the |
| settings, the display's presentation space is |
| automatically used. |
------------------------------------------------------------------------------*/
Settings
&setDisplayPS (const IPresSpaceHandle& hpsDisplay),
&setPrinterPS (const IPresSpaceHandle& hpsPrinter);
/*----------- Setting Information About the Initial Font -----------------------
| These functions provide ways to set information about the initial font that |
| will be displayed in the font dialog. |
| setFamily - Sets the font's family name. |
| setPointSize - Sets the font's point size. |
------------------------------------------------------------------------------*/
Settings
&setFamily (const char* fontFamily),
&setPointSize (unsigned long pointSize);
private: /*------------------------ PRIVATE ----------------------------------*/
IFont
*papplyFont;
struct _FONTDLG
*pData;
friend IFontDialog;
}; /* Settings */
/*------------------------ Constructors/Destructor -----------------------------
| You can construct instances of this class in the following ways: |
| - Using a constructor that takes 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 IFontDialogHandler to a modal |
| font dialog. The handler must be passed on the constructor because |
| once a modal font dialog 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. |
------------------------------------------------------------------------------*/
IFontDialog(IWindow* parent,
IWindow* owner,
Style style = defaultStyle() );
IFontDialog(IWindow* parent,
IWindow* owner,
const Settings& settings,
Style style = defaultStyle() );
IFontDialog(IWindow* parent,
IWindow* owner,
Style style,
const Settings& settings );
IFontDialog(IWindow* parent,
IWindow* owner,
IHandler* handler,
Style style = defaultStyle(),
const Settings& settings = Settings(0) );
~IFontDialog( );
/*-------------------------------- Accessors -----------------------------------
| The following functions provide means of getting and setting the accessible |
| attributes of instances of this class: |
| setDefaultStyle - Sets the default style for all subsequent items. |
| defaultStyle - Returns the current default style. |
------------------------------------------------------------------------------*/
static void
setDefaultStyle ( Style newDefault);
static Style
defaultStyle ( );
/*---------------- 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 end |
| the dialog. |
| returnValue - Returns the return code if an error occurred. |
------------------------------------------------------------------------------*/
long
buttonPressedId () const,
returnValue () const;
Boolean
isModeless ( ) const,
pressedOK ( ) const;
/*----------- Getting Information About the Chosen Font ------------------------
| These functions provide ways to get information about the font that was |
| selected in the font dialog. |
| fontFamily - Returns the font's family name. |
| fontWeight - Returns the weight class (boldness) of the font. |
| fontWidth - Returns the width class of the font. |
| emHeight - Returns the height of the Em square for the font. |
| xHeight - Returns the height above the baseline for lowercase |
| letters. |
| externalLeading - Returns the amount of white space between lines of |
| text. |
| pointSize - Returns the font's point size. |
| nominalPointSize - For a bit-map font, this returns the height of the |
| font. For a vector font, this is the optimal size |
| for the font. |
------------------------------------------------------------------------------*/
IString
fontFamily () const;
unsigned long
fontWeight () const,
fontWidth () const;
long
emHeight () const,
xHeight () const,
externalLeading () const,
pointSize () const,
nominalPointSize () const;
private: /*------------------------ PRIVATE ----------------------------------*/
IFont* papplyFont;
static Style currentDefaultStyle;
IHandler*
_handlerToAdd;
void IFontDialog :: initialize (IWindow* parent,
IWindow* owner,
Style style,
IHandler* handler,
const Settings& settings);
struct _FONTDLG
*pData;
friend void* _System
_IFontDlgProc(unsigned long hwnd, unsigned long ulMsg, void* mp1, void* mp2);
friend IFont;
friend IFontHandler;
}; /* IFontDialog */
/*----------------------------------------------------------------------------*/
/* Resume compiler default packing and warning messages. */
/*----------------------------------------------------------------------------*/
#pragma pack()
#pragma info(restore)
#ifndef I_NO_INLINES
#include <ifontdlg.inl>
#endif
#endif