home *** CD-ROM | disk | FTP | other *** search
/ PC Direkt 1995 March / PCD_395.iso / starview / wntmsci / german / tools.hx_ / TOOLS.HXX
Encoding:
Text File  |  1994-10-25  |  147.6 KB  |  4,465 lines

  1. /*************************************************************************
  2. * TOOLS.HXX
  3. * Tue Oct 25 17:14:32 1994
  4. * (c) 1992-1994 STAR DIVISION
  5. *************************************************************************/
  6. #ifndef _TOOLS_HXX
  7. #define _TOOLS_HXX
  8. #ifndef _SOLAR_H
  9. #include <solar.h>
  10. #endif
  11.  
  12. #ifndef _TOOLS_H
  13. #define _TOOLS_H
  14.  
  15. #ifndef _SOLAR_H
  16. #endif
  17.  
  18. #endif 
  19.  
  20. #ifndef _NEW_HXX
  21. #define _NEW_HXX
  22.  
  23. #ifndef _TOOLS_H
  24. #endif
  25.  
  26. typedef void (*_NEW_HANDLER)();
  27. _NEW_HANDLER set_new_handler( _NEW_HANDLER pHandler );
  28.  
  29. #endif 
  30.  
  31. #ifndef _LINK_HXX
  32. #define _LINK_HXX
  33.  
  34. #ifndef _TOOLS_H
  35. #endif
  36.  
  37. class LinkHdl
  38. {
  39. };
  40.  
  41. typedef long (LinkHdl::*PFUNC)( void* pCaller );
  42.  
  43. class Link
  44. {
  45. protected:
  46.     LinkHdl*    pInst;
  47.     PFUNC       pMemFunc;
  48.  
  49. public:
  50.                 Link();
  51.                 Link( LinkHdl* pLinkHdl, PFUNC pProc );
  52.  
  53.     long        Call( void* pCaller );
  54.  
  55.     BOOL        IsSet() const;
  56.     BOOL        operator !() const;
  57.  
  58.     BOOL        operator==( const Link& rLink ) const;
  59.     BOOL        operator!=( const Link& rLink ) const;
  60.  
  61. #ifdef _MSC_VER
  62.  
  63.                 Link( const Link& rLink )
  64.                 {
  65.                     pInst    = rLink.pInst;
  66.                     pMemFunc = rLink.pMemFunc;
  67.                 }
  68.  
  69.     Link&       operator=( const Link& rLink )
  70.                 {
  71.                     pInst    = rLink.pInst;
  72.                     pMemFunc = rLink.pMemFunc;
  73.                     return *this;
  74.                 }
  75. #endif
  76. };
  77.  
  78. #ifndef MPW33
  79.  
  80. inline Link::Link()
  81. {
  82.     pInst = NULL;
  83.     pMemFunc = 0;
  84. }
  85.  
  86. inline Link::Link( LinkHdl* pLinkHdl, PFUNC pProc )
  87. {
  88.     pInst = pLinkHdl;
  89.     pMemFunc = pProc;
  90. }
  91.  
  92. #endif
  93.  
  94. inline long Link::Call( void* pCaller )
  95. {
  96.     if ( pInst != NULL && pMemFunc != NULL )
  97.         return (pInst->*pMemFunc)( pCaller );
  98.     else
  99.         return FALSE;
  100. }
  101.  
  102. inline BOOL Link::IsSet() const
  103. {
  104.     if ( pInst != NULL && pMemFunc != NULL )
  105.         return TRUE;
  106.     else
  107.         return FALSE;
  108. }
  109.  
  110. inline BOOL Link::operator !() const
  111. {
  112.     if ( pInst == NULL || pMemFunc == NULL )
  113.         return TRUE;
  114.     else
  115.         return FALSE;
  116. }
  117.  
  118. #if !defined( __ZTC__ )
  119. #define LINK( pInst, Class, pMemFunc ) \
  120.             Link( (LinkHdl*)(void*)pInst, \
  121.                   (PFUNC) (long (Class::*)( void* )) &Class::pMemFunc )
  122. #define LINK2( pInst, Class, pMemFunc ) \
  123.             Link( (LinkHdl*)pInst, \
  124.                   (PFUNC) (long (Class::*)( void* )) &Class::pMemFunc )
  125. #else
  126. #define LINK( pInst, Class, pMemFunc ) \
  127.             Link( pInst, (PFUNC) &Class::pMemFunc )
  128. #define LINK2( pInst, Class, pMemFunc ) \
  129.             Link( (LinkHdl*)(void*)pInst, (PFUNC) &Class::pMemFunc )
  130. #endif
  131.  
  132. #endif  
  133.  
  134. #define _PAIR Pair
  135. #define _POINT Point
  136. #define _SIZE Size
  137. #define _RANGE Range
  138. #define _SELECTION Selection
  139. #define _RECTANGLE Rectangle
  140.  
  141. #define _PAIR_2 LPair
  142. #define _POINT_2 LPoint
  143. #define _SIZE_2 LSize
  144. #define _RANGE_2 LRange
  145. #define _SELECTION_2 LSelection
  146. #define _RECTANGLE_2 LRectangle
  147.  
  148. #define _SL_TYPE short
  149.  
  150. #define RANGE_MIN   ((short)0x8000)
  151. #define RANGE_MAX   0x7FFF
  152.  
  153. #define SELECTION_MIN   ((short)0x8000)
  154. #define SELECTION_MAX   0x7FFF
  155.  
  156. #ifndef _TOOLS_H
  157. #endif
  158.  
  159. class _PAIR_2;
  160. class _POINT_2;
  161. class _SIZE_2;
  162. class _RANGE_2;
  163. class _SELECTION_2;
  164. class _RECTANGLE_2;
  165.  
  166. class _PAIR
  167. {
  168. protected:
  169.     _SL_TYPE    nA;
  170.     _SL_TYPE    nB;
  171.  
  172.     friend _PAIR_2;
  173.  
  174. public:
  175.     _PAIR();
  176.     _PAIR( const _PAIR& rPair );
  177.     _PAIR( _SL_TYPE nA, _SL_TYPE nB );
  178.     _PAIR( const _PAIR_2& rPair );
  179.  
  180.     _SL_TYPE    A() const { return nA; }
  181.     _SL_TYPE    B() const { return nB; }
  182.  
  183.     _SL_TYPE&   A() { return nA; }
  184.     _SL_TYPE&   B() { return nB; }
  185.  
  186.     BOOL        operator == ( const _PAIR& rPair ) const;
  187.     BOOL        operator != ( const _PAIR& rPair ) const;
  188.  
  189.     _PAIR&      operator = ( const _PAIR& rPair );
  190.     _PAIR&      operator = ( const _PAIR_2& rPair );
  191. };
  192.  
  193. inline _PAIR::_PAIR()
  194. {
  195.     nA = nB = 0;
  196. }
  197.  
  198. inline _PAIR::_PAIR( const _PAIR& rPair )
  199. {
  200.     nA = rPair.nA;
  201.     nB = rPair.nB;
  202. }
  203.  
  204. inline _PAIR& _PAIR::operator = ( const _PAIR& rPair )
  205. {
  206.     nA = rPair.nA;
  207.     nB = rPair.nB;
  208.     return *this;
  209. }
  210.  
  211. class _POINT : public _PAIR
  212. {
  213. public:
  214.     _POINT();
  215.     _POINT( const _POINT& rPOINT );
  216.     _POINT( _SL_TYPE nX, _SL_TYPE nY );
  217.     _POINT( const _POINT_2& rPoint );
  218.  
  219.     _POINT&         operator += ( const _POINT& rPoint );
  220.     _POINT&         operator -= ( const _POINT& rPoint );
  221.     _POINT&         operator *= ( const _SL_TYPE nVal );
  222.     _POINT&         operator /= ( const _SL_TYPE nVal );
  223.  
  224. #ifdef __BORLANDC__
  225.     friend _POINT operator+( const _POINT &rVal1, const _POINT &rVal2 );
  226.     friend _POINT operator-( const _POINT &rVal1, const _POINT &rVal2 );
  227.     friend _POINT operator*( const _POINT &rVal1, const _SL_TYPE nVal2 );
  228.     friend _POINT operator/( const _POINT &rVal1, const _SL_TYPE nVal2 );
  229. #else
  230.     friend inline _POINT operator+( const _POINT &rVal1, const _POINT &rVal2 );
  231.     friend inline _POINT operator-( const _POINT &rVal1, const _POINT &rVal2 );
  232.     friend inline _POINT operator*( const _POINT &rVal1, const _SL_TYPE nVal2 );
  233.     friend inline _POINT operator/( const _POINT &rVal1, const _SL_TYPE nVal2 );
  234. #endif
  235.  
  236.     _SL_TYPE        X() const { return nA; }
  237.     _SL_TYPE        Y() const { return nB; }
  238.  
  239.     _SL_TYPE&       X() { return nA; }
  240.     _SL_TYPE&       Y() { return nB; }
  241.  
  242.     BOOL            IsAbove( const _POINT& rPoint ) const;
  243.     BOOL            IsBelow( const _POINT& rPoint ) const;
  244.     BOOL            IsLeft( const _POINT& rPoint ) const;
  245.     BOOL            IsRight( const _POINT& rPoint ) const;
  246. };
  247.  
  248. inline _POINT::_POINT()
  249. {
  250. }
  251.  
  252. inline _POINT::_POINT( const _POINT& rPoint ) : _PAIR( rPoint )
  253. {
  254. }
  255.  
  256. class _SIZE : public _PAIR
  257. {
  258. public:
  259.     _SIZE();
  260.     _SIZE( const _SIZE& rSize );
  261.     _SIZE( _SL_TYPE nWidth, _SL_TYPE nHeight );
  262.     _SIZE( const _SIZE_2& rSize );
  263.  
  264.     _SL_TYPE    Width() const  { return nA; }
  265.     _SL_TYPE    Height() const { return nB; }
  266.  
  267.     _SL_TYPE&   Width()  { return nA; }
  268.     _SL_TYPE&   Height() { return nB; }
  269. };
  270.  
  271. inline _SIZE::_SIZE()
  272. {
  273. }
  274.  
  275. inline _SIZE::_SIZE( const _SIZE& rSize ) : _PAIR( rSize )
  276. {
  277. }
  278.  
  279. class _RANGE : public _PAIR
  280. {
  281. public:
  282.     _RANGE();
  283.     _RANGE( const _RANGE& rRange );
  284.     _RANGE( _SL_TYPE nMin, _SL_TYPE nMax );
  285.     _RANGE( const _RANGE_2& rRange );
  286.  
  287.     _SL_TYPE    Min() const { return nA; }
  288.     _SL_TYPE    Max() const { return nB; }
  289.     _SL_TYPE    Len() const { return nB - nA + 1; }
  290.  
  291.     _SL_TYPE&   Min() { return nA; }
  292.     _SL_TYPE&   Max() { return nB; }
  293.  
  294.     BOOL        IsInside( _SL_TYPE nIs ) const;
  295.  
  296.     void        Justify();
  297. };
  298.  
  299. inline _RANGE::_RANGE()
  300. {
  301. }
  302.  
  303. inline _RANGE::_RANGE( const _RANGE& rRange ) : _PAIR( rRange )
  304. {
  305. }
  306.  
  307. class _SELECTION : public _PAIR
  308. {
  309. public:
  310.     _SELECTION();
  311.     _SELECTION( const _SELECTION& rSelection );
  312.     _SELECTION( _SL_TYPE nPos );
  313.     _SELECTION( _SL_TYPE nMin, _SL_TYPE nMax );
  314.     _SELECTION( const _SELECTION_2& rSelection );
  315.  
  316.     _SL_TYPE    Min() const { return nA; }
  317.     _SL_TYPE    Max() const { return nB; }
  318.     _SL_TYPE    Len() const { return nB - nA; }
  319.  
  320.     _SL_TYPE&   Min() { return nA; }
  321.     _SL_TYPE&   Max() { return nB; }
  322.  
  323.     BOOL        IsInside( _SL_TYPE nIs ) const;
  324.  
  325.     void        Justify();
  326.  
  327.     BOOL        operator !() const { return !Len(); }
  328. };
  329.  
  330. inline _SELECTION::_SELECTION()
  331. {
  332. }
  333.  
  334. inline _SELECTION::_SELECTION( const _SELECTION& rSelection ) :
  335.            _PAIR( rSelection )
  336. {
  337. }
  338.  
  339. #define RECT_EMPTY  ((short)-32767)
  340.  
  341. class _RECTANGLE
  342. {
  343. private:
  344.     _SL_TYPE    nLeft;
  345.     _SL_TYPE    nTop;
  346.     _SL_TYPE    nRight;
  347.     _SL_TYPE    nBottom;
  348.  
  349.     friend _RECTANGLE_2;
  350.  
  351. public:
  352.     _RECTANGLE();
  353.     _RECTANGLE( const _RECTANGLE& rRect );
  354.     _RECTANGLE( const _POINT& rLT, const _POINT& rRB );
  355.     _RECTANGLE( _SL_TYPE nLeft, _SL_TYPE nTop,
  356.                 _SL_TYPE nRight, _SL_TYPE nBottom );
  357.     _RECTANGLE( const _POINT& rLT, const _SIZE& rSize );
  358.     _RECTANGLE( const _RECTANGLE_2& rRect );
  359.  
  360.     _SL_TYPE    Left() const    { return nLeft;   }
  361.     _SL_TYPE    Right() const   { return nRight;  }
  362.     _SL_TYPE    Top() const     { return nTop;    }
  363.     _SL_TYPE    Bottom() const  { return nBottom; }
  364.  
  365.     _SL_TYPE&   Left()          { return nLeft;   }
  366.     _SL_TYPE&   Right()         { return nRight;  }
  367.     _SL_TYPE&   Top()           { return nTop;    }
  368.     _SL_TYPE&   Bottom()        { return nBottom; }
  369.  
  370.     _POINT      TopLeft() const;
  371.     _POINT      TopRight() const;
  372.     _POINT      TopCenter() const;
  373.     _POINT      BottomLeft() const;
  374.     _POINT      BottomRight() const;
  375.     _POINT      BottomCenter() const;
  376.     _POINT      LeftCenter() const;
  377.     _POINT      RightCenter() const;
  378.     _POINT      Center() const;
  379.  
  380.     _POINT      ChangePos( const _POINT& rPoint );
  381.     _SIZE       ChangeSize( const _SIZE rSize );
  382.     _SIZE       GetSize() const;
  383.  
  384.     _SL_TYPE    GetWidth() const;
  385.     _SL_TYPE    GetHeight() const;
  386.  
  387.     _RECTANGLE& Union( const _RECTANGLE& rRect );
  388.     _RECTANGLE& Intersection( const _RECTANGLE& rRect );
  389.     _RECTANGLE  GetUnion( const _RECTANGLE& rRect ) const;
  390.     _RECTANGLE  GetIntersection( const _RECTANGLE& rRect ) const;
  391.  
  392.     void        Justify();
  393.  
  394.     BOOL        IsInside( const _POINT& rPOINT ) const;
  395.     BOOL        IsInside( const _RECTANGLE& rRect ) const;
  396.     BOOL        IsOver( const _RECTANGLE& rRect ) const;
  397.  
  398.     BOOL        IsEmpty() const;
  399.  
  400.     BOOL        operator == ( const _RECTANGLE& rRect ) const;
  401.     BOOL        operator != ( const _RECTANGLE& rRect ) const;
  402.  
  403.     _RECTANGLE& operator = ( const _RECTANGLE& rRect );
  404.     _RECTANGLE& operator = ( const _RECTANGLE_2& rRect );
  405. };
  406.  
  407. inline _RECTANGLE::_RECTANGLE()
  408. {
  409.     nLeft  = nTop    = 0;
  410.     nRight = nBottom = RECT_EMPTY;
  411. }
  412.  
  413. inline _RECTANGLE::_RECTANGLE( const _RECTANGLE& rRect )
  414. {
  415.     nLeft   = rRect.nLeft;
  416.     nTop    = rRect.nTop;
  417.     nRight  = rRect.nRight;
  418.     nBottom = rRect.nBottom;
  419. }
  420.  
  421. inline _RECTANGLE& _RECTANGLE::operator = ( const _RECTANGLE& rRect )
  422. {
  423.     nLeft   = rRect.nLeft;
  424.     nTop    = rRect.nTop;
  425.     nRight  = rRect.nRight;
  426.     nBottom = rRect.nBottom;
  427.     return *this;
  428. }
  429.  
  430. #undef _PAIR
  431. #undef _POINT
  432. #undef _SIZE
  433. #undef _RANGE
  434. #undef _SELECTION
  435. #undef _RECTANGLE
  436.  
  437. #undef _PAIR_2
  438. #undef _POINT_2
  439. #undef _SIZE_2
  440. #undef _RANGE_2
  441. #undef _SELECTION_2
  442. #undef _RECTANGLE_2
  443.  
  444. #undef _SL_TYPE
  445.  
  446. #ifdef __private
  447. #undef private
  448. #undef __private
  449. #endif
  450.  
  451. #ifdef __protected
  452. #undef protected
  453. #undef __protected
  454. #endif
  455.  
  456. #ifndef private
  457. #define private     public
  458. #define __private
  459. #endif
  460.  
  461. #ifndef protected
  462. #define protected   public
  463. #define __protected
  464. #endif
  465.  
  466. #define _PAIR LPair
  467. #define _POINT LPoint
  468. #define _SIZE LSize
  469. #define _RANGE LRange
  470. #define _SELECTION LSelection
  471. #define _RECTANGLE LRectangle
  472.  
  473. #define _PAIR_2 Pair
  474. #define _POINT_2 Point
  475. #define _SIZE_2 Size
  476. #define _RANGE_2 Range
  477. #define _SELECTION_2 Selection
  478. #define _RECTANGLE_2 Rectangle
  479.  
  480. #define _SL_TYPE long
  481.  
  482. #define LRANGE_MIN   ((long)0x80000000L)
  483. #define LRANGE_MAX   0x7FFFFFFFL
  484.  
  485. #define LSELECTION_MIN   ((long)0x80000000L)
  486. #define LSELECTION_MAX   0x7FFFFFFFL
  487.  
  488. #ifndef _TOOLS_H
  489. #endif
  490.  
  491. class _PAIR_2;
  492. class _POINT_2;
  493. class _SIZE_2;
  494. class _RANGE_2;
  495. class _SELECTION_2;
  496. class _RECTANGLE_2;
  497.  
  498. class _PAIR
  499. {
  500. protected:
  501.     _SL_TYPE    nA;
  502.     _SL_TYPE    nB;
  503.  
  504.     friend _PAIR_2;
  505.  
  506. public:
  507.     _PAIR();
  508.     _PAIR( const _PAIR& rPair );
  509.     _PAIR( _SL_TYPE nA, _SL_TYPE nB );
  510.     _PAIR( const _PAIR_2& rPair );
  511.  
  512.     _SL_TYPE    A() const { return nA; }
  513.     _SL_TYPE    B() const { return nB; }
  514.  
  515.     _SL_TYPE&   A() { return nA; }
  516.     _SL_TYPE&   B() { return nB; }
  517.  
  518.     BOOL        operator == ( const _PAIR& rPair ) const;
  519.     BOOL        operator != ( const _PAIR& rPair ) const;
  520.  
  521.     _PAIR&      operator = ( const _PAIR& rPair );
  522.     _PAIR&      operator = ( const _PAIR_2& rPair );
  523. };
  524.  
  525. inline _PAIR::_PAIR()
  526. {
  527.     nA = nB = 0;
  528. }
  529.  
  530. inline _PAIR::_PAIR( const _PAIR& rPair )
  531. {
  532.     nA = rPair.nA;
  533.     nB = rPair.nB;
  534. }
  535.  
  536. inline _PAIR& _PAIR::operator = ( const _PAIR& rPair )
  537. {
  538.     nA = rPair.nA;
  539.     nB = rPair.nB;
  540.     return *this;
  541. }
  542.  
  543. class _POINT : public _PAIR
  544. {
  545. public:
  546.     _POINT();
  547.     _POINT( const _POINT& rPOINT );
  548.     _POINT( _SL_TYPE nX, _SL_TYPE nY );
  549.     _POINT( const _POINT_2& rPoint );
  550.  
  551.     _POINT&         operator += ( const _POINT& rPoint );
  552.     _POINT&         operator -= ( const _POINT& rPoint );
  553.     _POINT&         operator *= ( const _SL_TYPE nVal );
  554.     _POINT&         operator /= ( const _SL_TYPE nVal );
  555.  
  556. #ifdef __BORLANDC__
  557.     friend _POINT operator+( const _POINT &rVal1, const _POINT &rVal2 );
  558.     friend _POINT operator-( const _POINT &rVal1, const _POINT &rVal2 );
  559.     friend _POINT operator*( const _POINT &rVal1, const _SL_TYPE nVal2 );
  560.     friend _POINT operator/( const _POINT &rVal1, const _SL_TYPE nVal2 );
  561. #else
  562.     friend inline _POINT operator+( const _POINT &rVal1, const _POINT &rVal2 );
  563.     friend inline _POINT operator-( const _POINT &rVal1, const _POINT &rVal2 );
  564.     friend inline _POINT operator*( const _POINT &rVal1, const _SL_TYPE nVal2 );
  565.     friend inline _POINT operator/( const _POINT &rVal1, const _SL_TYPE nVal2 );
  566. #endif
  567.  
  568.     _SL_TYPE        X() const { return nA; }
  569.     _SL_TYPE        Y() const { return nB; }
  570.  
  571.     _SL_TYPE&       X() { return nA; }
  572.     _SL_TYPE&       Y() { return nB; }
  573.  
  574.     BOOL            IsAbove( const _POINT& rPoint ) const;
  575.     BOOL            IsBelow( const _POINT& rPoint ) const;
  576.     BOOL            IsLeft( const _POINT& rPoint ) const;
  577.     BOOL            IsRight( const _POINT& rPoint ) const;
  578. };
  579.  
  580. inline _POINT::_POINT()
  581. {
  582. }
  583.  
  584. inline _POINT::_POINT( const _POINT& rPoint ) : _PAIR( rPoint )
  585. {
  586. }
  587.  
  588. class _SIZE : public _PAIR
  589. {
  590. public:
  591.     _SIZE();
  592.     _SIZE( const _SIZE& rSize );
  593.     _SIZE( _SL_TYPE nWidth, _SL_TYPE nHeight );
  594.     _SIZE( const _SIZE_2& rSize );
  595.  
  596.     _SL_TYPE    Width() const  { return nA; }
  597.     _SL_TYPE    Height() const { return nB; }
  598.  
  599.     _SL_TYPE&   Width()  { return nA; }
  600.     _SL_TYPE&   Height() { return nB; }
  601. };
  602.  
  603. inline _SIZE::_SIZE()
  604. {
  605. }
  606.  
  607. inline _SIZE::_SIZE( const _SIZE& rSize ) : _PAIR( rSize )
  608. {
  609. }
  610.  
  611. class _RANGE : public _PAIR
  612. {
  613. public:
  614.     _RANGE();
  615.     _RANGE( const _RANGE& rRange );
  616.     _RANGE( _SL_TYPE nMin, _SL_TYPE nMax );
  617.     _RANGE( const _RANGE_2& rRange );
  618.  
  619.     _SL_TYPE    Min() const { return nA; }
  620.     _SL_TYPE    Max() const { return nB; }
  621.     _SL_TYPE    Len() const { return nB - nA + 1; }
  622.  
  623.     _SL_TYPE&   Min() { return nA; }
  624.     _SL_TYPE&   Max() { return nB; }
  625.  
  626.     BOOL        IsInside( _SL_TYPE nIs ) const;
  627.  
  628.     void        Justify();
  629. };
  630.  
  631. inline _RANGE::_RANGE()
  632. {
  633. }
  634.  
  635. inline _RANGE::_RANGE( const _RANGE& rRange ) : _PAIR( rRange )
  636. {
  637. }
  638.  
  639. class _SELECTION : public _PAIR
  640. {
  641. public:
  642.     _SELECTION();
  643.     _SELECTION( const _SELECTION& rSelection );
  644.     _SELECTION( _SL_TYPE nPos );
  645.     _SELECTION( _SL_TYPE nMin, _SL_TYPE nMax );
  646.     _SELECTION( const _SELECTION_2& rSelection );
  647.  
  648.     _SL_TYPE    Min() const { return nA; }
  649.     _SL_TYPE    Max() const { return nB; }
  650.     _SL_TYPE    Len() const { return nB - nA; }
  651.  
  652.     _SL_TYPE&   Min() { return nA; }
  653.     _SL_TYPE&   Max() { return nB; }
  654.  
  655.     BOOL        IsInside( _SL_TYPE nIs ) const;
  656.  
  657.     void        Justify();
  658.  
  659.     BOOL        operator !() const { return !Len(); }
  660. };
  661.  
  662. inline _SELECTION::_SELECTION()
  663. {
  664. }
  665.  
  666. inline _SELECTION::_SELECTION( const _SELECTION& rSelection ) :
  667.            _PAIR( rSelection )
  668. {
  669. }
  670.  
  671. #define RECT_EMPTY  ((short)-32767)
  672.  
  673. class _RECTANGLE
  674. {
  675. private:
  676.     _SL_TYPE    nLeft;
  677.     _SL_TYPE    nTop;
  678.     _SL_TYPE    nRight;
  679.     _SL_TYPE    nBottom;
  680.  
  681.     friend _RECTANGLE_2;
  682.  
  683. public:
  684.     _RECTANGLE();
  685.     _RECTANGLE( const _RECTANGLE& rRect );
  686.     _RECTANGLE( const _POINT& rLT, const _POINT& rRB );
  687.     _RECTANGLE( _SL_TYPE nLeft, _SL_TYPE nTop,
  688.                 _SL_TYPE nRight, _SL_TYPE nBottom );
  689.     _RECTANGLE( const _POINT& rLT, const _SIZE& rSize );
  690.     _RECTANGLE( const _RECTANGLE_2& rRect );
  691.  
  692.     _SL_TYPE    Left() const    { return nLeft;   }
  693.     _SL_TYPE    Right() const   { return nRight;  }
  694.     _SL_TYPE    Top() const     { return nTop;    }
  695.     _SL_TYPE    Bottom() const  { return nBottom; }
  696.  
  697.     _SL_TYPE&   Left()          { return nLeft;   }
  698.     _SL_TYPE&   Right()         { return nRight;  }
  699.     _SL_TYPE&   Top()           { return nTop;    }
  700.     _SL_TYPE&   Bottom()        { return nBottom; }
  701.  
  702.     _POINT      TopLeft() const;
  703.     _POINT      TopRight() const;
  704.     _POINT      TopCenter() const;
  705.     _POINT      BottomLeft() const;
  706.     _POINT      BottomRight() const;
  707.     _POINT      BottomCenter() const;
  708.     _POINT      LeftCenter() const;
  709.     _POINT      RightCenter() const;
  710.     _POINT      Center() const;
  711.  
  712.     _POINT      ChangePos( const _POINT& rPoint );
  713.     _SIZE       ChangeSize( const _SIZE rSize );
  714.     _SIZE       GetSize() const;
  715.  
  716.     _SL_TYPE    GetWidth() const;
  717.     _SL_TYPE    GetHeight() const;
  718.  
  719.     _RECTANGLE& Union( const _RECTANGLE& rRect );
  720.     _RECTANGLE& Intersection( const _RECTANGLE& rRect );
  721.     _RECTANGLE  GetUnion( const _RECTANGLE& rRect ) const;
  722.     _RECTANGLE  GetIntersection( const _RECTANGLE& rRect ) const;
  723.  
  724.     void        Justify();
  725.  
  726.     BOOL        IsInside( const _POINT& rPOINT ) const;
  727.     BOOL        IsInside( const _RECTANGLE& rRect ) const;
  728.     BOOL        IsOver( const _RECTANGLE& rRect ) const;
  729.  
  730.     BOOL        IsEmpty() const;
  731.  
  732.     BOOL        operator == ( const _RECTANGLE& rRect ) const;
  733.     BOOL        operator != ( const _RECTANGLE& rRect ) const;
  734.  
  735.     _RECTANGLE& operator = ( const _RECTANGLE& rRect );
  736.     _RECTANGLE& operator = ( const _RECTANGLE_2& rRect );
  737. };
  738.  
  739. inline _RECTANGLE::_RECTANGLE()
  740. {
  741.     nLeft  = nTop    = 0;
  742.     nRight = nBottom = RECT_EMPTY;
  743. }
  744.  
  745. inline _RECTANGLE::_RECTANGLE( const _RECTANGLE& rRect )
  746. {
  747.     nLeft   = rRect.nLeft;
  748.     nTop    = rRect.nTop;
  749.     nRight  = rRect.nRight;
  750.     nBottom = rRect.nBottom;
  751. }
  752.  
  753. inline _RECTANGLE& _RECTANGLE::operator = ( const _RECTANGLE& rRect )
  754. {
  755.     nLeft   = rRect.nLeft;
  756.     nTop    = rRect.nTop;
  757.     nRight  = rRect.nRight;
  758.     nBottom = rRect.nBottom;
  759.     return *this;
  760. }
  761.  
  762. #undef _PAIR
  763. #undef _POINT
  764. #undef _SIZE
  765. #undef _RANGE
  766. #undef _SELECTION
  767. #undef _RECTANGLE
  768.  
  769. #undef _PAIR_2
  770. #undef _POINT_2
  771. #undef _SIZE_2
  772. #undef _RANGE_2
  773. #undef _SELECTION_2
  774. #undef _RECTANGLE_2
  775.  
  776. #undef _SL_TYPE
  777.  
  778. #ifdef __private
  779. #undef private
  780. #undef __private
  781. #endif
  782.  
  783. #ifdef __protected
  784. #undef protected
  785. #undef __protected
  786. #endif
  787.  
  788. #define _PAIR Pair
  789. #define _POINT Point
  790. #define _SIZE Size
  791. #define _RANGE Range
  792. #define _SELECTION Selection
  793. #define _RECTANGLE Rectangle
  794.  
  795. #define _PAIR_2 LPair
  796. #define _POINT_2 LPoint
  797. #define _SIZE_2 LSize
  798. #define _RANGE_2 LRange
  799. #define _SELECTION_2 LSelection
  800. #define _RECTANGLE_2 LRectangle
  801.  
  802. #define _SL_TYPE short
  803.  
  804. #define RANGE_MIN   ((short)0x8000)
  805. #define RANGE_MAX   0x7FFF
  806.  
  807. #define SELECTION_MIN   ((short)0x8000)
  808. #define SELECTION_MAX   0x7FFF
  809.  
  810. inline _PAIR::_PAIR( _SL_TYPE _nA, _SL_TYPE _nB )
  811. {
  812.     _PAIR::nA = _nA;
  813.     _PAIR::nB = _nB;
  814. }
  815.  
  816. inline _PAIR::_PAIR( const _PAIR_2& rPair )
  817. {
  818.     nA = (_SL_TYPE)rPair.nA;
  819.     nB = (_SL_TYPE)rPair.nB;
  820. }
  821.  
  822. inline BOOL _PAIR::operator == ( const _PAIR& rPair ) const
  823. {
  824.     if ( (nA == rPair.nA) && (nB == rPair.nB) )
  825.         return TRUE;
  826.     else
  827.         return FALSE;
  828. }
  829.  
  830. inline BOOL _PAIR::operator != ( const _PAIR& rPair ) const
  831. {
  832.     if ( (nA != rPair.nA) || (nB != rPair.nB) )
  833.         return TRUE;
  834.     else
  835.         return FALSE;
  836. }
  837.  
  838. inline _PAIR& _PAIR::operator = ( const _PAIR_2& rPair )
  839. {
  840.     nA = (_SL_TYPE)rPair.nA;
  841.     nB = (_SL_TYPE)rPair.nB;
  842.     return *this;
  843. }
  844.  
  845. inline _POINT::_POINT( _SL_TYPE nX, _SL_TYPE nY ) : _PAIR( nX, nY )
  846. {
  847. }
  848.  
  849. inline _POINT::_POINT( const _POINT_2& rPoint ) : _PAIR( rPoint )
  850. {
  851. }
  852.  
  853. inline _POINT& _POINT::operator += ( const _POINT& rPoint )
  854. {
  855.     nA += rPoint.nA;
  856.     nB += rPoint.nB;
  857.     return *this;
  858. }
  859.  
  860. inline _POINT& _POINT::operator -= ( const _POINT& rPoint )
  861. {
  862.     nA -= rPoint.nA;
  863.     nB -= rPoint.nB;
  864.     return *this;
  865. }
  866.  
  867. inline _POINT& _POINT::operator *= ( const _SL_TYPE nVal )
  868. {
  869.     nA *= nVal;
  870.     nB *= nVal;
  871.     return *this;
  872. }
  873.  
  874. inline _POINT& _POINT::operator /= ( const _SL_TYPE nVal )
  875. {
  876.     nA /= nVal;
  877.     nB /= nVal;
  878.     return *this;
  879. }
  880.  
  881. inline _POINT operator+( const _POINT &rVal1, const _POINT &rVal2 )
  882. {
  883.     return _POINT( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB );
  884. }
  885.  
  886. inline _POINT operator-( const _POINT &rVal1, const _POINT &rVal2 )
  887. {
  888.     return _POINT( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB );
  889. }
  890.  
  891. inline _POINT operator*( const _POINT &rVal1, const _SL_TYPE nVal2 )
  892. {
  893.     return _POINT( rVal1.nA*nVal2, rVal1.nB*nVal2 );
  894. }
  895.  
  896. inline _POINT operator/( const _POINT &rVal1, const _SL_TYPE nVal2 )
  897. {
  898.     return _POINT( rVal1.nA/nVal2, rVal1.nB/nVal2 );
  899. }
  900.  
  901. inline BOOL _POINT::IsAbove( const _POINT& rPoint ) const
  902. {
  903.     if ( nB > rPoint.nB )
  904.         return TRUE;
  905.     else
  906.         return FALSE;
  907. }
  908.  
  909. inline BOOL _POINT::IsBelow( const _POINT& rPoint ) const
  910. {
  911.     if ( nB < rPoint.nB )
  912.         return TRUE;
  913.     else
  914.         return FALSE;
  915. }
  916.  
  917. inline BOOL _POINT::IsLeft( const _POINT& rPoint ) const
  918. {
  919.     if ( nA < rPoint.nA )
  920.         return TRUE;
  921.     else
  922.         return FALSE;
  923. }
  924.  
  925. inline BOOL _POINT::IsRight( const _POINT& rPoint ) const
  926. {
  927.     if ( nA > rPoint.nA )
  928.         return TRUE;
  929.     else
  930.         return FALSE;
  931. }
  932.  
  933. inline _SIZE::_SIZE( _SL_TYPE nWidth, _SL_TYPE nHeight ) :
  934.             _PAIR( nWidth, nHeight )
  935. {
  936. }
  937.  
  938. inline _SIZE::_SIZE( const _SIZE_2& rSize ) : _PAIR( rSize )
  939. {
  940. }
  941.  
  942. inline _RANGE::_RANGE( _SL_TYPE nMin, _SL_TYPE nMax ) : _PAIR( nMin, nMax )
  943. {
  944. }
  945.  
  946. inline _RANGE::_RANGE( const _RANGE_2& rRange ) : _PAIR( rRange )
  947. {
  948. }
  949.  
  950. inline BOOL _RANGE::IsInside( _SL_TYPE nIs ) const
  951. {
  952.     if ( (nA <= nIs) && (nIs <= nB ) )
  953.         return TRUE;
  954.     else
  955.         return FALSE;
  956. }
  957.  
  958. inline void _RANGE::Justify()
  959. {
  960.     if ( nA > nB )
  961.     {
  962.         _SL_TYPE nHelp = nA;
  963.         nA = nB;
  964.         nB = nHelp;
  965.     }
  966. }
  967.  
  968. inline _SELECTION::_SELECTION( _SL_TYPE nPos ) : _PAIR( nPos, nPos )
  969. {
  970. }
  971.  
  972. inline _SELECTION::_SELECTION( _SL_TYPE nMin, _SL_TYPE nMax ) :
  973.            _PAIR( nMin, nMax )
  974. {
  975. }
  976.  
  977. inline _SELECTION::_SELECTION( const _SELECTION_2& rSelection ) :
  978.            _PAIR( rSelection )
  979. {
  980. }
  981.  
  982. inline BOOL _SELECTION::IsInside( _SL_TYPE nIs ) const
  983. {
  984.     if ( (nA <= nIs) && (nIs < nB ) )
  985.         return TRUE;
  986.     else
  987.         return FALSE;
  988. }
  989.  
  990. inline void _SELECTION::Justify()
  991. {
  992.     if ( nA > nB )
  993.     {
  994.         _SL_TYPE nHelp = nA;
  995.         nA = nB;
  996.         nB = nHelp;
  997.     }
  998. }
  999.  
  1000. inline _RECTANGLE::_RECTANGLE( const _POINT& rLT, const _POINT& rRB )
  1001. {
  1002.     nLeft   = rLT.X();
  1003.     nTop    = rLT.Y();
  1004.     nRight  = rRB.X();
  1005.     nBottom = rRB.Y();
  1006. }
  1007.  
  1008. inline _RECTANGLE::_RECTANGLE( _SL_TYPE _nLeft,  _SL_TYPE _nTop,
  1009.                                _SL_TYPE _nRight, _SL_TYPE _nBottom )
  1010. {
  1011.     _RECTANGLE::nLeft   = _nLeft;
  1012.     _RECTANGLE::nTop    = _nTop;
  1013.     _RECTANGLE::nRight  = _nRight;
  1014.     _RECTANGLE::nBottom = _nBottom;
  1015. }
  1016.  
  1017. inline _RECTANGLE::_RECTANGLE( const _POINT& rLT, const _SIZE& rSize )
  1018. {
  1019.     nLeft   = rLT.X();
  1020.     nTop    = rLT.Y();
  1021.     nRight  = rSize.Width()  ? nLeft+rSize.Width()-1 : RECT_EMPTY;
  1022.     nBottom = rSize.Height() ? nTop+rSize.Height()-1 : RECT_EMPTY;
  1023. }
  1024.  
  1025. inline _RECTANGLE::_RECTANGLE( const _RECTANGLE_2& rRect )
  1026. {
  1027.     nLeft   = (_SL_TYPE)rRect.nLeft;
  1028.     nTop    = (_SL_TYPE)rRect.nTop;
  1029.     nRight  = (_SL_TYPE)rRect.nRight;
  1030.     nBottom = (_SL_TYPE)rRect.nBottom;
  1031. }
  1032.  
  1033. inline _RECTANGLE& _RECTANGLE::operator = ( const _RECTANGLE_2& rRect )
  1034. {
  1035.     nLeft   = (_SL_TYPE)rRect.nLeft;
  1036.     nTop    = (_SL_TYPE)rRect.nTop;
  1037.     nRight  = (_SL_TYPE)rRect.nRight;
  1038.     nBottom = (_SL_TYPE)rRect.nBottom;
  1039.     return *this;
  1040. }
  1041.  
  1042. inline _POINT _RECTANGLE::TopLeft() const
  1043. {
  1044.     return _POINT( nLeft, nTop );
  1045. }
  1046.  
  1047. inline _POINT _RECTANGLE::TopRight() const
  1048. {
  1049.     return _POINT( (nRight == RECT_EMPTY) ? nLeft : nRight,
  1050.                    nTop );
  1051. }
  1052.  
  1053. inline _POINT _RECTANGLE::BottomLeft() const
  1054. {
  1055.     return _POINT( nLeft,
  1056.                    (nBottom == RECT_EMPTY) ? nTop : nBottom );
  1057. }
  1058.  
  1059. inline _POINT _RECTANGLE::BottomRight() const
  1060. {
  1061.     return _POINT( (nRight  == RECT_EMPTY) ? nLeft : nRight,
  1062.                    (nBottom == RECT_EMPTY) ? nTop  : nBottom );
  1063. }
  1064.  
  1065. inline _SL_TYPE _RECTANGLE::GetWidth() const
  1066. {
  1067.     _SL_TYPE n;
  1068.     if( nRight == RECT_EMPTY )
  1069.         n = 0;
  1070.     else
  1071.     {
  1072.         n = nRight - nLeft;
  1073.         if( n < 0 )
  1074.             n--;
  1075.         else
  1076.             n++;
  1077.     }
  1078.     return n;
  1079. }
  1080.  
  1081. inline _SL_TYPE _RECTANGLE::GetHeight() const
  1082. {
  1083.     _SL_TYPE n;
  1084.     if( nBottom == RECT_EMPTY )
  1085.         n = 0;
  1086.     else
  1087.     {
  1088.         n = nBottom - nTop;
  1089.         if( n < 0 )
  1090.             n--;
  1091.         else
  1092.             n++;
  1093.     }
  1094.     return n;
  1095. }
  1096.  
  1097. inline _SIZE _RECTANGLE::GetSize() const
  1098. {
  1099.     return _SIZE( GetWidth(), GetHeight() );
  1100. }
  1101.  
  1102. inline BOOL _RECTANGLE::IsEmpty() const
  1103. {
  1104.     return nRight == RECT_EMPTY || nBottom == RECT_EMPTY;
  1105. }
  1106.  
  1107. inline BOOL _RECTANGLE::operator == ( const _RECTANGLE& rRect ) const
  1108. {
  1109.     if ( (nLeft   == rRect.nLeft   ) &&
  1110.          (nTop    == rRect.nTop    ) &&
  1111.          (nRight  == rRect.nRight  ) &&
  1112.          (nBottom == rRect.nBottom ) )
  1113.         return TRUE;
  1114.     else
  1115.         return FALSE;
  1116. }
  1117.  
  1118. inline BOOL _RECTANGLE::operator != ( const _RECTANGLE& rRect ) const
  1119. {
  1120.     if ( (nLeft   != rRect.nLeft   ) ||
  1121.          (nTop    != rRect.nTop    ) ||
  1122.          (nRight  != rRect.nRight  ) ||
  1123.          (nBottom != rRect.nBottom ) )
  1124.         return TRUE;
  1125.     else
  1126.         return FALSE;
  1127. }
  1128.  
  1129. #undef _PAIR
  1130. #undef _POINT
  1131. #undef _SIZE
  1132. #undef _RANGE
  1133. #undef _SELECTION
  1134. #undef _RECTANGLE
  1135.  
  1136. #undef _PAIR_2
  1137. #undef _POINT_2
  1138. #undef _SIZE_2
  1139. #undef _RANGE_2
  1140. #undef _SELECTION_2
  1141. #undef _RECTANGLE_2
  1142.  
  1143. #undef _SL_TYPE
  1144.  
  1145. #ifdef __private
  1146. #undef private
  1147. #undef __private
  1148. #endif
  1149.  
  1150. #ifdef __protected
  1151. #undef protected
  1152. #undef __protected
  1153. #endif
  1154.  
  1155. #ifndef private
  1156. #define private     public
  1157. #define __private
  1158. #endif
  1159.  
  1160. #ifndef protected
  1161. #define protected   public
  1162. #define __protected
  1163. #endif
  1164.  
  1165. #define _PAIR LPair
  1166. #define _POINT LPoint
  1167. #define _SIZE LSize
  1168. #define _RANGE LRange
  1169. #define _SELECTION LSelection
  1170. #define _RECTANGLE LRectangle
  1171.  
  1172. #define _PAIR_2 Pair
  1173. #define _POINT_2 Point
  1174. #define _SIZE_2 Size
  1175. #define _RANGE_2 Range
  1176. #define _SELECTION_2 Selection
  1177. #define _RECTANGLE_2 Rectangle
  1178.  
  1179. #define _SL_TYPE long
  1180.  
  1181. #define LRANGE_MIN   ((long)0x80000000L)
  1182. #define LRANGE_MAX   0x7FFFFFFFL
  1183.  
  1184. #define LSELECTION_MIN   ((long)0x80000000L)
  1185. #define LSELECTION_MAX   0x7FFFFFFFL
  1186.  
  1187. inline _PAIR::_PAIR( _SL_TYPE _nA, _SL_TYPE _nB )
  1188. {
  1189.     _PAIR::nA = _nA;
  1190.     _PAIR::nB = _nB;
  1191. }
  1192.  
  1193. inline _PAIR::_PAIR( const _PAIR_2& rPair )
  1194. {
  1195.     nA = (_SL_TYPE)rPair.nA;
  1196.     nB = (_SL_TYPE)rPair.nB;
  1197. }
  1198.  
  1199. inline BOOL _PAIR::operator == ( const _PAIR& rPair ) const
  1200. {
  1201.     if ( (nA == rPair.nA) && (nB == rPair.nB) )
  1202.         return TRUE;
  1203.     else
  1204.         return FALSE;
  1205. }
  1206.  
  1207. inline BOOL _PAIR::operator != ( const _PAIR& rPair ) const
  1208. {
  1209.     if ( (nA != rPair.nA) || (nB != rPair.nB) )
  1210.         return TRUE;
  1211.     else
  1212.         return FALSE;
  1213. }
  1214.  
  1215. inline _PAIR& _PAIR::operator = ( const _PAIR_2& rPair )
  1216. {
  1217.     nA = (_SL_TYPE)rPair.nA;
  1218.     nB = (_SL_TYPE)rPair.nB;
  1219.     return *this;
  1220. }
  1221.  
  1222. inline _POINT::_POINT( _SL_TYPE nX, _SL_TYPE nY ) : _PAIR( nX, nY )
  1223. {
  1224. }
  1225.  
  1226. inline _POINT::_POINT( const _POINT_2& rPoint ) : _PAIR( rPoint )
  1227. {
  1228. }
  1229.  
  1230. inline _POINT& _POINT::operator += ( const _POINT& rPoint )
  1231. {
  1232.     nA += rPoint.nA;
  1233.     nB += rPoint.nB;
  1234.     return *this;
  1235. }
  1236.  
  1237. inline _POINT& _POINT::operator -= ( const _POINT& rPoint )
  1238. {
  1239.     nA -= rPoint.nA;
  1240.     nB -= rPoint.nB;
  1241.     return *this;
  1242. }
  1243.  
  1244. inline _POINT& _POINT::operator *= ( const _SL_TYPE nVal )
  1245. {
  1246.     nA *= nVal;
  1247.     nB *= nVal;
  1248.     return *this;
  1249. }
  1250.  
  1251. inline _POINT& _POINT::operator /= ( const _SL_TYPE nVal )
  1252. {
  1253.     nA /= nVal;
  1254.     nB /= nVal;
  1255.     return *this;
  1256. }
  1257.  
  1258. inline _POINT operator+( const _POINT &rVal1, const _POINT &rVal2 )
  1259. {
  1260.     return _POINT( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB );
  1261. }
  1262.  
  1263. inline _POINT operator-( const _POINT &rVal1, const _POINT &rVal2 )
  1264. {
  1265.     return _POINT( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB );
  1266. }
  1267.  
  1268. inline _POINT operator*( const _POINT &rVal1, const _SL_TYPE nVal2 )
  1269. {
  1270.     return _POINT( rVal1.nA*nVal2, rVal1.nB*nVal2 );
  1271. }
  1272.  
  1273. inline _POINT operator/( const _POINT &rVal1, const _SL_TYPE nVal2 )
  1274. {
  1275.     return _POINT( rVal1.nA/nVal2, rVal1.nB/nVal2 );
  1276. }
  1277.  
  1278. inline BOOL _POINT::IsAbove( const _POINT& rPoint ) const
  1279. {
  1280.     if ( nB > rPoint.nB )
  1281.         return TRUE;
  1282.     else
  1283.         return FALSE;
  1284. }
  1285.  
  1286. inline BOOL _POINT::IsBelow( const _POINT& rPoint ) const
  1287. {
  1288.     if ( nB < rPoint.nB )
  1289.         return TRUE;
  1290.     else
  1291.         return FALSE;
  1292. }
  1293.  
  1294. inline BOOL _POINT::IsLeft( const _POINT& rPoint ) const
  1295. {
  1296.     if ( nA < rPoint.nA )
  1297.         return TRUE;
  1298.     else
  1299.         return FALSE;
  1300. }
  1301.  
  1302. inline BOOL _POINT::IsRight( const _POINT& rPoint ) const
  1303. {
  1304.     if ( nA > rPoint.nA )
  1305.         return TRUE;
  1306.     else
  1307.         return FALSE;
  1308. }
  1309.  
  1310. inline _SIZE::_SIZE( _SL_TYPE nWidth, _SL_TYPE nHeight ) :
  1311.             _PAIR( nWidth, nHeight )
  1312. {
  1313. }
  1314.  
  1315. inline _SIZE::_SIZE( const _SIZE_2& rSize ) : _PAIR( rSize )
  1316. {
  1317. }
  1318.  
  1319. inline _RANGE::_RANGE( _SL_TYPE nMin, _SL_TYPE nMax ) : _PAIR( nMin, nMax )
  1320. {
  1321. }
  1322.  
  1323. inline _RANGE::_RANGE( const _RANGE_2& rRange ) : _PAIR( rRange )
  1324. {
  1325. }
  1326.  
  1327. inline BOOL _RANGE::IsInside( _SL_TYPE nIs ) const
  1328. {
  1329.     if ( (nA <= nIs) && (nIs <= nB ) )
  1330.         return TRUE;
  1331.     else
  1332.         return FALSE;
  1333. }
  1334.  
  1335. inline void _RANGE::Justify()
  1336. {
  1337.     if ( nA > nB )
  1338.     {
  1339.         _SL_TYPE nHelp = nA;
  1340.         nA = nB;
  1341.         nB = nHelp;
  1342.     }
  1343. }
  1344.  
  1345. inline _SELECTION::_SELECTION( _SL_TYPE nPos ) : _PAIR( nPos, nPos )
  1346. {
  1347. }
  1348.  
  1349. inline _SELECTION::_SELECTION( _SL_TYPE nMin, _SL_TYPE nMax ) :
  1350.            _PAIR( nMin, nMax )
  1351. {
  1352. }
  1353.  
  1354. inline _SELECTION::_SELECTION( const _SELECTION_2& rSelection ) :
  1355.            _PAIR( rSelection )
  1356. {
  1357. }
  1358.  
  1359. inline BOOL _SELECTION::IsInside( _SL_TYPE nIs ) const
  1360. {
  1361.     if ( (nA <= nIs) && (nIs < nB ) )
  1362.         return TRUE;
  1363.     else
  1364.         return FALSE;
  1365. }
  1366.  
  1367. inline void _SELECTION::Justify()
  1368. {
  1369.     if ( nA > nB )
  1370.     {
  1371.         _SL_TYPE nHelp = nA;
  1372.         nA = nB;
  1373.         nB = nHelp;
  1374.     }
  1375. }
  1376.  
  1377. inline _RECTANGLE::_RECTANGLE( const _POINT& rLT, const _POINT& rRB )
  1378. {
  1379.     nLeft   = rLT.X();
  1380.     nTop    = rLT.Y();
  1381.     nRight  = rRB.X();
  1382.     nBottom = rRB.Y();
  1383. }
  1384.  
  1385. inline _RECTANGLE::_RECTANGLE( _SL_TYPE _nLeft,  _SL_TYPE _nTop,
  1386.                                _SL_TYPE _nRight, _SL_TYPE _nBottom )
  1387. {
  1388.     _RECTANGLE::nLeft   = _nLeft;
  1389.     _RECTANGLE::nTop    = _nTop;
  1390.     _RECTANGLE::nRight  = _nRight;
  1391.     _RECTANGLE::nBottom = _nBottom;
  1392. }
  1393.  
  1394. inline _RECTANGLE::_RECTANGLE( const _POINT& rLT, const _SIZE& rSize )
  1395. {
  1396.     nLeft   = rLT.X();
  1397.     nTop    = rLT.Y();
  1398.     nRight  = rSize.Width()  ? nLeft+rSize.Width()-1 : RECT_EMPTY;
  1399.     nBottom = rSize.Height() ? nTop+rSize.Height()-1 : RECT_EMPTY;
  1400. }
  1401.  
  1402. inline _RECTANGLE::_RECTANGLE( const _RECTANGLE_2& rRect )
  1403. {
  1404.     nLeft   = (_SL_TYPE)rRect.nLeft;
  1405.     nTop    = (_SL_TYPE)rRect.nTop;
  1406.     nRight  = (_SL_TYPE)rRect.nRight;
  1407.     nBottom = (_SL_TYPE)rRect.nBottom;
  1408. }
  1409.  
  1410. inline _RECTANGLE& _RECTANGLE::operator = ( const _RECTANGLE_2& rRect )
  1411. {
  1412.     nLeft   = (_SL_TYPE)rRect.nLeft;
  1413.     nTop    = (_SL_TYPE)rRect.nTop;
  1414.     nRight  = (_SL_TYPE)rRect.nRight;
  1415.     nBottom = (_SL_TYPE)rRect.nBottom;
  1416.     return *this;
  1417. }
  1418.  
  1419. inline _POINT _RECTANGLE::TopLeft() const
  1420. {
  1421.     return _POINT( nLeft, nTop );
  1422. }
  1423.  
  1424. inline _POINT _RECTANGLE::TopRight() const
  1425. {
  1426.     return _POINT( (nRight == RECT_EMPTY) ? nLeft : nRight,
  1427.                    nTop );
  1428. }
  1429.  
  1430. inline _POINT _RECTANGLE::BottomLeft() const
  1431. {
  1432.     return _POINT( nLeft,
  1433.                    (nBottom == RECT_EMPTY) ? nTop : nBottom );
  1434. }
  1435.  
  1436. inline _POINT _RECTANGLE::BottomRight() const
  1437. {
  1438.     return _POINT( (nRight  == RECT_EMPTY) ? nLeft : nRight,
  1439.                    (nBottom == RECT_EMPTY) ? nTop  : nBottom );
  1440. }
  1441.  
  1442. inline _SL_TYPE _RECTANGLE::GetWidth() const
  1443. {
  1444.     _SL_TYPE n;
  1445.     if( nRight == RECT_EMPTY )
  1446.         n = 0;
  1447.     else
  1448.     {
  1449.         n = nRight - nLeft;
  1450.         if( n < 0 )
  1451.             n--;
  1452.         else
  1453.             n++;
  1454.     }
  1455.     return n;
  1456. }
  1457.  
  1458. inline _SL_TYPE _RECTANGLE::GetHeight() const
  1459. {
  1460.     _SL_TYPE n;
  1461.     if( nBottom == RECT_EMPTY )
  1462.         n = 0;
  1463.     else
  1464.     {
  1465.         n = nBottom - nTop;
  1466.         if( n < 0 )
  1467.             n--;
  1468.         else
  1469.             n++;
  1470.     }
  1471.     return n;
  1472. }
  1473.  
  1474. inline _SIZE _RECTANGLE::GetSize() const
  1475. {
  1476.     return _SIZE( GetWidth(), GetHeight() );
  1477. }
  1478.  
  1479. inline BOOL _RECTANGLE::IsEmpty() const
  1480. {
  1481.     return nRight == RECT_EMPTY || nBottom == RECT_EMPTY;
  1482. }
  1483.  
  1484. inline BOOL _RECTANGLE::operator == ( const _RECTANGLE& rRect ) const
  1485. {
  1486.     if ( (nLeft   == rRect.nLeft   ) &&
  1487.          (nTop    == rRect.nTop    ) &&
  1488.          (nRight  == rRect.nRight  ) &&
  1489.          (nBottom == rRect.nBottom ) )
  1490.         return TRUE;
  1491.     else
  1492.         return FALSE;
  1493. }
  1494.  
  1495. inline BOOL _RECTANGLE::operator != ( const _RECTANGLE& rRect ) const
  1496. {
  1497.     if ( (nLeft   != rRect.nLeft   ) ||
  1498.          (nTop    != rRect.nTop    ) ||
  1499.          (nRight  != rRect.nRight  ) ||
  1500.          (nBottom != rRect.nBottom ) )
  1501.         return TRUE;
  1502.     else
  1503.         return FALSE;
  1504. }
  1505.  
  1506. #undef _PAIR
  1507. #undef _POINT
  1508. #undef _SIZE
  1509. #undef _RANGE
  1510. #undef _SELECTION
  1511. #undef _RECTANGLE
  1512.  
  1513. #undef _PAIR_2
  1514. #undef _POINT_2
  1515. #undef _SIZE_2
  1516. #undef _RANGE_2
  1517. #undef _SELECTION_2
  1518. #undef _RECTANGLE_2
  1519.  
  1520. #undef _SL_TYPE
  1521.  
  1522. #ifdef __private
  1523. #undef private
  1524. #undef __private
  1525. #endif
  1526.  
  1527. #ifdef __protected
  1528. #undef protected
  1529. #undef __protected
  1530. #endif
  1531. #ifndef _GEN_HXX
  1532. #define _GEN_HXX
  1533. #endif
  1534.  
  1535. #ifndef _GEN_HXX
  1536. #define _GEN_HXX
  1537.  
  1538. #endif 
  1539.  
  1540. #ifndef _BIGINT_HXX
  1541. #define _BIGINT_HXX
  1542.  
  1543. #ifndef _TOOLS_H
  1544. #endif
  1545.  
  1546. class BigInt
  1547. {
  1548. private:
  1549.     long            nVal;
  1550.     unsigned short  nNum[8];
  1551.     char            nLen;               
  1552.     char            nMaxLen;            
  1553.     USHORT          bIsNeg      : 1,    
  1554.                     bIsLong     : 1;
  1555.  
  1556. public:
  1557.                     BigInt();
  1558.                     BigInt( short nVal );
  1559.                     BigInt( long nVal );
  1560.                     BigInt( int nVal );
  1561.                     BigInt( USHORT nVal );
  1562.                     BigInt( const BigInt& rBigInt );
  1563.  
  1564.     operator        short() const;
  1565.     operator        long()  const;
  1566.     operator        int()  const;
  1567.     operator        USHORT()  const;
  1568.  
  1569.     BOOL            IsNeg() const;
  1570.     BOOL            IsZero() const;
  1571.     BOOL            IsOne() const;
  1572.     void            Abs();
  1573.  
  1574.     BigInt&         operator  =( const BigInt& rVal );
  1575.     BigInt&         operator +=( const BigInt& rVal );
  1576.     BigInt&         operator -=( const BigInt& rVal );
  1577.     BigInt&         operator *=( const BigInt& rVal );
  1578.     BigInt&         operator /=( const BigInt& rVal );
  1579.     BigInt&         operator %=( const BigInt& rVal );
  1580.  
  1581. #ifdef __BORLANDC__
  1582.     friend          BigInt operator +( const BigInt& rVal1, const BigInt& rVal2 );
  1583.     friend          BigInt operator -( const BigInt& rVal1, const BigInt& rVal2 );
  1584.     friend          BigInt operator *( const BigInt& rVal1, const BigInt& rVal2 );
  1585.     friend          BigInt operator /( const BigInt& rVal1, const BigInt& rVal2 );
  1586.     friend          BigInt operator %( const BigInt& rVal1, const BigInt& rVal2 );
  1587.  
  1588.     friend          BOOL operator==( const BigInt& rVal1, const BigInt& rVal2 );
  1589.     friend          BOOL operator!=( const BigInt& rVal1, const BigInt& rVal2 );
  1590.     friend          BOOL operator< ( const BigInt& rVal1, const BigInt& rVal2 );
  1591.     friend          BOOL operator> ( const BigInt& rVal1, const BigInt& rVal2 );
  1592.     friend          BOOL operator<=( const BigInt& rVal1, const BigInt& rVal2 );
  1593.     friend          BOOL operator>=( const BigInt& rVal1, const BigInt& rVal2 );
  1594. #else
  1595.     friend inline   BigInt operator +( const BigInt& rVal1, const BigInt& rVal2 );
  1596.     friend inline   BigInt operator -( const BigInt& rVal1, const BigInt& rVal2 );
  1597.     friend inline   BigInt operator *( const BigInt& rVal1, const BigInt& rVal2 );
  1598.     friend inline   BigInt operator /( const BigInt& rVal1, const BigInt& rVal2 );
  1599.     friend inline   BigInt operator %( const BigInt& rVal1, const BigInt& rVal2 );
  1600.  
  1601.     friend          BOOL operator==( const BigInt& rVal1, const BigInt& rVal2 );
  1602.     friend inline   BOOL operator!=( const BigInt& rVal1, const BigInt& rVal2 );
  1603.     friend          BOOL operator< ( const BigInt& rVal1, const BigInt& rVal2 );
  1604.     friend          BOOL operator> ( const BigInt& rVal1, const BigInt& rVal2 );
  1605.     friend inline   BOOL operator<=( const BigInt& rVal1, const BigInt& rVal2 );
  1606.     friend inline   BOOL operator>=( const BigInt& rVal1, const BigInt& rVal2 );
  1607. #endif
  1608. };
  1609.  
  1610. inline BigInt::BigInt()
  1611. {
  1612.     bIsLong = FALSE;
  1613.     nVal = 0;
  1614. }
  1615.  
  1616. inline BigInt::BigInt( short nValue )
  1617. {
  1618.     bIsLong = FALSE;
  1619.     nVal = nValue;
  1620. }
  1621.  
  1622. inline BigInt::BigInt( long nValue )
  1623. {
  1624.     bIsLong = FALSE;
  1625.     nVal = nValue;
  1626. }
  1627.  
  1628. inline BigInt::BigInt( int nValue )
  1629. {
  1630.     bIsLong = FALSE;
  1631.     nVal = nValue;
  1632. }
  1633.  
  1634. inline BigInt::BigInt( USHORT nValue )
  1635. {
  1636.     bIsLong = FALSE;
  1637.     nVal = nValue;
  1638. }
  1639.  
  1640. inline BigInt::operator short() const
  1641. {
  1642.     if ( !bIsLong && (nVal == (long)(short)nVal) )
  1643.         return (short)nVal;
  1644.     else
  1645.         return 0;
  1646. }
  1647.  
  1648. inline BigInt::operator long() const
  1649. {
  1650.     if ( !bIsLong )
  1651.         return nVal;
  1652.     else
  1653.         return 0;
  1654. }
  1655.  
  1656. inline BigInt::operator int() const
  1657. {
  1658.     if ( !bIsLong && (nVal == (long)(int)nVal) )
  1659.         return (int)nVal;
  1660.     else
  1661.         return 0;
  1662. }
  1663.  
  1664. inline BigInt::operator USHORT() const
  1665. {
  1666.     if ( !bIsLong && (nVal == (long)(USHORT)nVal) )
  1667.         return (USHORT)nVal;
  1668.     else
  1669.         return 0;
  1670. }
  1671.  
  1672. inline BOOL BigInt::IsNeg() const
  1673. {
  1674.     if ( !bIsLong )
  1675.         return (nVal < 0) ? TRUE : FALSE;
  1676.     else
  1677.         return (bIsNeg) ? TRUE : FALSE;
  1678. }
  1679.  
  1680. inline BOOL BigInt::IsZero() const
  1681. {
  1682.     if ( bIsLong )
  1683.         return FALSE;
  1684.     else
  1685.         return (nVal == 0) ? TRUE : FALSE;
  1686. }
  1687.  
  1688. inline BOOL BigInt::IsOne() const
  1689. {
  1690.     if ( bIsLong )
  1691.         return FALSE;
  1692.     else
  1693.         return (nVal == 1) ? TRUE : FALSE;
  1694. }
  1695.  
  1696. inline void BigInt::Abs()
  1697. {
  1698.     if ( bIsLong )
  1699.         bIsNeg = FALSE;
  1700.     else if ( nVal < 0 )
  1701.         nVal = -nVal;
  1702. }
  1703.  
  1704. inline BigInt operator+( const BigInt &rVal1, const BigInt &rVal2 )
  1705. {
  1706.     BigInt aErg( rVal1 );
  1707.     aErg += rVal2;
  1708.     return aErg;
  1709. }
  1710.  
  1711. inline BigInt operator-( const BigInt &rVal1, const BigInt &rVal2 )
  1712. {
  1713.     BigInt aErg( rVal1 );
  1714.     aErg -= rVal2;
  1715.     return aErg;
  1716. }
  1717.  
  1718. inline BigInt operator*( const BigInt &rVal1, const BigInt &rVal2 )
  1719. {
  1720.     BigInt aErg( rVal1 );
  1721.     aErg *= rVal2;
  1722.     return aErg;
  1723. }
  1724.  
  1725. inline BigInt operator/( const BigInt &rVal1, const BigInt &rVal2 )
  1726. {
  1727.     BigInt aErg( rVal1 );
  1728.     aErg /= rVal2;
  1729.     return aErg;
  1730. }
  1731.  
  1732. inline BigInt operator%( const BigInt &rVal1, const BigInt &rVal2 )
  1733. {
  1734.     BigInt aErg( rVal1 );
  1735.     aErg %= rVal2;
  1736.     return aErg;
  1737. }
  1738.  
  1739. inline BOOL operator!=( const BigInt& rVal1, const BigInt& rVal2 )
  1740. {
  1741.     if ( rVal1 == rVal2 )
  1742.         return FALSE;
  1743.     else
  1744.         return TRUE;
  1745. }
  1746.  
  1747. inline BOOL operator<=( const BigInt& rVal1, const BigInt& rVal2 )
  1748. {
  1749.     if ( rVal1 > rVal2 )
  1750.         return FALSE;
  1751.     else
  1752.         return TRUE;
  1753. }
  1754.  
  1755. inline BOOL operator>=( const BigInt& rVal1, const BigInt& rVal2 )
  1756. {
  1757.     if ( rVal1 < rVal2 )
  1758.         return FALSE;
  1759.     else
  1760.         return TRUE;
  1761. }
  1762.  
  1763. #endif
  1764.  
  1765. #ifndef _FRACT_HXX
  1766. #define _FRACT_HXX
  1767.  
  1768. #ifndef _TOOLS_H
  1769. #endif
  1770.  
  1771. class Fraction
  1772. {
  1773. private:
  1774.     long            nNumerator;
  1775.     long            nDenominator;
  1776.  
  1777. public:
  1778.                     Fraction() { nNumerator = 0; nDenominator = 1; }
  1779.                     Fraction( const Fraction & rFrac );
  1780.                     Fraction( long nNum, long nDen=1 );
  1781.                     Fraction( double dVal );
  1782.  
  1783.     BOOL            IsValid() const;
  1784.  
  1785.     long            GetNumerator() const { return nNumerator; }
  1786.     long            GetDenominator() const { return nDenominator; }
  1787.  
  1788.     operator        long() const;
  1789.     operator        double() const;
  1790.  
  1791.     Fraction&       operator=( const Fraction& rfrFrac );
  1792.  
  1793.     Fraction&       operator+=( const Fraction& rfrFrac );
  1794.     Fraction&       operator-=( const Fraction& rfrFrac );
  1795.     Fraction&       operator*=( const Fraction& rfrFrac );
  1796.     Fraction&       operator/=( const Fraction& rfrFrac );
  1797.  
  1798. #ifdef __BORLANDC__
  1799.     friend          Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 );
  1800.     friend          Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 );
  1801.     friend          Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 );
  1802.     friend          Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 );
  1803.  
  1804.     friend          BOOL operator==( const Fraction& rVal1, const Fraction& rVal2 );
  1805.     friend          BOOL operator!=( const Fraction& rVal1, const Fraction& rVal2 );
  1806.     friend          BOOL operator< ( const Fraction& rVal1, const Fraction& rVal2 );
  1807.     friend          BOOL operator> ( const Fraction& rVal1, const Fraction& rVal2 );
  1808.     friend          BOOL operator<=( const Fraction& rVal1, const Fraction& rVal2 );
  1809.     friend          BOOL operator>=( const Fraction& rVal1, const Fraction& rVal2 );
  1810. #else
  1811.     friend inline   Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 );
  1812.     friend inline   Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 );
  1813.     friend inline   Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 );
  1814.     friend inline   Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 );
  1815.  
  1816.     friend          BOOL operator==( const Fraction& rVal1, const Fraction& rVal2 );
  1817.     friend          BOOL operator!=( const Fraction& rVal1, const Fraction& rVal2 );
  1818.     friend          BOOL operator< ( const Fraction& rVal1, const Fraction& rVal2 );
  1819.     friend          BOOL operator> ( const Fraction& rVal1, const Fraction& rVal2 );
  1820.     friend inline   BOOL operator<=( const Fraction& rVal1, const Fraction& rVal2 );
  1821.     friend inline   BOOL operator>=( const Fraction& rVal1, const Fraction& rVal2 );
  1822. #endif
  1823. };
  1824.  
  1825. inline Fraction::Fraction( const Fraction& rFrac )
  1826. {
  1827.     nNumerator   = rFrac.nNumerator;
  1828.     nDenominator = rFrac.nDenominator;
  1829. }
  1830.  
  1831. inline Fraction& Fraction::operator=( const Fraction& rFrac )
  1832. {
  1833.     nNumerator   = rFrac.nNumerator;
  1834.     nDenominator = rFrac.nDenominator;
  1835.     return *this;
  1836. }
  1837.  
  1838. inline BOOL Fraction::IsValid() const
  1839. {
  1840.     if ( nDenominator > 0 )
  1841.         return TRUE;
  1842.      else
  1843.         return FALSE;
  1844. }
  1845.  
  1846. inline Fraction::operator long() const
  1847. {
  1848.     if ( nDenominator > 0 )
  1849.         return (nNumerator / nDenominator);
  1850.     else
  1851.         return 0;
  1852. }
  1853.  
  1854. inline Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 )
  1855. {
  1856.     Fraction aErg( rVal1 );
  1857.     aErg += rVal2;
  1858.     return aErg;
  1859. }
  1860.  
  1861. inline Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 )
  1862. {
  1863.     Fraction aErg( rVal1 );
  1864.     aErg -= rVal2;
  1865.     return aErg;
  1866. }
  1867.  
  1868. inline Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 )
  1869. {
  1870.     Fraction aErg( rVal1 );
  1871.     aErg *= rVal2;
  1872.     return aErg;
  1873. }
  1874.  
  1875. inline Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 )
  1876. {
  1877.     Fraction aErg( rVal1 );
  1878.     aErg /= rVal2;
  1879.     return aErg;
  1880. }
  1881.  
  1882. inline BOOL operator <=( const Fraction& rVal1, const Fraction& rVal2 )
  1883. {
  1884.     if ( rVal1 > rVal2 )
  1885.         return FALSE;
  1886.     else
  1887.         return TRUE;
  1888. }
  1889.  
  1890. inline BOOL operator >=( const Fraction& rVal1, const Fraction& rVal2 )
  1891. {
  1892.     if ( rVal1 < rVal2 )
  1893.         return FALSE;
  1894.     else
  1895.         return TRUE;
  1896. }
  1897.  
  1898. #endif 
  1899.  
  1900. #ifndef _STRING_HXX
  1901. #define _STRING_HXX
  1902.  
  1903. #ifndef _TOOLS_H
  1904. #endif
  1905.  
  1906. class ResId;
  1907.  
  1908. struct StringData
  1909. {
  1910.     USHORT      nLen;           
  1911.     USHORT      nRefCount;      
  1912.     char        aStr[1];        
  1913. };
  1914.  
  1915. #define STRING_NOTFOUND    ((USHORT)0xFFFF)
  1916. #define STRING_MATCH       ((USHORT)0xFFFF)
  1917. #define STRING_LEN         ((USHORT)0xFFFF)
  1918. #define STRING_MAXLEN      ((USHORT)0xFFFF-sizeof(StringData))
  1919.  
  1920. enum CharSet { CHARSET_DONTKNOW, CHARSET_ANSI, CHARSET_MAC,
  1921.                CHARSET_IBMPC_437, CHARSET_IBMPC_850, CHARSET_IBMPC_860,
  1922.                CHARSET_IBMPC_861, CHARSET_IBMPC_863, CHARSET_IBMPC_865,
  1923.                CHARSET_SYSTEM, CHARSET_SYMBOL,
  1924.                CHARSET_IBMPC = CHARSET_IBMPC_850 };
  1925. enum StringCompare { COMPARE_EQUAL, COMPARE_LESS, COMPARE_GREATER };
  1926. enum LineEnd  { LINEEND_CR, LINEEND_LF, LINEEND_CRLF };
  1927.  
  1928. CharSet GetSystemCharSet();
  1929. LineEnd GetSystemLineEnd();
  1930. short   svstrnicmp( const char* pStr1, const char* pStr2, USHORT nLen );
  1931.  
  1932. class String
  1933. {
  1934.     void            InitStringRes( const char* pCharStr, USHORT nLen );
  1935.  
  1936. private:
  1937.     StringData*     pData;
  1938.  
  1939. public:
  1940.                     String();
  1941.                     String( const ResId& rResId );
  1942.                     String( const String& rStr );
  1943.                     String( const String& rStr, USHORT nPos, USHORT nLen );
  1944.                     String( const char* pCharStr );
  1945.                     String( const char* pCharStr, USHORT nLen );
  1946.                     String( char c );
  1947.                     String( int n );
  1948.                     String( unsigned int n );
  1949.                     String( short n );
  1950.                     String( USHORT n );
  1951.                     String( long n );
  1952.                     String( ULONG n );
  1953.                     ~String();
  1954.  
  1955.     operator        const char*() const { return pData->aStr; }
  1956.     operator        char() const { return pData->aStr[0]; }
  1957.     operator        int() const;
  1958.     operator        unsigned int() const;
  1959.     operator        short() const;
  1960.     operator        USHORT() const;
  1961.     operator        long() const;
  1962.     operator        ULONG() const;
  1963.  
  1964.     String&         operator =  ( const String& rStr );
  1965.     String&         operator =  ( const char* pCharStr );
  1966.  
  1967.     String&         operator += ( const String& rStr );
  1968.     String&         operator += ( const char* pCharStr );
  1969.     String&         operator += ( char c );
  1970.     String&         operator += ( int n );
  1971.     String&         operator += ( unsigned int n );
  1972.     String&         operator += ( short n );
  1973.     String&         operator += ( USHORT n );
  1974.     String&         operator += ( long n );
  1975.     String&         operator += ( ULONG n );
  1976.  
  1977.     BOOL            operator !  () const { return !pData->nLen; }
  1978.  
  1979.     char&           operator [] ( USHORT nIndex );
  1980.     char            operator [] ( USHORT nIndex ) const
  1981.                         { return pData->aStr[nIndex]; }
  1982.  
  1983.     String          operator() ( USHORT n1, USHORT n2 ) const
  1984.                         { return Copy( n1, n2 ); }
  1985.     char&           operator() ( USHORT n )
  1986.                         { return String::operator[](n); }
  1987.  
  1988.     USHORT          Len() const { return pData->nLen; }
  1989.  
  1990.     String&         Insert( const String& rStr, USHORT nIndex = STRING_LEN );
  1991.     String&         Insert( const String& rStr, USHORT nPos, USHORT nLen,
  1992.                             USHORT nIndex = STRING_LEN );
  1993.     String&         Insert( const char* pCharStr, USHORT nIndex = STRING_LEN );
  1994.     String&         Insert( char c, USHORT nIndex = STRING_LEN );
  1995.     String&         Replace( const String& rStr, USHORT nIndex = 0 );
  1996.     String&         Erase( USHORT nIndex = 0, USHORT nCount = STRING_LEN );
  1997.     String          Cut( USHORT nIndex = 0, USHORT nCount = STRING_LEN );
  1998.     String          Copy( USHORT nIndex = 0, USHORT nCount = STRING_LEN ) const;
  1999.  
  2000.     String&         Fill( USHORT nCount, char cFillChar = ' ' );
  2001.     String&         Expand( USHORT nCount, char cExpandChar = ' ' );
  2002.     String&         EraseLeadingChars( char c = ' ' );
  2003.     String&         EraseTrailingChars( char c = ' ' );
  2004.     String&         EraseAllChars( char c = ' ' );
  2005.     String&         Reverse();
  2006.  
  2007.     String&         Convert( CharSet eSource,
  2008.                              CharSet eTarget = CHARSET_SYSTEM );
  2009.     static char     Convert( char c, CharSet eSource,
  2010.                              CharSet eTarget = CHARSET_SYSTEM );
  2011.     String&         ConvertLineEnd();
  2012.     String&         ConvertLineEnd( LineEnd eLineEnd );
  2013.  
  2014.     BOOL            IsPrintable( CharSet eCharSet = CHARSET_SYSTEM ) const;
  2015.     static BOOL     IsPrintable( char c, CharSet eCharSet = CHARSET_SYSTEM );
  2016.  
  2017.     String&         SpaceToZero();
  2018.     String&         ZeroToSpace();
  2019.  
  2020.     String&         ToUpper();
  2021.     String&         ToLower();
  2022.  
  2023.     String          Upper() const;
  2024.     String          Lower() const;
  2025.  
  2026.     BOOL            IsUpper() const;
  2027.     BOOL            IsLower() const;
  2028.     BOOL            IsAlpha() const;
  2029.     BOOL            IsNumeric() const;
  2030.     BOOL            IsAlphaNumeric() const;
  2031.  
  2032.     StringCompare   Compare( const String& rStr,
  2033.                              USHORT nLen = STRING_LEN ) const;
  2034.     StringCompare   Compare( const char* pCharStr,
  2035.                              USHORT nLen = STRING_LEN ) const;
  2036.     StringCompare   ICompare( const String& rStr,
  2037.                               USHORT nLen = STRING_LEN ) const;
  2038.     StringCompare   ICompare( const char* pCharStr,
  2039.                               USHORT nLen = STRING_LEN ) const;
  2040.  
  2041.     USHORT          Match( const String& rStr ) const;
  2042.     USHORT          Match( const char* pCharStr ) const;
  2043.  
  2044.     USHORT          Search( const String& rStr, USHORT nIndex = 0 ) const;
  2045.     USHORT          Search( const char* pCharStr, USHORT nIndex = 0 ) const;
  2046.     USHORT          Search( char c, USHORT nIndex = 0 ) const;
  2047.  
  2048.     USHORT          GetTokenCount( char cTok = ';' ) const;
  2049.     String          GetToken( USHORT nToken, char cTok = ';' ) const;
  2050.  
  2051.     char*           AllocStrBuf( USHORT nLen );
  2052.     const char*     GetStr() const { return pData->aStr; }
  2053.  
  2054. #ifdef __BORLANDC__
  2055.     friend          String operator+( const String& rStr1,  const String& rStr2  );
  2056.     friend          String operator+( const String& rStr,   const char* pCharStr );
  2057.     friend          String operator+( const char* pCharStr, const String& rStr   );
  2058. #else
  2059.     friend inline   String operator+( const String& rStr1,  const String& rStr2  );
  2060.     friend inline   String operator+( const String& rStr,   const char* pCharStr );
  2061.     friend inline   String operator+( const char* pCharStr, const String& rStr   );
  2062. #endif
  2063.  
  2064.     friend BOOL     operator == ( const String& rStr1,  const String& rStr2  );
  2065.     friend BOOL     operator == ( const String& rStr,   const char* pCharStr );
  2066.     friend BOOL     operator == ( const char* pCharStr, const String& rStr   );
  2067.     friend BOOL     operator != ( const String& rStr1,  const String& rStr2  );
  2068.     friend BOOL     operator != ( const String& rStr,   const char* pCharStr );
  2069.     friend BOOL     operator != ( const char* pCharStr, const String& rStr   );
  2070.     friend BOOL     operator <  ( const String& rStr1,  const String& rStr2  );
  2071.     friend BOOL     operator <  ( const String& rStr,   const char* pCharStr );
  2072.     friend BOOL     operator <  ( const char* pCharStr, const String& rStr   );
  2073.     friend BOOL     operator >  ( const String& rStr1,  const String& rStr2  );
  2074.     friend BOOL     operator >  ( const String& rStr,   const char* pCharStr );
  2075.     friend BOOL     operator >  ( const char* pCharStr, const String& rStr   );
  2076.     friend BOOL     operator <= ( const String& rStr1,  const String& rStr2  );
  2077.     friend BOOL     operator <= ( const String& rStr,   const char* pCharStr );
  2078.     friend BOOL     operator <= ( const char* pCharStr, const String& rStr   );
  2079.     friend BOOL     operator >= ( const String& rStr1,  const String& rStr2  );
  2080.     friend BOOL     operator >= ( const String& rStr,   const char* pCharStr );
  2081.     friend BOOL     operator >= ( const char* pCharStr, const String& rStr   );
  2082. };
  2083.  
  2084. inline String operator + ( const String& rStr1, const String& rStr2 )
  2085. {
  2086.     String aTmpStr( rStr1 );
  2087.     aTmpStr += rStr2;
  2088.     return aTmpStr;
  2089. }
  2090.  
  2091. inline String operator + ( const String& rStr, const char* pCharStr )
  2092. {
  2093.     String aTmpStr( rStr );
  2094.     aTmpStr += pCharStr;
  2095.     return aTmpStr;
  2096. }
  2097.  
  2098. inline String operator + ( const char* pCharStr, const String& rStr )
  2099. {
  2100.     String aTmpStr( pCharStr );
  2101.     aTmpStr += rStr;
  2102.     return aTmpStr;
  2103. }
  2104.  
  2105. #endif 
  2106.  
  2107. #ifndef _MTF_HXX
  2108. #define _MTF_HXX
  2109.  
  2110. #ifndef _TOOLS_H
  2111. #endif
  2112.  
  2113. #ifndef _LINK_HXX
  2114. #endif
  2115.  
  2116. #ifndef _STRING_HXX
  2117. #endif
  2118.  
  2119. class MetaFile;
  2120. class ActionList;
  2121. class LabelList;
  2122.  
  2123. class MetaAction
  2124. {
  2125. private:
  2126.     USHORT         nRefCount;     
  2127.     USHORT         nActionType;   
  2128.  
  2129. public:
  2130.                    MetaAction();
  2131.                    MetaAction( USHORT nType );
  2132.     virtual        ~MetaAction();
  2133.  
  2134.     virtual void   Execute( void* );
  2135.  
  2136.     USHORT         GetType() const { return nActionType; }
  2137.  
  2138.     void           Duplicate()  { nRefCount++; }
  2139.     void           Delete()     { nRefCount--; if ( !nRefCount ) delete this; }
  2140. };
  2141.  
  2142. #define METAFILE_END                ((ULONG)0xFFFFFFFF)
  2143. #define METAFILE_LABEL_NOTFOUND     ((ULONG)0xFFFFFFFF)
  2144.  
  2145. class MetaFile
  2146. {
  2147. private:
  2148.     Link                aHookHdlLink;       
  2149.     void*               pRecordObject;      
  2150.     ActionList*         pActionList;        
  2151.     LabelList*          pLabelList;         
  2152.     BOOL                bPause;             
  2153.     BOOL                bRecord;            
  2154.  
  2155. protected:
  2156.     virtual void        Linker( void*, BOOL );
  2157.     virtual long        Hook();
  2158.  
  2159. public:
  2160.                         MetaFile();
  2161.                         MetaFile( const MetaFile& rMtf );
  2162.     virtual             ~MetaFile();
  2163.  
  2164.     void                AddAction( MetaAction* pAction );
  2165.  
  2166.     void                Clear();
  2167.  
  2168.     void                Record( void* pObj );
  2169.     void                Play( void* pObj, ULONG nPos = METAFILE_END );
  2170.     void                Play( MetaFile& rMtf, ULONG nPos = METAFILE_END );
  2171.     void                Pause( BOOL bPaused );
  2172.     void                Stop();
  2173.  
  2174.     BOOL                IsRecord() const { return bRecord; }
  2175.     BOOL                IsPause() const  { return bPause;  }
  2176.  
  2177.     void                WindStart();
  2178.     void                WindEnd();
  2179.     void                Wind( ULONG nAction );
  2180.     void                WindPrev();
  2181.     void                WindNext();
  2182.  
  2183.     const MetaAction*   GetCurAction() const;
  2184.     const MetaAction*   GetAction( ULONG nAction ) const;
  2185.     ULONG               GetActionCount() const;
  2186.  
  2187.     BOOL                InsertLabel( const String& rLabel, ULONG nActionPos );
  2188.     void                RemoveLabel( const String& rLabel );
  2189.     ULONG               GetActionPos( const String& rLabel );
  2190.     String              GetLabel( ULONG nLabel );
  2191.     ULONG               GetLabelCount() const;
  2192.  
  2193.     Link                ChangeHookHdl( const Link& rLink );
  2194.     Link                GetHookHdl() const { return aHookHdlLink; }
  2195.  
  2196.     MetaFile&           operator=( const MetaFile& rMtf );
  2197. };
  2198.  
  2199. inline Link MetaFile::ChangeHookHdl( const Link& rLink )
  2200. {
  2201.     Link aOldLink = aHookHdlLink;
  2202.     aHookHdlLink = rLink;
  2203.     return aOldLink;
  2204. }
  2205.  
  2206. #endif 
  2207.  
  2208. #ifndef _CONTNR_HXX
  2209. #define _CONTNR_HXX
  2210.  
  2211. #ifndef _TOOLS_H
  2212. #endif
  2213.  
  2214. class CBlock;
  2215.  
  2216. #define CONTAINER_MAXBLOCKSIZE      ((USHORT)0x3FF0)
  2217.  
  2218. #define CONTAINER_APPEND            ((ULONG)0xFFFFFFFF)
  2219. #define CONTAINER_ENTRY_NOTFOUND    ((ULONG)0xFFFFFFFF)
  2220.  
  2221. class Container
  2222. {
  2223. private:
  2224.     CBlock*     pFirstBlock;
  2225.     CBlock*     pLastBlock;
  2226.     CBlock*     pCurBlock;
  2227.     USHORT      nCurIndex;
  2228.  
  2229.     USHORT      nBlockSize;
  2230.     USHORT      nInitSize;
  2231.     USHORT      nReSize;
  2232.  
  2233.     ULONG       nCount;
  2234.  
  2235. protected:
  2236.     void        ImpInsert( void* p, CBlock* pBlock, USHORT nIndex );
  2237.     void*       ImpRemove( CBlock* pBlock, USHORT nIndex );
  2238.     void*       ImpGetObject( ULONG nIndex ) const;
  2239.     void**      GetObjectPtr( ULONG nIndex );
  2240.  
  2241. public:
  2242.                 Container( USHORT nBlockSize,
  2243.                            USHORT nInitSize,
  2244.                            USHORT nReSize );
  2245.                 Container( ULONG nSize );
  2246.                 Container( const Container& rContainer );
  2247.                 ~Container();
  2248.  
  2249.     void        Insert( void* p );
  2250.     void        Insert( void* p, ULONG nIndex );
  2251.     void        Insert( void* pNew, void* pOld );
  2252.  
  2253.     void*       Remove();
  2254.     void*       Remove( ULONG nIndex );
  2255.     void*       Remove( void* p );
  2256.  
  2257.     void*       Replace( void* p );
  2258.     void*       Replace( void* p, ULONG nIndex );
  2259.     void*       Replace( void* pNew, void* pOld );
  2260.  
  2261.     ULONG       ChangeSize( ULONG nNewSize );
  2262.     ULONG       GetSize() const { return nCount; }
  2263.  
  2264.     ULONG       Count() const { return nCount; }
  2265.     void        Clear();
  2266.  
  2267.     void*       GetCurObject() const;
  2268.     ULONG       GetCurPos() const;
  2269.     void*       GetObject( ULONG nIndex ) const;
  2270.     ULONG       GetPos( const void* p ) const;
  2271.  
  2272.     void*       Seek( ULONG nIndex );
  2273.     void*       Seek( void* p );
  2274.     void*       First();
  2275.     void*       Last();
  2276.     void*       Next();
  2277.     void*       Prev();
  2278.  
  2279.     Container&  operator =( const Container& rContainer );
  2280.  
  2281.     BOOL        operator ==( const Container& rContainer ) const;
  2282.     BOOL        operator !=( const Container& rContainer ) const;
  2283. };
  2284.  
  2285. #endif 
  2286.  
  2287. #ifndef _LIST_HXX
  2288. #define _LIST_HXX
  2289.  
  2290. #ifndef _TOOLS_H
  2291. #endif
  2292.  
  2293. #ifndef _CONTNR_HXX
  2294. #endif
  2295.  
  2296. #define LIST_APPEND           CONTAINER_APPEND
  2297. #define LIST_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
  2298.  
  2299. class List : private Container
  2300. {
  2301. public:
  2302.             List( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) :
  2303.                 Container( 1024, _nInitSize, _nReSize ) {}
  2304.             List( USHORT _nBlockSize, USHORT _nInitSize, USHORT _nReSize ) :
  2305.                 Container( _nBlockSize, _nInitSize, _nReSize ) {}
  2306.             List( const List& rList ) : Container( rList ) {}
  2307.  
  2308.     void    Insert( void* p )
  2309.                 { Container::Insert( p ); }
  2310.     void    Insert( void* p, ULONG nIndex )
  2311.                 { Container::Insert( p, nIndex ); }
  2312.     void    Insert( void* pNew, void* pOld )
  2313.                 { Container::Insert( pNew, pOld ); }
  2314.  
  2315.     void*   Remove()
  2316.                 { return Container::Remove(); }
  2317.     void*   Remove( ULONG nIndex )
  2318.                 { return Container::Remove( nIndex ); }
  2319.     void*   Remove( void* p )
  2320.                 { return Container::Remove( p ); }
  2321.  
  2322.     void*   Replace( void* p )
  2323.                 { return Container::Replace( p ); }
  2324.     void*   Replace( void* p, ULONG nIndex )
  2325.                 { return Container::Replace( p, nIndex ); }
  2326.     void*   Replace( void* pNew, void* pOld )
  2327.                 { return Container::Replace( pNew, pOld ); }
  2328.  
  2329.     void    Clear() { Container::Clear(); }
  2330.     ULONG   Count() const { return Container::Count(); }
  2331.  
  2332.     void*   GetCurObject() const
  2333.                 { return Container::GetCurObject(); }
  2334.     ULONG   GetCurPos() const
  2335.                 { return Container::GetCurPos(); }
  2336.     void*   GetObject( ULONG nIndex ) const
  2337.                 { return Container::GetObject( nIndex ); }
  2338.     ULONG   GetPos( const void* p ) const
  2339.                 { return Container::GetPos( p ); }
  2340.  
  2341.     void*   Seek( ULONG nIndex ) { return Container::Seek( nIndex ); }
  2342.     void*   Seek( void* p )      { return Container::Seek( p ); }
  2343.     void*   First()              { return Container::First(); }
  2344.     void*   Last()               { return Container::Last(); }
  2345.     void*   Next()               { return Container::Next(); }
  2346.     void*   Prev()               { return Container::Prev(); }
  2347.  
  2348.     List&   operator =( const List& rList )
  2349.                 { Container::operator =( rList ); return *this; }
  2350.  
  2351.     BOOL    operator ==( const List& rList ) const
  2352.                 { return Container::operator ==( rList ); }
  2353.     BOOL    operator !=( const List& rList ) const
  2354.                 { return Container::operator !=( rList ); }
  2355. };
  2356.  
  2357. #define DECLARE_LIST( ClassName, Type )                                 \
  2358. class ClassName : private List                                          \
  2359. {                                                                       \
  2360. public:                                                                 \
  2361.                 ClassName( USHORT _nInitSize = 16,                      \
  2362.                            USHORT _nReSize = 16 ) :                     \
  2363.                     List( _nInitSize, _nReSize ) {}                     \
  2364.                 ClassName( USHORT _nBlockSize, USHORT _nInitSize,       \
  2365.                            USHORT _nReSize ) :                          \
  2366.                     List( _nBlockSize, _nInitSize, _nReSize ) {}        \
  2367.                 ClassName( const ClassName& rClassName ) :              \
  2368.                     List( rClassName ) {}                               \
  2369.                                                                         \
  2370.     void        Insert( Type p, ULONG nIndex )                          \
  2371.                     { List::Insert( (void*)p, nIndex ); }               \
  2372.     void        Insert( Type p )                                        \
  2373.                     { List::Insert( (void*)p ); }                       \
  2374.     void        Insert( Type pNew, Type pOld )                          \
  2375.                     { List::Insert( (void*)pNew, (void*)pOld ); }       \
  2376.     Type        Remove()                                                \
  2377.                     { return (Type)List::Remove(); }                    \
  2378.     Type        Remove( ULONG nIndex )                                  \
  2379.                     { return (Type)List::Remove( nIndex ); }            \
  2380.     Type        Remove( Type p )                                        \
  2381.                     { return (Type)List::Remove( (void*)p ); }          \
  2382.     Type        Replace( Type p )                                       \
  2383.                     { return (Type)List::Replace( (void*)p ); }         \
  2384.     Type        Replace( Type p, ULONG nIndex )                         \
  2385.                     { return (Type)List::Replace( (void*)p, nIndex ); } \
  2386.     Type        Replace( Type pNew, Type pOld )                         \
  2387.                     { return (Type)List::Replace( (void*)pNew,          \
  2388.                                                   (void*)pOld ); }      \
  2389.                                                                         \
  2390.     void        Clear() { List::Clear(); }                              \
  2391.     ULONG       Count() const { return List::Count(); }                 \
  2392.                                                                         \
  2393.     Type        GetCurObject() const                                    \
  2394.                     { return (Type)List::GetCurObject(); }              \
  2395.     ULONG       GetCurPos() const                                       \
  2396.                     { return List::GetCurPos(); }                       \
  2397.     Type        GetObject( ULONG nIndex ) const                         \
  2398.                     { return (Type)List::GetObject( nIndex ); }         \
  2399.     ULONG       GetPos( Type p ) const                                  \
  2400.                     { return List::GetPos( (void*)p ); }                \
  2401.                                                                         \
  2402.     Type        Seek( ULONG nIndex )                                    \
  2403.                     { return (Type)List::Seek( nIndex ); }              \
  2404.     Type        Seek( void* p ) { return (Type)List::Seek( p ); }       \
  2405.     Type        First()         { return (Type)List::First(); }         \
  2406.     Type        Last()          { return (Type)List::Last(); }          \
  2407.     Type        Next()          { return (Type)List::Next(); }          \
  2408.     Type        Prev()          { return (Type)List::Prev(); }          \
  2409.                                                                         \
  2410.     ClassName&  operator =( const ClassName& rClassName )               \
  2411.                     { List::operator =( rClassName ); return *this; }   \
  2412.                                                                         \
  2413.     BOOL        operator ==( const ClassName& rList ) const             \
  2414.                     { return List::operator ==( rList ); }              \
  2415.     BOOL        operator !=( const ClassName& rList ) const             \
  2416.                     { return List::operator !=( rList ); }              \
  2417. };
  2418.  
  2419. #endif 
  2420.  
  2421. #ifndef _STACK_HXX
  2422. #define _STACK_HXX
  2423.  
  2424. #ifndef _TOOLS_H
  2425. #endif
  2426.  
  2427. #ifndef _CONTNR_HXX
  2428. #endif
  2429.  
  2430. #define STACK_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
  2431.  
  2432. class Stack : private Container
  2433. {
  2434. public:
  2435.             Stack( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) :
  2436.                 Container( CONTAINER_MAXBLOCKSIZE, _nInitSize, _nReSize ) {}
  2437.             Stack( const Stack& rStack ) : Container( rStack ) {}
  2438.  
  2439.     void    Push( void* p ) { Container::Insert( p, CONTAINER_APPEND ); }
  2440.     void*   Pop()           { return Container::Remove( Count()-1 ); }
  2441.     void*   Top() const     { return Container::GetObject( Count()-1 ); }
  2442.  
  2443.     void    Clear()         { Container::Clear(); }
  2444.     ULONG   Count() const   { return Container::Count(); }
  2445.  
  2446.     void*   GetObject( ULONG nIndex ) const
  2447.                 { return Container::GetObject( nIndex ); }
  2448.     ULONG   GetPos( const void* p ) const
  2449.                 { return Container::GetPos( p ); }
  2450.  
  2451.     Stack&  operator =( const Stack& rStack )
  2452.                 { Container::operator =( rStack ); return *this; }
  2453.  
  2454.     BOOL    operator ==( const Stack& rStack ) const
  2455.                 { return Container::operator ==( rStack ); }
  2456.     BOOL    operator !=( const Stack& rStack ) const
  2457.                 { return Container::operator !=( rStack ); }
  2458. };
  2459.  
  2460. #define DECLARE_STACK( ClassName, Type )                            \
  2461. class ClassName : private Stack                                     \
  2462. {                                                                   \
  2463. public:                                                             \
  2464.                 ClassName( USHORT _nInitSize = 16,                  \
  2465.                        USHORT _nReSize = 16 ) :                     \
  2466.                     Stack( _nInitSize, _nReSize ) {}                \
  2467.                 ClassName( const ClassName& rClassName ) :          \
  2468.                     Stack( rClassName ) {}                          \
  2469.                                                                     \
  2470.     void        Push( Type p ) { Stack::Push( (void*)p ); }         \
  2471.     Type        Pop()          { return (Type)Stack::Pop(); }       \
  2472.     Type        Top() const    { return (Type)Stack::Top(); }       \
  2473.                                                                     \
  2474.     void        Clear()        { Stack::Clear(); }                  \
  2475.     ULONG       Count() const  { return Stack::Count(); }           \
  2476.                                                                     \
  2477.     Type        GetObject( ULONG nIndex ) const                     \
  2478.                     { return (Type)Stack::GetObject( nIndex ); }    \
  2479.     ULONG       GetPos( Type p ) const                              \
  2480.                     { return Stack::GetPos( (void*)p ); }           \
  2481.                                                                     \
  2482.     ClassName&  operator =( const ClassName& rClassName )           \
  2483.                     { Stack::operator =( rClassName );              \
  2484.                       return *this; }                               \
  2485.                                                                     \
  2486.     BOOL        operator ==( const ClassName& rStack ) const        \
  2487.                     { return Stack::operator ==( rStack ); }        \
  2488.     BOOL        operator !=( const ClassName& rStack ) const        \
  2489.                     { return Stack::operator !=( rStack ); }        \
  2490. };
  2491.  
  2492. #endif  
  2493.  
  2494. #ifndef _TABLE_HXX
  2495. #define _TABLE_HXX
  2496.  
  2497. #ifndef _TOOLS_H
  2498. #endif
  2499.  
  2500. #ifndef _CONTNR_HXX
  2501. #endif
  2502.  
  2503. #define TABLE_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
  2504.  
  2505. class Table : private Container
  2506. {
  2507. private:
  2508.     ULONG   nCount;
  2509.  
  2510.     ULONG   ImpGetIndex( ULONG nKey, ULONG* pIndex = NULL ) const;
  2511.  
  2512. public:
  2513.             Table( USHORT nInitSize = 16, USHORT nReSize = 16 );
  2514.             Table( const Table& rTable ) : Container( rTable )
  2515.                 { nCount = rTable.nCount; }
  2516.  
  2517.     BOOL    Insert( ULONG nKey, void* p );
  2518.     void*   Remove( ULONG nKey );
  2519.     void*   Replace( ULONG nKey, void* p );
  2520.     void*   Get( ULONG nKey ) const;
  2521.  
  2522.     void    Clear() { Container::Clear(); nCount = 0; }
  2523.     ULONG   Count() const { return( nCount ); }
  2524.  
  2525.     void*   GetCurObject() const;
  2526.     ULONG   GetCurKey() const;
  2527.     ULONG   GetKey( const void* p ) const;
  2528.     BOOL    IsKeyValid( ULONG nKey ) const;
  2529.  
  2530.     void*   Seek( ULONG nKey );
  2531.     void*   Seek( void* p );
  2532.     void*   First();
  2533.     void*   Last();
  2534.     void*   Next();
  2535.     void*   Prev();
  2536.  
  2537.     Table&  operator =( const Table& rTable );
  2538.  
  2539.     BOOL    operator ==( const Table& rTable ) const
  2540.                 { return Container::operator ==( rTable ); }
  2541.     BOOL    operator !=( const Table& rTable ) const
  2542.                 { return Container::operator !=( rTable ); }
  2543. };
  2544.  
  2545. #define DECLARE_TABLE( ClassName, Type )                                \
  2546. class ClassName : private Table                                         \
  2547. {                                                                       \
  2548. public:                                                                 \
  2549.                 ClassName( USHORT _nInitSize = 16,                      \
  2550.                            USHORT _nReSize = 16 ) :                     \
  2551.                     Table( _nInitSize, _nReSize ) {}                    \
  2552.                 ClassName( const ClassName& rClassName ) :              \
  2553.                     Table( rClassName ) {}                              \
  2554.                                                                         \
  2555.     BOOL        Insert( ULONG nKey, Type p )                            \
  2556.                     { return Table::Insert( nKey, (void*)p ); }         \
  2557.     Type        Remove( ULONG nKey )                                    \
  2558.                     { return (Type)Table::Remove( nKey ); }             \
  2559.     Type        Replace( ULONG nKey, Type p )                           \
  2560.                     { return (Type)Table::Replace( nKey, (void*)p ); }  \
  2561.     Type        Get( ULONG nKey ) const                                 \
  2562.                     { return (Type)Table::Get( nKey ); }                \
  2563.                                                                         \
  2564.     void        Clear() { Table::Clear(); }                             \
  2565.     ULONG       Count() const { return Table::Count(); }                \
  2566.                                                                         \
  2567.     Type        GetCurObject() const                                    \
  2568.                     { return (Type)Table::GetCurObject(); }             \
  2569.     ULONG       GetCurKey() const { return Table::GetCurKey(); }        \
  2570.     ULONG       GetKey( Type p ) const                                  \
  2571.                     { return Table::GetKey( (void*)p ); }               \
  2572.     BOOL        IsKeyValid( ULONG nKey ) const                          \
  2573.                     { return Table::IsKeyValid( nKey ); }               \
  2574.                                                                         \
  2575.     Type        Seek( ULONG nKey )                                      \
  2576.                     { return (Type)Table::Seek( nKey ); }               \
  2577.     Type        Seek( Type p )                                          \
  2578.                     { return (Type)Table::Seek( (void*)p ); }           \
  2579.     Type        First() { return (Type)Table::First(); }                \
  2580.     Type        Last()  { return (Type)Table::Last(); }                 \
  2581.     Type        Next()  { return (Type)Table::Next(); }                 \
  2582.     Type        Prev()  { return (Type)Table::Prev(); }                 \
  2583.                                                                         \
  2584.     ClassName&  operator =( const ClassName& rClassName )               \
  2585.                     { Table::operator =( rClassName );                  \
  2586.                       return *this; }                                   \
  2587.                                                                         \
  2588.     BOOL        operator ==( const ClassName& rTable ) const            \
  2589.                     { return Table::operator ==( rTable ); }            \
  2590.     BOOL        operator !=( const ClassName& rTable ) const            \
  2591.                     { return Table::operator !=( rTable ); }            \
  2592. };
  2593.  
  2594. #endif 
  2595.  
  2596. #ifndef _QUEUE_HXX
  2597. #define _QUEUE_HXX
  2598.  
  2599. #ifndef _TOOLS_H
  2600. #endif
  2601.  
  2602. #ifndef _CONTNR_HXX
  2603. #endif
  2604.  
  2605. #define QUEUE_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
  2606.  
  2607. class Queue : private Container
  2608. {
  2609. public:
  2610.             Queue( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) :
  2611.                 Container( _nReSize, _nInitSize, _nReSize ) {}
  2612.             Queue( const Queue& rQueue ) : Container( rQueue ) {}
  2613.  
  2614.     void    Put( void* p ) { Container::Insert( p, CONTAINER_APPEND ); }
  2615.     void*   Get()          { return Container::Remove( (ULONG)0 ); }
  2616.  
  2617.     void    Clear()        { Container::Clear(); }
  2618.     ULONG   Count() const  { return Container::Count(); }
  2619.  
  2620.     void*   GetObject( ULONG nIndex ) const
  2621.                 { return Container::GetObject( nIndex ); }
  2622.     ULONG   GetPos( const void* p ) const
  2623.                 { return Container::GetPos( p ); }
  2624.  
  2625.     Queue&  operator =( const Queue& rQueue )
  2626.                 { Container::operator =( rQueue ); return *this; }
  2627.  
  2628.     BOOL    operator ==( const Queue& rQueue ) const
  2629.                 { return Container::operator ==( rQueue ); }
  2630.     BOOL    operator !=( const Queue& rQueue ) const
  2631.                 { return Container::operator !=( rQueue ); }
  2632. };
  2633.  
  2634. #define DECLARE_QUEUE( ClassName, Type )                            \
  2635. class ClassName : private Queue                                     \
  2636. {                                                                   \
  2637. public:                                                             \
  2638.                 ClassName( USHORT _nInitSize = 16,                  \
  2639.                            USHORT _nReSize = 16 ) :                 \
  2640.                     Queue( _nInitSize, _nReSize ) {}                \
  2641.                 ClassName( const ClassName& rClassName ) :          \
  2642.                     Queue( rClassName ) {}                          \
  2643.                                                                     \
  2644.     void        Put( Type p ) { Queue::Put( (void*)p ); }           \
  2645.     Type        Get()         { return (Type)Queue::Get(); }        \
  2646.                                                                     \
  2647.     void        Clear()        { Queue::Clear(); }                  \
  2648.     ULONG       Count() const  { return Queue::Count(); }           \
  2649.                                                                     \
  2650.     Type        GetObject( ULONG nIndex ) const                     \
  2651.                     { return (Type)Queue::GetObject( nIndex ); }    \
  2652.     ULONG       GetPos( void* p ) const                             \
  2653.                     { return Queue::GetPos( (void*)p ); }           \
  2654.                                                                     \
  2655.     ClassName&  operator =( const ClassName& rClassName )           \
  2656.                     { Queue::operator =( rClassName );              \
  2657.                       return *this; }                               \
  2658.                                                                     \
  2659.     BOOL        operator ==( const Queue& rQueue ) const            \
  2660.                     { return Queue::operator ==( rQueue ); }        \
  2661.     BOOL        operator !=( const Queue& rQueue ) const            \
  2662.                     { return Queue::operator !=( rQueue ); }        \
  2663. };
  2664.  
  2665. #endif 
  2666.  
  2667. #ifndef _DYNARY_HXX
  2668. #define _DYNARY_HXX
  2669.  
  2670. #ifndef _TOOLS_H
  2671. #endif
  2672.  
  2673. #ifndef _CONTNR_HXX
  2674. #endif
  2675.  
  2676. class DynArray : private Container
  2677. {
  2678. public:
  2679.                 DynArray( ULONG nSize = 16 ) : Container( nSize ) {}
  2680.                 DynArray( const DynArray& rAry ) : Container( rAry ) {}
  2681.  
  2682.     void*       Put( ULONG nIndex, void* p )
  2683.                     { return Container::Replace( p, nIndex ); }
  2684.     void*       Get( ULONG nIndex ) const
  2685.                     { return Container::GetObject( nIndex ); }
  2686.  
  2687.     ULONG       ChangeSize( ULONG nNewSize )
  2688.                     { return Container::ChangeSize( nNewSize ); }
  2689.     ULONG       GetSize() const
  2690.                     { return Container::GetSize(); }
  2691.     void        Clear() { Container::Clear(); }
  2692.  
  2693.     DynArray&   operator =( const DynArray& rAry )
  2694.                     { Container::operator =( rAry ); return *this; }
  2695.  
  2696.     BOOL        operator ==( const DynArray& rAry ) const
  2697.                     { return Container::operator ==( rAry ); }
  2698.     BOOL        operator !=( const DynArray& rAry ) const
  2699.                     { return Container::operator !=( rAry ); }
  2700. };
  2701.  
  2702. #define DECLARE_DYNARRAY( ClassName, Type )                             \
  2703. class ClassName : private DynArray                                      \
  2704. {                                                                       \
  2705. public:                                                                 \
  2706.                 ClassName( ULONG nSize = 16 ) :                         \
  2707.                     DynArray( nSize ) {}                                \
  2708.                 ClassName( const ClassName& rClassName ) :              \
  2709.                     DynArray( rClassName ) {}                           \
  2710.                                                                         \
  2711.     Type        Put( ULONG nIndex, Type p )                             \
  2712.                     { return (Type)DynArray::Put( nIndex, (void*)p ); } \
  2713.     Type        Get( ULONG nIndex ) const                               \
  2714.                     { return (Type)DynArray::Get( nIndex ); }           \
  2715.                                                                         \
  2716.     ULONG       ChangeSize( ULONG nNewSize )                            \
  2717.                     { return DynArray::ChangeSize( nNewSize ); }        \
  2718.     ULONG       GetSize() const                                         \
  2719.                     { return DynArray::GetSize(); }                     \
  2720.     void        Clear() { DynArray::Clear(); }                          \
  2721.                                                                         \
  2722.     ClassName&  operator =( const ClassName& rClassName )               \
  2723.                     { DynArray::operator =( rClassName );               \
  2724.                       return *this; }                                   \
  2725.                                                                         \
  2726.     BOOL        operator ==( const ClassName& rAry ) const              \
  2727.                     { return DynArray::operator ==( rAry ); }           \
  2728.     BOOL        operator !=( const ClassName& rAry ) const              \
  2729.                     { return DynArray::operator !=( rAry ); }           \
  2730. };
  2731.  
  2732. #endif 
  2733.  
  2734. #ifndef _UNQIDX_HXX
  2735. #define _UNQIDX_HXX
  2736.  
  2737. #ifndef _TOOLS_H
  2738. #endif
  2739.  
  2740. #ifndef _CONTNR_HXX
  2741. #endif
  2742.  
  2743. #define UNIQUEINDEX_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
  2744.  
  2745. class UniqueIndex : private Container
  2746. {
  2747. private:
  2748.     ULONG           nReSize;
  2749.     ULONG           nStartIndex;
  2750.     ULONG           nUniqIndex;
  2751.     ULONG           nCount;
  2752.  
  2753. public:
  2754.                     UniqueIndex( ULONG nStartIndex = 0,
  2755.                                  ULONG nInitSize = 16,
  2756.                                  ULONG nReSize = 16 );
  2757.                     UniqueIndex( const UniqueIndex& rIdx );
  2758.  
  2759.     ULONG           Insert( void* p );
  2760.     void*           Remove( ULONG nIndex );
  2761.     void*           Replace( ULONG nIndex, void* p );
  2762.     void*           Get( ULONG nIndex ) const;
  2763.  
  2764.     void            Clear();
  2765.     ULONG           Count() const { return nCount; }
  2766.  
  2767.     void*           GetCurObject() const;
  2768.     ULONG           GetCurIndex() const;
  2769.     ULONG           GetIndex( const void* p ) const;
  2770.     BOOL            IsIndexValid( ULONG nIndex ) const;
  2771.  
  2772.     void*           Seek( ULONG nIndex );
  2773.     void*           Seek( void* p );
  2774.     void*           First();
  2775.     void*           Last();
  2776.     void*           Next();
  2777.     void*           Prev();
  2778.  
  2779.     UniqueIndex&    operator =( const UniqueIndex& rIdx );
  2780.  
  2781.     BOOL            operator ==( const UniqueIndex& rIdx ) const;
  2782.     BOOL            operator !=( const UniqueIndex& rIdx ) const;
  2783. };
  2784.  
  2785. #define DECLARE_UNIQUEINDEX( ClassName, Type )                          \
  2786. class ClassName : private UniqueIndex                                   \
  2787. {                                                                       \
  2788. public:                                                                 \
  2789.                 ClassName( ULONG _nStartIndex = 0,                      \
  2790.                            ULONG _nInitSize = 16, ULONG _nReSize = 16 ):\
  2791.                     UniqueIndex( _nStartIndex, _nInitSize, _nReSize ) {}\
  2792.                 ClassName( const ClassName& rClassName ) :              \
  2793.                     UniqueIndex( rClassName ) {}                        \
  2794.                                                                         \
  2795.     ULONG       Insert( Type p )                                        \
  2796.                     { return UniqueIndex::Insert( (void*)p ); }         \
  2797.     Type        Remove( ULONG nIndex )                                  \
  2798.                     { return (Type)UniqueIndex::Remove( nIndex ); }     \
  2799.     Type        Replace( ULONG nIndex, Type p )                         \
  2800.                     { return (Type)UniqueIndex::Replace( nIndex,        \
  2801.                                                          (void*)p ); }  \
  2802.     Type        Get( ULONG nIndex ) const                               \
  2803.                     { return (Type)UniqueIndex::Get( nIndex ); }        \
  2804.                                                                         \
  2805.     void        Clear() { UniqueIndex::Clear(); }                       \
  2806.     ULONG       Count() const { return UniqueIndex::Count(); }          \
  2807.                                                                         \
  2808.     Type        GetCurObject() const                                    \
  2809.                     { return (Type)UniqueIndex::GetCurObject(); }       \
  2810.     ULONG       GetCurIndex() const                                     \
  2811.                     { return UniqueIndex::GetCurIndex(); }              \
  2812.     ULONG       GetIndex( Type p ) const                                \
  2813.                     { return UniqueIndex::GetIndex( (void*)p ); }       \
  2814.     BOOL        IsIndexValid( ULONG nIndex ) const                      \
  2815.                     { return UniqueIndex::IsIndexValid( nIndex ); }     \
  2816.                                                                         \
  2817.     Type        Seek( ULONG nKey )                                      \
  2818.                     { return (Type)UniqueIndex::Seek( nKey ); }         \
  2819.     Type        Seek( Type p )                                          \
  2820.                     { return (Type)UniqueIndex::Seek( (void*)p ); }     \
  2821.     Type        First()  { return (Type)UniqueIndex::First(); }         \
  2822.     Type        Last()   { return (Type)UniqueIndex::Last(); }          \
  2823.     Type        Next()   { return (Type)UniqueIndex::Next(); }          \
  2824.     Type        Prev()   { return (Type)UniqueIndex::Prev(); }          \
  2825.                                                                         \
  2826.     ClassName&  operator =( const ClassName& rClassName )               \
  2827.                     { UniqueIndex::operator =( rClassName );            \
  2828.                       return *this; }                                   \
  2829.                                                                         \
  2830.     BOOL        operator ==( const ClassName& rIdx ) const              \
  2831.                     { return UniqueIndex::operator ==( rIdx ); }        \
  2832.     BOOL        operator !=( const ClassName& rIdx ) const              \
  2833.                     { return UniqueIndex::operator !=( rIdx ); }        \
  2834. };
  2835.  
  2836. #endif 
  2837.  
  2838. #ifndef _DEBUG_HXX
  2839. #define _DEBUG_HXX
  2840.  
  2841. #ifndef _TOOLS_H
  2842. #endif
  2843.  
  2844. #ifdef DBG_UTIL
  2845.  
  2846. typedef void (*DbgPrintLine)( const char* pLine );
  2847. typedef const char* (*DbgUsr)(const void* pThis );
  2848.  
  2849. #define DBG_TEST                    (0xFFFFFFFF)
  2850. #define DBG_TEST_XTOR               (0x00000001)
  2851. #define DBG_TEST_CHKTHIS            (0x00000002)
  2852. #define DBG_TEST_CHKFUNC            (0x00000004)
  2853. #define DBG_TEST_CHKEXIT            (0x00000008)
  2854. #define DBG_TEST_XTOR_REPORT        (0x00000010)
  2855. #define DBG_TEST_ASSERT_ERROR       (0x00000020)
  2856. #define DBG_TEST_ASSERT_WARNING     (0x00000040)
  2857. #define DBG_TEST_PROFILING          (0x00000100)
  2858. #define DBG_TEST_RESOURCE           (0x00000200)
  2859.  
  2860. #define DBG_MEM                     (0xFFFFFFFF)
  2861. #define DBG_MEM_INIT                (0x00000001)
  2862. #define DBG_MEM_OVERWRITE           (0x00000002)
  2863. #define DBG_MEM_POINTER             (0x00000004)
  2864. #define DBG_MEM_READONLY            (0x00000008)
  2865. #define DBG_MEM_REPORT              (0x00000010)
  2866.  
  2867. #define DBG_OUT_NULL                0
  2868. #define DBG_OUT_FILE                1
  2869. #define DBG_OUT_MSGBOX              2
  2870. #define DBG_OUT_WINDOW              3
  2871. #define DBG_OUT_SHELL               4
  2872.  
  2873. #define DBGGUI_RESTORE              0
  2874. #define DBGGUI_MINIMIZE             1
  2875. #define DBGGUI_MAXIMIZE             2
  2876.  
  2877. struct DbgGUIData
  2878. {
  2879.     USHORT      nX;
  2880.     USHORT      nY;
  2881.     USHORT      nDX;
  2882.     USHORT      nDY;
  2883.     USHORT      nShowStatus;
  2884. };
  2885.  
  2886. struct DbgData
  2887. {
  2888.     ULONG       nTestFlags;
  2889.     ULONG       nMemFlags;
  2890.     ULONG       nNewDelete;
  2891.     ULONG       nEntryExit;
  2892.     ULONG       bOverwrite;
  2893.     ULONG       nTraceOut;
  2894.     ULONG       nWarningOut;
  2895.     ULONG       nErrorOut;
  2896.     DbgGUIData  aGUIData;
  2897.     char        aDebugName[260];
  2898. };
  2899.  
  2900. struct DbgDataType
  2901. {
  2902.     void*       pData;
  2903.     char*       pName;
  2904. };
  2905.  
  2906. #define DBG_FUNC_DEBUGEND           1
  2907. #define DBG_FUNC_SETPRINTMSGBOX     2
  2908. #define DBG_FUNC_SETPRINTWINDOW     3
  2909. #define DBG_FUNC_SETPRINTSHELL      4
  2910. #define DBG_FUNC_GETDATA            5
  2911. #define DBG_FUNC_SAVEDATA           6
  2912.  
  2913. void* DbgFunc( USHORT nAction, void* pData = NULL );
  2914.  
  2915. inline void DbgDebugEnd()
  2916. {
  2917.     DbgFunc( DBG_FUNC_DEBUGEND );
  2918. }
  2919.  
  2920. inline void DbgSetPrintMsgBox( DbgPrintLine pProc )
  2921. {
  2922.     DbgFunc( DBG_FUNC_SETPRINTMSGBOX, pProc );
  2923. }
  2924.  
  2925. inline void DbgSetPrintWindow( DbgPrintLine pProc )
  2926. {
  2927.     DbgFunc( DBG_FUNC_SETPRINTWINDOW, pProc );
  2928. }
  2929.  
  2930. inline void DbgSetPrintShell( DbgPrintLine pProc )
  2931. {
  2932.     DbgFunc( DBG_FUNC_SETPRINTSHELL, pProc );
  2933. }
  2934.  
  2935. inline DbgData* DbgGetData()
  2936. {
  2937.     return (DbgData*)DbgFunc( DBG_FUNC_GETDATA );
  2938. }
  2939.  
  2940. inline void DbgSaveData( const DbgData& rData )
  2941. {
  2942.     DbgFunc( DBG_FUNC_SAVEDATA, (void*)&rData );
  2943. }
  2944.  
  2945. inline ULONG DbgIsAssertWarning()
  2946. {
  2947.     return DbgGetData()->nTestFlags & DBG_TEST_ASSERT_WARNING;
  2948. }
  2949.  
  2950. inline ULONG DbgIsAssert()
  2951. {
  2952.     return DbgGetData()->nTestFlags & DBG_TEST_ASSERT_ERROR;
  2953. }
  2954.  
  2955. inline ULONG DbgIsMemTest()
  2956. {
  2957.     return DbgGetData()->nMemFlags;
  2958. }
  2959.  
  2960. inline ULONG DbgIsResource()
  2961. {
  2962.     return DbgGetData()->nTestFlags & DBG_TEST_RESOURCE;
  2963. }
  2964.  
  2965. #define DBG_OUT_TRACE               1
  2966. #define DBG_OUT_WARNING             2
  2967. #define DBG_OUT_ERROR               3
  2968.  
  2969. void DbgOut( const char* pMsg, USHORT nOutType = DBG_OUT_TRACE,
  2970.              const char* pFile = NULL, USHORT nLine = 0 );
  2971.  
  2972. void DbgOutf( const char* pFStr, ... );
  2973.  
  2974. inline void DbgTrace( const char* pMsg,
  2975.                       const char* pFile = NULL, USHORT nLine = 0 )
  2976. {
  2977.     DbgOut( pMsg, DBG_OUT_TRACE, pFile, nLine );
  2978. }
  2979.  
  2980. inline void DbgWarning( const char* pMsg,
  2981.                         const char* pFile = NULL, USHORT nLine = 0 )
  2982. {
  2983.     DbgOut( pMsg, DBG_OUT_WARNING, pFile, nLine );
  2984. }
  2985.  
  2986. inline void DbgError( const char* pMsg,
  2987.                       const char* pFile = NULL, USHORT nLine = 0 )
  2988. {
  2989.     DbgOut( pMsg, DBG_OUT_ERROR, pFile, nLine );
  2990. }
  2991.  
  2992. #define DBG_PROF_START              1
  2993. #define DBG_PROF_STOP               2
  2994. #define DBG_PROF_CONTINUE           3
  2995. #define DBG_PROF_PAUSE              4
  2996.  
  2997. void DbgProf( USHORT nAction, DbgDataType* );
  2998.  
  2999. #define DBG_XTOR_CTOR               1
  3000. #define DBG_XTOR_DTOR               2
  3001. #define DBG_XTOR_CHKTHIS            3
  3002. #define DBG_XTOR_CHKOBJ             4
  3003. #define DBG_XTOR_DTOROBJ            0x8000
  3004.  
  3005. void DbgXtor( DbgDataType* pDbgData,
  3006.               USHORT nAction, const void* pThis, DbgUsr fDbgUsr );
  3007.  
  3008. class DbgXtorObj
  3009. {
  3010. private:
  3011.     DbgDataType*    pDbgData;
  3012.     const void*     pThis;
  3013.     DbgUsr          fDbgUsr;
  3014.     USHORT          nAction;
  3015.  
  3016. public:
  3017.                     DbgXtorObj( DbgDataType* pData,
  3018.                                 USHORT nAct, const void* pThs, DbgUsr fUsr )
  3019.                     {
  3020.                         DbgXtor( pData, nAct, pThs, fUsr );
  3021.                         pDbgData = pData;
  3022.                         nAction  = nAct;
  3023.                         pThis    = pThs;
  3024.                         fDbgUsr  = fUsr;
  3025.                     }
  3026.  
  3027.                     ~DbgXtorObj()
  3028.                     {
  3029.                         DbgXtor( pDbgData, nAction | DBG_XTOR_DTOROBJ,
  3030.                                  pThis, fDbgUsr );
  3031.                     }
  3032. };
  3033.  
  3034. #define DBG_PRAE( aName )                   __DbgName_##aName
  3035. #define DBG_NAME( aName )                   DbgDataType DBG_PRAE( aName ) = { 0, #aName }
  3036. #define DBG_NAMEEX( aName )                 extern DbgDataType DBG_PRAE( aName )
  3037.  
  3038. #if defined( W30 ) && (defined( __SC__ ) || defined( _MSC_VER ))
  3039. #define DBG_DEFTEXT                         static const char _far _pText[]
  3040. #define DBG_DEFFILE                         static const char _far _pFile[]
  3041. #else
  3042. #define DBG_DEFTEXT                         static const char* _pText
  3043. #define DBG_DEFFILE                         static const char* _pFile
  3044. #endif
  3045.  
  3046. #define DBG_DEBUGEND()                      DbgDebugEnd()
  3047.  
  3048. #define DBG_PROFSTART( aName )              \
  3049.     DbgProf( DBG_PROF_START,                \
  3050.              &DBG_PRAE(aName ) )
  3051.  
  3052. #define DBG_PROFSTOP( aName )               \
  3053.     DbgProf( DBG_PROF_STOP,                 \
  3054.              &DBG_PRAE(aName ) )
  3055.  
  3056. #define DBG_PROFCONTINUE( aName )           \
  3057.     DbgProf( DBG_PROF_CONTINUE,             \
  3058.              &DBG_PRAE(aName ) )
  3059.  
  3060. #define DBG_PROFPAUSE( aName )              \
  3061.     DbgProf( DBG_PROF_PAUSE,                \
  3062.              &DBG_PRAE(aName ) )
  3063.  
  3064. #define DBG_CTOR( aName, fTest )                    \
  3065.     DbgXtorObj aDbgXtorObj( &DBG_PRAE( aName ),     \
  3066.                             DBG_XTOR_CTOR,          \
  3067.                             (const void*)this,      \
  3068.                             fTest )
  3069.  
  3070. #define DBG_DTOR( aName, fTest )                    \
  3071.     DbgXtorObj aDbgXtorObj( &DBG_PRAE( aName ),     \
  3072.                             DBG_XTOR_DTOR,          \
  3073.                             (const void*)this,      \
  3074.                             fTest )
  3075.  
  3076. #define DBG_CHKTHIS( aName, fTest )                 \
  3077.     DbgXtorObj aDbgXtorObj( &DBG_PRAE( aName ),     \
  3078.                             DBG_XTOR_CHKTHIS,       \
  3079.                             (const void*)this,      \
  3080.                             fTest )
  3081.  
  3082. #define DBG_CHKOBJ( pObj, aName, fTest )            \
  3083.     DbgXtor( &DBG_PRAE( aName ), DBG_XTOR_CHKOBJ,   \
  3084.              (const void*)pObj, (DbgUsr)fTest )
  3085.  
  3086. #define DBG_ASSERTWARNING( sCon, aWarning ) \
  3087. {                                           \
  3088.     if ( DbgIsAssertWarning() )             \
  3089.     {                                       \
  3090.         if ( !( sCon ) )                    \
  3091.         {                                   \
  3092.             DBG_DEFTEXT      = aWarning;    \
  3093.             DBG_DEFFILE      = __FILE__;    \
  3094.             DbgWarning( _pText,             \
  3095.                         _pFile, __LINE__ ); \
  3096.         }                                   \
  3097.     }                                       \
  3098. }
  3099.  
  3100. #define DBG_ASSERT( sCon, aError )          \
  3101. {                                           \
  3102.     if ( DbgIsAssert() )                    \
  3103.     {                                       \
  3104.         if ( !( sCon ) )                    \
  3105.         {                                   \
  3106.             DBG_DEFTEXT      = aError;      \
  3107.             DBG_DEFFILE      = __FILE__;    \
  3108.             DbgError( _pText,               \
  3109.                       _pFile, __LINE__ );   \
  3110.         }                                   \
  3111.     }                                       \
  3112. }
  3113.  
  3114. #define DBG_TRACE( aTrace )                 \
  3115. {                                           \
  3116.     DbgTrace( aTrace );                     \
  3117. }
  3118.  
  3119. #define DBG_WARNING( aWarning )             \
  3120. {                                           \
  3121.     DbgWarning( aWarning );                 \
  3122. }
  3123.  
  3124. #define DBG_ERROR( aError )                 \
  3125. {                                           \
  3126.     DbgError( aError );                     \
  3127. }
  3128.  
  3129. #define DBG_WARNINGFILE( aWarning )             \
  3130. {                                               \
  3131.     DbgWarning( aWarning, __FILE__, __LINE__ ); \
  3132. }
  3133.  
  3134. #define DBG_ERRORFILE( aError )                 \
  3135. {                                               \
  3136.     DbgError( aError, __FILE__, __LINE__ );     \
  3137. }
  3138.  
  3139. #define DBG_INSTASSERT( bOn )                                   \
  3140. {                                                               \
  3141.     if ( bOn )                                                  \
  3142.         DbgGetData()->nTestFlags |= DBG_TEST_ASSERT_ERROR;      \
  3143.     else                                                        \
  3144.         DbgGetData()->nTestFlags &= ~DBG_TEST_ASSERT_ERROR;     \
  3145. }
  3146.  
  3147. #define DBG_INSTASSERTWARNING( bOn )                            \
  3148. {                                                               \
  3149.     if ( bOn )                                                  \
  3150.         DbgGetData()->nTestFlags |= DBG_TEST_ASSERT_WARNING;    \
  3151.     else                                                        \
  3152.         DbgGetData()->nTestFlags &= ~DBG_TEST_ASSERT_WARNING;   \
  3153. }
  3154.  
  3155. #define DBG_INSTOUTTRACE( nOut )            \
  3156. {                                           \
  3157.     DbgGetData()->nTraceOut = nOut;         \
  3158. }
  3159.  
  3160. #define DBG_INSTOUTWARNING( nOut )          \
  3161. {                                           \
  3162.     DbgGetData()->nWarningOut = nOut;       \
  3163. }
  3164.  
  3165. #define DBG_INSTOUTERROR( nOut )            \
  3166. {                                           \
  3167.     DbgGetData()->nErrorOut = nOut;         \
  3168. }
  3169.  
  3170. #else
  3171.  
  3172. struct DbgData;
  3173. struct DbgGUIData;
  3174. struct DbgDataType;
  3175.  
  3176. typedef void (*DbgPrintLine)( const char* pLine );
  3177. typedef const char* (*DbgUsr)(const void* pThis );
  3178.  
  3179. #define DBG_DEBUGEND()
  3180.  
  3181. #define DBG_NAME( aName )
  3182. #define DBG_NAMEEX( aName )
  3183.  
  3184. #define DBG_PROFSTART( aName )
  3185. #define DBG_PROFSTOP( aName )
  3186. #define DBG_PROFCONTINUE( aName )
  3187. #define DBG_PROFPAUSE( aName )
  3188.  
  3189. #define DBG_CTOR( aName, fTest )
  3190. #define DBG_DTOR( aName, fTest )
  3191. #define DBG_CHKTHIS( aName, fTest )
  3192. #define DBG_CHKOBJ( pObj, aName, fTest )
  3193.  
  3194. #define DBG_ASSERTWARNING( sCon, aWarning )
  3195. #define DBG_ASSERT( sCon, aError )
  3196. #define DBG_TRACE( aTrace )
  3197. #define DBG_WARNING( aWarning )
  3198. #define DBG_ERROR( aError )
  3199. #define DBG_WARNINGFILE( aWarning )
  3200. #define DBG_ERRORFILE( aError )
  3201.  
  3202. #define DBG_INSTASSERT( bOn )
  3203. #define DBG_INSTASSERTWARNING( bOn )
  3204.  
  3205. #define DBG_INSTOUTTRACE( nOut )
  3206. #define DBG_INSTOUTWARNING( nOut )
  3207. #define DBG_INSTOUTERROR( nOut )
  3208.  
  3209. #endif
  3210.  
  3211. #endif  
  3212.  
  3213. #ifndef _DATE_HXX
  3214. #define _DATE_HXX
  3215.  
  3216. #ifndef _TOOLS_H
  3217. #endif
  3218.  
  3219. class ResId;
  3220.  
  3221. enum DayOfWeek { MONDAY, TUESDAY, WEDNESDAY, THURSDAY,
  3222.                  FRIDAY, SATURDAY, SUNDAY };
  3223.  
  3224. class Date
  3225. {
  3226. private:
  3227.     ULONG           nDate;
  3228.  
  3229. public:
  3230.                     Date();
  3231.                     Date( const ResId & rResId );
  3232.                     Date( ULONG _nDate ) { Date::nDate = _nDate; }
  3233.                     Date( const Date& rDate )
  3234.                         { nDate = rDate.nDate; }
  3235.                     Date( USHORT nDay, USHORT nMonth, USHORT nYear )
  3236.                         { nDate = ((ULONG)(nDay%100)) +
  3237.                                   (((ULONG)(nMonth%100))*100) +
  3238.                                   (((ULONG)nYear%10000)*10000); }
  3239.  
  3240.     ULONG           ChangeDate( ULONG nNewDate )
  3241.                         { ULONG nOldDate = nDate; nDate = nNewDate;
  3242.                           return nOldDate; }
  3243.     ULONG           GetDate() const { return nDate; }
  3244.  
  3245.     USHORT          ChangeDay( USHORT nNewDay );
  3246.     USHORT          ChangeMonth( USHORT nNewMonth );
  3247.     USHORT          ChangeYear( USHORT nNewYear );
  3248.     USHORT          GetDay() const { return (USHORT)(nDate % 100); }
  3249.     USHORT          GetMonth() const { return (USHORT)((nDate / 100) % 100); }
  3250.     USHORT          GetYear() const { return (USHORT)(nDate / 10000); }
  3251.  
  3252.     DayOfWeek       GetDayOfWeek() const;
  3253.     USHORT          GetDayOfYear() const;
  3254.     USHORT          GetWeekOfYear() const;
  3255.  
  3256.     USHORT          GetDaysInMonth() const;
  3257.     USHORT          GetDaysInYear() const { return (IsLeapYear()) ? 366 : 365; }
  3258.     BOOL            IsLeapYear() const;
  3259.     BOOL            IsValid() const;
  3260.  
  3261.     BOOL            IsBetween( const Date& rFrom, const Date& rTo ) const
  3262.                         { return ((nDate >= rFrom.nDate) &&
  3263.                                  (nDate <= rTo.nDate)); }
  3264.  
  3265.     friend BOOL     operator ==( const Date& rDate1, const Date& rDate2 )
  3266.                         { return (rDate1.nDate == rDate2.nDate); }
  3267.     friend BOOL     operator !=( const Date& rDate1, const Date& rDate2 )
  3268.                         { return (rDate1.nDate != rDate2.nDate); }
  3269.     friend BOOL     operator  >( const Date& rDate1, const Date& rDate2 )
  3270.                         { return (rDate1.nDate > rDate2.nDate); }
  3271.     friend BOOL     operator  <( const Date& rDate1, const Date& rDate2 )
  3272.                         { return (rDate1.nDate < rDate2.nDate); }
  3273.     friend BOOL     operator >=( const Date& rDate1, const Date& rDate2 )
  3274.                         { return (rDate1.nDate >= rDate2.nDate); }
  3275.     friend BOOL     operator <=( const Date& rDate1, const Date& rDate2 )
  3276.                         { return (rDate1.nDate <= rDate2.nDate); }
  3277.  
  3278.     Date&           operator =( const Date& rDate )
  3279.                         { nDate = rDate.nDate; return *this; }
  3280.     Date&           operator +=( ULONG nDays );
  3281.     Date&           operator -=( ULONG nDays );
  3282.     Date&           operator ++();
  3283.     Date&           operator --();
  3284. #ifndef SUN
  3285. #ifndef MPW33
  3286.     Date            operator ++( int );
  3287.     Date            operator --( int );
  3288. #endif
  3289. #endif
  3290.  
  3291.     friend Date     operator +( const Date& rDate, ULONG nDays );
  3292.     friend Date     operator -( const Date& rDate, ULONG nDays );
  3293.     friend ULONG    operator -( const Date& rDate1, const Date& rDate2 );
  3294. };
  3295.  
  3296. #endif 
  3297.  
  3298. #ifndef _TIME_HXX
  3299. #define _TIME_HXX
  3300.  
  3301. #ifndef _TOOLS_H
  3302. #endif
  3303.  
  3304. class ResId;
  3305.  
  3306. class Time
  3307. {
  3308. private:
  3309.     long        nTime;
  3310.  
  3311. public:
  3312.                 Time();
  3313.                 Time( const ResId & rResId );
  3314.                 Time( long _nTime ) { Time::nTime = _nTime; }
  3315.                 Time( const Time& rTime )
  3316.                     { nTime = rTime.nTime; }
  3317.                 Time( USHORT nHour, USHORT nMin,
  3318.                       USHORT nSec = 0, USHORT n100Sec = 0 );
  3319.  
  3320.     long        ChangeTime( long nNewTime )
  3321.                     { long nOldTime = nTime; nTime = nNewTime;
  3322.                       return nOldTime; }
  3323.     long        GetTime() const { return nTime; }
  3324.  
  3325.     USHORT      ChangeHour( USHORT nNewHour );
  3326.     USHORT      ChangeMin( USHORT nNewMin );
  3327.     USHORT      ChangeSec( USHORT nNewSec );
  3328.     USHORT      Change100Sec( USHORT nNew100Sec );
  3329.     USHORT      GetHour() const
  3330.                     { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1;
  3331.                       return (USHORT)(nTempTime / 1000000); }
  3332.     USHORT      GetMin() const
  3333.                     { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1;
  3334.                       return (USHORT)((nTempTime / 10000) % 100); }
  3335.     USHORT      GetSec() const
  3336.                     { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1;
  3337.                       return (USHORT)((nTempTime / 100) % 100); }
  3338.     USHORT      Get100Sec() const
  3339.                     { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1;
  3340.                       return (USHORT)(nTempTime % 100); }
  3341.  
  3342.     BOOL        IsBetween( const Time& rFrom, const Time& rTo ) const
  3343.                     { return ((nTime >= rFrom.nTime) && (nTime <= rTo.nTime)); }
  3344.  
  3345.     friend BOOL operator ==( const Time& rTime1, const Time& rTime2 )
  3346.                     { return (rTime1.nTime == rTime2.nTime); }
  3347.     friend BOOL operator !=( const Time& rTime1, const Time& rTime2 )
  3348.                     { return (rTime1.nTime != rTime2.nTime); }
  3349.     friend BOOL operator  >( const Time& rTime1, const Time& rTime2 )
  3350.                     { return (rTime1.nTime > rTime2.nTime); }
  3351.     friend BOOL operator  <( const Time& rTime1, const Time& rTime2 )
  3352.                     { return (rTime1.nTime < rTime2.nTime); }
  3353.     friend BOOL operator >=( const Time& rTime1, const Time& rTime2 )
  3354.                     { return (rTime1.nTime >= rTime2.nTime); }
  3355.     friend BOOL operator <=( const Time& rTime1, const Time& rTime2 )
  3356.                     { return (rTime1.nTime <= rTime2.nTime); }
  3357.  
  3358.     Time&       operator =( const Time& rTime )
  3359.                     { nTime = rTime.nTime; return *this; }
  3360.     Time        operator -() const
  3361.                     { Time aTime; aTime.nTime = nTime*-1; return aTime; }
  3362.     Time&       operator +=( const Time& rTime );
  3363.     Time&       operator -=( const Time& rTime );
  3364.     friend Time operator +( const Time& rTime1, const Time& rTime2 );
  3365.     friend Time operator -( const Time& rTime1, const Time& rTime2 );
  3366. };
  3367.  
  3368. #endif 
  3369.  
  3370. #ifndef _DATETIME_HXX
  3371. #define _DATETIME_HXX
  3372.  
  3373. #ifndef _TOOLS_H
  3374. #endif
  3375.  
  3376. #ifndef _DATE_HXX
  3377. #endif
  3378.  
  3379. #ifndef _TIME_HXX
  3380. #endif
  3381.  
  3382. class DateTime : public Date, public Time
  3383. {
  3384. public:
  3385.                     DateTime() : Date(), Time() {}
  3386.                     DateTime( const Date& rDate ) : Date( rDate ), Time() {}
  3387.                     DateTime( const Time& rTime ) : Date(), Time( rTime ) {}
  3388.                     DateTime( const Date& rDate, const Time& rTime ) :
  3389.                         Date( rDate ), Time( rTime ) {}
  3390.  
  3391.     BOOL            IsBetween( const DateTime& rFrom,
  3392.                                const DateTime& rTo ) const;
  3393.  
  3394.     friend BOOL     operator ==( const DateTime& rDateTime1,
  3395.                                  const DateTime& rDateTime2 )
  3396.                          { return (((const Date&)rDateTime1) == ((const Date&)rDateTime2)) &&
  3397.                                   (((const Time&)rDateTime1) == ((const Time&)rDateTime2)); }
  3398.     friend BOOL     operator !=( const DateTime& rDateTime1,
  3399.                                  const DateTime& rDateTime2 )
  3400.                          { return (((const Date&)rDateTime1) != ((const Date&)rDateTime2)) ||
  3401.                                   (((const Time&)rDateTime1) != ((const Time&)rDateTime2)); }
  3402.     friend BOOL     operator  >( const DateTime& rDateTime1,
  3403.                                  const DateTime& rDateTime2 );
  3404.     friend BOOL     operator  <( const DateTime& rDateTime1,
  3405.                                  const DateTime& rDateTime2 );
  3406.     friend BOOL     operator >=( const DateTime& rDateTime1,
  3407.                                  const DateTime& rDateTime2 );
  3408.     friend BOOL     operator <=( const DateTime& rDateTime1,
  3409.                                  const DateTime& rDateTime2 );
  3410. };
  3411.  
  3412. #endif 
  3413.  
  3414. #ifndef _INTN_HXX
  3415. #define _INTN_HXX
  3416.  
  3417. #ifndef _TOOLS_H
  3418. #endif
  3419.  
  3420. #ifndef _STRING_HXX
  3421. #endif
  3422.  
  3423. #ifndef _TIME_HXX
  3424. #endif
  3425.  
  3426. #ifndef _DATE_HXX
  3427. #endif
  3428.  
  3429. class ResId;
  3430.  
  3431. enum LanguageType
  3432. {
  3433.     LANGUAGE_DONTKNOW                   = 0x00FF,
  3434.     LANGUAGE_SYSTEM                     = 0x0000,
  3435.     LANGUAGE_ALBANIAN                   = 0x041c,
  3436.     LANGUAGE_ARABIC                     = 0x0401,
  3437.     LANGUAGE_BAHASA                     = 0x0421,
  3438.     LANGUAGE_BULGARIAN                  = 0x0402,
  3439.     LANGUAGE_CATALAN                    = 0x0403,
  3440.     LANGUAGE_CHINESE                    = 0x0004,
  3441.     LANGUAGE_CHINESE_TRADITIONAL        = 0x0404,
  3442.     LANGUAGE_CHINESE_SIMPLIFIED         = 0x0804,
  3443.     LANGUAGE_CZECH                      = 0x0405,
  3444.     LANGUAGE_DANISH                     = 0x0406,
  3445.     LANGUAGE_DUTCH                      = 0x0413,
  3446.     LANGUAGE_DUTCH_BELGIAN              = 0x0813,
  3447.     LANGUAGE_ENGLISH                    = 0x0009,
  3448.     LANGUAGE_ENGLISH_US                 = 0x0409,
  3449.     LANGUAGE_ENGLISH_UK                 = 0x0809,
  3450.     LANGUAGE_ENGLISH_AUS                = 0x0c09,
  3451.     LANGUAGE_ENGLISH_CAN                = 0x1009,
  3452.     LANGUAGE_ENGLISH_NZ                 = 0x1409,
  3453.     LANGUAGE_ENGLISH_EIRE               = 0x1809,
  3454.     LANGUAGE_FINNISH                    = 0x040b,
  3455.     LANGUAGE_FRENCH                     = 0x040c,
  3456.     LANGUAGE_FRENCH_BELGIAN             = 0x080c,
  3457.     LANGUAGE_FRENCH_CANADIAN            = 0x0c0c,
  3458.     LANGUAGE_FRENCH_SWISS               = 0x100c,
  3459.     LANGUAGE_GERMAN                     = 0x0407,
  3460.     LANGUAGE_GERMAN_SWISS               = 0x0807,
  3461.     LANGUAGE_GERMAN_AUSTRIAN            = 0x1007,
  3462.     LANGUAGE_GREEK                      = 0x0408,
  3463.     LANGUAGE_HEBREW                     = 0x040d,
  3464.     LANGUAGE_HUNGARIAN                  = 0x040e,
  3465.     LANGUAGE_ICELANDIC                  = 0x040f,
  3466.     LANGUAGE_ITALIAN                    = 0x0410,
  3467.     LANGUAGE_ITALIAN_SWISS              = 0x0810,
  3468.     LANGUAGE_JAPANESE                   = 0x0411,
  3469.     LANGUAGE_KOREAN                     = 0x0412,
  3470.     LANGUAGE_NORWEGIAN                  = 0x0014,
  3471.     LANGUAGE_NORWEGIAN_BOKMAL           = 0x0414,
  3472.     LANGUAGE_NORWEGIAN_NYNORSK          = 0x0814,
  3473.     LANGUAGE_POLISH                     = 0x0415,
  3474.     LANGUAGE_PORTUGUESE                 = 0x0816,
  3475.     LANGUAGE_PORTUGUESE_BRAZILIAN       = 0x0416,
  3476.     LANGUAGE_RHAETO_ROMAN               = 0x0417,
  3477.     LANGUAGE_ROMANIAN                   = 0x0418,
  3478.     LANGUAGE_RUSSIAN                    = 0x0419,
  3479.     LANGUAGE_SERBO_CROATIAN             = 0x001a,
  3480.     LANGUAGE_SERBO_CROATIAN_CYRILLIC    = 0x081a,
  3481.     LANGUAGE_SERBO_CROATIAN_LATIN       = 0x041a,
  3482.     LANGUAGE_SLOVAK                     = 0x041b,
  3483.     LANGUAGE_SPANISH                    = 0x040a,
  3484.     LANGUAGE_SPANISH_MEXICAN            = 0x080a,
  3485.     LANGUAGE_SPANISH_MODERN             = 0x0c0a,
  3486.     LANGUAGE_SWEDISH                    = 0x041d,
  3487.     LANGUAGE_THAI                       = 0x041e,
  3488.     LANGUAGE_TURKISH                    = 0x041f,
  3489.     LANGUAGE_URDU                       = 0x0420,
  3490.     LANGUAGE_USER1                      = 0x00E1,
  3491.     LANGUAGE_USER2                      = 0x00E2,
  3492.     LANGUAGE_USER3                      = 0x00E3,
  3493.     LANGUAGE_USER4                      = 0x00E4,
  3494.     LANGUAGE_USER5                      = 0x00E5,
  3495.     LANGUAGE_USER6                      = 0x00E6,
  3496.     LANGUAGE_USER7                      = 0x00E7,
  3497.     LANGUAGE_USER8                      = 0x00E8,
  3498.     LANGUAGE_USER9                      = 0x00E9
  3499. };
  3500.  
  3501. enum CountryType
  3502. {
  3503.     COUNTRY_DONTKNOW                    = 0x00FF,
  3504.     COUNTRY_SYSTEM                      = 0x0000,
  3505.     COUNTRY_AUSTRALIA                   = 0x0401,
  3506.     COUNTRY_AUSTRIA                     = 0x0402,
  3507.     COUNTRY_BELGIUM                     = 0x0003,
  3508.     COUNTRY_BELGIUM_DUTCH               = 0x0403,
  3509.     COUNTRY_BELGIUM_FRENCH              = 0x0803,
  3510.     COUNTRY_BRAZIL                      = 0x0404,
  3511.     COUNTRY_CANADA                      = 0x0005,
  3512.     COUNTRY_CANADA_ENGLISH              = 0x0405,
  3513.     COUNTRY_CANADA_FRENCH               = 0x0805,
  3514.     COUNTRY_DENMARK                     = 0x0406,
  3515.     COUNTRY_FINLAND                     = 0x0407,
  3516.     COUNTRY_FRANCE                      = 0x0408,
  3517.     COUNTRY_GERMANY                     = 0x0409,
  3518.     COUNTRY_ICELAND                     = 0x040a,
  3519.     COUNTRY_IRELAND                     = 0x040b,
  3520.     COUNTRY_ITALY                       = 0x040c,
  3521.     COUNTRY_JAPAN                       = 0x040d,
  3522.     COUNTRY_MEXICO                      = 0x040e,
  3523.     COUNTRY_NETHERLANDS                 = 0x040f,
  3524.     COUNTRY_NEWZEALAND                  = 0x0410,
  3525.     COUNTRY_NORWAY                      = 0x0411,
  3526.     COUNTRY_PORTUGAL                    = 0x0412,
  3527.     COUNTRY_SOUTHKOREA                  = 0x0413,
  3528.     COUNTRY_SPAIN                       = 0x0414,
  3529.     COUNTRY_SWEDEN                      = 0x0415,
  3530.     COUNTRY_SWITZERLAND                 = 0x0016,
  3531.     COUNTRY_SWITZERLAND_FRENCH          = 0x0416,
  3532.     COUNTRY_SWITZERLAND_GERMAN          = 0x0816,
  3533.     COUNTRY_SWITZERLAND_ITALIAN         = 0x0c16,
  3534.     COUNTRY_TAIWAN                      = 0x0417,
  3535.     COUNTRY_UNITEDKINGDOM               = 0x0418,
  3536.     COUNTRY_UNITEDSTATES                = 0x0419,
  3537.     COUNTRY_USER1                       = 0x00E1,
  3538.     COUNTRY_USER2                       = 0x00E2,
  3539.     COUNTRY_USER3                       = 0x00E3,
  3540.     COUNTRY_USER4                       = 0x00E4,
  3541.     COUNTRY_USER5                       = 0x00E5,
  3542.     COUNTRY_USER6                       = 0x00E6,
  3543.     COUNTRY_USER7                       = 0x00E7,
  3544.     COUNTRY_USER8                       = 0x00E8,
  3545.     COUNTRY_USER9                       = 0x00E9
  3546. };
  3547.  
  3548. enum DateFormat { MDY, DMY, YMD };
  3549. enum TimeFormat { HOUR_12, HOUR_24 };
  3550. enum DayOfWeekFormat { DAYOFWEEK_NONE, DAYOFWEEK_SHORT, DAYOFWEEK_LONG };
  3551. enum MonthFormat { MONTH_NORMAL, MONTH_ZERO, MONTH_SHORT, MONTH_LONG };
  3552.  
  3553. typedef BOOL (*LanguageTestProc)( const String& rStr, CharSet eCharSet );
  3554. typedef void (*LanguageUpLowProc)( String& rStr, CharSet eCharSet );
  3555. typedef StringCompare (*LanguageCompareProc)( const String& rStr1, const String& rStr2,
  3556.                                               CharSet eCharSet );
  3557.  
  3558. class LanguageTable
  3559. {
  3560. private:
  3561.     USHORT              nRefCount;
  3562.     LanguageType        eLanguage;
  3563.     LanguageUpLowProc   pUpperProc;
  3564.     LanguageUpLowProc   pLowerProc;
  3565.     LanguageTestProc    pIsUpperProc;
  3566.     LanguageTestProc    pIsLowerProc;
  3567.     LanguageTestProc    pIsAlphaProc;
  3568.     LanguageTestProc    pIsNumericProc;
  3569.     LanguageTestProc    pIsAlphaNumericProc;
  3570.     LanguageCompareProc pCompareProc;
  3571.     String              aDayText[7];
  3572.     String              aAbbrevDayText[7];
  3573.     String              aMonthText[12];
  3574.     String              aAbbrevMonthText[12];
  3575.     String              aOKButtonText;
  3576.     String              aCancelButtonText;
  3577.     String              aHelpButtonText;
  3578.  
  3579. public:
  3580.                         LanguageTable();
  3581.                         LanguageTable( const LanguageTable& rTable );
  3582.                         ~LanguageTable();
  3583.  
  3584.     void                SetLanguage( LanguageType _eLanguage )
  3585.                             { LanguageTable::eLanguage = _eLanguage; }
  3586.     LanguageType        GetLanguage() const
  3587.                             { return eLanguage; }
  3588.     void                SetUpperProc( LanguageUpLowProc pProc )
  3589.                             { LanguageTable::pUpperProc = pProc; }
  3590.     LanguageUpLowProc   GetUpperProc() const
  3591.                             { return pUpperProc; }
  3592.     void                SetLowerProc( LanguageUpLowProc pProc )
  3593.                             { LanguageTable::pLowerProc = pProc; }
  3594.     LanguageUpLowProc   GetLowerProc() const
  3595.                             { return pLowerProc; }
  3596.     void                SetIsUpperProc( LanguageTestProc pProc )
  3597.                             { LanguageTable::pIsUpperProc = pProc; }
  3598.     LanguageTestProc    GetIsUpperProc() const
  3599.                             { return pIsUpperProc; }
  3600.     void                SetIsLowerProc( LanguageTestProc pProc )
  3601.                             { LanguageTable::pIsLowerProc = pProc; }
  3602.     LanguageTestProc    GetIsLowerProc() const
  3603.                             { return pIsLowerProc; }
  3604.     void                SetIsAlphaProc( LanguageTestProc pProc )
  3605.                             { LanguageTable::pIsAlphaProc = pProc; }
  3606.     LanguageTestProc    GetIsAlphaProc() const
  3607.                             { return pIsAlphaProc; }
  3608.     void                SetIsNumericProc( LanguageTestProc pProc )
  3609.                             { LanguageTable::pIsNumericProc = pProc; }
  3610.     LanguageTestProc    GetIsNumericProc() const
  3611.                             { return pIsNumericProc; }
  3612.     void                SetIsAlphaNumericProc( LanguageTestProc pProc )
  3613.                             { LanguageTable::pIsAlphaNumericProc = pProc; }
  3614.     LanguageTestProc    GetIsAlphaNumericProc() const
  3615.                             { return pIsAlphaNumericProc; }
  3616.     void                SetCompareProc( LanguageCompareProc pProc )
  3617.                             { LanguageTable::pCompareProc = pProc; }
  3618.     LanguageCompareProc GetCompareProc() const
  3619.                             { return pCompareProc; }
  3620.     void                SetDayText( DayOfWeek eDay, const String& rText )
  3621.                             { aDayText[(USHORT)eDay] = rText; }
  3622.     const String&       GetDayText( DayOfWeek eDay ) const
  3623.                             { return aDayText[(USHORT)eDay]; }
  3624.     void                SetAbbrevDayText( DayOfWeek eDay, const String& rText )
  3625.                             { aAbbrevDayText[(USHORT)eDay] = rText; }
  3626.     const String&       GetAbbrevDayText( DayOfWeek eDay ) const
  3627.                             { return aAbbrevDayText[(USHORT)eDay]; }
  3628.     void                SetMonthText( USHORT nMonth, const String& rText )
  3629.                             { aMonthText[nMonth-1] = rText; }
  3630.     const String&       GetMonthText( USHORT nMonth ) const
  3631.                             { return aMonthText[nMonth-1]; }
  3632.     void                SetAbbrevMonthText( USHORT nMonth, const String& rText )
  3633.                             { aAbbrevMonthText[nMonth-1] = rText; }
  3634.     const String&       GetAbbrevMonthText( USHORT nMonth ) const
  3635.                             { return aAbbrevMonthText[nMonth-1]; }
  3636.     void                SetOKButtonText( const String& rText )
  3637.                             { aOKButtonText = rText; }
  3638.     const String&       GetOKButtonText() const
  3639.                             { return aOKButtonText; }
  3640.     void                SetCancelButtonText( const String& rText )
  3641.                             { aCancelButtonText = rText; }
  3642.     const String&       GetCancelButtonText() const
  3643.                             { return aCancelButtonText; }
  3644.     void                SetHelpButtonText( const String& rText )
  3645.                             { aHelpButtonText = rText; }
  3646.     const String&       GetHelpButtonText() const
  3647.                             { return aHelpButtonText; }
  3648.  
  3649.     LanguageTable&      operator=( const LanguageTable& rTable );
  3650.  
  3651.     BOOL                operator==( const LanguageTable& rTable ) const;
  3652.     BOOL                operator!=( const LanguageTable& rTable ) const;
  3653. };
  3654.  
  3655. class CountryTable
  3656. {
  3657. private:
  3658.     USHORT              nRefCount;
  3659.     CountryType         eCountry;
  3660.     DateFormat          eDateFormat;
  3661.     char                cDateSep;
  3662.     BOOL                bDateDayLeadingZero;
  3663.     BOOL                bDateMonthLeadingZero;
  3664.     BOOL                bDateCentury;
  3665.     DateFormat          eLongDateFormat;
  3666.     DayOfWeekFormat     eLongDateDayOfWeekFormat;
  3667.     String              aLongDateDayOfWeekSep;
  3668.     BOOL                bLongDateDayLeadingZero;
  3669.     String              aLongDateDaySep;
  3670.     MonthFormat         eLongDateMonthFormat;
  3671.     String              aLongDateMonthSep;
  3672.     BOOL                bLongDateCentury;
  3673.     String              aLongDateYearSep;
  3674.     TimeFormat          eTimeFormat;
  3675.     char                cTimeSep;
  3676.     char                cTime100SecSep;
  3677.     BOOL                bTimeLeadingZero;
  3678.     String              aTimeAM;
  3679.     String              aTimePM;
  3680.     char                cNumThousandSep;
  3681.     BOOL                bNumThousandSep;
  3682.     char                cNumDecimalSep;
  3683.     BOOL                bNumLeadingZero;
  3684.     USHORT              nNumDigits;
  3685.     BOOL                bNumTrailingZeros;
  3686.     USHORT              nCurrPositiveFormat;
  3687.     USHORT              nCurrNegativeFormat;
  3688.     String              aCurrSymbol;
  3689.     USHORT              nCurrDigits;
  3690.     char                cCurrZeroChar;
  3691.     char                cListSep;
  3692.  
  3693. public:
  3694.                         CountryTable();
  3695.                         CountryTable( const CountryTable& rTable );
  3696.                         ~CountryTable();
  3697.  
  3698.     void                SetCountry( CountryType _eCountry )
  3699.                             { CountryTable::eCountry = _eCountry; }
  3700.     CountryType         GetCountry() const
  3701.                             { return eCountry; }
  3702.     void                SetDateFormat( DateFormat eFormat )
  3703.                             { CountryTable::eDateFormat = eFormat; }
  3704.     DateFormat          GetDateFormat() const
  3705.                             { return eDateFormat; }
  3706.     void                SetDateSep( char cSep )
  3707.                             { CountryTable::cDateSep = cSep; }
  3708.     char                GetDateSep() const
  3709.                             { return cDateSep; }
  3710.     void                SetDateDayLeadingZero( BOOL bLeading )
  3711.                             { CountryTable::bDateDayLeadingZero = bLeading; }
  3712.     BOOL                IsDateDayLeadingZero() const
  3713.                             { return bDateDayLeadingZero; }
  3714.     void                SetDateMonthLeadingZero( BOOL bLeading )
  3715.                             { CountryTable::bDateMonthLeadingZero = bLeading; }
  3716.     BOOL                IsDateMonthLeadingZero() const
  3717.                             { return bDateMonthLeadingZero; }
  3718.     void                SetDateCentury( BOOL bCentury )
  3719.                             { CountryTable::bDateCentury = bCentury; }
  3720.     BOOL                IsDateCentury() const
  3721.                             { return bDateCentury; }
  3722.     void                SetLongDateFormat( DateFormat eFormat )
  3723.                             { CountryTable::eLongDateFormat = eFormat; }
  3724.     DateFormat          GetLongDateFormat() const
  3725.                             { return eLongDateFormat; }
  3726.     void                SetLongDateDayOfWeekFormat( DayOfWeekFormat eFormat )
  3727.                             { CountryTable::eLongDateDayOfWeekFormat = eFormat; }
  3728.     DayOfWeekFormat     GetLongDateDayOfWeekFormat() const
  3729.                             { return eLongDateDayOfWeekFormat; }
  3730.     void                SetLongDateDayOfWeekSep( const String& rStr )
  3731.                             { CountryTable::aLongDateDayOfWeekSep = rStr; }
  3732.     const String&       GetLongDateDayOfWeekSep() const
  3733.                             { return aLongDateDayOfWeekSep; }
  3734.     void                SetLongDateDayLeadingZero( BOOL bLeading )
  3735.                             { CountryTable::bLongDateDayLeadingZero = bLeading; }
  3736.     BOOL                IsLongDateDayLeadingZero() const
  3737.                             { return bLongDateDayLeadingZero; }
  3738.     void                SetLongDateDaySep( const String& rStr )
  3739.                             { CountryTable::aLongDateDaySep = rStr; }
  3740.     const String&       GetLongDateDaySep() const
  3741.                             { return aLongDateDaySep; }
  3742.     void                SetLongDateMonthFormat( MonthFormat eFormat )
  3743.                             { CountryTable::eLongDateMonthFormat = eFormat; }
  3744.     MonthFormat         GetLongDateMonthFormat() const
  3745.                             { return eLongDateMonthFormat; }
  3746.     void                SetLongDateMonthSep( const String& rStr )
  3747.                             { CountryTable::aLongDateMonthSep = rStr; }
  3748.     const String&       GetLongDateMonthSep() const
  3749.                             { return aLongDateMonthSep; }
  3750.     void                SetLongDateCentury( BOOL bCentury )
  3751.                             { CountryTable::bLongDateCentury = bCentury; }
  3752.     BOOL                IsLongDateCentury() const
  3753.                             { return bLongDateCentury; }
  3754.     void                SetLongDateYearSep( const String& rStr )
  3755.                             { CountryTable::aLongDateYearSep = rStr; }
  3756.     const String&       GetLongDateYearSep() const
  3757.                             { return aLongDateYearSep; }
  3758.     void                SetTimeFormat( TimeFormat eFormat )
  3759.                             { CountryTable::eTimeFormat = eFormat; }
  3760.     TimeFormat          GetTimeFormat() const
  3761.                             { return eTimeFormat; }
  3762.     void                SetTimeSep( char cSep )
  3763.                             { CountryTable::cTimeSep = cSep; }
  3764.     char                GetTimeSep() const
  3765.                             { return cTimeSep; }
  3766.     void                SetTime100SecSep( char cSep )
  3767.                             { CountryTable::cTime100SecSep = cSep; }
  3768.     char                GetTime100SecSep() const
  3769.                             { return cTime100SecSep; }
  3770.     void                SetTimeLeadingZero( BOOL bLeading )
  3771.                             { CountryTable::bTimeLeadingZero = bLeading; }
  3772.     BOOL                IsTimeLeadingZero() const
  3773.                             { return bTimeLeadingZero; }
  3774.     void                SetTimeAM( const String& rStr )
  3775.                             { CountryTable::aTimeAM = rStr; }
  3776.     const String&       GetTimeAM() const
  3777.                             { return aTimeAM; }
  3778.     void                SetTimePM( const String& rStr )
  3779.                             { CountryTable::aTimePM = rStr; }
  3780.     const String&       GetTimePM() const
  3781.                             { return aTimePM; }
  3782.     void                SetNumThousandSep( char cSep )
  3783.                             { CountryTable::cNumThousandSep = cSep; }
  3784.     char                GetNumThousandSep() const
  3785.                             { return cNumThousandSep; }
  3786.     void                EnableNumThousandSep( BOOL bSep = TRUE )
  3787.                             { CountryTable::bNumThousandSep = bSep; }
  3788.     BOOL                IsNumThousandSep() const
  3789.                             { return bNumThousandSep; }
  3790.     void                SetNumDecimalSep( char cSep )
  3791.                             { CountryTable::cNumDecimalSep = cSep; }
  3792.     char                GetNumDecimalSep() const
  3793.                             { return cNumDecimalSep; }
  3794.     void                SetNumLeadingZero( BOOL bLeading )
  3795.                             { CountryTable::bNumLeadingZero = bLeading; }
  3796.     BOOL                IsNumLeadingZero() const
  3797.                             { return bNumLeadingZero; }
  3798.     void                SetNumDigits( USHORT nDigits )
  3799.                             { CountryTable::nNumDigits = nDigits; }
  3800.     USHORT              GetNumDigits() const
  3801.                             { return nNumDigits; }
  3802.     void                SetNumTrailingZeros( BOOL bTrailingZeros = TRUE )
  3803.                             { CountryTable::bNumTrailingZeros = bTrailingZeros; }
  3804.     BOOL                IsNumTrailingZeros() const
  3805.                             { return bNumTrailingZeros; }
  3806.     void                SetCurrPositiveFormat( USHORT nFormat )
  3807.                             { CountryTable::nCurrPositiveFormat = nFormat; }
  3808.     USHORT              GetCurrPositiveFormat() const
  3809.                             { return nCurrPositiveFormat; }
  3810.     void                SetCurrNegativeFormat( USHORT nFormat )
  3811.                             { CountryTable::nCurrNegativeFormat = nFormat; }
  3812.     USHORT              GetCurrNegativeFormat() const
  3813.                             { return nCurrNegativeFormat; }
  3814.     void                SetCurrSymbol( const String& rStr )
  3815.                             { CountryTable::aCurrSymbol = rStr; }
  3816.     const String&       GetCurrSymbol() const
  3817.                             { return aCurrSymbol; }
  3818.     void                SetCurrDigits( USHORT nDigits )
  3819.                             { CountryTable::nCurrDigits = nDigits; }
  3820.     USHORT              GetCurrDigits() const
  3821.                             { return nCurrDigits; }
  3822.     void                SetCurrZeroChar( char cZeroChar )
  3823.                             { CountryTable::cCurrZeroChar = cZeroChar; }
  3824.     char                GetCurrZeroChar() const
  3825.                             { return cCurrZeroChar; }
  3826.     void                SetListSep( char cSep )
  3827.                             { CountryTable::cListSep = cSep; }
  3828.     char                GetListSep() const
  3829.                             { return cListSep; }
  3830.  
  3831.     CountryTable&       operator=( const CountryTable& rTable );
  3832.  
  3833.     BOOL                operator==( const CountryTable& rTable ) const;
  3834.     BOOL                operator!=( const CountryTable& rTable ) const;
  3835. };
  3836.  
  3837. struct InternationalData
  3838. {
  3839.     LanguageTable*  pLanguage;
  3840.     CountryTable*   pCountry;
  3841.     USHORT          nRefCount;
  3842. };
  3843.  
  3844. #define      INTERNATIONAL_SYSTEM_DEFAULT   0xFFFF
  3845. void         UpdateInternationalSystemTables();
  3846. LanguageType GetSystemLanguage( USHORT nIndex = INTERNATIONAL_SYSTEM_DEFAULT );
  3847. CountryType  GetSystemCountry( USHORT nIndex = INTERNATIONAL_SYSTEM_DEFAULT );
  3848.  
  3849. class International
  3850. {
  3851.     void                Init( LanguageType eLanguage, CountryType eCountry );
  3852.  
  3853. private:
  3854.     InternationalData*  pData;
  3855.  
  3856. public:
  3857.                         International();
  3858.                         International( const ResId & rResId );
  3859.                         International( const International& rIntn );
  3860.                         International( CountryType eCountry,
  3861.                                        LanguageType eLanguage );
  3862.                         ~International();
  3863.  
  3864.     LanguageType        GetLanguage() const
  3865.                             { return pData->pLanguage->GetLanguage(); }
  3866.     CountryType         GetCountry() const
  3867.                             { return pData->pCountry->GetCountry(); }
  3868.  
  3869.     String              ChangeDayText( DayOfWeek eDay, const String& rStr );
  3870.     const String&       GetDayText( DayOfWeek eDay ) const
  3871.                             { return pData->pLanguage->GetDayText(eDay); }
  3872.     String              ChangeAbbrevDayText( DayOfWeek eDay, const String& rStr );
  3873.     const String&       GetAbbrevDayText( DayOfWeek eDay ) const
  3874.                             { return pData->pLanguage->GetAbbrevDayText(eDay); }
  3875.     String              ChangeMonthText( USHORT nMonth, const String& rStr );
  3876.     const String&       GetMonthText( USHORT nMonth ) const
  3877.                             { return pData->pLanguage->GetMonthText(nMonth); }
  3878.     String              ChangeAbbrevMonthText( USHORT nMonth, const String& rStr );
  3879.     const String&       GetAbbrevMonthText( USHORT nMonth ) const
  3880.                             { return pData->pLanguage->GetAbbrevMonthText(nMonth); }
  3881.  
  3882.     String              ChangeOKButtonText( const String& rStr );
  3883.     const String&       GetOKButtonText() const
  3884.                             { return pData->pLanguage->GetOKButtonText(); }
  3885.     String              ChangeCancelButtonText( const String& rStr );
  3886.     const String&       GetCancelButtonText() const
  3887.                             { return pData->pLanguage->GetCancelButtonText(); }
  3888.     String              ChangeHelpButtonText( const String& rStr );
  3889.     const String&       GetHelpButtonText() const
  3890.                             { return pData->pLanguage->GetHelpButtonText(); }
  3891.  
  3892.     void                ToUpper( String& rStr,
  3893.                                  CharSet eCharSet = CHARSET_SYSTEM ) const;
  3894.     void                ToLower( String& rStr,
  3895.                                  CharSet eCharSet = CHARSET_SYSTEM ) const;
  3896.  
  3897.     String              Upper( const String& rStr,
  3898.                                CharSet eCharSet = CHARSET_SYSTEM ) const;
  3899.     String              Lower( const String& rStr,
  3900.                                CharSet eCharSet = CHARSET_SYSTEM ) const;
  3901.  
  3902.     BOOL                IsUpper( const String& rStr,
  3903.                                  CharSet eCharSet = CHARSET_SYSTEM ) const;
  3904.     BOOL                IsLower( const String& rStr,
  3905.                                  CharSet eCharSet = CHARSET_SYSTEM ) const;
  3906.     BOOL                IsAlpha( const String& rStr,
  3907.                                  CharSet eCharSet = CHARSET_SYSTEM ) const;
  3908.     BOOL                IsNumeric( const String& rStr,
  3909.                                    CharSet eCharSet = CHARSET_SYSTEM ) const;
  3910.     BOOL                IsAlphaNumeric( const String& rStr,
  3911.                                         CharSet eCharSet = CHARSET_SYSTEM ) const;
  3912.  
  3913.     StringCompare       Compare( const String& rStr1, const String& rStr2,
  3914.                                  CharSet eCharSet = CHARSET_SYSTEM ) const;
  3915.  
  3916.     DateFormat          ChangeDateFormat( DateFormat eFormat );
  3917.     DateFormat          GetDateFormat() const
  3918.                             { return pData->pCountry->GetDateFormat(); }
  3919.     char                ChangeDateSep( char cSep );
  3920.     char                GetDateSep() const
  3921.                             { return pData->pCountry->GetDateSep(); }
  3922.     BOOL                ChangeDateDayLeadingZero( BOOL bLeading );
  3923.     BOOL                IsDateDayLeadingZero() const
  3924.                             { return pData->pCountry->IsDateDayLeadingZero(); }
  3925.     BOOL                ChangeDateMonthLeadingZero( BOOL bLeading );
  3926.     BOOL                IsDateMonthLeadingZero() const
  3927.                             { return pData->pCountry->IsDateMonthLeadingZero(); }
  3928.     BOOL                ChangeDateCentury( BOOL bCentury );
  3929.     BOOL                IsDateCentury() const
  3930.                             { return pData->pCountry->IsDateCentury(); }
  3931.     String              GetDate( const Date& rDate ) const;
  3932.  
  3933.     DateFormat          ChangeLongDateFormat( DateFormat eFormat );
  3934.     DateFormat          GetLongDateFormat() const
  3935.                             { return pData->pCountry->GetLongDateFormat(); }
  3936.     DayOfWeekFormat     ChangeLongDateDayOfWeekFormat( DayOfWeekFormat eFormat );
  3937.     DayOfWeekFormat     GetLongDateDayOfWeekFormat() const
  3938.                             { return pData->pCountry->GetLongDateDayOfWeekFormat(); }
  3939.     String              ChangeLongDateDayOfWeekSep( const String& rStr );
  3940.     const String&       GetLongDateDayOfWeekSep() const
  3941.                             { return pData->pCountry->GetLongDateDayOfWeekSep(); }
  3942.     BOOL                ChangeLongDateDayLeadingZero( BOOL bLeading );
  3943.     BOOL                IsLongDateDayLeadingZero() const
  3944.                             { return pData->pCountry->IsLongDateDayLeadingZero(); }
  3945.     String              ChangeLongDateDaySep( const String& rStr );
  3946.     const String&       GetLongDateDaySep() const
  3947.                             { return pData->pCountry->GetLongDateDaySep(); }
  3948.     MonthFormat         ChangeLongDateMonthFormat( MonthFormat eFormat );
  3949.     MonthFormat         GetLongDateMonthFormat() const
  3950.                             { return pData->pCountry->GetLongDateMonthFormat(); }
  3951.     String              ChangeLongDateMonthSep( const String& rStr );
  3952.     const String&       GetLongDateMonthSep() const
  3953.                             { return pData->pCountry->GetLongDateMonthSep(); }
  3954.     BOOL                ChangeLongDateCentury( BOOL bCentury );
  3955.     BOOL                IsLongDateCentury() const
  3956.                             { return pData->pCountry->IsLongDateCentury(); }
  3957.     String              ChangeLongDateYearSep( const String& rStr );
  3958.     const String&       GetLongDateYearSep() const
  3959.                             { return pData->pCountry->GetLongDateYearSep(); }
  3960.     String              GetLongDate( const Date& rDate ) const;
  3961.  
  3962.     TimeFormat          ChangeTimeFormat( TimeFormat eFormat );
  3963.     TimeFormat          GetTimeFormat() const
  3964.                             { return pData->pCountry->GetTimeFormat(); }
  3965.     char                ChangeTimeSep( char cSep );
  3966.     char                GetTimeSep() const
  3967.                             { return pData->pCountry->GetTimeSep(); }
  3968.     char                ChangeTime100SecSep( char cSep );
  3969.     char                GetTime100SecSep() const
  3970.                             { return pData->pCountry->GetTime100SecSep(); }
  3971.     BOOL                ChangeTimeLeadingZero( BOOL bLeading );
  3972.     BOOL                IsTimeLeadingZero() const
  3973.                             { return pData->pCountry->IsTimeLeadingZero(); }
  3974.     String              ChangeTimeAM( const String& rStr );
  3975.     const String&       GetTimeAM() const
  3976.                             { return pData->pCountry->GetTimeAM(); }
  3977.     String              ChangeTimePM( const String& rStr );
  3978.     const String&       GetTimePM() const
  3979.                             { return pData->pCountry->GetTimePM(); }
  3980.     String              GetDuration( const Time& rTime,
  3981.                                      BOOL bSec = TRUE, BOOL b100Sec = FALSE ) const;
  3982.     String              GetTime( const Time& rTime,
  3983.                                  BOOL bSec = TRUE, BOOL b100Sec = FALSE ) const;
  3984.  
  3985.     char                ChangeNumThousandSep( char cSep );
  3986.     char                GetNumThousandSep() const
  3987.                             { return pData->pCountry->GetNumThousandSep(); }
  3988.     void                EnableNumThousandSep( BOOL bSep = TRUE );
  3989.     BOOL                IsNumThousandSep() const
  3990.                             { return pData->pCountry->IsNumThousandSep(); }
  3991.     char                ChangeNumDecimalSep( char cSep );
  3992.     char                GetNumDecimalSep() const
  3993.                             { return pData->pCountry->GetNumDecimalSep(); }
  3994.     BOOL                ChangeNumLeadingZero( BOOL bLeading );
  3995.     BOOL                IsNumLeadingZero() const
  3996.                             { return pData->pCountry->IsNumLeadingZero(); }
  3997.     USHORT              ChangeNumDigits( USHORT nDigits );
  3998.     USHORT              GetNumDigits() const
  3999.                             { return pData->pCountry->GetNumDigits(); }
  4000.     BOOL                ChangeNumTrailingZeros( BOOL bTrailingZeros = TRUE );
  4001.     BOOL                IsNumTrailingZeros() const
  4002.                             { return pData->pCountry->IsNumTrailingZeros(); }
  4003.     String              GetNum( long nNumber, USHORT nDigits ) const;
  4004.     String              GetNum( long nNumber ) const
  4005.                             { return GetNum( nNumber, GetNumDigits() ); }
  4006.  
  4007.     USHORT              ChangeCurrPositiveFormat( USHORT nFormat );
  4008.     USHORT              GetCurrPositiveFormat() const
  4009.                             { return pData->pCountry->GetCurrPositiveFormat(); }
  4010.     USHORT              ChangeCurrNegativeFormat( USHORT nFormat );
  4011.     USHORT              GetCurrNegativeFormat() const
  4012.                             { return pData->pCountry->GetCurrNegativeFormat(); }
  4013.     String              ChangeCurrSymbol( const String& rSymbol );
  4014.     const String&       GetCurrSymbol() const
  4015.                             { return pData->pCountry->GetCurrSymbol(); }
  4016.     USHORT              ChangeCurrDigits( USHORT nDigits );
  4017.     USHORT              GetCurrDigits() const
  4018.                             { return pData->pCountry->GetCurrDigits(); }
  4019.     char                ChangeCurrZeroChar( char cZeroChar );
  4020.     char                GetCurrZeroChar() const
  4021.                             { return pData->pCountry->GetCurrZeroChar(); }
  4022.     String              GetCurr( long nNumber ) const;
  4023.  
  4024.     char                GetListSep() const
  4025.                             { return pData->pCountry->GetListSep(); }
  4026.  
  4027.     International&      operator=( const International& rIntn );
  4028.  
  4029.     BOOL                operator==( const International& rIntn ) const;
  4030.     BOOL                operator!=( const International& rIntn ) const;
  4031.  
  4032.     static void         RegisterLanguage( const LanguageTable& rTable );
  4033.     static BOOL         IsLanguageAvailable( LanguageType eLanguage );
  4034.     static USHORT       GetAvailableLanguagesCount();
  4035.     static LanguageType GetAvailableLanguage( USHORT nIndex );
  4036.     static void         RegisterCountry( const CountryTable& rTable );
  4037.     static BOOL         IsCountryAvailable( CountryType eCountry );
  4038.     static USHORT       GetAvailableCountriesCount();
  4039.     static CountryType  GetAvailableCountry( USHORT nIndex );
  4040. };
  4041.  
  4042. #endif 
  4043.  
  4044. #ifndef _WLDCRD_HXX
  4045. #define _WLDCRD_HXX
  4046.  
  4047. #ifndef _TOOLS_H
  4048. #endif
  4049.  
  4050. #ifndef _STRING_HXX
  4051. #endif
  4052.  
  4053. class WildCard
  4054. {
  4055. private:
  4056.     String      aWildString;
  4057.     char        cSepSymbol;
  4058.     USHORT      ImpMatch( const char *pWild, const char *pStr ) const;
  4059.  
  4060. public:
  4061.                 WildCard();
  4062.                 WildCard( const String& rWildCards,
  4063.                           const char cSeparator = '\0' );
  4064.  
  4065.     String      operator ()()   { return aWildString; }
  4066.  
  4067.     BOOL        Matches( const String& rStr ) const;
  4068.  
  4069.     BOOL        operator ==( const String& rString ) const
  4070.                     { return Matches( rString ); }
  4071.     BOOL        operator !=( const String& rString ) const
  4072.                     { return !( Matches( rString ) ); }
  4073.  
  4074.     WildCard&   operator =( const String& rString );
  4075.     WildCard&   operator =( const WildCard& rWildCard );
  4076. };
  4077.  
  4078. inline WildCard::WildCard()
  4079. {
  4080.     aWildString = String( '*' );
  4081.     cSepSymbol  = '\0';
  4082. }
  4083.  
  4084. inline WildCard::WildCard( const String& rWildCard, const char cSeparator )
  4085. {
  4086.     aWildString = rWildCard;
  4087.     cSepSymbol  = cSeparator;
  4088. }
  4089.  
  4090. inline WildCard& WildCard::operator=( const String& rString )
  4091. {
  4092.     aWildString = rString;
  4093.     return *this;
  4094. }
  4095.  
  4096. inline WildCard& WildCard::operator=( const WildCard& rWildCard )
  4097. {
  4098.     aWildString = rWildCard.aWildString;
  4099.     cSepSymbol = rWildCard.cSepSymbol;
  4100.     return *this;
  4101. }
  4102.  
  4103. #endif
  4104.  
  4105. #ifndef _FSYS_HXX
  4106. #define _FSYS_HXX
  4107.  
  4108. #ifndef _TOOLS_H
  4109. #endif
  4110.  
  4111. #ifndef _DATE_HXX
  4112. #endif
  4113. #ifndef _TIME_HXX
  4114. #endif
  4115. #ifndef _STRING_HXX
  4116. #endif
  4117. #ifndef _LINK_HXX
  4118. #endif
  4119. #ifndef _WLDCRD_HXX
  4120. #endif
  4121.  
  4122. class DirEntry;
  4123. class DirEntryList;
  4124. class FSysSortList;
  4125. class FileStatList;
  4126.  
  4127. #define FSYS_BUFSIZE 1024
  4128.  
  4129. typedef int DirEntryKind;
  4130. #define FSYS_KIND_UNKNOWN           ((DirEntryKind)     0)
  4131. #define FSYS_KIND_FILE              ((DirEntryKind)     1)
  4132. #define FSYS_KIND_DIR               ((DirEntryKind)     2)
  4133. #define FSYS_KIND_DEV               ((DirEntryKind)     4)
  4134. #define FSYS_KIND_BLOCK             ((DirEntryKind)     8)
  4135. #define FSYS_KIND_CHAR              ((DirEntryKind)    16)
  4136. #define FSYS_KIND_WILD              ((DirEntryKind)    32)
  4137. #define FSYS_KIND_REMOVEABLE        ((DirEntryKind)   128)
  4138. #define FSYS_KIND_FIXED             ((DirEntryKind)   256)
  4139. #define FSYS_KIND_REMOTE            ((DirEntryKind)   512)
  4140. #define FSYS_KIND_RAM               ((DirEntryKind)  1024)
  4141. #define FSYS_KIND_CDROM             ((DirEntryKind)  2048)
  4142. #define FSYS_KIND_ALL               ((DirEntryKind)  4095)
  4143.  
  4144. typedef int FSysSort;
  4145. #define FSYS_SORT_NONE              ((FSysSort)   0)
  4146. #define FSYS_SORT_SIZE              ((FSysSort)   1)
  4147. #define FSYS_SORT_CREATED           ((FSysSort)   2)
  4148. #define FSYS_SORT_MODIFYED          ((FSysSort)   4)
  4149. #define FSYS_SORT_ACCESSED          ((FSysSort)   8)
  4150. #define FSYS_SORT_ASCENDING         ((FSysSort)  16)
  4151. #define FSYS_SORT_DESCENDING        ((FSysSort)  32)
  4152. #define FSYS_SORT_EXT               ((FSysSort)  64)
  4153. #define FSYS_SORT_NAME              ((FSysSort) 128)
  4154. #define FSYS_SORT_KIND              ((FSysSort) 256)
  4155. #define FSYS_SORT_CREATOR           ((FSysSort) 512)
  4156. #define FSYS_SORT_END               ((FSysSort)1024)
  4157.  
  4158. enum DirEntryFlag
  4159. {
  4160.     FSYS_FLAG_NORMAL,
  4161.     FSYS_FLAG_VOLUME,                      
  4162.     FSYS_FLAG_ABSROOT,                     
  4163.     FSYS_FLAG_RELROOT,                     
  4164.     FSYS_FLAG_CURRENT = FSYS_FLAG_RELROOT, 
  4165.     FSYS_FLAG_PARENT,                      
  4166.     FSYS_FLAG_INVALID
  4167. };
  4168.  
  4169. enum FSysError
  4170. {
  4171.     FSYS_ERR_OK,
  4172.     FSYS_ERR_MISPLACEDCHAR,
  4173.     FSYS_ERR_INVALIDCHAR,
  4174.     FSYS_ERR_NOTEXISTS,
  4175.     FSYS_ERR_ALREADYEXISTS,
  4176.     FSYS_ERR_NOTADIRECTORY,
  4177.     FSYS_ERR_NOTAFILE,
  4178.     FSYS_ERR_INVALIDDEVICE,
  4179.     FSYS_ERR_ACCESSDENIED,
  4180.     FSYS_ERR_LOCKVIOLATION,
  4181.     FSYS_ERR_VOLUMEFULL,
  4182.     FSYS_ERR_NOENTRYASSIGNED,
  4183.     FSYS_ERR_ISWILDCARD,
  4184.     FSYS_ERR_NOTSUPPORTED,
  4185.     FSYS_ERR_UNKNOWN
  4186. };
  4187.  
  4188. enum FSysPathStyle
  4189. {
  4190.     FSYS_STYLE_HOST,
  4191.     FSYS_STYLE_FAT,
  4192.     FSYS_STYLE_MSDOS = FSYS_STYLE_FAT,
  4193.     FSYS_STYLE_HPFS,
  4194.     FSYS_STYLE_OS2 = FSYS_STYLE_HPFS,
  4195.     FSYS_STYLE_NTFS,
  4196.     FSYS_STYLE_NWFS,
  4197.     FSYS_STYLE_SYSV,
  4198.     FSYS_STYLE_BSD,
  4199.     FSYS_STYLE_UNX = FSYS_STYLE_BSD,
  4200.     FSYS_STYLE_MAC,
  4201.     FSYS_STYLE_DETECT,
  4202.     FSYS_STYLE_UNKNOWN
  4203. };
  4204.  
  4205. #if defined(WIN) || defined(W30)
  4206.  
  4207. String Gui2FSys( const String& rStr );
  4208. String FSys2Gui( const String& rStr );
  4209. #define GUI2FSYS(s) Gui2FSys( s )
  4210. #define FSYS2GUI(s) FSys2Gui( s )
  4211.  
  4212. #else
  4213.  
  4214. #define GUI2FSYS(s) s
  4215. #define FSYS2GUI(s) s
  4216.  
  4217. #endif
  4218.  
  4219. class FileStat
  4220. {
  4221.     friend class    Dir;
  4222.     friend void     ImpInitFileStat( FileStat&, struct dirent* );
  4223.  
  4224. private:
  4225.     FSysError       nError;
  4226.     DirEntryKind    nKindFlags;
  4227.     ULONG           nSize;
  4228.     FSysPathStyle   eStyle;
  4229.     String          aCreator;
  4230.     String          aType;
  4231.     Date            aDateCreated;
  4232.     Time            aTimeCreated;
  4233.     Date            aDateModified;
  4234.     Time            aTimeModified;
  4235.     Date            aDateAccessed;
  4236.     Time            aTimeAccessed;
  4237.  
  4238. protected:
  4239.  
  4240.                     FileStat( const void *pInfo,      
  4241.                               const void *pVolInfo ); 
  4242. public:
  4243.                     FileStat();
  4244.                     FileStat( const DirEntry& rDirEntry );
  4245.  
  4246.     BOOL            Update( const DirEntry& rDirEntry );
  4247.  
  4248.     FSysError       GetError() const { return nError; }
  4249.     ULONG           GetSize() const { return nSize; }
  4250.  
  4251.     DirEntryKind    GetKind() const { return nKindFlags; }
  4252.     BOOL            IsKind( DirEntryKind nKind ) const;
  4253.     FSysPathStyle   GetStyle() const { return eStyle; }
  4254.  
  4255.     String          GetType() const { return aType; }
  4256.     String          GetCreator() const { return aCreator; }
  4257.  
  4258.     Date            DateCreated() const  { return aDateCreated;  }
  4259.     Time            TimeCreated() const  { return aTimeCreated;  }
  4260.     Date            DateModified() const { return aDateModified; }
  4261.     Time            TimeModified() const { return aTimeModified; }
  4262.     Date            DateAccessed() const { return aDateAccessed; }
  4263.     Time            TimeAccessed() const { return aTimeAccessed; }
  4264.     BOOL            IsYounger( const FileStat& rIsOlder ) const;
  4265. };
  4266.  
  4267. inline BOOL FileStat::IsKind( DirEntryKind nKind ) const
  4268. {
  4269.     BOOL bRet; 
  4270.     if ( nError )
  4271.         bRet = nKind == FSYS_KIND_UNKNOWN;
  4272.     else
  4273.         bRet = ( nKind != FSYS_KIND_UNKNOWN ) &&
  4274.                ( ( nKindFlags & nKind ) == nKind );
  4275.     return bRet;
  4276. }
  4277.  
  4278. class DirEntry
  4279. {
  4280.     friend class Dir;
  4281.     friend class FileStat;
  4282.     friend const char* ImpCheckDirEntry( const void* p );
  4283.  
  4284. private:
  4285.     String              aName;
  4286.     DirEntryFlag        eFlag;
  4287.     DirEntry*           pParent;
  4288.     FSysError           eError;
  4289.  
  4290.                         DirEntry( const String& rInitName,
  4291.                                   DirEntryFlag aDirFlag,
  4292.                                   FSysPathStyle eStyle );
  4293.     FSysError           ImpParseName( const String& rIntiName,
  4294.                                       FSysPathStyle eParser );
  4295.     FSysError           ImpParseOs2Name( const String& rPfad,
  4296.                                          FSysPathStyle eStyle );
  4297.     FSysError           ImpParseUnixName( const String& rPfad,
  4298.                                           FSysPathStyle eStyle );
  4299.     FSysError           ImpParseMacName( const String& rPfad );
  4300.     const DirEntry*     ImpGetTopPtr() const;
  4301.     DirEntry*           ImpGetTopPtr();
  4302.     DirEntry*           ImpGetPreTopPtr();
  4303.     BOOL                ImpToRel( String aStart );
  4304.  
  4305. protected:
  4306.     void                ImpTrim( FSysPathStyle eStyle );
  4307.     const String&       ImpTheName() const;
  4308.     const DirEntryFlag  ImpTheFlag() const { return eFlag; };
  4309.     DirEntry*           ImpChangeParent( DirEntry* pNewParent );
  4310.  
  4311. public:
  4312.                         DirEntry( DirEntryFlag aDirFlag = FSYS_FLAG_CURRENT );
  4313.                         DirEntry( const DirEntry& rEntry );
  4314.                         DirEntry( const String& rInitName,
  4315.                                    FSysPathStyle eParser = FSYS_STYLE_HOST );
  4316.                         ~DirEntry();
  4317.  
  4318.     BOOL                IsValid() const { return eError == FSYS_ERR_OK; }
  4319.  
  4320.     String              ChangeExtension( const String& rExt, char cSep = '.' );
  4321.     String              GetExtension( char cSep = '.' ) const;
  4322.     String              CutExtension( char cSep = '.' );
  4323.     String              ChangeName( const String& rName, FSysPathStyle eFormatter = FSYS_STYLE_HOST );
  4324.     String              GetName( FSysPathStyle eFormatter = FSYS_STYLE_HOST ) const;
  4325.     String              CutName( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
  4326.     String              ChangeBase( const String& rBase, char cSep = '.' );
  4327.     String              GetBase(char cSep = '.' ) const;
  4328.     DirEntry            GetPath() const;
  4329.     DirEntry            GetDevice() const;
  4330.     String              GetVolume() const;
  4331.     String              GetFull( FSysPathStyle eFormatter = FSYS_STYLE_HOST,
  4332.                                  BOOL bWithDelimiter = FALSE,
  4333.                                  USHORT nMaxChars = STRING_MAXLEN ) const;
  4334.     DirEntry            TempName() const;
  4335.  
  4336.     BOOL                IsAbs() const;
  4337.     BOOL                ToAbs();
  4338.     BOOL                Find( const String& rPfad );
  4339.     BOOL                ToRel();
  4340.     BOOL                ToRel( const DirEntry& rRefDir );
  4341.  
  4342.     BOOL                SetCWD( BOOL bSloppy = FALSE );
  4343.     BOOL                MakeDir( BOOL bSloppy = FALSE ) const;
  4344.     BOOL                Exists() const;
  4345.     BOOL                First();
  4346.     USHORT              Level() const;
  4347.     FSysError           CopyTo( const DirEntry& rDestDir,
  4348.                                 BOOL bFile = FALSE ) const;
  4349.     FSysError           MoveTo( const DirEntry& rDestDir ) const;
  4350.     FSysError           Kill() const;
  4351.  
  4352.     DirEntry&           operator =( const DirEntry& rOrigDir );
  4353.     DirEntry            operator +( const DirEntry& rSubDir ) const;
  4354.     DirEntry&           operator +=( const DirEntry& rSubDir );
  4355.     BOOL                operator ==( const DirEntry& rAnotherDir ) const;
  4356.     BOOL                operator !=( const DirEntry& rAnotherDir ) const;
  4357.     const DirEntry&     operator []( USHORT nParentLevel ) const;
  4358.  
  4359.     static String       GetAccessDelimiter( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
  4360.     static String       GetSearchDelimiter( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
  4361.     static BOOL         IsCaseSensitive( FSysPathStyle eFormatter = FSYS_STYLE_HOST );
  4362. };
  4363.  
  4364. class FileCopier
  4365. {
  4366. private:
  4367.     DirEntry aSource;
  4368.     DirEntry aTarget;
  4369.     USHORT     nBlockSize;
  4370.     ULONG     nBytesTotal;
  4371.     ULONG     nBytesCopied;
  4372.     Link     aProgressLink;
  4373.  
  4374. protected:
  4375.     virtual BOOL        Progress();
  4376.  
  4377. public:
  4378.                         FileCopier();
  4379.                         FileCopier( const DirEntry &rSource,
  4380.                                     const DirEntry &rTarget );
  4381.                         FileCopier( const FileCopier &rCopier );
  4382.                         ~FileCopier();
  4383.  
  4384.     FileCopier&         operator = ( const FileCopier &rCopier );
  4385.  
  4386.     USHORT                ChangeBlockSize( USHORT nBytes );
  4387.     USHORT                GetBlockSize() const
  4388.                         { return nBlockSize; }
  4389.  
  4390.     ULONG               GetBytesTotal() const
  4391.                         { return nBytesTotal; }
  4392.     ULONG               GetBytesCopied() const
  4393.                         { return nBytesCopied; }
  4394.  
  4395.     Link                ChangeProgressHdl( const Link &rLink );
  4396.     const Link&         GetProgressHdl() const
  4397.                         { return aProgressLink; }
  4398.  
  4399.     void                SetSource( const DirEntry &rSource )
  4400.                         { aSource = rSource; }
  4401.     void                SetTarget( const DirEntry &rTarget )
  4402.                         { aTarget = rTarget; }
  4403.     const DirEntry&     GetSource() const { return aSource; }
  4404.     const DirEntry&     GetTarget() const { return aTarget; }
  4405.  
  4406.     FSysError            Execute();
  4407. };
  4408.  
  4409. inline Link FileCopier::ChangeProgressHdl( const Link &rLink )
  4410. {
  4411.     Link aOldLink = aProgressLink;
  4412.     aProgressLink = rLink;
  4413.     return aProgressLink;
  4414. }
  4415.  
  4416. inline USHORT FileCopier::ChangeBlockSize( USHORT nBytes )
  4417. {
  4418.     USHORT nOldBlockSize = nBlockSize;
  4419.     nBlockSize = nBytes;
  4420.     return nOldBlockSize;
  4421. }
  4422.  
  4423. class Dir : public DirEntry
  4424. {
  4425.     DirEntryList   *pLst;
  4426.     FSysSortList   *pSortLst;       
  4427.     FileStatList   *pStatLst;       
  4428.     WildCard        aNameMask;
  4429.     USHORT          eAttrMask;
  4430.  
  4431. private:
  4432.     Dir&            operator=( const Dir& ); 
  4433. #ifdef _DIR_CXX
  4434.     FSysError       ImpSetSort( va_list pArgs, FSysSort nSort );
  4435.     void            Construct( DirEntryKind nKind = FSYS_KIND_ALL );
  4436. #endif
  4437.  
  4438. protected:
  4439.     BOOL            ImpInsertPointReached( const DirEntry& rIsSmaller,
  4440.                                            const FileStat& rNewStat,
  4441.                                            ULONG nCurPos,
  4442.                                            ULONG nSortIndex ) const;
  4443.     void            ImpSortedInsert( const DirEntry *pNewEntry,
  4444.                                      const FileStat *pNewStat );
  4445. public:
  4446.                     Dir();
  4447.                     Dir( const DirEntry& rDirEntry,
  4448.                          DirEntryKind nKind = FSYS_KIND_ALL );
  4449.                     Dir( const DirEntry& rDirEntry,
  4450.                          DirEntryKind nKind,
  4451.                          FSysSort nSort, ... );
  4452.                     ~Dir();
  4453.  
  4454.     FSysError       SetSort( FSysSort nSort, ... );
  4455.     BOOL            Update();
  4456.     ULONG           Count() const;
  4457.  
  4458.     Dir&            operator +=( const Dir& rDir );
  4459.     DirEntry&       operator []( USHORT nIndex ) const;
  4460. };
  4461.  
  4462. #endif
  4463.  
  4464. #endif
  4465.