First commit 25/07/1999
This commit is contained in:
168
ActImg/actimg.cpp
Normal file
168
ActImg/actimg.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl\vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "actimg.h"
|
||||
|
||||
#pragma package(smart_init)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// ValidCtrCheck is used to assure that the components created do not have
|
||||
// any pure virtual functions.
|
||||
//
|
||||
static inline TActiveImage *ValidCtrCheck()
|
||||
{
|
||||
return new TActiveImage(NULL);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
#define FGlyph Canvas
|
||||
__fastcall TActiveImage::TActiveImage(TComponent* Owner)
|
||||
: TCustomControl(Owner)
|
||||
{
|
||||
CState = CSt_NORMAL;
|
||||
|
||||
Width = 50;
|
||||
Height = 50;
|
||||
|
||||
FGlyph->Brush->Color = clNone;
|
||||
FGlyph->Brush->Style = bsClear;
|
||||
FGlyph->CopyMode = cmSrcCopy;
|
||||
|
||||
RCanvas = Canvas;
|
||||
|
||||
GlyphNormal = new Graphics::TBitmap;
|
||||
GlyphOver = new Graphics::TBitmap;
|
||||
GlyphPress = new Graphics::TBitmap;
|
||||
|
||||
vAutoSize = false;
|
||||
|
||||
MouseCaptured = false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
namespace Actimg
|
||||
{
|
||||
void __fastcall PACKAGE Register()
|
||||
{
|
||||
TComponentClass classes[1] = {__classid(TActiveImage)};
|
||||
RegisterComponents("JD Soft.", classes, 0);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::Paint()
|
||||
{
|
||||
Graphics::TBitmap *Bitmap;
|
||||
|
||||
Brush->Color = clNone;
|
||||
Brush->Style = bsClear;
|
||||
|
||||
switch ( CState )
|
||||
{
|
||||
case CSt_PRESS:
|
||||
Bitmap = GlyphPress;
|
||||
break;
|
||||
case CSt_OVER:
|
||||
Bitmap = GlyphOver;
|
||||
break;
|
||||
case CSt_NORMAL:
|
||||
default:
|
||||
Bitmap = GlyphNormal;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! Bitmap -> Empty )
|
||||
FGlyph->BrushCopy( ClientRect, Bitmap, Rect( 0, 0, Bitmap->Width-1, Bitmap->Height-1 ), Bitmap->TransparentColor );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TActiveImage::~TActiveImage()
|
||||
{
|
||||
delete GlyphNormal;
|
||||
delete GlyphOver;
|
||||
delete GlyphPress;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::MouseMove( Classes::TShiftState Shift, int X, int Y )
|
||||
{
|
||||
/*
|
||||
if( CState != CSt_OVER && CState != CSt_PRESS )
|
||||
{
|
||||
if ( !MouseCaptured && SetCapture( Handle ) != NULL ) MouseCaptured = true;
|
||||
CState = CSt_OVER;
|
||||
Refresh();
|
||||
}
|
||||
if( (X<0) || (Y<0) || (X>Width) || (Y>Height))
|
||||
{
|
||||
if ( ReleaseCapture() != 0 ) MouseCaptured = false;
|
||||
CState = CSt_NORMAL;
|
||||
Refresh();
|
||||
}else{
|
||||
TCustomControl::MouseMove( Shift, X, Y );
|
||||
}
|
||||
*/
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::MouseDown( TMouseButton Button, Classes::TShiftState Shift, int X, int Y)
|
||||
{
|
||||
CState = CSt_PRESS;
|
||||
Refresh();
|
||||
// if ( ReleaseCapture() != 0 ) MouseCaptured = false;
|
||||
TCustomControl::MouseDown( Button, Shift, X, Y );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::MouseUp( TMouseButton Button, Classes::TShiftState Shift, int X, int Y)
|
||||
{
|
||||
CState = CSt_NORMAL;
|
||||
// if ( ReleaseCapture() != 0 ) { MouseCaptured = false; Refresh(); }
|
||||
TCustomControl::MouseUp( Button, Shift, X, Y );
|
||||
MouseMove( Shift, X, Y );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::SetGlyphOver( Graphics::TBitmap *val )
|
||||
{
|
||||
GlyphOver -> Assign( val );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::SetGlyphPress( Graphics::TBitmap *val )
|
||||
{
|
||||
GlyphPress -> Assign( val );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::SetGlyphNormal( Graphics::TBitmap *val )
|
||||
{
|
||||
GlyphNormal -> Assign( val );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::SetAutoSize( bool val )
|
||||
{
|
||||
vAutoSize = val;
|
||||
// Facilitamos la anchura y altura del control
|
||||
if ( vAutoSize && ! GlyphNormal->Empty )
|
||||
{
|
||||
Width = GlyphNormal->Width;
|
||||
Height = GlyphNormal->Height;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::CreateParams(TCreateParams &Params)
|
||||
{
|
||||
TCustomControl::CreateParams(Params); // La clase ascendente se ocupar<61> de establecer los par<61>metros generales
|
||||
Params.ExStyle = Params.ExStyle | WS_EX_TRANSPARENT;
|
||||
|
||||
// Params.Style = Params.Style | BS_OWNERDRAW;
|
||||
// TButton::ControlStyle = TControlStyle();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TActiveImage::CMMouseEnter ( TMessage& Msg )
|
||||
{
|
||||
CState = CSt_OVER;
|
||||
Refresh();
|
||||
inherited::Dispatch ( &Msg );
|
||||
}
|
||||
|
||||
void __fastcall TActiveImage::CMMouseLeave ( TMessage& Msg )
|
||||
{
|
||||
CState = CSt_NORMAL;
|
||||
Refresh();
|
||||
inherited::Dispatch ( &Msg );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user