?? suiscrollbar.pas
字號:
m_TrackBar.Top := m_Btn2.Height;
m_TrackBar.Height := Height - m_Btn1.Height - m_Btn2.Height - 1;
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);
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(SUI_THEME_SCROLLBAR_BACKGROUND_COLOR);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_SLIDER_IMAGE, m_SliderLeft, 3, 1);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_SLIDER_IMAGE, m_SliderCenter, 3, 2);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_SLIDER_IMAGE, m_SliderRight, 3, 3);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 1);
if m_Orientation = suiHorizontal then
RoundPicture(TempBmp);
m_Btn2.PicNormal.Bitmap.Assign(TempBmp);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 2);
if m_Orientation = suiHorizontal then
RoundPicture(TempBmp);
m_Btn2.PicMouseOn.Bitmap.Assign(TempBmp);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 3);
if m_Orientation = suiHorizontal then
RoundPicture(TempBmp);
m_Btn2.PicMouseDown.Bitmap.Assign(TempBmp);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 4);
if m_Orientation = suiHorizontal then
RoundPicture(TempBmp);
m_Btn1.PicNormal.Bitmap.Assign(TempBmp);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 5);
if m_Orientation = suiHorizontal then
RoundPicture(TempBmp);
m_Btn1.PicMouseOn.Bitmap.Assign(TempBmp);
m_FileTheme.GetBitmap(SUI_THEME_SCROLLBAR_BUTTON_IMAGE, TempBmp, 6, 6);
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 : TRect;
begin
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 < 18 then
m_LineButton := 18;
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
R := Rect(0, m_SliderLeft.Height, Buf.Width, Buf.Height - m_SliderRight.Height);
Buf.Canvas.Draw(0, R.Bottom, m_SliderRight);
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;
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 + -