home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / colord / tdemo2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-05  |  21.0 KB  |  469 lines

  1. /*-----------------------------------------------------------------------*/
  2. /* filename -       tdemo2.cpp                                           */
  3. /*                                                                       */
  4. /* function(s)                                                           */
  5. /*                  definitions for the following classes used in the    */
  6. /*                  TVColorDialog demo program...                        */
  7. /*                                                                       */
  8. /*                     TXDialog1                                         */
  9. /*                     TXDialog2                                         */
  10. /*                     TXDialog3                                         */
  11. /*                     TAppStatusLine                                    */
  12. /*                                                                       */
  13. /* author -         Michael "Mick" Newton                                */
  14. /*                                                                       */
  15. /*-----------------------------------------------------------------------*/
  16.  
  17. /*-----------------------------------------------------------------------*/
  18. /*                                                                       */
  19. /*    TDEMO2.CPP                                                         */
  20. /*                                                                       */
  21. /*    TVColorDialog shareware version 2.0                                */
  22. /*    (C) Copyright 1992,1993 Comsoft Software                           */
  23. /*    All Rights Reserved.                                               */
  24. /*                                                                       */
  25. /*-----------------------------------------------------------------------*/
  26.  
  27. // Define Turbo Vision classes used ***************************************
  28.  
  29. #define Uses_TApplication
  30. #define Uses_TDeskTop
  31. #define Uses_TDialog
  32. #define Uses_TListBox
  33. #define Uses_TObject
  34. #define Uses_TPalette
  35. #define Uses_TPoint
  36. #define Uses_TRect
  37. #define Uses_TSItem
  38. #define Uses_TSortedCollection
  39. #define Uses_TStatusDef
  40. #define Uses_TStatusItem
  41. #define Uses_TStatusLine
  42. #define Uses_TView
  43. #define Uses_TWindow
  44.  
  45. #include <tv.h>
  46.  
  47.  
  48.  
  49.  
  50.  
  51. // CRTL header files ******************************************************
  52.  
  53. #if !defined __STRSTREAM_H
  54. #include <strstrea.h>
  55. #endif
  56.  
  57.  
  58.  
  59.  
  60.  
  61. // Non-CRTL header files **************************************************
  62.  
  63. #if !defined __TDEMO2_HPP
  64. #include "tdemo2.hpp"
  65. #endif
  66.  
  67.  
  68.  
  69.  
  70.  
  71. // TXDialog1 **************************************************************
  72.  
  73. /* ┌───────────────────────────────────────────────────────────────────┐ */
  74. /* │ TXDialog1 palette layout                                          │ */
  75. /* ╞═══════╤═══════╤═══════════════════════════════════════════════════╡ */
  76. /* │ owner │ This  │                                                   │ */
  77. /* │ index │ index │ Item                                              │ */
  78. /* ├───────┼───────┼───────────────────────────────────────────────────┤ */
  79. /* │    64 │ 1     │ Frame passive                                     │ */
  80. /* │    65 │ 2     │ Frame active                                      │ */
  81. /* │    66 │ 3     │ Frame icon                                        │ */
  82. /* │    67 │ 4     │ ScrollBar page                                    │ */
  83. /* │    68 │ 5     │ ScrollBar controls                                │ */
  84. /* │    69 │ 6     │ StaticText                                        │ */
  85. /* │    70 │ 7     │ Label normal                                      │ */
  86. /* │    71 │ 8     │ Label selected                                    │ */
  87. /* │    72 │ 9     │ Label shortcut                                    │ */
  88. /* │    73 │ 10    │ Button normal                                     │ */
  89. /* │    74 │ 11    │ Button default                                    │ */
  90. /* │    75 │ 12    │ Button selected                                   │ */
  91. /* │    76 │ 13    │ Button disabled                                   │ */
  92. /* │    77 │ 14    │ Button shortcut                                   │ */
  93. /* │    78 │ 15    │ Button shadow                                     │ */
  94. /* │    79 │ 16    │ Cluster normal                                    │ */
  95. /* │    80 │ 17    │ Cluster selected                                  │ */
  96. /* │    81 │ 18    │ Cluster shortcut                                  │ */
  97. /* │    82 │ 19    │ InputLine normal text                             │ */
  98. /* │    83 │ 20    │ InputLine selected text                           │ */
  99. /* │    84 │ 21    │ InputLine arrows                                  │ */
  100. /* │    85 │ 22    │ History arrow                                     │ */
  101. /* │    86 │ 23    │ History sides                                     │ */
  102. /* │    87 │ 24    │ History scrollbar page                            │ */
  103. /* │    88 │ 25    │ History scrollbar controls                        │ */
  104. /* │    89 │ 26    │ ListViewer normal                                 │ */
  105. /* │    90 │ 27    │ ListViewer focused                                │ */
  106. /* │    91 │ 28    │ ListViewer selected                               │ */
  107. /* │    92 │ 29    │ ListViewer divider                                │ */
  108. /* │    93 │ 30    │ InfoPane                                          │ */
  109. /* │    94 │ 31    │ Reserved                                          │ */
  110. /* │    95 │ 32    │ Reserved                                          │ */
  111. /* │    96 │ 33    │ Unused                                            │ */
  112. /* │    97 │ 34    │ Unused                                            │ */
  113. /* │    98 │ 35    │ Unused                                            │ */
  114. /* │    99 │ 36    │ Unused                                            │ */
  115. /* │   100 │ 37    │ Unused                                            │ */
  116. /* │   101 │ 38    │ Unused                                            │ */
  117. /* │   102 │ 39    │ Unused                                            │ */
  118. /* │   103 │ 40    │ Unused                                            │ */
  119. /* │   104 │ 41    │ Unused                                            │ */
  120. /* │   105 │ 42    │ Unused                                            │ */
  121. /* │   106 │ 43    │ Unused                                            │ */
  122. /* │   107 │ 44    │ Unused                                            │ */
  123. /* │   108 │ 45    │ Unused                                            │ */
  124. /* │   109 │ 46    │ Unused                                            │ */
  125. /* │   110 │ 47    │ Unused                                            │ */
  126. /* │   111 │ 48    │ Unused                                            │ */
  127. /* │   112 │ 49    │ Unused                                            │ */
  128. /* │   113 │ 50    │ Unused                                            │ */
  129. /* └───────┴───────┴───────────────────────────────────────────────────┘ */
  130.  
  131. // Index 64 - 113
  132. #define cpTXDialog1 \
  133.    "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49" \
  134.    "\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53" \
  135.    "\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D" \
  136.    "\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67" \
  137.    "\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71"
  138.  
  139. TXDialog1::TXDialog1(const TRect& bounds, const char *aTitle) :
  140.            TDialog(bounds, aTitle),
  141.            TWindowInit(initFrame)
  142. {
  143. }
  144.  
  145.  
  146. void TXDialog1::shutDown()
  147. {
  148.    listbox->newList(0);
  149.    TDialog::shutDown();
  150. }
  151.  
  152.  
  153. TPalette& TXDialog1::getPalette() const
  154. {
  155.    static TPalette palette(cpTXDialog1, sizeof(cpTXDialog1) - 1);
  156.    return palette;
  157. }
  158.  
  159.  
  160. void TXDialog1::handleEvent(TEvent& event)
  161. {
  162.    TDialog::handleEvent(event);
  163.  
  164.    if(event.what == evCommand && event.message.command == cmCloseX)
  165.       {
  166.       if(TApplication::deskTop->current == this)
  167.          {
  168.          TApplication::deskTop->remove(this);
  169.          TObject::destroy((TXDialog1 *) this);
  170.          clearEvent(event);
  171.          }
  172.       }
  173. }
  174.  
  175.  
  176.  
  177.  
  178.  
  179. // TXDialog2 **************************************************************
  180.  
  181. /* ┌───────────────────────────────────────────────────────────────────┐ */
  182. /* │ TXDialog2 palette layout                                          │ */
  183. /* ╞═══════╤═══════╤═══════════════════════════════════════════════════╡ */
  184. /* │ owner │ This  │                                                   │ */
  185. /* │ index │ index │ Item                                              │ */
  186. /* ├───────┼───────┼───────────────────────────────────────────────────┤ */
  187. /* │   114 │ 1     │ Frame passive                                     │ */
  188. /* │   115 │ 2     │ Frame active                                      │ */
  189. /* │   116 │ 3     │ Frame icon                                        │ */
  190. /* │   117 │ 4     │ Scrollbar page                                    │ */
  191. /* │   118 │ 5     │ Scrollbar controls                                │ */
  192. /* │   119 │ 6     │ Static text                                       │ */
  193. /* │   120 │ 7     │ Label normal                                      │ */
  194. /* │   121 │ 8     │ Label selected                                    │ */
  195. /* │   122 │ 9     │ Label shortcut                                    │ */
  196. /* │   123 │ 10    │ Button normal                                     │ */
  197. /* │   124 │ 11    │ Button default                                    │ */
  198. /* │   125 │ 12    │ Button selected                                   │ */
  199. /* │   126 │ 13    │ Button disabled                                   │ */
  200. /* │   127 │ 14    │ Button shortcut                                   │ */
  201. /* │   128 │ 15    │ Button shadow                                     │ */
  202. /* │   129 │ 16    │ Cluster normal                                    │ */
  203. /* │   130 │ 17    │ Cluster selected                                  │ */
  204. /* │   131 │ 18    │ Cluster shortcut                                  │ */
  205. /* │   132 │ 19    │ Input normal text                                 │ */
  206. /* │   133 │ 20    │ Input selected text                               │ */
  207. /* │   134 │ 21    │ Input arrows                                      │ */
  208. /* │   135 │ 22    │ History arrow                                     │ */
  209. /* │   136 │ 23    │ History sides                                     │ */
  210. /* │   137 │ 24    │ History scrollbar page                            │ */
  211. /* │   138 │ 25    │ History scrollbar controls                        │ */
  212. /* │   139 │ 26    │ List normal                                       │ */
  213. /* │   140 │ 27    │ List focused                                      │ */
  214. /* │   141 │ 28    │ List selected                                     │ */
  215. /* │   142 │ 29    │ List divider                                      │ */
  216. /* │   143 │ 30    │ InfoPane                                          │ */
  217. /* │   144 │ 31    │ Reserved                                          │ */
  218. /* │   145 │ 32    │ Reserved                                          │ */
  219. /* │   146 │ 33    │ Unused                                            │ */
  220. /* │   147 │ 34    │ Unused                                            │ */
  221. /* │   148 │ 35    │ Unused                                            │ */
  222. /* │   149 │ 36    │ Unused                                            │ */
  223. /* │   150 │ 37    │ Unused                                            │ */
  224. /* │   151 │ 38    │ Unused                                            │ */
  225. /* │   152 │ 39    │ Unused                                            │ */
  226. /* │   153 │ 40    │ Unused                                            │ */
  227. /* │   154 │ 41    │ Unused                                            │ */
  228. /* │   155 │ 42    │ Unused                                            │ */
  229. /* │   156 │ 43    │ Unused                                            │ */
  230. /* │   157 │ 44    │ Unused                                            │ */
  231. /* │   158 │ 45    │ Unused                                            │ */
  232. /* │   159 │ 46    │ Unused                                            │ */
  233. /* │   160 │ 47    │ Unused                                            │ */
  234. /* │   161 │ 48    │ Unused                                            │ */
  235. /* │   162 │ 49    │ Unused                                            │ */
  236. /* │   163 │ 50    │ Unused                                            │ */
  237. /* └───────┴───────┴───────────────────────────────────────────────────┘ */
  238.  
  239. // Index 114 - 163
  240. #define cpTXDialog2 \
  241.    "\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B" \
  242.    "\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85" \
  243.    "\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F" \
  244.    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99" \
  245.    "\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3"
  246.  
  247. TXDialog2::TXDialog2(const TRect& bounds, const char *aTitle) :
  248.            TDialog(bounds, aTitle),
  249.            TWindowInit(initFrame)
  250. {
  251. }
  252.  
  253.  
  254. void TXDialog2::shutDown()
  255. {
  256.    listbox->newList(0);
  257.    TDialog::shutDown();
  258. }
  259.  
  260.  
  261. TPalette& TXDialog2::getPalette() const
  262. {
  263.    static TPalette palette(cpTXDialog2, sizeof(cpTXDialog2) - 1);
  264.    return palette;
  265. }
  266.  
  267.  
  268. void TXDialog2::handleEvent(TEvent& event)
  269. {
  270.    TDialog::handleEvent(event);
  271.  
  272.    if(event.what == evCommand && event.message.command == cmCloseX)
  273.       {
  274.       if(TApplication::deskTop->current == this)
  275.          {
  276.          TApplication::deskTop->remove(this);
  277.          TObject::destroy((TXDialog2 *) this);
  278.          clearEvent(event);
  279.          }
  280.       }
  281. }
  282.  
  283.  
  284.  
  285.  
  286.  
  287. // TXDialog3 **************************************************************
  288.  
  289. /* ┌───────────────────────────────────────────────────────────────────┐ */
  290. /* │ TXDialog3 palette layout                                          │ */
  291. /* ╞═══════╤═══════╤═══════════════════════════════════════════════════╡ */
  292. /* │ owner │ This  │                                                   │ */
  293. /* │ index │ index │ Item                                              │ */
  294. /* ├───────┼───────┼───────────────────────────────────────────────────┤ */
  295. /* │   164 │ 1     │ Frame passive                                     │ */
  296. /* │   165 │ 2     │ Frame active                                      │ */
  297. /* │   166 │ 3     │ Frame icon                                        │ */
  298. /* │   167 │ 4     │ ScrollBar page                                    │ */
  299. /* │   168 │ 5     │ ScrollBar controls                                │ */
  300. /* │   169 │ 6     │ StaticText                                        │ */
  301. /* │   170 │ 7     │ Label normal                                      │ */
  302. /* │   171 │ 8     │ Label selected                                    │ */
  303. /* │   172 │ 9     │ Label shortcut                                    │ */
  304. /* │   173 │ 10    │ Button normal                                     │ */
  305. /* │   174 │ 11    │ Button default                                    │ */
  306. /* │   175 │ 12    │ Button selected                                   │ */
  307. /* │   176 │ 13    │ Button disabled                                   │ */
  308. /* │   177 │ 14    │ Button shortcut                                   │ */
  309. /* │   178 │ 15    │ Button shadow                                     │ */
  310. /* │   179 │ 16    │ Cluster normal                                    │ */
  311. /* │   180 │ 17    │ Cluster selected                                  │ */
  312. /* │   181 │ 18    │ Cluster shortcut                                  │ */
  313. /* │   182 │ 19    │ Input normal text                                 │ */
  314. /* │   183 │ 20    │ Input selected text                               │ */
  315. /* │   184 │ 21    │ InputLine arrows                                  │ */
  316. /* │   185 │ 22    │ History arrow                                     │ */
  317. /* │   186 │ 23    │ History sides                                     │ */
  318. /* │   187 │ 24    │ History scrollbar page                            │ */
  319. /* │   188 │ 25    │ History scrollbar controls                        │ */
  320. /* │   189 │ 26    │ ListViewer normal                                 │ */
  321. /* │   190 │ 27    │ ListViewer focused                                │ */
  322. /* │   191 │ 28    │ ListViewer selected                               │ */
  323. /* │   192 │ 29    │ ListViewer divider                                │ */
  324. /* │   193 │ 30    │ InfoPane                                          │ */
  325. /* │   194 │ 31    │ Reserved                                          │ */
  326. /* │   195 │ 32    │ Reserved                                          │ */
  327. /* │   196 │ 33    │ Unused                                            │ */
  328. /* │   197 │ 34    │ Unused                                            │ */
  329. /* │   198 │ 35    │ Unused                                            │ */
  330. /* │   199 │ 36    │ Unused                                            │ */
  331. /* │   200 │ 37    │ Unused                                            │ */
  332. /* │   201 │ 38    │ Unused                                            │ */
  333. /* │   202 │ 39    │ Unused                                            │ */
  334. /* │   203 │ 40    │ Unused                                            │ */
  335. /* │   204 │ 41    │ Unused                                            │ */
  336. /* │   205 │ 42    │ Unused                                            │ */
  337. /* │   206 │ 43    │ Unused                                            │ */
  338. /* │   207 │ 44    │ Unused                                            │ */
  339. /* │   208 │ 45    │ Unused                                            │ */
  340. /* │   209 │ 46    │ Unused                                            │ */
  341. /* │   210 │ 47    │ Unused                                            │ */
  342. /* │   211 │ 48    │ Unused                                            │ */
  343. /* │   212 │ 49    │ Unused                                            │ */
  344. /* │   213 │ 50    │ Unused                                            │ */
  345. /* └───────┴───────┴───────────────────────────────────────────────────┘ */
  346.  
  347. // Index 164 - 213
  348. #define cpTXDialog3 \
  349.    "\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD" \
  350.    "\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7" \
  351.    "\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1" \
  352.    "\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB" \
  353.    "\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5"
  354.  
  355. TXDialog3::TXDialog3(const TRect& bounds, const char *aTitle) :
  356.            TDialog(bounds, aTitle),
  357.            TWindowInit(initFrame)
  358. {
  359. }
  360.  
  361.  
  362. void TXDialog3::shutDown()
  363. {
  364.    listbox->newList(0);
  365.    TDialog::shutDown();
  366. }
  367.  
  368.  
  369. TPalette& TXDialog3::getPalette() const
  370. {
  371.    static TPalette palette(cpTXDialog3, sizeof(cpTXDialog3) - 1);
  372.    return palette;
  373. }
  374.  
  375.  
  376. void TXDialog3::handleEvent(TEvent& event)
  377. {
  378.    TDialog::handleEvent(event);
  379.  
  380.    if(event.what == evCommand && event.message.command == cmCloseX)
  381.       {
  382.       if(TApplication::deskTop->current == this)
  383.          {
  384.          TApplication::deskTop->remove(this);
  385.          TObject::destroy((TXDialog3 *) this);
  386.          clearEvent(event);
  387.          }
  388.       }
  389. }
  390.  
  391.  
  392.  
  393.  
  394.  
  395. // TAppStatusLine *********************************************************
  396.  
  397. /* ┌───────────────────────────────────────────────────────────────────┐ */
  398. /* │ TAppStatusLine palette layout                                     │ */
  399. /* ╞═══════╤═══════╤═══════════════════════════════════════════════════╡ */
  400. /* │ owner │ This  │                                                   │ */
  401. /* │ index │ index │ Item                                              │ */
  402. /* ├───────┼───────┼───────────────────────────────────────────────────┤ */
  403. /* │   214 │ 1     │ Normal Text                                       │ */
  404. /* │   215 │ 2     │ Disabled Text                                     │ */
  405. /* │   216 │ 3     │ Shortcut Text                                     │ */
  406. /* │   217 │ 4     │ Normal Selection                                  │ */
  407. /* │   218 │ 5     │ Disabled Selection                                │ */
  408. /* │   219 │ 6     │ Shortcut Selection                                │ */
  409. /* └───────┴───────┴───────────────────────────────────────────────────┘ */
  410.  
  411. #define cpAppStatusLine "\xD6\xD7\xD8\xD9\xDA\xDB"
  412.  
  413. TAppStatusLine::TAppStatusLine(const TRect& bounds, TStatusDef& aDefs) :
  414.                 TStatusLine(bounds, aDefs)
  415. {
  416. }
  417.  
  418.  
  419. TPalette& TAppStatusLine::getPalette() const
  420. {
  421.    static TPalette palette(cpAppStatusLine, sizeof(cpAppStatusLine) - 1);
  422.    return palette;
  423. }
  424.  
  425.  
  426. const char *TAppStatusLine::hint(ushort aHelpCtx)
  427. {
  428.    static char buff[maxViewWidth];
  429.    ostrstream os(buff, sizeof buff);
  430.  
  431.    memset(buff, '\0', 81);
  432.  
  433.    switch(aHelpCtx)
  434.       {
  435.       case hcSystem:
  436.          os << "Program system menu";
  437.          break;
  438.       case hcAbout:
  439.          os << "Information about this program";
  440.          break;
  441.       case hcWritePal:
  442.          os << "Write application palettes to file";
  443.          break;
  444.       case hcExit:
  445.          os << "Quit this program";
  446.          break;
  447.       case hcColors:
  448.          os << "Select colors and pattern character";
  449.          break;
  450.       case hcOptions:
  451.          os << "Select TVColorDialog options";
  452.          break;
  453.       case hcXDialogs:
  454.          os << "Extended palette demo dialogs";
  455.          break;
  456.       default:
  457.          os << "No hint available";
  458.       }
  459.  
  460.    os << ends;
  461.  
  462.    return buff;
  463. }
  464.  
  465. //                                End of TDEMO2.CPP
  466.  
  467.  
  468.  
  469.