home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / TVCOLR.ZIP / BLDRSC.CPP next >
C/C++ Source or Header  |  1994-02-08  |  12KB  |  322 lines

  1. // File    : BLDRSC.CPP
  2. // Author  : Eric Woodruff,  CIS ID: 72134,1150
  3. // Updated : Tue 02/08/94 10:27:22
  4. // Note    : Hereby declared public domain
  5. // Compiler: Borland C++ 3.1/4.0
  6. //
  7. // This file contains the standard resource file builder.
  8. // Modify or add the necessary items and compile.
  9. //
  10.  
  11. #define RSC_FILENAME    "DEMO.RSC"   // File to create.
  12.                                      // Works for either demo.  Just specify
  13.                                      // /RDEMO.RSC on its command line.
  14.  
  15. #define WriteResource(a,b,c) \
  16.     cout << c << endl; \
  17.     a = b(); \
  18.     if( a == 0 ) \
  19.     { \
  20.         strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
  21.         TObject::destroy(rsc); \
  22.         exit(1); \
  23.     } \
  24.     rsc->put(a,c); \
  25.     TObject::destroy(a)
  26.  
  27. #define WriteObject(a,c) \
  28.     cout << c << endl; \
  29.     if(a == 0) \
  30.     { \
  31.         strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
  32.         TObject::destroy(rsc); \
  33.         exit(1); \
  34.     } \
  35.     rsc->put(a,c); \
  36.     TObject::destroy(a)
  37.  
  38. #include <conio.h>
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <time.h>
  43.  
  44. #define Uses_TButton
  45. #define Uses_TColorDialog
  46. #define Uses_TColorGroup
  47. #define Uses_TColorItem
  48. #define Uses_TDialog
  49. #define Uses_TKeys
  50. #define Uses_TMenuBar
  51. #define Uses_TMenuItem
  52. #define Uses_TRect
  53. #define Uses_TResourceFile
  54. #define Uses_TStaticText
  55. #define Uses_TStatusDef
  56. #define Uses_TStatusItem
  57. #define Uses_TStatusLine
  58. #define Uses_TSubMenu
  59. #define Uses_TVCOLR             // Use this if you modified the TV.H file.
  60. #define Uses_fpstream
  61. #include <tv.h>
  62.  
  63. #if !defined(cpDefSize)
  64. // Use this if you chose not to modify the Turbo Vision files.
  65. #include <tvcolr.h>
  66. #endif
  67.  
  68. #include <tcoltxt.h>
  69.  
  70. #include "link.h"           // Resource file link definitions.
  71. #include "demo.h"
  72.  
  73. // ============================================================================
  74. TDialog *Colors(void);
  75. TDialog *AboutBox(void);
  76.  
  77. TMenuBar *initMenuBar(void);
  78. TStatusLine *initStatusLine(void);
  79.  
  80. // ============================================================================
  81.  
  82. fpstream *s;
  83. TResourceFile* rsc;
  84. char endString[255] = "";
  85.  
  86. // ============================================================================
  87.  
  88. void exitfunc(void)
  89. {
  90.    cout << endl << endString << endl;
  91. }
  92.  
  93. #pragma exit exitfunc 31
  94.  
  95. void main(void)
  96. {
  97.     TDialog *dlg;
  98.     TMenuBar *menuBar;
  99.     TStatusLine *statusLine;
  100.  
  101.     cout << "Creating " RSC_FILENAME << endl;
  102.  
  103.     // Construct stream and resource file.
  104.     s = new fpstream (RSC_FILENAME, ios::trunc | ios::binary);
  105.     rsc = new TResourceFile(s);
  106.  
  107.     // Create all of the necessary dialogs for the demo.
  108.     WriteResource(dlg, AboutBox, "AboutBox");
  109.     WriteResource(dlg, Colors, "ColorDlg");
  110.  
  111.     // Create the menus and status line.
  112.     WriteResource(menuBar, initMenuBar, "MenuBar");
  113.     WriteResource(statusLine, initStatusLine, "StatusLine");
  114.  
  115.     TObject::destroy(rsc);
  116.     strcpy(endString, RSC_FILENAME " creation completed.");
  117. }
  118.  
  119. // ============================================================================
  120. TDialog *AboutBox(void)
  121. {
  122.     TDialog *aboutBox = new TDialog(TRect(0, 0, 46, 11), "About");
  123.     aboutBox->options |= ofCentered;
  124.  
  125.     aboutBox->insert(new TColorText(TRect(1, 1, 45, 7),
  126.             "\n\003TVCOLR/COLUPDT Changes Demo\n\003\n"
  127.             "\003by Eric Woodruff\n\003CIS ID: 72134,1150\n", eTxtInfo));
  128.  
  129.     TButton *b = new TButton(TRect(11,8,23,10), "O~K~", cmOK, bfDefault);
  130.     b->options |= ofCenterX;
  131.     aboutBox->insert(b);
  132.  
  133.     return aboutBox;
  134. }
  135.  
  136. TDialog *Colors(void)
  137. {
  138.     TColorGroup &group1 =
  139.         *new TColorGroup("Desktop") +
  140.             *new TColorItem("Background",        1)+
  141.  
  142.         *new TColorGroup("Menus") +
  143.             *new TColorItem("Normal text",       2)+
  144.             *new TColorItem("Disabled text",     3)+
  145.             *new TColorItem("Shortcut key",      4)+
  146.             *new TColorItem("Selection bar",     5)+
  147.             *new TColorItem("Selected disabled", 6)+
  148.             *new TColorItem("Shortcut selected", 7);
  149.  
  150.     TColorGroup &group2 =
  151.         *new TColorGroup("Blue Window") +
  152.             *new TColorItem("Frame inactive",    8)+
  153.             *new TColorItem("Frame active",      9)+
  154.             *new TColorItem("Frame icons",      10)+
  155.             *new TColorItem("Scrollbar page",   11)+
  156.             *new TColorItem("Scrollbar icons",  12)+
  157.             *new TColorItem("Normal text",      13)+
  158.             *new TColorItem("Selected text",    14)+
  159.  
  160.         *new TColorGroup("Cyan Window") +
  161.             *new TColorItem("Frame inactive",  16)+
  162.             *new TColorItem("Frame active",    17)+
  163.             *new TColorItem("Frame icons",     18)+
  164.             *new TColorItem("Scrollbar page",  19)+
  165.             *new TColorItem("Scrollbar icons", 20)+
  166.             *new TColorItem("Normal text",     21)+
  167.             *new TColorItem("Selected text",   22)+
  168.  
  169.         *new TColorGroup("Gray Window") +
  170.             *new TColorItem("Frame inactive",  24)+
  171.             *new TColorItem("Frame active",    25)+
  172.             *new TColorItem("Frame icons",     26)+
  173.             *new TColorItem("Scrollbar page",  27)+
  174.             *new TColorItem("Scrollbar icons", 28)+
  175.             *new TColorItem("Normal text",     29)+
  176.             *new TColorItem("Selected text",   30) +
  177.  
  178.         *new TColorGroup("Dialog Box") +
  179.             *new TColorItem("Frame inactive",   32)+
  180.             *new TColorItem("Frame active",     33)+
  181.             *new TColorItem("Frame icons",      34)+
  182.             *new TColorItem("Scrollbar page",   35)+
  183.             *new TColorItem("Scrollbar icons",  36);
  184.  
  185.     TColorGroup &group3 =
  186.         // The last four Dialog Text colors can be set, but are only
  187.         // accessible when using the alternate mapColor() routine
  188.         // from TVCOLR.ZIP.
  189.         *new TColorGroup("Dialog Text") +
  190.             *new TColorItem("Normal",       37)+
  191.             *new TColorItem("Information",  cCTxtInfoColor)+    // Extended
  192.             *new TColorItem("Notification", cCTxtNotifyColor)+  // Extended
  193.             *new TColorItem("Warning",      cCTxtWarnColor)+    // Extended
  194.             *new TColorItem("Error",        cCTxtErrorColor)+   // Extended
  195.  
  196.         // Selected Shortcut is only applicable if you made the
  197.         // changes described in COLUPDT.DOC in TVCOLR.ZIP.
  198.         *new TColorGroup("Dialog Label") +
  199.             *new TColorItem("Normal",            38)+
  200.             *new TColorItem("Selected",          39)+
  201.             *new TColorItem("Shortcut key",      40)+
  202. #ifdef MODIFIED_TV_COLORS
  203.             *new TColorItem("Selected shortcut", 66)+   // Added by me
  204. #endif
  205.  
  206.         // Default and Selected Shortcut are only applicable if you made
  207.         // the changes described in COLUPDT.DOC in TVCOLR.ZIP
  208.         *new TColorGroup("Dialog Button") +
  209.             *new TColorItem("Normal",            41)+
  210.             *new TColorItem("Default",           42)+
  211.             *new TColorItem("Selected",          43)+
  212.             *new TColorItem("Disabled",          44)+
  213.             *new TColorItem("Shortcut key",      45)+
  214. #ifdef MODIFIED_TV_COLORS
  215.             *new TColorItem("Default shortcut",  64)+   // Added by me
  216.             *new TColorItem("Selected shortcut", 65)+   // Added by me
  217. #endif
  218.             *new TColorItem("Shadow",            46)+
  219.  
  220.         *new TColorGroup("Dialog Cluster") +
  221.             *new TColorItem("Normal",    47)+
  222.             *new TColorItem("Selected",  48)+
  223.             *new TColorItem("Shortcut",  49);
  224.  
  225.     TColorGroup &group4 =
  226.         *new TColorGroup("Dialog Input") +
  227.             *new TColorItem("Input normal",      50)+
  228.             *new TColorItem("Input selected",    51)+
  229.             *new TColorItem("Input arrow",       52)+
  230.             *new TColorItem("History button",    53)+
  231.             *new TColorItem("History sides",     54)+
  232.             *new TColorItem("History scrollbar", 55)+
  233.             *new TColorItem("History icons",     56)+
  234.  
  235.         *new TColorGroup("Dialog List") +
  236.             *new TColorItem("Normal item",       57)+
  237.             *new TColorItem("Focused item",      58)+
  238.             *new TColorItem("Selected item",     59)+
  239.             *new TColorItem("Divider",           60)+
  240.             *new TColorItem("Information pane",  61)+
  241.  
  242. #ifdef MODIFIED_TV_COLORS
  243.         *new TColorGroup("Help Window") +
  244.             *new TColorItem("Frame inactive",   67)+
  245.             *new TColorItem("Frame active",     68)+
  246.             *new TColorItem("Frame icons",      69)+
  247.             *new TColorItem("Scrollbar page",   70)+
  248.             *new TColorItem("Scrollbar icons",  71)+
  249.             *new TColorItem("Normal text",      72)+
  250.             *new TColorItem("Keyword",          73)+
  251.             *new TColorItem("Selected keyword", 74);
  252. #else
  253.         *new TColorGroup("Help Window") +
  254.             *new TColorItem("Frame inactive",   64)+
  255.             *new TColorItem("Frame active",     65)+
  256.             *new TColorItem("Frame icons",      66)+
  257.             *new TColorItem("Scrollbar page",   67)+
  258.             *new TColorItem("Scrollbar icons",  68)+
  259.             *new TColorItem("Normal text",      69)+
  260.             *new TColorItem("Keyword",          70)+
  261.             *new TColorItem("Selected keyword", 71);
  262. #endif
  263.  
  264.     TColorGroup &group5 = group1 + group2 + group3 + group4;
  265.  
  266.     // See the notes in handleEvent() about the proper usage of TColorDialog.
  267.     TColorDialog *c = new TColorDialog((TPalette*)0, &group5);
  268.  
  269.     return c;
  270. }
  271.  
  272. TMenuBar *initMenuBar(void)
  273. {
  274.     TSubMenu& MiscMenu = *new TSubMenu( "~\xF0~", 0) +
  275.         *new TMenuItem( "~A~bout...", cmAbout, kbNoKey)+
  276.         *new TMenuItem( "~R~epaint desktop", cmRepaint, kbNoKey);
  277.  
  278.     TSubMenu& FileMenu = *new TSubMenu("~D~emo", 0) +
  279.         *new TMenuItem( "Insert ~B~lue Window", cmBlueWindow, kbF2, hcNoContext, "F2" ) +
  280.         *new TMenuItem( "Insert ~G~ray Window", cmGrayWindow, kbF3, hcNoContext, "F3" ) +
  281.         *new TMenuItem( "Insert ~C~yan Window", cmCyanWindow, kbF7, hcNoContext, "F7" ) +
  282.         *new TMenuItem( "Insert ~D~ialog Box",  cmDialogBox,  kbF8, hcNoContext, "F8" ) +
  283.         *new TMenuItem( "Insert ~H~elp Window", cmHelpWindow, kbF9, hcNoContext, "F9" ) +
  284.             newLine() +
  285.         *new TMenuItem( "~D~OS shell", cmDOSshell, kbNoKey) +
  286.         *new TMenuItem( "~Q~uit", cmQuit, kbAltX, hcNoContext, "Alt+X" );
  287.  
  288.     TSubMenu& WindowMenu = *new TSubMenu( "~W~indows", 0) +
  289.         *new TMenuItem( "~S~ize/Move", cmResize, kbCtrlF5, hcNoContext, "Ctrl+F5" ) +
  290.         *new TMenuItem( "~Z~oom", cmZoom, kbF5, hcNoContext, "F5" ) +
  291.         *new TMenuItem( "C~a~scade", cmCascade, kbNoKey) +
  292.         *new TMenuItem( "~T~ile", cmTile, kbNoKey) +
  293.         *new TMenuItem( "Ne~x~t", cmNext, kbF6, hcNoContext, "F6" ) +
  294.         *new TMenuItem( "~P~revious", cmPrev, kbShiftF6, hcNoContext, "Shift+F6" ) +
  295.         *new TMenuItem( "~C~lose", cmClose, kbAltF3, hcNoContext, "Alt+F3" ) +
  296.         *new TMenuItem( "Clos~e~ all", cmCloseTileable, kbNoKey) +
  297.             newLine() +
  298.         *new TMenuItem( "To~g~gle Screen Size", cmScreenSize, kbNoKey) +
  299.         *new TMenuItem( "~U~ser screen", cmUserScreen, kbAltF5, hcNoContext, "Alt+F5");
  300.  
  301.     TSubMenu& OptionsMenu = *new TSubMenu("~O~ptions", 0) +
  302.         *new TMenuItem( "~C~olors...", cmColors, kbNoKey ) +
  303.         *new TMenuItem( "C~h~ange palettes", cmChangePalettes, kbNoKey ) +
  304.         *new TMenuItem( "~M~ake palette strings text file", cmMakeStrings, kbNoKey) +
  305.             newLine() +
  306.         *new TMenuItem( "~L~oad configuration...", cmLoadCfg, kbNoKey) +
  307.         *new TMenuItem( "~S~ave configuration...", cmSaveCfg, kbNoKey);
  308.  
  309.     return new TMenuBar(TRect(0, 0, 80, 1), MiscMenu + FileMenu +
  310.         WindowMenu + OptionsMenu);
  311. }
  312.  
  313. TStatusLine *initStatusLine(void)
  314. {
  315.     return new TStatusLine( TRect(0, 24, 80, 25),
  316.       *new TStatusDef( 0, 0xFFFF ) +
  317.         *new TStatusItem(0, kbF10, cmMenu) +
  318.         *new TStatusItem( "~F1~ Help", kbF1, cmHelp ) +
  319.         *new TStatusItem( "~Alt+X~ Exit", kbAltX, cmQuit ) +
  320.         *new TStatusItem( "~Alt+F3~ Close", kbAltF3, cmClose));
  321. }
  322.