home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / TVINC.ZIP / COLORSEL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  10.9 KB  |  441 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   COLORSEL.H                                                            */
  4. /*                                                                         */
  5. /*   Copyright (c) Borland International 1991                              */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the class TColorDialog, used to set application palettes      */
  9. /*                                                                         */
  10. /* ------------------------------------------------------------------------*/
  11.  
  12. #pragma option -Vo-
  13. #if defined( __BCOPT__ )
  14. #pragma option -po-
  15. #endif
  16.  
  17. #if !defined( __COLOR_COMMAND_CODES )
  18. #define __COLOR_COMMAND_CODES
  19.  
  20. const
  21.   cmColorForegroundChanged = 71,
  22.   cmColorBackgroundChanged = 72,
  23.   cmColorSet               = 73,
  24.   cmNewColorItem           = 74,
  25.   cmNewColorIndex          = 75;
  26.  
  27. #endif  // __COLOR_COMMAND_CODES 
  28.  
  29. class far TColorItem;
  30. class far TColorGroup;
  31.  
  32. TColorItem& operator + ( TColorItem& i1, TColorItem& i2 );
  33. TColorGroup& operator + ( TColorGroup& g, TColorItem& i );
  34. TColorGroup& operator + ( TColorGroup& g1, TColorGroup& g2 );
  35.  
  36. #if defined( Uses_TColorItem ) && !defined( __TColorItem )
  37. #define __TColorItem
  38.  
  39. class far TColorGroup;
  40.  
  41. class TColorItem
  42. {
  43.  
  44. public:
  45.  
  46.     TColorItem( const char *nm, uchar idx, TColorItem *nxt = 0 );
  47.     virtual ~TColorItem();
  48.     const char *name;
  49.     uchar index;
  50.     TColorItem *next;
  51.     friend TColorGroup& operator + ( TColorGroup&, TColorItem& );
  52.     friend TColorItem& operator + ( TColorItem& i1, TColorItem& i2 );
  53.  
  54. };
  55.  
  56. #endif  // Uses_TColorItem
  57.  
  58. #if defined( Uses_TColorGroup ) && !defined( __TColorGroup )
  59. #define __TColorGroup
  60.  
  61. class far TColorItem;
  62.  
  63. class TColorGroup
  64. {
  65.  
  66. public:
  67.  
  68.     TColorGroup( const char *nm, TColorItem *itm = 0, TColorGroup *nxt = 0 );
  69.     virtual ~TColorGroup();
  70.     const char *name;
  71.     TColorItem *items;
  72.     TColorGroup *next;
  73.     friend TColorGroup& operator + ( TColorGroup&, TColorItem& );
  74.     friend TColorGroup& operator + ( TColorGroup& g1, TColorGroup& g2 );
  75.     
  76.  
  77. };
  78.  
  79. #endif  // Uses_TColorGroup
  80.  
  81. #if defined( Uses_TColorSelector ) && !defined( __TColorSelector )
  82. #define __TColorSelector
  83.  
  84. class far TRect;
  85. class far TEvent;
  86.  
  87. class TColorSelector : public TView
  88. {
  89.  
  90. public:
  91.  
  92.     enum ColorSel { csBackground, csForeground };
  93.  
  94.     TColorSelector( const TRect& Bounds, ColorSel ASelType );
  95.     virtual void draw();
  96.     virtual void handleEvent( TEvent& event );
  97.  
  98. protected:
  99.  
  100.     uchar color;
  101.     ColorSel selType;
  102.  
  103. private:
  104.  
  105.     void colorChanged();
  106.  
  107.     static const char near icon;
  108.  
  109.     virtual const char *streamableName() const
  110.         { return name; }
  111.  
  112. protected:
  113.  
  114.     TColorSelector( StreamableInit );
  115.     virtual void write( opstream& );
  116.     virtual void *read( ipstream& );
  117.  
  118. public:
  119.  
  120.     static const char * const near name;
  121.     static TStreamable *build();
  122.  
  123. };
  124.  
  125. inline ipstream& operator >> ( ipstream& is, TColorSelector& cl )
  126.     { return is >> (TStreamable&)cl; }
  127. inline ipstream& operator >> ( ipstream& is, TColorSelector*& cl )
  128.     { return is >> (void *&)cl; }
  129.  
  130. inline opstream& operator << ( opstream& os, TColorSelector& cl )
  131.     { return os << (TStreamable&)cl; }
  132. inline opstream& operator << ( opstream& os, TColorSelector* cl )
  133.     { return os << (TStreamable *)cl; }
  134.  
  135. #endif  // Uses_TColorSelector
  136.  
  137.  
  138. #if defined( Uses_TMonoSelector ) && !defined( __TMonoSelector )
  139. #define __TMonoSelector
  140.  
  141. class far TRect;
  142. class far TEvent;
  143.  
  144. class TMonoSelector : public TCluster
  145. {
  146.  
  147. public:
  148.  
  149.     TMonoSelector( const TRect& bounds );
  150.     virtual void draw();
  151.     virtual void handleEvent( TEvent& event );
  152.     virtual Boolean mark( int item );
  153.     void newColor();
  154.     virtual void press( int item );
  155.     void movedTo( int item );
  156.  
  157. private:
  158.  
  159.     static const char * near button;
  160.     static const char * near normal;
  161.     static const char * near highlight;
  162.     static const char * near underline;
  163.     static const char * near inverse;
  164.  
  165.     virtual const char *streamableName() const
  166.         { return name; }
  167.  
  168. protected:
  169.  
  170.     TMonoSelector( StreamableInit );
  171.  
  172. public:
  173.  
  174.     static const char * const near name;
  175.     static TStreamable *build();
  176.  
  177. };
  178.  
  179. inline ipstream& operator >> ( ipstream& is, TMonoSelector& cl )
  180.     { return is >> (TStreamable&)cl; }
  181. inline ipstream& operator >> ( ipstream& is, TMonoSelector*& cl )
  182.     { return is >> (void *&)cl; }
  183.  
  184. inline opstream& operator << ( opstream& os, TMonoSelector& cl )
  185.     { return os << (TStreamable&)cl; }
  186. inline opstream& operator << ( opstream& os, TMonoSelector* cl )
  187.     { return os << (TStreamable *)cl; }
  188.  
  189. #endif  // Uses_TMonoSelector
  190.  
  191. #if defined( Uses_TColorDisplay ) && !defined( __TColorDisplay )
  192. #define __TColorDisplay
  193.  
  194. class far TRect;
  195. class far TEvent;
  196.  
  197. class TColorDisplay : public TView
  198. {
  199.  
  200. public:
  201.  
  202.     TColorDisplay( const TRect& bounds, const char *aText );
  203.     virtual ~TColorDisplay();
  204.     virtual void draw();
  205.     virtual void handleEvent( TEvent& event );
  206.     virtual void setColor( uchar *aColor );
  207.  
  208. protected:
  209.  
  210.     uchar *color;
  211.     const char *text;
  212.  
  213. private:
  214.  
  215.     virtual const char *streamableName() const
  216.         { return name; }
  217.  
  218. protected:
  219.  
  220.     TColorDisplay( StreamableInit );
  221.     virtual void write( opstream& );
  222.     virtual void *read( ipstream& );
  223.  
  224. public:
  225.  
  226.     static const char * const near name;
  227.     static TStreamable *build();
  228.  
  229. };
  230.  
  231. inline ipstream& operator >> ( ipstream& is, TColorDisplay& cl )
  232.     { return is >> (TStreamable&)cl; }
  233. inline ipstream& operator >> ( ipstream& is, TColorDisplay*& cl )
  234.     { return is >> (void *&)cl; }
  235.  
  236. inline opstream& operator << ( opstream& os, TColorDisplay& cl )
  237.     { return os << (TStreamable&)cl; }
  238. inline opstream& operator << ( opstream& os, TColorDisplay* cl )
  239.     { return os << (TStreamable *)cl; }
  240.  
  241. #endif  // Uses_TColorDisplay
  242.  
  243.  
  244. #if defined( Uses_TColorGroupList ) && !defined( __TColorGroupList )
  245. #define __TColorGroupList
  246.  
  247. class far TRect;
  248. class far TScrollBar;
  249. class far TColorGroup;
  250. class far TColorItem;
  251.  
  252. class TColorGroupList : public TListViewer
  253. {
  254.  
  255. public:
  256.  
  257.     TColorGroupList( const TRect& bounds,
  258.                      TScrollBar *aScrollBar,
  259.                      TColorGroup *aGroups
  260.                    );
  261.     virtual ~TColorGroupList();
  262.     virtual void focusItem( short item );
  263.     virtual void getText( char *dest, short item, short maxLen );
  264.  
  265. protected:
  266.  
  267.     TColorGroup *groups;
  268.  
  269. private:
  270.  
  271.     virtual const char *streamableName() const
  272.         { return name; }
  273.     static void writeItems( opstream&, TColorItem * );
  274.     static void writeGroups( opstream&, TColorGroup * );
  275.     static TColorItem *readItems( ipstream& );
  276.     static TColorGroup *readGroups( ipstream& );
  277.  
  278. protected:
  279.  
  280.     TColorGroupList( StreamableInit );
  281.     virtual void write( opstream& );
  282.     virtual void *read( ipstream& );
  283.  
  284. public:
  285.  
  286.     static const char * const near name;
  287.     static TStreamable *build();
  288.  
  289. };
  290.  
  291. inline ipstream& operator >> ( ipstream& is, TColorGroupList& cl )
  292.     { return is >> (TStreamable&)cl; }
  293. inline ipstream& operator >> ( ipstream& is, TColorGroupList*& cl )
  294.     { return is >> (void *&)cl; }
  295.  
  296. inline opstream& operator << ( opstream& os, TColorGroupList& cl )
  297.     { return os << (TStreamable&)cl; }
  298. inline opstream& operator << ( opstream& os, TColorGroupList* cl )
  299.     { return os << (TStreamable *)cl; }
  300.  
  301. #endif  // Uses_TColorGroupList
  302.  
  303.  
  304. #if defined( Uses_TColorItemList ) && !defined( __TColorItemList )
  305. #define __TColorItemList
  306.  
  307. class far TRect;
  308. class far TScrollBar;
  309. class far TColorItem;
  310. class far TEvent;
  311.  
  312. class TColorItemList : public TListViewer
  313. {
  314.  
  315. public:
  316.  
  317.     TColorItemList( const TRect& bounds,
  318.                     TScrollBar *aScrollBar,
  319.                     TColorItem *aItems
  320.                   );
  321.     virtual void focusItem( short item );
  322.     virtual void getText( char *dest, short item, short maxLen );
  323.     virtual void handleEvent( TEvent& event );
  324.  
  325. protected:
  326.  
  327.     TColorItem *items;
  328.  
  329. private:
  330.  
  331.     virtual const char *streamableName() const
  332.         { return name; }
  333.  
  334. protected:
  335.  
  336.     TColorItemList( StreamableInit );
  337.  
  338. public:
  339.  
  340.     static const char * const near name;
  341.     static TStreamable *build();
  342.  
  343. };
  344.  
  345. inline ipstream& operator >> ( ipstream& is, TColorItemList& cl )
  346.     { return is >> (TStreamable&)cl; }
  347. inline ipstream& operator >> ( ipstream& is, TColorItemList*& cl )
  348.     { return is >> (void *&)cl; }
  349.  
  350. inline opstream& operator << ( opstream& os, TColorItemList& cl )
  351.     { return os << (TStreamable&)cl; }
  352. inline opstream& operator << ( opstream& os, TColorItemList* cl )
  353.     { return os << (TStreamable *)cl; }
  354.  
  355. #endif  // Uses_TColorItemList
  356.  
  357.  
  358. #if defined( Uses_TColorDialog ) && !defined( __TColorDialog )
  359. #define __TColorDialog
  360.  
  361. class far TColorGroup;
  362. class far TEvent;
  363. class far TColorDisplay;
  364. class far TColorGroupList;
  365. class far TLabel;
  366. class far TColorSelector;
  367. class far TMonoSelector;
  368. class far TPalette;
  369.  
  370. class TColorDialog : public TDialog
  371. {
  372.  
  373. public:
  374.  
  375.     TColorDialog( TPalette *aPalette, TColorGroup *aGroups );
  376.     ~TColorDialog();
  377.     virtual ushort dataSize();
  378.     virtual void getData( void *rec );
  379.     virtual void handleEvent( TEvent& event );
  380.     virtual void setData( void *rec);
  381.  
  382.     TPalette *pal;
  383.  
  384. protected:
  385.  
  386.     TColorDisplay *display;
  387.     TColorGroupList *groups;
  388.     TLabel *forLabel;
  389.     TColorSelector *forSel;
  390.     TLabel *bakLabel;
  391.     TColorSelector *bakSel;
  392.     TLabel *monoLabel;
  393.     TMonoSelector *monoSel;
  394.  
  395. private:
  396.  
  397.     static const char * near colors;
  398.     static const char * near groupText;
  399.     static const char * near itemText;
  400.     static const char * near forText;
  401.     static const char * near bakText;
  402.     static const char * near textText;
  403.     static const char * near colorText;
  404.     static const char * near okText;
  405.     static const char * near cancelText;
  406.     
  407.     virtual const char *streamableName() const
  408.         { return name; }
  409.  
  410. protected:
  411.  
  412.     TColorDialog( StreamableInit );
  413.     virtual void write( opstream& );
  414.     virtual void *read( ipstream& );
  415.  
  416. public:
  417.  
  418.     static const char * const near name;
  419.     static TStreamable *build();
  420.  
  421. };
  422.  
  423. inline ipstream& operator >> ( ipstream& is, TColorDialog& cl )
  424.     { return is >> (TStreamable&)cl; }
  425. inline ipstream& operator >> ( ipstream& is, TColorDialog*& cl )
  426.     { return is >> (void *&)cl; }
  427.  
  428. inline opstream& operator << ( opstream& os, TColorDialog& cl )
  429.     { return os << (TStreamable&)cl; }
  430. inline opstream& operator << ( opstream& os, TColorDialog* cl )
  431.     { return os << (TStreamable *)cl; }
  432.  
  433. #endif  // TColorDialog
  434.  
  435. #pragma option -Vo.
  436. #if defined( __BCOPT__ )
  437. #pragma option -po.
  438. #endif
  439.  
  440.  
  441.