, C++Builder, . , LED.h TColor , . 3 - , private . , _ published ( 6.15).
//---------------________________________________-_____-_--
#ifndef LEDH
#define LEDH //------------_____-_____--_________________________-___--.
#include <vcl\SysUtils.hpp>
#include <vcl\Controls.hpp>
#include <vcl\Classes.hpp>
#include <vcl\Forms.hpp> ^include <vcl\ExtCtrls.hpp> //____----------__________________________________------
class TLED: public TShape { private:
bool FOnOff;TColor FOnColor; TColor FOffColor;
void _fastcall SetOnOff(const bool Value);
void _fastcall ' SetOnColor
void _ fastcall SetOffColor (conet TColor OffColor);
protected:
public:
_fastcall TLED(TComponent* Owners- published:
property bool LEDOn= { read= FOnOff,write= SetOnOff); property l OnColor= { read=FOnColor,write=SetOnColor};:.,. __property TColor OffColor=
{ read=FOff Color, write= SetOffColor};
};
//_____________-___-_----____________------------------
#endif
6.15. LED.h .
LED.cpp ( 6.16). , .
#include <vcl\vcl.h>
#pragma hdrstop
# include "LED.h" //_------------____-----------.------------
static inline TLED *ValidCtrCheck() {
return new TLED(MULL);
)
void _fastcall TLED::SetOnOf?(const bool Value) {
POnOff = Value;
Brush->Color (POnOff)? FOnColor: POffColor?
}
//_--^-.-..
void _fastcall TLED::SetOnColor(const TColor OnColor) {
POnColor = OnColor;
Brush->Color = (FOnOff)? FOnColor: FOffColor;
}
//--------------------------------
void _fastcall TLED::SetOfColor(const TColor OffColor) {
FOffColor = OffColor;
Brush->Color = (FOnOff)? FOnColor: FOffColor;
}
//---_------------------------------------------------------
_fastcall TLED::TLED(TComponent* Owner): TShape(Owner)
{
Width = 15; // Height = 15; // FOnColor = cILime; // , FOffColor = cIRed; // , FOnOff = false; // Shape? atEllipse; // Pen->Color = clBlack; // Pen->Width = 2; // Brush->Color ^ FOffColor; //
|
|
}
//---------------____-______________________--________.
namespace Led
{
void _fastcall Register () {
TComponentClass classes[1] = {__ classid(TLED)};
RegisterComponents("Samples", classes, 0);
} }
6.16. LED.cpp .
. , . , . *