📄 bsdialogs.pas
字号:
FProgressAnimation := True;
FShowType := stStayOnTop;
FShowCancelButton := True;
FShowCloseButton := True;
FAlphaBlend := False;
FAlphaBlendAnimation := False;
FAlphaBlendValue := 200;
Form := nil;
Gauge := nil;
FExecute := False;
FMinValue := 0;
FMaxValue := 100;
FValue := 0;
FCaption := 'Process';
FLabelCaption := 'Name of process:';
FShowPercent := True;
FButtonSkinDataName := 'button';
FLabelSkinDataName := 'stdlabel';
FGaugeSkinDataName := 'gauge';
FDefaultLabelFont := TFont.Create;
FDefaultButtonFont := TFont.Create;
FDefaultGaugeFont := TFont.Create;
FUseSkinFont := True;
with FDefaultLabelFont do
begin
Name := 'Arial';
Style := [];
Height := 14;
end;
with FDefaultButtonFont do
begin
Name := 'Arial';
Style := [];
Height := 14;
end;
with FDefaultGaugeFont do
begin
Name := 'Arial';
Style := [];
Height := 14;
end;
end;
destructor TbsSkinProgressDialog.Destroy;
begin
FDefaultLabelFont.Free;
FDefaultButtonFont.Free;
FDefaultGaugeFont.Free;
inherited;
end;
procedure TbsSkinProgressDialog.SetValue(AValue: Integer);
begin
FValue := AValue;
if FExecute
then
begin
Gauge.Value := FValue;
if Gauge.Value = Gauge.MaxValue
then
if FShowType = stModal
then
Form.ModalResult := mrOk
else
Form.Close;
end;
end;
procedure TbsSkinProgressDialog.Close;
begin
Form.Close;
end;
procedure TbsSkinProgressDialog.SetDefaultLabelFont;
begin
FDefaultLabelFont.Assign(Value);
end;
procedure TbsSkinProgressDialog.SetDefaultGaugeFont;
begin
FDefaultGaugeFont.Assign(Value);
end;
procedure TbsSkinProgressDialog.SetDefaultButtonFont;
begin
FDefaultButtonFont.Assign(Value);
end;
procedure TbsSkinProgressDialog.Notification;
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
end;
procedure TbsSkinProgressDialog.OnFormShow(Sender: TObject);
begin
if Assigned(FOnShow) then FOnShow(Self);
end;
procedure TbsSkinProgressDialog.CancelBtnClick(Sender: TObject);
begin
Form.Close;
if Assigned(FOnCancel) then FOnCancel(Self);
end;
procedure TbsSkinProgressDialog.OnFormClose;
begin
FExecute := False;
Gauge := nil;
Form := nil;
if Value <> MaxValue
then
if Assigned(FOnCancel) then FOnCancel(Self);
Action := caFree;
end;
function TbsSkinProgressDialog.Execute;
var
BSF: TbsBusinessSkinForm;
Prompt: TbsSkinStdLabel;
DialogUnits: TPoint;
ButtonWidth, ButtonHeight: Integer;
begin
if FExecute then Exit;
Form := TForm.Create(Application);
Form.BorderStyle := bsDialog;
if FShowType = stStayOnTop
then
begin
Form.FormStyle := fsStayOnTop;
Form.OnClose := OnFormClose;
end;
Form.Caption := FCaption;
Form.Position := poScreenCenter;
Form.OnShow := OnFormShow;
BSF := TbsBusinessSkinForm.Create(Form);
BSF.BorderIcons := [];
if not FShowCloseButton then BSF.HideCaptionButtons := True;
BSF.SkinData := SkinData;
BSF.MenusSkinData := CtrlSkinData;
BSF.AlphaBlend := AlphaBlend;
BSF.AlphaBlendAnimation := AlphaBlendAnimation;
BSF.AlphaBlendValue := AlphaBlendValue;
try
with Form do
begin
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
ClientWidth := MulDiv(180, DialogUnits.X, 4);
end;
Prompt := TbsSkinStdLabel.Create(Form);
with Prompt do
begin
Parent := Form;
Left := MulDiv(8, DialogUnits.X, 4);
Top := MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
WordWrap := False;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinDataName := FLabelSkinDataName;
SkinData := CtrlSkinData;
Caption := FLabelCaption;
end;
Gauge := TbsSkinGauge.Create(Form);
with Gauge do
begin
Parent := Form;
MinValue := FMinValue;
MaxValue := FMaxValue;
ShowPercent := FShowPercent;
Value := FValue;
DefaultFont := DefaultGaugeFont;
UseSkinFont := Self.UseSkinFont;
Left := Prompt.Left;
Top := Prompt.Top + Prompt.Height + 5;
DefaultWidth := MulDiv(164, DialogUnits.X, 4);
SkinDataName := FGaugeSkinDataName;
SkinData := CtrlSkinData;
end;
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
if FShowCancelButton
then
begin
with TbsSkinButton.Create(Form) do
begin
Parent := Form;
DefaultFont := DefaultButtonFont;
UseSkinFont := Self.UseSkinFont;
if (CtrlSkinData <> nil) and (CtrlSkinData.ResourceStrData <> nil)
then
Caption := CtrlSkinData.ResourceStrData.GetResStr('MSG_BTN_CANCEL')
else
Caption := BS_MSG_BTN_CANCEL;
if FShowType = stStayOnTop then OnClick := CancelBtnClick;
ModalResult := mrCancel;
Cancel := True;
SetBounds(Gauge.Left + Gauge.Width - ButtonWidth, Gauge.Top + Gauge.Height + 15,
ButtonWidth, ButtonHeight);
DefaultHeight := ButtonHeight;
SkinDataName := FButtonSkinDataName;
SkinData := CtrlSkinData;
Form.ClientHeight := Top + Height + 13;
end;
end
else
Form.ClientHeight := Gauge.Top + Gauge.Height + 15;
FExecute := True;
Gauge.ProgressAnimationPause := Self.ProgressAnimationPause;
if Self.ProgressAnimation
then
Gauge.StartProgressAnimation;
if FShowType = stModal
then
begin
if Form.ShowModal = mrOk then Result := True else Result := False;
FExecute := False;
end
else
begin
Form.Show;
end;
finally
if FShowType = stModal
then
begin
Form.Free;
Gauge := nil;
Form := nil;
end;
end;
end;
constructor TbsFontDlgForm.CreateEx;
var
I: Integer;
ResStrData: TbsResourceStrData;
OffsetY: Integer;
begin
inherited CreateNew(AOwner);
if AShowScript then OffsetY := 45 else OffsetY := 0;
if (ACtrlSkinData <> nil) and (ACtrlSkinData.ResourceStrData <> nil)
then
ResStrData := ACtrlSkinData.ResourceStrData
else
ResStrData := nil;
KeyPreview := True;
BorderStyle := bsDialog;
Position := poScreenCenter;
BSF := TbsBusinessSkinForm.Create(Self);
FontColorLabel := TbsSkinStdLabel.Create(Self);
with FontColorLabel do
begin
Left := 10;
Top := 50 - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_COLOR')
else
Caption := BS_FONTDLG_COLOR;
AutoSize := True;
Parent := Self;
end;
FontColorBox := TbsSkinTextColorButton.Create(Self);
with FontColorBox do
begin
Left := 10;
Top := 65;
Width := 70;
DefaultHeight := 21;
Parent := Self;
ShowAutoColor := False;
InitColors;
SkinDataName := 'resizetoolbutton';
OnChangeColor := FontColorChange;
end;
FontNameLabel := TbsSkinStdLabel.Create(Self);
with FontNameLabel do
begin
Left := 10;
Top := 5 - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_NAME')
else
Caption := BS_FONTDLG_NAME;
AutoSize := True;
Parent := Self;
end;
FontNameBox := TbsSkinFontComboBox.Create(Self);
with FontNameBox do
begin
Left := 10;
Top := 20;
Width := 240;
DefaultHeight := 21;
Parent := Self;
PopulateList;
TabOrder := 0;
TabStop := True;
OnChange := FontNameChange;
end;
FontSizeLabel := TbsSkinStdLabel.Create(Self);
with FontSizeLabel do
begin
Left := 100;
Top := 50 - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_SIZE')
else
Caption := BS_FONTDLG_SIZE;
AutoSize := True;
Parent := Self;
end;
FontSizeEdit := TbsSkinFontSizeComboBox.Create(Self);
with FontSizeEdit do
begin
Left := 100;
Top := 65;
Parent := Self;
Width := 60;
Style := bscbEditStyle;
OnChange := FontSizeChange;
end;
FontHeightLabel := TbsSkinStdLabel.Create(Self);
with FontHeightLabel do
begin
Left := 100;
Top := 50 - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_HEIGHT')
else
Caption := BS_FONTDLG_Height;
AutoSize := True;
Parent := Self;
end;
FontHeightEdit := TbsSkinSpinEdit.Create(Self);
with FontHeightEdit do
begin
MinValue := -500;
MaxValue := 500;
Left := 100;
Top := 65;
Width := 60;
Parent := Self;
OnChange := FontHeightChange;
end;
ScriptLabel := TbsSkinStdLabel.Create(Self);
with ScriptLabel do
begin
Left := 10;
Top := 150 - 2;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_SCRIPT')
else
Caption := BS_FONTDLG_SCRIPT;
AutoSize := True;
Parent := Self;
end;
ScriptComboBox := TbsSkinComboBox.Create(Self);
with ScriptComboBox do
begin
Left := 10;
Top := 165;
Width := 240;
DefaultHeight := 21;
Parent := Self;
TabOrder := 4;
TabStop := True;
for I := 0 to 18 do
Items.Add(ScriptNames[I]);
OnChange := FontScriptChange;
end;
FontExLabel := TbsSkinStdLabel.Create(Self);
with FontExLabel do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -