//-------------------------------------------
// DrawBox.h - sicherer@sichemsoft.nl
// Complete commented code available on line
//-------------------------------------------
// ... #includes and typedefs omitted
//-------------------------------------------
typedef void __fastcall
(__closure *TDrawBoxMarkEvent)
(System::TObject* Sender,
double Left, double Top,
double Right, double Bottom);
// ... other closure type definitions omitted
//-------------------------------------------
class PACKAGE TDrawBox :
public TScrollingWinControl
{
typedef TScrollingWinControl inherited;
friend class TDrawBoxSurface;
friend class TDrawBoxPrintThread;
// ... other typedefs omitted
__published:
__property bool CrossHairs =
{read=GetCrossHairs, write=SetCrossHairs};
// ... other property declarations omitted
__property TDrawBoxMarkEvent OnMarked =
{ read=FOnMarked, write=FOnMarked };
__property TNotifyEvent OnPaint =
{ read=FOnPaint, write=FOnPaint };
// ... other event declarations omitted
public:
__fastcall TDrawBox(TComponent* Owner);
virtual __fastcall ~TDrawBox();
void
SetWindowExtents(double x1, double y1,
double x2, double y2);
// ... other window/viewport functions omitted
bool
SaveToFileAsEMF(const AnsiString &file,
double x1, double y1,
double x2, double y2)
// ... other save/print functions omitted
void
DrawLine(double x1, double y1,
double x2, double y2);
// ... other drawing functions omitted
protected:
virtual void __fastcall
SetCrossHairs(bool on);
virtual bool __fastcall
GetCrossHairs() const;
// ... other property access functions omitted
private:
TDrawBoxMarkEvent FOnMarked;
TNotifyEvent FOnPaint;
// ... other event variables omitted
TDrawBoxSurface *Surface;// drawing surface
TCanvas *Canvas; // where to draw
// ... other member variables omitted
void
NotifyMarked(int x1, int y1,
int x2, int y2, bool region);
void
NotifyMouseUp(TMouseButton button,
TShiftState shift, int x, int y)
void NotifyPaint();
// ... other notifications omitted
bool ScrollIfNeeded();
TMetafile
*CreateMetafile(double x1, double y1,
double x2, double y2);
bool
Save(const AnsiString &filename, bool emf,
double x1, double y1,
double x2, double y2);
// ... other private member functions omitted
};
//-------------------------------------------
class TDrawBoxSurface : public TPaintBox
{
typedef TPaintBox inherited;
friend TDrawBox; // all members private!
private:
TDrawBox *DrawBox; // pointer to parent
int OriginX, OriginY; // remember coords
int CurrentX, CurrentY; // ... during
// ... marking
bool CrossHairs; // show crosshairs?
TTimer *Timer; // for marking
// ... outside
// ... other member variables omitted
__fastcall
TDrawBoxSurface(TComponent* owner);
DYNAMIC void __fastcall
MouseUp(TMouseButton Button,
TShiftState Shift, int X, int Y);
// ... other mouse events omitted
void __fastcall TimerTick(TObject* Sender);
// ... other private member functions omitted
};
//-------------------------------------------
// class TDrawBoxPrintThread : background
// print
// ... entire declaration omitted
//-------------------------------------------