home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / TVCOLR.ZIP / TVCOLR.HDC < prev   
Text File  |  1994-02-08  |  10KB  |  230 lines

  1. // File    : TVCOLR.HDC
  2. // Author  : Eric Woodruff,  CIS ID: 72134,1150
  3. // Updated : Tue 02/08/94 20:54:26
  4. // Note    : Hereby declared public domain
  5. // Compiler: Borland C++ 3.1/4.0
  6. //
  7. // Easy extensions to the colors for Turbo Vision applications.
  8. // Complete documentation for this method can be found by downloading
  9. // TVCOLR.ZIP from the BCPPDOS forum of CompuServe.
  10. //
  11. // This copy contains complete comments on how to add extended colors.
  12. // See TVCOLR.H for an uncluttered view of how it works.
  13. //
  14. // NOTE: If you modify this file, modify TVCOLR.H accordingly!!
  15. //
  16.  
  17. #if !defined( __TVCOLR_H )
  18. #define __TVCOLR_H
  19.  
  20. #if !defined(cpColor)
  21. #define  Uses_TProgram
  22. #include <tv.h>             // Get the standard colors defined.
  23. #endif
  24.  
  25. #if !defined(cHelpColor)
  26. class far fpstream;
  27. #include <helpbase.h>       // Get the help colors defined.
  28. #endif
  29.  
  30. // An alternate color palette attributes map.
  31. // I have added two colors to TButton and one color to TLabel for when those
  32. // objects are selected that the default Turbo Vision doesn't have.  If the
  33. // definition MODIFIED_TV_COLORS appears in APP.H, then those three extra
  34. // colors will be defined here.
  35.  
  36. #if defined(MODIFIED_TV_COLORS)
  37.  
  38. #define cpAltColor \
  39.     "\x07\x70\x76\x74\x17\x08\x1B\x07\x03\x0B\x70\x70\x07\x70" \
  40.     "\x00\x37\x3F\x3A\x13\x13\x3F\x1F\x00\x70\x7F\x7A\x13\x13" \
  41.     "\x70\x7F\x00\x70\x7F\x7A\x13\x13\x70\x70\x6F\x7E\x1B\x1F" \
  42.     "\x6F\x10\x1E\x70\x30\x3F\x3E\x1B\x4F\x1A\x20\x70\x07\x70" \
  43.     "\x30\x1B\x3E\x31\x13\x00\x00\x1D\x6E\x6E"
  44.  
  45. #else
  46.  
  47. #define cpAltColor \
  48.     "\x07\x70\x76\x74\x17\x08\x1B\x07\x03\x0B\x70\x70\x07\x70" \
  49.     "\x00\x37\x3F\x3A\x13\x13\x3F\x1F\x00\x70\x7F\x7A\x13\x13" \
  50.     "\x70\x7F\x00\x70\x7F\x7A\x13\x13\x70\x70\x6F\x7E\x1B\x1F" \
  51.     "\x6F\x10\x1E\x70\x30\x3F\x3E\x1B\x4F\x1A\x20\x70\x07\x70" \
  52.     "\x30\x1B\x3E\x31\x13\x00\x00"
  53.  
  54. #endif
  55.  
  56. // An Alternate Color help window attribute map.
  57. #define cAltHelpColor "\x67\x6F\x6E\x76\x76\x6F\x6E\x1E"
  58.  
  59. // Define any other palette names and the total number of available palettes.
  60. // For additional palettes, start numbering them at 3.  They must come
  61. // after the regular color, black and white, and monochrome sets because
  62. // apColor, apBlackWhite, and apMonochrome are defined as 0 through 2.
  63. #define apAltColor         3        // Alternate color palette.
  64.  
  65. #define apTotalPalettes    4        // Color, B&W, Monochrome, Alt. Color.
  66.  
  67. // Define the default extended color sets (regular colors + help colors).
  68. //
  69. // If the default TV colors have not been modified as described in
  70. // COLUPDT.DOC, some padding is added so that the indices below come out
  71. // the same regardless of this optional change.
  72. //
  73. #if defined(MODIFIED_TV_COLORS)
  74.  
  75. #define cpDefAltColor       cpAltColor cAltHelpColor
  76. #define cpDefColor          cpColor cHelpColor
  77. #define cpDefBlackWhite     cpBlackWhite cHelpBlackWhite
  78. #define cpDefMonochrome     cpMonochrome cHelpMonochrome
  79.  
  80. #else
  81.  
  82. #define cpDefAltColor       cpAltColor cAltHelpColor "\x07\x07\x07"
  83. #define cpDefColor          cpColor cHelpColor "\x07\x07\x07"
  84. #define cpDefBlackWhite     cpBlackWhite cHelpBlackWhite "\x07\x07\x07"
  85. #define cpDefMonochrome     cpMonochrome cHelpMonochrome "\x07\x07\x07"
  86.  
  87. #endif
  88.  
  89. // Define the default size.  Doesn't matter which one we use because they are
  90. // all the same size.
  91. //
  92. // Any color index higher than this will be read directly from the
  93. // main application palette instead of walking up the owning view chain.
  94. // Indices less than or equal to this will follow the normal color mapping
  95. // routine.
  96. #define cpDefSize           sizeof(cpDefColor) - 1  // Less 1 for the NULL!
  97.  
  98. // ****************************************************************************
  99. // ^^^^^^     NOTHING ABOVE THIS POINT WILL EVER CHANGE AND MUST NOT!    ^^^^^^
  100. //                     (Unless you add more color palettes)
  101. // ****************************************************************************
  102. //
  103. // Now define the colors and color indices for each new class you need to
  104. // add. Follow the same group of steps for each definition.
  105. //
  106. // 1. Define the additional color attributes for each palette.
  107. //    These are the true attributes such as white on blue, light gray
  108. //    on black etc.
  109. //
  110. // TColorText additional color attributes.
  111. //
  112. #define cpColorTextAltColor   "\x1B\x1F\x4F\x4E"    // Alt color palette
  113. #define cpColorTextColor      "\x1B\x1F\x4F\x4E"    // Color palette
  114. #define cpColorTextBlackWhite "\x70\x7F\x07\x0F"    // B&W palette
  115. #define cpColorTextMonochrome "\x70\x01\x0F\x0F"    // Monochrome palette
  116.  
  117. //
  118. // 2. Define the indices into the extended application palettes.
  119. //
  120. // For additional classes' colors, add a #define for the index into the main
  121. // application palettes by taking the last defined offset from the class
  122. // prior to the one being defined and add an offset.
  123. //
  124. // For classes after this one, the #defines might look something like:
  125. // #define  cNewObjectXC1  cCTxtErrorColor + 1      // Prior last index was
  126. // #define  cNewObjectXC2  cCTxtErrorColor + 2      // cCTxtErrorColor
  127. // .
  128. // .
  129. // .
  130. // #define  cNewObjectYC1  cNewObjectXC2 + 1        // Prior last index was
  131. // #define  cNewObjectYC2  cNewObjectXC2 + 2        // cNewObjectXC2
  132. // etc.
  133. //
  134. #define cCTxtInfoColor      cpDefSize + 1       // Information color
  135. #define cCTxtNotifyColor    cpDefSize + 2       // Notification color
  136. #define cCTxtWarnColor      cpDefSize + 3       // Warning color
  137. #define cCTxtErrorColor     cpDefSize + 4       // Error color
  138.  
  139. //
  140. // These values are used to build the palette for the object in it's
  141. // getPalette() member function (defined in the object's source code file).
  142. // For colors that will match the owning view's color for that particular
  143. // item (i.e. normal text), just use an index such as '\x06' to access the
  144. // n'th element of the owners palette just like you normally would.
  145. //
  146. // Thus the TColorText palette is as follows:
  147. //      1 = Normal Text       (from owner's 6th palette entry)
  148. //      2 = Information Text  (custom added color)
  149. //      3 = Notification Text (custom added color)
  150. //      4 = Warning Text      (custom added color)
  151. //      5 = Error Text        (custom added color)
  152. //
  153. // The getPalette() functions will all look similar to this one:
  154. //
  155. // // Create a character array where each element is a color index.
  156. // // This forms the palette for the object.
  157. // char cpColorText[] = { '\x06', cCTxtInfoColor, cCTxtNotifyColor,
  158. //                                cCTxtWarnColor, cCTxtErrorColor };
  159. //
  160. // TPalette& TColorText::getPalette() const
  161. // {
  162. //     // Note the lack of a "- 1" after the sizeof().  There is no NULL on
  163. //     // this type of palette because it is a simple array, not a string.
  164. //     // Don't account for one!
  165. //     static TPalette palette( cpColorText, sizeof( cpColorText) );
  166. //     return palette;
  167. // }
  168.  
  169. // ****************************************************************************
  170. // vvvvvv       Additional extended color definitions will go here       vvvvvv
  171. // ****************************************************************************
  172. // Follow the above two steps for each new class.
  173. //
  174. // Step 1
  175. //
  176. // TMsgViewWindow and TMsgListViewer
  177. #define cpMsgDlgAltColor   "\x48\x4E\x4F\x74\x74\x4F\x6E\x4E"
  178. #define cpMsgDlgColor      "\x48\x4E\x4F\x74\x74\x4F\x6E\x4E"
  179. #define cpMsgDlgBlackWhite "\x78\x7F\x7F\x70\x70\x70\x07\x7F"
  180. #define cpMsgDlgMonochrome "\x70\x70\x0F\x0F\x0F\x70\x0F\x01"
  181.  
  182. // Step 2
  183. //
  184. #define cMsgFramePassive    cCTxtErrorColor + 1   // Frame passive
  185. #define cMsgFrameActive     cCTxtErrorColor + 2   // Frame active
  186. #define cMsgFrameIcon       cCTxtErrorColor + 3   // Frame icons
  187. #define cMsgSBPage          cCTxtErrorColor + 4   // Scrollbar page
  188. #define cMsgSBCtrl          cCTxtErrorColor + 5   // Scrollbar controls
  189. #define cMsgNText           cCTxtErrorColor + 6   // Normal text
  190. #define cMsgSText           cCTxtErrorColor + 7   // Selected/Focused text
  191. #define cMsgSelected        cCTxtErrorColor + 8   // Selected (inactive) text
  192.  
  193. // Step 1
  194. // TVMIndicator
  195. #define cpIndAltColor      "\x60\x7F"
  196. #define cpIndColor         "\x30\x7F"
  197. #define cpIndBlackWhite    "\x70\x70"
  198. #define cpIndMonochrome    "\x70\x70"
  199.  
  200. // Step 2
  201. #define cIndEditWin        cMsgSelected + 1       // For Edit Windows
  202. #define cIndMemoFld        cMsgSelected + 2       // For Memo Fields
  203.  
  204. // ****************************************************************************
  205. // ^^^^^^       ALWAYS ADD ANY NEW DEFINITIONS JUST ABOVE THIS LINE      ^^^^^^
  206. // ****************************************************************************
  207. //
  208. // 3. Define the full extended color sets.
  209. // Add any new class's colors to the *ends* of the #defines.  Just be sure to
  210. // do it in the order you defined them above or the indices won't match up.
  211. // By adding new classes to the ends of the #defines, you won't have to
  212. // recompile any existing class code because their offsets won't change.  You
  213. // are simply extending the current definition.  The only one you compile is
  214. // the new addition.
  215. // ****************************************************************************
  216.  
  217. #define cpExtAltColor       cpDefAltColor cpColorTextAltColor \
  218.                             cpMsgDlgAltColor cpIndAltColor
  219.  
  220. #define cpExtColor          cpDefColor cpColorTextColor cpMsgDlgColor \
  221.                             cpIndColor
  222.  
  223. #define cpExtBlackWhite     cpDefBlackWhite cpColorTextBlackWhite \
  224.                             cpMsgDlgBlackWhite cpIndBlackWhite
  225.  
  226. #define cpExtMonochrome     cpDefMonochrome cpColorTextMonochrome \
  227.                             cpMsgDlgMonochrome cpIndMonochrome
  228.  
  229. #endif // __TVCOLR_H
  230.