home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac / ve2tv103.zip / BLDRSC.CPP next >
C/C++ Source or Header  |  1994-07-31  |  33KB  |  881 lines

  1. // File    : BLDRSC.CPP
  2. // Author  : Eric Woodruff,  CIS ID: 72134,1150
  3. // Updated : Sun 07/31/94 15:56:28
  4. // Note    : Copyright 1994, Eric Woodruff, All Rights Reserved
  5. // Compiler: Borland C++ 3.1 to 4.02
  6. //
  7. // This program is the resource file builder for the demo editor.
  8. //
  9.  
  10. // NOTE: The 32 bit version of the resource file is *NOT* compatible with
  11. //       the 16 bit version!  This is because 'int' values stored in it are
  12. //       32 bits long not 16 so they no long match 'short' values which are
  13. //       16 bits long in either version.  See HISTORY.DOC for a required fix
  14. //       to TSTATUSL.CPP before building the 32 bit version of the resource
  15. //       file.
  16. //
  17. #if defined(__DPMI16__)
  18.     #define RSC_FILENAME    "TVEDIT16.RSC"   // File to create.
  19. #else
  20.     #if defined(__DPMI32__)
  21.         #define RSC_FILENAME    "TVEDIT32.RSC"   // File to create.
  22.     #else
  23.         #define RSC_FILENAME    "TVEDIT.RSC"   // File to create.
  24.     #endif
  25. #endif
  26.  
  27. #if _TV_VERSION == 0x0103
  28. #define WriteResource(a,b,c) \
  29.     cout << c << endl; \
  30.     a = b(); \
  31.     if( a == 0 ) \
  32.     { \
  33.         strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
  34.         TObject::destroy(rsc); \
  35.         exit(1); \
  36.     } \
  37.     rsc->put(a,c); \
  38.     TObject::destroy(a)
  39.  
  40. #define WriteObject(a,c) \
  41.     cout << c << endl; \
  42.     if(a == 0) \
  43.     { \
  44.         strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
  45.         TObject::destroy(rsc); \
  46.         exit(1); \
  47.     } \
  48.     rsc->put(a,c); \
  49.     TObject::destroy(a)
  50. #else
  51. #define WriteResource(a,b,c) \
  52.     cout << c << endl; \
  53.     a = b(); \
  54.     if( a == 0 ) \
  55.     { \
  56.         cout << endl << RSC_FILENAME << ": Creation failure" << endl; \
  57.         TObject::destroy(rsc); \
  58.         exit(1); \
  59.     } \
  60.     rsc->put(a,c); \
  61.     TObject::destroy(a)
  62.  
  63. #define WriteObject(a,c) \
  64.     cout << c << endl; \
  65.     if(a == 0) \
  66.     { \
  67.         cout << endl << RSC_FILENAME << ": Creation failure" << endl; \
  68.         TObject::destroy(rsc); \
  69.         exit(1); \
  70.     } \
  71.     rsc->put(a,c); \
  72.     TObject::destroy(a)
  73. #endif
  74.  
  75. #include <conio.h>
  76. #include <dir.h>
  77. #include <io.h>
  78. #include <stdio.h>
  79. #include <stdlib.h>
  80. #include <string.h>
  81. #include <time.h>
  82.  
  83. #define Uses_TButton
  84. #define Uses_TCheckBoxes
  85. #define Uses_TColorDialog
  86. #define Uses_TColorGroup
  87. #define Uses_TColorItem
  88. #define Uses_TDialog
  89. #define Uses_THistory
  90. #define Uses_TInputLine
  91. #define Uses_TKeys
  92. #define Uses_TLabel
  93. #define Uses_TMenuBar
  94. #define Uses_TMenuItem
  95. #define Uses_TRadioButtons
  96. #define Uses_TRect
  97. #define Uses_TResourceFile
  98. #define Uses_TScreen
  99. #define Uses_TScrollBar
  100. #define Uses_TSItem
  101. #define Uses_TStaticText
  102. #define Uses_TStatusDef
  103. #define Uses_TStatusItem
  104. #define Uses_TStatusLine
  105. #define Uses_TSubMenu
  106. #define Uses_TVCOLR             // Use this if you modified the TV.H file.
  107. #define Uses_fpstream
  108. #include <tv.h>
  109.  
  110. #if !defined(cpDefSize)
  111. // Use this if you chose not to modify the Turbo Vision files.
  112. #include <tvcolr.h>
  113. #endif
  114.  
  115. #define Uses_TVMIndicator
  116. #define Uses_TVMScrollBar
  117. #define Uses_TVMEditor
  118. #define Uses_TVMFileEditor
  119. #define Uses_TVMMemo
  120. #include <tvmedit.h>
  121.  
  122. #define Uses_TInteger
  123. #define Uses_TFilename
  124. #include <tintfile.h>
  125.  
  126. #include <tmsgview.h>
  127.  
  128. #include "link.h"           // Resource file link definitions
  129. #include "tvedit.h"         // Demo header file
  130.  
  131. // ============================================================================
  132. TDialog *Colors(void);
  133. TDialog *AboutBox(void);
  134.  
  135. TDialog *createStartUpDialog(void);
  136. TDialog *createLclEdOptDialog(void);
  137. TDialog *createDefEdOptDialog(void);
  138. TDialog *createFindDialog(void);
  139. TDialog *createReplaceDialog(void);
  140.  
  141. TDialog *createMemoDemoDialog(void);
  142. TDialog *createKeyHelpDialog(void);
  143.  
  144. TMenuBar *initMenuBar(void);
  145. TStatusLine *initStatusLine(void);
  146.  
  147. // ============================================================================
  148.  
  149. fpstream *s;
  150. TResourceFile* rsc;
  151.  
  152. // ============================================================================
  153.  
  154. // The exit function is no longer needed in the TV 2.0 version due to
  155. // the new TScreen::clearOnSuspend data member.
  156. #if _TV_VERSION == 0x0103
  157.  
  158. char endString[255] = "";
  159.  
  160. void exitfunc(void)
  161. {
  162.    cout << endl << endString << endl;
  163. }
  164.  
  165. #pragma exit exitfunc 31
  166.  
  167. #endif
  168.  
  169. void main(void)
  170. {
  171.     TDialog *dlg;
  172.     TMenuBar *menuBar;
  173.     TStatusLine *statusLine;
  174.  
  175. #if _TV_VERSION != 0x0103
  176.     // Prevent the screen from being cleared on exit.
  177.     TScreen::clearOnSuspend = False;
  178. #endif
  179.  
  180.     cout << "Creating " RSC_FILENAME << endl;
  181.  
  182.     // Construct stream and resource file.
  183.     s = new fpstream (RSC_FILENAME, ios::trunc | ios::binary);
  184.     rsc = new TResourceFile(s);
  185.  
  186.     // Create all of the necessary dialogs for the demo.
  187.     WriteResource(dlg, AboutBox, "AboutBox");
  188.     WriteResource(dlg, Colors, "ColorDlg");
  189.     WriteResource(dlg, createStartUpDialog, "StartUpDlg");
  190.     WriteResource(dlg, createLclEdOptDialog, "LclEdOptDlg");
  191.     WriteResource(dlg, createDefEdOptDialog, "DefEdOptDlg");
  192.     WriteResource(dlg, createFindDialog, "FindDialog");
  193.     WriteResource(dlg, createReplaceDialog, "ReplaceDialog");
  194.     WriteResource(dlg, createMemoDemoDialog, "MemoDemo");
  195.     WriteResource(dlg, createKeyHelpDialog, "KeyHelp");
  196.  
  197.     // Create the menus and status line.
  198.     WriteResource(menuBar, initMenuBar, "MenuBar");
  199.     WriteResource(statusLine, initStatusLine, "StatusLine");
  200.  
  201.     TObject::destroy(rsc);
  202.  
  203. #if _TV_VERSION == 0x0103
  204.     strcpy(endString, RSC_FILENAME ": Creation completed.");
  205. #else
  206.     cout << endl << RSC_FILENAME << ": Creation completed." << endl;
  207. #endif
  208.  
  209.     exit(0);
  210. }
  211.  
  212. // ============================================================================
  213. TDialog *AboutBox(void)
  214. {
  215.     TDialog *aboutBox = new TDialog(TRect(0, 0, 46, 11), "About");
  216.     aboutBox->options |= ofCentered;
  217.  
  218.     aboutBox->insert(new TStaticText(TRect(1, 2, 45, 8),
  219.         "\003TVMEditor 2.00 Class Library\n"
  220.         "\003Virtual Memory Text Editor Demo\n \n"
  221.         "\003(c) 1994 Eric Woodruff\n\003CIS ID: 72134,1150"));
  222.  
  223.     TButton *b = new TButton(TRect(11,8,23,10), "O~K~", cmOK, bfDefault);
  224.     b->options |= ofCenterX;
  225.     aboutBox->insert(b);
  226.  
  227.     return aboutBox;
  228. }
  229.  
  230. TDialog *Colors(void)
  231. {
  232.     TColorGroup &group1 =
  233.         *new TColorGroup("Desktop") +
  234.             *new TColorItem("Background",        1)+
  235.  
  236.         *new TColorGroup("Menus") +
  237.             *new TColorItem("Normal text",       2)+
  238.             *new TColorItem("Disabled text",     3)+
  239.             *new TColorItem("Shortcut key",      4)+
  240.             *new TColorItem("Selection bar",     5)+
  241.             *new TColorItem("Selected disabled", 6)+
  242.             *new TColorItem("Shortcut selected", 7);
  243.  
  244.     TColorGroup &group2 =
  245. //        *new TColorGroup("Blue Window") +
  246.         *new TColorGroup("Edit Window") +
  247.             *new TColorItem("Frame inactive",    8)+
  248.             *new TColorItem("Frame active",      9)+
  249.             *new TColorItem("Frame icons",      10)+
  250.             *new TColorItem("Scrollbar page",   11)+
  251.             *new TColorItem("Scrollbar icons",  12)+
  252.             *new TColorItem("Normal text",      13)+
  253.             *new TColorItem("Selected text",    14)+
  254.  
  255. //          *new TColorGroup("Error Tracking") +
  256.           *new TColorGroup("Line Tracking") +
  257.             *new TColorItem("Frame inactive",  cMsgFramePassive)+  // Extended
  258.             *new TColorItem("Frame active",    cMsgFrameActive)+   // Extended
  259.             *new TColorItem("Frame icons",     cMsgFrameIcon)+     // Extended
  260.             *new TColorItem("Scrollbar page",  cMsgSBPage)+        // Extended
  261.             *new TColorItem("Scrollbar icons", cMsgSBCtrl)+        // Extended
  262.             *new TColorItem("Normal text",     cMsgNText)+         // Extended
  263.             *new TColorItem("Focused text",    cMsgSText)+         // Extended
  264.             *new TColorItem("Selected text",   cMsgSelected);      // Extended
  265.  
  266.     TColorGroup &group3 =
  267.         *new TColorGroup("Edit Indicator") +
  268.             *new TColorItem("Edit Window",      cIndEditWin)+   // Extended
  269.             *new TColorItem("Memo Field",       cIndMemoFld)+   // Extended
  270.  
  271. //        *new TColorGroup("Gray Dialog Box") +
  272.         *new TColorGroup("Dialog Box") +
  273.             *new TColorItem("Frame inactive",   32)+
  274.             *new TColorItem("Frame active",     33)+
  275.             *new TColorItem("Frame icons",      34)+
  276.             *new TColorItem("Scrollbar page",   35)+
  277.             *new TColorItem("Scrollbar icons",  36)+
  278.  
  279.             // The last four text colors are only available when using the
  280.             // TColorText class from TVCOLR.ZIP/TVCLR2.ZIP.
  281.             *new TColorItem("Normal text",       37)+
  282.             *new TColorItem("Information",  cCTxtInfoColor)+    // Extended
  283.             *new TColorItem("Notification", cCTxtNotifyColor)+  // Extended
  284.             *new TColorItem("Warning",      cCTxtWarnColor)+    // Extended
  285.             *new TColorItem("Error",        cCTxtErrorColor)+   // Extended
  286.  
  287.         // Selected Shortcut is only applicable if you made the
  288.         // changes described in COLUPDT.DOC in TVCOLR.ZIP/TVCLR2.ZIP.
  289.             *new TColorItem("Normal label",            38)+
  290.             *new TColorItem("Selected label",          39)+
  291.             *new TColorItem("Label shortcut key",      40)+
  292. #ifdef MODIFIED_TV_COLORS
  293.     #if _TV_VERSION == 0x0103
  294.             *new TColorItem("Selected shortcut", 66)+   // Added by me - TV 1.03 location
  295.     #else
  296.             *new TColorItem("Selected label shortcut key", 138)+  // Same, but TV 2.0 location
  297.     #endif
  298. #endif
  299.  
  300.         // Default and Selected Shortcut are only applicable if you made
  301.         // the changes described in COLUPDT.DOC in TVCOLR.ZIP/TVCLR2.ZIP
  302.             *new TColorItem("Normal button",            41)+
  303.             *new TColorItem("Default button",           42)+
  304.             *new TColorItem("Selected button",          43)+
  305.             *new TColorItem("Disabled button",          44)+
  306.             *new TColorItem("Button shortcut key",      45)+
  307. #ifdef MODIFIED_TV_COLORS
  308.     #if _TV_VERSION == 0x0103
  309.             *new TColorItem("Default shortcut",  64)+   // Added by me - TV 1.03 location
  310.             *new TColorItem("Selected shortcut", 65)+
  311.     #else
  312.             *new TColorItem("Default button shortcut key",  136)+ // Same, but TV 2.0 location
  313.             *new TColorItem("Selected button shortcut key", 137)+
  314.     #endif
  315. #endif
  316.             *new TColorItem("Button shadow",            46)+
  317.  
  318.             *new TColorItem("Cluster normal",    47)+
  319.             *new TColorItem("Cluster selected",  48)+
  320.             *new TColorItem("Cluster shortcut",  49)+
  321.  
  322.             *new TColorItem("Input line normal",    50)+
  323.             *new TColorItem("Input line selected",  51)+
  324.             *new TColorItem("Input line arrow",     52)+
  325.             *new TColorItem("History button",       53)+
  326.             *new TColorItem("History sides",        54)+
  327.             *new TColorItem("History scrollbar",    55)+
  328.             *new TColorItem("History icons",        56)+
  329.  
  330.             *new TColorItem("Normal list item",     57)+
  331.             *new TColorItem("Focused list item",    58)+
  332.             *new TColorItem("Selected list item",   59)+
  333.             *new TColorItem("List divider",         60)+
  334.             *new TColorItem("Information pane",     61);
  335.  
  336.     TColorGroup &group4 =
  337.         *new TColorGroup("Help Window") +
  338. #if _TV_VERSION == 0x0103
  339.     #ifdef MODIFIED_TV_COLORS
  340.             *new TColorItem("Frame inactive",   67)+        // TV 1.03 locations after
  341.             *new TColorItem("Frame active",     68)+        // TVCOLR/TVCLR2.ZIP modifications.
  342.             *new TColorItem("Frame icons",      69)+
  343.             *new TColorItem("Scrollbar page",   70)+
  344.             *new TColorItem("Scrollbar icons",  71)+
  345.             *new TColorItem("Normal text",      72)+
  346.             *new TColorItem("Keyword",          73)+
  347.             *new TColorItem("Selected keyword", 74);
  348.     #else
  349.             *new TColorItem("Frame inactive",   64)+        // Standard unmodified TV 1.03
  350.             *new TColorItem("Frame active",     65)+        // locations.
  351.             *new TColorItem("Frame icons",      66)+
  352.             *new TColorItem("Scrollbar page",   67)+
  353.             *new TColorItem("Scrollbar icons",  68)+
  354.             *new TColorItem("Normal text",      69)+
  355.             *new TColorItem("Keyword",          70)+
  356.             *new TColorItem("Selected keyword", 71);
  357.     #endif
  358. #else
  359.             *new TColorItem("Frame inactive",   128)+       // The help colors are a part
  360.             *new TColorItem("Frame active",     129)+       // of the base palette in
  361.             *new TColorItem("Frame icons",      130)+       // TV 2.0.  These are the standard
  362.             *new TColorItem("Scrollbar page",   131)+       // unmodified locations.
  363.             *new TColorItem("Scrollbar icons",  132)+
  364.             *new TColorItem("Normal text",      133)+
  365.             *new TColorItem("Keyword",          134)+
  366.             *new TColorItem("Selected keyword", 135);
  367. #endif
  368.  
  369.     TColorGroup &All = group1 + group2 + group3 + group4;
  370.  
  371.     // See the notes in handleEvent() about the proper usage of TColorDialog.
  372.     TColorDialog *c = new TColorDialog((TPalette*)0, &All);
  373.  
  374.     return c;
  375. }
  376.  
  377. TMenuBar *initMenuBar(void)
  378. {
  379.     TSubMenu& MiscMenu = *new TSubMenu( "~\xF0~", 0) +
  380.         *new TMenuItem( "~A~bout...", cmAbout, kbNoKey)+
  381.         *new TMenuItem( "~R~epaint desktop", cmRepaint, kbNoKey);
  382.  
  383.     TSubMenu& FileMenu = *new TSubMenu("~F~ile", 0) +
  384.         *new TMenuItem("~N~ew", cmNew, kbNoKey) +
  385.         *new TMenuItem("~O~pen...", cmOpen, kbF3, hcNoContext, "F3") +
  386.         *new TMenuItem("~S~ave", cmSave, kbF2, hcNoContext, "F2") +
  387.         *new TMenuItem("S~a~ve as...", cmSaveAs, kbNoKey) +
  388.         *new TMenuItem("Save a~l~l", cmSaveAll, kbNoKey) +
  389.             newLine() +
  390.         *new TMenuItem("~C~hange dir...", cmChDir, kbNoKey)+
  391.         *new TMenuItem("~P~rint", cmPrintFile, kbNoKey) +
  392.         *new TMenuItem( "~D~OS shell", cmDosShell, kbNoKey) +
  393.             newLine() +
  394.         *new TMenuItem( "~Q~uit", cmQuit, kbAltX, hcNoContext, "Alt+X" );
  395.  
  396.     TSubMenu& EditMenu = *new TSubMenu("~E~dit", 0) +
  397.         *new TMenuItem("~U~ndo", cmUndo, kbAltMinus, hcNoContext, "Alt -" ) +
  398.         *new TMenuItem("~R~edo", cmRedo, kbAltEqual, hcNoContext, "Alt =" ) +
  399.             newLine() +
  400.         *new TMenuItem("Cu~t~", cmCut, kbShiftDel, hcNoContext, "Shift+Del") +
  401.         *new TMenuItem("~C~opy", cmCopy, kbCtrlIns, hcNoContext, "Ctrl+Ins") +
  402.         *new TMenuItem("~P~aste", cmPaste, kbShiftIns, hcNoContext, "Shift+Ins") +
  403.         *new TMenuItem("C~l~ear", cmClear, kbCtrlDel, hcNoContext, "Ctrl+Del")+
  404.             newLine() +
  405.         *new TMenuItem("~S~how clipboard", cmShowClip, kbNoKey);
  406.  
  407.     TSubMenu& SearchMenu = *new TSubMenu("~S~earch", 0) +
  408.         *new TMenuItem("~F~ind...", cmFind, kbNoKey) +
  409.         *new TMenuItem("~R~eplace...", cmReplace, kbNoKey) +
  410.         *new TMenuItem("~S~earch again", cmSearchAgain, kbCtrlL, hcNoContext, "Ctrl+L")+
  411.             newLine() +
  412.         *new TMenuItem("~G~o to line number...", cmGotoLine, kbNoKey)+
  413.         *new TMenuItem("~P~revious Message", cmPrevMsg, kbAltF7, hcNoContext, "Alt+F7")+
  414.         *new TMenuItem("~N~ext Message", cmNextMsg, kbAltF8, hcNoContext, "Alt+F8");
  415.  
  416.     TSubMenu& WindowMenu = *new TSubMenu( "~W~indows", 0) +
  417.         *new TMenuItem( "~S~ize/Move", cmResize, kbCtrlF5, hcNoContext, "Ctrl+F5" ) +
  418.         *new TMenuItem( "~Z~oom", cmZoom, kbF5, hcNoContext, "F5" ) +
  419.         *new TMenuItem( "C~a~scade", cmCascade, kbNoKey) +
  420.         *new TMenuItem( "~T~ile", cmTile, kbNoKey) +
  421.         *new TMenuItem( "Ne~x~t", cmNext, kbF6, hcNoContext, "F6" ) +
  422.         *new TMenuItem( "~P~revious", cmPrev, kbShiftF6, hcNoContext, "Shift+F6" ) +
  423.         *new TMenuItem( "~C~lose", cmClose, kbAltF3, hcNoContext, "Alt+F3" ) +
  424.         *new TMenuItem( "Clos~e~ all", cmCloseAll, kbNoKey) +
  425.             newLine() +
  426.         *new TMenuItem( "To~g~gle Screen Size", cmScreenSize, kbNoKey) +
  427.         *new TMenuItem( "~U~ser screen", cmUserScreen, kbAltF5, hcNoContext, "Alt+F5");
  428.  
  429.     TSubMenu& OptionsMenu = *new TSubMenu("~O~ptions", 0) +
  430.         *new TMenuItem("S~t~art up options...", cmStartUpOpt, kbNoKey)+
  431.             newLine()+
  432.         *new TMenuItem("~D~efault editor options...", cmDefaultEditorOpt, kbNoKey)+
  433.         *new TMenuItem("C~u~rrent editor options...", cmLocalEditorOpt, kbF8, hcNoContext, "F8")+
  434.             newLine()+
  435.         *new TMenuItem( "~C~olors...", cmColors, kbNoKey ) +
  436.         *new TMenuItem( "C~h~ange palettes", cmChangePalettes, kbNoKey ) +
  437.             newLine() +
  438.         *new TMenuItem( "~L~oad configuration...", cmLoadCfg, kbNoKey) +
  439.         *new TMenuItem( "~S~ave configuration...", cmSaveCfg, kbNoKey) +
  440.             newLine()+
  441.         *new TMenuItem("~R~ecord macro...", cmRecord, kbAltR, hcNoContext, "Alt+R")+
  442.         *new TMenuItem("~P~lay macro...", cmPlay, kbAltP, hcNoContext, "Alt+P");
  443.  
  444.     TSubMenu& MemoMenu = *new TSubMenu( "~D~emo", 0) +
  445.         *new TMenuItem( "~M~essage viewer demo", cmMsgViewer, kbNoKey)+
  446.             newLine()+
  447.         *new TMenuItem( "~R~eplace key maps", cmReplaceKeyMaps, kbNoKey)+
  448.             newLine()+
  449.         *new TMenuItem( "M~e~mo demo dialog...", cmMemoDemo, kbNoKey)+
  450.         *new TMenuItem( "~K~ey definition list", cmKeyHelp, kbF1, hcNoContext, "F1");
  451.  
  452.     return new TMenuBar(TRect(0, 0, 80, 1), MiscMenu + FileMenu + EditMenu +
  453.         SearchMenu + WindowMenu + OptionsMenu + MemoMenu);
  454. }
  455.  
  456. TStatusLine *initStatusLine(void)
  457. {
  458.     return new TStatusLine( TRect(0, 24, 80, 25),
  459.       *new TStatusDef( 0, 0xFFFF ) +
  460.         *new TStatusItem("~F1~ Help", kbF1, cmKeyHelp) +
  461.         *new TStatusItem("~F2~ Save", kbF2, cmSave) +
  462.         *new TStatusItem("~F3~ Open", kbF3, cmOpen) +
  463.         *new TStatusItem("~Alt+F3~ Close", kbAltF3, cmClose) +
  464.         *new TStatusItem("~F5~ Zoom", kbF5, cmZoom) +
  465.         *new TStatusItem("~F6~ Next", kbF6, cmNext) +
  466.  
  467.         // If this one isn't on the status line, modal dialogs won't handle
  468.         // the event.  When present, you can edit the local options for
  469.         // any dialog box memo field.  Another way would be to derive a new
  470.         // TDialog class and override it's handleEvent() to call
  471.         // editorDialog() when a button is pushed for this event, etc.
  472.         *new TStatusItem("~F8~ Lcl Opt", kbF8, cmLocalEditorOpt) +
  473.  
  474.         *new TStatusItem(0, kbF10, cmMenu));
  475. }
  476.  
  477. TDialog *createFindDialog(void)
  478. {
  479.     TDialog *d = new TDialog(TRect(0,0,54,16), "Find");
  480.  
  481.     d->options |= ofCentered;
  482.  
  483.     TInputLine *i = new TInputLine(TRect(16,2,49,3), 80);
  484.     d->insert(i);
  485.     d->insert(new TLabel(TRect(2,2,15,3), "~T~ext to find", i));
  486.     d->insert(new THistory(TRect(49,2,52,3), i, 10));
  487.  
  488.     TCheckBoxes *b = new TCheckBoxes(TRect(3,5,27,7),
  489.         new TSItem("~C~ase sensitive",
  490.         new TSItem("~W~hole words only", 0)));
  491.     d->insert(b);
  492.  
  493.     d->insert(new TLabel(TRect(3,4,12,5), "~O~ptions", b));
  494.  
  495.     TRadioButtons *r = new TRadioButtons(TRect(32,5,51,7),
  496.         new TSItem("~F~orward",
  497.         new TSItem("~B~ackward", 0)));
  498.     d->insert(r);
  499.     d->insert(new TLabel(TRect(32,4,42,5), "~D~irection", r));
  500.  
  501.     r = new TRadioButtons(TRect(3,10,27,12),
  502.         new TSItem("~G~lobal",
  503.         new TSItem("~S~elected text", 0)));
  504.     d->insert(r);
  505.     d->insert(new TLabel(TRect(3,9,9,10), "~S~cope", r));
  506.  
  507.     r = new TRadioButtons(TRect(32,10,51,12),
  508.         new TSItem("~F~rom cursor",
  509.         new TSItem("~E~ntire scope", 0)));
  510.     d->insert(r);
  511.     d->insert(new TLabel(TRect(32,9,42,10), "~O~rigin", r));
  512.  
  513.     d->insert(new TButton(TRect(12,13,22,15), "O~K~", cmOK, bfDefault));
  514.     d->insert(new TButton(TRect(28,13,40,15), "Cancel", cmCancel, bfNormal));
  515.  
  516.     d->selectNext(False);
  517.  
  518.     return d;
  519. }
  520.  
  521. TDialog *createReplaceDialog(void)
  522. {
  523.     TDialog *d = new TDialog(TRect(0,0,54,18), "Replace");
  524.  
  525.     d->options |= ofCentered;
  526.  
  527.     TInputLine *i = new TInputLine(TRect(16,2,49,3), 80);
  528.     d->insert(i);
  529.     d->insert(new TLabel(TRect(2,2,15,3), "~T~ext to find", i));
  530.     d->insert(new THistory(TRect(49,2,52,3), i, 10));
  531.  
  532.     i = new TInputLine(TRect(16,4,49,5), 80);
  533.     d->insert(i);
  534.     d->insert(new TLabel(TRect(6,4,15,5), "~N~ew text", i));
  535.     d->insert(new THistory(TRect(49,4,52,5), i, 11));
  536.  
  537.     TCheckBoxes *b = new TCheckBoxes(TRect(3,7,27,10),
  538.         new TSItem("~C~ase sensitive",
  539.         new TSItem("~W~hole words only",
  540.         new TSItem("~P~rompt on replace", 0))));
  541.     d->insert(b);
  542.     d->insert(new TLabel(TRect(3,6,12,7), "~O~ptions", b));
  543.  
  544.     TRadioButtons *r = new TRadioButtons(TRect(32,7,51,9),
  545.         new TSItem("~F~orward",
  546.         new TSItem("~B~ackward", 0)));
  547.     d->insert(r);
  548.     d->insert(new TLabel(TRect(32,6,42,7), "~D~irection", r));
  549.  
  550.     r = new TRadioButtons(TRect(3,12,27,14),
  551.         new TSItem("~G~lobal",
  552.         new TSItem("~S~elected text", 0)));
  553.     d->insert(r);
  554.     d->insert(new TLabel(TRect(3,11,9,12), "~S~cope", r));
  555.  
  556.     r = new TRadioButtons(TRect(32,12,51,14),
  557.         new TSItem("~F~rom cursor",
  558.         new TSItem("~E~ntire scope", 0)));
  559.     d->insert(r);
  560.     d->insert(new TLabel(TRect(32,11,42,12), "~O~rigin", r));
  561.  
  562.     // NOTE:  If the Replace Dialog returns cmYes, *ALL* occurances will
  563.     //        be replaced, not just the first one.  This was easier than
  564.     //        using a new command and deriving a dialog box class that
  565.     //        could return a non-standard value.  The TVMEditor classes
  566.     //        will look specifically for cmYes to enable the Change All
  567.     //        option for search and replace operations.  If cmOK is
  568.     //        returned, only the first occurance is replaced.
  569.     //
  570.     d->insert(new TButton(TRect( 7,15,17,17), "O~K~", cmOK, bfDefault));
  571.     d->insert(new TButton(TRect(19,15,35,17), "Change ~A~ll", cmYes, bfNormal));
  572.     d->insert(new TButton(TRect(37,15,47,17), "Cancel", cmCancel, bfNormal));
  573.  
  574.     d->selectNext(False);
  575.  
  576.     return d;
  577. }
  578.  
  579. TDialog *createDefEdOptDialog(void)
  580. {
  581.     TDialog *dlg = new TDialog(TRect(1,0,79,23), "Default Editor Options");
  582.     if(!dlg)
  583.         return NULL;
  584.  
  585.     dlg->options = ofCentered;
  586.  
  587.     TCheckBoxes *b = new TCheckBoxes(TRect(3,3,32,13),
  588.         new TSItem("~I~nsert mode",
  589.         new TSItem("~A~uto indent mode",
  590.         new TSItem("W~o~rd wrap mode",
  591.         new TSItem("Keep trai~l~ing spaces",
  592.         new TSItem("~U~se tab character",
  593.         new TSItem("Ca~n~ undo/redo",
  594.         new TSItem("E~x~pand tabs on load",
  595.         new TSItem("Create backup ~f~iles",
  596.         new TSItem("Use LF only when sa~v~ed",
  597.         new TSItem("Text is ~r~ead only", 0)))))))))));
  598.     dlg->insert(b);
  599.     dlg->insert(new TLabel(TRect(3,2,32,3), "General Options", b));
  600.  
  601.     b = new TCheckBoxes(TRect(5,15,30,17),
  602.         new TSItem("~(~)",
  603.         new TSItem("~[~]",
  604.         new TSItem("~{~}",
  605.         new TSItem("~'~'",
  606.         new TSItem("~\"~\"",
  607.         new TSItem("~<~>", 0)))))));
  608.     dlg->insert(b);
  609.     dlg->insert(new TLabel(TRect(5,14,30,15), "Enter Matching", b));
  610.  
  611.     TInteger *i = new TInteger(TRect(22,18,27,19), 3, 16, 2);
  612.     dlg->insert(i);
  613.     dlg->insert(new TLabel(TRect(11,18,21,19), "~T~ab size:", i));
  614.  
  615.     i = new TInteger(TRect(22,19,27,20), 3, 16, 1);
  616.     dlg->insert(i);
  617.     dlg->insert(new TLabel(TRect(8,19,21,20), "Indent si~z~e:", i));
  618.  
  619.     i = new TInteger(TRect(22,20,27,21), 4, 250, 20);
  620.     dlg->insert(i);
  621.     dlg->insert(new TLabel(TRect(7,20,21,21), "Rig~h~t margin:", i));
  622.  
  623.     b = new TCheckBoxes(TRect(40,3,69,6),
  624.         new TSItem("~C~ase sensitive",
  625.         new TSItem("~W~hole words only",
  626.         new TSItem("~P~rompt on replace", 0))));
  627.     dlg->insert(b);
  628.     dlg->insert(new TLabel(TRect(40,2,69,3), "Search/Replace Options", b));
  629.  
  630.     i = new TInteger(TRect(62, 7, 69, 8), 6, 32767, 0);
  631.     dlg->insert(i);
  632.     dlg->insert(new TLabel(TRect(34, 7, 61, 8), "~S~tart Signs of Life after:", i));
  633.     dlg->insert(new TStaticText(TRect(70, 7, 75, 8), "lines"));
  634.  
  635.     i = new TInteger(TRect(62, 8, 69, 9), 6, 32767, 0);
  636.     dlg->insert(i);
  637.     dlg->insert(new TLabel(TRect(34, 8, 61, 9), "After start, update ever~y~:", i));
  638.     dlg->insert(new TStaticText(TRect(70, 8, 75, 9), "lines"));
  639.  
  640.     TFilename *s = new TFilename(TRect(62,10,67,11), 4);
  641.     dlg->insert(s);
  642.     dlg->insert(new TLabel(TRect(42,10,61,11), "~D~efault extension:", s));
  643.  
  644.     s = new TFilename(TRect(62,11,67,12), 4);
  645.     dlg->insert(s);
  646.     dlg->insert(new TLabel(TRect(43,11,61,12), "~B~ackup extension:", s));
  647.  
  648.     s = new TFilename(TRect(34,14,75,15), MAXPATH);
  649.     dlg->insert(s);
  650.     dlg->insert(new TLabel(TRect(34,13,75,14), "~E~ditor swap file path:", s));
  651.  
  652.     s = new TFilename(TRect(34, 17, 75, 18), MAXPATH);
  653.     dlg->insert(s);
  654.     dlg->insert(new TLabel(TRect(34, 16, 75, 17), "Printin~g~ Device:", s));
  655.  
  656.     dlg->insert(new TButton(TRect(44,20,54,22), "O~K~", cmOK, bfDefault));
  657.     dlg->insert(new TButton(TRect(61,20,71,22), "Cancel", cmCancel, bfNormal));
  658.  
  659.     dlg->selectNext(False);
  660.     return dlg;
  661. }
  662.  
  663. TDialog *createStartUpDialog(void)
  664. {
  665. #if !defined(__DPMI16__) && !defined(__DPMI32__)
  666.     TDialog *dlg = new TDialog(TRect(17,2,62,20), "Start Up Options");
  667.     if(!dlg)
  668.         return NULL;
  669.  
  670.     dlg->options = ofCentered;
  671.  
  672.     TCheckBoxes *ck = new TCheckBoxes(TRect(4,3,41,5),
  673.         new TSItem("~I~ndicator at top of edit window",
  674.         new TSItem("Sa~v~e desktop on exit", 0)));
  675.     dlg->insert(ck);
  676.     dlg->insert(new TLabel(TRect(4,2,41,3), "Miscellaneous", ck));
  677.  
  678.     TRadioButtons *rb = new TRadioButtons(TRect(9,7,36,12),
  679.         new TSItem("Check for ~E~MS first",
  680.         new TSItem("Check for ~X~MS first",
  681.         new TSItem("Check for E~M~S only",
  682.         new TSItem("Check for XM~S~ only",
  683.         new TSItem("Use ~d~isk only", 0))))));
  684.     dlg->insert(rb);
  685.     dlg->insert(new TLabel(TRect(9,6,36,7), "Virtual Memory Preference", rb));
  686.  
  687.     TInteger *nm = new TInteger(TRect(28,13,32,14), 3, 60, 4);
  688.     dlg->insert(nm);
  689.     dlg->insert(new TLabel(TRect(2,13,27,14), "~B~uffer size for editors:", nm));
  690.     dlg->insert(new TStaticText(TRect(33,13,41,14), "(Kbytes)"));
  691.  
  692.     dlg->insert(new TButton(TRect(6,15,16,17), "O~K~", cmOK, bfDefault));
  693.     dlg->insert(new TButton(TRect(28,15,38,17), "Cancel", cmCancel, bfNormal));
  694. #else
  695.     TDialog* dlg = new TDialog(TRect(9, 5, 70, 17), "Start Up Options");
  696.     if(!dlg)
  697.         return NULL;
  698.  
  699.     dlg->options |= ofCentered;
  700.  
  701.     TCheckBoxes *ck = new TCheckBoxes(TRect(12, 3, 49, 5),
  702.         new TSItem("~I~ndicator at top of edit window",
  703.         new TSItem("Sa~v~e desktop on exit", 0)));
  704.     dlg->insert(ck);
  705.     dlg->insert(new TLabel(TRect(12, 2, 49, 3), "Miscellaneous", ck));
  706.  
  707.     TInteger *nm = new TInteger(TRect(42, 6, 46, 7), 3, 60, 4);
  708.     dlg->insert(nm);
  709.     dlg->insert(new TLabel(TRect(16, 6, 41, 7), "~B~uffer size for editors:",
  710.         nm));
  711.     dlg->insert(new TStaticText(TRect(48, 6, 56, 7), "(Kbytes)"));
  712.  
  713.     nm = new TInteger(TRect(42, 7, 49, 8), 6, 32767, 60);
  714.     dlg->insert(nm);
  715.     dlg->insert(new TLabel(TRect(2, 7, 41, 8),
  716.         "~M~aximum allocatable memory per editor:", nm));
  717.     dlg->insert(new TStaticText(TRect(50, 7, 58, 8), "(KBytes)"));
  718.  
  719.     dlg->insert(new TButton(TRect(9, 9, 19, 11), "O~K~", cmOK, bfDefault));
  720.     dlg->insert(new TButton(TRect(42, 9, 52, 11), "Cancel", cmCancel, bfNormal));
  721.  
  722. #endif
  723.  
  724.     dlg->selectNext(False);
  725.     return dlg;
  726. }
  727.  
  728. TDialog *createLclEdOptDialog(void)
  729. {
  730.     TDialog *dlg = new TDialog(TRect(9,5,71,18), "Current Editor Options");
  731.     if(!dlg)
  732.         return NULL;
  733.  
  734.     dlg->options = ofCentered;
  735.  
  736.     TCheckBoxes *b = new TCheckBoxes(TRect(3,3,32,9),
  737.         new TSItem("~I~nsert mode",
  738.         new TSItem("~A~uto indent mode",
  739.         new TSItem("W~o~rd wrap mode",
  740.         new TSItem("Keep trai~l~ing spaces",
  741.         new TSItem("~U~se tab character",
  742.         new TSItem("Ca~n~ undo/redo", 0)))))));
  743.     dlg->insert(b);
  744.     dlg->insert(new TLabel(TRect(3,2,32,3), "General Options", b));
  745.  
  746.     b = new TCheckBoxes(TRect(34,3,59,5),
  747.         new TSItem("~(~)",
  748.         new TSItem("~[~]",
  749.         new TSItem("~{~}",
  750.         new TSItem("~'~'",
  751.         new TSItem("~\"~\"",
  752.         new TSItem("~<~>", 0)))))));
  753.     dlg->insert(b);
  754.     dlg->insert(new TLabel(TRect(34,2,59,3), "Enter Matching", b));
  755.  
  756.     TInteger *i = new TInteger(TRect(51,6,56,7), 3, 16, 2);
  757.     dlg->insert(i);
  758.     dlg->insert(new TLabel(TRect(40,6,50,7), "~T~ab size:", i));
  759.  
  760.     i = new TInteger(TRect(51,7,56,8), 3, 16, 1);
  761.     dlg->insert(i);
  762.     dlg->insert(new TLabel(TRect(37,7,50,8), "Indent si~z~e:", i));
  763.  
  764.     i = new TInteger(TRect(51,8,56,9), 4, 250, 20);
  765.     dlg->insert(i);
  766.     dlg->insert(new TLabel(TRect(36,8,50,9), "Rig~h~t margin:", i));
  767.  
  768.     dlg->insert(new TButton(TRect(16,10,26,12), "O~K~", cmOK, bfDefault));
  769.     dlg->insert(new TButton(TRect(35,10,45,12), "Cancel", cmCancel, bfNormal));
  770.  
  771.     dlg->selectNext(False);
  772.     return dlg;
  773. }
  774.  
  775. TDialog *createMemoDemoDialog(void)
  776. {
  777.     TDialog *dlg = new TDialog(TRect(1,2,79,21), "TVMMemo Demo");
  778.     if(!dlg)
  779.         return NULL;
  780.  
  781.     dlg->options |= ofCentered;
  782.  
  783.     TScrollBar *hsbar = new TScrollBar(TRect(16,7,75,8));
  784.     dlg->insert(hsbar);
  785.  
  786.     TVMScrollBar *vsbar = new TVMScrollBar(TRect(75,3,76,7));
  787.     dlg->insert(vsbar);
  788.  
  789.     // Note that the indicator is shortened and will only display the
  790.     // modified flag and cursor position.
  791.     TVMIndicator *ind = new TVMIndicator(TRect(2,7,16,8));
  792.     dlg->insert(ind);
  793.  
  794.     TVMMemo *memo = new TVMMemo(TRect(2,3,75,7), hsbar, vsbar, ind, 4);
  795. //    memo->setOption(efCanUndo, False);
  796.     dlg->insert(memo);
  797.     dlg->insert(new TLabel(TRect(2,2,75,3), "Memo field #1", memo));
  798.  
  799.     hsbar = new TScrollBar(TRect(16,14,75,15));
  800.     dlg->insert(hsbar);
  801.  
  802.     vsbar = new TVMScrollBar(TRect(75,10,76,14));
  803.     dlg->insert(vsbar);
  804.  
  805.     ind = new TVMIndicator(TRect(2,14,16,15));
  806.     dlg->insert(ind);
  807.  
  808.     memo = new TVMMemo(TRect(2,10,75,14), hsbar, vsbar, ind, 4);
  809. //    memo->setOption(efCanUndo, False);
  810.     dlg->insert(memo);
  811.     dlg->insert(new TLabel(TRect(2,9,75,10), "Memo field #2", memo));
  812.  
  813.     dlg->insert(new TButton(TRect(24,16,34,18), "O~K~", cmOK, bfNormal));
  814.     dlg->insert(new TButton(TRect(44,16,54,18), "Cancel", cmCancel, bfNormal));
  815.  
  816.     dlg->selectNext(False);
  817.     return dlg;
  818. }
  819.  
  820. TDialog *createKeyHelpDialog(void)
  821. {
  822.     FILE *fp;
  823.     long  size;
  824.     short sizeInK = 4;
  825.     char KeyHelpFile[30] = "KEYHELP.DOC";
  826.  
  827.     if(access(KeyHelpFile, 0))
  828.         strcpy(KeyHelpFile, "..\\KEYHELP.DOC");
  829.  
  830.     TDialog *dlg = new TDialog(TRect(2,0,78,22), "Editor Help");
  831.     if(!dlg)
  832.         return NULL;
  833.  
  834.     dlg->options |= ofCentered;
  835.  
  836.     // For this demo, the information can be assumed Read Only, so there
  837.     // is no need to display the Read Only indicator.
  838.     TVMIndicator *ind = new TVMIndicator(TRect(1,1,75,2), False);
  839.     ind->setDefaultMessage("  \x11 TVMEditor 2.00 \x10");
  840.     dlg->insert(ind);
  841.  
  842.     TVMScrollBar *vsbar = new TVMScrollBar(TRect(75,2,76,18));
  843.     dlg->insert(vsbar);
  844.  
  845.     // You don't have to do this, but it will prevent the memo field from
  846.     // creating a swap file.  If you know the size of the file, you can
  847.     // simply specify it in the constructor.
  848.     // If you don't care about swap file creation or you are using a version
  849.     // that will swap to EMS/XMS, it can also be ignored.
  850.     fp = fopen(KeyHelpFile, "rb");
  851.  
  852.     if(fp)
  853.     {
  854.         size = filelength(fileno(fp));
  855.  
  856.         // The +8 is the overhead needed for internal information.
  857.         // This will insure that no swapping occurs.
  858.         // Of course, if the file is over 50K, swapping may occur anyway.
  859.         sizeInK = short(size / 1024) + 8;
  860.         fclose(fp);
  861.     }
  862.  
  863.     // Constructor will round buffer up to the nearest 4K or shorten it to 60K.
  864.     // The constructor will also load KEYHELP.DOC into the buffer.  The loaded
  865.     // text will then reside in the resource file when the memo field is
  866.     // output.  This is one reason TVMMemo is derived from TVMFileEditor.
  867.     // It makes stuff like this so easy.
  868.     TVMMemo *Memo = new TVMMemo(TRect(1,2,75,18), NULL, vsbar, ind, sizeInK,
  869.         KeyHelpFile);
  870.  
  871.     // No need for undo and make it read-only.
  872.     Memo->setOption(efCanUndo, False);
  873.     Memo->setOption(efReadOnly, True);
  874.     dlg->insert(Memo);
  875.  
  876.     dlg->insert(new TButton(TRect(33,19,43,21), "O~K~", cmOK, bfDefault));
  877.  
  878.     dlg->selectNext(False);
  879.     return dlg;
  880. }
  881.