home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / ifontdlg.hp_ / IFONTDLG.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  15.8 KB  |  296 lines

  1. #ifndef _IFONTDLG_
  2. #define _IFONTDLG_
  3. /*******************************************************************************
  4. * FILE NAME: IFONTDLG.HPP                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IFontPkg - Package of font information for the font dialog.              *
  9. *     IFontDialog - A dialog box to select a font.                             *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   (C) Copyright IBM Corporation 1992                                         *
  13. *   All Rights Reserved                                                        *
  14. *   Licensed Materials * Property of IBM                                       *
  15. *                                                                              *
  16. * HISTORY:                                                                     *
  17. *$Log:   R:/IBMCLASS/IBASEAPP/VCS/IFONTDLG.HPV  $                                                                         *
  18. //
  19. //   Rev 1.1   25 Oct 1992 16:57:06   nunn
  20. //changed library name to ICLUI
  21. //
  22. //   Rev 1.0   25 Oct 1992 11:46:08   tsuji
  23. //Initial revision.
  24. *******************************************************************************/
  25. #ifndef _IVBASE_
  26.   #include <ivbase.hpp>
  27. #endif
  28. #ifndef _IDIALOG_
  29.   #include <idialog.hpp>
  30. #endif
  31. #ifndef _IHANDLE_
  32.   #include <ihandle.hpp>
  33. #endif
  34.  
  35. // Forward declarations for other classes:
  36. class   IFontPkg;
  37. class   IFontDialog;
  38. class   IFontMgr;
  39. class   IString;
  40.  
  41. class IFontPkg : public IVBase
  42. {
  43. /*******************************************************************************
  44. * This class stores information needed to run the font dialog.                 *
  45. *                                                                              *
  46. * The type of information includes information about the initial font to       *
  47. * display in the dialog, information about how to display the font dialog,     *
  48. * and information about the selected font.                                     *
  49. *                                                                              *
  50. * Once a font is selected with the font dialog, it can be used by creating     *
  51. * an IFontMgr class with the constructor that takes a font package, or by      *
  52. * calling the method setFont on an existing IFontMgr.                          *
  53. *                                                                              *
  54. * EXAMPLE:                                                                     *
  55. *    // To create a font dialog and then create an IFontMgr with the result    *
  56. *    IFontPkg fntp;                                                            *
  57. *    IFontDlg fntd((IWindow*)0, (IWindow*)pwin, fntp);                         *
  58. *    if (fntp.buttonPressedId() == DID_OK) {                                   *
  59. *       IFontMgr fntm(fntp);                                                   *
  60. *       // The IFontMgr is now set with the new font.                          *
  61. *    }                                                                         *
  62. *******************************************************************************/
  63. public:
  64. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  65. | There are 3 ways to construct instances of this class:                       |
  66. |   1. default                                                                 |
  67. |     Constructs a font package with all default values.                       |
  68. |   2. From an IFontMgr                                                        |
  69. |     Constructs a font package set with the same font as the font manager.    |
  70. |   3. From another IFontPkg                                                   |
  71. |     Constructs a font package set with the same values as another font pkg.  |
  72. ------------------------------------------------------------------------------*/
  73.    IFontPkg               ();
  74.    IFontPkg               (const IFontMgr& fntm);
  75.    IFontPkg               (const IFontPkg& fntp);
  76.  
  77. virtual
  78.    ~IFontPkg              ();
  79.  
  80. /*------------------- SETTING THE PRESENTATION SPACE ---------------------------
  81. | These functions provide ways to set the presentation space that will be      |
  82. | used to determine which fonts are available.                                 |
  83. |    setDisplayPS - Sets the display's presentation space.                     |
  84. |    setPrinterPS - Sets the printer's presentation space.                     |
  85. |                                                                              |
  86. ------------------------------------------------------------------------------*/
  87. void
  88.    setDisplayPS          (IPresSpaceHandle hpsDisplay),
  89.    setPrinterPS          (IPresSpaceHandle hpsPrinter);
  90.  
  91. /*----------- SETTING INFORMATION ABOUT THE INITIAL FONT -----------------------
  92. | These functions provide ways to set information about the initial font that  |
  93. | will be displayed in the font dialog.                                        |
  94. |    setFontFamily - Sets the font's family name.                              |
  95. |    setPointSize - Sets the font's point size.                                |
  96. |    setFontType - Sets the font type.                                         |
  97. |    setFontTypeMask - Sets the font type mask.                                |
  98. |    setFontStyle - Sets the font style.                                       |
  99. |    setFontStyleMask - Sets the font style mask.                              |
  100. ------------------------------------------------------------------------------*/
  101. void
  102.    setFontFamily          (const char* pszFontFamily),
  103.    setPointSize           (unsigned long usPointSize),
  104.    setFontType            (unsigned long flFontType),
  105.    setFontTypeMask        (unsigned long flFontTypeMask),
  106.    setFontStyle           (unsigned long flFontStyle),
  107.    setFontStyleMask       (unsigned long flFontStyleMask);
  108.  
  109. /*----------- GETTING INFORMATION ABOUT THE CHOOSEN FONT -----------------------
  110. | These functions provide ways to get information about the font that was      |
  111. | selected in the font dialog.                                                 |
  112. |    fontFamily - Returns the font's family name.                              |
  113. |    pointSize - Returns the font's point size.                                |
  114. |    fontType - Returns the font type.                                         |
  115. |    fontTypeMask - Returns the font type mask.                                |
  116. |    fontStyle - Returns the font style.                                       |
  117. |    fontStyleMask - Returns the font style mask.                              |
  118. |    fontWeight - Returns the weight class (boldness) of the font.             |
  119. |    fontWidth - Returns the width class of the font.                          |
  120. |    emHeight - Returns the height of the 'M' square for the font.             |
  121. |    xHeight - Returns the height above the baseline for lowercase letters.    |
  122. |    externalLeaing - Returns the amount of whitespace between lines of text.  |
  123. |    nominalPointSize - Returns the point size the font was made for.          |
  124. |    fontAttributes - Returns a pointer to the font attributes structure.      |
  125. ------------------------------------------------------------------------------*/
  126. IString
  127.    fontFamily             () const;
  128.  
  129. unsigned long
  130.    pointSize              () const,
  131.    fontType               () const,
  132.    fontTypeMask           () const,
  133.    fontStyle              () const,
  134.    fontStyleMask          () const,
  135.    fontWeight             () const,
  136.    fontWidth              () const;
  137.  
  138. long
  139.    emHeight               () const,
  140.    xHeight                () const,
  141.    externalLeading        () const,
  142.    nominalPointSize       () const;
  143.  
  144. void* const
  145.    fontAttributes         () const;
  146.  
  147. /*---------------- SETTING INFORMATION ABOUT THE DIALOG ------------------------
  148. | These functions provide ways to customize the font dialog.                   |
  149. |    setDialogTitle - Sets the font dialog's title.                            |
  150. |    setPreviewText - Sets the text to display in the font sample box          |
  151. |    setSizeList - Sets the list of point size choices.                        |
  152. |    setDialogStyle - Sets the dialog's style.                                 |
  153. |    setDialogFlags - Sets the dialog flags.                                   |
  154. |    setForegroundColor - Sets the foreground color of the preview area.       |
  155. |    setBackgroundColor - Sets the background color of the preview area.       |
  156. ------------------------------------------------------------------------------*/
  157. void
  158.    setDialogTitle        (const char* pszTtle),
  159.    setPreviewText        (const char* pszPrview),
  160.    setSizeList           (const char* pszSizeList),
  161.    setDialogStyle        (unsigned long flStyle = 0),
  162.    setDialogFlags        (unsigned long flFlags),
  163.    setForegroundColor    (long lColor),
  164.    setBackgroundColor    (long lColor);
  165.  
  166. /*---------------- GETTING INFORMATION ABOUT THE DIALOG ------------------------
  167. | These functions provide ways to get information about the dialog             |
  168. |    dialogStyle - Returns the dialog's style.                                 |
  169. |    dialogFlags - Returns the dialog flags.                                   |
  170. |    buttonPressedId - Returns the id of the button that was pressed.          |
  171. |    returnCode - Returns the return code, if an error occurred.               |
  172. |    foregroundColor - Returns the foreground color of the preview area.       |
  173. |    backgroundColor - Returns the background color of the preview area.       |
  174. ------------------------------------------------------------------------------*/
  175. unsigned long
  176.    dialogStyle           () const,
  177.    dialogFlags           () const;
  178.  
  179. long
  180.    buttonPressedId       () const,
  181.    returnCode            () const,
  182.    foregroundColor       () const,
  183.    backgroundColor       () const;
  184.  
  185. /*------------------- CUSTOM MESSAGE PROCESSING --------------------------------
  186. | These functions are used to notify the dialog that you will be adding a font |
  187. | handler to the font dialog to process various messages that the font dialog  |
  188. | receives.                                                                    |
  189. |                                                                              |
  190. | The default is to not enable custom processing and let the font dialog       |
  191. | handle it all.  Note you can call enableCustomProc and not add a font        |
  192. | handler.  It will act as if there is no default processing.                  |
  193. |                                                                              |
  194. |    enableCustomProc - Signals that you will be adding a font handler.        |
  195. |    disableCustomProc - Signals that you will not be adding a font handler.   |
  196. |                                                                              |
  197. ------------------------------------------------------------------------------*/
  198. void
  199.    enableCustomProc      (),
  200.    disableCustomProc     ();
  201.  
  202. private:
  203. /*------------------------------ DATA MEMBERS ----------------------------------
  204. |  pvFontData - pointer to the font dlg data structure.                        |
  205. ------------------------------------------------------------------------------*/
  206. void
  207.    *pvFontData;
  208.  
  209. friend IFontDialog;
  210. }; /* IFontPkg */
  211.  
  212.  
  213.  
  214. class IFontDialog : public IDialogWindow
  215. {
  216. /*******************************************************************************
  217. * This class displays a font dialog for the use to choose a font.              *
  218. *                                                                              *
  219. * Once a font is selected with the font dialog, it can be used by creating     *
  220. * an IFontMgr class with the constructor that takes a font package, or by      *
  221. * calling the method setFont on an existing IFontMgr.                          *
  222. *                                                                              *
  223. * EXAMPLE:                                                                     *
  224. *    // To create a font dialog and then create an IFontMgr with the result    *
  225. *    IFontPkg fntp;                                                            *
  226. *    IFontDlg fntd((IWindow*)0, (IWindow*)pwin, fntp);                         *
  227. *    if (fntp.buttonPressedId() == DID_OK) {                                   *
  228. *       IFontMgr fntm(fntp);                                                   *
  229. *       // The IFontMgr is now set with the new font.                          *
  230. *    }                                                                         *
  231. *******************************************************************************/
  232. public:
  233. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  234. | There are 2 ways to construct instances of this class:                       |
  235. |   1. default                                                                 |
  236. |     Constructs a font dialog with the specified parent and owner windows.    |
  237. |   2. Custom dialog                                                           |
  238. |     Constructs a font dialog with a custom template or with custom message   |
  239. |     processing.  The create method must be called to begin processing the    |
  240. |     dialog.                                                                  |
  241. ------------------------------------------------------------------------------*/
  242.    IFontDialog  (const IWindow* pwndParent,
  243.                  const IWindow* pwndOwner,
  244.                  IFontPkg& fntp);
  245.    IFontDialog  (const IWindow* pwndParent,
  246.                  const IWindow* pwndOwner,
  247.                  IFontPkg& fntp,
  248.                  const IResourceId& resid);
  249.  
  250. virtual
  251.    ~IFontDialog  ();
  252.  
  253. /*-------------------------- SHOW THE DIALOG -----------------------------------
  254. | This function creates and displays the font dialog.  It must be called by    |
  255. | the user of the font dialog if the second constructor is used (custom dlg).  |
  256. ------------------------------------------------------------------------------*/
  257.    unsigned long showDialog(State state=modal);
  258.  
  259. /*-------------------------- DIALOG HANDLE -------------------------------------
  260. | This function gives access to the font dialog's window handle.               |
  261. |    handle - Returns the font dialog's window handle.                         |
  262. ------------------------------------------------------------------------------*/
  263. virtual const IWindowHandle&
  264.    handle() const;
  265.  
  266. protected:
  267. /*----------------------------- IMPLEMENTATION ---------------------------------
  268. | This function must be called to begin processing the font dialog.            |
  269. |    create - Creates the font dialog and begins processing it.                |
  270. ------------------------------------------------------------------------------*/
  271. void
  272.    create       (const IWindow* pwndParent,
  273.                  const IWindow* pwndOwner,
  274.                  void* pvFontData);
  275.  
  276. private:
  277. /*------------------------------ DATA MEMBERS ----------------------------------
  278. |  hwndClDlg - The window handle of the font dialog.                           |
  279. |  pwndClParent - A pointer to the parent window of the font dialog            |
  280. |  pwndClOwner -  A pointer to the owner  window of the font dialog            |
  281. |  pvClFontData - A pointer to the font data structure                         |
  282. ------------------------------------------------------------------------------*/
  283. IWindowHandle
  284.    hwndClDlg;
  285.  
  286. const IWindow
  287.    *pwndClParent,
  288.    *pwndClOwner;
  289.  
  290. void
  291.    *pvClFontData;
  292.  
  293. }; /* IFontDialog */
  294.  
  295. #endif
  296.