Initial commit

This commit is contained in:
2026-06-13 00:05:19 +08:00
commit 754cd7ccdb
402 changed files with 123771 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+139
View File
@@ -0,0 +1,139 @@
//---------------------------------------------------------------------------
#ifndef CapButtonH
#define CapButtonH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Imaging.pnglang.hpp>
#include <Vcl.Graphics.hpp>
//---------------------------------------------------------------------------
class PACKAGE TCapButton : public TGraphicControl
{
public:
enum TModalResult{
mrNone = System::Int8(0x0),
mrOk = System::Int8(0x1),
mrCancel = System::Int8(0x2),
mrAbort = System::Int8(0x3),
mrRetry = System::Int8(0x4),
mrIgnore = System::Int8(0x5),
mrYes = System::Int8(0x6),
mrNo = System::Int8(0x7),
mrClose = System::Int8(0x8),
mrHelp = System::Int8(0x9),
mrTryAgain = System::Int8(0xa),
mrContinue = System::Int8(0xb),
mrAll = System::Int8(0xc),
mrNoToAll = System::Int8(0xd),
mrYesToAll = System::Int8(0xe)
};
private:
COLORREF
clrFrameExNormal,
clrFrameExEnter,
clrFrameExDisable,
clrFrameNormal,
clrLineNormal,
clrRectNormal,
clrRectDisable,
clrCapArrowOpenBound[10],
clrCapArrowOpenLine[4],
clrExFrameBound[4],
clrExFrameBoundDisable[4];
TColor FBorderColor;
TColor FInterFrameColor;
TColor FInterColor;
void __fastcall IniColor(int nstate);
COLORREF __fastcall TransformColor(COLORREF icolor, int nNum=0, bool bplus=true);
void __fastcall SetBorderColor(TColor iBorderColor);
void __fastcall SetInterFrameColor(TColor iInterFrameColor);
void __fastcall SetInterColor(TColor iInterColor);
private:
String FCaption;
TNotifyEvent FOnMouseEnter;//on mouse enter notify event
TNotifyEvent FOnMouseLeave;//on mouse leave notify event
// System::Uitypes::TModalResult FModalResult;
TModalResult FModalResult;
int __fastcall GetFontSize();
MESSAGE void __fastcall CMMouseEnter(Winapi::Messages::TMessage &Msg); // to know when mouse is entered
MESSAGE void __fastcall CMMouseLeave(Winapi::Messages::TMessage &Msg); // to know when mouse is leaved
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TGraphicControl)
protected:
bool FEnablePNG; //是否加载了png格式图片背景
bool FDown; // value to know if we painting mouse down
int EtatBtn; // 0=Normal 1=Mouse entered 2=Pressed 3=Disabled
int FStateCount;
Vcl::Imaging::Pngimage::TPngImage *FPngImg; //our 4 states image
DYNAMIC void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall SetEnabled(bool Value);
public:
__fastcall virtual TCapButton(System::Classes::TComponent* AOwner);
__fastcall virtual ~TCapButton(void);
void __fastcall SetStateCount( int count );
void __fastcall SetPngImg(Vcl::Imaging::Pngimage::TPngImage *value); // we set the png image
void __fastcall SetDown(bool value); // to know if mouse is down or not
void __fastcall SetEnablePNG(bool Value);// to know if customer set png img
void __fastcall SetCaption(String Value);
virtual void __fastcall Paint(void); // override the painting of the component
DYNAMIC void __fastcall Click(void);
__published:
__property Action;
__property Anchors = {default=3};
__property bool Down = {read=FDown, write=SetDown, default=False};
__property Enabled = {default=1};
__property int ImgStates = {read=FStateCount, write=SetStateCount, default=4};
// __property System::Uitypes::TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property ParentShowHint = {default=1};
__property Vcl::Imaging::Pngimage::TPngImage *PngImg = {read=FPngImg, write=SetPngImg};
__property PopupMenu;
__property ShowHint;
__property Visible = {default=1};
__property OnClick;
__property OnContextPopup;
__property OnMouseDown;
__property OnMouseMove;
__property OnMouseUp;
__property System::Classes::TNotifyEvent OnMouseEnter = {read=FOnMouseEnter, write=FOnMouseEnter};
__property System::Classes::TNotifyEvent OnMouseLeave = {read=FOnMouseLeave, write=FOnMouseLeave};
__property bool EnablePNG = {read=FEnablePNG, write=SetEnablePNG, default=False};
__property TColor BorderColor = {read=FBorderColor, write=SetBorderColor, default=TColor(0x83807d)};
__property TColor InterFrameColor = {read=FInterFrameColor, write=SetInterFrameColor, default=TColor(0x302e2c)};
__property TColor InterColor = {read=FInterColor, write=SetInterColor, default=TColor(0x58504a)};
private:
Vcl::Imaging::Pngimage::TPngImage *m_pPngButton, *m_pPngFoucusButton;
Vcl::Imaging::Pngimage::TPngImage *pTmpDraw, *pTmpFoucusDraw;
void __fastcall PaintCustomer(void);
void __fastcall PaintCustomerText(void);
public:
TRect rtCaption;
void __fastcall SetFontSize( int value );
void __fastcall SetFont(String name, int size );
__published:
__property String Caption = {read=FCaption, write=FCaption};
__property int FontSize = {read=GetFontSize, write=SetFontSize, default=8};
};
//---------------------------------------------------------------------------
#endif
+17
View File
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
+664
View File
@@ -0,0 +1,664 @@
//---------------------------------------------------------------------------
#pragma hdrstop
#include "CKBox.h"
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
static inline void ValidCtrCheck(TCKBox *)
{
new TCKBox(NULL);
}
#define BOX_RECT RGB( 145, 156, 170 )
#define CLR_ENABLED RGB( 100, 108, 119 )
#define CLR_ENABLED_1 RGB( 119, 129, 130 )
#define CLR_CAPTION RGB( 172, 184, 200 )
#define RET_LEFT 4
#define RET_W 10
#define CLR_RECT_1_1 RGB( 100, 108, 119 ) //bMouse 内条
#define CLR_RECT_1_2 RGB( 87,96,111 )
//#define CLR_RECT_2_1 RGB( 102,113,130 ) // bMouse&&!FCheck
//#define CLR_RECT_2_2 RGB( 43,46,51 ) //Check
//#define CLR_RECT_2_3 RGB( 77,85,100 ) //Nor
#define MIN_H 6
#define MIN_W 11
const static char pngImageCheck[] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,
0x0d,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0x0c,0x00,
0x00,0x00,0x0b,0x08,0x06,0x00,0x00,0x00,0x4b,0x70,
0x6c,0x5f,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,
0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,0x13,0x01,0x00,
0x9a,0x9c,0x18,0x00,0x00,0x0a,0x4d,0x69,0x43,0x43,
0x50,0x50,0x68,0x6f,0x74,0x6f,0x73,0x68,0x6f,0x70,
0x20,0x49,0x43,0x43,0x20,0x70,0x72,0x6f,0x66,0x69,
0x6c,0x65,0x00,0x00,0x78,0xda,0x9d,0x53,0x77,0x58,
0x93,0xf7,0x16,0x3e,0xdf,0xf7,0x65,0x0f,0x56,0x42,
0xd8,0xf0,0xb1,0x97,0x6c,0x81,0x00,0x22,0x23,0xac,
0x08,0xc8,0x10,0x59,0xa2,0x10,0x92,0x00,0x61,0x84,
0x10,0x12,0x40,0xc5,0x85,0x88,0x0a,0x56,0x14,0x15,
0x11,0x9c,0x48,0x55,0xc4,0x82,0xd5,0x0a,0x48,0x9d,
0x88,0xe2,0xa0,0x28,0xb8,0x67,0x41,0x8a,0x88,0x5a,
0x8b,0x55,0x5c,0x38,0xee,0x1f,0xdc,0xa7,0xb5,0x7d,
0x7a,0xef,0xed,0xed,0xfb,0xd7,0xfb,0xbc,0xe7,0x9c,
0xe7,0xfc,0xce,0x79,0xcf,0x0f,0x80,0x11,0x12,0x26,
0x91,0xe6,0xa2,0x6a,0x00,0x39,0x52,0x85,0x3c,0x3a,
0xd8,0x1f,0x8f,0x4f,0x48,0xc4,0xc9,0xbd,0x80,0x02,
0x15,0x48,0xe0,0x04,0x20,0x10,0xe6,0xcb,0xc2,0x67,
0x05,0xc5,0x00,0x00,0xf0,0x03,0x79,0x78,0x7e,0x74,
0xb0,0x3f,0xfc,0x01,0xaf,0x6f,0x00,0x02,0x00,0x70,
0xd5,0x2e,0x24,0x12,0xc7,0xe1,0xff,0x83,0xba,0x50,
0x26,0x57,0x00,0x20,0x91,0x00,0xe0,0x22,0x12,0xe7,
0x0b,0x01,0x90,0x52,0x00,0xc8,0x2e,0x54,0xc8,0x14,
0x00,0xc8,0x18,0x00,0xb0,0x53,0xb3,0x64,0x0a,0x00,
0x94,0x00,0x00,0x6c,0x79,0x7c,0x42,0x22,0x00,0xaa,
0x0d,0x00,0xec,0xf4,0x49,0x3e,0x05,0x00,0xd8,0xa9,
0x93,0xdc,0x17,0x00,0xd8,0xa2,0x1c,0xa9,0x08,0x00,
0x8d,0x01,0x00,0x99,0x28,0x47,0x24,0x02,0x40,0xbb,
0x00,0x60,0x55,0x81,0x52,0x2c,0x02,0xc0,0xc2,0x00,
0xa0,0xac,0x40,0x22,0x2e,0x04,0xc0,0xae,0x01,0x80,
0x59,0xb6,0x32,0x47,0x02,0x80,0xbd,0x05,0x00,0x76,
0x8e,0x58,0x90,0x0f,0x40,0x60,0x00,0x80,0x99,0x42,
0x2c,0xcc,0x00,0x20,0x38,0x02,0x00,0x43,0x1e,0x13,
0xcd,0x03,0x20,0x4c,0x03,0xa0,0x30,0xd2,0xbf,0xe0,
0xa9,0x5f,0x70,0x85,0xb8,0x48,0x01,0x00,0xc0,0xcb,
0x95,0xcd,0x97,0x4b,0xd2,0x33,0x14,0xb8,0x95,0xd0,
0x1a,0x77,0xf2,0xf0,0xe0,0xe2,0x21,0xe2,0xc2,0x6c,
0xb1,0x42,0x61,0x17,0x29,0x10,0x66,0x09,0xe4,0x22,
0x9c,0x97,0x9b,0x23,0x13,0x48,0xe7,0x03,0x4c,0xce,
0x0c,0x00,0x00,0x1a,0xf9,0xd1,0xc1,0xfe,0x38,0x3f,
0x90,0xe7,0xe6,0xe4,0xe1,0xe6,0x66,0xe7,0x6c,0xef,
0xf4,0xc5,0xa2,0xfe,0x6b,0xf0,0x6f,0x22,0x3e,0x21,
0xf1,0xdf,0xfe,0xbc,0x8c,0x02,0x04,0x00,0x10,0x4e,
0xcf,0xef,0xda,0x5f,0xe5,0xe5,0xd6,0x03,0x70,0xc7,
0x01,0xb0,0x75,0xbf,0x6b,0xa9,0x5b,0x00,0xda,0x56,
0x00,0x68,0xdf,0xf9,0x5d,0x33,0xdb,0x09,0xa0,0x5a,
0x0a,0xd0,0x7a,0xf9,0x8b,0x79,0x38,0xfc,0x40,0x1e,
0x9e,0xa1,0x50,0xc8,0x3c,0x1d,0x1c,0x0a,0x0b,0x0b,
0xed,0x25,0x62,0xa1,0xbd,0x30,0xe3,0x8b,0x3e,0xff,
0x33,0xe1,0x6f,0xe0,0x8b,0x7e,0xf6,0xfc,0x40,0x1e,
0xfe,0xdb,0x7a,0xf0,0x00,0x71,0x9a,0x40,0x99,0xad,
0xc0,0xa3,0x83,0xfd,0x71,0x61,0x6e,0x76,0xae,0x52,
0x8e,0xe7,0xcb,0x04,0x42,0x31,0x6e,0xf7,0xe7,0x23,
0xfe,0xc7,0x85,0x7f,0xfd,0x8e,0x29,0xd1,0xe2,0x34,
0xb1,0x5c,0x2c,0x15,0x8a,0xf1,0x58,0x89,0xb8,0x50,
0x22,0x4d,0xc7,0x79,0xb9,0x52,0x91,0x44,0x21,0xc9,
0x95,0xe2,0x12,0xe9,0x7f,0x32,0xf1,0x1f,0x96,0xfd,
0x09,0x93,0x77,0x0d,0x00,0xac,0x86,0x4f,0xc0,0x4e,
0xb6,0x07,0xb5,0xcb,0x6c,0xc0,0x7e,0xee,0x01,0x02,
0x8b,0x0e,0x58,0xd2,0x76,0x00,0x40,0x7e,0xf3,0x2d,
0x8c,0x1a,0x0b,0x91,0x00,0x10,0x67,0x34,0x32,0x79,
0xf7,0x00,0x00,0x93,0xbf,0xf9,0x8f,0x40,0x2b,0x01,
0x00,0xcd,0x97,0xa4,0xe3,0x00,0x00,0xbc,0xe8,0x18,
0x5c,0xa8,0x94,0x17,0x4c,0xc6,0x08,0x00,0x00,0x44,
0xa0,0x81,0x2a,0xb0,0x41,0x07,0x0c,0xc1,0x14,0xac,
0xc0,0x0e,0x9c,0xc1,0x1d,0xbc,0xc0,0x17,0x02,0x61,
0x06,0x44,0x40,0x0c,0x24,0xc0,0x3c,0x10,0x42,0x06,
0xe4,0x80,0x1c,0x0a,0xa1,0x18,0x96,0x41,0x19,0x54,
0xc0,0x3a,0xd8,0x04,0xb5,0xb0,0x03,0x1a,0xa0,0x11,
0x9a,0xe1,0x10,0xb4,0xc1,0x31,0x38,0x0d,0xe7,0xe0,
0x12,0x5c,0x81,0xeb,0x70,0x17,0x06,0x60,0x18,0x9e,
0xc2,0x18,0xbc,0x86,0x09,0x04,0x41,0xc8,0x08,0x13,
0x61,0x21,0x3a,0x88,0x11,0x62,0x8e,0xd8,0x22,0xce,
0x08,0x17,0x99,0x8e,0x04,0x22,0x61,0x48,0x34,0x92,
0x80,0xa4,0x20,0xe9,0x88,0x14,0x51,0x22,0xc5,0xc8,
0x72,0xa4,0x02,0xa9,0x42,0x6a,0x91,0x5d,0x48,0x23,
0xf2,0x2d,0x72,0x14,0x39,0x8d,0x5c,0x40,0xfa,0x90,
0xdb,0xc8,0x20,0x32,0x8a,0xfc,0x8a,0xbc,0x47,0x31,
0x94,0x81,0xb2,0x51,0x03,0xd4,0x02,0x75,0x40,0xb9,
0xa8,0x1f,0x1a,0x8a,0xc6,0xa0,0x73,0xd1,0x74,0x34,
0x0f,0x5d,0x80,0x96,0xa2,0x6b,0xd1,0x1a,0xb4,0x1e,
0x3d,0x80,0xb6,0xa2,0xa7,0xd1,0x4b,0xe8,0x75,0x74,
0x00,0x7d,0x8a,0x8e,0x63,0x80,0xd1,0x31,0x0e,0x66,
0x8c,0xd9,0x61,0x5c,0x8c,0x87,0x45,0x60,0x89,0x58,
0x1a,0x26,0xc7,0x16,0x63,0xe5,0x58,0x35,0x56,0x8f,
0x35,0x63,0x1d,0x58,0x37,0x76,0x15,0x1b,0xc0,0x9e,
0x61,0xef,0x08,0x24,0x02,0x8b,0x80,0x13,0xec,0x08,
0x5e,0x84,0x10,0xc2,0x6c,0x82,0x90,0x90,0x47,0x58,
0x4c,0x58,0x43,0xa8,0x25,0xec,0x23,0xb4,0x12,0xba,
0x08,0x57,0x09,0x83,0x84,0x31,0xc2,0x27,0x22,0x93,
0xa8,0x4f,0xb4,0x25,0x7a,0x12,0xf9,0xc4,0x78,0x62,
0x3a,0xb1,0x90,0x58,0x46,0xac,0x26,0xee,0x21,0x1e,
0x21,0x9e,0x25,0x5e,0x27,0x0e,0x13,0x5f,0x93,0x48,
0x24,0x0e,0xc9,0x92,0xe4,0x4e,0x0a,0x21,0x25,0x90,
0x32,0x49,0x0b,0x49,0x6b,0x48,0xdb,0x48,0x2d,0xa4,
0x53,0xa4,0x3e,0xd2,0x10,0x69,0x9c,0x4c,0x26,0xeb,
0x90,0x6d,0xc9,0xde,0xe4,0x08,0xb2,0x80,0xac,0x20,
0x97,0x91,0xb7,0x90,0x0f,0x90,0x4f,0x92,0xfb,0xc9,
0xc3,0xe4,0xb7,0x14,0x3a,0xc5,0x88,0xe2,0x4c,0x09,
0xa2,0x24,0x52,0xa4,0x94,0x12,0x4a,0x35,0x65,0x3f,
0xe5,0x04,0xa5,0x9f,0x32,0x42,0x99,0xa0,0xaa,0x51,
0xcd,0xa9,0x9e,0xd4,0x08,0xaa,0x88,0x3a,0x9f,0x5a,
0x49,0x6d,0xa0,0x76,0x50,0x2f,0x53,0x87,0xa9,0x13,
0x34,0x75,0x9a,0x25,0xcd,0x9b,0x16,0x43,0xcb,0xa4,
0x2d,0xa3,0xd5,0xd0,0x9a,0x69,0x67,0x69,0xf7,0x68,
0x2f,0xe9,0x74,0xba,0x09,0xdd,0x83,0x1e,0x45,0x97,
0xd0,0x97,0xd2,0x6b,0xe8,0x07,0xe9,0xe7,0xe9,0x83,
0xf4,0x77,0x0c,0x0d,0x86,0x0d,0x83,0xc7,0x48,0x62,
0x28,0x19,0x6b,0x19,0x7b,0x19,0xa7,0x18,0xb7,0x19,
0x2f,0x99,0x4c,0xa6,0x05,0xd3,0x97,0x99,0xc8,0x54,
0x30,0xd7,0x32,0x1b,0x99,0x67,0x98,0x0f,0x98,0x6f,
0x55,0x58,0x2a,0xf6,0x2a,0x7c,0x15,0x91,0xca,0x12,
0x95,0x3a,0x95,0x56,0x95,0x7e,0x95,0xe7,0xaa,0x54,
0x55,0x73,0x55,0x3f,0xd5,0x79,0xaa,0x0b,0x54,0xab,
0x55,0x0f,0xab,0x5e,0x56,0x7d,0xa6,0x46,0x55,0xb3,
0x50,0xe3,0xa9,0x09,0xd4,0x16,0xab,0xd5,0xa9,0x1d,
0x55,0xbb,0xa9,0x36,0xae,0xce,0x52,0x77,0x52,0x8f,
0x50,0xcf,0x51,0x5f,0xa3,0xbe,0x5f,0xfd,0x82,0xfa,
0x63,0x0d,0xb2,0x86,0x85,0x46,0xa0,0x86,0x48,0xa3,
0x54,0x63,0xb7,0xc6,0x19,0x8d,0x21,0x16,0xc6,0x32,
0x65,0xf1,0x58,0x42,0xd6,0x72,0x56,0x03,0xeb,0x2c,
0x6b,0x98,0x4d,0x62,0x5b,0xb2,0xf9,0xec,0x4c,0x76,
0x05,0xfb,0x1b,0x76,0x2f,0x7b,0x4c,0x53,0x43,0x73,
0xaa,0x66,0xac,0x66,0x91,0x66,0x9d,0xe6,0x71,0xcd,
0x01,0x0e,0xc6,0xb1,0xe0,0xf0,0x39,0xd9,0x9c,0x4a,
0xce,0x21,0xce,0x0d,0xce,0x7b,0x2d,0x03,0x2d,0x3f,
0x2d,0xb1,0xd6,0x6a,0xad,0x66,0xad,0x7e,0xad,0x37,
0xda,0x7a,0xda,0xbe,0xda,0x62,0xed,0x72,0xed,0x16,
0xed,0xeb,0xda,0xef,0x75,0x70,0x9d,0x40,0x9d,0x2c,
0x9d,0xf5,0x3a,0x6d,0x3a,0xf7,0x75,0x09,0xba,0x36,
0xba,0x51,0xba,0x85,0xba,0xdb,0x75,0xcf,0xea,0x3e,
0xd3,0x63,0xeb,0x79,0xe9,0x09,0xf5,0xca,0xf5,0x0e,
0xe9,0xdd,0xd1,0x47,0xf5,0x6d,0xf4,0xa3,0xf5,0x17,
0xea,0xef,0xd6,0xef,0xd1,0x1f,0x37,0x30,0x34,0x08,
0x36,0x90,0x19,0x6c,0x31,0x38,0x63,0xf0,0xcc,0x90,
0x63,0xe8,0x6b,0x98,0x69,0xb8,0xd1,0xf0,0x84,0xe1,
0xa8,0x11,0xcb,0x68,0xba,0x91,0xc4,0x68,0xa3,0xd1,
0x49,0xa3,0x27,0xb8,0x26,0xee,0x87,0x67,0xe3,0x35,
0x78,0x17,0x3e,0x66,0xac,0x6f,0x1c,0x62,0xac,0x34,
0xde,0x65,0xdc,0x6b,0x3c,0x61,0x62,0x69,0x32,0xdb,
0xa4,0xc4,0xa4,0xc5,0xe4,0xbe,0x29,0xcd,0x94,0x6b,
0x9a,0x66,0xba,0xd1,0xb4,0xd3,0x74,0xcc,0xcc,0xc8,
0x2c,0xdc,0xac,0xd8,0xac,0xc9,0xec,0x8e,0x39,0xd5,
0x9c,0x6b,0x9e,0x61,0xbe,0xd9,0xbc,0xdb,0xfc,0x8d,
0x85,0xa5,0x45,0x9c,0xc5,0x4a,0x8b,0x36,0x8b,0xc7,
0x96,0xda,0x96,0x7c,0xcb,0x05,0x96,0x4d,0x96,0xf7,
0xac,0x98,0x56,0x3e,0x56,0x79,0x56,0xf5,0x56,0xd7,
0xac,0x49,0xd6,0x5c,0xeb,0x2c,0xeb,0x6d,0xd6,0x57,
0x6c,0x50,0x1b,0x57,0x9b,0x0c,0x9b,0x3a,0x9b,0xcb,
0xb6,0xa8,0xad,0x9b,0xad,0xc4,0x76,0x9b,0x6d,0xdf,
0x14,0xe2,0x14,0x8f,0x29,0xd2,0x29,0xf5,0x53,0x6e,
0xda,0x31,0xec,0xfc,0xec,0x0a,0xec,0x9a,0xec,0x06,
0xed,0x39,0xf6,0x61,0xf6,0x25,0xf6,0x6d,0xf6,0xcf,
0x1d,0xcc,0x1c,0x12,0x1d,0xd6,0x3b,0x74,0x3b,0x7c,
0x72,0x74,0x75,0xcc,0x76,0x6c,0x70,0xbc,0xeb,0xa4,
0xe1,0x34,0xc3,0xa9,0xc4,0xa9,0xc3,0xe9,0x57,0x67,
0x1b,0x67,0xa1,0x73,0x9d,0xf3,0x35,0x17,0xa6,0x4b,
0x90,0xcb,0x12,0x97,0x76,0x97,0x17,0x53,0x6d,0xa7,
0x8a,0xa7,0x6e,0x9f,0x7a,0xcb,0x95,0xe5,0x1a,0xee,
0xba,0xd2,0xb5,0xd3,0xf5,0xa3,0x9b,0xbb,0x9b,0xdc,
0xad,0xd9,0x6d,0xd4,0xdd,0xcc,0x3d,0xc5,0x7d,0xab,
0xfb,0x4d,0x2e,0x9b,0x1b,0xc9,0x5d,0xc3,0x3d,0xef,
0x41,0xf4,0xf0,0xf7,0x58,0xe2,0x71,0xcc,0xe3,0x9d,
0xa7,0x9b,0xa7,0xc2,0xf3,0x90,0xe7,0x2f,0x5e,0x76,
0x5e,0x59,0x5e,0xfb,0xbd,0x1e,0x4f,0xb3,0x9c,0x26,
0x9e,0xd6,0x30,0x6d,0xc8,0xdb,0xc4,0x5b,0xe0,0xbd,
0xcb,0x7b,0x60,0x3a,0x3e,0x3d,0x65,0xfa,0xce,0xe9,
0x03,0x3e,0xc6,0x3e,0x02,0x9f,0x7a,0x9f,0x87,0xbe,
0xa6,0xbe,0x22,0xdf,0x3d,0xbe,0x23,0x7e,0xd6,0x7e,
0x99,0x7e,0x07,0xfc,0x9e,0xfb,0x3b,0xfa,0xcb,0xfd,
0x8f,0xf8,0xbf,0xe1,0x79,0xf2,0x16,0xf1,0x4e,0x05,
0x60,0x01,0xc1,0x01,0xe5,0x01,0xbd,0x81,0x1a,0x81,
0xb3,0x03,0x6b,0x03,0x1f,0x04,0x99,0x04,0xa5,0x07,
0x35,0x05,0x8d,0x05,0xbb,0x06,0x2f,0x0c,0x3e,0x15,
0x42,0x0c,0x09,0x0d,0x59,0x1f,0x72,0x93,0x6f,0xc0,
0x17,0xf2,0x1b,0xf9,0x63,0x33,0xdc,0x67,0x2c,0x9a,
0xd1,0x15,0xca,0x08,0x9d,0x15,0x5a,0x1b,0xfa,0x30,
0xcc,0x26,0x4c,0x1e,0xd6,0x11,0x8e,0x86,0xcf,0x08,
0xdf,0x10,0x7e,0x6f,0xa6,0xf9,0x4c,0xe9,0xcc,0xb6,
0x08,0x88,0xe0,0x47,0x6c,0x88,0xb8,0x1f,0x69,0x19,
0x99,0x17,0xf9,0x7d,0x14,0x29,0x2a,0x32,0xaa,0x2e,
0xea,0x51,0xb4,0x53,0x74,0x71,0x74,0xf7,0x2c,0xd6,
0xac,0xe4,0x59,0xfb,0x67,0xbd,0x8e,0xf1,0x8f,0xa9,
0x8c,0xb9,0x3b,0xdb,0x6a,0xb6,0x72,0x76,0x67,0xac,
0x6a,0x6c,0x52,0x6c,0x63,0xec,0x9b,0xb8,0x80,0xb8,
0xaa,0xb8,0x81,0x78,0x87,0xf8,0x45,0xf1,0x97,0x12,
0x74,0x13,0x24,0x09,0xed,0x89,0xe4,0xc4,0xd8,0xc4,
0x3d,0x89,0xe3,0x73,0x02,0xe7,0x6c,0x9a,0x33,0x9c,
0xe4,0x9a,0x54,0x96,0x74,0x63,0xae,0xe5,0xdc,0xa2,
0xb9,0x17,0xe6,0xe9,0xce,0xcb,0x9e,0x77,0x3c,0x59,
0x35,0x59,0x90,0x7c,0x38,0x85,0x98,0x12,0x97,0xb2,
0x3f,0xe5,0x83,0x20,0x42,0x50,0x2f,0x18,0x4f,0xe5,
0xa7,0x6e,0x4d,0x1d,0x13,0xf2,0x84,0x9b,0x85,0x4f,
0x45,0xbe,0xa2,0x8d,0xa2,0x51,0xb1,0xb7,0xb8,0x4a,
0x3c,0x92,0xe6,0x9d,0x56,0x95,0xf6,0x38,0xdd,0x3b,
0x7d,0x43,0xfa,0x68,0x86,0x4f,0x46,0x75,0xc6,0x33,
0x09,0x4f,0x52,0x2b,0x79,0x91,0x19,0x92,0xb9,0x23,
0xf3,0x4d,0x56,0x44,0xd6,0xde,0xac,0xcf,0xd9,0x71,
0xd9,0x2d,0x39,0x94,0x9c,0x94,0x9c,0xa3,0x52,0x0d,
0x69,0x96,0xb4,0x2b,0xd7,0x30,0xb7,0x28,0xb7,0x4f,
0x66,0x2b,0x2b,0x93,0x0d,0xe4,0x79,0xe6,0x6d,0xca,
0x1b,0x93,0x87,0xca,0xf7,0xe4,0x23,0xf9,0x73,0xf3,
0xdb,0x15,0x6c,0x85,0x4c,0xd1,0xa3,0xb4,0x52,0xae,
0x50,0x0e,0x16,0x4c,0x2f,0xa8,0x2b,0x78,0x5b,0x18,
0x5b,0x78,0xb8,0x48,0xbd,0x48,0x5a,0xd4,0x33,0xdf,
0x66,0xfe,0xea,0xf9,0x23,0x0b,0x82,0x16,0x7c,0xbd,
0x90,0xb0,0x50,0xb8,0xb0,0xb3,0xd8,0xb8,0x78,0x59,
0xf1,0xe0,0x22,0xbf,0x45,0xbb,0x16,0x23,0x8b,0x53,
0x17,0x77,0x2e,0x31,0x5d,0x52,0xba,0x64,0x78,0x69,
0xf0,0xd2,0x7d,0xcb,0x68,0xcb,0xb2,0x96,0xfd,0x50,
0xe2,0x58,0x52,0x55,0xf2,0x6a,0x79,0xdc,0xf2,0x8e,
0x52,0x83,0xd2,0xa5,0xa5,0x43,0x2b,0x82,0x57,0x34,
0x95,0xa9,0x94,0xc9,0xcb,0x6e,0xae,0xf4,0x5a,0xb9,
0x63,0x15,0x61,0x95,0x64,0x55,0xef,0x6a,0x97,0xd5,
0x5b,0x56,0x7f,0x2a,0x17,0x95,0x5f,0xac,0x70,0xac,
0xa8,0xae,0xf8,0xb0,0x46,0xb8,0xe6,0xe2,0x57,0x4e,
0x5f,0xd5,0x7c,0xf5,0x79,0x6d,0xda,0xda,0xde,0x4a,
0xb7,0xca,0xed,0xeb,0x48,0xeb,0xa4,0xeb,0x6e,0xac,
0xf7,0x59,0xbf,0xaf,0x4a,0xbd,0x6a,0x41,0xd5,0xd0,
0x86,0xf0,0x0d,0xad,0x1b,0xf1,0x8d,0xe5,0x1b,0x5f,
0x6d,0x4a,0xde,0x74,0xa1,0x7a,0x6a,0xf5,0x8e,0xcd,
0xb4,0xcd,0xca,0xcd,0x03,0x35,0x61,0x35,0xed,0x5b,
0xcc,0xb6,0xac,0xdb,0xf2,0xa1,0x36,0xa3,0xf6,0x7a,
0x9d,0x7f,0x5d,0xcb,0x56,0xfd,0xad,0xab,0xb7,0xbe,
0xd9,0x26,0xda,0xd6,0xbf,0xdd,0x77,0x7b,0xf3,0x0e,
0x83,0x1d,0x15,0x3b,0xde,0xef,0x94,0xec,0xbc,0xb5,
0x2b,0x78,0x57,0x6b,0xbd,0x45,0x7d,0xf5,0x6e,0xd2,
0xee,0x82,0xdd,0x8f,0x1a,0x62,0x1b,0xba,0xbf,0xe6,
0x7e,0xdd,0xb8,0x47,0x77,0x4f,0xc5,0x9e,0x8f,0x7b,
0xa5,0x7b,0x07,0xf6,0x45,0xef,0xeb,0x6a,0x74,0x6f,
0x6c,0xdc,0xaf,0xbf,0xbf,0xb2,0x09,0x6d,0x52,0x36,
0x8d,0x1e,0x48,0x3a,0x70,0xe5,0x9b,0x80,0x6f,0xda,
0x9b,0xed,0x9a,0x77,0xb5,0x70,0x5a,0x2a,0x0e,0xc2,
0x41,0xe5,0xc1,0x27,0xdf,0xa6,0x7c,0x7b,0xe3,0x50,
0xe8,0xa1,0xce,0xc3,0xdc,0xc3,0xcd,0xdf,0x99,0x7f,
0xb7,0xf5,0x08,0xeb,0x48,0x79,0x2b,0xd2,0x3a,0xbf,
0x75,0xac,0x2d,0xa3,0x6d,0xa0,0x3d,0xa1,0xbd,0xef,
0xe8,0x8c,0xa3,0x9d,0x1d,0x5e,0x1d,0x47,0xbe,0xb7,
0xff,0x7e,0xef,0x31,0xe3,0x63,0x75,0xc7,0x35,0x8f,
0x57,0x9e,0xa0,0x9d,0x28,0x3d,0xf1,0xf9,0xe4,0x82,
0x93,0xe3,0xa7,0x64,0xa7,0x9e,0x9d,0x4e,0x3f,0x3d,
0xd4,0x99,0xdc,0x79,0xf7,0x4c,0xfc,0x99,0x6b,0x5d,
0x51,0x5d,0xbd,0x67,0x43,0xcf,0x9e,0x3f,0x17,0x74,
0xee,0x4c,0xb7,0x5f,0xf7,0xc9,0xf3,0xde,0xe7,0x8f,
0x5d,0xf0,0xbc,0x70,0xf4,0x22,0xf7,0x62,0xdb,0x25,
0xb7,0x4b,0xad,0x3d,0xae,0x3d,0x47,0x7e,0x70,0xfd,
0xe1,0x48,0xaf,0x5b,0x6f,0xeb,0x65,0xf7,0xcb,0xed,
0x57,0x3c,0xae,0x74,0xf4,0x4d,0xeb,0x3b,0xd1,0xef,
0xd3,0x7f,0xfa,0x6a,0xc0,0xd5,0x73,0xd7,0xf8,0xd7,
0x2e,0x5d,0x9f,0x79,0xbd,0xef,0xc6,0xec,0x1b,0xb7,
0x6e,0x26,0xdd,0x1c,0xb8,0x25,0xba,0xf5,0xf8,0x76,
0xf6,0xed,0x17,0x77,0x0a,0xee,0x4c,0xdc,0x5d,0x7a,
0x8f,0x78,0xaf,0xfc,0xbe,0xda,0xfd,0xea,0x07,0xfa,
0x0f,0xea,0x7f,0xb4,0xfe,0xb1,0x65,0xc0,0x6d,0xe0,
0xf8,0x60,0xc0,0x60,0xcf,0xc3,0x59,0x0f,0xef,0x0e,
0x09,0x87,0x9e,0xfe,0x94,0xff,0xd3,0x87,0xe1,0xd2,
0x47,0xcc,0x47,0xd5,0x23,0x46,0x23,0x8d,0x8f,0x9d,
0x1f,0x1f,0x1b,0x0d,0x1a,0xbd,0xf2,0x64,0xce,0x93,
0xe1,0xa7,0xb2,0xa7,0x13,0xcf,0xca,0x7e,0x56,0xff,
0x79,0xeb,0x73,0xab,0xe7,0xdf,0xfd,0xe2,0xfb,0x4b,
0xcf,0x58,0xfc,0xd8,0xf0,0x0b,0xf9,0x8b,0xcf,0xbf,
0xae,0x79,0xa9,0xf3,0x72,0xef,0xab,0xa9,0xaf,0x3a,
0xc7,0x23,0xc7,0x1f,0xbc,0xce,0x79,0x3d,0xf1,0xa6,
0xfc,0xad,0xce,0xdb,0x7d,0xef,0xb8,0xef,0xba,0xdf,
0xc7,0xbd,0x1f,0x99,0x28,0xfc,0x40,0xfe,0x50,0xf3,
0xd1,0xfa,0x63,0xc7,0xa7,0xd0,0x4f,0xf7,0x3e,0xe7,
0x7c,0xfe,0xfc,0x2f,0xf7,0x84,0xf3,0xfb,0x25,0xd2,
0x9f,0x33,0x00,0x00,0x00,0x20,0x63,0x48,0x52,0x4d,
0x00,0x00,0x7a,0x25,0x00,0x00,0x80,0x83,0x00,0x00,
0xf9,0xff,0x00,0x00,0x80,0xe9,0x00,0x00,0x75,0x30,
0x00,0x00,0xea,0x60,0x00,0x00,0x3a,0x98,0x00,0x00,
0x17,0x6f,0x92,0x5f,0xc5,0x46,0x00,0x00,0x00,0xd8,
0x49,0x44,0x41,0x54,0x78,0xda,0x8c,0xd1,0xbd,0x4a,
0xc4,0x60,0x10,0x85,0xe1,0x27,0x59,0x1b,0x51,0xb4,
0x12,0x94,0x05,0xc1,0x72,0x83,0x16,0x09,0x9a,0xb4,
0x6a,0x65,0x25,0x6c,0x25,0x78,0x0d,0x56,0xbb,0x95,
0xa5,0x9d,0x95,0x8d,0x20,0x78,0x03,0x62,0xab,0x78,
0x07,0x56,0x69,0xd2,0x2c,0x04,0xaf,0x62,0x5b,0xcb,
0xcf,0x26,0x81,0xcf,0x1f,0x88,0x03,0x53,0x9c,0xe1,
0x9d,0x19,0xe6,0x4c,0x12,0x42,0x30,0x14,0x59,0x51,
0x9d,0xe2,0x0d,0xaf,0xe9,0x3f,0xe0,0xb2,0x83,0x57,
0xb1,0x4c,0x07,0xe0,0x4d,0x3c,0x77,0x30,0x6c,0x0f,
0x6d,0x78,0xc4,0x5e,0xa4,0xc7,0x69,0x34,0x6d,0x3d,
0x2b,0xaa,0x83,0x48,0x5f,0xe2,0x22,0x82,0x6f,0x71,
0x9c,0x84,0x10,0x64,0x45,0x75,0x8e,0x07,0x2c,0x91,
0x63,0x84,0x8f,0x68,0xfa,0xbc,0x6d,0xea,0x3b,0x58,
0xc9,0x8a,0xea,0x1e,0x57,0xfd,0x4a,0x4c,0xb1,0x1b,
0xc1,0xd7,0x3d,0x0c,0xa3,0xad,0x9d,0xf1,0x3b,0xd6,
0x70,0x84,0x14,0xfb,0x38,0xc1,0x06,0x9e,0xda,0xa6,
0x9e,0xc5,0x47,0x25,0xfd,0x1f,0x22,0xaf,0x7b,0x47,
0x16,0xa8,0xda,0xa6,0xfe,0xfc,0xb3,0xa1,0x6b,0x3a,
0xc3,0x4b,0x27,0x0f,0xdb,0xa6,0x5e,0xfc,0xf2,0x2d,
0x84,0xf0,0x2d,0x27,0x79,0x39,0x9d,0xe4,0xe5,0xcd,
0xcf,0x7a,0x9f,0x5f,0x03,0x00,0xb7,0x35,0x53,0x35,
0x8f,0xfe,0x68,0x97,0x00,0x00,0x00,0x00,0x49,0x45,
0x4e,0x44,0xae,0x42,0x60,0x82
};
__fastcall TCKBox::TCKBox( TComponent* Owner )
:TPanel(Owner)
{
Width = 80;
Height = 18;
FAutoBox = true;
// FBoxEnabled = true;
FEnabled = true;
bMouse = false;
ParentColor = true;
Ctl3D = false;
ParentCtl3D = false;
DoubleBuffered = true;
m_pImgCheck = new Vcl::Imaging::Pngimage::TPngImage(); //we create our png
TMemoryStream *pngStream = new TMemoryStream();
pngStream->Position = 0;
pngStream->WriteBuffer(pngImageCheck, 2988);
pngStream->Position = 0;
m_pImgCheck->LoadFromStream(pngStream);
delete pngStream;
/* m_pCaption = new TLabel(this);
m_pCaption->Parent = this;
// m_pCaption->AutoSize = true;
m_pCaption->OnClick = Clicklb;
m_pCaption->Left = Height + 2;
m_pCaption->Top = ( Height - m_pCaption->Height ) / 2;
*/
}
//---------------------------------------------------------------------------
__fastcall TCKBox::~TCKBox()
{
if( m_pImgCheck ){
delete m_pImgCheck;
m_pImgCheck = NULL;
}
/* if( m_pCaption ){
delete m_pCaption;
m_pCaption = NULL;
}
*/
}
//---------------------------------------------------------------------------
namespace Ckbox
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TCKBox)};
RegisterComponents(L"Samples", classes, 0);
}
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::Paint(void)
{
TRect Rect;
int hText = Canvas->TextHeight( m_strText );// m_pCaption->Height;
if( FAutoBox && hText>0 ){
Rect.init( RET_LEFT, (Height-hText)/2, RET_LEFT+hText, (Height+hText)/2+1 );
}
else{
Rect.init( RET_LEFT, 0, RET_LEFT + Height, Height );
}
if( FEnabled ){
Canvas->Brush->Color = BoxColor;
Canvas->FrameRect( Rect );
TRect rct1,rct2;
if( Rect.Height()<= 9 ){
rct1.init( Rect.Left+1,Rect.Top+1,Rect.Right-1,Rect.Bottom-1 ); //内1
}
else{
rct1.init( Rect.Left+1,Rect.Top+1,Rect.Right-1,Rect.Bottom-1 ); //内1
}
rct2.init( Rect.Left+1+1,Rect.Top+1+1,Rect.Right-1-1,Rect.Bottom-1-1 );
if( bMouse && !FChecked ){
if( Rect.Height()<=9 ){
Canvas->Brush->Color = CLR_RECT_1_1; //内条
Canvas->FillRect(rct1);
}
else{
Canvas->Brush->Color = CLR_RECT_1_1; //内条
Canvas->FillRect(rct1);
}
}
else if( bMouse && FChecked ){
if( Rect.Height()<=9 ){
Canvas->Brush->Color = CLR_RECT_1_1; //内条
Canvas->FrameRect(rct1);
Canvas->StretchDraw(rct2, m_pImgCheck); //黑块
}else{
Canvas->Brush->Color = CLR_RECT_1_1; //内条
Canvas->FillRect(rct1);
Canvas->StretchDraw(rct2, m_pImgCheck); //黑块
}
}
else if( !bMouse && FChecked ){
if( Rect.Height()<=9 ){
Canvas->Brush->Color = CLR_RECT_1_2; //内条
Canvas->FrameRect(rct1);
Canvas->StretchDraw(rct2, m_pImgCheck); //黑块
}
else{
Canvas->Brush->Color = CLR_RECT_1_2; //内条
Canvas->FillRect(rct1);
Canvas->StretchDraw(rct2, m_pImgCheck); //黑块
}
}
else if( !bMouse && !FChecked ){
if( Rect.Height()<=9 ){
Canvas->Brush->Color = CLR_RECT_1_2; //内条
Canvas->FillRect(rct1);
}
else{
Canvas->Brush->Color = CLR_RECT_1_2; //内条
Canvas->FillRect(rct1);//FrameRect(rct1);
}
}
}
else{
Canvas->Brush->Color = CLR_ENABLED;
Canvas->FrameRect( Rect );
TRect temp(Rect.Left+1,Rect.Top+1,Rect.Right-1,Rect.Bottom-1);
Canvas->Brush->Color = CLR_ENABLED_1;
Canvas->FillRect( temp );
}
if( !m_strText.IsEmpty() ){
int x = RET_LEFT + Height + 2, y = (Height-hText)/2;
Canvas->Brush->Style = bsClear;
Canvas->TextOut( x, y, m_strText );
if( !FEnabled ){
// }
// else{
//Canvas->Font->Color = RGB(255,255,255);
Canvas->TextOut( x, y, m_strText );
TColor clUse = Canvas->Font->Color;
Canvas->Font->Color = RGB(128,128,128);
Canvas->TextOut( x-1, y-1, m_strText );
Canvas->Font->Color = clUse;
}
Canvas->Brush->Style = bsSolid;
}
}
//---------------------------------------------------------------------------
/*
TColor __fastcall TCKBox::ColorSub(TColor cColor,int index)
{
int R = GetRValue(cColor);//; cColor&0x000000FF;//
int G = GetGValue(cColor);//cColor&0x0000FF00;//
int B = GetBValue(cColor);//cColor&0x0000FF00;//
// int A = cColor&0xFF000000;
int tr= (R*(100-index)+255*index)/100,
tg = (G*(100-index)+255*index)/100,
tb = (B*(100-index)+255*index)/100;
return RGB(tr,tg,tb);
}
//---------------------------------------------------------------------------
*/
void __fastcall TCKBox::SetChecked(bool bCheck)
{
if( FChecked!=bCheck ){
FChecked = bCheck;
if(FOnChange)
FOnChange(this);
if( Visible && Handle ){
RECT rect;
SetRect( &rect, 0, 0, Height, Height );
InvalidateRect( Handle, &rect, false );
}
}
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::SetEnabled(bool bEnabled)
{
if( FEnabled!=bEnabled ){
FEnabled = bEnabled;
// Paint();
Invalidate();
}
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::SetBoxColor(TColor cColor)
{
if( FBoxColor!=cColor ){
FBoxColor = cColor;
//Paint();
if( Visible && Handle ){
RECT rect;
SetRect( &rect, 0, 0, Height, Height );
InvalidateRect( Handle, &rect, false );
}
}
}
//---------------------------------------------------------------------------
TFont* __fastcall TCKBox::GetTextFont()
{
return Canvas->Font;
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::SetTextFont(TFont* Value)
{
/* if( m_pCaption ){
m_pCaption->Font = Value;
m_pCaption->Invalidate();
}
*/
Canvas->Font = Value;
if( Visible && Handle ){
RECT rect;
SetRect( &rect, Height, 0, Width, Height );
InvalidateRect( Handle, &rect, false );
}
//Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::Click(void)
{
if( FEnabled ){
FChecked = !Checked;
if(FOnChange)
FOnChange(this);
TPanel::Click();
// Paint();
Invalidate();
}
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::CMMouseLeave(TWMMouse &Message)
{
if(bMouse){
bMouse = false;
RECT rect;
SetRect( &rect, 0, 0, Height, Height );
InvalidateRect( Handle, &rect, false );
}
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::CMMouseEnter(TWMMouse &Message)
{
if(!bMouse){
bMouse = true;
RECT rect;
SetRect( &rect, 0, 0, Height, Height );
InvalidateRect( Handle, &rect, false );
}
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::WMSize(Winapi::Messages::TWMSize &Message)
{
Height = Message.Height < MIN_H ? MIN_H : Message.Height;
Width = Message.Width< MIN_W ? MIN_W : Message.Width;
/* m_pCaption->Left = Height + 2;
m_pCaption->Top = ( Height - m_pCaption->Height ) / 2;
m_pCaption->Width = Width - Height - 2;
m_pCaption->Invalidate();
*/
Message.Result = true;
return;
}
//---------------------------------------------------------------------------
String __fastcall TCKBox::GetCaption()
{
// if( m_pCaption )
// return m_pCaption->Caption;
return m_strText;
}
//---------------------------------------------------------------------------
void __fastcall TCKBox::SetCaption( String Value )
{
m_strText = Value;
if( Visible && Handle ){
RECT rect;
SetRect( &rect, Height, 0, Width, Height );
InvalidateRect( Handle, &rect, false );
}
/*
if( m_pCaption ){
m_pCaption->Caption = Value;
m_pCaption->Invalidate();
}
*/
}
//---------------------------------------------------------------------------
+74
View File
@@ -0,0 +1,74 @@
//---------------------------------------------------------------------------
#ifndef CKBoxH
#define CKBoxH
#include <vcl.h>
#include <Vcl.Imaging.pngimage.hpp>
//---------------------------------------------------------------------------
class PACKAGE TCKBox : public TPanel
{
private:
bool FChecked;
bool FEnabled;
bool bMouse;
bool FAutoBox;
TNotifyEvent FOnChange;
TColor FBoxColor;
String m_strText;
// TLabel *m_pCaption;
Vcl::Imaging::Pngimage::TPngImage *m_pImgCheck;
private:
void __fastcall SetBoxEnabled(bool bEnabled);
void __fastcall SetEnabled(bool bEnabled);
void __fastcall SetChecked(bool bCheck);
void __fastcall SetBoxColor(TColor cColor);
TFont* __fastcall GetTextFont();
void __fastcall SetTextFont( TFont* Value );
// void __fastcall Clicklb(TObject *Sender);
// TColor __fastcall ColorSub(TColor cColor,int index);
String __fastcall GetCaption();
void __fastcall SetCaption( String Value );
protected:
virtual void __fastcall Paint(void);
MESSAGE void __fastcall CMMouseLeave(TWMMouse &Message);
MESSAGE void __fastcall CMMouseEnter(TWMMouse &Message);
MESSAGE void __fastcall WMSize(Winapi::Messages::TWMSize &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TWMMouse, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TWMMouse, CMMouseLeave)
MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
END_MESSAGE_MAP(TPanel)
public:
DYNAMIC void __fastcall Click(void);
__fastcall TCKBox( TComponent* Owner );
__fastcall ~TCKBox();
__published:
__property bool Checked = { read = FChecked, write = SetChecked, default = 0 };
__property bool Enabled = { read = FEnabled, write = SetEnabled, default = 1 };
__property bool AutoBox = { read = FAutoBox,write = FAutoBox,default = 1};
__property TColor BoxColor = { read = FBoxColor,write = SetBoxColor };
__property Font = { read = GetTextFont, write = SetTextFont };
__property TNotifyEvent OnChange = {read = FOnChange, write = FOnChange ,default = NULL};
__property String Caption = {read = GetCaption, write = SetCaption };
};
#endif
/*
使用说明
1、OnChange 为当 Checked 发生改变时触发 为外部接口 也可以使用父类 TPanel 的 onClick
2、FontSize 为 字体大小
3、AutoBox 为 True 时:
Box 的大小随字体高度变化
为false 时:
Box 的大小 随控件的 Height 变化
4、BoxEnabled 能否使用 ,不与 TPanel 的 Enabled 冲突
附注:
控件 最小 Height 为 6 ;最小 Width 为 11
*/
+17
View File
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,241 @@
//---------------------------------------------------------------------------
#pragma hdrstop
#include "ComboBoxComponent.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#include "DropListScrollBar.cpp"
#include "DropListView.cpp"
#include "CapButton.cpp"
static inline void ValidCtrCheck(TComboBoxComponent *)
{
new TComboBoxComponent(NULL);
}
namespace Comboboxcomponent
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TComboBoxComponent)};
RegisterComponents(L"Samples", classes, 0);
}
}
#define MIN(x, y) ((x)<(y)?(x):(y))
__fastcall TComboBoxComponent::TComboBoxComponent(TComponent *Owner)
: CBCapButton(Owner)
{
m_ClickStat = 0;
m_IsMouseOver = false;
ItemHeight = 20;
ShowItemCount = 5;
FShowMode = TComboBoxMode(cbShowDown);
// 初始化下拉列表框
m_DropListView = new TDropListView(this);
m_DropListView->Parent = (TWinControl *)Owner;
m_DropListView->SetDesignVisible(false);
m_DropListView->Visible = false;
m_DropListView->OnHide = DoDropListHide;
m_DropListView->OnShow = DoDropListShow;
OnMouseEnter = DoMouseEnter;
OnMouseLeave = DoMouseLeave;
}
__fastcall TComboBoxComponent::~TComboBoxComponent()
{
}
void __fastcall TComboBoxComponent::SetParent(TWinControl* AParent)
{
m_DropListView->Parent = AParent;
CBCapButton::Parent = AParent;
}
void __fastcall TComboBoxComponent::SetFontSize( int value )
{
m_DropListView->SetFontSize(value);
CBCapButton::SetFontSize(value);
}
void __fastcall TComboBoxComponent::SetFont( String name, int size )
{
CBCapButton::SetFont(name, size);
m_DropListView->SetFont(name, size);
}
TComboBoxItem * __fastcall TComboBoxComponent::AddItem(String Caption)
{
TComboBoxItem * pNewItem = new TComboBoxItem(Caption, DoItemClick);
m_DropListView->AddItem(pNewItem);
return pNewItem;
}
TComboBoxItem * __fastcall TComboBoxComponent::GetItem(int Index)
{
return m_DropListView->GetItem( Index );
}
void __fastcall TComboBoxComponent::Clear()
{
if(m_DropListView->ItemsCount != 0)
{
m_DropListView->Clear();
}
}
void __fastcall TComboBoxComponent::DoDropListShow(TObject *Sender)
{
Down = true;
m_ClickStat = 1;
}
void __fastcall TComboBoxComponent::DoDropListHide(TObject *Sender)
{
Down = false;
if(!m_IsMouseOver)
{
m_ClickStat = 2;
}
else
{
m_ClickStat = 3;
}
}
void __fastcall TComboBoxComponent::DoItemClick(TComboBoxItem* Sender, int Index)
{
Caption = Sender->Caption;
if(FOnChange) FOnChange(Sender, Index);
}
void __fastcall TComboBoxComponent::DoMouseEnter(TObject *Sender)
{
m_IsMouseOver = true;
}
void __fastcall TComboBoxComponent::DoMouseLeave(TObject *Sender)
{
m_IsMouseOver = false;
}
/*
void __fastcall TComboBoxComponent::CMMouseEnter(TMessage &Message)
{
m_IsMouseOver = true;
//TGraphicControl::Dispatch(&Message);
CBCapButton::DefaultHandler(&Message);
}
void __fastcall TComboBoxComponent::CMMouseLeave(TMessage &Message)
{
m_IsMouseOver = false;
//TGraphicControl::Dispatch(&Message);
}
*/
void __fastcall TComboBoxComponent::MouseDown(TMouseButton Button, TShiftState Shift, int X, int Y)
{
TGraphicControl::MouseDown(Button, Shift, X, Y);
if(Button != 0) return;
if(m_ClickStat == 3) return;
m_DropListView->ItemHeight = FItemHeight;
m_DropListView->Width = Width;
TPoint var_Client(0, Height);
TPoint var_Screen = ClientToScreen(var_Client);
m_DropListView->Left = var_Screen.X;
m_DropListView->ShowItemsCount = FShowItemCount;
if(ShowMode == TComboBoxMode(cbShowUp))
{
// 上方显示
m_DropListView->Top = var_Screen.Y - Height - m_DropListView->ListHeight;
}
else
{
// 下方显示
m_DropListView->Top = var_Screen.Y;
}
m_DropListView->Show();
}
void __fastcall TComboBoxComponent::MouseUp(TMouseButton Button, TShiftState Shift, int X, int Y)
{
TGraphicControl::MouseUp(Button, Shift, X, Y);
if(Button != 0) return;
if(m_ClickStat == 3) m_ClickStat = 0;
}
int __fastcall TComboBoxComponent::GetDefaultItem()
{
return m_DropListView->DefItemIndex;
}
int __fastcall TComboBoxComponent::GetItemsCount()
{
return m_DropListView->ItemsCount;
}
void __fastcall TComboBoxComponent::RemoveItem(int Index)
{
int var_Count = m_DropListView->ItemsCount;
if(Index < var_Count && Index >= 0)
{
m_DropListView->RemoveItem(Index);
}
}
void __fastcall TComboBoxComponent::SetDefaultItem(int Value)
{
int var_Count = m_DropListView->ItemsCount;
if(Value >= var_Count || Value < 0)
{
Value = -1;
Caption = "";
}
else if(var_Count > 0)
{
TComboBoxItem *var_Item = m_DropListView->GetItem(Value);
if(var_Item != NULL)
{
Caption = var_Item->Caption;
}
}
m_DropListView->DefItemIndex = Value;
}
void __fastcall TComboBoxComponent::SetItemHeight(int Value)
{
FItemHeight = Value;
}
void __fastcall TComboBoxComponent::SetShowMode(TComboBoxMode Value)
{
FShowMode = Value;
}
void __fastcall TComboBoxComponent::SetShowItemCount(int Value)
{
FShowItemCount = Value;
}
@@ -0,0 +1,427 @@
//---------------------------------------------------------------------------
#ifndef ComboBoxComponentH
#define ComboBoxComponentH
#include <vcl.h>
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Imaging.pnglang.hpp>
#include <Vcl.Graphics.hpp>
//---------------------------------------------------------------------------
class TDropListScrollBar;
class TComboBoxItem;
class TDropListView;
class CBCapButton;
//---------------------------------------------------------------------------
/* 定义下拉列表项点击事件 */
typedef void __fastcall (__closure *TItemClickEvent)(TComboBoxItem* Sender, int Index);
/* 下拉列表框显示风格 */
enum DECLSPEC_DENUM TComboBoxMode : unsigned char {cbShowUp, cbShowDown};
//typedef System::Set<ComboBox_Mode, ComboBox_Mode::cbShowUp, ComboBox_Mode::cbShowDown> TComboBoxMode;
/* 定义下拉列表框变化事件 */
typedef void __fastcall (__closure *TComboBoxChangeEvent)(TComboBoxItem* Sender, int Index);
/**************************************************************************************************/
/**************************************************************************************************/
class TDropListScrollBar : public TScrollBar
{
private:
// int m_nTileHeight, //add by tj 2013/11/18
int m_nThumbHeight,
m_nThumbTop,
m_nPreThumbTop,
m_nDragPos,
m_nDragPoint,
m_iClicked,
m_iHitPrev,
m_nMax,
m_nMin,
m_nPos,
m_nPage,
m_nTrackPos;
bool m_bPause,
m_bNotify,
m_bDrag,
m_bTrace;
TBitmap *u_pPicLineUp,
*u_pPicLineDown;
TTimer *m_pTimer;
TCanvas *m_pCanvas;
int HitTest( int X, int Y );
void CalcThumbHeight();
void CalcThumbTop();
void DrawArrow( int iDirection, int iState );
void DrawThumb( int iState, bool bEraseBk, int iPageUD=-1 );
void __fastcall TimerProc(TObject* Sender);
MESSAGE void __fastcall WMPaint(Winapi::Messages::TWMPaint &Message);
MESSAGE void __fastcall WMLButtonDown(TWMMouse &Message);
MESSAGE void __fastcall WMLButtonUp(TWMMouse &Message);
MESSAGE void __fastcall WMLButtonDblClk(TWMMouse &Message);
MESSAGE void __fastcall WMRButtonDown(TWMMouse &Message); //add by tj 2013/11/18
MESSAGE void __fastcall WMRButtonUp(TWMMouse &Message); //add by tj 2013/11/18
MESSAGE void __fastcall WMMouseMove(TWMMouse &Message);
// MESSAGE void __fastcall CMMouseLeave(TMessage &Message); //add by tj 2013/11/25 12:35
MESSAGE void __fastcall SBMSetScrollInfo(TMessage &Message);
MESSAGE void __fastcall SBMGetScrollInfo(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_PAINT, TWMPaint, WMPaint)
MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLButtonDown)
MESSAGE_HANDLER(WM_LBUTTONUP, TWMLButtonUp, WMLButtonUp)
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, TWMLButtonDblClk, WMLButtonDblClk)
MESSAGE_HANDLER(WM_RBUTTONDOWN, TWMRButtonDown, WMRButtonDown)
MESSAGE_HANDLER(WM_RBUTTONUP, TWMRButtonUp, WMRButtonUp) //add by tj 2013/11/18
MESSAGE_HANDLER(WM_MOUSEMOVE, TWMMouseMove, WMMouseMove) //add by tj 2013/11/18
// MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave) //add by tj 2013/11/25 12:35
MESSAGE_HANDLER(SBM_SETSCROLLINFO, TMessage, SBMSetScrollInfo)
MESSAGE_HANDLER(SBM_GETSCROLLINFO, TMessage, SBMGetScrollInfo)
END_MESSAGE_MAP(TScrollBar)
protected:
virtual void __fastcall PaintWindow(HDC DC);
public:
TWinControl *m_pWndCtrl;
bool m_bAction;
__fastcall virtual TDropListScrollBar(System::Classes::TComponent* AOwner);
__fastcall ~TDropListScrollBar();
void __fastcall CMMouseLeave(TObject *Sender); //add by tj 2013/11/25 12:35
bool IsDraging(){ return m_bDrag; };
void __fastcall SetPosition(int Value, bool bRedraw=true);
void __fastcall SetPageSize(int Value, bool bRedraw=true);
void __fastcall SetRange(int AMin, int AMax, bool bRedraw=true);
void __fastcall GetScrollRange(int* nMin, int* nMax);
int __fastcall GetScrollPos();
int __fastcall GetPageSize();
};
/**************************************************************************************************/
/**************************************************************************************************/
class TComboBoxItem : public TObject
{
private:
int FTag;
String FCaption;
TItemClickEvent FOnItemClick;
void __fastcall SetCaption(String Caption);
public:
__fastcall TComboBoxItem(String Caption, TItemClickEvent OnItemClick);
void __fastcall DrawItem(TCanvas *Canvas, TRect Rect, bool Selected);
__published:
__property String Caption = {read = FCaption, write = FCaption};
__property int Tag = {read = FTag, write = FTag};
__property TItemClickEvent OnItemClicked = {read = FOnItemClick, write = FOnItemClick};
};
// ---------------------------------------------------------------------------
// TDropListView
// ---------------------------------------------------------------------------
class TDropListView : public TWinControl
{
private:
TNotifyEvent FOnHide, // 下拉列表隐藏事件
FOnShow; // 下拉列表显示事件
int FItemHeight,
FItemWidth,
FShowItemsCount,
FDefItemIndex;
TControlCanvas *m_Canvas;
TList *m_ItemRectList,
*m_ItemList;
TDropListScrollBar *m_ScrollBar;
HWND m_pActiveWnd;
int m_BeginIndex,
m_EndIndex,
m_CurrentItemIndex,
m_RealShowCount,
m_MouseX,
m_MouseY;
void __fastcall CreateScrollBar();
void __fastcall DoItemsCountChange();
void __fastcall DoItemClicked(int Index);
void __fastcall DoItemSelect(int Index);
void __fastcall DoKeyUpDown(int Index);
void __fastcall DoShowItemsChange();
int __fastcall CalcListHeight();
int __fastcall GetItemsCount();
TRect *__fastcall GetItemRect(int Index);
void __fastcall SetShowItemsCount(int Value);
MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message);
MESSAGE void __fastcall WMKeyDown(TWMKeyDown &Message);
MESSAGE void __fastcall WMKillFocus(TMessage &Message);
MESSAGE void __fastcall WMLButtonDown(TWMLButtonDown &Message);
MESSAGE void __fastcall WMMouseWheel(TWMMouseWheel &Message);
MESSAGE void __fastcall WMPaint(TWMPaint &Message);
MESSAGE void __fastcall WMSetFocus(TMessage &Message);
MESSAGE void __fastcall WMVScroll(TWMScroll &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
MESSAGE_HANDLER(CN_KEYDOWN, TWMKeyDown, WMKeyDown)
MESSAGE_HANDLER(WM_KILLFOCUS, TMessage, WMKillFocus)
MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLButtonDown)
MESSAGE_HANDLER(WM_MOUSEWHEEL, TWMMouseWheel, WMMouseWheel)
MESSAGE_HANDLER(WM_PAINT, TWMPaint, WMPaint)
MESSAGE_HANDLER(WM_SETFOCUS, TMessage, WMSetFocus)
MESSAGE_HANDLER(WM_VSCROLL, TWMScroll, WMVScroll)
END_MESSAGE_MAP(TWinControl)
protected:
virtual void __fastcall CreateParams(TCreateParams &Params);
virtual void __fastcall CreateWnd();
virtual void __fastcall PaintWindow(HDC DC);
DYNAMIC void __fastcall MouseDown(TMouseButton Button, TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseMove(TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(TMouseButton Button, TShiftState Shift, int X, int Y);
public:
__fastcall TDropListView(TComponent *Owner);
__fastcall ~TDropListView();
void __fastcall AddItem(TComboBoxItem* Item);
void __fastcall Clear();
TComboBoxItem *__fastcall GetItem(int Index);
void __fastcall Hide();
void __fastcall RemoveItem(int Index);
void __fastcall ScrollPos(int Pos);
void __fastcall Show();
void __fastcall SetFontSize(int sz);
void __fastcall SetFont(String name, int sz);
__published:
__property int ListHeight = {read = CalcListHeight};
__property int ItemHeight = {write = FItemHeight, read = FItemHeight, default = 16};
__property TNotifyEvent OnHide = {write = FOnHide, read = FOnHide};
__property TNotifyEvent OnShow = {write = FOnShow, read = FOnShow};
__property int ShowItemsCount = {write = SetShowItemsCount, read = FShowItemsCount};
__property int DefItemIndex = {read = FDefItemIndex, write = FDefItemIndex};
__property int ItemsCount = {read = GetItemsCount};
};
/**************************************************************************************************/
/**************************************************************************************************/
class CBCapButton : public TGraphicControl
{
public:
enum TModalResult{
mrNone = System::Int8(0x0),
mrOk = System::Int8(0x1),
mrCancel = System::Int8(0x2),
mrAbort = System::Int8(0x3),
mrRetry = System::Int8(0x4),
mrIgnore = System::Int8(0x5),
mrYes = System::Int8(0x6),
mrNo = System::Int8(0x7),
mrClose = System::Int8(0x8),
mrHelp = System::Int8(0x9),
mrTryAgain = System::Int8(0xa),
mrContinue = System::Int8(0xb),
mrAll = System::Int8(0xc),
mrNoToAll = System::Int8(0xd),
mrYesToAll = System::Int8(0xe)
};
private:
COLORREF
clrFrameExNormal,
clrFrameExEnter,
clrFrameExDisable,
clrFrameNormal,
clrLineNormal,
clrRectNormal,
clrRectDisable,
clrCapArrowOpenBound[10],
clrCapArrowOpenLine[4],
clrExFrameBound[4],
clrExFrameBoundDisable[4];
TColor FBorderColor;
TColor FInterFrameColor;
TColor FInterColor;
void __fastcall IniColor(int nstate);
COLORREF __fastcall TransformColor(COLORREF icolor, int nNum=0, bool bplus=true);
void __fastcall SetBorderColor(TColor iBorderColor);
void __fastcall SetInterFrameColor(TColor iInterFrameColor);
void __fastcall SetInterColor(TColor iInterColor);
TNotifyEvent FOnMouseEnter;//on mouse enter notify event
TNotifyEvent FOnMouseLeave;//on mouse leave notify event
String FCaption;
// System::Uitypes::TModalResult FModalResult;
TModalResult FModalResult;
void __fastcall SetCaption(String Value);
MESSAGE void __fastcall CMMouseEnter(Winapi::Messages::TMessage &Msg); // to know when mouse is entered
MESSAGE void __fastcall CMMouseLeave(Winapi::Messages::TMessage &Msg); // to know when mouse is leaved
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TGraphicControl)
protected:
bool FEnablePNG; //是否加载了png格式图片背景
bool FDown; // value to know if we painting mouse down
int EtatBtn; // 0=Normal 1=Mouse entered 2=Pressed 3=Disabled
int FStateCount;
Vcl::Imaging::Pngimage::TPngImage *FPngImg; //our 4 states image
DYNAMIC void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall SetEnabled(bool Value);
public:
__fastcall virtual CBCapButton(System::Classes::TComponent* AOwner);
__fastcall virtual ~CBCapButton(void);
void __fastcall SetStateCount( int count );
void __fastcall SetPngImg(Vcl::Imaging::Pngimage::TPngImage *value); // we set the png image
void __fastcall SetDown(bool value); // to know if mouse is down or not
void __fastcall SetEnablePNG(bool Value);// to know if customer set png img
virtual void __fastcall SetFontSize( int value );
virtual void __fastcall SetFont( String name, int sz );
virtual void __fastcall Paint(void); // override the painting of the component
DYNAMIC void __fastcall Click(void);
__published:
__property Action;
__property Anchors = {default=3};
__property bool Down = {read=FDown, write=SetDown, default=False};
__property Enabled = {default=1};
__property int ImgStates = {read=FStateCount, write=SetStateCount, default=4};
// __property System::Uitypes::TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property ParentShowHint = {default=1};
__property Vcl::Imaging::Pngimage::TPngImage *PngImg = {read=FPngImg, write=SetPngImg};
__property PopupMenu;
__property ShowHint;
__property Visible = {default=1};
__property OnClick;
__property OnContextPopup;
__property OnMouseDown;
__property OnMouseMove;
__property OnMouseUp;
__property System::Classes::TNotifyEvent OnMouseEnter = {read=FOnMouseEnter, write=FOnMouseEnter};
__property System::Classes::TNotifyEvent OnMouseLeave = {read=FOnMouseLeave, write=FOnMouseLeave};
__property bool EnablePNG = {read=FEnablePNG, write=SetEnablePNG, default=False};
__property TColor BorderColor = {read=FBorderColor, write=SetBorderColor, default=TColor(0x83807d)};
__property TColor InterFrameColor = {read=FInterFrameColor, write=SetInterFrameColor, default=TColor(0x302e2c)};
__property TColor InterColor = {read=FInterColor, write=SetInterColor, default=TColor(0x58504a)};
private:
Vcl::Imaging::Pngimage::TPngImage *m_pPngButton, *m_pPngFoucusButton;
Vcl::Imaging::Pngimage::TPngImage *pTmpDraw, *pTmpFoucusDraw;
void __fastcall PaintCustomer(void);
void __fastcall PaintCustomerText(void);
public:
TRect rtCaption;
__published:
__property int FontSize = {write=SetFontSize, default=8};
__property String Caption = {read=FCaption, write=SetCaption};
};
/**************************************************************************************************/
/**************************************************************************************************/
class PACKAGE TComboBoxComponent : public CBCapButton
{
private:
TComboBoxChangeEvent FOnChange; // ComboBox变化事件
int FItemHeight,
FShowItemCount;
TComboBoxMode FShowMode;
TDropListView *m_DropListView; // 定义下拉列表框
bool m_IsMouseOver;
int m_ClickStat; // .....
void __fastcall DoItemClick(TComboBoxItem *Sender, int Index);
// 处理下拉列表隐藏、显示事件
void __fastcall DoDropListShow(TObject *Sender);
void __fastcall DoDropListHide(TObject *Sender);
int __fastcall GetDefaultItem();
int __fastcall GetItemsCount();
void __fastcall SetDefaultItem(int Value);
void __fastcall SetItemHeight(int Value);
void __fastcall SetShowItemCount(int Value);
void __fastcall SetShowMode(TComboBoxMode Value);
void __fastcall DoMouseEnter(TObject *Sender);
void __fastcall DoMouseLeave(TObject *Sender);
//MESSAGE void __fastcall CMMouseEnter(TMessage &Message);
//MESSAGE void __fastcall CMMouseLeave(TMessage &Message);
//BEGIN_MESSAGE_MAP
// MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
// MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
//END_MESSAGE_MAP(CBCapButton)
protected:
DYNAMIC void __fastcall MouseDown(TMouseButton Button, TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(TMouseButton Button, TShiftState Shift, int X, int Y);
virtual void __fastcall SetParent(TWinControl* AParent);
public:
__fastcall TComboBoxComponent(TComponent *Owner);
__fastcall ~TComboBoxComponent();
TComboBoxItem * __fastcall AddItem(String Caption);
void __fastcall Clear();
void __fastcall RemoveItem(int Index);
TComboBoxItem * __fastcall GetItem(int Index);
virtual void __fastcall SetFontSize( int value );
virtual void __fastcall SetFont( String name, int size );
__property int DefItemIndex = {read = GetDefaultItem, write = SetDefaultItem};
__property int ItemsCount = {read = GetItemsCount};
__published:
__property TComboBoxChangeEvent OnChange = {read = FOnChange, write = FOnChange};
__property int ItemHeight = {read = FItemHeight, write = SetItemHeight, default = 20};
__property int ShowItemCount = {read = FShowItemCount, write = SetShowItemCount, default = 10};
__property TComboBoxMode ShowMode = {read = FShowMode, write = SetShowMode, default = cbShowDown};
__property TWinControl* Parent = {read=FParent, write=SetParent};
};
/**************************************************************************************************/
/**************************************************************************************************/
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,619 @@
//---------------------------------------------------------------------------
#include "ComboBoxComponent.h"
//---------------------------------------------------------------------------
#define CP_ITEM_SLECTED RGB(67, 73, 80)
#define CP_ITEM_UNSLECTED RGB(39, 42, 47)
//---------------------------------------------------------------------------
__fastcall TComboBoxItem::TComboBoxItem(String Caption, TItemClickEvent OnItemClick)
{
FCaption = Caption;
FOnItemClick = OnItemClick;
FTag = 0;
}
//---------------------------------------------------------------------------
void __fastcall TComboBoxItem::DrawItem(TCanvas *Canvas, TRect Rect, bool Selected)
{
if(Selected)
Canvas->Brush->Color = CP_ITEM_SLECTED;
else
Canvas->Brush->Color = CP_ITEM_UNSLECTED;
/* 绘制背景 */
Canvas->FillRect(Rect);
/* 绘制文字 */
int var_TextRectTop = Rect.Top + (Rect.Height() - Canvas->TextHeight(FCaption)) / 2;
TRect var_TextRect(4, var_TextRectTop, Rect.Right - 4, Rect.Bottom);
Canvas->TextRect(var_TextRect, FCaption);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//#define CP_BORDER RGB(29, 31, 35)
#define CP_BORDER RGB(106, 111, 117)
#define CP_BACKGRND RGB(39, 42, 47)
#define CP_BORDER_HL RGB(30, 32, 36)
#define CP_BACKGRND_HL RGB(67, 73, 80)
#define CP_TXT_NOR RGB(213, 221, 232)
#define CP_TXT_DISABLE RGB(100, 108, 119)
#define CP_BREAK RGB(100, 108, 119)
#define CP_BOARD_FILL RGB(76, 82, 91)
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
//---------------------------------------------------------------------------
__fastcall TDropListView::TDropListView(TComponent *Owner) : TWinControl(Owner)
{
m_Canvas = new TControlCanvas();
m_Canvas->Control = this;
m_Canvas->Font->Color = RGB(156, 170, 189);
m_ItemRectList = new TList();
m_ItemList = new TList();
FOnHide = NULL;
FOnShow = NULL;
FItemHeight = 16;
FItemWidth = 99;
FDefItemIndex = -1;
FShowItemsCount = 10;
DoShowItemsChange();
m_CurrentItemIndex = 0;
m_RealShowCount = 0;
m_BeginIndex = 0;
m_ScrollBar = NULL;
SetDesignVisible(false);
Ctl3D = false;
ParentBackground = false;
ParentBiDiMode = false;
ParentColor = false;
ParentCustomHint = false;
ParentDoubleBuffered = false;
ParentFont = true;
ParentShowHint = false;
CreateScrollBar();
}
//---------------------------------------------------------------------------
__fastcall TDropListView::~TDropListView()
{
if(m_ItemRectList)
{
delete m_ItemRectList;
m_ItemRectList = NULL;
}
if(m_ItemList)
{
delete m_ItemList;
m_ItemList = NULL;
}
if(m_ScrollBar)
{
delete m_ScrollBar;
m_ScrollBar = NULL;
}
if(m_Canvas)
{
delete m_Canvas;
m_Canvas = NULL;
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::AddItem(TComboBoxItem* Item)
{
m_ItemList->Add(Item);
DoItemsCountChange();
}
//---------------------------------------------------------------------------
int __fastcall TDropListView::CalcListHeight()
{
if(ItemsCount == 0)
return 10;
else
return FItemHeight * m_RealShowCount;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::Clear()
{
m_ItemList->Clear();
FDefItemIndex = -1;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::CreateParams(TCreateParams &Params)
{
TWinControl::CreateParams(Params);
Params.Style = 0;
Params.Style = WS_POPUP;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::CreateScrollBar()
{
m_ScrollBar = new TDropListScrollBar(NULL);
m_ScrollBar->Parent = this;
m_ScrollBar->Visible = false;
m_ScrollBar->m_pWndCtrl = this;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::CreateWnd()
{
TWinControl::CreateWnd();
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::SetFontSize(int sz)
{
m_Canvas->Font->Size = sz;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::SetFont(String name, int sz)
{
m_Canvas->Font->Name = name;
m_Canvas->Font->Size = sz;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::DoItemClicked(int Index)
{
FDefItemIndex = Index;
GetItem(FDefItemIndex)->OnItemClicked(GetItem(FDefItemIndex), FDefItemIndex);
Hide();
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::DoItemsCountChange()
{
m_RealShowCount = MIN(FShowItemsCount, ItemsCount);
m_EndIndex = m_BeginIndex + m_RealShowCount;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::DoItemSelect(int Index)
{
if(Index != m_CurrentItemIndex)
{
/* 还原上一次选中项 */
if(m_CurrentItemIndex >= m_BeginIndex && m_CurrentItemIndex < m_EndIndex)
{
GetItem(m_CurrentItemIndex)->DrawItem(m_Canvas,
*GetItemRect(m_CurrentItemIndex - m_BeginIndex), false);
}
/* 更新当前选择项 */
m_CurrentItemIndex = Index;
/* 重绘选中项 */
GetItem(m_CurrentItemIndex)->DrawItem(m_Canvas,
*GetItemRect(m_CurrentItemIndex - m_BeginIndex), true);
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::DoKeyUpDown(int Index)
{
if(Index < m_BeginIndex)
{
int var_eIndex = Index + 1;
if(var_eIndex < m_RealShowCount)
ScrollPos(0);
else
ScrollPos(var_eIndex - m_RealShowCount);
}
if(Index >= m_EndIndex)
{
int var_eIndex = Index + m_RealShowCount;
if(var_eIndex > ItemsCount)
ScrollPos(ItemsCount - m_RealShowCount);
else
ScrollPos(var_eIndex - m_RealShowCount);
}
DoItemSelect(Index);
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::DoShowItemsChange()
{
m_ItemRectList->Clear();
for(int i = 0; i < FShowItemsCount; i++)
{
int var_ItemTop = i * FItemHeight;
int var_ItemBottom = var_ItemTop + FItemHeight;
m_ItemRectList->Add(new TRect(1, var_ItemTop + 1, FItemWidth, var_ItemBottom - 1));
}
DoItemsCountChange();
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::Hide()
{
TWinControl::Hide();
SetActiveWindow(m_pActiveWnd);
if(FOnHide) FOnHide(this);
}
//---------------------------------------------------------------------------
int __fastcall TDropListView::GetItemsCount()
{
if(m_ItemList)
return m_ItemList->Count;
else
return -1;
}
//---------------------------------------------------------------------------
TComboBoxItem *__fastcall TDropListView::GetItem(int Index)
{
if(ItemsCount == 0 || Index < 0 || Index > ItemsCount)
return NULL;
else
return (TComboBoxItem *)m_ItemList->Items[Index];
}
//---------------------------------------------------------------------------
TRect *__fastcall TDropListView::GetItemRect(int Index)
{
return (TRect *)m_ItemRectList->Items[Index];
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::MouseDown(TMouseButton Button, TShiftState Shift, int X, int Y)
{
TWinControl::MouseDown(Button, Shift, X, Y);
TRect cl_Rect = GetClientRect();
if(X >= 0 && X <= cl_Rect.Right && Y >= 0 && Y <= cl_Rect.Bottom && ItemsCount > 0)
{
if(Button == 0 && X < FItemWidth)
{
int var_DefItemIndex = Y / FItemHeight + m_BeginIndex;
if(m_CurrentItemIndex != var_DefItemIndex)
DoItemSelect(var_DefItemIndex);
else
DoItemClicked(var_DefItemIndex);
}
}
else
{
Hide();
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::MouseMove(TShiftState Shift, int X, int Y)
{
TWinControl::MouseMove(Shift, X, Y);
if(m_MouseX == X && m_MouseY == Y) return;
m_MouseX = X;
m_MouseY = Y;
TRect var_Rect = GetClientRect();
if(X >= 0 && X < FItemWidth && Y >= 0 && Y < var_Rect.Bottom && ItemsCount > 0)
DoItemSelect(Y / FItemHeight + m_BeginIndex);
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::MouseUp(TMouseButton Button, TShiftState Shift, int X, int Y)
{
TWinControl::MouseUp(Button, Shift, X, Y);
TRect cl_Rect = GetClientRect();
if(X >= 0 && X <= cl_Rect.Right && Y >= 0 && Y <= cl_Rect.Bottom)
{
if(Visible && ItemsCount > 0 && Button == 0 && X < FItemWidth)
{
int var_DefItemIndex = Y / FItemHeight + m_BeginIndex;
if(m_CurrentItemIndex != var_DefItemIndex)
DoItemSelect(var_DefItemIndex);
else
DoItemClicked(var_DefItemIndex);
}
}
else
{
if(Visible) Hide();
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::PaintWindow(HDC DC)
{
if(ItemsCount == 0) return;
m_Canvas->Lock();
for(int Index = m_BeginIndex; Index < m_EndIndex; Index++)
{
int var_ShowIndex = Index - m_BeginIndex;
if(Index == m_CurrentItemIndex)
GetItem(Index)->DrawItem(m_Canvas, *GetItemRect(var_ShowIndex), true);
else
GetItem(Index)->DrawItem(m_Canvas, *GetItemRect(var_ShowIndex), false);
}
m_Canvas->Unlock();
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::RemoveItem(int Index)
{
if(ItemsCount == 0 || Index < 0 || Index > ItemsCount)
return;
if(Index == FDefItemIndex)
FDefItemIndex = -1;
else if(Index > FDefItemIndex)
FDefItemIndex--;
m_ItemList->Delete(Index);
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::ScrollPos(int Pos)
{
if(Pos >= 0 && Pos < ItemsCount)
{
int var_bIndex = Pos;
int var_eIndex = Pos + m_RealShowCount;
if(var_eIndex > ItemsCount)
{
var_eIndex = ItemsCount;
var_bIndex = var_eIndex - m_RealShowCount;
}
if(var_bIndex != m_BeginIndex)
{
m_BeginIndex = var_bIndex;
m_EndIndex = var_eIndex;
PaintWindow(NULL);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::SetShowItemsCount(int Value)
{
if(FShowItemsCount != Value)
{
FShowItemsCount = Value;
DoShowItemsChange();
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::Show()
{
TWinControl::Show();
m_pActiveWnd = GetActiveWindow();
SetActiveWindow(Handle);
//if(FDefItemIndex == -1)
//m_CurrentItemIndex = 0;
//else
m_CurrentItemIndex = FDefItemIndex;
if(m_CurrentItemIndex == -1)
{
m_BeginIndex = 0;
m_EndIndex = m_RealShowCount;
ScrollPos(0);
}
else
{
m_BeginIndex = m_CurrentItemIndex;
m_EndIndex = m_CurrentItemIndex + m_RealShowCount;
if(m_EndIndex > ItemsCount)
{
m_EndIndex = ItemsCount;
m_BeginIndex = m_EndIndex - m_RealShowCount;
}
if(m_CurrentItemIndex < m_BeginIndex || m_CurrentItemIndex >= m_EndIndex)
{
int var_eIndex = m_CurrentItemIndex + 1;
if(var_eIndex < m_RealShowCount)
ScrollPos(m_BeginIndex);
else
ScrollPos(m_EndIndex - m_RealShowCount);
}
}
if(ItemsCount == 0)
Height = 10;
else
Height = FItemHeight * m_RealShowCount;
if(m_ScrollBar)
{
m_ScrollBar->Height = Height - 2;
m_ScrollBar->Left = Width - m_ScrollBar->Width - 1;
m_ScrollBar->Top = 1;
if(m_RealShowCount < ItemsCount)
{
m_ScrollBar->Visible = true;
FItemWidth = m_ScrollBar->Left;
m_ScrollBar->SetRange(0, ItemsCount - 1);
m_ScrollBar->SetPageSize(m_RealShowCount);
m_ScrollBar->SetPosition(m_BeginIndex);
DoShowItemsChange();
}
else
{
m_ScrollBar->Visible = false;
FItemWidth = Width - 1;
DoShowItemsChange();
}
}
if(FOnShow) FOnShow(this);
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMEraseBkgnd(TWMEraseBkgnd &Message)
{
TCanvas* var_BKCanvas = new TCanvas();
var_BKCanvas->Handle = Message.DC;
TRect var_Rect = GetClientRect();
var_BKCanvas->Brush->Color = CP_BACKGRND; // 绘制底色
var_BKCanvas->FillRect(var_Rect);
var_BKCanvas->Brush->Color = CP_BORDER; // 绘制边框
var_BKCanvas->FrameRect(var_Rect);
delete var_BKCanvas;
var_BKCanvas = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMKeyDown(TWMKeyDown &Message)
{
if(ItemsCount == 0) return;
if(Message.CharCode == VK_UP)
{
int var_Index = m_CurrentItemIndex - 1;
if(var_Index < 0) var_Index = 0;
DoKeyUpDown(var_Index);
}
else if(Message.CharCode == VK_DOWN)
{
int var_Index = m_CurrentItemIndex + 1;
if(var_Index >= ItemsCount) var_Index = ItemsCount - 1;
DoKeyUpDown(var_Index);
}
else if(Message.CharCode == VK_ESCAPE)
{
Hide();
}
else if(Message.CharCode == VK_RETURN)
{
DoItemClicked(m_CurrentItemIndex);
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMKillFocus(TMessage &Message)
{
Hide();
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMLButtonDown(TWMLButtonDown &Message)
{
TWinControl::Dispatch(&Message);
if(m_ScrollBar)
{
}
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMMouseWheel(TWMMouseWheel &Message)
{
UINT nSBCode;
if(Message.WheelDelta < 0)
{
nSBCode = SB_LINEDOWN;
}
else
{
nSBCode = SB_LINEUP;
}
if(m_ScrollBar->Visible)
Perform(WM_VSCROLL, MAKELONG(nSBCode, 0), NULL);
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMPaint(TWMPaint &Message)
{
PaintHandler(Message);
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMSetFocus(TMessage &Message)
{
}
//---------------------------------------------------------------------------
void __fastcall TDropListView::WMVScroll(TWMScroll &Message)
{
int minpos, maxpos, page, curpos;
m_ScrollBar->GetScrollRange(& minpos, & maxpos);
page = m_ScrollBar->GetPageSize();
curpos = m_ScrollBar->GetScrollPos();
switch(Message.ScrollCode)
{
case SB_TOP:
curpos = minpos;
break;
case SB_BOTTOM:
curpos = maxpos - page + 1;
break;
case SB_ENDSCROLL:
break;
case SB_LINEUP:
if(curpos > minpos)
{
curpos--;
}
break;
case SB_LINEDOWN:
if(curpos < maxpos - page + 1)
{
curpos++;
}
break;
case SB_PAGEUP:
if(curpos > minpos)
{
curpos = MAX(minpos, curpos - page);
}
break;
case SB_PAGEDOWN:
if(curpos < maxpos)
{
curpos = MIN(maxpos - page + 1, curpos + page);
}
break;
case SB_THUMBPOSITION:
curpos = Message.Pos;
break;
case SB_THUMBTRACK:
curpos = Message.Pos;
break;
}
if(Message.ScrollBar != m_ScrollBar->Handle)
{
m_ScrollBar->SetPosition(curpos);
}
ScrollPos(curpos);
}
//---------------------------------------------------------------------------
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
+654
View File
@@ -0,0 +1,654 @@
[Closed Files]
File_0=TSourceModule,'E:\Ac_Project\Ac_Windows\PngButton\PNGButton.pas',0,1,181,82,200,0,0,,
File_1=TSourceModule,'d:\program file\embarcadero\studio\23.0\include\dinkumware\xlocnum',0,1,1586,20,1618,0,0,,
File_2=TSourceModule,'E:\Ac_Project\Ac_Windows\PngButton\TPNGButtonPCH1.h',0,1,1,1,1,0,0,,
File_3=TSourceModule,'d:\program file\embarcadero\studio\23.0\include\windows\crtl\typeinfo.h',0,1,122,2,154,0,0,,
File_4=TSourceModule,'E:\BCB_Project\Apps\UKeyApps\SLPChecker\SLPChecker.cpp',0,1,1,99,594,0,0,,
File_5=TSourceModule,'E:\BCB_Project\Apps\UKeyApps\SLPrint\PrintThread.cpp',0,1,1,1,1,0,0,,
File_6=TSourceModule,'E:\BCB_Project\Apps\UKeyApps\SLPChecker\Common.cpp',0,1,34,63,66,0,0,,
File_7=TSourceModule,'E:\BCB_Project\Apps\UKeyApps\SLPChecker\SLPChecker.vrc',0,1,1,1,2,0,0,,
File_8=TSourceModule,'E:\BCB_Project\Apps\Global\GlobalUnit.cpp',0,1,1,1,1,0,0,,
File_9=TSourceModule,'E:\BCB_Project\Apps\TotalGoals\Datas.cpp',0,1,1834,55,1847,0,0,,
File_10=TSourceModule,'E:\BCB_Project\Apps\TotalGoals\TGsMain.cpp',0,1,1378,115,1406,0,0,,
File_11=TSourceModule,'E:\BCB_Project\Apps\SportteryHedge\SLHdgMain.cpp',0,1,1,1,1,0,0,,
File_12=TSourceModule,'E:\BCB_Project\Apps\TotalGoals\HGPanelUnit.cpp',0,1,145,75,169,0,0,,
File_13=TSourceModule,'E:\BCB_Project\Apps\TotalGoals\BDPanelUnit.cpp',0,1,134,57,79,0,0,,
File_14=TSourceModule,'E:\BCB_Project\Apps\TotalGoals\SLPanelUnit.cpp',0,1,9,56,26,0,0,,
[Modules]
Count=0
EditWindowCount=1
[EditWindow0]
ViewCount=0
CurrentView=-1
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=9938
Height=9253
MaxLeft=-1
MaxTop=-1
ClientWidth=9938
ClientHeight=9253
TBDockHeight=4476
LRDockWidth=3621
Dockable=1
StayOnTop=0
DockedToMainForm=1
BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0
TopPanelSize=0
LeftPanelSize=1895
LeftPanelClients=PropertyInspector,DockSite3
LeftPanelData=00000800010100000000251000000000000001670700000000000001000000005A0E000009000000446F636B53697465330100000000B31C00001100000050726F7065727479496E73706563746F72FFFFFFFF
RightPanelSize=1996
RightPanelClients=DockSite2,DockSite4
RightPanelData=00000800010100000000251000000000000001CC0700000000000001000000004912000009000000446F636B53697465320100000000B31C000009000000446F636B5369746534FFFFFFFF
BottomPanelSize=1542
BottomPanelClients=DockSite1,MessageView
BottomPanelData=0000080001020100000009000000446F636B536974653103450000000000000206060000000000000100000000034500000F0000004D65737361676556696577466F726DFFFFFFFF
BottomMiddlePanelSize=0
BottomMiddlePanelClients=DockSite0,GraphDrawingModel
BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779F1D00000000000002F206000000000000FFFFFFFF
[Watches]
Count=0
[WatchWindow]
WatchColumnWidth=120
WatchShowColumnHeaders=1
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=3824
Height=1221
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1221
TBDockHeight=216
LRDockWidth=13602
Dockable=1
StayOnTop=0
[Breakpoints]
Count=0
[EmbarcaderoWin32Debugger_AddressBreakpoints]
Count=0
[EmbarcaderoWin64Debugger_AddressBreakpoints]
Count=0
[EmbarcaderoWin64LLDBDebugger_AddressBreakpoints]
Count=0
[Main Window]
PercentageSizes=1
Create=1
Visible=1
Docked=0
State=2
Left=145
Top=273
Width=8930
Height=8520
MaxLeft=-4
MaxTop=-7
MaxWidth=8930
MaxHeight=8520
ClientWidth=10000
ClientHeight=10057
BottomPanelSize=8944
BottomPanelClients=EditWindow0
BottomPanelData=0000080000000000000000000000000000000000000000000000000100000000000000000C0000004564697457696E646F775F30FFFFFFFF
[ProjectManager]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=1996
Height=4382
MaxLeft=-1
MaxTop=-1
ClientWidth=1996
ClientHeight=4382
TBDockHeight=5898
LRDockWidth=2348
Dockable=1
StayOnTop=0
[MessageView]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=28
Width=9938
Height=1394
MaxLeft=-1
MaxTop=-1
ClientWidth=9938
ClientHeight=1394
TBDockHeight=1394
LRDockWidth=2770
Dockable=1
StayOnTop=0
[ToolForm]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=1996
Height=2557
MaxLeft=-1
MaxTop=-1
ClientWidth=1996
ClientHeight=2557
TBDockHeight=7155
LRDockWidth=1996
Dockable=1
StayOnTop=0
[PropertyInspector]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=557
Width=1895
Height=3599
MaxLeft=-1
MaxTop=-1
ClientWidth=1895
ClientHeight=3599
PixelsPerInch=96
MonitorNum=0
TBDockHeight=4274
LRDockWidth=1895
Dockable=1
StayOnTop=0
SplitPos=111
[frmDesignPreview]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=1996
Height=4073
MaxLeft=-1
MaxTop=-1
ClientWidth=1996
ClientHeight=4073
TBDockHeight=5955
LRDockWidth=2512
Dockable=1
StayOnTop=0
[TemplateView]
PercentageSizes=1
Create=1
Visible=0
Docked=1
State=0
Left=0
Top=0
Width=273
Height=359
MaxLeft=-1
MaxTop=-1
ClientWidth=273
ClientHeight=359
TBDockHeight=359
LRDockWidth=273
Dockable=1
StayOnTop=0
Name=120
Description=334
filter=1
[DebugLogView]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=3824
Height=1221
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1221
TBDockHeight=409
LRDockWidth=4949
Dockable=1
StayOnTop=0
[ThreadStatusWindow]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=3824
Height=1221
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1221
TBDockHeight=216
LRDockWidth=7406
Dockable=1
StayOnTop=0
Column0Width=145
Column1Width=100
Column2Width=115
Column3Width=619
[LocalVarsWindow]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=3824
Height=1221
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1221
TBDockHeight=1537
LRDockWidth=3484
Dockable=1
StayOnTop=0
[CallStackWindow]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=3824
Height=1221
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1221
TBDockHeight=2062
LRDockWidth=3484
Dockable=1
StayOnTop=0
[PatchForm]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=2340
Height=1279
MaxLeft=-1
MaxTop=-1
ClientWidth=2340
ClientHeight=1279
TBDockHeight=2500
LRDockWidth=3398
Dockable=1
StayOnTop=0
[FindReferencsForm]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=2340
Height=1279
MaxLeft=-1
MaxTop=-1
ClientWidth=2340
ClientHeight=1279
TBDockHeight=2320
LRDockWidth=2824
Dockable=1
StayOnTop=0
[RefactoringForm]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=2340
Height=1279
MaxLeft=-1
MaxTop=-1
ClientWidth=2340
ClientHeight=1279
TBDockHeight=3211
LRDockWidth=2824
Dockable=1
StayOnTop=0
[ToDo List]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=2340
Height=1279
MaxLeft=-1
MaxTop=-1
ClientWidth=2340
ClientHeight=1279
TBDockHeight=1157
LRDockWidth=3676
Dockable=1
StayOnTop=0
Column0Width=314
Column1Width=30
Column2Width=150
Column3Width=172
Column4Width=129
SortOrder=4
ShowHints=1
ShowChecked=1
[DataExplorerContainer]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=1996
Height=4073
MaxLeft=-1
MaxTop=-1
ClientWidth=1996
ClientHeight=4073
TBDockHeight=4885
LRDockWidth=7148
Dockable=1
StayOnTop=0
[GraphDrawingModel]
PercentageSizes=1
Create=1
Visible=0
Docked=1
State=0
Left=0
Top=0
Width=2855
Height=3211
MaxLeft=-1
MaxTop=-1
ClientWidth=2855
ClientHeight=3211
TBDockHeight=3211
LRDockWidth=2855
Dockable=1
StayOnTop=0
[BreakpointWindow]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=3824
Height=1221
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1221
TBDockHeight=1545
LRDockWidth=8742
Dockable=1
StayOnTop=0
Column0Width=200
Column1Width=75
Column2Width=200
Column3Width=200
Column4Width=200
Column5Width=75
Column6Width=75
[StructureView]
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=0
Width=1895
Height=3542
MaxLeft=-1
MaxTop=-1
ClientWidth=1895
ClientHeight=3542
TBDockHeight=3678
LRDockWidth=1895
Dockable=1
StayOnTop=0
[ParnassusBookmarksForm]
PercentageSizes=1
Create=1
Visible=0
Docked=0
State=0
Left=0
Top=0
Width=2227
Height=2364
MaxLeft=-4
MaxTop=-7
ClientWidth=2164
ClientHeight=2083
TBDockHeight=2364
LRDockWidth=2227
Dockable=1
StayOnTop=0
[BorlandEditorCodeExplorer@EditWindow0]
PercentageSizes=1
Create=1
Visible=0
Docked=0
State=0
Left=0
Top=0
Width=1824
Height=6171
MaxLeft=-4
MaxTop=-7
ClientWidth=1762
ClientHeight=5891
TBDockHeight=6171
LRDockWidth=1824
Dockable=1
StayOnTop=0
[DockHosts]
DockHostCount=5
[DockSite0]
HostDockSite=DockBottomCenterPanel
DockSiteType=1
PercentageSizes=1
Create=1
Visible=0
Docked=1
State=0
Left=8
Top=8
Width=2340
Height=1480
MaxLeft=-1
MaxTop=-1
ClientWidth=2340
ClientHeight=1480
PixelsPerInch=96
MonitorNum=0
TBDockHeight=1480
LRDockWidth=2340
Dockable=1
StayOnTop=0
TabPosition=1
ActiveTabID=RefactoringForm
TabDockClients=RefactoringForm,PatchForm,FindReferencsForm,ToDo List
[DockSite1]
HostDockSite=DockBottomPanel
DockSiteType=1
PercentageSizes=1
Create=1
Visible=0
Docked=1
State=0
Left=8
Top=8
Width=3824
Height=1422
MaxLeft=-1
MaxTop=-1
ClientWidth=3824
ClientHeight=1422
PixelsPerInch=96
MonitorNum=0
TBDockHeight=1422
LRDockWidth=3824
Dockable=1
StayOnTop=0
TabPosition=1
ActiveTabID=DebugLogView
TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow
[DockSite2]
HostDockSite=DockRightPanel
DockSiteType=1
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=28
Width=1996
Height=4583
MaxLeft=-1
MaxTop=-1
ClientWidth=1996
ClientHeight=4583
PixelsPerInch=96
MonitorNum=0
TBDockHeight=4274
LRDockWidth=1996
Dockable=1
StayOnTop=0
TabPosition=1
ActiveTabID=ProjectManager
TabDockClients=ProjectManager,DataExplorerContainer,frmDesignPreview
[DockSite3]
HostDockSite=DockLeftPanel
DockSiteType=1
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=28
Width=1895
Height=3542
MaxLeft=-1
MaxTop=-1
ClientWidth=1895
ClientHeight=3542
PixelsPerInch=96
MonitorNum=0
TBDockHeight=4274
LRDockWidth=1895
Dockable=1
StayOnTop=0
TabPosition=1
ActiveTabID=StructureView
TabDockClients=StructureView
[DockSite4]
HostDockSite=DockRightPanel
DockSiteType=1
PercentageSizes=1
Create=1
Visible=1
Docked=1
State=0
Left=0
Top=702
Width=1996
Height=2557
MaxLeft=-1
MaxTop=-1
ClientWidth=1996
ClientHeight=2557
PixelsPerInch=96
MonitorNum=0
TBDockHeight=4274
LRDockWidth=1996
Dockable=1
StayOnTop=0
TabPosition=1
ActiveTabID=ToolForm
TabDockClients=ToolForm,TemplateView
[ActiveProject]
ActiveProject=8
+120
View File
@@ -0,0 +1,120 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{CE208A77-9005-40A7-9448-30493E16683A}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Projects Include="TCKBox.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TComboBoxComponent.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TGeneralDialogPanel.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TLineEdit.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TRadioBtn.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TSkinTrackBar.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TTextButton.cbproj">
<Dependencies/>
</Projects>
<Projects Include="TCapButton.cbproj">
<Dependencies/>
</Projects>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Default.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Default.Personality/>
</BorlandProject>
</ProjectExtensions>
<Target Name="TCKBox">
<MSBuild Projects="TCKBox.cbproj"/>
</Target>
<Target Name="TCKBox:Clean">
<MSBuild Projects="TCKBox.cbproj" Targets="Clean"/>
</Target>
<Target Name="TCKBox:Make">
<MSBuild Projects="TCKBox.cbproj" Targets="Make"/>
</Target>
<Target Name="TComboBoxComponent">
<MSBuild Projects="TComboBoxComponent.cbproj"/>
</Target>
<Target Name="TComboBoxComponent:Clean">
<MSBuild Projects="TComboBoxComponent.cbproj" Targets="Clean"/>
</Target>
<Target Name="TComboBoxComponent:Make">
<MSBuild Projects="TComboBoxComponent.cbproj" Targets="Make"/>
</Target>
<Target Name="TGeneralDialogPanel">
<MSBuild Projects="TGeneralDialogPanel.cbproj"/>
</Target>
<Target Name="TGeneralDialogPanel:Clean">
<MSBuild Projects="TGeneralDialogPanel.cbproj" Targets="Clean"/>
</Target>
<Target Name="TGeneralDialogPanel:Make">
<MSBuild Projects="TGeneralDialogPanel.cbproj" Targets="Make"/>
</Target>
<Target Name="TLineEdit">
<MSBuild Projects="TLineEdit.cbproj"/>
</Target>
<Target Name="TLineEdit:Clean">
<MSBuild Projects="TLineEdit.cbproj" Targets="Clean"/>
</Target>
<Target Name="TLineEdit:Make">
<MSBuild Projects="TLineEdit.cbproj" Targets="Make"/>
</Target>
<Target Name="TRadioBtn">
<MSBuild Projects="TRadioBtn.cbproj"/>
</Target>
<Target Name="TRadioBtn:Clean">
<MSBuild Projects="TRadioBtn.cbproj" Targets="Clean"/>
</Target>
<Target Name="TRadioBtn:Make">
<MSBuild Projects="TRadioBtn.cbproj" Targets="Make"/>
</Target>
<Target Name="TSkinTrackBar">
<MSBuild Projects="TSkinTrackBar.cbproj"/>
</Target>
<Target Name="TSkinTrackBar:Clean">
<MSBuild Projects="TSkinTrackBar.cbproj" Targets="Clean"/>
</Target>
<Target Name="TSkinTrackBar:Make">
<MSBuild Projects="TSkinTrackBar.cbproj" Targets="Make"/>
</Target>
<Target Name="TTextButton">
<MSBuild Projects="TTextButton.cbproj"/>
</Target>
<Target Name="TTextButton:Clean">
<MSBuild Projects="TTextButton.cbproj" Targets="Clean"/>
</Target>
<Target Name="TTextButton:Make">
<MSBuild Projects="TTextButton.cbproj" Targets="Make"/>
</Target>
<Target Name="TCapButton">
<MSBuild Projects="TCapButton.cbproj"/>
</Target>
<Target Name="TCapButton:Clean">
<MSBuild Projects="TCapButton.cbproj" Targets="Clean"/>
</Target>
<Target Name="TCapButton:Make">
<MSBuild Projects="TCapButton.cbproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="TCKBox;TComboBoxComponent;TGeneralDialogPanel;TLineEdit;TRadioBtn;TSkinTrackBar;TTextButton;TCapButton"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="TCKBox:Clean;TComboBoxComponent:Clean;TGeneralDialogPanel:Clean;TLineEdit:Clean;TRadioBtn:Clean;TSkinTrackBar:Clean;TTextButton:Clean;TCapButton:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="TCKBox:Make;TComboBoxComponent:Make;TGeneralDialogPanel:Make;TLineEdit:Make;TRadioBtn:Make;TSkinTrackBar:Make;TTextButton:Make;TCapButton:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project>
@@ -0,0 +1,353 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#pragma hdrstop
#include "GeneralDialogPanel.h"
#pragma package(smart_init)
#include "PNGButton.cpp"
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
//
static const char *pngImage =
"89504E470D0A1A0A0000000D49484452000000450000001208060000000D0613"\
"66000000097048597300000B1300000B1301009A9C1800000A4D694343505068"\
"6F746F73686F70204943432070726F66696C65000078DA9D53775893F7163EDF"\
"F7650F5642D8F0B1976C81002223AC08C81059A21092006184101240C585880A"\
"561415119C4855C482D50A489D88E2A028B867418A885A8B555C38EE1FDCA7B5"\
"7D7AEFEDEDFBD7FBBCE79CE7FCCE79CF0F8011122691E6A26A003952853C3AD8"\
"1F8F4F48C4C9BD80021548E0042010E6CBC26705C50000F00379787E74B03FFC"\
"01AF6F00020070D52E2412C7E1FF83BA50265700209100E02212E70B01905200"\
"C82E54C81400C81800B053B3640A009400006C797C422200AA0D00ECF4493E05"\
"00D8A993DC1700D8A21CA908008D0100992847240240BB00605581522C02C0C2"\
"00A0AC40222E04C0AE018059B632470280BD0500768E58900F4060008099422C"\
"CC0020380200431E13CD03204C03A030D2BFE0A95F7085B8480100C0CB95CD97"\
"4BD23314B895D01A77F2F0E0E221E2C26CB142611729106609E4229C979B2313"\
"48E7034CCE0C00001AF9D1C1FE383F90E7E6E4E1E666E76CEFF4C5A2FE6BF06F"\
"223E21F1DFFEBC8C020400104ECFEFDA5FE5E5D60370C701B075BF6BA95B00DA"\
"560068DFF95D33DB09A05A0AD07AF98B7938FC401E9EA150C83C1D1C0A0B0BED"\
"2562A1BD30E38B3EFF33E16FE08B7EF6FC401EFEDB7AF000719A4099ADC0A383"\
"FD71616E76AE528EE7CB0442316EF7E723FEC7857FFD8E29D1E234B15C2C158A"\
"F15889B850224DC779B952914421C995E212E97F32F11F96FD0993770D00AC86"\
"4FC04EB607B5CB6CC07EEE01028B0E58D27600407EF32D8C1A0B910010673432"\
"79F7000093BFF98F402B0100CD97A4E30000BCE8185CA894174CC608000044A0"\
"812AB041070CC114ACC00E9CC11DBCC01702610644400C24C03C104206E4801C"\
"0AA11896411954C03AD804B5B0031AA0119AE110B4C131380DE7E0125C81EB70"\
"170660189EC218BC86090441C8081361213A8811628ED822CE0817998E042261"\
"48349280A420E988145122C5C872A402A9426A915D4823F22D7214398D5C40FA"\
"90DBC820328AFC8ABC47319481B25103D4027540B9A81F1A8AC6A073D174340F"\
"5D8096A26BD11AB41E3D80B6A2A7D14BE87574007D8A8E6380D1310E668CD961"\
"5C8C87456089581A26C71663E55835568F35631D583776151BC09E61EF082402"\
"8B8013EC085E8410C26C82909047584C5843A825EC23B412BA085709838431C2"\
"272293A84FB4257A12F9C478623AB1905846AC26EE211E219E255E270E135F93"\
"48240EC992E44E0A21259032490B496B48DB482DA453A43ED210699C4C26EB90"\
"6DC9DEE408B280AC209791B7900F904F92FBC9C3E4B7143AC588E24C09A22452"\
"A494124A35653FE504A59F324299A0AA51CDA99ED408AA883A9F5A496DA07650"\
"2F5387A91334759A25CD9B1643CBA42DA3D5D09A696769F7682FE974BA09DD83"\
"1E4597D097D26BE807E9E7E983F4770C0D860D83C7486228196B197B19A718B7"\
"192F994CA605D39799C85430D7321B9967980F986F55582AF62A7C1591CA1295"\
"3A9556957E95E7AA545573553FD579AA0B54AB550FAB5E567DA64655B350E3A9"\
"09D416ABD5A91D55BBA936AECE5277528F50CF515FA3BE5FFD82FA630DB28685"\
"46A08648A35463B7C6198D2116C63265F15842D6725603EB2C6B984D625BB2F9"\
"EC4C7605FB1B762F7B4C534373AA66AC6691669DE671CD010EC6B1E0F039D99C"\
"4ACE21CE0DCE7B2D032D3F2DB1D66AAD66AD7EAD37DA7ADABEDA62ED72ED16ED"\
"EBDAEF75709D409D2C9DF53A6D3AF77509BA36BA51BA85BADB75CFEA3ED363EB"\
"79E909F5CAF50EE9DDD147F56DF4A3F517EAEFD6EFD11F373034083690196C31"\
"3863F0CC9063E86B9869B8D1F084E1A811CB68BA91C468A3D149A327B826EE87"\
"67E33578173E66AC6F1C62AC34DE65DC6B3C61626932DBA4C4A4C5E4BE29CD94"\
"6B9A66BAD1B4D374CCCCC82CDCACD8ACC9EC8E39D59C6B9E61BED9BCDBFC8D85"\
"A5459CC54A8B368BC796DA967CCB05964D96F7AC98563E567956F556D7AC49D6"\
"5CEB2CEB6DD6576C501B579B0C9B3A9BCBB6A8AD9BADC4769B6DDF14E2148F29"\
"D229F5536EDA31ECFCEC0AEC9AEC06ED39F661F625F66DF6CF1DCC1C121DD63B"\
"743B7C727475CC766C70BCEBA4E134C3A9C4A9C3E957671B67A1739DF33517A6"\
"4B90CB1297769717536DA78AA76E9F7ACB95E51AEEBAD2B5D3F5A39BBB9BDCAD"\
"D96DD4DDCC3DC57DABFB4D2E9B1BC95DC33DEF41F4F0F758E271CCE39DA79BA7"\
"C2F390E72F5E765E595EFBBD1E4FB39C269ED6306DC8DBC45BE0BDCB7B603A3E"\
"3D65FACEE9033EC63E029F7A9F87BEA6BE22DF3DBE237ED67E997E07FC9EFB3B"\
"FACBFD8FF8BFE179F216F14E056001C101E501BD811A81B3036B031F049904A5"\
"0735058D05BB062F0C3E15420C090D591F72936FC017F21BF96333DC672C9AD1"\
"15CA089D155A1BFA30CC264C1ED6118E86CF08DF107E6FA6F94CE9CCB60888E0"\
"476C88B81F69199917F97D14292A32AA2EEA51B453747174F72CD6ACE459FB67"\
"BD8EF18FA98CB93BDB6AB6727667AC6A6C526C63EC9BB880B8AAB8817887F845"\
"F1971274132409ED89E4C4D8C43D89E37302E76C9A339CE49A54967463AEE5DC"\
"A2B917E6E9CECB9E773C593559907C3885981297B23FE5832042502F184FE5A7"\
"6E4D1D13F2849B854F45BEA28DA251B1B7B84A3C92E69D5695F638DD3B7D43FA"\
"68864F4675C633094F522B79911992B923F34D5644D6DEACCFD971D92D39949C"\
"949CA3520D6996B42BD730B728B74F662B2B930DE479E66DCA1B9387CAF7E423"\
"F973F3DB156C854CD1A3B452AE500E164C2FA82B785B185B78B848BD485AD433"\
"DF66FEEAF9230B82167CBD90B050B8B0B3D8B87859F1E022BF45BB16238B5317"\
"772E315D52BA647869F0D27DCB68CBB296FD50E2585255F26A79DCF28E5283D2"\
"A5A5432B82573495A994C9CB6EAEF45AB9631561956455EF6A97D55B567F2A17"\
"955FAC70ACA8AEF8B046B8E6E2574E5FD57CF5796DDADADE4AB7CAEDEB48EBA4"\
"EB6EACF759BFAF4ABD6A41D5D086F00DAD1BF18DE51B5F6D4ADE74A17A6AF58E"\
"CDB4CDCACD03356135ED5BCCB6ACDBF2A136A3F67A9D7F5DCB56FDADABB7BED9"\
"26DAD6BFDD777BF30E831D153BDEEF94ECBCB52B78576BBD457DF56ED2EE82DD"\
"8F1A621BBABFE67EDDB847774FC59E8F7BA57B07F645EFEB6A746F6CDCAFBFBF"\
"B2096D52368D1E483A70E59B806FDA9BED9A77B5705A2A0EC241E5C127DFA67C"\
"7BE350E8A1CEC3DCC3CDDF997FB7F508EB48792BD23ABF75AC2DA36DA03DA1BD"\
"EFE88CA39D1D5E1D47BEB7FF7EEF31E36375C7358F579EA09D283DF1F9E48293"\
"E3A764A79E9D4E3F3DD499DC79F74CFC996B5D515DBD6743CF9E3F1774EE4CB7"\
"5FF7C9F3DEE78F5DF0BC70F422F762DB25B74BAD3DAE3D477E70FDE148AF5B6F"\
"EB65F7CBED573CAE74F44DEB3BD1EFD37FFA6AC0D573D7F8D72E5D9F79BDEFC6"\
"EC1BB76E26DD1CB825BAF5F876F6ED17770AEE4CDC5D7A8F78AFFCBEDAFDEA07"\
"FA0FEA7FB4FEB165C06DE0F860C060CFC3590FEF0E09879EFE94FFD387E1D247"\
"CC47D52346238D8F9D1F1F1B0D1ABDF264CE93E1A7B2A713CFCA7E56FF79EB73"\
"ABE7DFFDE2FB4BCF58FCD8F00BF98BCFBFAE79A9F372EFABA9AF3AC723C71FBC"\
"CE793DF1A6FCADCEDB7DEFB8EFBADFC7BD1F9928FC40FE50F3D1FA63C7A7D04F"\
"F73EE77CFEFC2FF784F3FB25D29F330000067F4944415478DABD58094C944714"\
"9EDD85656529085A400B495913D46A9346894DDAC4A3BA2A566CB54A8B72552C"\
"2A022D2AD178228256299472C8214D056FA86D53A807A65A4D5AABD1A6D15A95"\
"8A3D14C55A05916365D9DDBE61DFB06F87DD4093EA9FBCFCF3CF3FF3E69B6FDE"\
"BCF76614168B853D89C7643289A282881245419A5A50E4F6F4BF19C522B55738"\
"18E3BFEA96755A1494143291FFF3E124A8405C405C515CB05E8031E19B122740"\
"77811851BAB0AD994C5249C610A220933413DD322926223DC43F695204684E84"\
"1B883B881644837574E2666C4F09E3F5069036907690C7488E9828255C4D4458"\
"A323C205295C4727911EC26552B8724F102F029A21B02604C627E40D32800CC0"\
"81B6A018255254488816F5FAE07B004EC6420029B14E41087908F200DF6D488C"\
"98A8205C8DFAB4F816C4D0AD27B0084238CE0ED4D981C4181D598A666EF8DBE9"\
"D7AFD7A7D2E5562A955D5151917129EF27D7565656BD94959D73C068347AD136"\
"414141B95F1EAA5A830350525C10A857C4FCC8942B57AFA648BA4D5B32338AA7"\
"4F9BFAD7C54B977CE2172F4D34180C5ADA263838B8A0F2C0BE2C24A61D096384"\
"14F7D7C366A53434DC5E27E34E4A5CB6FCDDD898BA13274FFAAD5ABD264FC6ED"\
"EFEFBFEDE8E19AED8418879612307DC6CC838D8D8DE368673737B7FB39D9592B"\
"D7AEDBB0AAB9B97904FDE7EBEBFB53EDD1C373A178CB81A5085206720C00BE10"\
"C087D0FE1E1E1E8FCA4A4B76AE484D0D877F0112E89F01F4122836A2B5762029"\
"165CF96E5238E99326EB773535358DEF2F6E2F2FCF1F4E9D3C1149C8363A2285"\
"BF34A74E9F0E0156BF80157B962A51A954066E4DB44EA3D1DCDBBC296D9E5E3F"\
"E52C9A3B7D84C96A9094217575752F2E5C149FDDDADA3A9036747575ED845554"\
"4B643517EF284C1D3D7AD445F8BC0DD28C63C8DBA79B9433677ED4A5AC5879A0"\
"BFB83FDCBA65C1C409E37FEB0F297C22CF64E77C1CB177DFFE02B3D9ECC29C3C"\
"0A85C23C3FE29DA4D4952BF6C0E723661FFE7A3031AB4FE1663B0444575D5DA3"\
"DFB8293D0E74AB9CE906D3B7AC5FB7B66CF69B6FD4C2E70D903B085EF814C66C"\
"3E6800EA1F5C5C523AB17467D9B6BE702F8A5BB87A59C2D26FE1F31FD42B2CD0"\
"EC2CFAF0C1862E5E92B0F9ECB973B1CE94BF3C6EDCAE92E21D1BA0D8C06C61B2"\
"D7FC98D5F171D0FE9C149091EB37A64DE4E438D31D1636F33858E07750BC0A52"\
"CFACDB8783EF64F6215990C20304B79021807B5E3F705721D1F7983540F46C4B"\
"67A4F08102DF9A175E545F7F639A33E5C386E98E1DAAAAE4FBFD26593D47A4B8"\
"21686E29C340462C8A5F3CFBFCF90B639DE90E09197B01FCCC5750BC82A4DC41"\
"F08F9D90E285A4F803EEE47EE0CE27A4504B71480A9F84F772F07AE0B157B13E"\
"1EFD94C95BB3B66FCB665627285B8BC80D844F190AA2CBFD242F7C5779C59CBE"\
"7483891F4A5C96C057946F1FEA53689EC2497147FD83C117461CABAD5DDE97EE"\
"D0D0E91F6DCDCC38C8ACDB87EB1551CDE1F6D102E0D0FC82C2DDB27352ABD54D"\
"9D9D9DDEB48E3B31087B51B131D1479835E6CBA48895E4FD86D61E3FFE2A4482"\
"4CD9A96AB5EEAD6D6DED1EB48E3BDFCC8CF4B553F5FAEF91141A7DC4027247DB"\
"9D039557EC0EC9CB2F28EF2FEEE4A4C49898E8A8F3CC96033974B46ED7AED58D"\
"8C7B2FFE6B880E8154C9A0413EBF1415166C84C8912BFF832871F3D39DA5B386"\
"0F0FE6A6FE58224544079F9BB76E3DBF2032BAA2A5A5E539DA3F3030F04FD82A"\
"FBE74746C6DDBFFFC02E72787A7A36ECDD53111D1810F007B32671224A0852BA"\
"33E5CB977FF503DCD510798264DC25454519B10BE3B264DC10817E07DC61A346"\
"BD7097D932E65EA4784C0B9DB1FFEEDDBF67D2CE3CD66F4E4F9B032B760556E3"\
"15B0A27D5D5D5DEEB48D9F9F6FCDB1238723A0D84AAAEDCC1B74E7CBBAB55A6D"\
"CBEEF2CF72753ADD23708EBE49C91F24C1AA6A1CE84E62F6662EF294EE6C76C2"\
"A4D78A1F3E6C992BE3DE51989F3076CC98E6EA9A6F02D236A5E7C11CED1243C8"\
"553E875C6509B3256F26991411253C992D25B620106EBA069CA048F37BBA32AB"\
"1314D1815A0A27458326CEF7BD0FEAD7206966664BF34532A6C46F03EA7D8084"\
"B4619DBC7DD4ACF7B94A9C7D449A2FCE490A664BF3E9B94AA4F9E6A771201413"\
"D52070772C8B3CC2C46C074271B853927F1D08BA1D276164B64847F58BC3A02B"\
"B33F65D3444F29E93632DB8150E87D2AA764015C9C64C5D5015D497A925531FB"\
"53AEB83AA027590BEB7DD5E0E2A0AFD02F1E25C144C7168BF254AE0E2831F482"\
"C9D9458F7C5944FFC9174D8C3DA14BA67F0133893470B75DAFB1000000004945"\
"4E44AE426082";
//---------------------------------------------------------------------------
static const COLORREF
CLR_TXT_HOT = RGB(171, 186, 207), //d5dde8
CLR_BKG_EXTERNAL_ROUND = RGB(107, 115, 126),
CLR_BKG_EXTERNAL_FRMAE = RGB(145, 156, 170),
CLR_BKG_INTERNAL = RGB(65, 70, 77 ),
CLR_BKG_INTERNAL_LINE_HIG = RGB(118, 126, 134),
CLR_BKG_INTERNAL_LINE_BLACK = RGB(32, 36, 41 );
//---------------------------------------------------------------------------
static inline void ValidCtrCheck(TGeneralDialogPanel *)
{
new TGeneralDialogPanel(NULL);
}
//---------------------------------------------------------------------------
#define PNGCLOSE_LEFT Width - m_imgClose->Width/3 - 2
#define PNGCLOSE_TOP 3
__fastcall TGeneralDialogPanel::TGeneralDialogPanel(TComponent* Owner)
: TPanel(Owner)
{
Color = CLR_BKG_INTERNAL;
FOnCanceled = NULL;
m_imgClose = new TPngImage();
TMemoryStream *pngStream = new TMemoryStream();
String pngData = pngImage;
int length = pngData.Length();
const char *temppngImage = pngImage;
unsigned char buffer[10000];
for(int i=0;i<length;i++){
sscanf(temppngImage, "%02hhx", &buffer[i]);
temppngImage += 2;
}
pngStream->Position = 0;
pngStream->WriteBuffer(buffer, length);
pngStream->Position = 0;
m_imgClose->LoadFromStream(pngStream);
delete pngStream;
m_btnClose = new CBTPNButton(this);
m_btnClose->SetStateCount( 3 );
m_btnClose->SetPngImg( m_imgClose );
m_btnClose->SetColor( Color );
m_btnClose->Left = PNGCLOSE_LEFT;
m_btnClose->Top = PNGCLOSE_TOP;
m_btnClose->Hint = "关闭";
m_btnClose->ModalResult = System::Uitypes::mrCancel;
m_btnClose->Parent = this;
m_btnClose->OnClick = CloseClick;
Canvas->Font->Size = 9;
}
//---------------------------------------------------------------------------
__fastcall TGeneralDialogPanel::~TGeneralDialogPanel()
{
if(m_imgClose)
delete m_imgClose;
if(m_btnClose)
delete m_btnClose;
}
//---------------------------------------------------------------------------
namespace Generaldialogpanel
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TGeneralDialogPanel)};
RegisterComponents(L"Samples", classes, 0);
}
}
//---------------------------------------------------------------------------
void __fastcall TGeneralDialogPanel::CloseClick(TObject *Sender)
{
if( FOnCanceled )
FOnCanceled( this );
}
//---------------------------------------------------------------------------
void __fastcall TGeneralDialogPanel::WMEraseBkgnd(Winapi::Messages::TWMEraseBkgnd &Message)
{
TRect rect = GetClientRect();
TRect rectFill = rect;
TCanvas* tempCanvas = new TCanvas;
tempCanvas->Handle = Message.DC;
rectFill.Top = rectFill.Top + LEN_BKG_EXTERNAL_ROUND;
rectFill.Left = rectFill.Left + LEN_BKG_EXTERNAL_ROUND;
rectFill.Right = rectFill.Right - LEN_BKG_EXTERNAL_ROUND;
rectFill.Bottom = rectFill.Bottom - LEN_BKG_EXTERNAL_ROUND;
tempCanvas->Brush->Color = CLR_BKG_INTERNAL;
tempCanvas->FillRect( rectFill );
delete tempCanvas;
Message.Result = true;
}
//---------------------------------------------------------------------------
void __fastcall TGeneralDialogPanel::WMSize(Winapi::Messages::TWMSize &Message)
{
DefaultHandler( &Message );
m_btnClose->Left = PNGCLOSE_LEFT;
m_btnClose->Top = PNGCLOSE_TOP;
}
//---------------------------------------------------------------------------
void __fastcall TGeneralDialogPanel::CreateWnd()
{
Vcl::Extctrls::TPanel::CreateWnd();
Canvas->Font->Assign(Font);
}
//---------------------------------------------------------------------------
void __fastcall TGeneralDialogPanel::Paint(void)
{
//==========画圆角
Canvas->Pen->Color = CLR_BKG_EXTERNAL_ROUND;
int X,Y;
//上面的
Y = 0;
X = 0;
Canvas->Pixels[X][Y] = Canvas->Pen->Color;
X = Width - LEN_BKG_EXTERNAL_ROUND;
Canvas->Pixels[X][Y] = Canvas->Pen->Color;
//下面的
Y = Height - LEN_BKG_EXTERNAL_ROUND;
X = 0;
Canvas->Pixels[X][Y] = Canvas->Pen->Color;
X = Width - LEN_BKG_EXTERNAL_ROUND;
Canvas->Pixels[X][Y] = Canvas->Pen->Color;
//===========画边框
Canvas->Pen->Color = CLR_BKG_EXTERNAL_FRMAE;
Canvas->MoveTo( LEN_BKG_EXTERNAL_FRMAE, 0 );
Canvas->LineTo( Width-LEN_BKG_EXTERNAL_FRMAE, 0 );
Canvas->MoveTo( LEN_BKG_EXTERNAL_FRMAE, Height-LEN_BKG_EXTERNAL_FRMAE );
Canvas->LineTo( Width-LEN_BKG_EXTERNAL_FRMAE, Height-LEN_BKG_EXTERNAL_FRMAE );
Canvas->MoveTo( 0, LEN_BKG_EXTERNAL_FRMAE );
Canvas->LineTo( 0, Height-LEN_BKG_EXTERNAL_FRMAE );
Canvas->MoveTo( Width-LEN_BKG_EXTERNAL_FRMAE, LEN_BKG_EXTERNAL_FRMAE );
Canvas->LineTo( Width-LEN_BKG_EXTERNAL_FRMAE, Height-LEN_BKG_EXTERNAL_FRMAE );
//===========画分割线
int iLineHeight = LEN_BKG_INTERNAL_LINE;
Canvas->Pen->Color = CLR_BKG_INTERNAL_LINE_HIG;
Canvas->MoveTo( LEN_BKG_EXTERNAL_FRMAE, iLineHeight );
Canvas->LineTo( Width-LEN_BKG_EXTERNAL_FRMAE, iLineHeight );
Canvas->MoveTo( LEN_BKG_EXTERNAL_FRMAE, iLineHeight+2 );
Canvas->LineTo( Width-LEN_BKG_EXTERNAL_FRMAE, iLineHeight+2 );
Canvas->Pen->Color = CLR_BKG_INTERNAL_LINE_BLACK;
Canvas->MoveTo( LEN_BKG_EXTERNAL_FRMAE, iLineHeight+1 );
Canvas->LineTo( Width-LEN_BKG_EXTERNAL_FRMAE, iLineHeight+1 );
//画标题
Canvas->Font->Color = CLR_TXT_HOT;
Canvas->Brush->Style = bsClear;
TSize size = Canvas->TextExtent( Caption );
X = LEN_BKG_EXTERNAL_FRMAE + ( Width - size.Width )/2,
Y = LEN_BKG_EXTERNAL_FRMAE + ( LEN_BKG_INTERNAL_LINE-size.Height )/2;
Canvas->TextOut( X, Y, Caption );
}
//---------------------------------------------------------------------------
void __fastcall TGeneralDialogPanel::MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y)
{
if (X > Left + 10 && X < Left + Width - 50 && Y < Top + LEN_BKG_INTERNAL_LINE){
ReleaseCapture();
Parent->Perform(WM_NCLBUTTONDOWN,HTCAPTION, 0);
}else{
Vcl::Extctrls::TPanel::MouseDown(Button, Shift, X, Y);
}
}
//---------------------------------------------------------------------------
@@ -0,0 +1,54 @@
//---------------------------------------------------------------------------
/////////////////////////////////
////////安装 记得在生成编译包的工程和使用工程中加图片 Res\System\close.png -->L"PngImage_Close"
/////////////////////////////////
#ifndef GeneralDialogPanelH
#define GeneralDialogPanelH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Imaging.jpeg.hpp>
#include <Vcl.Graphics.hpp>
//---------------------------------------------------------------------------
class CBTPNButton;
#define LEN_BKG_EXTERNAL_ROUND 1
#define LEN_BKG_EXTERNAL_FRMAE 1
#define LEN_BKG_INTERNAL_LINE 23
//---------------------------------------------------------------------------
class PACKAGE TGeneralDialogPanel : public TPanel
{
private:
TNotifyEvent FOnCanceled; // 关闭窗口事件
TPngImage *m_imgClose;
CBTPNButton *m_btnClose;
void __fastcall CloseClick(TObject *Sender);
MESSAGE void __fastcall WMEraseBkgnd(Winapi::Messages::TWMEraseBkgnd &Message);
MESSAGE void __fastcall WMSize(Winapi::Messages::TWMSize &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
END_MESSAGE_MAP(Vcl::Extctrls::TPanel)
protected:
virtual void __fastcall Paint(void);
virtual void __fastcall CreateWnd();
DYNAMIC void __fastcall MouseDown(System::Uitypes::TMouseButton Button,
System::Classes::TShiftState Shift, int X, int Y);
public:
__fastcall TGeneralDialogPanel(TComponent* Owner);
__fastcall ~TGeneralDialogPanel();
__published:
__property TNotifyEvent OnCanceled = {write = FOnCanceled, read = FOnCanceled};
};
//---------------------------------------------------------------------------
#endif
+205
View File
@@ -0,0 +1,205 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "PNGButton.h"
//#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
//static inline void ValidCtrCheck(TPNGButton *)
//{
// new TPNGButton(NULL);
//}
////---------------------------------------------------------------------------
__fastcall CBTPNButton::CBTPNButton(TComponent* Owner)
: TGraphicControl(Owner)
{
Height = 25; //a default Height
Width = 75; //a default Width
FStateCount = 4; //default state count
FPngImg = new Vcl::Imaging::Pngimage::TPngImage(); //we create our png
FDown = false;
}
//---------------------------------------------------------------------------
__fastcall CBTPNButton::~CBTPNButton(void)
{
if(FPngImg)
delete FPngImg; //destroy our png
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::SetStateCount( int count )
{
if( count>4 ) count = 4;
if( count<2 ) count = 2;
FStateCount = count;
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::SetPngImg(Vcl::Imaging::Pngimage::TPngImage *value)
{
FPngImg->Assign(value);
//Now setting the component width and height by the png image used
Height = FPngImg->Height;
Width = FPngImg->Width / FStateCount;
Constraints->MaxHeight = Height;
Constraints->MinHeight = Height;
Constraints->MaxWidth = Width;
Constraints->MinWidth = Width;
EtatBtn = 0; //reset the component state to normal
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::SetDown(bool value)
{
if( FStateCount<3 )
value = false;
FDown = value;
if( FDown==False )
EtatBtn = 0; //is the mouse down is false then we reset the component state to normal
Paint();
// Refresh(); //we repaint the componet)
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::SetColor( TColor value )
{
FBkColor = value;
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::Paint(void)
{
TRect rect = GetClientRect();
Canvas->Brush->Color = FBkColor;
Canvas->FillRect( rect );
if( FPngImg ){
switch( EtatBtn ){
case 0:
FPngImg->Draw( Canvas, Rect(0, 0, FStateCount*Width, Height) ); // Normal
break;
case 1:
FPngImg->Draw( Canvas, Rect(-Width, 0, (FStateCount-1)*Width, Height) ); // Mouse Entered
break;
case 2:
FPngImg->Draw( Canvas, Rect(-(Width*2), 0, (FStateCount-2)*Width, Height) ); // Pressed
break;
case 3:
FPngImg->Draw( Canvas, Rect(-(Width*3), 0, (FStateCount-3)*Width, Height) ); // Disabled
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::SetEnabled(bool Value)
{
if(FStateCount<4) //can't be disable
Value = true;
TGraphicControl::SetEnabled(Value);
if( Enabled )
EtatBtn = 0;
else
EtatBtn = 3;
Paint();
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::MouseDown(System::Uitypes::TMouseButton Button,
System::Classes::TShiftState Shift, int X, int Y)
{
TGraphicControl::MouseDown( Button, Shift, X, Y );
if( Button==mbLeft && Enabled && FStateCount>2){
EtatBtn = 2; // Pressed
Paint();
// Refresh();
}
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::MouseUp(System::Uitypes::TMouseButton Button,
System::Classes::TShiftState Shift, int X, int Y)
{
TGraphicControl::MouseUp( Button, Shift, X, Y );
if( Button==mbLeft && Enabled ){
if( X>=0 && X<Width && Y>=0 && Y<Height )
EtatBtn = 1; //Mouse Entered
else
EtatBtn = 0; //normal;
Paint();
// Refresh(); //repaint component
}
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::CMMouseEnter(Winapi::Messages::TMessage &Msg)
{
if( Enabled ){//&& !ComponentState.Contains(csDesigning) ){
EtatBtn = 1; // Mouse Entered
Paint();
// Refresh(); //repainting the component
}
if( FOnMouseEnter )
FOnMouseEnter(this); //if user set a mouse enter procedure then we execute it
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::CMMouseLeave(Winapi::Messages::TMessage &Msg)
{
if( Enabled ){//&& !ComponentState.Contains(csDesigning) ) {
EtatBtn = 0; //Normal
Paint();
// Refresh(); //repainting the component
}
if( FOnMouseLeave )
FOnMouseLeave(this); //if user set a mouse leave procedure then we execute it
}
//---------------------------------------------------------------------------
void __fastcall CBTPNButton::Click(void)
{
TCustomForm * parentForm = GetParentForm( this );
if( parentForm ){
parentForm->ModalResult = FModalResult;
parentForm->Close();
}
TGraphicControl::Click();
}
//---------------------------------------------------------------------------
//namespace Pngbutton
//{
// void __fastcall PACKAGE Register()
// {
// TComponentClass classes[1] = {__classid(TPNGButton)};
// RegisterComponents(L"Samples", classes, 0);
// }
//}
////---------------------------------------------------------------------------
+108
View File
@@ -0,0 +1,108 @@
//---------------------------------------------------------------------------
/////////////////////////////////
////////安装 可以不用安装,直接用原来的 .pas文件安装
/////////////////////////////////
/////////////////////////////////
/////////使用
//--》供新的包使用
//把.cpp 中 #pragma package(smart_init) 去掉
//新包.cpp #include "PNGButton.cpp"
/////////////////////////////////
#ifndef PNGButtonH
#define PNGButtonH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Imaging.pnglang.hpp>
//---------------------------------------------------------------------------
//class PACKAGE TPNGButton : public TGraphicControl
class CBTPNButton : public TGraphicControl
{
public:
enum TModalResult{
mrNone = System::Int8(0x0),
mrOk = System::Int8(0x1),
mrCancel = System::Int8(0x2),
mrAbort = System::Int8(0x3),
mrRetry = System::Int8(0x4),
mrIgnore = System::Int8(0x5),
mrYes = System::Int8(0x6),
mrNo = System::Int8(0x7),
mrClose = System::Int8(0x8),
mrHelp = System::Int8(0x9),
mrTryAgain = System::Int8(0xa),
mrContinue = System::Int8(0xb),
mrAll = System::Int8(0xc),
mrNoToAll = System::Int8(0xd),
mrYesToAll = System::Int8(0xe)
};
private:
TNotifyEvent FOnMouseEnter;//on mouse enter notify event
TNotifyEvent FOnMouseLeave;//on mouse leave notify event
// System::Uitypes::TModalResult FModalResult;
TModalResult FModalResult;
MESSAGE void __fastcall CMMouseEnter(Winapi::Messages::TMessage &Msg); // to know when mouse is entered
MESSAGE void __fastcall CMMouseLeave(Winapi::Messages::TMessage &Msg); // to know when mouse is leaved
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TGraphicControl)
protected:
int EtatBtn; // 0=Normal 1=Mouse entered 2=Pressed 3=Disabled
int FStateCount;
Vcl::Imaging::Pngimage::TPngImage *FPngImg; //our 4 states image
bool FDown; // value to know if we painting mouse down
TColor FBkColor;
DYNAMIC void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall SetEnabled(bool Value);
public:
__fastcall virtual CBTPNButton(System::Classes::TComponent* AOwner);
__fastcall virtual ~CBTPNButton(void);
void __fastcall SetStateCount( int count );
void __fastcall SetPngImg(Vcl::Imaging::Pngimage::TPngImage *value); // we set the png image
void __fastcall SetDown(bool value); // to know if mouse is down or not
void __fastcall SetColor( TColor value );
virtual void __fastcall Paint(void); // override the painting of the component
DYNAMIC void __fastcall Click(void);
__published:
__property Action;
__property Anchors = {default=3};
__property bool Down = {read=FDown, write=SetDown, default=False};
__property Enabled = {default=1};
__property int ImgStates = {read=FStateCount, write=SetStateCount, default=4};
// __property System::Uitypes::TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property ParentShowHint = {default=1};
__property Vcl::Imaging::Pngimage::TPngImage *PngImg = {read=FPngImg, write=SetPngImg};
__property PopupMenu;
__property ShowHint;
__property Visible = {default=1};
__property OnClick;
__property OnContextPopup;
__property OnMouseDown;
__property OnMouseMove;
__property OnMouseUp;
__property System::Classes::TNotifyEvent OnMouseEnter = {read=FOnMouseEnter, write=FOnMouseEnter};
__property System::Classes::TNotifyEvent OnMouseLeave = {read=FOnMouseLeave, write=FOnMouseLeave};
};
//---------------------------------------------------------------------------
#endif
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
+784
View File
@@ -0,0 +1,784 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "LineEdit.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TLineEdit *)
{
new TLineEdit(NULL);
}
//---------------------------------------------------------------------------
__fastcall TLineEdit::TLineEdit(TComponent* Owner)
: TWinControl(Owner)
{
m_Canvas = new TControlCanvas();
m_Canvas->Control = this;
m_HintLabel = new TLabel(this);
m_HintLabel->Font->Color = TColor(0x594D43);
m_HintLabel->OnMouseDown = DoHintLabelMouseDown;
Height = 24;
Width = 124;
FBorderColor = TColor(0x5F5954);
FShadowColor = TColor(0x4C463F);
Color = TColor(0xC4B4A8);
FHintColor = TColor(0x594D43);
FMaxLength = 500;
FOnChange = NULL;
TabStop = true;
FNumberMax = -1;
FNumberMin = -1;
m_IsCreated = false;
}
//---------------------------------------------------------------------------
namespace Lineedit
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TLineEdit)};
RegisterComponents(L"Samples", classes, 0);
}
}
//---------------------------------------------------------------------------
__fastcall TLineEdit::~TLineEdit()
{
if(m_Canvas)
{
delete m_Canvas;
m_Canvas = NULL;
}
if(m_HintLabel)
{
delete m_HintLabel;
m_HintLabel = NULL;
}
}
//---------------------------------------------------------------------------
void __fastcall TLineEdit::SetTextFont(String name, int size)
{
Font->Name = name;
Font->Size = size;
m_HintLabel->Font->Name = Font->Name;
m_HintLabel->Font->Size = Font->Size;
}
//---------------------------------------------------------------------------
void __fastcall TLineEdit::AdjustThisSize()
{
// 设置创建圆角窗口
HRGN var_Hrgn;
var_Hrgn = CreateRoundRectRgn(0, 0, Width + 1, Height + 1, 3, 3);
SetWindowRgn(Handle, var_Hrgn, true);
DeleteObject(var_Hrgn);
// 获取字体高度
m_FontHeight = CalcFontHeight();
int var_EditTop = (Height - m_FontHeight) / 2;
// 计算编辑区位置
m_TextRect = GetClientRect();
m_TextRect.Left += 4;
m_TextRect.Right -= 4;
m_TextRect.Top = var_EditTop;
// 设置HintText位置
m_HintLabel->Top = m_TextRect.Top;
m_HintLabel->Left = m_TextRect.Left;
m_HintLabel->Width = m_TextRect.Width();
// 设置编辑区左右边距
SendMessage(Handle, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, 0);
// 设置编辑区域(多行编辑有效)
SendMessage(Handle, EM_SETRECT, 0, (LPARAM)(&m_TextRect));
}
int __fastcall TLineEdit::CalcColorValue(TColor Bg, TColor Fr, int Level, int Alpha)
{
return ((Bg * (Level - Alpha) + Fr * Alpha) / Level);
}
int __fastcall TLineEdit::CalcFontHeight()
{
// 计算字体高度
TTextMetric var_Metric;
HDC var_DC = GetDC(0);
SelectObject(var_DC, Font->Handle);
GetTextMetricsW(var_DC, &var_Metric);
ReleaseDC(0, var_DC);
return var_Metric.tmHeight;
}
void __fastcall TLineEdit::CreateShadowColor()
{
int var_R, var_G, var_B, var_Alpha;
int Level = (int)(atan(3.14 / 2) * 500);
// 计算阴影颜色
for(int var_Index = 0; var_Index < 4; var_Index++)
{
var_Alpha = (int)(atan(3.14 / (2 * 3) * var_Index) * 500);
var_R = CalcColorValue(GetRValue(FShadowColor), GetRValue(Color), Level, var_Alpha);
var_G = CalcColorValue(GetGValue(FShadowColor), GetGValue(Color), Level, var_Alpha);
var_B = CalcColorValue(GetBValue(FShadowColor), GetBValue(Color), Level, var_Alpha);
m_ShadowColorArray[var_Index] = RGB(var_R, var_G, var_B);
}
m_ShadowColorArray[4] = Color;
}
void __fastcall TLineEdit::CreateParams(TCreateParams &Params)
{
TWinControl::CreateParams(Params);
CreateSubClass(Params, L"EDIT");
DWORD var_Alignments[] = {ES_LEFT, ES_RIGHT, ES_CENTER};
DWORD var_CharCase[] = {0, ES_UPPERCASE, ES_LOWERCASE};
DWORD var_HideSelection[] = {ES_NOHIDESEL, 0};
DWORD var_NumbersOnly[] = {0, ES_NUMBER};
DWORD var_OEMConvert[] = {0, ES_OEMCONVERT};
DWORD var_PasswordChar[] = {0, ES_PASSWORD};
DWORD var_ReadOnly[] = {0, ES_READONLY};
Params.Style |= var_Alignments[FAlignment];
Params.Style |= var_CharCase[FCharCase];
Params.Style |= var_HideSelection[FHideSelection];
Params.Style |= var_NumbersOnly[FNumbersOnly];
Params.Style |= var_OEMConvert[FOEMConvert];
Params.Style |= var_PasswordChar[FPasswordChar != 0];
Params.Style |= var_ReadOnly[FReadOnly];
Params.Style |= ES_AUTOHSCROLL;
Params.Style |= ES_MULTILINE;
//Params.Style |= WS_TABSTOP;
//Params.ExStyle |= WS_EX_CONTROLPARENT;
}
void __fastcall TLineEdit::CreateWindowHandle(const TCreateParams &Params)
{
TWinControl::CreateWindowHandle(Params);
}
void __fastcall TLineEdit::CreateWnd()
{
TWinControl::CreateWnd();
m_HintLabel->Parent = this;
if(FPasswordChar != 0)
{
if(FPasswordChar == '*')
{
SendMessageW(Handle, EM_SETPASSWORDCHAR, L'', 0);
}
else
{
SendMessageW(Handle, EM_SETPASSWORDCHAR, FPasswordChar, 0);
}
}
if(FReadOnly)
{
SendMessage(WindowHandle, EM_SETREADONLY, 1, 0);
}
if(!m_IsCreated)
{
SetText(FText);
m_IsCreated = true;
}
SetMaxLength(FMaxLength);
AdjustThisSize();
}
void __fastcall TLineEdit::CMColorChanged(TMessage &Message)
{
CreateShadowColor();
Invalidate();
}
void __fastcall TLineEdit::CMFontChanged(TWMFontChange &Message)
{
TColor var_FontColor = Font->Color;
if(var_FontColor != m_FontColor) {
m_FontColor = var_FontColor; // 保存字体颜色
Invalidate();
}
else {
m_HintLabel->Font->Name = Font->Name;
m_HintLabel->Font->Size = Font->Size;
RecreateWnd();
}
}
void __fastcall TLineEdit::SetBorderColor(TColor Color)
{
if(FBorderColor != Color)
{
FBorderColor = Color;
SendMessage(Handle, CM_COLORCHANGED, 0, 0);
}
}
void __fastcall TLineEdit::SetCursorPos(int Pos)
{
//SendMessage(Handle, EM_SETSEL, Pos, Pos);
SendMessage(Handle, EM_SCROLL, SB_PAGEUP, 0);
}
void __fastcall TLineEdit::SetFocus()
{
m_HintLabel->Visible = false;
TWinControl::SetFocus();
}
void __fastcall TLineEdit::SetOnChange(TNotifyEvent OnChange)
{
FOnChange = OnChange;
}
void __fastcall TLineEdit::SetShadowColor(TColor Color)
{
if(FShadowColor != Color)
{
FShadowColor = Color;
SendMessage(Handle, CM_COLORCHANGED, 0, 0);
}
}
void __fastcall TLineEdit::ShowHintText()
{
if(Text.IsEmpty() && !Focused())
m_HintLabel->Visible = true;
else
m_HintLabel->Visible = false;
//if(Text.Length() == 0) m_HintLabel->Visible = true;
//else m_HintLabel->Visible = false;
}
void __fastcall TLineEdit::WMChar(TWMChar &Message)
{
if(Message.CharCode < 32)
{
switch(Message.CharCode)
{
case 1: // Ctrl + A
case 3: // 双击鼠标左键
SelectAll();
break;
default:
TWinControl::Dispatch(&Message);
}
}
else if(Message.CharCode == 32)
{
if(!FNumbersOnly)
TWinControl::Dispatch(&Message);
}
else
{
// 限制长度
String text = GetText();
int selStart = GetSelStart();
int selLen = GetSelLength();
text.Delete(selStart + 1, selLen);
if(text.Length() < FMaxLength)
{
if(FNumbersOnly)
{
if(Message.CharCode >= 0x30 && Message.CharCode <= 0x39)
{
if(FNumberMax != -1) {
wchar_t c = Message.CharCode;
if(!text.IsEmpty()) {
if(selStart == 0 && Message.CharCode == '0')
return;
if(StrToInt(text) == 0 && Message.CharCode == '0')
return;
}
text.Insert(String(c), selStart);
int num = StrToInt(text);
if(num <= FNumberMax) {
TWinControl::Dispatch(&Message);
}
}
else
TWinControl::Dispatch(&Message);
}
}
else
{
TWinControl::Dispatch(&Message);
}
}
else
{
//MessageBeep(MB_OK);
}
}
}
void __fastcall TLineEdit::WMCommand(TWMCommand &Message)
{
if(Message.NotifyCode == EN_CHANGE)
{
//ShowHintText();
Invalidate();
if(FOnChange) FOnChange(this);
}
}
void __fastcall TLineEdit::WMCtlColorEdit(TWMCtlColorEdit &Message)
{
if(GetTextColor(Message.ChildDC) != ColorToRGB(Font->Color))
SetTextColor(Message.ChildDC, ColorToRGB(Font->Color)); // 设置编辑文字颜色
//if(GetBkColor(Message.ChildDC) != ColorToRGB(Color))
//{
// SetBkColor(Message.ChildDC, ColorToRGB(Color)); // 设置编辑背景颜色
//}
if(GetBkMode(Message.ChildDC) != TRANSPARENT)
SetBkMode(Message.ChildDC, TRANSPARENT);
//ExcludeUpdateRgn(Message.ChildDC, Message.ChildWnd); */
}
void __fastcall TLineEdit::WMCtlColorStatic(TWMCtlColorStatic &Message)
{
SetTextColor(Message.ChildDC, ColorToRGB(Font->Color)); // 设置编辑文字颜色
if(GetBkMode(Message.ChildDC) != TRANSPARENT)
SetBkMode(Message.ChildDC, TRANSPARENT);
//SetBkColor(Message.ChildDC, ColorToRGB(Color)); // 设置编辑背景颜色
}
void __fastcall TLineEdit::WMEraseBkgnd(TWMEraseBkgnd &Message)
{
m_Canvas->Lock();
m_Canvas->Handle = Message.DC;
TRect var_Rect = GetClientRect();
// 绘制背景
m_Canvas->Brush->Color = Color;
m_Canvas->FillRect(var_Rect);
// 绘制边框
m_Canvas->Brush->Color = FBorderColor;
m_Canvas->FrameRect(var_Rect);
var_Rect.Top++;
var_Rect.Left++;
var_Rect.Right--;
var_Rect.Bottom--;
// 绘制阴影
m_Canvas->Brush->Color = TColor(m_ShadowColorArray[0]);
//m_Canvas->Brush->Color = FShadowColor;
m_Canvas->FrameRect(var_Rect);
for(int var_Layer = 1; var_Layer < 4; var_Layer++)
{
// 设置画笔颜色
m_Canvas->Pen->Color = TColor(m_ShadowColorArray[var_Layer]);
m_Canvas->MoveTo(var_Rect.Left + var_Layer, var_Rect.Bottom - 2);
m_Canvas->LineTo(var_Rect.Left + var_Layer, var_Rect.Top + var_Layer);
m_Canvas->MoveTo(var_Rect.Left + var_Layer, var_Rect.Top + var_Layer);
m_Canvas->LineTo(var_Rect.Right - 1, var_Rect.Top + var_Layer);
}
m_Canvas->UpdateTextFlags();
m_Canvas->Unlock();
}
void __fastcall TLineEdit::WMKeyDown(TWMKeyDown &Message)
{
if(Message.CharCode == VK_RETURN && !FReadOnly && Enabled)
{
MessageBeep(MB_OK);
}
TWinControl::Dispatch(&Message);
}
void __fastcall TLineEdit::WMKillFocus(TWMKillFocus &Message)
{
ShowHintText();
TWinControl::Dispatch(&Message);
if(Text.Length() < FMaxLength && !Text.IsEmpty())
{
if(FNumbersOnly && FNumberMin != -1)
{
int Value = StrToInt(Text);
if(Value < FNumberMin) {
Text = IntToStr(FNumberMin);
}
}
}
Invalidate();
}
void __fastcall TLineEdit::WMPaint(TWMPaint &Message)
{
PaintHandler(Message);
}
void __fastcall TLineEdit::WMSetFocus(TWMSetFocus &Message)
{
//ShowHintText();
m_HintLabel->Visible = false;
TWinControl::Dispatch(&Message);
}
void __fastcall TLineEdit::WMSize(TWMSize &Message)
{
// 获取当前字体高度
m_FontHeight = CalcFontHeight();
// 计算编辑框的最小高度
int var_MinHeight = m_FontHeight + 4;
int var_MinWidth = 20;
// 检查宽高的合法性
if(Height < var_MinHeight)
{
Height = var_MinHeight;
return;
}
if(Width < var_MinWidth)
{
Width = var_MinWidth;
return;
}
AdjustThisSize();
}
/******************************************************************************/
// 编辑框操作
/******************************************************************************/
void __fastcall TLineEdit::DoHintLabelMouseDown(TObject *Sender,
TMouseButton Button,
TShiftState Shift, int X, int Y)
{
SetFocus();
}
void __fastcall TLineEdit::Clear()
{
FText = "";
SetText(FText);
}
void __fastcall TLineEdit::ClearSelection()
{
SendMessage(Handle, WM_CLEAR, 0, 0);
}
void __fastcall TLineEdit::CopyToClipboard()
{
SendMessage(Handle, WM_COPY, 0, 0);
}
void __fastcall TLineEdit::CutToClipboard()
{
SendMessage(Handle, WM_CUT, 0, 0);
}
void __fastcall TLineEdit::PasteFromClipboard()
{
SendMessage(Handle, WM_PASTE, 0, 0);
}
void __fastcall TLineEdit::Undo()
{
SendMessage(Handle, WM_UNDO, 0, 0);
}
void __fastcall TLineEdit::ClearUndo()
{
SendMessage(Handle, EM_EMPTYUNDOBUFFER, 0, 0);
}
void __fastcall TLineEdit::SelectAll()
{
SendMessage(Handle, EM_SETSEL, 0, -1);
}
String __fastcall TLineEdit::GetText()
{
if(HandleAllocated())
{
SendMessageW(Handle, WM_GETTEXT, 1024, (LPARAM)m_TextBuf);
}
else
{
wcscpy( m_TextBuf, FText.c_str() );
}
return String(m_TextBuf);
}
bool __fastcall TLineEdit::GetCanUndo()
{
if(HandleAllocated())
{
return (SendMessage(Handle, EM_CANUNDO, 0, 0) != 0);
}
else
{
return false;
}
}
int __fastcall TLineEdit::GetSelLength()
{
TSelection Selection;
SendMessage(Handle, EM_GETSEL, (WPARAM)&Selection.StartPos, (LPARAM)&Selection.EndPos);
return Selection.EndPos - Selection.StartPos;
}
int __fastcall TLineEdit::GetSelStart()
{
int var_Result;
SendMessage(Handle, EM_GETSEL, (WPARAM)&var_Result, 0);
return var_Result;
}
String __fastcall TLineEdit::GetSelText()
{
int var_Start, var_Length;
var_Start = GetSelStart();
var_Length = GetSelLength();
return Text.SubString(var_Start + 1, var_Length);
}
void __fastcall TLineEdit::SetMaxLength(int Value)
{
if(Value > 500 || Value <= 0)
{
Value = 500;
}
if(FMaxLength != Value)
{
FMaxLength = Value;
}
}
void __fastcall TLineEdit::SetSelLength(int Value)
{
TSelection Selection;
SendMessage(Handle, EM_GETSEL, (WPARAM)&Selection.StartPos, (LPARAM)&Selection.EndPos);
Selection.EndPos = Selection.StartPos + Value;
SendMessage(Handle, EM_SETSEL, Selection.StartPos, Selection.EndPos);
SendMessage(Handle, EM_SCROLLCARET, 0, 0);
}
void __fastcall TLineEdit::SetSelStart(int Value)
{
SendMessage(Handle, EM_SETSEL, Value, Value);
}
void __fastcall TLineEdit::SetAlignment(TAlignment Value)
{
if(FAlignment != Value)
{
FAlignment = Value;
m_HintLabel->Alignment = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetCharCase(TEditCharCase Value)
{
if(FCharCase != Value)
{
FCharCase = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetHideSelection(bool Value)
{
if(FHideSelection != Value)
{
FHideSelection = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetHintText(String Value)
{
if(FHintText != Value)
{
FHintText = Value;
m_HintLabel->Caption = Value;
}
}
void __fastcall TLineEdit::SetHintColor(TColor Value)
{
if(FHintColor != Value)
{
FHintColor = Value;
m_HintLabel->Font->Color = Value;
}
}
void __fastcall TLineEdit::SetNumbersOnly(bool Value)
{
if(FNumbersOnly != Value)
{
FNumbersOnly = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetOEMConvert(bool Value)
{
if(FOEMConvert != Value)
{
FOEMConvert = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetPasswordChar(WideChar Value)
{
if(FPasswordChar != Value)
{
FPasswordChar = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetReadOnly(bool Value)
{
if(FReadOnly != Value)
{
FReadOnly = Value;
if(HandleAllocated())
{
RecreateWnd();
}
}
}
void __fastcall TLineEdit::SetText(String Value)
{
FText = Value;
if(HandleAllocated())
{
//SetWindowText(Handle, Value.c_str());
//SetWindowText(Handle, FText.c_str());
if(Value.IsEmpty())
{
m_HintLabel->SetDesignVisible(true);
m_HintLabel->Visible = true;
}
else
{
m_HintLabel->SetDesignVisible(false);
m_HintLabel->Visible = false;
}
SendMessageW(Handle, WM_SETTEXT, 0, (LPARAM)Value.c_str());
if(FOnChange) FOnChange(this);
}
}
void __fastcall TLineEdit::SetNumberMax(int Value)
{
if(FNumberMax != Value) {
FNumberMax = Value;
}
}
void __fastcall TLineEdit::SetNumberMin(int Value)
{
if(FNumberMin != Value) {
if(Value > FNumberMax) {
Value = FNumberMax;
}
FNumberMin = Value;
}
}
/******************************************************************************/
+186
View File
@@ -0,0 +1,186 @@
//---------------------------------------------------------------------------
#ifndef LineEditH
#define LineEditH
//---------------------------------------------------------------------------
#include <vcl.h>
//---------------------------------------------------------------------------
class PACKAGE TLineEdit : public TWinControl
{
private:
TEditCharCase FCharCase;
TColor FBorderColor, // 边框颜色
FShadowColor; // 阴影颜色
TAlignment FAlignment;
WideChar FPasswordChar;
String FText;
String FHintText;
TColor FHintColor;
bool FHideSelection,
FNumbersOnly,
FOEMConvert,
FReadOnly;
int FMaxLength,
FNumberMax,
FNumberMin;
TNotifyEvent FOnChange;
TControlCanvas *m_Canvas;
int m_ShadowColorArray[4]; // 阴影颜色数组
int m_FontHeight; // 备份字体高度
bool m_IsCreated;
TLabel *m_HintLabel;
TColor m_FontColor; // 备份字体颜色
TRect m_TextRect;
WCHAR m_TextBuf[512];
void __fastcall AdjustThisSize();
int __fastcall CalcColorValue(TColor BgColor, TColor FrColor, int Level, int Alpha);
int __fastcall CalcFontHeight();
void __fastcall CreateShadowColor(); // 创建阴影颜色
void __fastcall SetBorderColor(TColor Color);
void __fastcall SetOnChange(TNotifyEvent OnChange);
void __fastcall SetShadowColor(TColor Color);
void __fastcall ShowHintText();
/******************************************************************************/
// 编辑框操作
/******************************************************************************/
void __fastcall DoHintLabelMouseDown(TObject *Sender,
TMouseButton Button,
TShiftState Shift, int X, int Y);
UnicodeString __fastcall GetText();
bool __fastcall GetCanUndo();
int __fastcall GetSelLength();
int __fastcall GetSelStart();
String __fastcall GetSelText();
void __fastcall SetAlignment(TAlignment Value);
void __fastcall SetCharCase(TEditCharCase Value);
void __fastcall SetHideSelection(bool Value);
void __fastcall SetHintText(String Value);
void __fastcall SetHintColor(TColor Value);
void __fastcall SetNumbersOnly(bool Value);
void __fastcall SetOEMConvert(bool Value);
void __fastcall SetPasswordChar(WideChar Value);
void __fastcall SetReadOnly(bool Value);
void __fastcall SetText(UnicodeString Value);
void __fastcall SetMaxLength(int Value);
void __fastcall SetSelLength(int Value);
void __fastcall SetSelStart(int Value);
void __fastcall SetNumberMax(int Value);
void __fastcall SetNumberMin(int Value);
/******************************************************************************/
MESSAGE void __fastcall CMColorChanged(TMessage &Message);
MESSAGE void __fastcall CMFontChanged(TWMFontChange &Message);
MESSAGE void __fastcall WMChar(TWMChar &Message);
MESSAGE void __fastcall WMCommand(TWMCommand &Message);
MESSAGE void __fastcall WMCtlColorEdit(TWMCtlColorEdit &Message);
MESSAGE void __fastcall WMCtlColorStatic(TWMCtlColorStatic &Message);
MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message);
MESSAGE void __fastcall WMKeyDown(TWMKeyDown &Message);
MESSAGE void __fastcall WMKillFocus(TWMKillFocus &Message);
MESSAGE void __fastcall WMPaint(TWMPaint &Message);
MESSAGE void __fastcall WMSetFocus(TWMSetFocus &Message);
MESSAGE void __fastcall WMSize(TWMSize &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_COLORCHANGED, TMessage, CMColorChanged)
MESSAGE_HANDLER(CM_FONTCHANGED, TWMFontChange, CMFontChanged)
MESSAGE_HANDLER(CN_COMMAND, TWMCommand, WMCommand)
MESSAGE_HANDLER(CN_CTLCOLOREDIT, TWMCtlColorEdit, WMCtlColorEdit)
MESSAGE_HANDLER(CN_CTLCOLORSTATIC, TWMCtlColorStatic, WMCtlColorStatic)
MESSAGE_HANDLER(WM_CHAR, TWMChar, WMChar)
MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
MESSAGE_HANDLER(WM_KEYDOWN, TWMKeyDown, WMKeyDown)
MESSAGE_HANDLER(WM_KILLFOCUS, TWMKillFocus, WMKillFocus)
MESSAGE_HANDLER(WM_PAINT, TWMPaint, WMPaint)
MESSAGE_HANDLER(WM_SETFOCUS, TWMSetFocus, WMSetFocus)
MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
END_MESSAGE_MAP(TWinControl)
__property Hint;
protected:
virtual void __fastcall CreateParams(TCreateParams &Params);
virtual void __fastcall CreateWindowHandle(const TCreateParams &Params);
virtual void __fastcall CreateWnd();
public:
__fastcall TLineEdit(TComponent* Owner);
__fastcall ~TLineEdit();
void __fastcall SetFocus();
void __fastcall SetCursorPos(int Pos);
void __fastcall SetTextFont(String name, int size);
/******************************************************************************/
// 编辑框操作
/******************************************************************************/
void __fastcall Clear();
void __fastcall ClearSelection();
void __fastcall CopyToClipboard();
void __fastcall CutToClipboard();
void __fastcall PasteFromClipboard();
void __fastcall Undo();
void __fastcall ClearUndo();
void __fastcall SelectAll();
__property bool CanUndo = {read = GetCanUndo, nodefault};
__property int SelLength = {read = GetSelLength, write = SetSelLength, nodefault};
__property int SelStart = {read = GetSelStart, write = SetSelStart, nodefault};
__property String SelText = {read = GetSelText};
__property AlignWithMargins = {default = false};
__property HelpContext;
__property HelpKeyword;
__property HelpType;
__property Margins;
__property Cursor;
/******************************************************************************/
__published:
__property TColor BorderColor = {read = FBorderColor, write = SetBorderColor, default = TColor(0x5F5954)};
__property TColor ShadowColor = {read = FShadowColor, write = SetShadowColor, default = TColor(0x4C463F)};
__property TNotifyEvent OnChange = {read = FOnChange, write = SetOnChange};
__property TAlignment Alignment = {read = FAlignment, write = SetAlignment};
__property TEditCharCase CharCase = {read = FCharCase, write = SetCharCase};
__property bool HideSelection = {read = FHideSelection, write = SetHideSelection};
__property String HintText = {read = FHintText, write = SetHintText};
__property TColor HintColor = {read = FHintColor, write = SetHintColor, default = TColor(0x594D43)};
__property int MaxLength = {read = FMaxLength, write = SetMaxLength, default = 500};
__property bool NumbersOnly = {read = FNumbersOnly, write = SetNumbersOnly};
__property bool OEMConvert = {read = FOEMConvert, write = SetOEMConvert};
__property WideChar PasswordChar = {read = FPasswordChar, write = SetPasswordChar};
__property bool ReadOnly = {read = FReadOnly, write = SetReadOnly};
__property int NumberMax = {read = FNumberMax, write = SetNumberMax};
__property int NumberMin = {read = FNumberMin, write = SetNumberMin};
__property UnicodeString Text = {read = GetText, write = SetText};
__property Color = {default = TColor(0xC4B4A8)};
__property Font;
__property TabOrder = {default = -1};
__property TabStop = {default = true};
__property OnKeyDown;
__property OnKeyPress;
__property OnKeyUp;
};
//---------------------------------------------------------------------------
#endif
+17
View File
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
+156
View File
@@ -0,0 +1,156 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "RadioBtn.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
static inline void ValidCtrCheck(TRadioBtn *)
{
new TRadioBtn(NULL);
}
//---------------------------------------------------------------------------
namespace Radiobtn
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TRadioBtn)};
RegisterComponents(L"Samples", classes, 0);
}
}
//---------------------------------------------------------------------------
__fastcall TRadioBtn::TRadioBtn(System::Classes::TComponent* AOwner) : TPanel(AOwner)
{
m_pRaBtn = new TRadioButton(this);
m_pRaBtn->Parent = this;
m_pRaBtn->ControlStyle>>csOpaque;
m_pRaBtn->Caption= L"";
m_pRaBtn->OnClick = Onclicked;
m_lbCaption = new TLabel(this);
m_lbCaption->Parent = this;
m_lbCaption->ControlStyle>>csOpaque;
m_lbCaption->OnClick = Onclicked;
m_lbCaption->OnMouseMove = MouseMoveEvent;
this->OnMouseMove = MouseMoveEvent;
FChecked = false;
FEnabled = true;
SetChildBounds();
SetCaption(L"TRadioBtn");
SetFont(Font);
ControlStyle >> csOpaque;
Width = 100;
Height = 17;
}
//---------------------------------------------------------------------------
__fastcall TRadioBtn::~TRadioBtn(void)
{
if(m_lbCaption) delete m_lbCaption;
if(m_pRaBtn) delete m_pRaBtn;
}
//---------------------------------------------------------------------------
void __fastcall TRadioBtn::SetChildBounds()
{
int nEdge = GetSystemMetrics(SM_CXMENUCHECK);
int mHgt = m_lbCaption->Height;
if( mHgt>Height ) Height = mHgt;
m_lbCaption->SetBounds(nEdge+1, (Height-m_lbCaption->Height)/2,
m_lbCaption->Width, m_lbCaption->Height);
m_pRaBtn->SetBounds(0, 0, nEdge, Height);
}
//---------------------------------------------------------------------------
void __fastcall TRadioBtn::CreateWnd(void)
{
Vcl::Extctrls::TPanel::CreateWnd();
SetWindowLong( Parent->Handle, GWL_STYLE,
GetWindowLong(Parent->Handle, GWL_STYLE) & ~WS_CLIPCHILDREN );
}
//---------------------------------------------------------------------------
void __fastcall TRadioBtn::CreateParams(Controls::TCreateParams &Params)
{
Vcl::Extctrls::TPanel::CreateParams(Params);
Params.ExStyle |= WS_EX_TRANSPARENT;
}
//---------------------------------------------------------------------------
void __fastcall TRadioBtn::Paint()
{
SetBkMode( Canvas->Handle, TRANSPARENT );
StyleServices()->DrawParentBackground( Handle, Canvas->Handle, NULL, true);
}
//---------------------------------------------------------------------------
void __fastcall TRadioBtn::WMSize(Winapi::Messages::TWMSize &Message)
{
SetChildBounds();
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::SetCaption(String FCaptionTmp)
{
m_lbCaption->Caption = FCaptionTmp;
FCaption = FCaptionTmp;
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::SetFont(TFont *FFontTmp)
{
m_lbCaption->Font = FFontTmp;
SetChildBounds();
this->Invalidate();
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::SetChecked(bool bChecked)
{
m_pRaBtn->Checked = bChecked;
FChecked = bChecked;
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::SetEnabled(bool bEnabled)
{
FEnabled = bEnabled;
m_lbCaption->Enabled = bEnabled;
m_pRaBtn->Enabled = bEnabled;
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::SetCheckedSameparent(TWinControl* pCtrl)
{
if( pCtrl->ClassNameIs( TRadioBtn::ClassName() ) ){
TRadioBtn *pTRadioBtn = (TRadioBtn *)pCtrl;
if( pTRadioBtn->Checked && pTRadioBtn!=this )
pTRadioBtn->Checked = false;
}
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::Onclicked(TObject *Sender)
{
if(!FChecked) {
SetChecked(true);
for( int i=0; i<this->Parent->ControlCount; i++ ){
SetCheckedSameparent( (TWinControl*)(this->Parent->Controls[i]) );
}
if( OnClick ) OnClick(this);
}
}
//--------------------------------------------------------------------------
void __fastcall TRadioBtn::Click(void)
{
if( !FEnabled ) return;
Onclicked(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TRadioBtn::MouseMoveEvent(System::TObject* Sender, System::Classes::TShiftState Shift, int X, int Y)
{
if( !FEnabled ) return;
}
//---------------------------------------------------------------------------
+55
View File
@@ -0,0 +1,55 @@
//---------------------------------------------------------------------------
#ifndef RadioBtnH
#define RadioBtnH
//---------------------------------------------------------------------------
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class PACKAGE TRadioBtn :public TPanel {
private:
bool FChecked;
bool FEnabled;
String FCaption;
void __fastcall SetCaption(String FCaptionTmp);
void __fastcall SetFont(TFont *FFontTmp);
void __fastcall SetChecked(bool bChecked);
void __fastcall SetEnabled(bool bEnabled);
TLabel *m_lbCaption;
TRadioButton *m_pRaBtn;
void __fastcall Onclicked(TObject *Sender);
void __fastcall SetCheckedSameparent(TWinControl* pCtrl);
void __fastcall SetChildBounds();
COLORREF __fastcall TransformColor(COLORREF icolor, int nNum, bool bplus=true);
void __fastcall MouseMoveEvent(System::TObject* Sender, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall CreateWnd();
virtual void __fastcall CreateParams(Controls::TCreateParams &Params);
virtual void __fastcall Paint(void);
DYNAMIC void __fastcall Click(void);
MESSAGE void __fastcall WMSize(Winapi::Messages::TWMSize &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
END_MESSAGE_MAP( TPanel )
public:
__fastcall TRadioBtn(System::Classes::TComponent* AOwner);
__fastcall ~TRadioBtn(void);
__published:
__property Font = {write=SetFont};
__property String Caption = {read=FCaption, write=SetCaption};
__property bool Checked = {read=FChecked, write=SetChecked, default=false};
__property bool Enabled = {read=FEnabled, write=SetEnabled, default=true};
};
#endif
+17
View File
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
+467
View File
@@ -0,0 +1,467 @@
//---------------------------------------------------------------------------
#pragma hdrstop
#include "SkinTrackBar.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#define trHorizontal 1 //横向滑块
#define trVertical 0 //纵向滑块
#define SLIDER_MAX_H 25 //滑块长度
#define SLIDER_MIN_H 10
#define SLIDER_W 10 //滑块宽度
#define PANEL_MIN_W 30 //Panel最小宽度
#define CHANNEL_LEFT 5
#define CHANNEL_W 2 //滑槽宽度
static const COLORREF
CLR_BACK_ENABLE = RGB(22,33,44), //d5dde8
CLR_BACK_DISABLE = RGB(112,130,154), //d5dde8
CLR_SLIDER_DOWN = RGB(77,88,99), //d5dde8
CLR_SLIDER_HOVER = RGB(55,66,77), //d5dde8
CLR_SLIDER_NORMAL = RGB(44,55,77); //d5dde8
static inline void ValidCtrCheck(TSkinTrackBar *)
{
new TSkinTrackBar(NULL);
}
namespace Skintrackbar
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TSkinTrackBar)};
RegisterComponents(L"Samples", classes, 0);
}
}
__fastcall TSkinTrackBar::TSkinTrackBar(System::Classes::TComponent* AOwner)
: TPanel(AOwner)
{
bDown = false;
bMouse = false;
FEnabled = true;
FOrientation = 1; //默认横向滑块
FMax = 100;
FMin = 0;
FPosition = 0;
FPageSize = 1;
Hint = IntToStr(FPosition);
ParentBackground = true;
Slider = new TPaintBox(this);
Slider->Parent = this;
Slider->ParentShowHint = false;
Slider->ShowHint = false;
Slider->OnMouseEnter = CMMouseEnter;
Slider->OnMouseLeave = CMMouseLeave;
Slider->OnMouseDown = CMMouseDown;
Slider->OnPaint = SliderPaint;
ParentColor = true;
}
//-----------------------------------------------------------------------------
__fastcall TSkinTrackBar::~TSkinTrackBar()
{
delete Slider;
Slider = NULL;
}
void __fastcall TSkinTrackBar::SetMax(int Value)
{
if(Value <= FMin)
{
// if(ComponentState.Contains(csDesigning))
// {
// MessageBox(Handle, "Max:必须大于Min!!!", "错误", MB_OK | MB_ICONERROR);
// }
}
else
{
if(FMax != Value)
{
FMax = Value;
if(FPosition > FMax){
FPosition = FMax;
if(FOnChange)
FOnChange(this);
}
if( FOrientation ){
Slider->Left = CHANNEL_LEFT+(double)(FPosition-FMin)*(Width-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin);
}
else{
Slider->Top = Height-CHANNEL_LEFT-(double)(FPosition-FMin)*(Height-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin)-SLIDER_W;
}
}
}
}
void __fastcall TSkinTrackBar::SetMin(int Value)
{
if(Value >= FMax)
{
// if(ComponentState.Contains(csDesigning))
// {
// MessageBox(Handle, "Min:必须小于Max!!!", "错误", MB_OK | MB_ICONERROR);
// }
}
else
{
if(FMin != Value)
{
FMin = Value;
if(FPosition < FMin){
FPosition = FMin;
if(FOnChange)
FOnChange(this);
}
if( FOrientation ){
Slider->Left = CHANNEL_LEFT+(double)(FPosition-FMin)*(Width-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin);
}
else{
Slider->Top = Height-CHANNEL_LEFT-(double)(FPosition-FMin)*(Height-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin)-SLIDER_W;
}
}
}
}
void __fastcall TSkinTrackBar::SetPosition(int iPosition)
{
if(iPosition>FMax)
iPosition = FMax;
if(iPosition<FMin)
iPosition = FMin;
if(FPosition!=iPosition){
FPosition = iPosition;
Hint = IntToStr(FPosition);
if( FOrientation ){
Slider->Left = CHANNEL_LEFT+(double)(FPosition-FMin)*(Width-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin);
}
else{
Slider->Top = Height-CHANNEL_LEFT-(double)(FPosition-FMin)*(Height-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin)-SLIDER_W;
}
if(FOnChange)
FOnChange(this);
Invalidate();
// Slider->Invalidate();
}
}
void __fastcall TSkinTrackBar::SetOrientation(bool bOrientation)
{
if(FOrientation != bOrientation)
{
FOrientation = bOrientation;
TWMSize msg;
WMSize(msg);
Invalidate();
// Slider->Invalidate();
}
}
void __fastcall TSkinTrackBar::SetEnabled(bool bEnabled)
{
if( FEnabled!=bEnabled ){
FEnabled = bEnabled;
Invalidate();
}
}
void __fastcall TSkinTrackBar::CMMouseEnter(System::TObject* Sender)
{
if( FEnabled ){
bMouse = true;
Slider->Invalidate();
}
}
void __fastcall TSkinTrackBar::CMMouseLeave(System::TObject* Sender)
{
if( FEnabled ){
bMouse = false;
Slider->Invalidate();
}
}
void __fastcall TSkinTrackBar::CMMouseDown(System::TObject* Sender, System::Uitypes::TMouseButton Button,
System::Classes::TShiftState Shift, int X, int Y)
{
if( FEnabled && Button==mbLeft ){
bDown = true;
MouseCapture = true;
Slider->Invalidate();
SetFocus();
}
}
void __fastcall TSkinTrackBar::WMMouseMove(TWMMouse &Message)
{
if( FEnabled && bDown ){
if( FOrientation ){ // trHorizontal 1 //横向滑块
DrawH(Message);
}
else{
DrawV(Message);
}
}
TPanel::Dispatch(&Message);
}
void __fastcall TSkinTrackBar::WMLButtonDown(TWMLButtonDown &Message)
{
if( FEnabled ){
if( FOrientation && Message.YPos>Slider->Top
&& Message.YPos<Slider->Top+Slider->Height
&& Message.XPos>0 && Message.XPos<Width){
//横向
DrawH(Message);
bDown = true;
MouseCapture = true;
}
else if( !FOrientation && Message.XPos>Slider->Left
&& Message.XPos<Slider->Left + Slider->Width
&& Message.YPos>0 && Message.YPos<Height){
//纵向
DrawV(Message);
bDown = true;
MouseCapture = true;
}
SetFocus();
}
TPanel::Dispatch(&Message);
}
void __fastcall TSkinTrackBar::WMLButtonUp(TWMLButtonUp &Message)
{
if( FEnabled ){
bDown = false;
bMouse = false;
MouseCapture = false;
Slider->Invalidate();
}
TPanel::Dispatch(&Message);
}
void __fastcall TSkinTrackBar::WMMouseWheel(TWMMouseWheel &Message)
{
if( FEnabled ){
int iPos = FPosition;
if( Message.WheelDelta>0 ){
iPos += FPageSize;
if( iPos>FMax )
iPos = FMax;
}
else{
iPos -= FPageSize;
if( iPos<FMin )
iPos = FMin;
}
Position = iPos;
}
}
void __fastcall TSkinTrackBar::WMEraseBkgnd(TWMEraseBkgnd &Message)
{
TPanel::Dispatch(&Message);
TRect Channel;
if( Orientation )
Channel.init( CHANNEL_LEFT,
Height/2-CHANNEL_W,
Width-CHANNEL_LEFT,
Height/2+CHANNEL_W);
else
Channel.init(
Width/2-CHANNEL_W,
CHANNEL_LEFT,
Width/2+CHANNEL_W,
Height-CHANNEL_LEFT
);
TCanvas* tempCanvas = new TCanvas;
tempCanvas->Handle = Message.DC;
if( Enabled ){
tempCanvas->Brush->Color = CLR_BACK_ENABLE;
tempCanvas->FillRect(Channel);
}
else{
tempCanvas->Brush->Color = CLR_BACK_DISABLE;
tempCanvas->FillRect(Channel);
}
delete tempCanvas;
}
void __fastcall TSkinTrackBar::SliderPaint(System::TObject* Sender)
{
TRect rect = Slider->ClientRect;
if ( !FEnabled ) {
Slider->Canvas->Brush->Color = CLR_BACK_DISABLE;
Slider->Canvas->FillRect(rect);
// TRect rct(rect);
// Frame3D( Slider->Canvas, rect, clBlack,clGray,1 );
// rect = rct;
}
else if(bDown){//鼠标按下
Slider->Canvas->Brush->Color = CLR_SLIDER_DOWN;
Slider->Canvas->FillRect(rect);
// TRect rct(rect);
Frame3D( Slider->Canvas, rect, clBlack,clGray,1 );
// rect = rct;
}
else if(bMouse){//鼠标移动到滑块上
Slider->Canvas->Brush->Color = CLR_SLIDER_HOVER;
Slider->Canvas->FillRect(rect);
// TRect rct(rect);
Frame3D( Slider->Canvas, rect, clGray,clBlack, 1 );
// rect = rct;
}
else{ //平常
Slider->Canvas->Brush->Color = CLR_SLIDER_NORMAL;
Slider->Canvas->FillRect(rect);
// TRect rct(rect);
Frame3D( Slider->Canvas, rect, clGray,clBlack, 1 );
// rect = rct;
}
}
void __fastcall TSkinTrackBar::DrawH(TWMMouse &Message) // 横向
{
int oldPosition = FPosition;
if(Message.XPos<CHANNEL_LEFT+SLIDER_W/2){
if(Slider->Left==CHANNEL_LEFT)
return;
Slider->Left = CHANNEL_LEFT;
FPosition = FMin;
}
else if(Message.XPos>Width-CHANNEL_LEFT-SLIDER_W/2){
if(Slider->Left==Width-CHANNEL_LEFT - SLIDER_W)
return;
Slider->Left = Width-CHANNEL_LEFT - SLIDER_W;
FPosition = FMax;
}
else{
FPosition = FMin+(double)(Message.XPos - CHANNEL_LEFT - SLIDER_W/2)/(Width-2*CHANNEL_LEFT-SLIDER_W)*(FMax-FMin) +0.5;
Slider->Left = CHANNEL_LEFT+(double)(FPosition-FMin)*(Width-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin);
}
Hint = IntToStr(FPosition);
if( oldPosition!=FPosition && FOnChange )
FOnChange(this);
}
void __fastcall TSkinTrackBar::DrawV(TWMMouse &Message)
{
int oldPosition = FPosition;
if(Message.YPos<CHANNEL_LEFT+SLIDER_W/2){
if(Slider->Top==CHANNEL_LEFT)
return;
Slider->Top = CHANNEL_LEFT;
FPosition = FMax;
}
else if(Message.YPos>Height-CHANNEL_LEFT-SLIDER_W/2){
if(Slider->Top==Height-CHANNEL_LEFT - SLIDER_W)
return;
Slider->Top = Height-CHANNEL_LEFT - SLIDER_W;
FPosition = FMin;
}
else{
FPosition = FMax-(double)(Message.YPos - CHANNEL_LEFT - SLIDER_W/2)/(Height-2*CHANNEL_LEFT-SLIDER_W)*(FMax-FMin);
Slider->Top = Height-CHANNEL_LEFT-(double)(FPosition-FMin)*(Height-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin)-SLIDER_W;
}
if( oldPosition!=FPosition && FOnChange )
FOnChange(this);
}
void __fastcall TSkinTrackBar::WMSize(TWMSize &Message)
{
if(FOrientation){
//确定横向滑块区域
if( Width<PANEL_MIN_W )
Width = PANEL_MIN_W; //20
if( Height<SLIDER_MIN_H )
Height = SLIDER_MIN_H;
if( Height>=SLIDER_MAX_H ){
Slider->Left = CHANNEL_LEFT+(double)(FPosition-FMin)* (Width-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin);
Slider->Top = Height/2-SLIDER_MAX_H/2;
Slider->Width = SLIDER_W;
Slider->Height = SLIDER_MAX_H;
}
else{
Slider->Left = CHANNEL_LEFT+(double)(FPosition-FMin)*(Width-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin);
Slider->Top = 1;
Slider->Width = SLIDER_W;
Slider->Height = Height-2;
}
}
else
{
//确定纵向滑块区域
if( Height<PANEL_MIN_W )
Height = PANEL_MIN_W; //20
if( Width<SLIDER_MIN_H )
Width = SLIDER_MIN_H;
if( Width>=SLIDER_MAX_H ){
Slider->Left = Width/2-SLIDER_MAX_H/2;
Slider->Top = Height-CHANNEL_LEFT-(double)(FPosition-FMin)*(Height-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin)-SLIDER_W;
Slider->Width = SLIDER_MAX_H;
Slider->Height = SLIDER_W;
}
else{
Slider->Left = 1;
Slider->Top = Height-CHANNEL_LEFT-(double)(FPosition-FMin)*(Height-2*CHANNEL_LEFT-SLIDER_W)/(FMax-FMin)-SLIDER_W;
Slider->Width = Width-2;
Slider->Height = SLIDER_W;
}
}
}
+105
View File
@@ -0,0 +1,105 @@
//---------------------------------------------------------------------------
#ifndef SkinTrackBarH
#define SkinTrackBarH
#include "vcl.h"
//---------------------------------------------------------------------------
class PACKAGE TSkinTrackBar : public TPanel
{
private:
TPaintBox *Slider;
int FPosition;
bool FOrientation,
FEnabled;
TNotifyEvent FOnChange;
int FMax,
FMin;
int FPageSize;
bool bDown;
bool bMouse;
void __fastcall Paint(void){};
void __fastcall DrawH(TWMMouse &Message);
void __fastcall DrawV(TWMMouse &Message);
void __fastcall SetMax(int Value);
void __fastcall SetMin(int Value);
void __fastcall SetPosition(int iPosition);
void __fastcall SetOrientation(bool bOrientation);
void __fastcall SetEnabled(bool bEnabled);
void __fastcall SliderPaint(System::TObject* Sender);
void __fastcall CMMouseEnter(System::TObject* Sender);
void __fastcall CMMouseLeave(System::TObject* Sender);
void __fastcall CMMouseDown(System::TObject* Sender, System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
MESSAGE void __fastcall WMMouseWheel(TWMMouseWheel &Message);
MESSAGE void __fastcall WMSize(TWMSize &Message);
MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message);
MESSAGE void __fastcall WMLButtonDown(TWMLButtonDown &Message);
MESSAGE void __fastcall WMLButtonUp(TWMLButtonUp &Message);
MESSAGE void __fastcall WMMouseMove(TWMMouse &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLButtonDown)
MESSAGE_HANDLER(WM_LBUTTONUP, TWMLButtonUp, WMLButtonUp)
MESSAGE_HANDLER(WM_MOUSEWHEEL, TWMMouseWheel, WMMouseWheel)
MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
MESSAGE_HANDLER(WM_MOUSEMOVE, TWMMouseMove, WMMouseMove)
END_MESSAGE_MAP(TPanel)
public:
void __fastcall TMouseWheelEvent(System::TObject* Sender, System::Classes::TShiftState Shift, int WheelDelta, const System::Types::TPoint &MousePos, bool &Handled);
__fastcall TSkinTrackBar(System::Classes::TComponent* AOwner);
__fastcall ~TSkinTrackBar();
__published:
__property bool Orientation = {read=FOrientation, write=SetOrientation, default=true};
__property TNotifyEvent OnChange = {read = FOnChange, write = FOnChange ,default = NULL};
__property bool Enabled = {read = FEnabled, write = SetEnabled, default=true };
__property int Max = {read = FMax, write = SetMax, default = 100};
__property int Min = {read = FMin, write = SetMin, default = 0};
__property int PageSize = {read = FPageSize, write = FPageSize, default = 1};
__property int Position = {read = FPosition, write = SetPosition, stored=FPosition, default = 0};
};
#endif
/************************************************************
使用说明:
1、内部参数
设置方向Orientation,最大值Max,最小值Min,位置Position
2、外部接口
OnChange 为 TNotifyEvent类型
3、使用例举
p_Track = new TSkinTrackBar(GeneralDialogPanel1);
p_Track->Parent = GeneralDialogPanel1;
p_Track->Top = 50;
p_Track->Left = 100;
p_Track->Width = 100;
p_Track->Height = 100;
p_Track->Position = 30; //初始位置
p_Track->ParentBackground = true; //是否背景透明,为true则背景为 Parent的背景---默认为true
p_Track->Orientation = false; //滑块方向 横向为 true ,纵向为false 默认为 true 横向
p_Track->OnChange = Change; //外部接口Change
p_Track->Show();
************************************************************/
+17
View File
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+17
View File
@@ -0,0 +1,17 @@
//---------------------------------------------------------------------------
#include <System.hpp>
#pragma hdrstop
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
return 1;
}
//---------------------------------------------------------------------------
+494
View File
@@ -0,0 +1,494 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#pragma package(smart_init)
#include "TextButton.h"
////////////////////////////////////////////////////////////////////////////////////
#define PIXEL_EXTERNAL_FRAME 1 //外边界大小
#define PIXEL_INTERNAL_FARME 1 //内边界大小
#define PIXEL_INTERNAL_BOUND 1 //圆角大小
#define PIXLE_TEXT_LEFT_OFFSET 3 //文字左边偏移距离
#define PIXEL_TEXT_X Width - 2*PIXLE_TEXT_LEFT_OFFSET
static const COLORREF
CLR_TXT_NOR = RGB( 156, 170, 189 ),
CLR_TXT_HOT = RGB( 201, 214, 229 ),
CLR_TXT_DIS = RGB( 75, 77, 79 ),
clrFrameExBound = RGB(65,70,77),
clrFrameExNormal = RGB(125,128,131),
clrFrameExEnter = RGB(145,156,170),
clrFrameExDisable = RGB(109,114,120),
clrFrameBoundNormal = RGB(68,70,73),
clrFrameBoundEnter = RGB(70,72,76),
clrFrameNormal = RGB(44,46,48),
clrLineNormal = RGB(44,46,48),
clrRectNormal = RGB(74,80,88),
clrRectDisable = RGB(100,106,113),
//角从左到右,从上到下
clrCapArrowOpenBound[10]=
{ RGB(50,54,60),RGB(54,58,64),RGB(57,61,67),RGB(58,63,69),
RGB(58,63,69),RGB(62,67,74),RGB(64,69,76),
RGB(66,71,78),RGB(68,74,81),
RGB(71,77,85)},
clrCapArrowOpenLine[4] =
{ RGB(59,64,70),
RGB(65,70,77),
RGB(69,75,82),
RGB(73,78,86)},
clrExFrameBound[4] =
{ RGB(81,87,94),
RGB(94,100,107),
RGB(113,118,124),
RGB(126,130,136)
},
clrExFrameBoundDisable[4] =
{ RGB(77,83,91),
RGB(86,91,99),
RGB(98,103,110),
RGB(105,110,117)
};
//---------------------------------------------------------------------------
static inline void ValidCtrCheck(TTextButton *)
{
new TTextButton(NULL);
}
//---------------------------------------------------------------------------
namespace Textbutton
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TTextButton)};
RegisterComponents(L"Samples", classes, 0);
}
}
//---------------------------------------------------------------------------
__fastcall TTextButton::TTextButton(TComponent* Owner)
: TGraphicControl(Owner)
{
Height = 25; //a default Height
Width = 75; //a default Width
FStateCount = 4; //default state count
FDown = false;
ShowHint = true;
}
//---------------------------------------------------------------------------
__fastcall TTextButton::~TTextButton(void)
{
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::Paint(void)
{
if( FDown ) EtatBtn = 2;
if( !Enabled ) EtatBtn = 3;
PaintCustomer();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::MouseDown(System::Uitypes::TMouseButton Button,
System::Classes::TShiftState Shift, int X, int Y)
{
TGraphicControl::MouseDown( Button, Shift, X, Y );
if( Button==mbLeft && Enabled && FStateCount>2){
EtatBtn = 2; // Pressed
Paint();
Refresh();
}
TCustomForm * parentForm = GetParentForm( this );
if( parentForm && parentForm==Application->MainForm ){
TPoint pt(X,Y);
pt = ClientToParent( pt, parentForm );
Application->MainForm->OnMouseDown( NULL, Button, Shift, pt.X, pt.Y );
}
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::MouseUp(System::Uitypes::TMouseButton Button,
System::Classes::TShiftState Shift, int X, int Y)
{
TGraphicControl::MouseUp( Button, Shift, X, Y );
if( Button==mbLeft && Enabled ){
if( X>=0 && X<Width && Y>=0 && Y<Height )
EtatBtn = 1; //Mouse Entered
else
EtatBtn = 0; //normal;
Paint();
Refresh(); //repaint component
}
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::CMMouseEnter(Winapi::Messages::TMessage &Msg)
{
if( Enabled && !ComponentState.Contains(csDesigning) ){
EtatBtn = 1; // Mouse Entered
Paint();
Refresh(); //repainting the component
}
if( FOnMouseEnter )
FOnMouseEnter(this); //if user set a mouse enter procedure then we execute it
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::CMMouseLeave(Winapi::Messages::TMessage &Msg)
{
if( Enabled && !ComponentState.Contains(csDesigning) ) {
EtatBtn = 0; //Normal
Paint();
Refresh(); //repainting the component
}
if( FOnMouseLeave )
FOnMouseLeave(this); //if user set a mouse leave procedure then we execute it
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::Click(void)
{
TCustomForm * parentForm = GetParentForm( this );
if( parentForm ){
parentForm->ModalResult = FModalResult;
}
TGraphicControl::Click();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::SetEnabled(bool Value)
{
if(FStateCount<4) //can't be disable
Value = true;
TGraphicControl::SetEnabled(Value);
if( Enabled )
EtatBtn = 0;
else
EtatBtn = 3;
Paint();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::SetStateCount( int count )
{
if( count>4 ) count = 4;
if( count<2 ) count = 2;
FStateCount = count;
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::SetDown(bool value)
{
if( FStateCount<3 )
value = false;
FDown = value;
if( FDown==False )
EtatBtn = 0; //is the mouse down is false then we reset the component state to normal
Paint();
Refresh(); //we repaint the componet)
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::SetFontSize( int value )
{
Canvas->Font->Size = value;
Paint();
Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::SetFontName(System::Uitypes::TFontName value)
{
Canvas->Font->Name = value;
Paint();
Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::SetTextFont(String name, int size)
{
Canvas->Font->Name = name;
Canvas->Font->Size = size;
Paint();
Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::PaintCustomer(void)
{
TRect rectDraw = GetClientRect();
TRect tmpRet = rectDraw;
//================画外边框
if(EtatBtn == 0){
Canvas->Brush->Color = clrFrameExNormal;
Canvas->Pen->Color = clrFrameExNormal;
}else if(EtatBtn == 3){
Canvas->Brush->Color = clrFrameExDisable;
Canvas->Pen->Color = clrFrameExDisable;
}else {
Canvas->Brush->Color = clrFrameExEnter;
Canvas->Pen->Color = clrFrameExEnter;
}
int X,Y;
//上
Y = 0;
X = PIXEL_EXTERNAL_FRAME ;
Canvas->MoveTo( X, Y );
X = Width - PIXEL_EXTERNAL_FRAME ;
Canvas->LineTo( X, Y );
//下
Y = Height - PIXEL_EXTERNAL_FRAME ;
X = PIXEL_EXTERNAL_FRAME ;
Canvas->MoveTo( X, Y );
X = Width - PIXEL_EXTERNAL_FRAME ;
Canvas->LineTo( X, Y );
//左
X = 0 ;
Y = PIXEL_EXTERNAL_FRAME ;
Canvas->MoveTo( X, Y );
Y = Height - PIXEL_EXTERNAL_FRAME ;
Canvas->LineTo( X, Y );
//右
X = Width - PIXEL_EXTERNAL_FRAME ;
Y = PIXEL_EXTERNAL_FRAME ;
Canvas->MoveTo( X, Y );
Y = Height - PIXEL_EXTERNAL_FRAME ;
Canvas->LineTo( X, Y );
//画外边框圆角
int iLPixl, iTPixl, iRPixl, iBPixl ;
TRect tmpRetPic = rectDraw; //画内部区域渐变图像
int iDistant = 1; //画点right和bottom - 1
for(int i=0;i<4;i++)
{
//角 4*4 上左右 下左右
iLPixl = tmpRetPic.Left + i;
iTPixl = tmpRetPic.Top;
iRPixl = tmpRetPic.Right - i - iDistant;
iBPixl = tmpRetPic.Bottom - iDistant;
if(EtatBtn == 3)
Canvas->Pen->Color = clrExFrameBoundDisable[i];
else
Canvas->Pen->Color = clrExFrameBound[i];
Canvas->Pixels[iLPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iLPixl][iBPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iBPixl] = Canvas->Pen->Color;
if(i>0){ //每个角对称
iLPixl = tmpRetPic.Left;
iTPixl = tmpRetPic.Top + i;
iRPixl = tmpRetPic.Right - iDistant;
iBPixl = tmpRetPic.Bottom - i - iDistant;
Canvas->Pixels[iLPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iLPixl][iBPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iBPixl] = Canvas->Pen->Color;
}
}
//=================画内边框
//画圆角
if(EtatBtn == 0) Canvas->Pen->Color = clrFrameBoundNormal;
else Canvas->Pen->Color = clrFrameBoundEnter;
tmpRet.Top = PIXEL_EXTERNAL_FRAME;
tmpRet.left = PIXEL_EXTERNAL_FRAME;
Canvas->Pixels[tmpRet.left][tmpRet.top] = Canvas->Pen->Color;
tmpRet.left = Width - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Canvas->Pixels[tmpRet.left][tmpRet.top] = Canvas->Pen->Color;
//////////////
tmpRet.Top = Height - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
tmpRet.left = PIXEL_EXTERNAL_FRAME;
Canvas->Pixels[tmpRet.left][tmpRet.top] = Canvas->Pen->Color;
tmpRet.left = Width - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Canvas->Pixels[tmpRet.left][tmpRet.top] = Canvas->Pen->Color;
//画线
Canvas->Pen->Color = clrFrameNormal;
// int X,Y;
//上
Y = PIXEL_EXTERNAL_FRAME;
X = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
Canvas->MoveTo( X, Y );
X = Width - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Canvas->LineTo( X, Y );
//下
Y = Height - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
X = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
Canvas->MoveTo( X, Y );
X = Width - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Canvas->LineTo( X, Y );
//左
X = PIXEL_EXTERNAL_FRAME ;
Y = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
Canvas->MoveTo( X, Y );
Y = Height - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Canvas->LineTo( X, Y );
//右
X = Width - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Y = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
Canvas->MoveTo( X, Y );
Y = Height - PIXEL_EXTERNAL_FRAME - PIXEL_INTERNAL_FARME;
Canvas->LineTo( X, Y );
//==============画内部区域
if(3 == EtatBtn){
Canvas->Brush->Color = clrRectDisable;
Canvas->Pen->Color = clrRectDisable;
}else{
Canvas->Brush->Color = clrRectNormal;
Canvas->Pen->Color = clrRectNormal;
}
tmpRet.Left = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
tmpRet.Top = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
tmpRet.Right = Width - tmpRet.Left;
tmpRet.Bottom = Height - tmpRet.Top;
Canvas->Rectangle(tmpRet.Left, tmpRet.Top,
tmpRet.Right, tmpRet.Bottom);
if(3 != EtatBtn)
{
if(2 == EtatBtn) // down
{
tmpRetPic = rectDraw; //画内部区域渐变图像
iDistant = PIXEL_EXTERNAL_FRAME + PIXEL_INTERNAL_FARME;
tmpRetPic.Left += iDistant;
tmpRetPic.Top += iDistant;
tmpRetPic.Right -= iDistant;
tmpRetPic.Bottom -= iDistant;
iDistant = 1; //画点right和bottom - 1
int iTmpAdd = 0;//clrCapArrowOpenBound 当前位置
for(int i=0; i<4; i++)
{
//边线
Canvas->Brush->Color = clrCapArrowOpenLine[i];
Canvas->FrameRect(tmpRetPic);
int iadd = 0;//clrCapArrowOpenBound 当前位置增加
for(int j=0; j<4-i; j++) {
//角 4*4 上左右 下左右
iLPixl = tmpRetPic.Left + j;
iTPixl = tmpRetPic.Top;
iRPixl = tmpRetPic.Right - j - iDistant;
iBPixl = tmpRetPic.Bottom - iDistant;
Canvas->Pen->Color = clrCapArrowOpenBound[iTmpAdd+j];
Canvas->Pixels[iLPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iLPixl][iBPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iBPixl] = Canvas->Pen->Color;
if(j>0){ //每个角对称
iLPixl = tmpRetPic.Left;
iTPixl = tmpRetPic.Top + j;
iRPixl = tmpRetPic.Right - iDistant;
iBPixl = tmpRetPic.Bottom - j - iDistant;
Canvas->Pixels[iLPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iTPixl] = Canvas->Pen->Color;
Canvas->Pixels[iLPixl][iBPixl] = Canvas->Pen->Color;
Canvas->Pixels[iRPixl][iBPixl] = Canvas->Pen->Color;
}
iadd++;
}
iTmpAdd += iadd;
tmpRetPic.Left += iDistant;
tmpRetPic.Top += iDistant;
tmpRetPic.Right -= iDistant;
tmpRetPic.Bottom -= iDistant;
}
}
}
PaintCustomerText();
}
//---------------------------------------------------------------------------
void __fastcall TTextButton::PaintCustomerText(void)
{
int X,Y;
if( !Text.IsEmpty() ){
if( EtatBtn==0 ){
Canvas->Font->Color = CLR_TXT_NOR;
}
else if( EtatBtn==3 ){
Canvas->Font->Color = CLR_TXT_DIS;
}
else{
Canvas->Font->Color = CLR_TXT_HOT;
}
Canvas->Brush->Style = bsClear;
String strText = FText;
TSize size = Canvas->TextExtent( strText );
int nLen = strText.Length();
if( size.Width > PIXEL_TEXT_X)
{
nLen = nLen*(PIXEL_TEXT_X)/size.Width;
nLen -= 1;
if(nLen <= 0){
strText = strText.SubString(0, 1);
}else{
strText = strText.SubString(0, nLen);
strText += "..";
}
size = Canvas->TextExtent( strText );
}
X = PIXLE_TEXT_LEFT_OFFSET + ( PIXEL_TEXT_X - size.Width )/2;
Y = ( Height -size.Height )/2;
Canvas->TextOut( X, Y, strText );
}
}
//---------------------------------------------------------------------------
+101
View File
@@ -0,0 +1,101 @@
//---------------------------------------------------------------------------
#ifndef TextButtonH
#define TextButtonH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Imaging.pnglang.hpp>
#include <Vcl.Graphics.hpp>
//---------------------------------------------------------------------------
class PACKAGE TTextButton : public TGraphicControl
{
public:
enum TModalResult{
mrNone = System::Int8(0x0),
mrOk = System::Int8(0x1),
mrCancel = System::Int8(0x2),
mrAbort = System::Int8(0x3),
mrRetry = System::Int8(0x4),
mrIgnore = System::Int8(0x5),
mrYes = System::Int8(0x6),
mrNo = System::Int8(0x7),
mrClose = System::Int8(0x8),
mrHelp = System::Int8(0x9),
mrTryAgain = System::Int8(0xa),
mrContinue = System::Int8(0xb),
mrAll = System::Int8(0xc),
mrNoToAll = System::Int8(0xd),
mrYesToAll = System::Int8(0xe)
};
private:
TNotifyEvent FOnMouseEnter;//on mouse enter notify event
TNotifyEvent FOnMouseLeave;//on mouse leave notify event
// System::Uitypes::TModalResult FModalResult;
TModalResult FModalResult;
MESSAGE void __fastcall CMMouseEnter(Winapi::Messages::TMessage &Msg); // to know when mouse is entered
MESSAGE void __fastcall CMMouseLeave(Winapi::Messages::TMessage &Msg); // to know when mouse is leaved
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TGraphicControl)
protected:
bool FDown; // value to know if we painting mouse down
int EtatBtn; // 0=Normal 1=Mouse entered 2=Pressed 3=Disabled
int FStateCount;
String FText;
DYNAMIC void __fastcall MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
DYNAMIC void __fastcall MouseUp(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);
virtual void __fastcall SetEnabled(bool Value);
__published:
__property Action;
__property Anchors = {default=3};
// __property System::Uitypes::TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};
__property TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=mrNone};
__property ParentShowHint = {default=1};
__property PopupMenu;
__property ShowHint;
__property Visible = {default=1};
__property OnClick;
__property OnContextPopup;
__property OnMouseDown;
__property OnMouseMove;
__property OnMouseUp;
__property System::Classes::TNotifyEvent OnMouseEnter = {read=FOnMouseEnter, write=FOnMouseEnter};
__property System::Classes::TNotifyEvent OnMouseLeave = {read=FOnMouseLeave, write=FOnMouseLeave};
__property bool Down = {read=FDown, write=SetDown, default=False};
__property Enabled = {default=1};
__property int ImgStates = {read=FStateCount, write=SetStateCount, default=4};
__property String Text = {read=FText, write=FText};
__property int FontSize = {write=SetFontSize, default=8};
__property System::Uitypes::TFontName FontName = {write=SetFontName};
private:
void __fastcall PaintCustomer(void);
void __fastcall PaintCustomerText(void);
public:
__fastcall virtual TTextButton(System::Classes::TComponent* AOwner);
__fastcall virtual ~TTextButton(void);
virtual void __fastcall Paint(void); // override the painting of the component
DYNAMIC void __fastcall Click(void);
void __fastcall SetStateCount( int count );
void __fastcall SetDown(bool value); // to know if mouse is down or not
void __fastcall SetFontSize( int value );
void __fastcall SetFontName(System::Uitypes::TFontName value);
void __fastcall SetTextFont(String name, int size);
};
//---------------------------------------------------------------------------
#endif