home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm7.zip / glbfont.hpp < prev    next >
C/C++ Source or Header  |  1999-06-12  |  3KB  |  87 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1998,1999  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.     PMB #181
  21.     11900 Metric Blvd Ste. J
  22.     Austin Tx 78758-3117
  23.     pelliott@io.com
  24. */
  25. #ifndef GLBFONT
  26. #define GLBFONT
  27. #include <ifont.hpp>
  28.  
  29. #include "AProfile.hpp"
  30.  
  31. // This object saves and restores IFonts.
  32. // could not use the Template tecnique for light weight
  33. // persistance because face name is varriable lengh.
  34. // do it the simple way using profiles.
  35.  
  36. class ExternalFont
  37. {
  38.     private:
  39.           AProfile profile;               // profile to save get profiles.
  40.  
  41.           // character strings.
  42.           static const char * const face_name;//        =         "faceName";
  43.           static const char * const point_size;//       =         "pointSize";
  44.           static const char * const use_fixed_font;//   =         "useFixedFont";
  45.           static const char * const use_vector_font;//  =         "useVectorFont";
  46.     public:
  47.  
  48.  
  49.        // construct from another profile or from a file id in user profile.
  50.        ExternalFont(const AProfile& old_profile) : profile(old_profile) {};
  51.        ExternalFont() : profile("listpm","application_ini") {};
  52.  
  53.        // returns if the font is stored in the profile.
  54.        Boolean FontExistsExternally(void)
  55.        {
  56.             return
  57.                profile.containsKeyName(face_name)         &&
  58.                profile.containsKeyName(point_size)        &&
  59.                profile.containsKeyName(use_fixed_font)    &&
  60.                profile.containsKeyName(use_vector_font)   ;
  61.        };
  62.  
  63.        // construct a font from the info stored in the profile.
  64.        // was const
  65.        operator IFont()
  66.        {
  67.             IString face   = profile.elementWithKey(face_name);
  68.             long    point  = profile.integerWithKey(point_size);
  69.             long    fixed  = profile.integerWithKey(use_fixed_font);
  70.             long    vector = profile.integerWithKey(use_vector_font);
  71.  
  72.             return IFont( face, point, Boolean(fixed), Boolean(vector) );
  73.        };
  74.  
  75.        // store the font info to the profile.
  76.        ExternalFont& operator<<(const IFont& font)
  77.        {
  78.             profile.addOrReplaceElementWithKey(face_name,font.name() );
  79.             profile.addOrReplaceElementWithKey(point_size,font.pointSize() );
  80.             profile.addOrReplaceElementWithKey(use_fixed_font,font.isFixed() );
  81.             profile.addOrReplaceElementWithKey(use_vector_font,font.isVectorOnly() );
  82.  
  83.             return *this;
  84.        };
  85. };
  86. #endif // GLBFONT
  87.