home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 17
/
CD_ASCQ_17_101194.iso
/
vrac
/
ve2tv103.zip
/
BLDRSC.CPP
next >
Wrap
C/C++ Source or Header
|
1994-07-31
|
33KB
|
881 lines
// File : BLDRSC.CPP
// Author : Eric Woodruff, CIS ID: 72134,1150
// Updated : Sun 07/31/94 15:56:28
// Note : Copyright 1994, Eric Woodruff, All Rights Reserved
// Compiler: Borland C++ 3.1 to 4.02
//
// This program is the resource file builder for the demo editor.
//
// NOTE: The 32 bit version of the resource file is *NOT* compatible with
// the 16 bit version! This is because 'int' values stored in it are
// 32 bits long not 16 so they no long match 'short' values which are
// 16 bits long in either version. See HISTORY.DOC for a required fix
// to TSTATUSL.CPP before building the 32 bit version of the resource
// file.
//
#if defined(__DPMI16__)
#define RSC_FILENAME "TVEDIT16.RSC" // File to create.
#else
#if defined(__DPMI32__)
#define RSC_FILENAME "TVEDIT32.RSC" // File to create.
#else
#define RSC_FILENAME "TVEDIT.RSC" // File to create.
#endif
#endif
#if _TV_VERSION == 0x0103
#define WriteResource(a,b,c) \
cout << c << endl; \
a = b(); \
if( a == 0 ) \
{ \
strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
TObject::destroy(rsc); \
exit(1); \
} \
rsc->put(a,c); \
TObject::destroy(a)
#define WriteObject(a,c) \
cout << c << endl; \
if(a == 0) \
{ \
strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
TObject::destroy(rsc); \
exit(1); \
} \
rsc->put(a,c); \
TObject::destroy(a)
#else
#define WriteResource(a,b,c) \
cout << c << endl; \
a = b(); \
if( a == 0 ) \
{ \
cout << endl << RSC_FILENAME << ": Creation failure" << endl; \
TObject::destroy(rsc); \
exit(1); \
} \
rsc->put(a,c); \
TObject::destroy(a)
#define WriteObject(a,c) \
cout << c << endl; \
if(a == 0) \
{ \
cout << endl << RSC_FILENAME << ": Creation failure" << endl; \
TObject::destroy(rsc); \
exit(1); \
} \
rsc->put(a,c); \
TObject::destroy(a)
#endif
#include <conio.h>
#include <dir.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define Uses_TButton
#define Uses_TCheckBoxes
#define Uses_TColorDialog
#define Uses_TColorGroup
#define Uses_TColorItem
#define Uses_TDialog
#define Uses_THistory
#define Uses_TInputLine
#define Uses_TKeys
#define Uses_TLabel
#define Uses_TMenuBar
#define Uses_TMenuItem
#define Uses_TRadioButtons
#define Uses_TRect
#define Uses_TResourceFile
#define Uses_TScreen
#define Uses_TScrollBar
#define Uses_TSItem
#define Uses_TStaticText
#define Uses_TStatusDef
#define Uses_TStatusItem
#define Uses_TStatusLine
#define Uses_TSubMenu
#define Uses_TVCOLR // Use this if you modified the TV.H file.
#define Uses_fpstream
#include <tv.h>
#if !defined(cpDefSize)
// Use this if you chose not to modify the Turbo Vision files.
#include <tvcolr.h>
#endif
#define Uses_TVMIndicator
#define Uses_TVMScrollBar
#define Uses_TVMEditor
#define Uses_TVMFileEditor
#define Uses_TVMMemo
#include <tvmedit.h>
#define Uses_TInteger
#define Uses_TFilename
#include <tintfile.h>
#include <tmsgview.h>
#include "link.h" // Resource file link definitions
#include "tvedit.h" // Demo header file
// ============================================================================
TDialog *Colors(void);
TDialog *AboutBox(void);
TDialog *createStartUpDialog(void);
TDialog *createLclEdOptDialog(void);
TDialog *createDefEdOptDialog(void);
TDialog *createFindDialog(void);
TDialog *createReplaceDialog(void);
TDialog *createMemoDemoDialog(void);
TDialog *createKeyHelpDialog(void);
TMenuBar *initMenuBar(void);
TStatusLine *initStatusLine(void);
// ============================================================================
fpstream *s;
TResourceFile* rsc;
// ============================================================================
// The exit function is no longer needed in the TV 2.0 version due to
// the new TScreen::clearOnSuspend data member.
#if _TV_VERSION == 0x0103
char endString[255] = "";
void exitfunc(void)
{
cout << endl << endString << endl;
}
#pragma exit exitfunc 31
#endif
void main(void)
{
TDialog *dlg;
TMenuBar *menuBar;
TStatusLine *statusLine;
#if _TV_VERSION != 0x0103
// Prevent the screen from being cleared on exit.
TScreen::clearOnSuspend = False;
#endif
cout << "Creating " RSC_FILENAME << endl;
// Construct stream and resource file.
s = new fpstream (RSC_FILENAME, ios::trunc | ios::binary);
rsc = new TResourceFile(s);
// Create all of the necessary dialogs for the demo.
WriteResource(dlg, AboutBox, "AboutBox");
WriteResource(dlg, Colors, "ColorDlg");
WriteResource(dlg, createStartUpDialog, "StartUpDlg");
WriteResource(dlg, createLclEdOptDialog, "LclEdOptDlg");
WriteResource(dlg, createDefEdOptDialog, "DefEdOptDlg");
WriteResource(dlg, createFindDialog, "FindDialog");
WriteResource(dlg, createReplaceDialog, "ReplaceDialog");
WriteResource(dlg, createMemoDemoDialog, "MemoDemo");
WriteResource(dlg, createKeyHelpDialog, "KeyHelp");
// Create the menus and status line.
WriteResource(menuBar, initMenuBar, "MenuBar");
WriteResource(statusLine, initStatusLine, "StatusLine");
TObject::destroy(rsc);
#if _TV_VERSION == 0x0103
strcpy(endString, RSC_FILENAME ": Creation completed.");
#else
cout << endl << RSC_FILENAME << ": Creation completed." << endl;
#endif
exit(0);
}
// ============================================================================
TDialog *AboutBox(void)
{
TDialog *aboutBox = new TDialog(TRect(0, 0, 46, 11), "About");
aboutBox->options |= ofCentered;
aboutBox->insert(new TStaticText(TRect(1, 2, 45, 8),
"\003TVMEditor 2.00 Class Library\n"
"\003Virtual Memory Text Editor Demo\n \n"
"\003(c) 1994 Eric Woodruff\n\003CIS ID: 72134,1150"));
TButton *b = new TButton(TRect(11,8,23,10), "O~K~", cmOK, bfDefault);
b->options |= ofCenterX;
aboutBox->insert(b);
return aboutBox;
}
TDialog *Colors(void)
{
TColorGroup &group1 =
*new TColorGroup("Desktop") +
*new TColorItem("Background", 1)+
*new TColorGroup("Menus") +
*new TColorItem("Normal text", 2)+
*new TColorItem("Disabled text", 3)+
*new TColorItem("Shortcut key", 4)+
*new TColorItem("Selection bar", 5)+
*new TColorItem("Selected disabled", 6)+
*new TColorItem("Shortcut selected", 7);
TColorGroup &group2 =
// *new TColorGroup("Blue Window") +
*new TColorGroup("Edit Window") +
*new TColorItem("Frame inactive", 8)+
*new TColorItem("Frame active", 9)+
*new TColorItem("Frame icons", 10)+
*new TColorItem("Scrollbar page", 11)+
*new TColorItem("Scrollbar icons", 12)+
*new TColorItem("Normal text", 13)+
*new TColorItem("Selected text", 14)+
// *new TColorGroup("Error Tracking") +
*new TColorGroup("Line Tracking") +
*new TColorItem("Frame inactive", cMsgFramePassive)+ // Extended
*new TColorItem("Frame active", cMsgFrameActive)+ // Extended
*new TColorItem("Frame icons", cMsgFrameIcon)+ // Extended
*new TColorItem("Scrollbar page", cMsgSBPage)+ // Extended
*new TColorItem("Scrollbar icons", cMsgSBCtrl)+ // Extended
*new TColorItem("Normal text", cMsgNText)+ // Extended
*new TColorItem("Focused text", cMsgSText)+ // Extended
*new TColorItem("Selected text", cMsgSelected); // Extended
TColorGroup &group3 =
*new TColorGroup("Edit Indicator") +
*new TColorItem("Edit Window", cIndEditWin)+ // Extended
*new TColorItem("Memo Field", cIndMemoFld)+ // Extended
// *new TColorGroup("Gray Dialog Box") +
*new TColorGroup("Dialog Box") +
*new TColorItem("Frame inactive", 32)+
*new TColorItem("Frame active", 33)+
*new TColorItem("Frame icons", 34)+
*new TColorItem("Scrollbar page", 35)+
*new TColorItem("Scrollbar icons", 36)+
// The last four text colors are only available when using the
// TColorText class from TVCOLR.ZIP/TVCLR2.ZIP.
*new TColorItem("Normal text", 37)+
*new TColorItem("Information", cCTxtInfoColor)+ // Extended
*new TColorItem("Notification", cCTxtNotifyColor)+ // Extended
*new TColorItem("Warning", cCTxtWarnColor)+ // Extended
*new TColorItem("Error", cCTxtErrorColor)+ // Extended
// Selected Shortcut is only applicable if you made the
// changes described in COLUPDT.DOC in TVCOLR.ZIP/TVCLR2.ZIP.
*new TColorItem("Normal label", 38)+
*new TColorItem("Selected label", 39)+
*new TColorItem("Label shortcut key", 40)+
#ifdef MODIFIED_TV_COLORS
#if _TV_VERSION == 0x0103
*new TColorItem("Selected shortcut", 66)+ // Added by me - TV 1.03 location
#else
*new TColorItem("Selected label shortcut key", 138)+ // Same, but TV 2.0 location
#endif
#endif
// Default and Selected Shortcut are only applicable if you made
// the changes described in COLUPDT.DOC in TVCOLR.ZIP/TVCLR2.ZIP
*new TColorItem("Normal button", 41)+
*new TColorItem("Default button", 42)+
*new TColorItem("Selected button", 43)+
*new TColorItem("Disabled button", 44)+
*new TColorItem("Button shortcut key", 45)+
#ifdef MODIFIED_TV_COLORS
#if _TV_VERSION == 0x0103
*new TColorItem("Default shortcut", 64)+ // Added by me - TV 1.03 location
*new TColorItem("Selected shortcut", 65)+
#else
*new TColorItem("Default button shortcut key", 136)+ // Same, but TV 2.0 location
*new TColorItem("Selected button shortcut key", 137)+
#endif
#endif
*new TColorItem("Button shadow", 46)+
*new TColorItem("Cluster normal", 47)+
*new TColorItem("Cluster selected", 48)+
*new TColorItem("Cluster shortcut", 49)+
*new TColorItem("Input line normal", 50)+
*new TColorItem("Input line selected", 51)+
*new TColorItem("Input line arrow", 52)+
*new TColorItem("History button", 53)+
*new TColorItem("History sides", 54)+
*new TColorItem("History scrollbar", 55)+
*new TColorItem("History icons", 56)+
*new TColorItem("Normal list item", 57)+
*new TColorItem("Focused list item", 58)+
*new TColorItem("Selected list item", 59)+
*new TColorItem("List divider", 60)+
*new TColorItem("Information pane", 61);
TColorGroup &group4 =
*new TColorGroup("Help Window") +
#if _TV_VERSION == 0x0103
#ifdef MODIFIED_TV_COLORS
*new TColorItem("Frame inactive", 67)+ // TV 1.03 locations after
*new TColorItem("Frame active", 68)+ // TVCOLR/TVCLR2.ZIP modifications.
*new TColorItem("Frame icons", 69)+
*new TColorItem("Scrollbar page", 70)+
*new TColorItem("Scrollbar icons", 71)+
*new TColorItem("Normal text", 72)+
*new TColorItem("Keyword", 73)+
*new TColorItem("Selected keyword", 74);
#else
*new TColorItem("Frame inactive", 64)+ // Standard unmodified TV 1.03
*new TColorItem("Frame active", 65)+ // locations.
*new TColorItem("Frame icons", 66)+
*new TColorItem("Scrollbar page", 67)+
*new TColorItem("Scrollbar icons", 68)+
*new TColorItem("Normal text", 69)+
*new TColorItem("Keyword", 70)+
*new TColorItem("Selected keyword", 71);
#endif
#else
*new TColorItem("Frame inactive", 128)+ // The help colors are a part
*new TColorItem("Frame active", 129)+ // of the base palette in
*new TColorItem("Frame icons", 130)+ // TV 2.0. These are the standard
*new TColorItem("Scrollbar page", 131)+ // unmodified locations.
*new TColorItem("Scrollbar icons", 132)+
*new TColorItem("Normal text", 133)+
*new TColorItem("Keyword", 134)+
*new TColorItem("Selected keyword", 135);
#endif
TColorGroup &All = group1 + group2 + group3 + group4;
// See the notes in handleEvent() about the proper usage of TColorDialog.
TColorDialog *c = new TColorDialog((TPalette*)0, &All);
return c;
}
TMenuBar *initMenuBar(void)
{
TSubMenu& MiscMenu = *new TSubMenu( "~\xF0~", 0) +
*new TMenuItem( "~A~bout...", cmAbout, kbNoKey)+
*new TMenuItem( "~R~epaint desktop", cmRepaint, kbNoKey);
TSubMenu& FileMenu = *new TSubMenu("~F~ile", 0) +
*new TMenuItem("~N~ew", cmNew, kbNoKey) +
*new TMenuItem("~O~pen...", cmOpen, kbF3, hcNoContext, "F3") +
*new TMenuItem("~S~ave", cmSave, kbF2, hcNoContext, "F2") +
*new TMenuItem("S~a~ve as...", cmSaveAs, kbNoKey) +
*new TMenuItem("Save a~l~l", cmSaveAll, kbNoKey) +
newLine() +
*new TMenuItem("~C~hange dir...", cmChDir, kbNoKey)+
*new TMenuItem("~P~rint", cmPrintFile, kbNoKey) +
*new TMenuItem( "~D~OS shell", cmDosShell, kbNoKey) +
newLine() +
*new TMenuItem( "~Q~uit", cmQuit, kbAltX, hcNoContext, "Alt+X" );
TSubMenu& EditMenu = *new TSubMenu("~E~dit", 0) +
*new TMenuItem("~U~ndo", cmUndo, kbAltMinus, hcNoContext, "Alt -" ) +
*new TMenuItem("~R~edo", cmRedo, kbAltEqual, hcNoContext, "Alt =" ) +
newLine() +
*new TMenuItem("Cu~t~", cmCut, kbShiftDel, hcNoContext, "Shift+Del") +
*new TMenuItem("~C~opy", cmCopy, kbCtrlIns, hcNoContext, "Ctrl+Ins") +
*new TMenuItem("~P~aste", cmPaste, kbShiftIns, hcNoContext, "Shift+Ins") +
*new TMenuItem("C~l~ear", cmClear, kbCtrlDel, hcNoContext, "Ctrl+Del")+
newLine() +
*new TMenuItem("~S~how clipboard", cmShowClip, kbNoKey);
TSubMenu& SearchMenu = *new TSubMenu("~S~earch", 0) +
*new TMenuItem("~F~ind...", cmFind, kbNoKey) +
*new TMenuItem("~R~eplace...", cmReplace, kbNoKey) +
*new TMenuItem("~S~earch again", cmSearchAgain, kbCtrlL, hcNoContext, "Ctrl+L")+
newLine() +
*new TMenuItem("~G~o to line number...", cmGotoLine, kbNoKey)+
*new TMenuItem("~P~revious Message", cmPrevMsg, kbAltF7, hcNoContext, "Alt+F7")+
*new TMenuItem("~N~ext Message", cmNextMsg, kbAltF8, hcNoContext, "Alt+F8");
TSubMenu& WindowMenu = *new TSubMenu( "~W~indows", 0) +
*new TMenuItem( "~S~ize/Move", cmResize, kbCtrlF5, hcNoContext, "Ctrl+F5" ) +
*new TMenuItem( "~Z~oom", cmZoom, kbF5, hcNoContext, "F5" ) +
*new TMenuItem( "C~a~scade", cmCascade, kbNoKey) +
*new TMenuItem( "~T~ile", cmTile, kbNoKey) +
*new TMenuItem( "Ne~x~t", cmNext, kbF6, hcNoContext, "F6" ) +
*new TMenuItem( "~P~revious", cmPrev, kbShiftF6, hcNoContext, "Shift+F6" ) +
*new TMenuItem( "~C~lose", cmClose, kbAltF3, hcNoContext, "Alt+F3" ) +
*new TMenuItem( "Clos~e~ all", cmCloseAll, kbNoKey) +
newLine() +
*new TMenuItem( "To~g~gle Screen Size", cmScreenSize, kbNoKey) +
*new TMenuItem( "~U~ser screen", cmUserScreen, kbAltF5, hcNoContext, "Alt+F5");
TSubMenu& OptionsMenu = *new TSubMenu("~O~ptions", 0) +
*new TMenuItem("S~t~art up options...", cmStartUpOpt, kbNoKey)+
newLine()+
*new TMenuItem("~D~efault editor options...", cmDefaultEditorOpt, kbNoKey)+
*new TMenuItem("C~u~rrent editor options...", cmLocalEditorOpt, kbF8, hcNoContext, "F8")+
newLine()+
*new TMenuItem( "~C~olors...", cmColors, kbNoKey ) +
*new TMenuItem( "C~h~ange palettes", cmChangePalettes, kbNoKey ) +
newLine() +
*new TMenuItem( "~L~oad configuration...", cmLoadCfg, kbNoKey) +
*new TMenuItem( "~S~ave configuration...", cmSaveCfg, kbNoKey) +
newLine()+
*new TMenuItem("~R~ecord macro...", cmRecord, kbAltR, hcNoContext, "Alt+R")+
*new TMenuItem("~P~lay macro...", cmPlay, kbAltP, hcNoContext, "Alt+P");
TSubMenu& MemoMenu = *new TSubMenu( "~D~emo", 0) +
*new TMenuItem( "~M~essage viewer demo", cmMsgViewer, kbNoKey)+
newLine()+
*new TMenuItem( "~R~eplace key maps", cmReplaceKeyMaps, kbNoKey)+
newLine()+
*new TMenuItem( "M~e~mo demo dialog...", cmMemoDemo, kbNoKey)+
*new TMenuItem( "~K~ey definition list", cmKeyHelp, kbF1, hcNoContext, "F1");
return new TMenuBar(TRect(0, 0, 80, 1), MiscMenu + FileMenu + EditMenu +
SearchMenu + WindowMenu + OptionsMenu + MemoMenu);
}
TStatusLine *initStatusLine(void)
{
return new TStatusLine( TRect(0, 24, 80, 25),
*new TStatusDef( 0, 0xFFFF ) +
*new TStatusItem("~F1~ Help", kbF1, cmKeyHelp) +
*new TStatusItem("~F2~ Save", kbF2, cmSave) +
*new TStatusItem("~F3~ Open", kbF3, cmOpen) +
*new TStatusItem("~Alt+F3~ Close", kbAltF3, cmClose) +
*new TStatusItem("~F5~ Zoom", kbF5, cmZoom) +
*new TStatusItem("~F6~ Next", kbF6, cmNext) +
// If this one isn't on the status line, modal dialogs won't handle
// the event. When present, you can edit the local options for
// any dialog box memo field. Another way would be to derive a new
// TDialog class and override it's handleEvent() to call
// editorDialog() when a button is pushed for this event, etc.
*new TStatusItem("~F8~ Lcl Opt", kbF8, cmLocalEditorOpt) +
*new TStatusItem(0, kbF10, cmMenu));
}
TDialog *createFindDialog(void)
{
TDialog *d = new TDialog(TRect(0,0,54,16), "Find");
d->options |= ofCentered;
TInputLine *i = new TInputLine(TRect(16,2,49,3), 80);
d->insert(i);
d->insert(new TLabel(TRect(2,2,15,3), "~T~ext to find", i));
d->insert(new THistory(TRect(49,2,52,3), i, 10));
TCheckBoxes *b = new TCheckBoxes(TRect(3,5,27,7),
new TSItem("~C~ase sensitive",
new TSItem("~W~hole words only", 0)));
d->insert(b);
d->insert(new TLabel(TRect(3,4,12,5), "~O~ptions", b));
TRadioButtons *r = new TRadioButtons(TRect(32,5,51,7),
new TSItem("~F~orward",
new TSItem("~B~ackward", 0)));
d->insert(r);
d->insert(new TLabel(TRect(32,4,42,5), "~D~irection", r));
r = new TRadioButtons(TRect(3,10,27,12),
new TSItem("~G~lobal",
new TSItem("~S~elected text", 0)));
d->insert(r);
d->insert(new TLabel(TRect(3,9,9,10), "~S~cope", r));
r = new TRadioButtons(TRect(32,10,51,12),
new TSItem("~F~rom cursor",
new TSItem("~E~ntire scope", 0)));
d->insert(r);
d->insert(new TLabel(TRect(32,9,42,10), "~O~rigin", r));
d->insert(new TButton(TRect(12,13,22,15), "O~K~", cmOK, bfDefault));
d->insert(new TButton(TRect(28,13,40,15), "Cancel", cmCancel, bfNormal));
d->selectNext(False);
return d;
}
TDialog *createReplaceDialog(void)
{
TDialog *d = new TDialog(TRect(0,0,54,18), "Replace");
d->options |= ofCentered;
TInputLine *i = new TInputLine(TRect(16,2,49,3), 80);
d->insert(i);
d->insert(new TLabel(TRect(2,2,15,3), "~T~ext to find", i));
d->insert(new THistory(TRect(49,2,52,3), i, 10));
i = new TInputLine(TRect(16,4,49,5), 80);
d->insert(i);
d->insert(new TLabel(TRect(6,4,15,5), "~N~ew text", i));
d->insert(new THistory(TRect(49,4,52,5), i, 11));
TCheckBoxes *b = new TCheckBoxes(TRect(3,7,27,10),
new TSItem("~C~ase sensitive",
new TSItem("~W~hole words only",
new TSItem("~P~rompt on replace", 0))));
d->insert(b);
d->insert(new TLabel(TRect(3,6,12,7), "~O~ptions", b));
TRadioButtons *r = new TRadioButtons(TRect(32,7,51,9),
new TSItem("~F~orward",
new TSItem("~B~ackward", 0)));
d->insert(r);
d->insert(new TLabel(TRect(32,6,42,7), "~D~irection", r));
r = new TRadioButtons(TRect(3,12,27,14),
new TSItem("~G~lobal",
new TSItem("~S~elected text", 0)));
d->insert(r);
d->insert(new TLabel(TRect(3,11,9,12), "~S~cope", r));
r = new TRadioButtons(TRect(32,12,51,14),
new TSItem("~F~rom cursor",
new TSItem("~E~ntire scope", 0)));
d->insert(r);
d->insert(new TLabel(TRect(32,11,42,12), "~O~rigin", r));
// NOTE: If the Replace Dialog returns cmYes, *ALL* occurances will
// be replaced, not just the first one. This was easier than
// using a new command and deriving a dialog box class that
// could return a non-standard value. The TVMEditor classes
// will look specifically for cmYes to enable the Change All
// option for search and replace operations. If cmOK is
// returned, only the first occurance is replaced.
//
d->insert(new TButton(TRect( 7,15,17,17), "O~K~", cmOK, bfDefault));
d->insert(new TButton(TRect(19,15,35,17), "Change ~A~ll", cmYes, bfNormal));
d->insert(new TButton(TRect(37,15,47,17), "Cancel", cmCancel, bfNormal));
d->selectNext(False);
return d;
}
TDialog *createDefEdOptDialog(void)
{
TDialog *dlg = new TDialog(TRect(1,0,79,23), "Default Editor Options");
if(!dlg)
return NULL;
dlg->options = ofCentered;
TCheckBoxes *b = new TCheckBoxes(TRect(3,3,32,13),
new TSItem("~I~nsert mode",
new TSItem("~A~uto indent mode",
new TSItem("W~o~rd wrap mode",
new TSItem("Keep trai~l~ing spaces",
new TSItem("~U~se tab character",
new TSItem("Ca~n~ undo/redo",
new TSItem("E~x~pand tabs on load",
new TSItem("Create backup ~f~iles",
new TSItem("Use LF only when sa~v~ed",
new TSItem("Text is ~r~ead only", 0)))))))))));
dlg->insert(b);
dlg->insert(new TLabel(TRect(3,2,32,3), "General Options", b));
b = new TCheckBoxes(TRect(5,15,30,17),
new TSItem("~(~)",
new TSItem("~[~]",
new TSItem("~{~}",
new TSItem("~'~'",
new TSItem("~\"~\"",
new TSItem("~<~>", 0)))))));
dlg->insert(b);
dlg->insert(new TLabel(TRect(5,14,30,15), "Enter Matching", b));
TInteger *i = new TInteger(TRect(22,18,27,19), 3, 16, 2);
dlg->insert(i);
dlg->insert(new TLabel(TRect(11,18,21,19), "~T~ab size:", i));
i = new TInteger(TRect(22,19,27,20), 3, 16, 1);
dlg->insert(i);
dlg->insert(new TLabel(TRect(8,19,21,20), "Indent si~z~e:", i));
i = new TInteger(TRect(22,20,27,21), 4, 250, 20);
dlg->insert(i);
dlg->insert(new TLabel(TRect(7,20,21,21), "Rig~h~t margin:", i));
b = new TCheckBoxes(TRect(40,3,69,6),
new TSItem("~C~ase sensitive",
new TSItem("~W~hole words only",
new TSItem("~P~rompt on replace", 0))));
dlg->insert(b);
dlg->insert(new TLabel(TRect(40,2,69,3), "Search/Replace Options", b));
i = new TInteger(TRect(62, 7, 69, 8), 6, 32767, 0);
dlg->insert(i);
dlg->insert(new TLabel(TRect(34, 7, 61, 8), "~S~tart Signs of Life after:", i));
dlg->insert(new TStaticText(TRect(70, 7, 75, 8), "lines"));
i = new TInteger(TRect(62, 8, 69, 9), 6, 32767, 0);
dlg->insert(i);
dlg->insert(new TLabel(TRect(34, 8, 61, 9), "After start, update ever~y~:", i));
dlg->insert(new TStaticText(TRect(70, 8, 75, 9), "lines"));
TFilename *s = new TFilename(TRect(62,10,67,11), 4);
dlg->insert(s);
dlg->insert(new TLabel(TRect(42,10,61,11), "~D~efault extension:", s));
s = new TFilename(TRect(62,11,67,12), 4);
dlg->insert(s);
dlg->insert(new TLabel(TRect(43,11,61,12), "~B~ackup extension:", s));
s = new TFilename(TRect(34,14,75,15), MAXPATH);
dlg->insert(s);
dlg->insert(new TLabel(TRect(34,13,75,14), "~E~ditor swap file path:", s));
s = new TFilename(TRect(34, 17, 75, 18), MAXPATH);
dlg->insert(s);
dlg->insert(new TLabel(TRect(34, 16, 75, 17), "Printin~g~ Device:", s));
dlg->insert(new TButton(TRect(44,20,54,22), "O~K~", cmOK, bfDefault));
dlg->insert(new TButton(TRect(61,20,71,22), "Cancel", cmCancel, bfNormal));
dlg->selectNext(False);
return dlg;
}
TDialog *createStartUpDialog(void)
{
#if !defined(__DPMI16__) && !defined(__DPMI32__)
TDialog *dlg = new TDialog(TRect(17,2,62,20), "Start Up Options");
if(!dlg)
return NULL;
dlg->options = ofCentered;
TCheckBoxes *ck = new TCheckBoxes(TRect(4,3,41,5),
new TSItem("~I~ndicator at top of edit window",
new TSItem("Sa~v~e desktop on exit", 0)));
dlg->insert(ck);
dlg->insert(new TLabel(TRect(4,2,41,3), "Miscellaneous", ck));
TRadioButtons *rb = new TRadioButtons(TRect(9,7,36,12),
new TSItem("Check for ~E~MS first",
new TSItem("Check for ~X~MS first",
new TSItem("Check for E~M~S only",
new TSItem("Check for XM~S~ only",
new TSItem("Use ~d~isk only", 0))))));
dlg->insert(rb);
dlg->insert(new TLabel(TRect(9,6,36,7), "Virtual Memory Preference", rb));
TInteger *nm = new TInteger(TRect(28,13,32,14), 3, 60, 4);
dlg->insert(nm);
dlg->insert(new TLabel(TRect(2,13,27,14), "~B~uffer size for editors:", nm));
dlg->insert(new TStaticText(TRect(33,13,41,14), "(Kbytes)"));
dlg->insert(new TButton(TRect(6,15,16,17), "O~K~", cmOK, bfDefault));
dlg->insert(new TButton(TRect(28,15,38,17), "Cancel", cmCancel, bfNormal));
#else
TDialog* dlg = new TDialog(TRect(9, 5, 70, 17), "Start Up Options");
if(!dlg)
return NULL;
dlg->options |= ofCentered;
TCheckBoxes *ck = new TCheckBoxes(TRect(12, 3, 49, 5),
new TSItem("~I~ndicator at top of edit window",
new TSItem("Sa~v~e desktop on exit", 0)));
dlg->insert(ck);
dlg->insert(new TLabel(TRect(12, 2, 49, 3), "Miscellaneous", ck));
TInteger *nm = new TInteger(TRect(42, 6, 46, 7), 3, 60, 4);
dlg->insert(nm);
dlg->insert(new TLabel(TRect(16, 6, 41, 7), "~B~uffer size for editors:",
nm));
dlg->insert(new TStaticText(TRect(48, 6, 56, 7), "(Kbytes)"));
nm = new TInteger(TRect(42, 7, 49, 8), 6, 32767, 60);
dlg->insert(nm);
dlg->insert(new TLabel(TRect(2, 7, 41, 8),
"~M~aximum allocatable memory per editor:", nm));
dlg->insert(new TStaticText(TRect(50, 7, 58, 8), "(KBytes)"));
dlg->insert(new TButton(TRect(9, 9, 19, 11), "O~K~", cmOK, bfDefault));
dlg->insert(new TButton(TRect(42, 9, 52, 11), "Cancel", cmCancel, bfNormal));
#endif
dlg->selectNext(False);
return dlg;
}
TDialog *createLclEdOptDialog(void)
{
TDialog *dlg = new TDialog(TRect(9,5,71,18), "Current Editor Options");
if(!dlg)
return NULL;
dlg->options = ofCentered;
TCheckBoxes *b = new TCheckBoxes(TRect(3,3,32,9),
new TSItem("~I~nsert mode",
new TSItem("~A~uto indent mode",
new TSItem("W~o~rd wrap mode",
new TSItem("Keep trai~l~ing spaces",
new TSItem("~U~se tab character",
new TSItem("Ca~n~ undo/redo", 0)))))));
dlg->insert(b);
dlg->insert(new TLabel(TRect(3,2,32,3), "General Options", b));
b = new TCheckBoxes(TRect(34,3,59,5),
new TSItem("~(~)",
new TSItem("~[~]",
new TSItem("~{~}",
new TSItem("~'~'",
new TSItem("~\"~\"",
new TSItem("~<~>", 0)))))));
dlg->insert(b);
dlg->insert(new TLabel(TRect(34,2,59,3), "Enter Matching", b));
TInteger *i = new TInteger(TRect(51,6,56,7), 3, 16, 2);
dlg->insert(i);
dlg->insert(new TLabel(TRect(40,6,50,7), "~T~ab size:", i));
i = new TInteger(TRect(51,7,56,8), 3, 16, 1);
dlg->insert(i);
dlg->insert(new TLabel(TRect(37,7,50,8), "Indent si~z~e:", i));
i = new TInteger(TRect(51,8,56,9), 4, 250, 20);
dlg->insert(i);
dlg->insert(new TLabel(TRect(36,8,50,9), "Rig~h~t margin:", i));
dlg->insert(new TButton(TRect(16,10,26,12), "O~K~", cmOK, bfDefault));
dlg->insert(new TButton(TRect(35,10,45,12), "Cancel", cmCancel, bfNormal));
dlg->selectNext(False);
return dlg;
}
TDialog *createMemoDemoDialog(void)
{
TDialog *dlg = new TDialog(TRect(1,2,79,21), "TVMMemo Demo");
if(!dlg)
return NULL;
dlg->options |= ofCentered;
TScrollBar *hsbar = new TScrollBar(TRect(16,7,75,8));
dlg->insert(hsbar);
TVMScrollBar *vsbar = new TVMScrollBar(TRect(75,3,76,7));
dlg->insert(vsbar);
// Note that the indicator is shortened and will only display the
// modified flag and cursor position.
TVMIndicator *ind = new TVMIndicator(TRect(2,7,16,8));
dlg->insert(ind);
TVMMemo *memo = new TVMMemo(TRect(2,3,75,7), hsbar, vsbar, ind, 4);
// memo->setOption(efCanUndo, False);
dlg->insert(memo);
dlg->insert(new TLabel(TRect(2,2,75,3), "Memo field #1", memo));
hsbar = new TScrollBar(TRect(16,14,75,15));
dlg->insert(hsbar);
vsbar = new TVMScrollBar(TRect(75,10,76,14));
dlg->insert(vsbar);
ind = new TVMIndicator(TRect(2,14,16,15));
dlg->insert(ind);
memo = new TVMMemo(TRect(2,10,75,14), hsbar, vsbar, ind, 4);
// memo->setOption(efCanUndo, False);
dlg->insert(memo);
dlg->insert(new TLabel(TRect(2,9,75,10), "Memo field #2", memo));
dlg->insert(new TButton(TRect(24,16,34,18), "O~K~", cmOK, bfNormal));
dlg->insert(new TButton(TRect(44,16,54,18), "Cancel", cmCancel, bfNormal));
dlg->selectNext(False);
return dlg;
}
TDialog *createKeyHelpDialog(void)
{
FILE *fp;
long size;
short sizeInK = 4;
char KeyHelpFile[30] = "KEYHELP.DOC";
if(access(KeyHelpFile, 0))
strcpy(KeyHelpFile, "..\\KEYHELP.DOC");
TDialog *dlg = new TDialog(TRect(2,0,78,22), "Editor Help");
if(!dlg)
return NULL;
dlg->options |= ofCentered;
// For this demo, the information can be assumed Read Only, so there
// is no need to display the Read Only indicator.
TVMIndicator *ind = new TVMIndicator(TRect(1,1,75,2), False);
ind->setDefaultMessage(" \x11 TVMEditor 2.00 \x10");
dlg->insert(ind);
TVMScrollBar *vsbar = new TVMScrollBar(TRect(75,2,76,18));
dlg->insert(vsbar);
// You don't have to do this, but it will prevent the memo field from
// creating a swap file. If you know the size of the file, you can
// simply specify it in the constructor.
// If you don't care about swap file creation or you are using a version
// that will swap to EMS/XMS, it can also be ignored.
fp = fopen(KeyHelpFile, "rb");
if(fp)
{
size = filelength(fileno(fp));
// The +8 is the overhead needed for internal information.
// This will insure that no swapping occurs.
// Of course, if the file is over 50K, swapping may occur anyway.
sizeInK = short(size / 1024) + 8;
fclose(fp);
}
// Constructor will round buffer up to the nearest 4K or shorten it to 60K.
// The constructor will also load KEYHELP.DOC into the buffer. The loaded
// text will then reside in the resource file when the memo field is
// output. This is one reason TVMMemo is derived from TVMFileEditor.
// It makes stuff like this so easy.
TVMMemo *Memo = new TVMMemo(TRect(1,2,75,18), NULL, vsbar, ind, sizeInK,
KeyHelpFile);
// No need for undo and make it read-only.
Memo->setOption(efCanUndo, False);
Memo->setOption(efReadOnly, True);
dlg->insert(Memo);
dlg->insert(new TButton(TRect(33,19,43,21), "O~K~", cmOK, bfDefault));
dlg->selectNext(False);
return dlg;
}