home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
xped2
/
xped2app.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-12
|
5KB
|
217 lines
/* Project xped2
Copyright ⌐ 1993. All Rights Reserved.
SUBSYSTEM: xped2.exe Application
FILE: xped2app.cpp
AUTHOR:
OVERVIEW
========
Source file for implementation of XpEd2App (TApplication).
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include "xped2app.h"
#include "xped2abd.h" // Definition of about dialog.
//{{XpEd2App Implementation}}
//
// Build a response table for all messages/commands handled
// by the application.
//
DEFINE_RESPONSE_TABLE1(XpEd2App, TApplication)
//{{XpEd2AppRSP_TBL_BEGIN}}
EV_COMMAND(CM_FILENEW, CmFileNew),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_FILECLOSE, CmFileClose),
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
//{{XpEd2AppRSP_TBL_END}}
END_RESPONSE_TABLE;
//
// FrameWindow must be derived to override Paint for Preview and Print.
//
class SDIDecFrame : public TDecoratedFrame {
public:
SDIDecFrame (TWindow *parent, const char far *title, TWindow *clientWnd, BOOL trackMenuSelection = FALSE, TModule *module = 0) :
TDecoratedFrame(parent, title, clientWnd, trackMenuSelection, module)
{ }
~SDIDecFrame ()
{ }
};
//////////////////////////////////////////////////////////
// XpEd2App
// =====
//
XpEd2App::XpEd2App () : TApplication("xped2")
{
// Common file file flags and filters for Open/Save As dialogs. Filename and directory are
// computed in the member functions CmFileOpen, and CmFileSaveAs.
FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
FileData.SetFilter("All Files (*.*)|*.*|");
// INSERT>> Your constructor code here.
}
XpEd2App::~XpEd2App ()
{
// INSERT>> Your destructor code here.
}
void XpEd2App::SetupSpeedBar (TDecoratedFrame *frame)
{
//
// Create default toolbar New and associate toolbar buttons with commands.
//
TControlBar* cb = new TControlBar(frame);
cb->Insert(*new TButtonGadget(CM_FILENEW, CM_FILENEW));
cb->Insert(*new TButtonGadget(CM_FILEOPEN, CM_FILEOPEN));
cb->Insert(*new TButtonGadget(CM_FILESAVE, CM_FILESAVE));
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_EDITCUT, CM_EDITCUT));
cb->Insert(*new TButtonGadget(CM_EDITCOPY, CM_EDITCOPY));
cb->Insert(*new TButtonGadget(CM_EDITPASTE, CM_EDITPASTE));
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_EDITUNDO, CM_EDITUNDO));
cb->Insert(*new TSeparatorGadget(6));
cb->Insert(*new TButtonGadget(CM_EDITFIND, CM_EDITFIND));
cb->Insert(*new TButtonGadget(CM_EDITFINDNEXT, CM_EDITFINDNEXT));
// Add fly-over help hints.
cb->SetHintMode(TGadgetWindow::EnterHints);
frame->Insert(*cb, TDecoratedFrame::Top);
}
//////////////////////////////////////////////////////////
// XpEd2App
// =====
// Application intialization.
//
void XpEd2App::InitMainWindow ()
{
Client = new TEditFile(0, 0, 0);
SDIDecFrame *frame = new SDIDecFrame(0, GetName(), Client, TRUE);
nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWMAXIMIZED : nCmdShow;
//
// Assign ICON w/ this application.
//
frame->SetIcon(this, IDI_SDIAPPLICATION);
//
// Menu associated with window and accelerator table associated with table.
//
frame->AssignMenu(SDI_MENU);
//
// Associate with the accelerator table.
//
frame->Attr.AccelTable = SDI_MENU;
SetupSpeedBar(frame);
TStatusBar *sb = new TStatusBar(frame, TGadget::Recessed,
TStatusBar::CapsLock |
TStatusBar::NumLock |
TStatusBar::ScrollLock |
TStatusBar::Overtype);
frame->Insert(*sb, TDecoratedFrame::Bottom);
MainWindow = frame;
//
// Borland Windows custom controls.
//
EnableBWCC();
}
//////////////////////////////////////////////////////////
// XpEd2App
// ===========
// Menu File New command
void XpEd2App::CmFileNew ()
{
Client->NewFile();
}
//////////////////////////////////////////////////////////
// XpEd2App
// ===========
// Menu File Open command
void XpEd2App::CmFileOpen ()
{
//
// Display standard Open dialog box to select a file name.
//
*FileData.FileName = 0;
if (Client->CanClose())
if (TFileOpenDialog(MainWindow, FileData).Execute() == IDOK)
OpenFile();
}
void XpEd2App::OpenFile (const char *fileName)
{
if (fileName)
lstrcpy(FileData.FileName, fileName);
Client->ReplaceWith(FileData.FileName);
}
//////////////////////////////////////////////////////////
// XpEd2App
// =====
// Menu File Close command
void XpEd2App::CmFileClose ()
{
if (Client->CanClose())
Client->DeleteSubText(0, UINT(-1));
}
//////////////////////////////////////////////////////////
// XpEd2App
// ===========
// Menu Help About xped2.exe command
void XpEd2App::CmHelpAbout ()
{
//
// Show the modal dialog.
//
XpEd2AboutDlg(MainWindow).Execute();
}
int OwlMain (int , char* [])
{
XpEd2App App;
int result;
result = App.Run();
return result;
}