home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 May
/
VPR9705A.ISO
/
VPR_DATA
/
PROGRAM
/
CBTRIAL
/
SETUP
/
DATA.Z
/
PIEREG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-14
|
4KB
|
136 lines
//---------------------------------------------------------------------------
// Borland C++Builder
// Copyright (c) 1987, 1997 Borland International Inc. All Rights Reserved.
//---------------------------------------------------------------------------
#pragma hdrstop //since we include .cpp files we can't use pre compiled headers
#include <SysUtils.hpp>
#include <memory> //For use of auto_ptr
#if !defined (REGISTER_ALL_CONTROLS)
#include "piereg.h"
#include "pies.cpp"
#else
#include "source\piereg.h"
#include "source\pies.cpp"
#endif
#pragma resource "*.dfm"
//#pragma resource "*.res" //IDE links .res automatically for components
//---------------------------------------------------------------------------
namespace Piereg{
void __fastcall Register()
{
TComponentClass classes[1] = {__classid(TPie)};
RegisterComponents("Samples", classes, 0);
RegisterComponentEditor(__classid(TPie), __classid(TPieEditor));
RegisterPropertyEditor(__typeinfo(TAngles),
NULL,
"",
__classid(TAnglesProperty));
}
} //namespace
//---------------------------------------------------------------------------
// TAngleEditorDlg
__fastcall TAngleEditorDlg::TAngleEditorDlg(TComponent* AOwner) : TForm(AOwner) { }
__fastcall TAngleEditorDlg::TAngleEditorDlg(TComponent* AOwner, int Dummy) : TForm(AOwner, Dummy) { }
__fastcall TAngleEditorDlg::TAngleEditorDlg(HWND ParentWindow) : TForm(ParentWindow) { }
__fastcall TAngleEditorDlg::~TAngleEditorDlg(void) { }
void __fastcall TAngleEditorDlg::STrackBarChange(TObject* /*Sender*/)
{
SetStartAngle(STrackBar->Position);
}
void __fastcall TAngleEditorDlg::ETrackBarChange(TObject* /*Sender*/)
{
SetEndAngle(ETrackBar->Position);
}
void __fastcall TAngleEditorDlg::SetStartAngle(Integer Value)
{
STrackBar->Position = Value;
SAngleLabel->Caption = "StartAngle = " + String(Value);
FAngles->StartAngle = Value;
}
void __fastcall TAngleEditorDlg::SetEndAngle(Integer Value)
{
ETrackBar->Position = Value;
EAngleLabel->Caption = "EndAngle = " + String(Value);
FAngles->EndAngle = Value;
}
void __fastcall TAngleEditorDlg::SetAngles(TAngles* Value)
{
FAngles = Value;
FOrigStart = Value->StartAngle;
FOrigEnd = Value->EndAngle;
SetStartAngle(Value->StartAngle);
SetEndAngle(Value->EndAngle);
}
void __fastcall TAngleEditorDlg::CancelClick(TObject* /*Sender*/)
{
SetStartAngle(FOrigStart);
SetEndAngle(FOrigEnd);
}
//---------------------------------------------------------------------------
// TAnglesProperty
__fastcall TAnglesProperty::TAnglesProperty(void) : TClassProperty() { }
__fastcall TAnglesProperty::~TAnglesProperty(void) { }
void __fastcall TAnglesProperty::Edit()
{
//We use the auto_ptr so that the object is destroyed automatically
//on exit of the function.
// std::auto_ptr<TAngles> Angles(new TAngles());
std::auto_ptr<TAngleEditorDlg> AngleEditor(new TAngleEditorDlg(Application));
AngleEditor->EditorAngles = (TAngles*)GetOrdValue();
AngleEditor->ShowModal();
}
TPropertyAttributes __fastcall TAnglesProperty::GetAttributes()
{
return (TPropertyAttributes() << paDialog << paSubProperties);
}
//---------------------------------------------------------------------------
//TPieEditor
__fastcall TPieEditor::TPieEditor(TComponent* AComponent, TFormDesigner* ADesigner)
: TDefaultEditor(AComponent, ADesigner) { }
__fastcall TPieEditor::~TPieEditor(void) { }
void __fastcall TPieEditor::EditProperty(TPropertyEditor* PropertyEditor,
bool& Continue,
bool& /*FreeEditor*/)
{
String PropName(PropertyEditor->GetName());
if (strcmpi(PropName.c_str(),"ANGLES") == 0){
PropertyEditor->Edit();
Continue = false;
}
}
int __fastcall TPieEditor::GetVerbCount()
{
return 1;
}
String __fastcall TPieEditor::GetVerb(Integer Index)
{
if (Index == 0)
return "Edit Angles";
else return "";
}
void __fastcall TPieEditor::ExecuteVerb(Integer Index)
{
if (Index == 0) Edit();
}
//---------------------------------------------------------------------------