⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suiscrollbar.pas

📁 SUIPack v6.40.Full.Source for Delphi 5 - 2009 (实际上 2010 上也能编译通过)
💻 PAS
📖 第 1 页 / 共 2 页
字号:
////////////////////////////////////////////////////////////////////////////////
//
//
//  FileName    :   SUIScrollBar.pas
//  Creator     :   Shen Min
//  Date        :   2003-03-26 V1-V3
//                  2003-07-02 V4
//                  2006-06-14 V6
//  Comment     :
//
//  Copyright (c) 2002-2006 Sunisoft
//  http://www.sunisoft.com
//  Email: support@sunisoft.com
//
////////////////////////////////////////////////////////////////////////////////

unit SUIScrollBar;

interface

{$I SUIPack.inc}

uses Windows, ExtCtrls, Classes, Controls, SysUtils, Graphics, Forms, Messages,
     Math,
     SUIProgressBar, SUITrackBar, SUIButton, SUIThemes, SUIMgr, SUI2Define;

type
    TsuiScrollBar = class(TCustomPanel)
    private
        m_TrackBar : TsuiScrollTrackBar;
        m_Btn1 : TsuiImageButton;
        m_Btn2 : TsuiImageButton;
        m_SliderLeft : TBitmap;
        m_SliderCenter : TBitmap;
        m_SliderRight : TBitmap;

        m_UIStyle : TsuiUIStyle;
        m_FileTheme : TsuiFileTheme;
        m_Orientation : TsuiProgressBarOrientation;
        m_SmallChange : TScrollBarInc;
        m_LineButton: Integer;

        procedure SetOrientation(const Value: TsuiProgressBarOrientation);
        procedure SetUIStyle(const Value: TsuiUIStyle);

        procedure PlaceTrackBarAndButton();
        procedure UpdatePictures();
        procedure UpdateSliderPic();

        function GetMax: Integer;
        function GetMin: Integer;
        function GetPosition: Integer;
        procedure SetMax(const Value: Integer);
        procedure SetMin(const Value: Integer);
        procedure SetPosition(const Value: Integer);
        function GetLargeChange: TScrollBarInc;
        procedure SetLargeChange(const Value: TScrollBarInc);
        function GetPageSize: Integer;
        procedure SetPageSize(const Value: Integer);
        function GetSliderVisible: Boolean;
        procedure SetSliderVisible(const Value: Boolean);
        function GetOnChange: TNotifyEvent;
        procedure SetOnChange(const Value: TNotifyEvent);
        procedure SetFileTheme(const Value: TsuiFileTheme);

        procedure MouseContinuouslyDownDec(Sender : TObject);
        procedure MouseContinuouslyDownInc(Sender : TObject);

        procedure WMSIZE(var Msg : TMessage); message WM_SIZE;
        procedure WMERASEBKGND( var Msg : TMessage); message WM_ERASEBKGND;
        procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
        procedure CMVisibleChanged(var Message: TMessage); message CM_VISIBLECHANGED;
        procedure SetLineButton(const Value: Integer);
        function GetLastChange: Integer;

    protected
        procedure Resize(); override;
        procedure Notification(AComponent: TComponent; Operation: TOperation); override;

    public
        constructor Create(AOwner : TComponent); override;
        destructor Destroy(); override;

        property SliderVisible : Boolean read GetSliderVisible write SetSliderVisible;
        property LastChange : Integer read GetLastChange;

    published
        property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
        property LineButton : Integer read m_LineButton write SetLineButton;
        property Orientation : TsuiProgressBarOrientation read m_Orientation write SetOrientation;
        property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
        property Max : Integer read GetMax write SetMax;
        property Min : Integer read GetMin write SetMin;
        property Position : Integer read GetPosition write SetPosition;
        property SmallChange : TScrollBarInc read m_SmallChange write m_SmallChange;
        property LargeChange : TScrollBarInc read GetLargeChange write SetLargeChange;
        property PageSize : Integer read GetPageSize write SetPageSize;

        property Align;
        property Anchors;
        property BiDiMode;
        property Color;
        property Constraints;
        property DragCursor;
        property DragKind;
        property DragMode;
        property Enabled;
        property ParentBiDiMode;
        property ParentColor;
        property ParentShowHint;
        property PopupMenu;
        property ShowHint;
        property Visible;

        property OnChange : TNotifyEvent read GetOnChange write SetOnChange;
        property OnContextPopup;
        property OnDragDrop;
        property OnDragOver;
        property OnEndDock;
        property OnEndDrag;
        property OnEnter;
        property OnExit;
        property OnStartDock;
        property OnStartDrag;

    end;

implementation

uses SUIPublic;

{ TsuiScrollBar }

procedure TsuiScrollBar.CMColorChanged(var Message: TMessage);
begin
    if m_TrackBar <> nil then
        m_TrackBar.Color := Color;
end;

procedure TsuiScrollBar.CMVisibleChanged(var Message: TMessage);
begin
    inherited;

    m_TrackBar.Visible := Visible;
    m_Btn1.Visible := Visible;
    m_Btn2.Visible := Visible;
end;

constructor TsuiScrollBar.Create(AOwner: TComponent);
begin
    inherited;

    ControlStyle := ControlStyle - [csAcceptsControls];
    m_SliderLeft := TBitmap.Create();
    m_SliderCenter := TBitmap.Create();
    m_SliderRight := TBitmap.Create();

    m_TrackBar := TsuiScrollTrackBar.Create(self);
    m_TrackBar.Parent := self;
    m_TrackBar.ShowTick := false;
    m_TrackBar.TabStop := false;
    m_TrackBar.Transparent := false;
    m_TrackBar.Max := 100;

    m_Btn1 := TsuiImageButton.Create(self);
    m_Btn1.Parent := self;
    m_Btn1.OnMouseContinuouslyDown := MouseContinuouslyDownInc;
    m_Btn1.MouseContinuouslyDownInterval := 100;
    m_Btn1.TabStop := false;
    m_Btn2 := TsuiImageButton.Create(self);
    m_Btn2.Parent := self;
    m_Btn2.OnMouseContinuouslyDown := MouseContinuouslyDownDec;
    m_Btn2.MouseContinuouslyDownInterval := 100;
    m_Btn2.TabStop := false;

    BevelOuter := bvNone;
    BevelInner := bvNone;

    Orientation := suiHorizontal;
    m_SmallChange := 1;
    m_LineButton := 0;
    Height := 185;

    UIStyle := GetSUIFormStyle(AOwner);
    PlaceTrackBarAndButton();
end;

destructor TsuiScrollBar.Destroy;
begin
    m_Btn2.Free();
    m_Btn1.Free();
    m_TrackBar.Free();
    m_SliderRight.Free();
    m_SliderCenter.Free();
    m_SliderLeft.Free();

    inherited;
end;

function TsuiScrollBar.GetLargeChange: TScrollBarInc;
begin
    Result := m_TrackBar.PageSize;
end;

function TsuiScrollBar.GetLastChange: Integer;
begin
    Result := m_TrackBar.LastChange;
end;

function TsuiScrollBar.GetMax: Integer;
begin
    Result := m_TrackBar.Max;
end;

function TsuiScrollBar.GetMin: Integer;
begin
    Result := m_TrackBar.Min;
end;

function TsuiScrollBar.GetOnChange: TNotifyEvent;
begin
    Result := m_TrackBar.OnChange;
end;

function TsuiScrollBar.GetPageSize: Integer;
begin
    Result := m_TrackBar.PageSize;
end;

function TsuiScrollBar.GetPosition: Integer;
begin
    Result := m_TrackBar.Position;
end;

function TsuiScrollBar.GetSliderVisible: Boolean;
begin
    Result := m_TrackBar.SliderVisible
end;

procedure TsuiScrollBar.MouseContinuouslyDownDec(Sender: TObject);
begin
    m_TrackBar.Position := m_TrackBar.Position - m_SmallChange;
end;

procedure TsuiScrollBar.MouseContinuouslyDownInc(Sender: TObject);
begin
    m_TrackBar.Position := m_TrackBar.Position + m_SmallChange;
end;

procedure TsuiScrollBar.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
    inherited;
    if (
        (Operation = opRemove) and
        (AComponent = m_FileTheme)
    )then
    begin
        m_FileTheme := nil;
        SetUIStyle(SUI_THEME_DEFAULT);          
    end;
end;

procedure TsuiScrollBar.PlaceTrackBarAndButton;
begin
    m_TrackBar.Orientation := m_Orientation;

    if (Height = 0) or (Width = 0) then
    begin
        Visible := False;
    end
    else
    begin
        if m_Orientation = suiVertical then
        begin
            m_Btn2.Top := 0;
            m_Btn2.Left := 0;
            m_TrackBar.Top := m_Btn2.Height;
            m_TrackBar.Height := Height - m_Btn1.Height - m_Btn2.Height;
            m_TrackBar.Left := 0;
            m_Btn1.Top := Height - m_Btn1.Height;
            m_Btn1.Left := 0;
            Width := m_Btn2.Width;
        end
        else
        begin
            m_Btn2.Left := 0;
            m_Btn2.Top := 0;
            m_TrackBar.Left := m_Btn2.Width;
            m_TrackBar.Width := Width - m_Btn1.Width - m_Btn2.Width;
            m_TrackBar.Top := 0;
            m_Btn1.Left := Width - m_Btn1.Width;
            m_Btn1.Top := 0;
            Height := m_Btn2.Height;
        end;
        UpdateSliderPic();
    end;
end;

procedure TsuiScrollBar.Resize;
begin
    inherited;

    PlaceTrackBarAndButton();
end;

procedure TsuiScrollBar.SetFileTheme(const Value: TsuiFileTheme);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -