📄 bsdialogs.pas
字号:
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.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 := [];
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);
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;
FExecute := True;
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;
begin
inherited CreateNew(AOwner);
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 := 5;
Top := 50;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_COLOR')
else
Caption := BS_FONTDLG_COLOR;
AutoSize := True;
Parent := Self;
end;
FontColorBox := TbsSkinColorComboBox.Create(Self);
with FontColorBox do
begin
Left := 5;
Top := 65;
Width := 90;
DefaultHeight := 21;
Parent := Self;
ShowNames := False;
ExStyle := [bscbCustomColor, bscbPrettyNames, bscbStandardColors];;
OnChange := FontColorChange;
end;
FontNameLabel := TbsSkinStdLabel.Create(Self);
with FontNameLabel do
begin
Left := 5;
Top := 5;
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 := 5;
Top := 20;
Width := 200;
DefaultHeight := 21;
Parent := Self;
PopulateList;
TabOrder := 0;
TabStop := True;
OnChange := FontNameChange;
end;
FontSizeLabel := TbsSkinStdLabel.Create(Self);
with FontSizeLabel do
begin
Left := 5;
Top := 95;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_SIZE')
else
Caption := BS_FONTDLG_SIZE;
AutoSize := True;
Parent := Self;
end;
FontSizeEdit := TbsSkinSpinEdit.Create(Self);
with FontSizeEdit do
begin
MinValue := -128;
MaxValue := 128;
Increment := 2;
Left := 5;
Top := 110;
Parent := Self;
Width := 90;
OnChange := FontSizeChange;
end;
FontHeightLabel := TbsSkinStdLabel.Create(Self);
with FontHeightLabel do
begin
Left := 110;
Top := 95;
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 := 110;
Top := 110;
Width := 95;
Parent := Self;
OnChange := FontHeightChange;
end;
ScriptLabel := TbsSkinStdLabel.Create(Self);
with ScriptLabel do
begin
Left := 5;
Top := 140;
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 := 5;
Top := 155;
Width := 200;
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
begin
Left := 210;
Top := 50;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_EXAMPLE')
else
Caption := BS_FONTDLG_EXAMPLE;
AutoSize := True;
Parent := Self;
end;
FontExamplePanel := TbsSkinPanel.Create(Self);
with FontExamplePanel do
begin
Parent := Self;
BorderStyle := bvFrame;
Left := 210;
Top := 65;
Width := 185;
Height := 67;
end;
FontExampleLabel := TLabel.Create(Self);
with FontExampleLabel do
begin
Parent := FontExamplePanel;
Transparent := True;
Align := alClient;
Caption := 'AaBbYyZz';
end;
OkButton := TbsSkinButton.Create(Self);
with OkButton do
begin
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('MSG_BTN_OK')
else
Caption := BS_MSG_BTN_OK;
CanFocused := True;
Left := 225;
Top := 190;
Width := 75;
DefaultHeight := 25;
Parent := Self;
ModalResult := mrOk;
end;
CancelButton := TbsSkinButton.Create(Self);
with CancelButton do
begin
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('MSG_BTN_CANCEL')
else
Caption := BS_MSG_BTN_CANCEL;
CanFocused := True;
Left := 315;
Top := 190;
Width := 75;
DefaultHeight := 25;
Parent := Self;
ModalResult := mrCancel;
Cancel := True;
end;
FontStyleLabel := TbsSkinStdLabel.Create(Self);
with FontStyleLabel do
begin
Left := 210;
Top := 5;
if ResStrData <> nil
then
Caption := ResStrData.GetResStr('FONTDLG_STYLE')
else
Caption := BS_FONTDLG_STYLE;
AutoSize := True;
Parent := Self;
end;
BoldButton := TbsSkinSpeedButton.Create(Self);
with BoldButton do
begin
Parent := Self;
AllowAllUp := True;
DefaultWidth := 25;
DefaultHeight := 25;
SkinDataName := 'toolbutton';
GroupIndex := 1;
NumGlyphs := 1;
Left := 245;
Top := 20;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -