home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / basic / emed15 / samples / owl / mdtmdicl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-04  |  19.7 KB  |  610 lines

  1. /*  Project emedit
  2.     Early Morning Software
  3.     Copyright ⌐ 1994. All Rights Reserved.
  4.  
  5.     SUBSYSTEM:    emedit.exe Application
  6.     FILE:         mdtmdicl.cpp
  7.     AUTHOR:       Ted Stockwell
  8.  
  9.  
  10.     OVERVIEW
  11.     ========
  12.     Source file for implementation of emeditMDIClient (TMDIClient).
  13. */
  14.  
  15. #include <time.h>
  16. #include <dir.h>
  17. #include <owl\owlpch.h>
  18.  
  19. #define CommonDialog_DATA
  20. #include <cmdialog.h>
  21. #pragma hdrstop
  22.  
  23. #include "emedtapp.h"
  24. #include "mdtmdicl.h"
  25. #include "mdtmdich.h"
  26. #include "apxprint.h"
  27. #include "apxprev.h"
  28. #include "mdtchldc.h"
  29.  
  30. #include "padedit.h"
  31.  
  32.  
  33.  
  34.  
  35. static string MostRecentFileNames[ 4 ];
  36. static int MRUFileItemCount= 0; // # of items on MRU file list.
  37.  
  38. //{{emeditMDIClient Implementation}}
  39.  
  40.  
  41. //
  42. // Build a response table for all messages/commands handled
  43. // by emeditMDIClient derived from TMDIClient.
  44. //
  45. DEFINE_RESPONSE_TABLE1(emeditMDIClient, TMDIClient)
  46. //{{emeditMDIClientRSP_TBL_BEGIN}}
  47.     EV_COMMAND(CM_MDIFILENEW, CmFileNew),
  48.     EV_COMMAND(CM_MDIFILEOPEN, CmFileOpen),
  49.     EV_COMMAND(CM_FILEPRINT, CmFilePrint),
  50.     EV_COMMAND(CM_FILEPRINTERSETUP, CmFilePrintSetup),
  51.     EV_COMMAND(CM_FILEPRINTPREVIEW, CmFilePrintPreview),
  52.     EV_COMMAND_ENABLE(CM_FILEPRINT, CmPrintEnable),
  53.     EV_COMMAND_ENABLE(CM_FILEPRINTERSETUP, CmPrintEnable),
  54.     EV_COMMAND_ENABLE(CM_FILEPRINTPREVIEW, CmPrintEnable),
  55.     EV_WM_DROPFILES,
  56.     EV_COMMAND(CM_FONT, CmOptionsFont),
  57.     EV_COMMAND_ENABLE(CM_FONT, CmOptionsFontEnable),
  58.     EV_COMMAND_ENABLE(CM_EDITSELECT_ALL, CmEditSelectAllEnable),
  59.     EV_COMMAND_ENABLE(CM_EDITTIMEDATE, CmEditTimeDateEnable),
  60.     EV_COMMAND(CM_EDITTIMEDATE, CmEditTimeDate),
  61.     EV_COMMAND_ENABLE(CM_FILECLOSE, CmFileCloseEnable),
  62.     EV_COMMAND(CM_FILECLOSE, CmFileClose),
  63.     EV_COMMAND_ENABLE(CM_STREAMBLOCK, CmStreamBlockEnable),
  64.     EV_COMMAND_ENABLE(CM_FILELAST1, CmFileLast1Enable),
  65.     EV_COMMAND_ENABLE(CM_FILELAST2, CmFileLast2Enable),
  66.     EV_COMMAND_ENABLE(CM_FILELAST3, CmFileLast3Enable),
  67.     EV_COMMAND_ENABLE(CM_FILELAST4, CmFileLast4Enable),
  68.     EV_COMMAND(CM_FILELAST1, CmFileLast1),
  69.     EV_COMMAND(CM_FILELAST2, CmFileLast2),
  70.     EV_COMMAND(CM_FILELAST3, CmFileLast3),
  71.     EV_COMMAND(CM_FILELAST4, CmFileLast4),
  72.     EV_COMMAND_ENABLE(CM_LINEBLOCK, CmLineBlockEnable),
  73.     EV_COMMAND_ENABLE(CM_COLUMNBLOCK, CmColumnBlockEnable),
  74.     EV_COMMAND(CM_COLUMNBLOCK, CmColumnBlock),
  75.     EV_COMMAND(CM_LINEBLOCK, CmLineBlock),
  76.     EV_COMMAND(CM_STREAMBLOCK, CmStreamBlock),
  77.     EV_COMMAND_ENABLE(CM_EDITCLEAR, CMEditClearEnable),
  78. //{{emeditMDIClientRSP_TBL_END}}
  79. END_RESPONSE_TABLE;
  80.  
  81.  
  82. //////////////////////////////////////////////////////////
  83. // emeditMDIClient
  84. // ===========
  85. // Construction/Destruction handling.
  86. emeditMDIClient::emeditMDIClient () :
  87.  TMDIClient ()
  88. {
  89.     ChildCount = 0;
  90.     // INSERT>> Your constructor code here.
  91. }
  92.  
  93.  
  94.  emeditMDIClient::~emeditMDIClient () {
  95.     Destroy();
  96.     // INSERT>> Your destructor code here.
  97. }
  98.  
  99.  
  100. //////////////////////////////////////////////////////////
  101. // emeditMDIClient
  102. // ===========
  103. // MDIClient site initialization.
  104. void emeditMDIClient::SetupWindow () {
  105.     // Default SetUpWindow processing.
  106.     TMDIClient::SetupWindow ();
  107.  
  108.     // Common file file flags and filters for Open/Save As dialogs.  Filename and directory are
  109.     // computed in the member functions CmFileOpen, and CmFileSaveAs.
  110.     FileData.Flags = OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;
  111.     FileData.SetFilter("All Files (*.*)|*.*|");
  112.  
  113.     // Accept files via drag/drop in the client window.
  114.     DragAcceptFiles(TRUE);
  115.  
  116.     GetRecentFiles(); // Read EMEDIT.INI and set recent file menu items appropriately
  117. }
  118.  
  119.  
  120.  
  121. void emeditMDIClient::SetDefaultBlockMarks( ENUM BlkType ) {
  122.   ((emeditApp*)GetApplication())->SetDefaultBlockType( BlkType );
  123.  
  124.   // loop through all the children and set the default block type
  125.   emeditMDIChild *child = TYPESAFE_DOWNCAST( GetFirstChild(), emeditMDIChild );
  126.   for (unsigned I= NumChildren(); I--;) {
  127.     emeditChildClient* const client = TYPESAFE_DOWNCAST(child->GetClientWindow(), emeditChildClient);
  128.  
  129.     if (client->editor->SetPropSelDefaultType( BlkType ) == 0  &&  BlkType == TVbxEditor::SelMark_3_Column) {
  130.       MessageBox("Can't do column blocks with proportional fonts.", GetApplication()->GetName(), MB_OK);
  131.       break;
  132.     }
  133.  
  134.     child = TYPESAFE_DOWNCAST( child->Next(), emeditMDIChild );
  135.   }
  136. }
  137.  
  138.  
  139.  
  140. void emeditMDIClient::GetRecentFiles() {
  141.   // Get recent file strings from EMEDIT.INI
  142.   char* key[]= { "RecentFile1", "RecentFile2", "RecentFile3", "RecentFile4" };
  143.   for (int I = 4; 1 <= I; I--) {
  144.  
  145.     // This variable must be large enough to hold the return string
  146.     // from the GetPrivateProfileString API.
  147.     char IniString[ 256 ];
  148.  
  149.     const int RetVal = GetPrivateProfileString("Recent Files", key[ I-1 ], "Not Used", IniString, sizeof(IniString) - 1, "EMEDIT.INI");
  150.     if (RetVal && strstr(IniString, "Not Used") == 0)
  151.       AppendFileMenuItem( IniString );
  152.   }
  153. }
  154.  
  155.  
  156.  
  157. void emeditMDIClient::WriteRecentFiles() {
  158.   char* key[]= { "RecentFile1", "RecentFile2", "RecentFile3", "RecentFile4" };
  159.  
  160.   for (int I= MRUFileItemCount; I--;)
  161.     WritePrivateProfileString("Recent Files", key[ I ], MostRecentFileNames[I].c_str(), "EMEDIT.INI");
  162. }
  163.  
  164.  
  165.  
  166.  
  167. void emeditMDIClient::AppendFileMenuItem(const char* fileitem) {
  168.   int bad= 0;
  169.   TMenu MainMenu( GetApplication()->GetMainWindow()->GetMenu() );
  170.   TMenu FileMenu( MainMenu.GetSubMenu(0) );
  171.  
  172.   // 1st, get to see if the file is already on the list
  173.   int onlist= FALSE;
  174.   for (int I= MRUFileItemCount; I--;)
  175.     if (MostRecentFileNames[ I ] == fileitem) {
  176.       onlist= I + 1;
  177.       break;
  178.     }
  179.  
  180.   // If the given file name is on the list but not in the top position then we
  181.   // must move it to the top position.
  182.   if (1 < onlist) {
  183.       string S= MostRecentFileNames[ onlist-1 ];
  184.  
  185.       // Move the given file name to the top of the list
  186.       for (int I= onlist-1; I--; )
  187.         MostRecentFileNames[ I + 1 ]= MostRecentFileNames[ I ];
  188.       MostRecentFileNames[0]= S;
  189.  
  190.       // Now, set the text on all da menu items...
  191.       for (int J= MRUFileItemCount; 1 <= J; J--) {
  192.         char N[7];
  193.         string X= "&";
  194.         X+= itoa( J, N, 10 );
  195.         X+= " ";
  196.         X+= MostRecentFileNames[ J-1 ];
  197.         FileMenu.ModifyMenu( CM_FILELAST1 + J - 1, MF_ENABLED | MF_STRING | MF_UNCHECKED, CM_FILELAST1 + J - 1, X.c_str() );
  198.       }
  199.   }
  200.  
  201.   // If the given file name is not on the list then we must add it (and
  202.   // possibly drop the least recently used file name).
  203.   if (!onlist) {
  204.  
  205.     // if there are no file names appended yet then
  206.     // add a separator to the end of the file menu
  207.     if (MRUFileItemCount == 0)
  208.       if (FileMenu.AppendMenu( MF_SEPARATOR, 0, 0 )==0)
  209.         bad= TRUE;
  210.  
  211.     // if there are less than four items on the list then we must add one
  212.     if (!bad)
  213.       if (MRUFileItemCount < 4)
  214.         if (FileMenu.AppendMenu( MF_ENABLED | MF_STRING | MF_UNCHECKED, CM_FILELAST1 + MRUFileItemCount )==0)
  215.           bad= TRUE;
  216.  
  217.     // Must now rearrange the text on the menu items
  218.     if (!bad) {
  219.       if (MRUFileItemCount < 4)
  220.         MRUFileItemCount++;
  221.  
  222.       for (int I= MRUFileItemCount-1; I--; )
  223.         MostRecentFileNames[ I + 1 ]= MostRecentFileNames[ I ];
  224.       MostRecentFileNames[0]= fileitem;
  225.  
  226.       // Now, set the text on all da menu items...
  227.       for (int J= MRUFileItemCount; 1 <= J; J--) {
  228.         char N[7];
  229.         string X= "&";
  230.         X+= itoa( J, N, 10 );
  231.         X+= " ";
  232.         X+= MostRecentFileNames[ J-1 ];
  233.         FileMenu.ModifyMenu( CM_FILELAST1 + J - 1, MF_ENABLED | MF_STRING | MF_UNCHECKED, CM_FILELAST1 + J - 1, X.c_str() );
  234.       }
  235.     }
  236.   }
  237. }
  238.  
  239.  
  240.  
  241. //
  242. // Open the modeless Replace commdlg
  243. //
  244.  
  245. //////////////////////////////////////////////////////////
  246. // emeditMDIClient
  247. // ===========
  248. // Menu File New command
  249. void emeditMDIClient::CmFileNew () {
  250.     char    title[255];
  251.  
  252.     // Generate a title for the MDI child window.
  253.     wsprintf(title, "%d", ChildCount++);
  254.  
  255.     emeditMDIChild* child = new emeditMDIChild( *this, title, 0 );
  256.  
  257.     // Associate ICON w/ this child window.
  258.     child->SetIcon(GetApplication(), IDI_DOC);
  259.  
  260.     // If the current active MDI child is maximize then this one should be also.
  261.     emeditMDIChild *curChild = (emeditMDIChild *)GetActiveMDIChild();
  262.     if (curChild && (curChild->GetWindowLong(GWL_STYLE) & WS_MAXIMIZE))
  263.         child->Attr.Style |= WS_MAXIMIZE;
  264.  
  265.     child->Create();
  266. }
  267.  
  268.  
  269. void emeditMDIClient::OpenFile (const char *fileName) {
  270.     if (fileName)
  271.         lstrcpy(FileData.FileName, fileName);
  272.  
  273.     // create the child window.  set the file name and file attributes that the
  274.     // editor contol should use when it sets itself up.
  275.     emeditMDIChild* child = new emeditMDIChild( *this, "", 0 );
  276.     emeditChildClient *cclient = TYPESAFE_DOWNCAST( child->GetClientWindow(), emeditChildClient );
  277.     cclient->editor->SetFileName( FileData.FileName );
  278.     cclient->editor->FileFlags= FileData.Flags;
  279.  
  280.     // Associate ICON w/ this child window.
  281.     child->SetIcon(GetApplication(), IDI_DOC);
  282.  
  283.     // If the current active MDI child is maximized then this one should be also.
  284.     emeditMDIChild *curChild = (emeditMDIChild *)GetActiveMDIChild();
  285.     if (curChild && (curChild->GetWindowLong(GWL_STYLE) & WS_MAXIMIZE))
  286.         child->Attr.Style |= WS_MAXIMIZE;
  287.  
  288.     child->Create();
  289.  
  290.     AppendFileMenuItem( FileData.FileName );
  291. }
  292.  
  293.  
  294. //////////////////////////////////////////////////////////
  295. // emeditMDIClient
  296. // ===========
  297. // Menu File Open command
  298. void emeditMDIClient::CmFileOpen ()
  299. {
  300.     //
  301.     // Display standard Open dialog box to select a file name.
  302.     //
  303.     *FileData.FileName = 0;
  304.     if (TFileOpenDialog(this, FileData).Execute() == IDOK)
  305.         OpenFile();
  306. }
  307.  
  308.  
  309. //////////////////////////////////////////////////////////
  310. // emeditMDIClient
  311. // ==========
  312. // Menu File Print command
  313. void emeditMDIClient::CmFilePrint ()
  314. {
  315.     //
  316.     // Create Printer object if not already created.
  317.     //
  318.     emeditApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), emeditApp);
  319.     if (theApp) {
  320.         if (!theApp->Printer)
  321.             theApp->Printer = new TPrinter;
  322.  
  323.         //
  324.         // Create Printout window and set characteristics.
  325.         //
  326.         APXPrintOut printout(theApp->Printer, Title, GetActiveMDIChild(), TRUE);
  327.  
  328.         theApp->Printing = TRUE;
  329.  
  330.         //
  331.         // Bring up the Print dialog and print the document.
  332.         //
  333.         theApp->Printer->Print(GetActiveMDIChild()->GetClientWindow(), printout, TRUE);
  334.  
  335.         theApp->Printing = FALSE;
  336.     }
  337. }
  338.  
  339.  
  340. //////////////////////////////////////////////////////////
  341. // emeditMDIClient
  342. // ==========
  343. // Menu File Print Setup command
  344. void emeditMDIClient::CmFilePrintSetup ()
  345. {
  346.     emeditApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), emeditApp);
  347.     if (theApp) {
  348.         if (!theApp->Printer)
  349.             theApp->Printer = new TPrinter;
  350.  
  351.         //
  352.         // Bring up the Print Setup dialog.
  353.         //
  354.         theApp->Printer->Setup(this);
  355.     }
  356. }
  357.  
  358.  
  359. //////////////////////////////////////////////////////////
  360. // emeditMDIClient
  361. // ==========
  362. // Menu File Print Preview command
  363. void emeditMDIClient::CmFilePrintPreview ()
  364. {
  365.     emeditApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), emeditApp);
  366.     if (theApp) {
  367.         if (!theApp->Printer)
  368.             theApp->Printer = new TPrinter;
  369.  
  370.         theApp->Printing = TRUE;
  371.  
  372.         PreviewWindow *prevW = new PreviewWindow(Parent, theApp->Printer, GetActiveMDIChild(), "Print Preview", new TLayoutWindow(0));
  373.         prevW->Create();
  374.  
  375.         GetApplication()->BeginModal(GetApplication()->MainWindow);
  376.  
  377.         // We must destroy the preview window explicitly.  Otherwise, the window will not be destroyed until
  378.         // it's parent the MainWindow is destroyed.
  379.         prevW->Destroy();
  380.         delete prevW;
  381.  
  382.         theApp->Printing = FALSE;
  383.     }
  384. }
  385.  
  386.  
  387. //////////////////////////////////////////////////////////
  388. // emeditMDIClient
  389. // ==========
  390. // Menu enabler used by Print, Print Setup and Print Preview.
  391. void emeditMDIClient::CmPrintEnable (TCommandEnabler &tce) {
  392.     if (GetActiveMDIChild()) {
  393.         emeditApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), emeditApp);
  394.         if (theApp) {
  395.             // If we have a Printer already created just test if all is okay.
  396.             // Otherwise create a Printer object and make sure the printer
  397.             // really exists and then delete the Printer object.
  398.             if (!theApp->Printer) {
  399.                 theApp->Printer = new TPrinter;
  400.  
  401.                 tce.Enable(theApp->Printer->GetSetup().Error == 0);
  402.             } else
  403.                 tce.Enable(theApp->Printer->GetSetup().Error == 0);
  404.         }
  405.     } else
  406.         tce.Enable(FALSE);
  407. }
  408.  
  409.  
  410.  
  411. void emeditMDIClient::EvDropFiles (TDropInfo) {
  412.     Parent->ForwardMessage();
  413. }
  414.  
  415.  
  416.  
  417. void emeditMDIClient::CmOptionsFont ()
  418. {
  419.   // Maybe I'm an idiot for not understanding how to use OWL to display
  420.   // the common font dialog, however, CMDIALOG.VBX is incredibly easy
  421.   // to use (assuming that you have the VB docs that explain how to use it)
  422.   // and so I use that instead of OWL here.  I think this is an example of
  423.   // why VBX's are so popular.
  424.  
  425.   // instantiate a common dialog control
  426.   string strFontName;
  427.   float fFontSize;
  428.   BOOL bFontBold, bFontItalic, bFontUnderLine, bFontStrikeThru;
  429.   COLORREF clrFontColor;
  430.   TVbxCommonDialog CMFontDialog(this, IDC_CMDIALOG1, 0, 0,0,0,0, sizeof( CommonDialogData ), CommonDialogData, ::Module );
  431.   CMFontDialog.Create();
  432.  
  433.   // Get the font attributes of the active window :
  434.   // WARNING, KLUDGE BELOW : So much for my flame above, while VBX's might in
  435.   // theory be productive the environment that supports them can't be lame.
  436.   // There seems to be a bug in BIVBX.DLL's support of the standard FontSize
  437.   // property, instead of returning the font size in points it seems to be
  438.   // returning the font size in twips, so I take the value returned from
  439.   // GetPropFontSize and divide by 20.  What's doubly bad about a bug like
  440.   // this (besides robbing me of my productivity) is that if Borland fixes the
  441.   // bug then the code below will not work for anyone with the new BIVBX DLL.
  442.   emeditMDIChild* child = TYPESAFE_DOWNCAST( GetActiveMDIChild(), emeditMDIChild );
  443.   emeditChildClient *cclient = TYPESAFE_DOWNCAST( child->GetClientWindow(), emeditChildClient );
  444.   emeditEditor* Text1 = cclient->editor;
  445.   Text1->GetPropFontName( strFontName );
  446.   Text1->GetPropFontSize( fFontSize ); fFontSize/= 20;
  447.   Text1->GetPropFontBold( bFontBold );
  448.   Text1->GetPropFontItalic( bFontItalic );
  449.   Text1->GetPropFontUnderline( bFontUnderLine );
  450.   Text1->GetPropFontStrikethru( bFontStrikeThru );
  451.   Text1->GetPropForeColor( clrFontColor );
  452.  
  453.   // set cancel to true
  454.   CMFontDialog.SetPropCancelError( TRUE );
  455.  
  456.   // Set the font attributes in the common dialog box to the font attributes
  457.   // in the current window:
  458.   CMFontDialog.SetPropFlags( 0x3 | 0x100 ); // CF_BOTH and CF_EFFECTS
  459.   CMFontDialog.SetPropFontName( strFontName );
  460.   CMFontDialog.SetPropFontSize( fFontSize );
  461.   CMFontDialog.SetPropFontBold( bFontBold );
  462.   CMFontDialog.SetPropFontItalic( bFontItalic );
  463.   CMFontDialog.SetPropFontUnderLine( bFontUnderLine );
  464.   CMFontDialog.SetPropFontStrikeThru( bFontStrikeThru );
  465.   CMFontDialog.SetPropColor( clrFontColor );
  466.  
  467.   // display the dialog box, if the user presses cancel then an error is
  468.   // generated and FALSE is returned.
  469.   BOOL OK= CMFontDialog.SetPropAction( 4 );
  470.  
  471.   // set the properties according to the user's selections...
  472.   if( OK ) {
  473.  
  474.     // Get the font attrbutes the user chose:
  475.     int CMFontDiallogFonstSize;
  476.     CMFontDialog.GetPropFontName( strFontName );
  477.     CMFontDialog.GetPropFontSize( CMFontDiallogFonstSize );
  478.     CMFontDialog.GetPropFontBold( bFontBold );
  479.     CMFontDialog.GetPropFontItalic( bFontItalic );
  480.     CMFontDialog.GetPropFontUnderLine( bFontUnderLine );
  481.     CMFontDialog.GetPropFontStrikeThru( bFontStrikeThru );
  482.     CMFontDialog.GetPropColor( clrFontColor );
  483.  
  484.     // Set the active window's font attributes to the user's choices:
  485.     Text1->SetPropVisible( FALSE );
  486.     Text1->SetPropFontName( strFontName );
  487.     Text1->SetPropFontSize( CMFontDiallogFonstSize * 20 );
  488.     Text1->SetPropFontBold( bFontBold );
  489.     Text1->SetPropFontItalic( bFontItalic );
  490.     Text1->SetPropFontUnderline( bFontUnderLine );
  491.     Text1->SetPropFontStrikethru( bFontStrikeThru );
  492.     Text1->SetPropForeColor( clrFontColor );
  493.     Text1->SetPropVisible( TRUE );
  494.   }
  495. }
  496.  
  497.  
  498. void emeditMDIClient::CmOptionsFontEnable (TCommandEnabler &tce) {
  499.      tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  500. }
  501.  
  502.  
  503. void emeditMDIClient::CmEditSelectAllEnable (TCommandEnabler &tce) {
  504.      tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  505. }
  506.  
  507.  
  508. void emeditMDIClient::CmEditTimeDateEnable (TCommandEnabler &tce) {
  509.      tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  510. }
  511.  
  512.  
  513.  
  514. void emeditMDIClient::CmEditTimeDate () {
  515.   time_t t = time(NULL);
  516.   string now( asctime( localtime( &t ) ) );
  517.   emeditMDIChild* child = TYPESAFE_DOWNCAST( GetActiveMDIChild(), emeditMDIChild );
  518.   emeditChildClient *cclient = TYPESAFE_DOWNCAST( child->GetClientWindow(), emeditChildClient );
  519.   cclient->editor->SetPropSelText( now.remove( now.length() - 1 ) );
  520. }
  521.  
  522.  
  523.  
  524. void emeditMDIClient::CmFileCloseEnable (TCommandEnabler &tce)  {
  525.   tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  526. }
  527.  
  528.  
  529. void emeditMDIClient::CmFileClose () { GetActiveMDIChild()->CloseWindow(); }
  530.  
  531.  
  532. void emeditMDIClient::CmStreamBlockEnable (TCommandEnabler &tce) 
  533. {
  534.   tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  535. }
  536.  
  537. void emeditMDIClient::CmFileLast1Enable (TCommandEnabler &tce) { tce.Enable( TRUE ); }
  538.  
  539. void emeditMDIClient::CmFileLast2Enable (TCommandEnabler &tce) { tce.Enable( TRUE ); }
  540.  
  541. void emeditMDIClient::CmFileLast3Enable (TCommandEnabler &tce) { tce.Enable( TRUE ); }
  542.  
  543. void emeditMDIClient::CmFileLast4Enable (TCommandEnabler &tce) { tce.Enable( TRUE ); }
  544.  
  545.  
  546. void emeditMDIClient::CmFileLast1 () { OpenFile( MostRecentFileNames[ 0 ].c_str() ); }
  547.  
  548.  
  549. void emeditMDIClient::CmFileLast2 () { OpenFile( MostRecentFileNames[ 1 ].c_str() ); }
  550.  
  551. void emeditMDIClient::CmFileLast3 () { OpenFile( MostRecentFileNames[ 2 ].c_str() ); }
  552.  
  553. void emeditMDIClient::CmFileLast4 () { OpenFile( MostRecentFileNames[ 3 ].c_str() ); }
  554.  
  555.  
  556. void emeditMDIClient::CmLineBlockEnable (TCommandEnabler &tce)
  557. {
  558.   tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  559. }
  560.  
  561.  
  562. void emeditMDIClient::CmColumnBlockEnable (TCommandEnabler &tce)
  563. {
  564.   tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  565. }
  566.  
  567.  
  568. void emeditMDIClient::CmColumnBlock () { SetDefaultBlockMarks( TVbxEditor::SelMark_3_Column ); }
  569.  
  570.  
  571. void emeditMDIClient::CmLineBlock () { SetDefaultBlockMarks( TVbxEditor::SelMark_2_Line ); }
  572.  
  573.  
  574. void emeditMDIClient::CmStreamBlock () { SetDefaultBlockMarks( TVbxEditor::SelMark_1_Stream ); }
  575.  
  576.  
  577. void emeditMDIClient::CMEditClearEnable (TCommandEnabler &tce)
  578. {
  579.   tce.Enable(GetActiveMDIChild() ? TRUE : FALSE);
  580. }
  581.  
  582.  
  583. void emeditMDIClient::CleanupWindow ()
  584. {
  585.     TMDIClient::CleanupWindow();
  586.  
  587.     // INSERT>> Your code here.
  588.     WriteRecentFiles();
  589. }
  590.  
  591.  
  592.  
  593. void emeditMDIClient::SetInsertMode( BOOL mode ) {
  594.   // loop through all the children and set the insert mode
  595.   emeditMDIChild *child = TYPESAFE_DOWNCAST( GetFirstChild(), emeditMDIChild );
  596.   for (unsigned I= NumChildren(); I--;) {
  597.     emeditChildClient* const client = TYPESAFE_DOWNCAST(child->GetClientWindow(), emeditChildClient);
  598.  
  599.     client->editor->SetPropInsertMode( mode ); // set insert mode
  600.  
  601.     // change caret width based on insert mode
  602.     int caretwidth;
  603.     client->editor->GetPropCaretWidth( caretwidth );
  604.     client->editor->SetPropCaretWidth( mode ? (caretwidth >> 1) : (caretwidth << 1) );
  605.  
  606.     child = TYPESAFE_DOWNCAST( child->Next(), emeditMDIChild );
  607.   }
  608. }
  609.  
  610.