📄 flatboxs.pas
字号:
unit FlatBoxs;
interface
{$I FlatStyle.inc}
uses
Windows, Messages, Classes, Forms, Controls, Graphics,
SysUtils, ExtCtrls, FlatUtils, FlatSkins, ActnList, StdCtrls;
type
{ TDefineListBox }
TDefineListBox = class(TVersionControl)
private
scrollType: TScrollType;
FirstItem: Integer;
FSorted: Boolean;
FItems: TStringList;
FRects: TList;
FChecks: TList;
FItemIndex: Integer;
FMultiSelect: Boolean;
FOnChange: TNotifyChange;
FOnClick: TNotifyClick;
FStyle: TListStyle;
FCaption: TCaption;
FMouseIn: boolean;
procedure SetSorted(Value: Boolean);
procedure SetItems(Value: TStringList);
procedure SetSelected(Index: Integer; Value: Boolean);
procedure SetItemIndex(Value: Integer);
procedure SetMultiSelect(Value: Boolean);
procedure SetListStyle(const Value: TListStyle);
procedure SetCaption(const Value: TCaption);
function GetItemCount: Integer;
protected
procedure SetItemsRect;
procedure Paint; override;
procedure Loaded; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure SetName(const Value: TComponentName); override;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure ScrollTimerHandler(Sender: TObject);
procedure StyleChange(Sender: TObject);
procedure SelectNotifyEvent;
procedure WMMove(var Message: TWMMove); message WM_MOVE;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure WMKeyDown(var Message: TWMKeyDown); message CN_KEYDOWN;
procedure WMMouseWheel(var Message: TMessage); message WM_MOUSEWHEEL;
procedure WMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMParentFontChanged(var Message: TMessage); message CM_PARENTFONTCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure DeleteChecked(index: integer);
procedure AddCheck(index: integer);
function FindChecked(Value: Integer;var Index:Integer): boolean;
function GetMaxItems: Integer;
function GetSelected(Index: Integer): Boolean;
function GetSelCount: Integer;
function GetItemIndex: Integer;
function GetItemText: TCaption;
property Skin: TListStyle read FStyle write SetListStyle;
property MaxItems: Integer read GetMaxItems;
property Items: TStringList read FItems write SetItems;
property MultiSelect: Boolean read FMultiSelect write SetMultiSelect default false;
property Caption:TCaption read FCaption write SetCaption;
property Sorted: Boolean read FSorted write SetSorted default false;
property OnClick: TNotifyClick read FOnClick write FOnClick;
property OnChange: TNotifyChange read FOnChange write FOnChange;
property TabStop default True;
property ParentColor default True;
property ParentFont default True;
property Enabled default True;
property Visible default True;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Click; override;
procedure Clear;
function Find(Value:String; var Index : Integer):boolean;
property ItemText:TCaption read GetItemText;
property Selected[Index: Integer]: Boolean read GetSelected write SetSelected;
property SelCount: Integer read GetSelCount;
property ItemIndex: Integer read GetItemIndex write SetItemIndex;
property ItemCount: Integer read GetItemCount;
end;
{ TFlatListBox }
TFlatListBox = class(TDefineListBox)
published
property Caption;
property Skin;
property Align;
property Items;
property MultiSelect;
property Sorted;
property Font;
property ParentFont;
property ParentShowHint;
property Enabled;
property Visible;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property OnClick;
property OnChange;
property OnDblClick;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property OnKeyDown;
property OnKeyPress;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyUp;
property OnStartDock;
property OnStartDrag;
end;
{ TDefineListChecks }
TDefineListChecks = class(TVersionControl)
private
FSelected: Integer;
FCurSelected :integer;
scrollType: TScrollType;
FirstItem: Integer;
FSorted: Boolean;
FItems: TStringList;
FRects: TList;
FChecks: TList;
FOnChange: TNotifyChange;
FOnClick: TNotifyClick;
FOnClickCheck: TNotifyEvent;
FCaption: TCaption;
FStyle: TCheckStyle;
FMouseIn: boolean;
procedure SetSorted(Value: Boolean);
procedure SetItems(Value: TStringList);
procedure SetChecked(Index: Integer; Value: Boolean);
procedure SetCaption(const Value: TCaption);
procedure SetCheckStyle(const Value: TCheckStyle);
procedure SetItemIndex(Value: Integer);
function GetItemCount: Integer;
protected
procedure Paint; override;
procedure Loaded; override;
procedure SetItemsRect;
procedure ScrollTimerHandler(Sender: TObject);
procedure DrawCheckRect(Canvas: TCanvas; StartRect: TRect; checked: Boolean);
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure StyleChange( Sender: TObject);
procedure SetName(const Value: TComponentName); override;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMMove(var Message: TWMMove); message WM_MOVE;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure WMKeyDown(var Message: TWMKeyDown); message CN_KEYDOWN;
procedure WMMouseWheel(var Message: TMessage); message WM_MOUSEWHEEL;
procedure WMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMParentFontChanged(var Message: TMessage); message CM_PARENTFONTCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure SelectNotifyEvent;
procedure DeleteChecked(index: integer);
procedure AddCheck(index: integer);
function FindChecked(Value: Integer;var Index:Integer): boolean;
function GetChecked(Index: Integer): Boolean;
function GetSelCount: Integer;
function GetItemIndex: Integer;
function GetItemText: TCaption;
function GetMaxItems: Integer;
property Skin: TCheckStyle read FStyle write SetCheckStyle;
property Sorted: Boolean read FSorted write SetSorted default false;
property Items: TStringList read FItems write SetItems;
property MaxItems: Integer read GetMaxItems;
property Caption: TCaption read FCaption write SetCaption;
property OnClick: TNotifyClick read FOnClick write FOnClick;
property OnChange: TNotifyChange read FOnChange write FOnChange;
property OnClickCheck: TNotifyEvent read FOnClickCheck write FOnClickCheck;
property TabStop default True;
property ParentColor default True;
property ParentFont default True;
property Enabled default True;
property Visible default True;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Clear;
procedure Click; override;
procedure CheckAll;
procedure CheckCancel;
procedure Delete(Index:Integer);
function Find(Value: String; var Index: Integer): boolean;
property Checked[Index: Integer]: Boolean read GetChecked write SetChecked;
property SelCount: Integer read GetSelCount;
property ItemText: TCaption read GetItemText;
property ItemIndex: Integer read GetItemIndex write SetItemIndex;
property ItemCount: Integer read GetItemCount;
end;
{ TFlatCheckListBox }
TFlatCheckListBox = class(TDefineListChecks)
published
property Skin;
property Caption;
property Sorted;
property Items;
property Align;
property Font;
property ParentFont;
property ParentShowHint;
property Enabled;
property Visible;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property ParentColor;
property OnClick;
property OnChange;
property OnClickCheck;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnStartDock;
property OnStartDrag;
end;
{ TDefineCheckBox }
TDefineCheckBox = class(TVersionControl)
private
FMouseIn: Boolean;
FMouseDown: Boolean;
Focused: Boolean;
FLayout: TLayoutPosition;
FChecked: Boolean;
FFocusedColor: TColor;
FDownColor: TColor;
FCheckedColor: TColor;
FBorderColor: TColor;
FTransparent: Boolean;
procedure SetColors(Index: Integer; Value: TColor);
procedure SetLayout(Value: TLayoutPosition);
procedure SetChecked(Value: Boolean);
procedure SetTransparent(const Value: Boolean);
protected
procedure DoEnter; override;
procedure DoExit; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMTextChanged(var Message: TWmNoParams); message CM_TEXTCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure CNCommand(var Message: TWMCommand); message CN_COMMAND;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMParentColorChanged(var Message: TWMNoParams); message CM_PARENTCOLORCHANGED;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMMove(var Message: TWMMove); message WM_MOVE;
procedure Paint; override;
property Transparent: Boolean read FTransparent write SetTransparent default True;
property Checked: Boolean read FChecked write SetChecked default false;
property ColorFocused: TColor index 0 read FFocusedColor write SetColors default DefaultBackdropColor;
property ColorDown: TColor index 1 read FDownColor write SetColors default DefaultBarColor;
property ColorChecked: TColor index 2 read FCheckedColor write SetColors default DefaultCheckColor;
property ColorBorder: TColor index 3 read FBorderColor write SetColors default DefaultBorderColor;
property Layout: TLayoutPosition read FLayout write SetLayout default lpLeft;
property Color default DefaultFlatColor;
property ParentColor default false;
property TabStop default True;
public
constructor Create(AOwner: TComponent); override;
end;
{ TFlatCheckBox }
TFlatCheckBox = class(TDefineCheckBox)
published
property Transparent;
property Caption;
property Checked;
property ColorFocused;
property ColorDown;
property ColorChecked;
property Color;
property ColorBorder;
property Action;
property Enabled;
property Font;
property Layout;
property ParentColor;
property ParentFont;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
{ TDefineGroupBox }
TDefineGroupBox = class(TVersionControl)
private
FTransparent: Boolean;
FBorderColor: TColor;
FBorder: TGroupBoxBorder;
FBackgropStopColor: TColor;
FBackgropStartColor: TColor;
FStyleFace: TStyleFace;
FBackgropOrien: TStyleOrien;
FAlignment: TAlignmentText;
procedure SetColors(const Index: Integer; const Value: TColor);
procedure SetBorder(const Value: TGroupBoxBorder);
procedure SetTransparent(const Value: Boolean);
procedure SetBackgropOrien(const Value: TStyleOrien);
procedure SetStyleFace(const Value: TStyleFace); virtual;
procedure SetAlignment(const Value: TAlignmentText);
protected
procedure Paint; override;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMTextChanged(var Message: TWmNoParams); message CM_TEXTCHANGED;
procedure CMSysColorChange(var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMParentColorChanged(var Message: TWMNoParams); message CM_PARENTCOLORCHANGED;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMMove(var Message: TWMMove); message WM_MOVE;
property ColorBorder: TColor index 0 read FBorderColor write SetColors default DefaultBorderColor;
property BackgropStartColor: TColor index 1 read FBackgropStartColor write SetColors default DefaultColorStart;
property BackgropStopColor: TColor index 2 read FBackgropStopColor write SetColors default DefaultColorStop;
property BackgropOrien: TStyleOrien read FBackgropOrien write SetBackgropOrien default bsHorizontal;
property StyleFace: TStyleFace read FStyleFace write SetStyleFace default fsDefault;
property Border: TGroupBoxBorder read FBorder write SetBorder default brFull;
property Transparent: Boolean read FTransparent write SetTransparent default false;
property Alignment: TAlignmentText read FAlignment write SetAlignment default stLeft;
public
constructor Create(AOwner: TComponent); override;
end;
{ TDefineGroupBox }
TFlatGroupBox = class(TDefineGroupBox)
published
property Action;
property Transparent;
property Alignment;
property Align;
property Cursor;
property Caption;
property Font;
property ParentFont;
property Color;
property ParentColor;
property PopupMenu;
property ShowHint;
property ParentShowHint;
property Enabled;
property Visible;
property TabOrder;
property TabStop;
property Hint;
property HelpContext;
property ColorBorder;
property BackgropStartColor;
property BackgropStopColor;
property BackgropOrien;
property StyleFace;
property Border;
property Anchors;
property Constraints;
property DragKind;
property DragMode;
property DragCursor;
property ParentBiDiMode;
property DockSite;
property OnEndDock;
property OnStartDock;
property OnDockDrop;
property OnDockOver;
property OnGetSiteInfo;
property OnUnDock;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -