?? suidbctrls.pas
字號(hào):
procedure SetBorderColor(const Value: TColor);
procedure DrawButton();
procedure DrawArrow(const ACanvas : TCanvas;X, Y : Integer);
procedure SetArrowColor(const Value: TColor);
procedure SetButtonColor(const Value: TColor);
procedure SetUIStyle(const Value: TsuiUIStyle);
procedure SetFileTheme(const Value: TsuiFileTheme);
protected
procedure SetEnabled(Value: Boolean); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Paint(); override;
public
constructor Create(AOwner : TComponent); override;
published
property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
property BorderColor : TColor read m_BorderColor write SetBorderColor;
property ArrowColor : TColor read m_ArrowColor write SetArrowColor;
property ButtonColor : TColor read m_ButtonColor write SetButtonColor;
end;
const
InitRepeatPause = 400; { pause before repeat timer (ms) }
RepeatPause = 100; { pause before hint window displays (ms)}
SpaceSize = 5; { size of space between special buttons }
type
TsuiNavButton = class;
TsuiNavDataLink = class;
ENavClick = procedure (Sender: TObject; Button: TNavigateBtn) of object;
{ TsuiDBNavigator }
TsuiDBNavigator = class (TCustomPanel)
private
m_UIStyle : TsuiUIStyle;
m_FileTheme : TsuiFileTheme;
m_Cursor : TCursor;
FDataLink: TsuiNavDataLink;
FVisibleButtons: TButtonSet;
FHints: TStrings;
FDefHints: TStrings;
ButtonWidth: Integer;
MinBtnSize: TPoint;
FOnNavClick: ENavClick;
FBeforeAction: ENavClick;
FocusedButton: TNavigateBtn;
FConfirmDelete: Boolean;
procedure BtnMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ClickHandler(Sender: TObject);
function GetDataSource: TDataSource;
function GetHints: TStrings;
procedure HintsChanged(Sender: TObject);
procedure InitButtons;
procedure InitHints;
procedure SetDataSource(Value: TDataSource);
procedure SetHints(Value: TStrings);
procedure SetSize(var W: Integer; var H: Integer);
procedure SetVisible(Value: TButtonSet);
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
procedure SetUIStyle(const Value: TsuiUIStyle);
procedure SetFileTheme(const Value: TsuiFileTheme);
procedure SetCursor(const Value: TCursor);
protected
Buttons: array[TNavigateBtn] of TsuiNavButton;
procedure DataChanged;
procedure EditingChanged;
procedure ActiveChanged;
procedure Loaded; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
procedure CalcMinSize(var W, H: Integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
procedure BtnClick(Index: TNavigateBtn); virtual;
published
property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property VisibleButtons: TButtonSet read FVisibleButtons write SetVisible
default [nbFirst, nbPrior, nbNext, nbLast, nbInsert, nbDelete,
nbEdit, nbPost, nbCancel, nbRefresh];
property Cursor : TCursor read m_Cursor write SetCursor;
property Align;
property Anchors;
property Constraints;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Hints: TStrings read GetHints write SetHints;
property ParentCtl3D;
property ParentShowHint;
property PopupMenu;
property ConfirmDelete: Boolean read FConfirmDelete write FConfirmDelete default True;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property BeforeAction: ENavClick read FBeforeAction write FBeforeAction;
property OnClick: ENavClick read FOnNavClick write FOnNavClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnResize;
property OnStartDock;
property OnStartDrag;
end;
{ TsuiNavButton }
TsuiNavButton = class(TsuiButton)
private
FIndex: TNavigateBtn;
FNavStyle: TNavButtonStyle;
FRepeatTimer: TTimer;
procedure TimerExpired(Sender: TObject);
protected
procedure Paint; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
property NavStyle: TNavButtonStyle read FNavStyle write FNavStyle;
property Index : TNavigateBtn read FIndex write FIndex;
end;
{ TsuiNavDataLink }
TsuiNavDataLink = class(TDataLink)
private
FNavigator: TsuiDBNavigator;
protected
procedure EditingChanged; override;
procedure DataSetChanged; override;
procedure ActiveChanged; override;
public
constructor Create(ANav: TsuiDBNavigator);
destructor Destroy; override;
end;
TsuiDBGrid = class(TDBGrid)
private
m_BorderColor : TColor;
m_FocusedColor : TColor;
m_SelectedColor : TColor;
m_UIStyle : TsuiUIStyle;
m_FileTheme : TsuiFileTheme;
procedure SetBorderColor(const Value: TColor);
procedure WMEARSEBKGND(var Msg : TMessage); message WM_ERASEBKGND;
procedure SetUIStyle(const Value: TsuiUIStyle);
procedure SetFileTheme(const Value: TsuiFileTheme);
procedure SetFocusedColor(const Value: TColor);
procedure SetSelectedColor(const Value: TColor);
function GetFontColor: TColor;
procedure SetFontColor(const Value: TColor);
function GetTitleFontColor: TColor;
procedure SetTitleFontColor(const Value: TColor);
function GetFixedBGColor: TColor;
procedure SetFixedBGColor(const Value: TColor);
function GetBGColor: TColor;
procedure SetBGColor(const Value: TColor);
protected
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
procedure Paint(); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create (AOwner: TComponent); override;
published
property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
property BorderColor : TColor read m_BorderColor write SetBorderColor;
property FocusedColor : TColor read m_FocusedColor write SetFocusedColor;
property SelectedColor : TColor read m_SelectedColor write SetSelectedColor;
property FontColor : TColor read GetFontColor write SetFontColor;
property TitleFontColor : TColor read GetTitleFontColor write SetTitleFontColor;
property FixedBGColor : TColor read GetFixedBGColor write SetFixedBGColor;
property BGColor : TColor read GetBGColor write SetBGColor;
end;
implementation
uses SUIPublic, SUIProgressBar;
{ TsuiDBEdit }
constructor TsuiDBEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csOpaque];
BorderStyle := bsNone;
BorderWidth := 2;
UIStyle := GetSUIFormStyle(AOwner);
end;
procedure TsuiDBEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (
(Operation = opRemove) and
(AComponent = m_FileTheme)
)then
begin
m_FileTheme := nil;
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
procedure TsuiDBEdit.WMPaint(var Message: TWMPaint);
begin
inherited;
DrawControlBorder(self, m_BorderColor, Color);
end;
procedure TsuiDBEdit.WMEARSEBKGND(var Msg: TMessage);
begin
inherited;
DrawControlBorder(self, m_BorderColor, Color);
end;
procedure TsuiDBEdit.SetFileTheme(const Value: TsuiFileTheme);
begin
m_FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
procedure TsuiDBEdit.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
begin
m_UIStyle := Value;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
m_BorderColor := m_FileTheme.GetColor(SUI_THEME_CONTROL_BORDER_COLOR)
else
m_BorderColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_CONTROL_BORDER_COLOR);
Repaint();
end;
procedure TsuiDBEdit.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
Repaint();
end;
{ TsuiDBMemo }
constructor TsuiDBMemo.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle + [csOpaque];
BorderStyle := bsNone;
BorderWidth := 2;
m_SelfChanging := false;
m_UserChanging := false;
m_MouseDown := false;
UIStyle := GetSUIFormStyle(AOwner);
end;
procedure TsuiDBMemo.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if AComponent = nil then
Exit;
if (
(Operation = opRemove) and
(AComponent = m_HScrollBar)
)then
begin
m_HScrollBar := nil;
UpdateInnerScrollBars();
end;
if (
(Operation = opRemove) and
(AComponent = m_VScrollBar)
)then
begin
m_VScrollBar := nil;
UpdateInnerScrollBars();
end;
if (
(Operation = opRemove) and
(AComponent = m_FileTheme)
)then
begin
m_FileTheme := nil;
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
procedure TsuiDBMemo.WMCut(var Message: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBMemo.WMUndo(var Message: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBMemo.WMPaste(var Message: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBMemo.WMPaint(var Msg : TMessage);
begin
inherited;
DrawControlBorder(self, m_BorderColor, Color);
end;
procedure TsuiDBMemo.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
Repaint();
end;
procedure TsuiDBMemo.WMEARSEBKGND(var Msg: TMessage);
begin
inherited;
DrawControlBorder(self, m_BorderColor, Color);
end;
procedure TsuiDBMemo.CMEnabledChanged(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBMemo.OnHScrollBarChange(Sender: TObject);
begin
if m_SelfChanging then
Exit;
m_UserChanging := true;
SendMessage(Handle, WM_HSCROLL, MakeWParam(SB_THUMBPOSITION, m_HScrollBar.Position), 0);
Invalidate;
m_UserChanging := false;
end;
procedure TsuiDBMemo.OnVScrollBarChange(Sender: TObject);
begin
if m_SelfChanging then
Exit;
m_UserChanging := true;
SendMessage(Handle, WM_VSCROLL, MakeWParam(SB_THUMBPOSITION, m_VScrollBar.Position), 0);
Invalidate;
m_UserChanging := false;
end;
procedure TsuiDBMemo.SetHScrollBar(const Value: TsuiScrollBar);
begin
if m_HScrollBar = Value then
Exit;
if m_HScrollBar <> nil then
begin
m_HScrollBar.OnChange := nil;
m_HScrollBar.LineButton := 0;
m_HScrollBar.Max := 100;
m_HScrollBar.Enabled := true;
end;
m_HScrollBar := Value;
if m_HScrollBar = nil then
begin
UpdateInnerScrollBars();
Exit;
end;
m_HScrollBar.Orientation := suiHorizontal;
m_HScrollBar.OnChange := OnHScrollBarChange;
m_HScrollBar.BringToFront();
UpdateInnerScrollBars();
UpdateScrollBarsPos();
end;
procedure TsuiDBMemo.SetVScrollBar(const Value: TsuiScrollBar);
begin
if m_VScrollBar = Value then
Exit;
if m_VScrollBar <> nil then
begin
m_VScrollBar.OnChange := nil;
m_VScrollBar.LineButton := 0;
m_VScrollBar.Max := 100;
m_VScrollBar.Enabled := true;
end;
m_VScrollBar := Value;
if m_VScrollBar = nil then
begin
UpdateInnerScrollBars();
Exit;
end;
m_VScrollBar.Orientation := suiVertical;
m_VScrollBar.OnChange := OnVScrollBArChange;
m_VScrollBar.BringToFront();
UpdateInnerScrollBars();
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -