home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ivbfontd.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  19.2 KB  |  372 lines

  1. #ifndef _IVBFONTD_
  2.   #define _IVBFONTD_
  3. /*******************************************************************************
  4. * FILE NAME: ivbfontd.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IVBFontDialog - A surrogate of the IFontDialog class.                    *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM(R) VisualAge(TM) for C++                                               *
  12. *   (C) Copyright International Business Machines Corporation 1991, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *   This program will not run in DOS mode.                                     *
  18. *                                                                              *
  19. *******************************************************************************/
  20. #ifndef _IVBDEFS__
  21. #include <ivbdefs.h>
  22. #endif
  23.  
  24. #ifndef _ISTDNTFY_
  25.   #include <istdntfy.hpp>
  26. #endif
  27.  
  28. #ifndef _IFONTDLG_
  29.   #include <ifontdlg.hpp>
  30. #endif
  31.  
  32. #ifndef _IFONT_
  33.   #include <ifont.hpp>
  34. #endif
  35.  
  36. #ifndef _IFONTHDR_
  37.   #include <ifonthdr.hpp>
  38. #endif
  39.  
  40. /*-------------------------- Pragma Library Support --------------------------*/
  41. #ifndef __NO_DEFAULT_LIBS__
  42.   #ifdef __OS2__
  43.     #ifdef __IMPORTLIB__
  44.        #pragma library("CPPOOV3I.LIB")
  45.     #else
  46.        #pragma library("CPPOOV3.LIB")
  47.     #endif
  48.   #endif
  49.   #ifdef __WINDOWS__
  50.     #ifdef __IMPORTLIB__
  51.        #pragma library("CPPWOV3I.LIB")
  52.     #else
  53.        #pragma library("CPPWOV3.LIB")
  54.     #endif
  55.   #endif
  56. #endif
  57.  
  58. //Forward declarations for other classes:
  59. class IVBFontDialogData;
  60. class IWindow;
  61. class IFont;
  62.  
  63. /*----------------------------------------------------------------------------*/
  64. /* Align classes on four byte boundary.                                       */
  65. /*----------------------------------------------------------------------------*/
  66. #pragma pack(4)
  67.  
  68. class IVBFontDialog : public IStandardNotifier
  69. {
  70. typedef IStandardNotifier
  71.   Inherited;
  72. /*******************************************************************************
  73. * The IVBFontDialog class manages access to a IFontDialog::Settings and        *
  74. * showing a IFontDialog object.                                                *
  75. *                                                                              *
  76. * An object of this class creates a IFontDialog::Settings object.              *
  77. * Calling a member funtion in the Display Dialog group will construct and show *
  78. * a new IFontDialog object from the local settings object and owner together   *
  79. * with the member function parameters parent, style and handler.               *
  80. * Objects of this class do not forward notifications of either IFontDialog     *
  81. * or IFontDialog::Settings.                                                    *
  82. *                                                                              *
  83. * Example:                                                                     *
  84. *   IVBFontDialog  fd( owner );                                                *
  85. *   fd.setTitle( "Select a font" ).setOKButtonText( "Select" );                *
  86. *   do {                                                                       *
  87. *      fd.showModally( );               //wait for user to press "Select"      *
  88. *      } while ( !fd.pressedOK());                                             *
  89. *   processFont( fd.fontFamily());      //member function to process font      *
  90. *                                                                              *
  91. ********************************************************************************/
  92. public:
  93.  
  94. /*------------------------ Constructors/Destructor -----------------------------
  95. | You can construct an object of this class:                                   |
  96. |   - From an owner window pointer.                                            |
  97. |                                                                              |
  98. |------------------------------------------------------------------------------*/
  99.   IVBFontDialog (IWindow*    owner);
  100.  
  101. virtual
  102.  ~IVBFontDialog ( );
  103.  
  104. /*------------------------------ Display Dialog --------------------------------
  105. | These member functions create and show a IFontDialog:                        |
  106. |   showModally              - Results in an application-modal IFontDialog     |
  107. |                              being displayed.                                |
  108. |   setFontFromWindowModally - Results in an application-modal IFontDialog     |
  109. |                              being displayed. The target window font is      |
  110. |                              used as the default font.  If the dialog is     |
  111. |                              dismissed with OK the selected font is set in   |
  112. |                              the target window.                              |
  113. |   setFontFromFontModally   - Results in an application-modal IFontDialog     |
  114. |                              being displayed.    The target font is used as  |
  115. |                              the default font.   If the dialog is dismissed  |
  116. |                              with OK the selected font is set in the target  |
  117. |                              font.                                           |
  118. |   show                     - Results in a IFontDialog being made visible.    |
  119. |                              The default mode is modal.  If you require a    |
  120. |                              modeless dialog, you must set the modeless      |
  121. |                              style bit in the Style argument.                |
  122. |   showFromFont             - Results in a IFontDialog being made visible.    |
  123. |                              The default mode is modal.  If you require a    |
  124. |                              modeless dialog, you must set the modeless      |
  125. |                              style bit in the Style argument.                |
  126. |   Note: Only one instance of IFontDialog may be showing at any time,         |
  127. |         a second member function may not be called a second time until       |
  128. |         the first called member function has been dismissed.                 |
  129. |         A modal dialog has been dismissed when the caller is returned        |
  130. |         control.  The results from showing a dialog are loss when            |
  131. |         the next Display Dialog group member function is called.             |
  132. |                                                                              |
  133. ------------------------------------------------------------------------------*/
  134. virtual unsigned long
  135.   showModally              ( IWindow*                   parent  = NULL
  136.                            , const IFontDialog::Style   style   = IFontDialog::defaultStyle()
  137.                            , IHandler*                  handler = 0 ),
  138.   setFontFromWindowModally ( IWindow*                   target
  139.                            , IWindow*                   parent  = NULL
  140.                            , const IFontDialog::Style   style   = IFontDialog::defaultStyle()
  141.                            , IHandler*                  handler = 0 ),
  142.   setFontFromFontModally   ( IFont*                     target
  143.                            , IWindow*                   parent  = NULL
  144.                            , const IFontDialog::Style   style   = IFontDialog::defaultStyle()
  145.                            , IHandler*                  handler = 0 );
  146.  
  147. virtual IVBFontDialog
  148.  &show                     ( IWindow*                   parent
  149.                            , const IFontDialog::Style   style   = IFontDialog::defaultStyle()
  150.                            , IHandler*                  handler = 0 ),
  151.  &showFromFont             ( IFont*                     target
  152.                            , IWindow*                   parent
  153.                            , const IFontDialog::Style   style   = IFontDialog::defaultStyle()
  154.                            , IHandler*                  handler = 0 );
  155.  
  156. /*---------------- Getting Information About the Dialog ------------------------
  157. | These member functions allow querying information about the dialog:          |
  158. |   isModeless      - Returns true if the dismissed dialog was modeless.       |
  159. |   pressedOK       - Returns true if the user ended the dialog by pressing    |
  160. |                     the OK push button.                                      |
  161. |   buttonPressedId - Returns the ID of the push button that was used to       |
  162. |                     dismiss the dialog.                                      |
  163. |   returnValue     - Returns the return code, if an error occurred.           |
  164. |     Note: These member functions are valid only after a dialog is            |
  165. |           dismissed.                                                         |
  166. |                                                                              |
  167. ------------------------------------------------------------------------------*/
  168. Boolean
  169.   isModeless              ( ) const,
  170.   pressedOK               ( ) const;
  171. unsigned long
  172.   buttonPressedId         ( ) const;
  173. long
  174.   returnValue             ( ) const;
  175.  
  176. /*---------------- Getting Information About the Chosen Font -------------------
  177. | These member functions allow querying information about the selected font:   |
  178. |    fontFamily       - Returns the font's family name.                        |
  179. |    fontWeight       - Returns the weight class (boldness) of the font.       |
  180. |    fontWidth        - Returns the width class of the font.                   |
  181. |    emHeight         - Returns the height of the Em square for the font.      |
  182. |    xHeight          - Returns the height above the baseline for lowercase    |
  183. |                       letters.                                               |
  184. |    externalLeading  - Returns the amount of white space between lines of     |
  185. |                       text.                                                  |
  186. |    pointSize        - Returns the font's point size.                         |
  187. |    nominalPointSize - For a bit-map font, this returns the height of the     |
  188. |                       font.  For a vector font, this is the optimal size     |
  189. |                       for the font.                                          |
  190. ------------------------------------------------------------------------------*/
  191. IFont
  192.   font                   ( ) const;
  193.  
  194. virtual IVBFontDialog
  195.  &setFont                (const IFont& font);
  196.  
  197. #ifdef __OS2__
  198. IString
  199.   fontFamily             ( ) const;
  200. #endif
  201.  
  202. #ifdef __OS2__
  203. unsigned long
  204.   fontWeight             ( ) const,
  205.   fontWidth              ( ) const,
  206.   emHeight               ( ) const,
  207.   xHeight                ( ) const,
  208.   externalLeading        ( ) const,
  209.   nominalPointSize       ( ) const;
  210. #endif
  211.  
  212. unsigned long
  213.   pointSize              ( ) const;
  214.  
  215. /*---------------- Setting Information About the Dialog ------------------------
  216. | These member functions allow customizing the dialog:                         |
  217. |   setTitle          - Sets the font dialog's title.                          |
  218. |   setPreviewText    - Sets the text to display in the font sample box.       |
  219. |   setSizeList       - Sets the list of point size choices.  This only        |
  220. |                       affects dialogs for vector fonts.  A dialog for a      |
  221. |                       bit-map font will have the size list automatically     |
  222. |                       set to the available sizes for the bit-map font.       |
  223. |                       The size list is a comma delimited string              |
  224. |                       (e.g. "8,10,12,14,18,24").                             |
  225. |   setPosition       - Sets the initial placement of the dialog within the    |
  226. |                       parent window.  If this is not set, the dialog is      |
  227. |                       centered in the parent window.                         |
  228. |   setDialogTemplate - Specifies a dialog template resource to be used in     |
  229. |                       place of the OS/2-supplied default font dialog.        |
  230. |   setDisplayPS      - Set a display presentation space, the IFontDialog      |
  231. |                       will query the presentation space for candidate fonts. |
  232. |   setPrinterPS      - Set a printer presentation space, the IFontDialog      |
  233. |                       will query the presentation space for candidate fonts. |
  234. |   setFamily         - Set the default font family.                           |
  235. |   setPointSize      - Set the default font point size.                       |
  236. |                                                                              |
  237. ------------------------------------------------------------------------------*/
  238. #ifdef __OS2__
  239. virtual  IVBFontDialog
  240.  &setSizeList           ( const char*             sizeList        ),
  241.  &setDisplayPS          ( const IPresSpaceHandle& presSpaceHandle ),
  242.  &setPrinterPS          ( const IPresSpaceHandle& presSpaceHandle ),
  243.  &setFamily             ( const char*             fontFamily      ),
  244.  &setPointSize          ( unsigned long           pointSize       );
  245. #endif
  246.  
  247. virtual  IVBFontDialog
  248.  &setTitle              ( const char*             title           ),
  249.  &setTitle              ( const IResourceId&      text            ),
  250.  &setPreviewText        ( const char*             previewText     ),
  251.  &setPosition           ( const IPoint&           position        ),
  252.  &setDialogTemplate     ( const IResourceId&      templateId      );
  253.  
  254. /*----------------------- Access to Settings and Dialog ------------------------
  255. | These member functions provide addressability to the IFontDialog and the     |
  256. | Settings object (useful with tear-off attributes or access to methods not    |
  257. | externalized by this class):                                                 |
  258. |    fontDialog         - Returns a pointer to the IFontDialog object.         |
  259. |    fontDialogSettings - Returns a pointer to the IFontDialog::Settings       |
  260. |                        object.                                               |
  261. |                                                                              |
  262. ------------------------------------------------------------------------------*/
  263. IFontDialog
  264.  *fontDialog         ( );
  265. IFontDialog::Settings
  266.  *fontDialogSettings ( );
  267.  
  268. /*----------------------- Notification Event Descriptions ----------------------
  269. | These INotificationId strings are used for all notifications that            |
  270. | IVBFontDialog provides to its observers:                                     |
  271. |   createdId   - Notification identifier provided to observers when a new     |
  272. |                 IFontDialog has been created.                                |
  273. |   dismissedId - Notification identifier provided to observers when the       |
  274. |                 showing IFontDialog has been dismissed.                      |
  275. |   pressedOkId - Notification identifier provided to observers when the       |
  276. |                 showing IFontDialog has been dismissed with ok button.       |
  277. ------------------------------------------------------------------------------*/
  278. static INotificationId const
  279.   IVB_IMPORT createdId,
  280.   IVB_IMPORT dismissedId,
  281.   IVB_IMPORT pressedOkId;
  282.  
  283. private:
  284. /*------------------------------- PRIVATE ------------------------------------*/
  285. class IDismissFontDialogDetector;
  286.  
  287. IWindow
  288.  *fOwner;
  289. IFontDialog::Settings
  290.   fSettings;
  291. IFont
  292.   fFont;
  293. IFontDialog
  294.  *fFontDialog;
  295. IDismissFontDialogDetector
  296.  *fDismissHandler;
  297. Boolean
  298.   fShowing;
  299. IVBFontDialogData
  300.  *fFontDialogProxyData;
  301.  
  302. /*--------------------------- Blocked class methods ----------------------------
  303. | Neither the copy constructor or assignment operator are supported.           |
  304. |                                                                              |
  305. ------------------------------------------------------------------------------*/
  306.   IVBFontDialog ( const IVBFontDialog& source );
  307. IVBFontDialog
  308.  &operator=        ( const IVBFontDialog& source );
  309.  
  310. /*--------------------- Report Detection of Dialog End -------------------------
  311. | This member function provides a means to notify observers when a modeless    |
  312. | IFontDialog is dismissed.                                                    |
  313. |   dialogEndDetected - Notify observers of IFontDialog dismissal.             |
  314. ------------------------------------------------------------------------------*/
  315. virtual IVBFontDialog
  316.  &dialogEndDetected ( );
  317.  
  318.  
  319. class  IDismissFontDialogDetector : public IFontDialogHandler
  320. {
  321. typedef IFontDialogHandler
  322.   Inherited;
  323. /*******************************************************************************
  324. * The IDismissFontDialogDetector class detects the dismissal of a IFontDialog. *
  325. *                                                                              *
  326. ********************************************************************************/
  327. public:
  328. /*------------------------ Constructors/Destructor -----------------------------
  329. | You construct objects of this class:                                         |
  330. |   -  From the default constructor which takes no objects.                    |
  331. |                                                                              |
  332. ------------------------------------------------------------------------------*/
  333.   IDismissFontDialogDetector( );
  334.  
  335. virtual
  336.   ~IDismissFontDialogDetector( );
  337.  
  338. /*------------------------------ Dialog Dismissal ------------------------------
  339. | This member function enables the capture of a IFontDialog dismissal event:   |
  340. |   listenForResults  - Ready the capture of a IFontDialog dismissal event.    |
  341. |                                                                              |
  342. ------------------------------------------------------------------------------*/
  343. virtual IDismissFontDialogDetector
  344.  &listenForResults ( IVBFontDialog* fontDialogProxy );
  345.  
  346. /*-------------------------------- Overrides -----------------------------------
  347. | This member function is an overidde of an inherited function:                |
  348. |   modelessResults -  Called when a modeless IFontDialog is dismissed.        |
  349. |                                                                              |
  350. ------------------------------------------------------------------------------*/
  351. virtual Boolean
  352.   modelessResults  ( IFontDialog*      endingDialog );
  353.  
  354. private:
  355. /*------------------------------- PRIVATE ------------------------------------*/
  356.  
  357. IVBFontDialog
  358.  *fProxy;
  359.  
  360. };   // end IDismissFontDialogDetector
  361.  
  362. friend IDismissFontDialogDetector::modelessResults( IFontDialog* );
  363.  
  364. };  // end IVBFontDialog
  365.  
  366. /*----------------------------------------------------------------------------*/
  367. /* Resume compiler default packing and warning messages.                      */
  368. /*----------------------------------------------------------------------------*/
  369. #pragma pack()
  370.  
  371. #endif /* _IVBFONTD_ */
  372.