home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / src / tvtext.cpp < prev    next >
C/C++ Source or Header  |  1999-05-26  |  8KB  |  245 lines

  1. /*
  2.  * tvtext.cc
  3.  *
  4.  * Turbo Vision - Version 2.0
  5.  *
  6.  * Copyright (c) 1994 by Borland International
  7.  * All Rights Reserved.
  8.  *
  9.  * Modified by Sergio Sigala <ssigala@globalnet.it>
  10.  */
  11.  
  12. #define Uses_TKeys
  13. #define Uses_TScreen
  14. #define Uses_TRadioButtons
  15. #define Uses_TMenuBox
  16. #define Uses_TFrame
  17. #define Uses_TIndicator
  18. #define Uses_THistory
  19. #define Uses_TColorSelector
  20. #define Uses_TMonoSelector
  21. #define Uses_TColorDialog
  22. #define Uses_TInputLine
  23. #define Uses_TStatusLine
  24. #define Uses_TCheckBoxes
  25. #define Uses_TScrollBar
  26. #define Uses_TButton
  27. #define Uses_TDirListBox
  28. #define Uses_TFileEditor
  29. #define Uses_TEditWindow
  30. #define Uses_TFileList
  31. #define Uses_TProgram
  32. #define Uses_MsgBox
  33. #define Uses_TChDirDialog
  34. #define Uses_TFileDialog
  35. #define Uses_TFileInfoPane
  36. #define Uses_TDeskTop
  37. #define Uses_TPXPictureValidator
  38. #define Uses_TFilterValidator
  39. #define Uses_TRangeValidator
  40. #define Uses_TStringLookupValidator
  41. #define Uses_TListViewer
  42. #define Uses_TOutlineViewer
  43. #include <tvision/tv.h>
  44. #include <tvision/help.h>
  45.  
  46. #include <ctype.h>
  47.  
  48. const uchar specialChars[] =
  49. {
  50.     175, 174, 26, 27, ' ', ' '
  51. };
  52.  
  53. static const char altCodes1[] =
  54.     "QWERTYUIOP\0\0\0\0ASDFGHJKL\0\0\0\0\0ZXCVBNM";
  55. static const char altCodes2[] = "1234567890-=";
  56.  
  57. char getAltChar(ushort keyCode)
  58. {
  59.     if ((keyCode & 0xff) == 0)
  60.         {
  61.         ushort tmp = (keyCode >> 8);
  62.  
  63.         if( tmp == 2 )
  64.             return '\xF0';      // special case to handle alt-Space
  65.  
  66.         else if( tmp >= 0x10 && tmp <= 0x32 )
  67.             return altCodes1[tmp-0x10];     // alt-letter
  68.  
  69.         else if( tmp >= 0x78 && tmp <= 0x83 )
  70.             return altCodes2[tmp - 0x78];   // alt-number
  71.  
  72.         }
  73.     return 0;
  74. }
  75.  
  76. ushort getAltCode(char c)
  77. {
  78.     if( c == 0 )
  79.         return 0;
  80.  
  81.     if( hab == NULLHANDLE )
  82.         c = toupper(c);
  83.      else
  84.           c = WinUpperChar( hab, Codepage, Country, c );
  85.  
  86.     /* SS: this makes g++ happy */
  87.  
  88. //    if( (unsigned char) c == '\xF0' )
  89.     if( (unsigned char) c == (unsigned char) '\xF0' )
  90.         return 0x200;       // special case to handle alt-Space
  91.  
  92. //    for( int i = 0; i < sizeof( altCodes1 ); i++)
  93.     int i;
  94. //    for( i = 0; i < sizeof( altCodes1 ); i++) /* XXX */
  95.     for( i = 0; i < (int)sizeof( altCodes1 ); i++) /* XXX */
  96.        if( altCodes1[i] == c )
  97.         return (i+0x10) << 8;
  98.  
  99. //    for( i = 0; i < sizeof( altCodes2); i++) /* XXX */
  100.     for( i = 0; i < (int)sizeof( altCodes2); i++) /* XXX */
  101.         if (altCodes2[i] == c)
  102.             return (i+0x78) << 8;
  103.  
  104.     return 0;
  105. }
  106.  
  107. inline uchar lo(ushort w) { return w & 0xff; }
  108. inline uchar hi(ushort w) { return w >> 8; }
  109.  
  110. char getCtrlChar(ushort keyCode)
  111. {
  112.     if ( (lo(keyCode)!= 0) && (lo(keyCode) <= ('Z'-'A'+1)))
  113.         return lo(keyCode) + 'A' - 1;
  114.     else
  115.         return 0;
  116. }
  117.  
  118. ushort getCtrlCode(uchar ch)
  119. {
  120.     return getAltCode(ch)|(((('a'<=ch)&&(ch<='z'))?(ch&~0x20):ch)-'A'+1);
  121. }
  122.  
  123. const char * TRadioButtons::button = " ( ) ";
  124.  
  125. const char * TMenuBox::frameChars = " \332\304\277  \300\304\331  \263 \263  \303\304\264 ";
  126.  
  127. const char TFrame::initFrame[19] =
  128.   "\x06\x0A\x0C\x05\x00\x05\x03\x0A\x09\x16\x1A\x1C\x15\x00\x15\x13\x1A\x19";
  129.  
  130. char TFrame::frameChars[33] =
  131.     "   └ │┌├ ┘─┴┐┤┬┼   ╚ ║╔╟ ╝═╧╗╢╤ "; // for UnitedStates code page
  132.  
  133. const char * TFrame::closeIcon = "[~\xFE~]";
  134. const char * TFrame::zoomIcon = "[~\x18~]";
  135. const char * TFrame::unZoomIcon = "[~\x12~]";
  136. const char * TFrame::dragIcon = "~─┘~";
  137.  
  138. /*const*/ char TIndicator::dragFrame = '\xCD';
  139. /*const*/ char TIndicator::normalFrame = '\xC4';
  140.  
  141. const char * THistory::icon = "\xDE~\x19~\xDD";
  142.  
  143. /*const*/ char TColorSelector::icon = '\xDB';
  144.  
  145. const char * TMonoSelector::button = " ( ) ";
  146. const char * TMonoSelector::normal = "Normal";
  147. const char * TMonoSelector::highlight = "Highlight";
  148. const char * TMonoSelector::underline = "Underline";
  149. const char * TMonoSelector::inverse = "Inverse";
  150.  
  151. const char * TColorDialog::colors = "Colors";
  152. const char * TColorDialog::groupText = "~G~roup";
  153. const char * TColorDialog::itemText = "~I~tem";
  154. const char * TColorDialog::forText = "~F~oreground";
  155. const char * TColorDialog::bakText = "~B~ackground";
  156. const char * TColorDialog::textText = "Text ";
  157. const char * TColorDialog::colorText = "Color";
  158. const char * TColorDialog::okText = "O~K~";
  159. const char * TColorDialog::cancelText = "Cancel";
  160.  
  161. const char TInputLine::rightArrow = '\x10';
  162. const char TInputLine::leftArrow = '\x11';
  163.  
  164. const char * TStatusLine::hintSeparator = "\xB3 ";
  165.  
  166. const char * TCheckBoxes::button = " [ ] ";
  167.  
  168. TScrollChars TScrollBar::vChars = {30, 31, 177, 254, 178};
  169. TScrollChars TScrollBar::hChars = {17, 16, 177, 254, 178};
  170.  
  171. const char * TButton::shadows = "\xDC\xDB\xDF";
  172. const char * TButton::markers = "[]";
  173.  
  174. const char * TDirListBox::pathDir   = "└─┬";
  175. const char * TDirListBox::firstDir  =   "└┬─";
  176. const char * TDirListBox::middleDir =   " ├─";
  177. const char * TDirListBox::lastDir   =   " └─";
  178. const char * TDirListBox::drives = "Drives";
  179. const char * TDirListBox::graphics = "└├─";
  180.  
  181. const char * TFileEditor::backupExt = ".BAK";
  182.  
  183. const char * TPXPictureValidator::errorMsg = "Error in picture format.\n %s";
  184. const char * TFilterValidator::errorMsg = "Invalid character in input";
  185. const char * TRangeValidator::errorMsg = "Value not in the range %ld to %ld";
  186. const char * TStringLookupValidator::errorMsg = "Input is not in list of valid strings";
  187.  
  188. const char * TRangeValidator::validUnsignedChars = "+0123456789";
  189. const char * TRangeValidator::validSignedChars = "+-0123456789";
  190.  
  191. const char * TListViewer::emptyText = "<empty>";
  192.  
  193. const char * THelpWindow::helpWinTitle = "Help";
  194. const char * THelpFile::invalidContext =
  195.     "\n No help available in this context.";
  196.  
  197. const char * TEditWindow::clipboardTitle = "Clipboard";
  198. const char * TEditWindow::untitled = "Untitled";
  199.  
  200. const char * TFileList::tooManyFiles = "Too many files.";
  201.  
  202. const char * TProgram::exitText = "~Alt-X~ Exit";
  203.  
  204. const char * MsgBoxText::yesText = "~Y~es";
  205. const char * MsgBoxText::noText = "~N~o";
  206. const char * MsgBoxText::okText = "O~K~";
  207. const char * MsgBoxText::cancelText = "Cancel";
  208. const char * MsgBoxText::warningText = "Warning";
  209. const char * MsgBoxText::errorText = "Error";
  210. const char * MsgBoxText::informationText = "Information";
  211. const char * MsgBoxText::confirmText = "Confirm";
  212.  
  213. const char * TChDirDialog::changeDirTitle = "Change Directory";
  214. const char * TChDirDialog::dirNameText = "Directory ~n~ame";
  215. const char * TChDirDialog::dirTreeText = "Directory ~t~ree";
  216. const char * TChDirDialog::okText = "O~K~";
  217. const char * TChDirDialog::chdirText = "~C~hdir";
  218. const char * TChDirDialog::revertText = "~R~evert";
  219. const char * TChDirDialog::helpText = "Help";
  220. const char * TChDirDialog::drivesText = "Drives";
  221. const char * TChDirDialog::invalidText = "Invalid directory";
  222.  
  223. const char * TFileDialog::filesText = "~F~iles";
  224. const char * TFileDialog::openText = "~O~pen";
  225. const char * TFileDialog::okText = "O~K~";
  226. const char * TFileDialog::replaceText = "~R~eplace";
  227. const char * TFileDialog::clearText = "~C~lear";
  228. const char * TFileDialog::cancelText = "Cancel";
  229. const char * TFileDialog::helpText = "~H~elp";
  230. const char * TFileDialog::invalidDriveText = "Invalid drive or directory";
  231. const char * TFileDialog::invalidFileText = "Invalid file name.";
  232.  
  233. const char * TFileInfoPane::pmText = "p";
  234. const char * TFileInfoPane::amText = "a";
  235. const char * const TFileInfoPane::months[] =
  236.     {
  237.     "","Jan","Feb","Mar","Apr","May","Jun",
  238.     "Jul","Aug","Sep","Oct","Nov","Dec"
  239.     };
  240.  
  241. /*const*/ char TDeskTop::defaultBkgrnd = '\xB0';
  242.  
  243. char TListViewer::separatorChar = 179;
  244. const char* TOutlineViewer::graphChars = "\x20\xB3\xC3\xC0\xC4\xC4+\xC4";
  245.