home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm2.zip / source / glbfont.hpp < prev    next >
C/C++ Source or Header  |  1996-07-08  |  3KB  |  85 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1996  Paul Elliott
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     Paul Elliott
  20.     3987 South Gessner #224
  21.     Houston Tx 77063
  22.     Paul.Elliott@Hrnowl.LoneStar.Org
  23. */
  24. #ifndef GLBFONT
  25. #define GLBFONT
  26. #include <ifont.hpp>
  27.  
  28. #include "AProfile.hpp"
  29.  
  30. // This object saves and restores IFonts.
  31. // could not use the Template tecnique for light weight
  32. // persistance because face name is varriable lengh.
  33. // do it the simple way using profiles.
  34.  
  35. class ExternalFont
  36. {
  37.     private:
  38.           AProfile profile;               // profile to save get profiles.
  39.  
  40.           // character strings.
  41.           static const char * const face_name;//        =         "faceName";
  42.           static const char * const point_size;//       =         "pointSize";
  43.           static const char * const use_fixed_font;//   =         "useFixedFont";
  44.           static const char * const use_vector_font;//  =         "useVectorFont";
  45.     public:
  46.  
  47.  
  48.        // construct from another profile or from a file id in user profile.
  49.        ExternalFont(const AProfile& old_profile) : profile(old_profile) {};
  50.        ExternalFont() : profile("listpm","application_ini") {};
  51.  
  52.        // returns if the font is stored in the profile.
  53.        Boolean FontExistsExternally(void)
  54.        {
  55.             return
  56.                profile.containsKeyName(face_name)         &&
  57.                profile.containsKeyName(point_size)        &&
  58.                profile.containsKeyName(use_fixed_font)    &&
  59.                profile.containsKeyName(use_vector_font)   ;
  60.        };
  61.  
  62.        // construct a font from the info stored in the profile.
  63.        operator IFont() const
  64.        {
  65.             IString face   = profile.elementWithKey(face_name);
  66.             long    point  = profile.integerWithKey(point_size);
  67.             long    fixed  = profile.integerWithKey(use_fixed_font);
  68.             long    vector = profile.integerWithKey(use_vector_font);
  69.  
  70.             return IFont( face, point, Boolean(fixed), Boolean(vector) );
  71.        };
  72.  
  73.        // store the font info to the profile.
  74.        ExternalFont& operator<<(const IFont& font)
  75.        {
  76.             profile.addOrReplaceElementWithKey(face_name,font.name() );
  77.             profile.addOrReplaceElementWithKey(point_size,font.pointSize() );
  78.             profile.addOrReplaceElementWithKey(use_fixed_font,font.isFixed() );
  79.             profile.addOrReplaceElementWithKey(use_vector_font,font.isVectorOnly() );
  80.  
  81.             return *this;
  82.        };
  83. };
  84. #endif // GLBFONT
  85.