home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / TVCOLR.ZIP / COLUPDT.DOC < prev    next >
Text File  |  1994-02-08  |  14KB  |  303 lines

  1. Notice
  2. ======
  3.     The changes described in this file DO require the source code to the
  4. Turbo Vision class library.  All of Borland's copyrights remain in effect
  5. and I make no claim of ownership or copyright to the modifications described
  6. herein.  It's always a good idea to back up the files to be modified in case
  7. you mess something up and, if you do, I'M NOT RESPONSIBLE!
  8.  
  9. Files you should have received in TVCOLR.ZIP:
  10. =============================================
  11.         TVCOLR.DOC      -- Document describing extending TV's palette system.
  12.         COLUPDT.DOC     -- Document describing some TV modifications.
  13.         MAPCOLOR.CPP    -- A replacement TView::mapColor().
  14.                            This can be used whether you have the TV source
  15.                            code or not.
  16.         TVCOLR.H        -- A default TVCOLR.H file to get you started.
  17.         TVCOLR.HDC      -- TVCOLR.H fully commented.
  18.         TCOLTEXT.H      -- TColorText header file.
  19.         TCOLTEXT.CPP    -- TColorText class code.  This class is used
  20.                            throughout the demo and has colors in TVCOLR.H.
  21.         DEMOUMOD.EXE    -- Demo using the unmodified TV library.
  22.         DEMOMOD.EXE     -- Demo using the modifications described in the docs.
  23.         DEMO.H          -- Demo header file.
  24.         DEMO.CPP        -- Demo source code.
  25.         DEMO.PRJ        -- Demo program project file.
  26.         DEMNOSRC.PRJ    -- Similar to DEMO.PRJ, but for those with no source
  27.                            code for Turbo Vision.
  28.         LINK.H          -- Resource file __link() definitions for the demo.
  29.         BLDRSC.CPP      -- Resource file builder.
  30.         BLDRSC.PRJ      -- Resource file builder project file.  The included
  31.                            executables have the .RSC file appended to the EXE.
  32.  
  33.     If your copy is incomplete, you can find a full copy in the BCPPDOS
  34. forum on CompuServe in the Turbo Vision library section.
  35.  
  36. Background Information
  37. ======================
  38.     While adding a TColorDialog to my application, I found out that unlike
  39. the compiler's IDE, Turbo Vision had no entries for changing a default
  40. button's shortcut color, a selected button's shortcut color, or a selected
  41. label's shortcut color.  Thus, the hotkeys for them always seem to stand out
  42. in an aesthetically unsatisfactory way (well, they do to me anyway <g>).
  43. Run DEMOUMOD.EXE and you'll see what I mean.  Also, you can't use black on
  44. black as a color (i.e. for a blank desktop background).  Finally, if you
  45. ever use apMonochrome, TColorDialog has defined TMonoSelector to be one line
  46. too long so that the "Inverse" radio button shows up twice.  I have included
  47. notes on fixing these problems here.  You can see the default action by
  48. running DEMOUMOD.EXE and executing the Colors selection on the Options menu.
  49. Look at the hot keys and, when using the monochrome palette, the color
  50. selector.
  51.     You might ask, "If you're just adding colors to TButton and TLabel, why
  52. not put them into TVCOLR.H, derive new TButton and TLabel classes, and use
  53. them instead?"  I thought of doing that at first, but it won't work well.
  54. It would be fine for any buttons or labels you use in your own dialogs, but
  55. buttons and labels in Turbo Vision's own dialogs (TColorDialog, TFileDialog,
  56. etc) would be unaffected because they would use the normal TButtons and
  57. TLabels with the old palette strings and would still have the same problem.
  58. By directly modifying the underlying source code for those two objects and
  59. rebuilding the library, it takes care of all situations.
  60.     Any line numbers given are for the unmodified Turbo Vision 1.03 source
  61. code right from the installation diskettes.  If you have been following the
  62. Turbo Vision messages and library in the BCPPDOS forum on CompuServe, there
  63. have been some reports on bug fixes.  If you have made them, these line
  64. numbers might not match up exactly.  However, you should be able to look
  65. around the general vicinity and find the line(s) in question.
  66.  
  67. NOTE:  AS A PRECAUTION, ALWAYS KEEP BACKUPS OF THE ORIGINAL FILES LISTED
  68. BELOW INCASE YOU DO HAVE PROBLEMS.
  69.  
  70. Files affected:
  71.     APP.H
  72.     DIALOGS.H
  73.     HELPBASE.H
  74.     COLORSEL.CPP
  75.     DRIVERS.CPP
  76.     MAPCOLOR.CPP
  77.     TBUTTON.CPP
  78.     TDIALOG.CPP
  79.     TLABEL.CPP
  80.     TV.LIB
  81.  
  82. *******************************************************************************
  83.  
  84. To fix TMonoSelector in COLORSEL.CPP
  85.  
  86. Line 649 is:
  87.     monoSel = new TMonoSelector( TRect( 44, 3, 59, 8 ) );
  88.  
  89. Change to:
  90.     monoSel = new TMonoSelector( TRect( 44, 3, 59, 7 ) );
  91.  
  92. *******************************************************************************
  93.  
  94. To allow black on black as a color selection:
  95.  
  96. COLORSEL.CPP:  Lines 341-342 in TColorDisplay::draw() are:
  97.  
  98.     if( c == 0 )
  99.         c = errorAttr;
  100.  
  101. Comment them out or delete both lines.
  102.  
  103. -------------------------------------------------------------------------------
  104. DRIVERS.CPP:  Lines 67-68 and lines 124-125 are both:
  105.  
  106.     OR      AH,AH
  107.     JE      __3
  108.  
  109. Comment them out or delete both sets of lines.
  110.  
  111. -------------------------------------------------------------------------------
  112. MAPCOLOR.CPP:   Lines 25-26 and lines 35-36 are both:
  113.     if( color == 0 )
  114.         return errorAttr;
  115.  
  116. Change both to:
  117.     if( color == 0 )
  118.         return 0;       // Return black on black.
  119.  
  120.     Note that the changes to MAPCOLOR.CPP don't need to be done if you are
  121. going to put the changes described in TVCOLR.DOC into effect.  In which
  122. case, you will be replacing the existing MAPCOLOR.CPP with the one supplied
  123. in TVCOLR.ZIP.
  124.  
  125. *******************************************************************************
  126.  
  127.     I chose to add the two colors for TButton and one color for TLabel
  128. *after* the last normal entry in the base palettes so that it wouldn't muck
  129. up all the other color index assignments currently in effect.  I also didn't
  130. just fill them in by using the spaces marked as RESERVED for obvious
  131. reasons.  I put them *ahead* of the help window colors so that you aren't
  132. forced to add the help colors to your application if you don't want to or
  133. need to.  All of the help color indices are defined in HELPBASE.H so they
  134. were easy to reassign.
  135.  
  136. To add entries for a default button's shortcut color, selected button's
  137. shortcut color, and for a selected label's shortcut color, do the following:
  138.  
  139. *******************************************************************************
  140.  
  141. In TBUTTON.CPP, change line 44 from:
  142.  
  143. #define cpButton "\x0A\x0B\x0C\x0D\x0E\x0E\x0E\x0F"
  144.  
  145. To:
  146.  
  147. #define cpButton "\x0A\x0B\x0C\x0D\x0E\x21\x22\x0F"
  148.  
  149. *******************************************************************************
  150. In TLABEL.CPP, change line 31 from:
  151.  
  152. #define cpLabel "\x07\x08\x09\x09"
  153.  
  154. To:
  155.  
  156. #define cpLabel "\x07\x08\x09\x23"
  157.  
  158. *******************************************************************************
  159. In TDIALOG.CPP, change lines 23-24 from:
  160.  
  161. #define cpDialog "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"\
  162.                  "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"
  163.  
  164. To: (just add '\' to the second line and insert the third line for the palette)
  165.  
  166. #define cpDialog "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"\
  167.                  "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"\
  168.                  "\x40\x41\x42"
  169.  
  170. *******************************************************************************
  171. In DIALOGS.H, optionally add the following lines to the TDialog palette
  172. comments to keep things well documented.  These will end up as lines 68-70:
  173.  
  174. /*       33 = Button shortcut default                                     */
  175. /*       34 = Button shortcut selected                                    */
  176. /*       35 = TLabel shortcut selected                                    */
  177.  
  178. *******************************************************************************
  179.  
  180. In APP.H, change lines 138-154 from:
  181.  
  182. #define cpColor \
  183.     "\x71\x70\x78\x74\x20\x28\x24\x17\x1F\x1A\x31\x31\x1E\x71\x00" \
  184.     "\x37\x3F\x3A\x13\x13\x3E\x21\x00\x70\x7F\x7A\x13\x13\x70\x7F\x00" \
  185.     "\x70\x7F\x7A\x13\x13\x70\x70\x7F\x7E\x20\x2B\x2F\x78\x2E\x70\x30" \
  186.     "\x3F\x3E\x1F\x2F\x1A\x20\x72\x31\x31\x30\x2F\x3E\x31\x13\x00\x00"
  187.  
  188. #define cpBlackWhite \
  189.     "\x70\x70\x78\x7F\x07\x07\x0F\x07\x0F\x07\x70\x70\x07\x70\x00" \
  190.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x7F\x7F\x70\x07\x70\x07\x00" \
  191.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  192.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x00\x00"
  193.  
  194. #define cpMonochrome \
  195.     "\x70\x07\x07\x0F\x70\x70\x70\x07\x0F\x07\x70\x70\x07\x70\x00" \
  196.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07\x00" \
  197.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  198.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x00\x00"
  199.  
  200. To: (just add a '\' to the fourth line and insert a fifth line in each palette)
  201.  
  202. #define cpColor \
  203.     "\x71\x70\x78\x74\x20\x28\x24\x17\x1F\x1A\x31\x31\x1E\x71\x00" \
  204.     "\x37\x3F\x3A\x13\x13\x3E\x21\x00\x70\x7F\x7A\x13\x13\x70\x7F\x00" \
  205.     "\x70\x7F\x7A\x13\x13\x70\x70\x7F\x7E\x20\x2B\x2F\x78\x2E\x70\x30" \
  206.     "\x3F\x3E\x1F\x2F\x1A\x20\x72\x31\x31\x30\x2F\x3E\x31\x13\x00\x00" \
  207.     "\x2E\x2E\x7E"
  208.  
  209. #define cpBlackWhite \
  210.     "\x70\x70\x78\x7F\x07\x07\x0F\x07\x0F\x07\x70\x70\x07\x70\x00" \
  211.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x7F\x7F\x70\x07\x70\x07\x00" \
  212.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  213.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x00\x00" \
  214.     "\x0F\x0F\x7F"
  215.  
  216. #define cpMonochrome \
  217.     "\x70\x07\x07\x0F\x70\x70\x70\x07\x0F\x07\x70\x70\x07\x70\x00" \
  218.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07\x00" \
  219.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  220.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x00\x00" \
  221.     "\x0F\x0F\x0F"
  222.  
  223. Then, at line 137 insert the following definition:
  224.  
  225. #define MODIFIED_TV_COLORS
  226.  
  227.     TVCOLR.H uses this #define to see if it should add the extra three
  228. colors to the custom cpAltColor palette and also to the cpDefXXX palettes.
  229. You can also use it as I did in BLDRSC.CPP to skip colors for the
  230. TColorDialog when they aren't defined.  This is a better method than the
  231. UNMODIFIED_TURBO_VISION definition I used for a prior release of these
  232. files.  The TVCOLR.H in this release will maintain the proper index values
  233. regardless of whether these three colors have been added or not.
  234.  
  235. *******************************************************************************
  236. In HELPBASE.H, change line 19 from:
  237.  
  238. #define cHelpWindow     "\x40\x41\x42\x43\x44\x45\x46\x47"
  239.  
  240. To:
  241.  
  242. #define cHelpWindow     "\x43\x44\x45\x46\x47\x48\x49\x4A"
  243.  
  244. *******************************************************************************
  245.  
  246. For reference, you can add the following text to the TProgram palette
  247. description in the manual (pages 342-343).
  248.  
  249.                         64   65   66   67   68   69   70   71   72   73   74
  250.                       ╔════╤════╤════╤════╤════╤════╤════╤════╤════╤════╤════╗
  251.         cpColor       ║x2E │x2E │x7E │x37 │x3F │x3A │x13 │x13 │x30 │x3E │x1E ║
  252.                       ╠════╧════╧════╧════╧════╧════╧════╧════╧════╧════╧════╣
  253.                       ╠════╤════╤════╤════╤════╤════╤════╤════╤════╤════╤════╣
  254.         cpBlackWhite  ║x0F │x0F │x7F │x07 │x0F │x07 │x70 │x70 │x07 │x0F │x70 ║
  255.                       ╠════╧════╧════╧════╧════╧════╧════╧════╧════╧════╧════╣
  256.                       ╠════╤════╤════╤════╤════╤════╤════╤════╤════╤════╤════╣
  257.         cpMonochrome  ║x0F │x0F │x0F │x07 │x0F │x07 │x70 │x70 │x07 │x0F │x70 ║
  258.                       ╚════╧════╧════╧════╧════╧════╧════╧════╧════╧════╧════╝
  259.                         │    │    │    │    │    │    │    │    │    │    │
  260. Button shortcut default─┘    │    │    │    │    │    │    │    │    │    │
  261. Button shortcut selected─────┘    │    │    │    │    │    │    │    │    │
  262.                                   │    │    │    │    │    │    │    │    │
  263. TLabel shortcut selected──────────┘    │    │    │    │    │    │    │    │
  264.                                        │    │    │    │    │    │    │    │
  265. Help frame passive─────────────────────┘    │    │    │    │    │    │    │
  266. Help frame active───────────────────────────┘    │    │    │    │    │    │
  267. Help frame icons─────────────────────────────────┘    │    │    │    │    │
  268. Scrollbar page────────────────────────────────────────┘    │    │    │    │
  269. Scrollbar icons────────────────────────────────────────────┘    │    │    │
  270. Normal text─────────────────────────────────────────────────────┘    │    │
  271. Keyword──────────────────────────────────────────────────────────────┘    │
  272. Selected keyword──────────────────────────────────────────────────────────┘
  273.  
  274. *******************************************************************************
  275.  
  276. Implementation
  277. ==============
  278.     That's all there is to it.  Once you've made the modifications, change
  279. directories to \BC\TVISION\SOURCE (substitute your path as necessary) and
  280. issue the command:  make -fmakefile
  281.  
  282.     I think it's best to rebuild the library because by doing the MAKE,
  283. you can insure that everything that needs updating gets recompiled.  I've
  284. included a demo program that illustrates the differences between the
  285. unmodified version and modified version of the code.  Look there for
  286. additional comments and notes.
  287.     I have seen some other Turbo Vision examples and files on CompuServe
  288. that define their own custom application palette for their included demo
  289. program like I do.  If compiled with these changes, the hotkeys for the
  290. buttons and labels will be undefined unless you add the three extra bytes to
  291. their custom palette or enclose them in an #ifdef block like TVCOLR.H does.
  292.  
  293. *******************************************************************************
  294.  
  295.     Well, I hope you find this useful.  I'd appreciate any feedback,
  296. comments, suggestions, questions, etc that you may have on the changes I
  297. implemented.  I can be reached on CompuServe E-Mail at 72134,1150 or by
  298. posting a message in Section 11 (Turbo Vision) of the BCPPDOS forum.
  299. Thanks.
  300.  
  301. Eric Woodruff,  CIS ID: 72134,1150
  302. Tue 02/08/94 10:42:28
  303.