home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xfontdlg.cpp < prev    next >
C/C++ Source or Header  |  1997-04-05  |  3KB  |  94 lines

  1. #include "xfontdlg.h"
  2. #include <stdlib.h>
  3.  
  4. /*@ 
  5. @class XFontDialog
  6. @parent XSystemDialog
  7. @type overview
  8. @symbol _
  9. */
  10.  
  11.  
  12. /*@ XFontDialog :: XFontDialog(const XWindow * owner, const char *fontName, const SHORT fontSize, const LONG style, const LONG attr, const char *title, const char *preView)
  13. @group constructors/destructors
  14. @remarks Open the stystem-defined dialog to select a font.
  15. @parameters  <t '°' c=2>
  16.                 °XWindow * owner   °owner of the dialog
  17.             °char * fontName   °default font name
  18.             °SHORT fontSize    °default font size
  19.             °LONG style        °style of the font, valid values are:
  20.  
  21.             °LONG atrributes   °dialog attributes, valid values are:
  22.                                         <t '°' c=1>
  23.                                  °FDLG_CENTER
  24.                                  °FDLG_HELPBUTTON
  25.                                  °FDLG_APPLYBUTTON
  26.                                  °FDLG_RESETBUTTON
  27.                                  °FDLG_MODELESS
  28.                                  °FDLG_INITFROMFATTRS
  29.                                  °FDLG_BITMAPONLY
  30.                                  °FDLG_VECTORONLY
  31.                                  °FDLG_FIXEDWIDTHONLY
  32.                                  °FDLG_PROPORTIONALONLY
  33.                                  °FDLG_NOSYNTHESIZEDFONTS
  34.                                  °FDLG_NATIONAL_LANGUAGE
  35.                                     </t>
  36.             °char * preview    °text for the preview-window of the dialog
  37.                 </t>
  38. */
  39. XFontDialog :: XFontDialog(const XWindow * owner, const char *fontName, const SHORT fontSize, const LONG style, const LONG attr, const char *title, const char *preView)
  40. {
  41.     memset(&fdlg, 0, sizeof(fdlg));
  42.     fdlg.cbSize = sizeof(fdlg);
  43.     fdlg.pszFamilyname = (PSZ) malloc(FACESIZE);
  44.     fdlg.usFamilyBufLen = 100;
  45.     fdlg.hpsScreen = WinGetPS(owner->GetHandle());
  46.     fdlg.pszTitle = (PSZ) title;
  47.     fdlg.pszPreview = (PSZ) preView;
  48.     fdlg.fl = attr;
  49.     fdlg.clrFore = CLR_BLACK;
  50.     fdlg.clrBack = CLR_WHITE;
  51.     fdlg.fAttrs.usCodePage = 437;
  52.     strcpy((char *) fdlg.pszFamilyname, fontName);
  53.     fdlg.fxPointSize = MAKEFIXED(fontSize, 0);
  54.     fdlg.flStyle = style;
  55.     WinFontDlg(HWND_DESKTOP, owner->GetHandle(), &fdlg);
  56.     command = fdlg.lReturn;
  57. }
  58.  
  59.  
  60. /*@ XFontDialog::GetFontName(XString * buffer)
  61. @group misc
  62. @remarks Query the name of the selected font.
  63. @parameters XString * buffer   buffer to hold the data
  64. */
  65. void XFontDialog::GetFontName(XString * buffer)
  66. {
  67.     SHORT l = strlen((char *) fdlg.fAttrs.szFacename) + 1;
  68.  
  69.     memcpy(buffer->GetBuffer(l), fdlg.fAttrs.szFacename, l);
  70.     buffer->ReleaseBuffer(l - 1);
  71. }
  72.  
  73.  
  74. /*@ XFontDialog::GetFontSize()
  75. @group misc
  76. @remarks Query the selected font-size
  77. @returns SHORT size
  78. */
  79.  
  80. XFontDialog :: ~XFontDialog()
  81. {
  82.     free(fdlg.pszFamilyname);
  83. }
  84.  
  85.  
  86. /*@ XSystemDialog::GetCommand()
  87. @group misc
  88. @remarks Return the users action.
  89. @returns SHORT action  ID of the users action:<BR>
  90.                         USER_OK<BR>
  91.                         USER_CANCEL
  92. */
  93.  
  94.