home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm4.zip / source / glbsize.hpp < prev    next >
C/C++ Source or Header  |  1998-04-22  |  4KB  |  130 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.     11900 Metric Blvd #J-181
  21.     Austin Tx 78758-3117
  22.     pelliott@io.com
  23. */
  24. #ifndef GLBSIZE
  25. #define GLBSIZE
  26. #include <ipoint.hpp>
  27.  
  28. #include "Ltper.hpp"
  29. #include "LtProf.hpp"
  30.  
  31. // Size structure (LONG values).
  32.  
  33. // typedef struct _SIZEL {
  34. // LONG   cx;  /*  Width. */
  35. // LONG   cy;  /*  Height. */
  36. //  } SIZEL;
  37. //
  38. // typedef SIZEL *PSIZEL;
  39.  
  40. // raw struct holding info of ISize, can be bytewise copied
  41. // and not reference to outside world such as pointers/
  42.  
  43. struct _SIZEL {
  44. long   cx;  /*  Width. */
  45. long   cy;  /*  Height. */
  46. };
  47.  
  48. // This constructor is declared but not defined
  49. // in Open class library.
  50. //ISize::ISize( const _SIZEL& raw_size)
  51. //{
  52. //    setHeight(raw_size.cx);
  53. //    setWidth(raw_size.cy);
  54. //};
  55.  
  56. // SIZEL is the essance of a PSize.
  57. // One can create an ISize from a PSize.
  58.  
  59.  
  60. class PSize : private SIZEL
  61. {
  62.   public:
  63.  
  64.     // can consturct a PSize from raw SIZEL.
  65.     PSize(const SIZEL& size) : SIZEL(size)  {};
  66.  
  67.     // conversion operator yeilds raw SIZEL.
  68.     operator SIZEL& ()
  69.     {
  70.         return *(SIZEL *) this;
  71.     };
  72.  
  73.     // get constant SIZEL from a const PSize.
  74.     operator const SIZEL& () const
  75.     {
  76.         return *(const SIZEL *) this;
  77.     };
  78.  
  79.     // can convert to an ISize.
  80.     operator ISize() const
  81.     {
  82.  
  83.        return ISize(cx,cy);
  84.     };
  85.  
  86.     // can be constructed from a ISize.
  87.     PSize( const ISize& size) : SIZEL(size.asSIZEL() ) {};
  88. };
  89.  
  90. // a source of PSizes.
  91. // Can create PSize from a stored Sizel.
  92. typedef ExternalExistance<PSize,SIZEL> ExternalSize;
  93.  
  94. // a source of PSizes from application profiles.
  95.  
  96. class SizeStore
  97. {
  98.      private:
  99.         ProfStorage storage;                  // Profile source.
  100.         ExternalSize size_existance;          // ExternalExistance from profile.
  101.      public:
  102.  
  103.         // constuctor. Profile from application name, user ini file.key=frame_size.
  104.         SizeStore() :
  105.           storage("listpm","application_ini","frame_size"),
  106.           // external existance from profile.
  107.           size_existance(storage)
  108.           {};
  109.  
  110.         // returns true when key exists in profile.
  111.         Boolean sizeExternal(void) { return size_existance.ExistsExternally(); };
  112.  
  113.         // get ISize stored externally.
  114.         operator ISize()
  115.         {
  116.            ExternalSize::Created created(size_existance);
  117.            return created.operator ISize();
  118.  
  119.         };
  120.  
  121.         // Store ISize in profile.
  122.         SizeStore& operator<<(const ISize& size)
  123.         {
  124.            PSize psize(size);
  125.            size_existance << psize;
  126.            return *this;
  127.         };
  128. };
  129. #endif // GLBSIZE
  130.