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

📄 suiscrollbar.pas

📁 SUIPack v6.40.Full.Source for Delphi 5 - 2009 (实际上 2010 上也能编译通过)
💻 PAS
📖 第 1 页 / 共 2 页
字号:
begin
    m_FileTheme := Value;
    SetUIStyle(m_UIStyle);
end;

procedure TsuiScrollBar.SetLargeChange(const Value: TScrollBarInc);
begin
    m_TrackBar.PageSize := Value;
end;

procedure TsuiScrollBar.SetLineButton(const Value: Integer);
begin
    if m_LineButton = Value then
        Exit;

    if m_Orientation = suiVertical then
    begin
        if Value > Height - m_Btn1.Height - m_Btn2.Height then
            Exit;
    end
    else
    begin
        if Value > Width - m_Btn1.Width - m_Btn2.Width then
            Exit;
    end;

    m_LineButton := Value;
    UpdateSliderPic();
end;

procedure TsuiScrollBar.SetMax(const Value: Integer);
begin
    m_TrackBar.Max := Value;
end;

procedure TsuiScrollBar.SetMin(const Value: Integer);
begin
    m_TrackBar.Min := Value;
end;

procedure TsuiScrollBar.SetOnChange(const Value: TNotifyEvent);
begin
    m_TrackBar.OnChange := Value;
end;

procedure TsuiScrollBar.SetOrientation(const Value: TsuiProgressBarOrientation);
begin
    if m_Orientation = Value then
        Exit;

    m_Orientation := Value;
    UpdatePictures();

    PlaceTrackBarAndButton();
end;

procedure TsuiScrollBar.SetPageSize(const Value: Integer);
begin
    m_TrackBar.PageSize := Value;
    UpdateSliderPic();
end;

procedure TsuiScrollBar.SetPosition(const Value: Integer);
begin
    if m_TrackBar.Position = Value then
        Exit;
    m_TrackBar.Position := Value;
end;

procedure TsuiScrollBar.SetSliderVisible(const Value: Boolean);
begin
    if m_TrackBar.SliderVisible <> Value then
        m_TrackBar.SliderVisible := Value;
end;

procedure TsuiScrollBar.SetUIStyle(const Value: TsuiUIStyle);
begin
    m_UIStyle := Value;

    m_TrackBar.Color := Color;
    UpdatePictures();
    PlaceTrackBarAndButton();
end;

procedure TsuiScrollBar.UpdatePictures;
var
    OutUIStyle : TsuiUIStyle;
    TempBmp : TBitmap;
begin
    m_TrackBar.BarImage := nil;
    TempBmp := TBitmap.Create();

    if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
    begin
        Color := m_FileTheme.GetColor(SKIN2_SCROLLBARCOLOR);
        TempBmp.Assign(m_FileTheme.GetBitmap(SKIN2_SCROLLBAR));
        RoundPicture(TempBmp);
        SpitBitmap(TempBmp, m_SliderLeft, 3, 1);
        SpitBitmap(TempBmp, m_SliderCenter, 3, 2);
        SpitBitmap(TempBmp, m_SliderRight, 3, 3);

        m_FileTheme.GetBitmap2(SKIN2_SCROLLBARUPBUTTON, TempBmp, 3, 1);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn2.PicNormal.Bitmap.Assign(TempBmp);
        m_FileTheme.GetBitmap2(SKIN2_SCROLLBARUPBUTTON, TempBmp, 3, 2);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn2.PicMouseOn.Bitmap.Assign(TempBmp);
        m_FileTheme.GetBitmap2(SKIN2_SCROLLBARUPBUTTON, TempBmp, 3, 3);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn2.PicMouseDown.Bitmap.Assign(TempBmp);
        m_FileTheme.GetBitmap2(SKIN2_SCROLLBARDOWNBUTTON, TempBmp, 3, 1);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn1.PicNormal.Bitmap.Assign(TempBmp);
        m_FileTheme.GetBitmap2(SKIN2_SCROLLBARDOWNBUTTON, TempBmp, 3, 2);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn1.PicMouseOn.Bitmap.Assign(TempBmp);
        m_FileTheme.GetBitmap2(SKIN2_SCROLLBARDOWNBUTTON, TempBmp, 3, 3);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn1.PicMouseDown.Bitmap.Assign(TempBmp);
    end
    else
    begin
        Color := GetInsideThemeColor(OutUIStyle, SUI_THEME_SCROLLBAR_BACKGROUND_COLOR);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_SLIDER_IMAGE, m_SliderLeft, 3, 1);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_SLIDER_IMAGE, m_SliderCenter, 3, 2);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_SLIDER_IMAGE, m_SliderRight, 3, 3);

        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 1);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn2.PicNormal.Bitmap.Assign(TempBmp);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 2);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn2.PicMouseOn.Bitmap.Assign(TempBmp);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 3);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn2.PicMouseDown.Bitmap.Assign(TempBmp);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 4);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn1.PicNormal.Bitmap.Assign(TempBmp);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 5);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn1.PicMouseOn.Bitmap.Assign(TempBmp);
        GetInsideThemeBitmap(OutUIStyle, SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 6);
        if m_Orientation = suiHorizontal then
            RoundPicture(TempBmp);
        m_Btn1.PicMouseDown.Bitmap.Assign(TempBmp);
    end;

    TempBmp.Free();

    if m_Orientation = suiVertical then
    begin
        RoundPicture3(m_SliderLeft);
        RoundPicture3(m_SliderCenter);
        RoundPicture3(m_SliderRight);
    end;

    m_Btn1.AutoSize := true;
    m_Btn2.AutoSize := true;
    Repaint();
end;

procedure TsuiScrollBar.UpdateSliderPic;
var
    Buf : TBitmap;
    TempPageSize : Integer;
    R, DR, SR : TRect;
    OutUIStyle : TsuiUIStyle;
    H, L : Integer;
    B : Boolean;
begin
    B := false;
    Buf := TBitmap.Create();

    if m_Orientation = suiVertical then
        Buf.Width := m_SliderLeft.Width
    else
        Buf.Height := m_SliderLeft.Height;

    if m_LineButton <= 0 then
    begin
        TempPageSize := PageSize;
        if (TempPageSize < 10) or (TempPageSize > 100) then
            TempPageSize := 10;

        if m_Orientation = suiVertical then
        begin
            if m_TrackBar.Height > 0 then
                Buf.Height := (TempPageSize * m_TrackBar.Height div 100)
        end
        else
        begin
            if m_TrackBar.Width > 0 then
                Buf.Width := (TempPageSize * m_TrackBar.Width div 100)
        end;
    end
    else
    begin
        if m_LineButton < 16 then
            m_LineButton := 16;
        if m_Orientation = suiVertical then
            Buf.Height := m_LineButton
        else
            Buf.Width := m_LineButton;
    end;

    Buf.Canvas.Draw(0, 0, m_SliderLeft);
    if m_Orientation = suiVertical then
    begin
        if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
        begin
            B := true;
            DR := Rect(0, Buf.Height - 3, Buf.Width, Buf.Height);
            SR := Rect(0, m_SliderRight.Height - 3, m_SliderRight.Width, m_SliderRight.Height);
            Buf.Canvas.CopyRect(DR, m_SliderRight.Canvas, SR);
            H := Buf.Height - 6;
            if H < m_SliderCenter.Height then
            begin
                R := Rect(0, 3, Buf.Width, Buf.Height - 3);
                ResizeImage(m_SliderCenter, Buf.Canvas, R);
            end
            else
            begin
                L := 3 + (H - m_SliderCenter.Height) div 2;
                Buf.Canvas.Draw(0, L, m_SliderCenter);
                DR := Rect(0, 3, Buf.Width, L);
                SR := Rect(0, 3, m_SliderLeft.Width, m_SliderLeft.Height);
                Buf.Canvas.CopyRect(DR, m_SliderLeft.Canvas, SR);
                DR := Rect(0, L + m_SliderCenter.Height, Buf.Width, Buf.Height - 3);
                SR := Rect(0, 0, m_SliderRight.Width, m_SliderRight.Height - 3);
                Buf.Canvas.CopyRect(DR, m_SliderRight.Canvas, SR);
            end; 
        end
        else
        begin
            R := Rect(0, m_SliderLeft.Height, Buf.Width, Buf.Height - m_SliderRight.Height);
            Buf.Canvas.Draw(0, R.Bottom, m_SliderRight);
        end;
    end
    else
    begin
        if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
        begin
            B := true;
            DR := Rect(Buf.Width - 3, 0, Buf.Width, Buf.Height);
            SR := Rect(m_SliderRight.Width - 3, 0, m_SliderRight.Width, m_SliderRight.Height);
            Buf.Canvas.CopyRect(DR, m_SliderRight.Canvas, SR);
            H := Buf.Width - 6;
            if H < m_SliderCenter.Width then
            begin
                R := Rect(3, 0, Buf.Width - 3, Buf.Height);
                ResizeImage(m_SliderCenter, Buf.Canvas, R);
            end
            else
            begin
                L := 3 + (H - m_SliderCenter.Width) div 2;
                Buf.Canvas.Draw(L, 0, m_SliderCenter);
                DR := Rect(3, 0, L, Buf.Height);
                SR := Rect(3, 0, m_SliderLeft.Width, m_SliderLeft.Height);
                Buf.Canvas.CopyRect(DR, m_SliderLeft.Canvas, SR);
                DR := Rect(L + m_SliderCenter.Width, 0, Buf.Width - 3, Buf.Height);
                SR := Rect(0, 0, m_SliderRight.Width - 3, m_SliderRight.Height);
                Buf.Canvas.CopyRect(DR, m_SliderRight.Canvas, SR);
            end;
        end
        else
        begin
            R := Rect(m_SliderLeft.Width, 0, Buf.Width - m_SliderRight.Width, Buf.Height);
            Buf.Canvas.Draw(R.Right, 0, m_SliderRight);
        end;
    end;

    if not B then
        Buf.Canvas.StretchDraw(R, m_SliderCenter);

    m_TrackBar.SliderImage.Bitmap.Assign(Buf);
    m_TrackBar.UpdateSliderSize();

    Buf.Free();
end;

procedure TsuiScrollBar.WMERASEBKGND(var Msg: TMessage);
begin
    // do nothing
end;

procedure TsuiScrollBar.WMSIZE(var Msg: TMessage);
begin
    inherited;

    PlaceTrackBarAndButton();
end;

end.

⌨️ 快捷键说明

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