home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 May
/
Pcwk5b98.iso
/
Borland
/
Cplus45
/
BC45
/
EXPERT.PAK
/
TOLEVIEW.OWL
< prev
next >
Wrap
Text File
|
1995-08-29
|
7KB
|
229 lines
<<[H]TOleView [[TOleView]]
##{hheader.snp}
#include <owl\owlpch.h>
#pragma hdrstop
##<<TApplication QUERY_FILENAME_CPP [[Filename]]
#include "[[Filename]].rh" // Definition of all resources.
//{{TOleView = [[TOleView]]}}
class [[TOleView]] : public TOleView {
public:
[[TOleView]] (TDocument& doc, TWindow* parent = 0);
virtual ~[[TOleView]] ();
##--BEGIN-- @OPT_APPL_TOOLBAR
private:
TControlBar *ToolBar;
##--END-- @OPT_APPL_TOOLBAR
##--BEGIN-- @OPT_APPL_PRINTING
//{{[[TOleView]]VIRTUAL_BEGIN}}
public:
virtual void Paint (TDC& dc, bool erase, TRect& rect);
##:DBVirtual(\\"[[TOleView]]", "Paint")
//{{[[TOleView]]VIRTUAL_END}}
##--END-- @OPT_APPL_PRINTING
##--BEGIN-- @OPT_APPL_PRINTING || @OPT_APPL_TOOLBAR
//{{[[TOleView]]RSP_TBL_BEGIN}}
protected:
##@OPT_APPL_PRINTING
void EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo);
##@OPT_APPL_TOOLBAR
bool EvOcViewShowTools (TOcToolBarInfo far& tbi);
//{{[[TOleView]]RSP_TBL_END}}
DECLARE_RESPONSE_TABLE([[TOleView]]);
##--END-- @OPT_APPL_PRINTING || @OPT_APPL_TOOLBAR
}; //{{[[TOleView]]}}
##{hfooter.snp}
>>[H]TOleView [[TOleView]]
<<[CPP]TOleView [[TOleView]]
##{cheader.snp}
#include <owl\owlpch.h>
#pragma hdrstop
##<<TApplication QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
##QUERY_FILE_H [[FileName]]
#include "[[FileName]]"
#include <stdio.h>
//{{[[TOleView]] Implementation}}
##--BEGIN-- @OPT_APPL_PRINTING || @OPT_APPL_TOOLBAR
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//
// Build a response table for all messages/commands handled
// by [[TOleView]] derived from TOleView.
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
DEFINE_RESPONSE_TABLE1([[TOleView]], TOleView)
//{{[[TOleView]]RSP_TBL_BEGIN}}
## @OPT_APPL_PRINTING
## :DBResponse(\\"[[TOleView]]", "", "", "WM_GETMINMAXINFO", "")
EV_WM_GETMINMAXINFO,
## @OPT_APPL_TOOLBAR
## :DBResponse(\\"[[TOleView]]", "", "", "OC_VIEWSHOWTOOLS", "")
EV_OC_VIEWSHOWTOOLS,
//{{[[TOleView]]RSP_TBL_END}}
END_RESPONSE_TABLE;
##--END-- @OPT_APPL_PRINTING || @OPT_APPL_TOOLBAR
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//////////////////////////////////////////////////////////
// [[TOleView]]
// ==========
// Construction/Destruction handling.
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
[[TOleView]]::[[TOleView]] (TDocument& doc, TWindow* parent)
: TOleView(doc, parent)
{
##QUERY_WIND_STYLE [[StyleAttributes]]
##StyleAttributes != "" 3
// Override the default window style for TOleView.
[[StyleAttributes]]
##QUERY_WIND_BACKGRND [[BackgroundColor]]
##BackgroundColor != "" 3
// Change the window's background color
SetBkgndColor([[BackgroundColor]]);
##@OPT_APPL_TOOLBAR 2
ToolBar = 0;
// INSERT>> Your constructor code here.
}
[[TOleView]]::~[[TOleView]] ()
{
// INSERT>> Your destructor code here.
}
##--BEGIN-- @OPT_APPL_PRINTING == TRUE
##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
//
// Paint routine for Window, Printer, and PrintPreview for a TOleView client.
//
##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
void [[TOleView]]::Paint (TDC& dc, bool erase, TRect& rect)
{
##<<TApplication QUERY_CLASS_NAME [[TApplication]]
[[TApplication]] *theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
if (theApp) {
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
// Only paint if we're printing and we have something to paint, otherwise do nothing.
if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
// Use pageSize to get the size of the window to render into. For a Window it's the client area,
// for a printer it's the printer DC dimensions and for print preview it's the layout window.
TSize pageSize(rect.right - rect.left, rect.bottom - rect.top);
TPrintDialog::TData &printerData = theApp->Printer->GetSetup();
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
// Compute the number of pages to print.
printerData.MinPage = 1;
printerData.MaxPage = 1;
TOcView *ocView = GetOcView();
##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 3
//
// Default TOcPart painting
//
TRect clientRect = GetClientRect();
TRect logicalRect = clientRect + (TSize&)ocView->GetOrigin();
for (TOcPartCollectionIter i(GetOcDoc()->GetParts()); i; i++) {
TOcPart& p = *i.Current();
if (p.IsVisible(logicalRect)) {
TRect r = p.GetRect();
r -= ocView->GetOrigin();
p.Draw(dc, r, clientRect); // Draw the embedded object.
if (p.IsSelected()) {
TUIHandle handle(r,
TUIHandle::HandlesIn |
TUIHandle::Grapples |
TUIHandle::HatchBorder,
5);
handle.Paint(dc);
} else {
TUIHandle handle(r, TUIHandle::HatchBorder, 5);
handle.Paint(dc);
}
}
}
// INSERT>> Special printing code goes here.
} else {
TOleView::Paint(dc, erase, rect);
// INSERT>> Normal painting code goes here.
}
##--BEGIN-- @QUERY_APPL_OLE == VALUE_SERVER
##@QUERY_PRJ_NAME [[Title]]
dc.TextOut(0, 30, "[[Title]] OLE Server");
##--END-- @QUERY_APPL_OLE == VALUE_SERVER
}
}
void [[TOleView]]::EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo)
{
##<<TApplication QUERY_CLASS_NAME [[TApplication]]
[[TApplication]] *theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
if (theApp) {
if (theApp->Printing) {
minmaxinfo.ptMaxSize = TPoint(32000, 32000);
minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000);
return;
}
}
TOleView::EvGetMinMaxInfo(minmaxinfo);
}
##--END-- @OPT_APPL_PRINTING == TRUE
##--BEGIN-- @OPT_APPL_TOOLBAR
bool [[TOleView]]::EvOcViewShowTools (TOcToolBarInfo far& tbi)
{
// Construct & create a control bar for show, destroy our bar for hide
if (tbi.Show) {
if (!ToolBar) {
ToolBar = new TControlBar(this);
##<<TApplication QUERY_CLASS_NAME [[TApplication]]
[[TApplication]] *theApp = TYPESAFE_DOWNCAST(GetApplication(), [[TApplication]]);
CHECK(theApp);
theApp->CreateGadgets(ToolBar, true);
}
ToolBar->Create();
tbi.HTopTB = (HWND)*ToolBar;
} else {
if (ToolBar) {
ToolBar->Destroy();
delete ToolBar;
ToolBar = 0;
}
}
return true;
}
##--END-- @OPT_APPL_TOOLBAR
>>[CPP]TOleView [[TOleView]]