- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
(extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
BT game source (never mixed into CODE/). Round 1-3 state:
* 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
(BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
since 1996.
* BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
its binary-recorded line 400 exactly.
* BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
(Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
TeamScore=12 flagged [T4]).
* MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
(VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
the period compiler is the drift detector).
* Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
(per-TU verification sweep under authentic OPT.MAK flags).
* README: corrected roadmap - MECH.HPP is the capstone grown with the mech
TU reconstructions; BTREG.CPP green = the header-family milestone.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
307 lines
8.3 KiB
C++
307 lines
8.3 KiB
C++
///----------------------------------------------------------------------------
|
|
// ObjectWindows - (C) Copyright 1994 by Borland International
|
|
//----------------------------------------------------------------------------
|
|
#include <owl/owlpch.h>
|
|
#include <owl/applicat.h>
|
|
#include <owl/gdiobjec.h>
|
|
|
|
#include <ocf/ocfpch.h>
|
|
#include <ocf/ocapp.h>
|
|
#include <ocf/ocdoc.h>
|
|
#include <ocf/ocview.h>
|
|
#include <ocf/ocstorag.h>
|
|
#include <ocf/ocreg.h>
|
|
|
|
#include <owl/ocfevent.h>
|
|
#include <owl/uihandle.h>
|
|
#include <owl/printer.h>
|
|
#include <owl/preview.h>
|
|
|
|
#include <owl/oleframe.h>
|
|
#include <owl/docview.rh>
|
|
|
|
#include "sampcont.h"
|
|
#define USE_WINDOW_PRINTOUT
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Printout class that prints the contents of a window
|
|
//
|
|
class TWindowPrintout : public TPrintout {
|
|
public:
|
|
TWindowPrintout(const char* title, TWindow* window, BOOL scale = TRUE)
|
|
: TPrintout(title)
|
|
{ Window = window;
|
|
Scale = scale;
|
|
MapMode = MM_ISOTROPIC; // Respect aspect ratio of window
|
|
//MapMode = MM_ANISOTROPIC; // Make printout fill the page
|
|
}
|
|
|
|
void GetDialogInfo(int& minPage, int& maxPage, int& selFromPage, int& selToPage);
|
|
void PrintPage(int page, TRect& rect, unsigned flags);
|
|
|
|
protected:
|
|
TWindow* Window;
|
|
BOOL Scale;
|
|
int MapMode;
|
|
};
|
|
|
|
|
|
// Do not enable page range in the print dialog since only one page is
|
|
// available to be printed
|
|
//
|
|
void TWindowPrintout::GetDialogInfo(int& minPage, int& maxPage, int& selFromPage, int& selToPage)
|
|
{
|
|
minPage = 0;
|
|
maxPage = 0;
|
|
selFromPage = selToPage = 0;
|
|
}
|
|
|
|
|
|
void TWindowPrintout::PrintPage(int /*page*/, TRect& bandRect, unsigned /*flags*/)
|
|
{
|
|
// Conditionally scale the DC to the window so the printout will
|
|
// resemble the window
|
|
//
|
|
int oldMode;
|
|
TSize oldVExt, oldWExt;
|
|
if (Scale) {
|
|
oldMode = DC->SetMapMode(MapMode);
|
|
TRect clientR = Window->GetClientRect();
|
|
DC->SetViewportExt(PageSize, &oldVExt);
|
|
DC->SetWindowExt(clientR.Size(), &oldWExt);
|
|
DC->IntersectClipRect(clientR);
|
|
DC->DPtoLP(bandRect, 2);
|
|
}
|
|
|
|
// Call the window to paint itself to the printer DC.
|
|
//
|
|
Window->Paint(*DC, FALSE, bandRect);
|
|
|
|
// Restore changes made to the DC
|
|
//
|
|
if (Scale) {
|
|
DC->SetWindowExt(oldWExt);
|
|
DC->SetViewportExt(oldVExt);
|
|
DC->SetMapMode(oldMode);
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
class TModalFrame : public TFrameWindow {
|
|
public:
|
|
TModalFrame(TWindow* parent, const char far* title, TWindow* client) :
|
|
TFrameWindow(parent, title, client),
|
|
TWindow(parent, title) {}
|
|
|
|
virtual void Destroy(int ret);
|
|
};
|
|
|
|
|
|
void TModalFrame::Destroy(int ret)
|
|
{
|
|
GetApplication()->EndModal(IDCANCEL);
|
|
GetApplication()->MainWindow->EnableWindow(TRUE);
|
|
|
|
TWindow::Destroy(ret);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
DEFINE_RESPONSE_TABLE1(TOleSampContainer, TOleWindow)
|
|
EV_COMMAND(CM_FILESAVE, CmFileSave),
|
|
EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
|
|
EV_COMMAND(CM_EXIT, CmExit),
|
|
EV_COMMAND(CM_FILEPRINT, CmFilePrint),
|
|
EV_COMMAND(CM_FILEPRINTERSETUP, CmFilePrinterSetup),
|
|
EV_COMMAND(CM_FILEPRINTPREVIEW, CmPrintPreview),
|
|
END_RESPONSE_TABLE;
|
|
|
|
BEGIN_REGISTRATION(docReg)
|
|
REGDATA(progid, "MdiOle")
|
|
REGDATA(description,"MdiOle Document")
|
|
REGFORMAT(0, ocrEmbedSource, ocrContent, ocrIStorage, ocrGet)
|
|
REGFORMAT(1, ocrMetafilePict, ocrContent, ocrMfPict|ocrStaticMed, ocrGet)
|
|
REGFORMAT(2, ocrBitmap, ocrContent, ocrGDI|ocrStaticMed, ocrGet)
|
|
REGFORMAT(3, ocrDib, ocrContent, ocrHGlobal|ocrStaticMed, ocrGet)
|
|
REGFORMAT(4, ocrLinkSource, ocrContent, ocrIStream, ocrGet)
|
|
END_REGISTRATION
|
|
|
|
|
|
TOleSampContainer::TOleSampContainer(TWindow* parent,
|
|
const char far* fileName,
|
|
TModule* module)
|
|
: TOleWindow(parent, module)
|
|
{
|
|
// Create a OcDocument object to hold the ole parts that we create
|
|
// and a OcView to provide ole services
|
|
//
|
|
OcDoc = new TOcDocument(*OcApp, fileName);
|
|
OcView = new TOcView(*OcDoc, &docReg);
|
|
|
|
// Perform actual file loading, and let the OcDoc load its parts
|
|
//
|
|
if (fileName) {
|
|
strcpy(FileData.FileName, fileName);
|
|
OcDoc->LoadParts();
|
|
} else {
|
|
strcpy(FileData.FileName, "");
|
|
}
|
|
FileData.Flags = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
|
|
FileData.SetFilter(string(*GetModule(), IDS_DOCFILEFILTER).c_str());
|
|
Printer = new TPrinter;
|
|
}
|
|
|
|
TOleSampContainer::~TOleSampContainer()
|
|
{
|
|
delete Printer;
|
|
}
|
|
|
|
//
|
|
// Perform normal SetupWindow, plus let the OcView object know our HWND so that
|
|
// it can talk to us.
|
|
//
|
|
void
|
|
TOleSampContainer::SetupWindow()
|
|
{
|
|
TOleWindow::SetupWindow();
|
|
SetDocTitle(*FileData.FileName ? FileData.FileName : "Untitled", 0);
|
|
}
|
|
|
|
void
|
|
TOleSampContainer::CleanupWindow()
|
|
{
|
|
TOleWindow::CleanupWindow();
|
|
}
|
|
|
|
void
|
|
TOleSampContainer::CmExit()
|
|
{
|
|
OcView->EvClose();
|
|
OcDoc->Close();
|
|
TWindow::CmExit();
|
|
}
|
|
|
|
//
|
|
// Perform a save operation (or saveAs if doc is untitled) This saves the parts
|
|
// and commits the storage
|
|
//
|
|
void
|
|
TOleSampContainer::CmFileSave()
|
|
{
|
|
if (!OcDoc->GetName().length()) {
|
|
CmFileSaveAs();
|
|
} else {
|
|
OcDoc->SaveParts(0, true);
|
|
OcDoc->GetStorage()->Commit(STGC_DEFAULT);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Save the document to a new storage file
|
|
//
|
|
void
|
|
TOleSampContainer::CmFileSaveAs()
|
|
{
|
|
*FileData.FileName = 0;
|
|
if (TFileSaveDialog(this, FileData).Execute() == IDOK) {
|
|
if (OcDoc->SaveToFile(FileData.FileName)) {
|
|
OcDoc->GetStorage()->Commit(STGC_DEFAULT);
|
|
SetDocTitle(FileData.FileName, 0);
|
|
} else
|
|
MessageBox("Cannot save to new file", "File save error", MB_OK);
|
|
}
|
|
}
|
|
|
|
void
|
|
TOleSampContainer::CmFilePrint() // Execute File:Print command
|
|
{
|
|
if (Printer) {
|
|
TWindowPrintout printout("OLE2 Container", this);
|
|
Printer->Print(this, printout, TRUE);
|
|
}
|
|
}
|
|
|
|
void
|
|
TOleSampContainer::CmFilePrinterSetup() // Execute File:Printer-setup command
|
|
{
|
|
if (Printer)
|
|
Printer->Setup(this);
|
|
}
|
|
|
|
void TOleSampContainer::CmPrintPreview()
|
|
{
|
|
// Create the printer DC. If it fails, let the print dialog report the error
|
|
// for us.
|
|
//
|
|
TPrintDC* prnDC;
|
|
try {
|
|
prnDC = new TPrintDC(Printer->GetSetup().GetDriverName(),
|
|
Printer->GetSetup().GetDeviceName(),
|
|
Printer->GetSetup().GetOutputName(),
|
|
Printer->GetSetup().GetDevMode());
|
|
}
|
|
catch (TGdiBase::TXGdi) {
|
|
TPrintDialog(Parent, Printer->GetSetup()).Execute();
|
|
return;
|
|
}
|
|
|
|
TSize printExtent(prnDC->GetDeviceCaps(HORZRES), prnDC->GetDeviceCaps(VERTRES));
|
|
|
|
#if defined(USE_WINDOW_PRINTOUT)
|
|
TWindowPrintout printout("Print Preview", this);
|
|
#else
|
|
TTestPrintout printout("Print Preview");
|
|
#endif
|
|
|
|
TLayoutWindow* layout = new TLayoutWindow(0);
|
|
layout->SetBkgndColor(GetSysColor(COLOR_APPWORKSPACE));
|
|
|
|
for (int i = 0; i < 1; i++) {
|
|
TPreviewPage* page = new TPreviewPage(layout, printout, *prnDC, printExtent);
|
|
|
|
TLayoutMetrics metrics;
|
|
metrics.X.Set(lmLeft, lmRightOf, lmParent, lmLeft, 15);
|
|
metrics.Y.Set(lmTop, lmBelow, lmParent, lmTop, 15);
|
|
|
|
//
|
|
// Determine major axis of preview page, have that follow parent size.
|
|
// Make minor axis a percentage (aspect ratio) of the page's major axis
|
|
//
|
|
if (printExtent.cx > printExtent.cy) {
|
|
metrics.Width.Set(lmRight, lmLeftOf, lmParent, lmRight, 15);
|
|
metrics.Height.PercentOf(page, int((long(printExtent.cy)*100)/printExtent.cx),
|
|
lmWidth);
|
|
} else {
|
|
metrics.Height.Set(lmBottom, lmAbove, lmParent, lmBottom, 15);
|
|
metrics.Width.PercentOf(page, int((long(printExtent.cx)*100)/printExtent.cy),
|
|
lmHeight);
|
|
}
|
|
|
|
layout->SetChildLayoutMetrics(*page, metrics);
|
|
}
|
|
|
|
TFrameWindow* frame = new TModalFrame(this, "Preview", layout);
|
|
frame->Create();
|
|
frame->ShowWindow(SW_SHOWNORMAL);
|
|
|
|
GetApplication()->BeginModal(Parent);
|
|
delete prnDC;
|
|
}
|
|
|
|
//
|
|
// See if we can close. Also let OcView know we are going away
|
|
//
|
|
BOOL
|
|
TOleSampContainer::CanClose()
|
|
{
|
|
if (!TOleWindow::CanClose())
|
|
return false;
|
|
|
|
OcView->EvClose();
|
|
OcDoc->Close();
|
|
return true;
|
|
}
|
|
|
|
|