home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / tvme30.zip / BLDRSC.CPP next >
C/C++ Source or Header  |  1995-08-02  |  34KB  |  915 lines

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