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

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