//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Clock.h"
#include <math.h>
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
void __fastcall TCenter::SetX(int value)
{
if( value != FX )
{
FX = value;
UpdateParent();
}
}
void __fastcall TCenter::SetY(int value)
{
if( value != FY )
{
FY = value;
UpdateParent();
}
}
void __fastcall TCenter::UpdateParent(void)
{
FParent->Repaint();
}
TCenter::TCenter() : TPersistent()
{
FX = 50;
FY = 50;
}
//class THand--------------------------------------------------------
void __fastcall THand::SetRadius(int value)
{
if( value != FRadius )
{
FRadius = value;
UpdateParent();
}
}
void __fastcall THand::SetBackRadius(int value)
{
if( value != FBackRadius )
{
FBackRadius = value;
UpdateParent();
}
}
void __fastcall THand::SetWidth(int value)
{
if( value != FWidth )
{
FWidth = value;
UpdateParent();
}
}
void __fastcall THand::SetColor(TColor value)
{
if( value != FColor )
{
FColor = value;
UpdateParent();
}
}
void __fastcall THand::UpdateParent(void)
{
FParent->Repaint();
}
THand::THand() : TPersistent()
{
}
//class TCenterPoint------------------------------------------------------------
void __fastcall TCenterPoint::SetPointSize(int value)
{
if( value != FPointSize )
{
FPointSize = value;
UpdateParent();
}
}
void __fastcall TCenterPoint::SetPenSize(int value)
{
if( value != FPenSize )
{
FPenSize = value;
UpdateParent();
}
}
void __fastcall TCenterPoint::SetPenColor(TColor value)
{
if( value != FPenColor )
{
FPenColor = value;
UpdateParent();
}
}
void __fastcall TCenterPoint::SetFillColor(TColor value)
{
if( value != FFillColor )
{
FFillColor = value;
UpdateParent();
}
}
void __fastcall TCenterPoint::UpdateParent(void)
{
FParent->Repaint();
}
TCenterPoint::TCenterPoint() : TPersistent()
{
}
//class TClock------------------------------------------------------------------
__fastcall TClock::TClock(TComponent* AOwner) : TCustomControl(AOwner)
{
Width = 100;
Height = 100;
FOldWidth = Width;
FOldHeight = Height;
FTransparentColor = clFuchsia;
FTransparent = false;
DisImage = new Graphics::TBitmap();
WorkImage = new Graphics::TBitmap();
FPicture = new Graphics::TPicture();
FStepTimer = new TTimer(this); //建立时钟发生器
FInterval = 1000;
FInterActive = true;
FStepTimer->Enabled = FInterActive;
FStepTimer->Interval = FInterval;
FStepTimer->OnTimer = UpdateClock;
FVerInfo = "sundiy's super Clock";
FColorOrBmp = bgPicture;
FAutoCenter = true;
FHourHandEnabled = true;
FMinuteHandEnabled = true;
FSecondHandEnabled = true;
FPictureStyle = psNone;
FThemeStyle = tsNone;
FRoundX = 25;
FRoundY = 25;
FHoleRound = false;
FCenter = new TCenter;
FCenter->Parent = this;
FCenter->X = 50;
FCenter->Y = 50;
FHourHand = new THand;
FHourHand->Parent = this;
FHourHand->BackRadius = 6;
FHourHand->Color = clGreen;
FHourHand->Radius = 25;
FHourHand->Width = 2;
FMinuteHand = new THand;
FMinuteHand->Parent = this;
FMinuteHand->BackRadius = 6;
FMinuteHand->Color = clBlue;
FMinuteHand->Radius = 30;
FMinuteHand->Width = 2;
FSecondHand = new THand;
FSecondHand->Parent = this;
FSecondHand->BackRadius = 11;
FSecondHand->Color = clRed;
FSecondHand->Radius = 38;
FSecondHand->Width = 1;
FDrawCenterPoint = new TCenterPoint;
FDrawCenterPoint->Parent = this;
FDrawCenterPoint->PointSize = 4;
FDrawCenterPoint->PenSize = 1;
FDrawCenterPoint->FillColor = clBlack;
FDrawCenterPoint->PenColor = clWhite;
}
__fastcall TClock::~TClock(void)
{
delete FStepTimer;
delete WorkImage;
delete DisImage;
delete FPicture;
}
void __fastcall TClock::SetPicture(TPicture* value)
{
if( !(value->Graphic->Empty) )
{
FPicture->Assign(value);
Width = FPicture->Width;
Height = FPicture->Height;
Repaint();
}
}
void __fastcall TClock::SetTransparent(bool value)
{
if( value != FTransparent )
{
FTransparent = value;
Repaint();
}
}
void __fastcall TClock::SetTransparentColor(TColor Value)
{
if( Value != FTransparentColor )
{
FTransparentColor = Value;
Repaint();
}
}
void __fastcall TClock::SetInterval(int Value)
{
if( Value != FInterval )
{
FInterval = Value;
FStepTimer->Interval = FInterval;
Repaint();
}
}
void __fastcall TClock::SetActive(bool Value)
{
if( Value != Active )
{
FInterActive = Value;
FStepTimer->Enabled = FInterActive;
Repaint();
}
}
void __fastcall TClock::VersionMark(String value)
{
}
void __fastcall TClock::SetBgColor(TColor Value)
{
if( Value != FBgUseColor )
{
FBgUseColor = Value;
Repaint();
}
}
void __fastcall TClock::SetBgStyle(TClockBgStyle Value)
{
if( Value != FColorOrBmp )
{
FColorOrBmp = Value;
Repaint();
}
}
void __fastcall TClock::SetCenterPoint(bool Value)
{
if( Value != FCenterPoint )
{
FCenterPoint = Value;
Repaint();
}
}
void __fastcall TClock::SetAutoCenter(bool Value)
{
if( Value != FAutoCenter )
{
if( Value )
{
FCenter->X = Width / 2;
FCenter->Y = Height / 2;
}
FAutoCenter = Value;
Repaint();
}
}
void __fastcall TClock::SetHourHandEnabled(bool value)
{
if( value != FHourHandEnabled )
{
FHourHandEnabled = value;
Repaint();
}
}
void __fastcall TClock::SetMinuteHandEnabled(bool value)
{
if( value != FMinuteHandEnabled )
{
FMinuteHandEnabled = value;
Repaint();
}
}
void __fastcall TClock::SetSecondHandEnabled(bool value)
{
if( value != FSecondHandEnabled )
{
FSecondHandEnabled = value;
Repaint();
}
}
void __fastcall TClock::SetPictureStyle(TClockPictureStyle Value)
{
if( Value != FPictureStyle )
{
FPictureStyle = Value;
Repaint();
}
}
void __fastcall TClock::SetThemeStyle(TClockThemeStyle value)
{
if( value != FThemeStyle )
{
FThemeStyle = value;
StyleChanged();
}
}
void __fastcall TClock::SetRoundX(int Value)
{
if( Value != FRoundX )
{
FRoundX = Value;
StyleChanged();
}
}
void __fastcall TClock::SetRoundY(int Value)
{
if( Value != FRoundY )
{
FRoundY = Value;
StyleChanged();
}
}
void __fastcall TClock::SetHoleRound(bool Value)
{
if( Value != FHoleRound )
{
FHoleRound = Value;
Repaint();
}
}
void __fastcall TClock::UpdateClock(TObject* Sender)
{
Word H,M,S,MS;
TDateTime dt = Now();
dt.DecodeTime(&H, &M, &S, &MS);
Paint();
if( s != OldSecond)
{
if( NULL != FSecond )
FSecond(this, s);
OldSecond = s;
}
if( m != OldMinute)
{
if( NULL != FMinute )
FMinute(this, m);
OldMinute = m;
}
if( h != OldHour )
{
if( NULL != FHo
没有合适的资源?快使用搜索试试~ 我知道了~
c++builder 时钟控件
共5个文件
cpp:2个
res:1个
bpk:1个
4星 · 超过85%的资源 需积分: 10 33 下载量 32 浏览量
2011-03-17
16:38:27
上传
评论 2
收藏 7KB RAR 举报
温馨提示
c++builder 时钟控件 控件 时钟 指针 可分别设置时、分、秒针显示 可设置背景图片
资源推荐
资源详情
资源评论
收起资源包目录
fsclock.rar (5个子文件)
fsclock
fsClock.cpp 524B
Clock.h 8KB
Clock.cpp 14KB
fsClock.res 2KB
fsClock.bpk 3KB
共 5 条
- 1
资源评论
- 老小笨鸟2012-04-16好东西,学习控件制作的源代码,感谢帖主啊
- kevin_20092013-01-03这个有点意思
- 小米粥再来一碗2012-06-27这个还是很不错的,特别是像我这样的菜鸟,用起来还是很方便的~
- elitegroup2013-12-11不错,很方便。 效果也OK,推荐。
ddrvos
- 粉丝: 12
- 资源: 40
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功