📄 acsbutils.pas
字号:
unit acSBUtils;
{$I sDefs.inc}
{.$DEFINE LOGGED}
interface
uses Windows, Messages, sCommonData, Controls, sSkinManager, Graphics, Classes, ExtCtrls,
Forms{$IFNDEF DELPHI5}, types{$ENDIF}, ComCtrls, StdCtrls, sConst, TypInfo;
const
acPropStr = 'ACSBSC';
CSBS_NORMAL = 0;
CSBS_HOTTRACKED = 2;
CSBS_THUMBALWAYS = 4;
CSBS_VISIBLE = 8;
THUMBTRACK_SNAPDIST = 24;
MINTHUMBSIZE_NT4 = 8;
MINTHUMBSIZE_2000 = 6;
SM_CXVERTSB = 1;
SM_CYVERTSB = 0;
SM_CXHORZSB = 0;
SM_CYHORZSB = 1;
SM_SCROLL_LENGTH = 0;
COOLSB_NONE = -1;
HTSCROLL_NONE = -1;
HTSCROLL_NORMAL = -1;
SYSTEM_METRIC = -1;
HTSCROLL_LEFT = SB_LINELEFT;
HTSCROLL_UP = SB_LINEUP;
HTSCROLL_DOWN = SB_LINEDOWN;
HTSCROLL_RIGHT = SB_LINERIGHT;
HTSCROLL_THUMB = SB_THUMBTRACK;
HTSCROLL_PAGELEFT = SB_PAGELEFT;
HTSCROLL_PAGERIGHT = SB_PAGERIGHT;
HTSCROLL_PAGEUP = SB_PAGEUP;
HTSCROLL_PAGEDOWN = SB_PAGEDOWN;
COOLSB_TIMERID1 = 65533; // initial timer
COOLSB_TIMERID2 = 65534; // scroll message timer
COOLSB_TIMERID3 = 65522; // mouse hover timer
COOLSB_TIMERINTERVAL1 = 300;
COOLSB_TIMERINTERVAL2 = 55;
COOLSB_TIMERINTERVAL3 = 20; // mouse hover time
type
TDropMarkMode = (dmmNone, dmmLeft, dmmRight);
THeaderPaintInfo = record
TargetCanvas: TCanvas;
Column: TCollectionItem;
PaintRectangle: TRect;
TextRectangle: TRect;
IsHoverIndex, IsDownIndex, IsEnabled, ShowHeaderGlyph, ShowSortGlyph, ShowRightBorder: Boolean;
DropMark: TDropMarkMode;
GlyphPos, SortGlyphPos: TPoint;
end;
THeaderPaintElements = set of (hpeBackground, hpeDropMark, hpeHeaderGlyph, hpeSortGlyph, hpeText);
TAdvancedHeaderPaintEvent = procedure(Sender: TPersistent; var PaintInfo: THeaderPaintInfo; const Elements: THeaderPaintElements) of object;
THeaderPaintQueryElementsEvent = procedure(Sender: TPersistent; var PaintInfo: THeaderPaintInfo; var Elements: THeaderPaintElements) of object;
TacScrollWnd = class;
TacScrollBar = class(TObject)
fScrollFlags : word; // flags
fScrollVisible : boolean; // if this scrollbar visible?
ScrollInfo : TScrollInfo; // positional data (range, position, page size etc)
nArrowLength : integer; // perpendicular size (height of a horizontal, width of a vertical)
nArrowWidth : integer; // parallel size (width of horz, height of vert)
nButSizeBefore : integer; // size to the left / above the bar
nButSizeAfter : integer; // size to the right / below the bar
fButVisibleBefore : boolean; // if the buttons to the left are visible
fButVisibleAfter : boolean; // if the buttons to the right are visible
nBarType : word; // SB_HORZ / SB_VERT
fFlatScrollbar : word; // do we display flat scrollbars?
nMinThumbSize : integer;
sw : TacScrollWnd;
end;
TacMainWnd = class(TObject)
public
DlgMode : boolean;
Caption : acString;
WndRect : TRect;
WndSize : TSize;
WndPos : TPoint;
ParentRect : TRect;
ParentWnd : hwnd;
OldWndProc : TWndMethod;
OldProc : Pointer;
CtrlHandle : hwnd;
SkinManager : TsSkinManager;
SkinData : TsCommonData;
DontRepaint : boolean;
ParamsChanged : boolean;
StdColor, StdFontColor : TColor;
Destroyed : boolean;
OwnSkinData : boolean;
NewWndProcInstance : Pointer;
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); virtual;
procedure SaveStdParams; virtual;
procedure RestoreStdParams; virtual;
procedure SetSkinParams; virtual;
destructor Destroy; override;
function CallPrevWndProc(Handle : hwnd; Msg : longint; WParam : longint; var LParam : longint) : longint;
procedure acWndProc(var Message: TMessage); virtual;
end;
TacStaticWnd = class(TacMainWnd)
public
procedure AC_WMPaint(var Message : TWMPaint);
procedure PaintText; virtual;
procedure acWndProc(var Message: TMessage); override;
end;
TacIconWnd = class(TacStaticWnd)
procedure PaintText; override;
end;
TacDlgPanelWnd = class(TacMainWnd) // Used in Open/Save picture dialogs
public
Panel : TPanel;
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); override;
procedure PrepareCache; dynamic;
procedure AC_WMNCPaint(aDC : hdc);
procedure AC_WMPaint(aDC : hdc);
procedure acWndProc(var Message: TMessage); override;
end;
TacLinkWnd = class(TacStaticWnd)
public
procedure PaintText; override;
procedure acWndProc(var Message: TMessage); override;
end;
TacBtnWnd = class(TacMainWnd)
public
function CtrlStyle : dword;
function Down : boolean;
function CurrentState : integer;
procedure DrawCaption; dynamic;
procedure DrawGlyph; dynamic;
function GlyphSize : TSize; dynamic;
procedure DoDrawText(var Rect: TRect; Flags: Longint); dynamic;
function CaptionRect : TRect; dynamic;
function MaxCaptionWidth : integer; dynamic;
function TextRectSize : TSize; dynamic;
procedure PrepareCache; dynamic;
procedure AC_WMPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
procedure RestoreStdParams; override;
procedure SetSkinParams; override;
end;
TacBitBtnWnd = class(TacBtnWnd)
public
hBmp : hBitmap;
hIco : hIcon;
function CaptionRect : TRect; override;
function GlyphRect : TRect;
function GlyphSize : TSize; override;
procedure DrawGlyph; override;
function MaxCaptionWidth : integer; override;
end;
TacSizerWnd = class(TacMainWnd)
public
procedure AC_WMPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
end;
TacSpinWnd = class(TacMainWnd)
public
lOffset : integer;
bMousePressed : boolean;
Btn1State, Btn2State : integer;
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); override;
procedure PrepareCache;
procedure AC_WMPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
end;
TacCheckBoxWnd = class(TacMainWnd)
public
function State : TCheckBoxState;
function CtlState : integer;
function CheckRect: TRect;
function SkinCheckRect(i : integer): TRect;
function SkinGlyphWidth(i : integer) : integer;
function SkinGlyphHeight(i : integer) : integer;
procedure DrawCheckText;
procedure DrawSkinGlyph(i : integer);
function GlyphMaskIndex(State : TCheckBoxState) : smallint;
procedure PrepareCache;
procedure AC_WMPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
end;
TacToolBarWnd = class(TacMainWnd)
public
ClientRect : TRect;
BorderWidth : integer;
HotBtn : integer;
procedure PrepareCache;
procedure DrawButtons(Bmp : TBitmap);
procedure DrawBtn(Index : integer; R : TRect; DC : hdc);
function GetButtonRect(Index : integer) : TRect;
function Count : integer;
function ButtonRect(Index : integer) : TRect;
procedure AC_WMPaint(Message : TWMPaint);
procedure AC_WMNCPaint(Message : TMessage);
procedure acWndProc(var Message: TMessage); override;
end;
TacTransPanelWnd = class(TacMainWnd)
public
procedure AC_WMPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
end;
TacGroupBoxWnd = class(TacMainWnd)
public
function CaptionRect: TRect;
procedure PrepareCache;
procedure WriteText(R : TRect);
procedure AC_WMPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
end;
TacTabWnd = class(TacMainWnd)
public
function DisplayRect: TRect;
procedure PrepareCache;
procedure AC_WMPaint(Message : TWMPaint);
procedure AC_WMNCPaint(Message : TWMPaint);
procedure acWndProc(var Message: TMessage); override;
end;
TacScrollWnd = class(TacMainWnd)
public
bars : word;
sBarHorz : TacScrollBar;
sBarVert : TacScrollBar;
fThumbTracking : boolean;
fLeftScrollbar : boolean;
cxLeftEdge, cxRightEdge : integer;
cyTopEdge, cyBottomEdge : integer;
bPreventStyleChange : boolean; // To prevent calling original WindowProc in response to our own temporary style change (fixes TreeView problem)
destructor Destroy; override;
procedure acWndProc(var Message: TMessage); override;
end;
TacPanelWnd = class(TacMainWnd)
public
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); override;
procedure PrepareCache; dynamic;
procedure AC_WMNCPaint(aDC : hdc);
procedure AC_WMPaint(var aDC : hdc);
procedure acWndProc(var Message: TMessage); override;
end;
{$IFNDEF NOMNUHOOK}
TacMnuWnd = class(TacScrollWnd)
public
RgnChanged : integer;
procedure PrepareCache; dynamic;
procedure acWndProc(var Message: TMessage); override;
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); override;
end;
{$ENDIF}
TacBaseWnd = class(TacScrollWnd)
public
procedure acWndProc(var Message: TMessage); override;
end;
TacMDIWnd = class(TacBaseWnd)
public
FForm : TForm;
MDISkinData : TsCommonData;
SkinProvider : TObject;
destructor Destroy; override;
procedure acWndProc(var Message: TMessage); override;
procedure UpdateGraphControls;
end;
////////////////////////////////////////////
// TCustomEdit, TCustomListbox compatible //
////////////////////////////////////////////
TacEditWnd = class(TacBaseWnd)
public
Color : TColor;
FrameColor : integer;
Brush : TBrush;
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); override;
procedure acWndProc(var Message: TMessage); override;
procedure SaveStdParams; override;
procedure SetSkinParams; override;
procedure RestoreStdParams; override;
end;
//////////////////
// ComboListBox //
//////////////////
TacComboListWnd = class(TacEditWnd)//TacScrollWnd)
public
Showed : boolean;
SimplyBox : boolean;
constructor Create(AHandle : hwnd; ASkinData : TsCommonData; ASkinManager : TsSkinManager; const SkinSection : string; Repaint : boolean = True); override;
destructor Destroy; override;
procedure acWndProc(var Message: TMessage); override;
end;
////////////////////////////////
// TCustomListView compatible //
////////////////////////////////
TacListViewWnd = class(TacEditWnd)
public
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -