#ifndef __TSpeedButton_H #define __TSpeedButton_H //--------------------------------------------------------------------------- // speed ¹öÅÏ: ¸¶¿ì½º°¡ ¿Ã¶ó¿ÔÀ»¶§¿Í Ŭ¸¯ÇßÀ»¶§ Á»´õ ¸ÚÁø È¿°ú¸¦ ÁÖ±â À§ÇÑ °ÍÀÌ´Ù. // // Written by KTS. class TSpeedButton : public Buttons::TSpeedButton { typedef Buttons::TSpeedButton inherited; private: struct TF { int FGroupIndex; void *FGlyph; bool FDown; bool FDragging; bool FAllowAllUp; TButtonLayout FLayout; int FSpacing; bool FTransparent; int FMargin; bool FFlat; bool FMouseInControl; }; TF* GetF() { return (TF*)((UINT)this + sizeof(Controls::TGraphicControl)); } bool FStateIn(TButtonState aa, TButtonState ab) { if (FState == aa || FState == ab) return true; return false; } public: void __fastcall Paint() { int DownStyles[2] = { BDR_RAISEDINNER, BDR_SUNKENOUTER }; int FillStyles[2] = { BF_MIDDLE, 0 }; TRect PaintRect; int DrawFlags; TPoint Offset; TF *F = GetF(); if (!Enabled) { FState = bsDisabled; F->FDragging = false; } else if (FState == bsDisabled) { if (F->FDown && (GroupIndex != 0)) FState = bsExclusive; else FState = bsUp; } Canvas->Font = this->Font; PaintRect = Rect(0, 0, Width, Height); if (!F->FFlat) { DrawFlags = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT; if (FStateIn(bsDown, bsExclusive)) DrawFlags = DrawFlags | DFCS_PUSHED; DrawFrameControl(Canvas->Handle, &PaintRect, DFC_BUTTON, DrawFlags); } else { if ((FStateIn(bsDown, bsExclusive)) || (F->FMouseInControl &&(FState != bsDisabled)) || ComponentState.Contains(csDesigning)) { if (FStateIn(bsDown, bsExclusive)) { Canvas->Pen->Color = clGray; Canvas->Brush->Color = (TColor)0x00EBEBEB; } else { Canvas->Pen->Color = clSilver; Canvas->Brush->Color = (TColor)0x00FFF2E8; } Canvas->RoundRect(PaintRect.left, PaintRect.top, PaintRect.right, PaintRect.bottom, 5, 5); } else if (!Transparent) { Canvas->Brush->Color = Color; Canvas->FillRect(PaintRect); } InflateRect(&PaintRect, -1, -1); } if (FStateIn(bsDown, bsExclusive)) { if ((FState == bsExclusive) && (!F->FFlat || !F->FMouseInControl)) { Canvas->Brush->Bitmap = AllocPatternBitmap(clBtnFace, clBtnHighlight); Canvas->FillRect(PaintRect); } Offset.x = 1; Offset.y = 1; } else { Offset.x = 0; Offset.y = 0; } // ¾Æ·¡ 3ÁÙÀº ÄÄÆÄÀÏÀ» À§ÇØ Ãß°¡ ÀÛ¾÷À» ÇØ¾ß ÇÔ. TButtonGlyph *bg = (TButtonGlyph *)F->FGlyph; bg->Draw(Canvas, PaintRect, Offset, Caption, F->FLayout, F->FMargin, F->FSpacing, FState, Transparent, DrawTextBiDiModeFlags(0)); } }; #define TSpeedButton ::TSpeedButton //--------------------------------------------------------------------------- #endif