spMessages.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:57k
- {*******************************************************************}
- { }
- { Almediadev Visual Component Library }
- { DynamicSkinForm }
- { Version 4.98 }
- { }
- { Copyright (c) 2000-2002 Almediadev }
- { ALL RIGHTS RESERVED }
- { }
- { Home: http://www.almdev.com }
- { Support: support@almdev.com }
- { }
- {*******************************************************************}
- unit spMessages;
- interface
- uses Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms,
- DynamicSkinForm, SkinData, SkinCtrls, SkinBoxCtrls, Dialogs, StdCtrls, ExtCtrls,
- spSkinShellCtrls;
- type
- TspMessageForm = class(TForm)
- protected
- procedure HelpButtonClick(Sender: TObject);
- public
- DSF: TspDynamicSkinForm;
- Message: TspSkinStdLabel;
- constructor Create(AOwner: TComponent); override;
- end;
- TspSkinMessage = class(TComponent)
- protected
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FButtonSkinDataName: String;
- FMessageLabelSkinDataName: String;
- FDefaultFont: TFont;
- FDefaultButtonFont: TFont;
- FUseSkinFont: Boolean;
- FAlphaBlend: Boolean;
- FAlphaBlendAnimation: Boolean;
- FAlphaBlendValue: Byte;
- procedure SetDefaultFont(Value: TFont);
- procedure SetDefaultButtonFont(Value: TFont);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- function MessageDlg(const Msg: string; DlgType: TMsgDlgType;
- Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property ButtonSkinDataName: String
- read FButtonSkinDataName write FButtonSkinDataName;
- property MessageLabelSkinDataName: String
- read FMessageLabelSkinDataName write FMessageLabelSkinDataName;
- property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
- property DefaultButtonFont: TFont read FDefaultButtonFont write SetDefaultButtonFont;
- property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
- end;
- TspSkinProgressDialog = class(TComponent)
- protected
- FExecute: Boolean;
- Gauge: TspSkinGauge;
- Form: TForm;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FButtonSkinDataName: String;
- FGaugeSkinDataName: String;
- FLabelSkinDataName: String;
- FDefaultLabelFont: TFont;
- FDefaultGaugeFont: TFont;
- FDefaultButtonFont: TFont;
- FUseSkinFont: Boolean;
- FMinValue, FMaxValue, FValue: Integer;
- FCaption: String;
- FLabelCaption: String;
- FShowPercent: Boolean;
- FAlphaBlend: Boolean;
- FAlphaBlendValue: Byte;
- FAlphaBlendAnimation: Boolean;
- procedure SetValue(AValue: Integer);
- procedure SetDefaultLabelFont(Value: TFont);
- procedure SetDefaultButtonFont(Value: TFont);
- procedure SetDefaultGaugeFont(Value: TFont);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- function Execute: Boolean;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property Caption: String read FCaption write FCaption;
- property LabelCaption: String read FLabelCaption write FLabelCaption;
- property ShowPercent: Boolean read FShowPercent write FShowPercent;
- property MinValue: Integer read FMinValue write FMinValue;
- property MaxValue: Integer read FMaxValue write FMaxValue;
- property Value: Integer read FValue write SetValue;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property ButtonSkinDataName: String
- read FButtonSkinDataName write FButtonSkinDataName;
- property LabelSkinDataName: String
- read FLabelSkinDataName write FLabelSkinDataName;
- property GaugeSkinDataName: String
- read FGaugeSkinDataName write FGaugeSkinDataName;
- property DefaultLabelFont: TFont read FDefaultLabelFont write SetDefaultLabelFont;
- property DefaultButtonFont: TFont read FDefaultButtonFont write SetDefaultButtonFont;
- property DefaultGaugeFont: TFont read FDefaultGaugeFont write SetDefaultGaugeFont;
- property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
- end;
- TspSkinInputDialog = class(TComponent)
- protected
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FButtonSkinDataName: String;
- FEditSkinDataName: String;
- FLabelSkinDataName: String;
- FDefaultLabelFont: TFont;
- FDefaultEditFont: TFont;
- FDefaultButtonFont: TFont;
- FUseSkinFont: Boolean;
- FAlphaBlend: Boolean;
- FAlphaBlendValue: Byte;
- FAlphaBlendAnimation: Boolean;
- procedure SetDefaultLabelFont(Value: TFont);
- procedure SetDefaultButtonFont(Value: TFont);
- procedure SetDefaultEditFont(Value: TFont);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- function InputBox(const ACaption, APrompt, ADefault: string): string;
- function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property ButtonSkinDataName: String
- read FButtonSkinDataName write FButtonSkinDataName;
- property LabelSkinDataName: String
- read FLabelSkinDataName write FLabelSkinDataName;
- property EditSkinDataName: String
- read FEditSkinDataName write FEditSkinDataName;
- property DefaultLabelFont: TFont read FDefaultLabelFont write SetDefaultLabelFont;
- property DefaultButtonFont: TFont read FDefaultButtonFont write SetDefaultButtonFont;
- property DefaultEditFont: TFont read FDefaultEditFont write SetDefaultEditFont;
- property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
- end;
- TspFontDlgForm = class(TForm)
- public
- DSF: TspDynamicSkinForm;
- FontNameBox: TspSkinFontComboBox;
- FontColorBox: TspSkinColorComboBox;
- FontSizeEdit: TspSkinSpinEdit;
- FontHeightEdit: TspSkinSpinEdit;
- FontExamplePanel: TspSkinPanel;
- FontExampleLabel: TLabel;
- OkButton, CancelButton: TspSkinButton;
- FontNameLabel, FontColorLabel, FontSizeLabel,
- FontHeightLabel, FontStyleLabel, FontExLabel: TspSkinStdLabel;
- BoldButton, ItalicButton,
- UnderLineButton, StrikeOutButton: TspSkinSpeedButton;
- constructor Create(AOwner: TComponent); override;
- procedure FontSizeChange(Sender: TObject);
- procedure FontHeightChange(Sender: TObject);
- procedure FontNameChange(Sender: TObject);
- procedure FontColorChange(Sender: TObject);
- procedure BoldButtonClick(Sender: TObject);
- procedure ItalicButtonClick(Sender: TObject);
- procedure StrikeOutButtonClick(Sender: TObject);
- procedure UnderLineButtonClick(Sender: TObject);
- end;
- TspSkinFontDialog = class(TComponent)
- private
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TspFontDlgForm;
- FOnChange: TNotifyEvent;
- FFont: TFont;
- FShowSizeEdit, FShowHeightEdit: Boolean;
- FAlphaBlend: Boolean;
- FAlphaBlendAnimation: Boolean;
- FAlphaBlendValue: Byte;
- function GetTitle: string;
- procedure SetTitle(const Value: string);
- procedure SetFont(Value: TFont);
- procedure SetDefaultFont(Value: TFont);
- protected
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure Change;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
- property Font: TFont read FFont write SetFont;
- property Title: string read GetTitle write SetTitle;
- property ShowSizeEdit: Boolean read FShowSizeEdit write FShowSizeEdit;
- property ShowHeightEdit: Boolean read FShowHeightEdit write FShowHeightEdit;
- property OnChange: TnotifyEvent read FOnChange write FOnChange;
- end;
- TspSkinTextDialog = class(TComponent)
- protected
- Memo: TspSkinMemo2;
- FShowToolBar: Boolean;
- FCaption: String;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FButtonSkinDataName: String;
- FMemoSkinDataName: String;
- FDefaultMemoFont: TFont;
- FDefaultButtonFont: TFont;
- FUseSkinFont: Boolean;
- FClientWidth: Integer;
- FClientHeight: Integer;
- FLines: TStrings;
- FSkinOpenDialog: TspSkinOpenDialog;
- FSkinSaveDialog: TspSkinSaveDialog;
- FAlphaBlend: Boolean;
- FAlphaBlendAnimation: Boolean;
- FAlphaBlendValue: Byte;
- procedure SetLines(Value: TStrings);
- procedure SetClientWidth(Value: Integer);
- procedure SetClientHeight(Value: Integer);
- procedure SetDefaultButtonFont(Value: TFont);
- procedure SetDefaultMemoFont(Value: TFont);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- //
- procedure NewButtonClick(Sender: TObject);
- procedure OpenButtonClick(Sender: TObject);
- procedure SaveButtonClick(Sender: TObject);
- procedure CopyButtonClick(Sender: TObject);
- procedure CutButtonClick(Sender: TObject);
- procedure PasteButtonClick(Sender: TObject);
- procedure DeleteButtonClick(Sender: TObject);
- //
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinOpenDialog: TspSkinOpenDialog
- read FSkinOpenDialog write FSkinOpenDialog;
- property SkinSaveDialog: TspSkinSaveDialog
- read FSkinSaveDialog write FSkinSaveDialog;
- property ShowToolBar: Boolean read FShowToolBar write FShowToolBar;
- property Lines: TStrings read FLines write SetLines;
- property ClientWidth: Integer read FClientWidth write SetClientWidth;
- property ClientHeight: Integer read FClientHeight write SetClientHeight;
- property Caption: String read FCaption write FCaption;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property ButtonSkinDataName: String
- read FButtonSkinDataName write FButtonSkinDataName;
- property MemoSkinDataName: String
- read FMemoSkinDataName write FMemoSkinDataName;
- property DefaultButtonFont: TFont read FDefaultButtonFont write SetDefaultButtonFont;
- property DefaultMemoFont: TFont read FDefaultMemoFont write SetDefaultMemoFont;
- property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
- end;
- TspSkinPasswordDialog = class(TComponent)
- protected
- FLoginMode: Boolean;
- FCaption: String;
- FLogin: String;
- FLoginCaption: String;
- FPasswordCaption: String;
- FPassword: String;
- FPasswordChar: Char;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FButtonSkinDataName: String;
- FEditSkinDataName: String;
- FLabelSkinDataName: String;
- FDefaultLabelFont: TFont;
- FDefaultEditFont: TFont;
- FDefaultButtonFont: TFont;
- FAlphaBlend: Boolean;
- FAlphaBlendAnimation: Boolean;
- FAlphaBlendValue: Byte;
- FUseSkinFont: Boolean;
- procedure SetDefaultLabelFont(Value: TFont);
- procedure SetDefaultButtonFont(Value: TFont);
- procedure SetDefaultEditFont(Value: TFont);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property LoginMode: Boolean read FLoginMode write FLoginMode;
- property Login: String read FLogin write FLogin;
- property LoginCaption: String read FLoginCaption write FLoginCaption;
- property Password: String read FPassword write FPassword;
- property PasswordChar: Char read FPasswordChar write FPasswordChar;
- property Caption: String read FCaption write FCaption;
- property PasswordCaption: String read FPasswordCaption write FPasswordCaption;
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property ButtonSkinDataName: String
- read FButtonSkinDataName write FButtonSkinDataName;
- property LabelSkinDataName: String
- read FLabelSkinDataName write FLabelSkinDataName;
- property EditSkinDataName: String
- read FEditSkinDataName write FEditSkinDataName;
- property DefaultLabelFont: TFont read FDefaultLabelFont write SetDefaultLabelFont;
- property DefaultButtonFont: TFont read FDefaultButtonFont write SetDefaultButtonFont;
- property DefaultEditFont: TFont read FDefaultEditFont write SetDefaultEditFont;
- property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
- end;
- implementation
- {$R *.res}
- var
- ButtonNames: array[TMsgDlgBtn] of string = (
- 'Yes', 'No', 'OK', 'Cancel', 'Abort', 'Retry', 'Ignore', 'All', 'NoToAll',
- 'YesToAll', 'Help');
- ButtonCaptions: array[TMsgDlgBtn] of string = (
- '&Yes', '&No', 'OK', 'Cancel', '&Abort', '&Retry', '&Ignore', '&All', 'N&oToAll',
- '&YesToAll', '&Help');
- Captions: array[TMsgDlgType] of string = ('Warning', 'Error',
- 'Information', 'Confirm', '');
- ModalResults: array[TMsgDlgBtn] of Integer = (
- mrYes, mrNo, mrOk, mrCancel, mrAbort, mrRetry, mrIgnore, mrAll, mrNoToAll,
- mrYesToAll, 0);
- IconIDs: array[TMsgDlgType] of PChar = (IDI_EXCLAMATION, IDI_HAND,
- IDI_ASTERISK, IDI_QUESTION, nil);
- const
- MSGFORMBUTTONWIDTH = 40;
- function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType;
- Buttons: TMsgDlgButtons; ASkinData, ACtrlSkinData: TspSkinData;
- AButtonSkinDataName: String; AMessageLabelSkinDataName: String;
- ADefaultFont: TFont; ADefaultButtonFont: TFont; AUseSkinFont: Boolean;
- AAlphaBlend, AAlphaBlendAnimation: Boolean; AAlphaBlendValue: Byte): TspMessageForm;
- var
- BI, ButtonWidth,
- ButtonHeight, ButtonSpacing, ButtonCount, ButtonGroupWidth, X: Integer;
- B, DefaultButton, CancelButton: TMsgDlgBtn;
- IconID: PChar;
- begin
- Result := TspMessageForm.Create(Application);
- with Result do
- begin
- with DSF do
- begin
- SkinData := ASkinData;
- MenusSkinData := ACtrlSkinData;
- AlphaBlend := AAlphaBlend;
- AlphaBlendAnimation := AAlphaBlendAnimation;
- AlphaBlendValue := AAlphaBlendValue;
- end;
- ButtonWidth := 60;
- //
- if (ACtrlSkinData <> nil) and (not ACtrlSkinData.Empty)
- then
- begin
- BI := ACtrlSkinData.GetControlIndex(AButtonSkinDataName);
- if (BI <> -1) and
- (TspDataSkinControl(ACtrlSkinData.CtrlList.Items[BI]) is TspDataSkinButtonControl)
- then
- begin
- with TspDataSkinButtonControl(ACtrlSkinData.CtrlList.Items[BI]) do
- ButtonHeight := SkinRect.Bottom - SkinRect.Top;
- end
- else
- ButtonHeight := 25;
- end
- else
- ButtonHeight := 25;
- //
- ButtonSpacing := 10;
- ButtonCount := 0;
- for B := Low(TMsgDlgBtn) to High(TMsgDlgBtn) do
- if B in Buttons then Inc(ButtonCount);
- ButtonGroupWidth := 0;
- if ButtonCount <> 0 then
- ButtonGroupWidth := ButtonWidth * ButtonCount +
- ButtonSpacing * (ButtonCount - 1);
- Left := (Screen.Width div 2) - (Width div 2);
- Top := (Screen.Height div 2) - (Height div 2);
- if DlgType <> mtCustom
- then Caption := Captions[DlgType]
- else Caption := Application.Title;
- // add icon
- IconID := IconIDs[DlgType];
- with TImage.Create(Result) do
- begin
- Name := 'Image';
- Parent := Result;
- Picture.Icon.Handle := LoadIcon(0, IconID);
- SetBounds(5, 5, 32, 32);
- end;
- // add label
- Result.Message := TspSkinStdLabel.Create(Result);
- with Result.Message do
- begin
- Font := ADefaultFont;
- DefaultFont := ADefaultFont;
- UseSkinFont := AUseSkinFont;
- SkinDataName := AMessageLabelSkinDataName;
- SkinData := ACtrlSkinData;
- AutoSize := True;
- Name := 'Message';
- Parent := Result;
- Caption := Msg;
- Left := 50;
- Top := 10;
- X := Left + Width;
- end;
- ClientHeight := 45 + ButtonHeight + Result.Message.Height;
-
- if ButtonGroupWidth < X
- then
- ClientWidth := X + 10
- else
- ClientWidth := ButtonGroupWidth + 10;
- if Width > Result.DSF.GetMaxWidth
- then
- Width := Result.DSF.GetMaxWidth
- else
- if Width < Result.DSF.GetMinWidth
- then
- Width := Result.DSF.GetMinWidth;
- // add buttons
- if mbOk in Buttons then DefaultButton := mbOk else
- if mbYes in Buttons then DefaultButton := mbYes else
- DefaultButton := mbRetry;
- if mbCancel in Buttons then CancelButton := mbCancel else
- if mbNo in Buttons then CancelButton := mbNo else
- CancelButton := mbOk;
- X := (ClientWidth - ButtonGroupWidth) div 2;
- for B := Low(TMsgDlgBtn) to High(TMsgDlgBtn) do
- if B in Buttons then
- with TspSkinButton.Create(Result) do
- begin
- Parent := Result;
- Name := ButtonNames[B];
- CanFocused := True;
- Caption := ButtonCaptions[B];
- ModalResult := ModalResults[B];
- if B = DefaultButton then Default := True;
- if B = CancelButton then Cancel := True;
- DefaultHeight := ButtonHeight;
- SetBounds(X, Result.ClientHeight - ButtonHeight - 10,
- ButtonWidth, ButtonHeight);
- DefaultFont := ADefaultButtonFont;
- UseSkinFont := AUseSkinFont;
- Inc(X, ButtonWidth + ButtonSpacing);
- if B = mbHelp then
- OnClick := Result.HelpButtonClick;
- SkinDataName := AButtonSkinDataName;
- SkinData := ACtrlSkinData;
- end;
- end;
- end;
- constructor TspMessageForm.Create(AOwner: TComponent);
- begin
- inherited CreateNew(AOwner);
- Position := poScreenCenter;
- BorderStyle := bsDialog;
- KeyPreview := True;
- DSF := TspDynamicSkinForm.Create(Self);
- DSF.BorderIcons := [];
- DSF.SizeAble := False;
- end;
- procedure TspMessageForm.HelpButtonClick(Sender: TObject);
- begin
- Application.HelpContext(HelpContext);
- end;
- constructor TspSkinMessage.Create;
- begin
- inherited Create(AOwner);
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- FButtonSkinDataName := 'button';
- FMessageLabelSkinDataName := 'stdlabel';
- FDefaultFont := TFont.Create;
- FDefaultButtonFont := TFont.Create;
- FUseSkinFont := True;
- with FDefaultFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- with FDefaultButtonFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- end;
- destructor TspSkinMessage.Destroy;
- begin
- FDefaultFont.Free;
- FDefaultButtonFont.Free;
- inherited;
- end;
- procedure TspSkinMessage.SetDefaultButtonFont;
- begin
- FDefaultButtonFont.Assign(Value);
- end;
- function TspSkinMessage.MessageDlg;
- begin
- with CreateMessageDialog(Msg, DlgType, Buttons,
- FSD, FCtrlFSD, FButtonSkinDataName,
- FMessageLabelSkinDataName, FDefaultFont, FDefaultButtonFont, FUseSkinFont,
- FAlphaBlend, FAlphaBlendAnimation, FAlphaBlendValue) do
- try
- Result := ShowModal;
- finally
- Free;
- end;
- end;
- procedure TspSkinMessage.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TspSkinMessage.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;
- constructor TspSkinInputDialog.Create;
- begin
- inherited Create(AOwner);
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
-
- FButtonSkinDataName := 'button';
- FLabelSkinDataName := 'stdlabel';
- FEditSkinDataName := 'edit';
- FDefaultLabelFont := TFont.Create;
- FDefaultButtonFont := TFont.Create;
- FDefaultEditFont := 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 FDefaultEditFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- end;
- destructor TspSkinInputDialog.Destroy;
- begin
- FDefaultLabelFont.Free;
- FDefaultButtonFont.Free;
- FDefaultEditFont.Free;
- inherited;
- end;
- procedure TspSkinInputDialog.SetDefaultLabelFont;
- begin
- FDefaultLabelFont.Assign(Value);
- end;
- procedure TspSkinInputDialog.SetDefaultEditFont;
- begin
- FDefaultEditFont.Assign(Value);
- end;
- procedure TspSkinInputDialog.SetDefaultButtonFont;
- begin
- FDefaultButtonFont.Assign(Value);
- end;
- procedure TspSkinInputDialog.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;
- function GetAveCharSize(Canvas: TCanvas): TPoint;
- var
- I: Integer;
- Buffer: array[0..51] of Char;
- begin
- for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));
- for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
- GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
- Result.X := Result.X div 52;
- end;
- function TspSkinInputDialog.InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
- const
- WS_EX_LAYERED = $80000;
-
- var
- Form: TForm;
- DSF: TspDynamicSkinForm;
- Prompt: TspSkinStdLabel;
- Edit: TspSkinEdit;
- DialogUnits: TPoint;
- ButtonTop, ButtonWidth, ButtonHeight: Integer;
- begin
- Form := TForm.Create(Application);
- Form.BorderStyle := bsDialog;
- Form.Caption := ACaption;
- Form.Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Form);
- DSF.BorderIcons := [];
- DSF.SkinData := SkinData;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.SizeAble := False;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- //
- try
- with Form do
- begin
- Canvas.Font := Font;
- DialogUnits := GetAveCharSize(Canvas);
- ClientWidth := MulDiv(180, DialogUnits.X, 4);
- end;
- Prompt := TspSkinStdLabel.Create(Form);
- with Prompt do
- begin
- Parent := Form;
- Caption := APrompt;
- Left := MulDiv(8, DialogUnits.X, 4);
- Top := MulDiv(8, DialogUnits.Y, 8);
- Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
- WordWrap := True;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinDataName := FLabelSkinDataName;
- SkinData := CtrlSkinData;
- end;
- Edit := TspSkinEdit.Create(Form);
- with Edit do
- begin
- Parent := Form;
- DefaultFont := DefaultEditFont;
- UseSkinFont := Self.UseSkinFont;
- Left := Prompt.Left;
- Top := Prompt.Top + Prompt.Height + 5;
- DefaultWidth := MulDiv(164, DialogUnits.X, 4);
- MaxLength := 255;
- Text := Value;
- SelectAll;
- SkinDataName := FEditSkinDataName;
- SkinData := CtrlSkinData;
- end;
- ButtonTop := Edit.Top + Edit.Height + 15;
- ButtonWidth := MulDiv(50, DialogUnits.X, 4);
- ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
- with TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'OK';
- ModalResult := mrOk;
- Default := True;
- SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
- ButtonHeight);
- DefaultHeight := ButtonHeight;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- end;
- with TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'Cancel';
- ModalResult := mrCancel;
- Cancel := True;
- SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
- ButtonWidth, ButtonHeight);
- DefaultHeight := ButtonHeight;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- Form.ClientHeight := Top + Height + 13;
- end;
- if Form.ShowModal = mrOk
- then
- begin
- Value := Edit.Text;
- Result := True;
- end
- else
- Result := False;
- finally
- Form.Free;
- end;
- end;
- function TspSkinInputDialog.InputBox(const ACaption, APrompt, ADefault: string): string;
- begin
- Result := ADefault;
- InputQuery(ACaption, APrompt, Result);
- end;
- constructor TspSkinProgressDialog.Create;
- begin
- inherited Create(AOwner);
-
- 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 TspSkinProgressDialog.Destroy;
- begin
- FDefaultLabelFont.Free;
- FDefaultButtonFont.Free;
- FDefaultGaugeFont.Free;
- inherited;
- end;
- procedure TspSkinProgressDialog.SetValue(AValue: Integer);
- begin
- FValue := AValue;
- if FExecute
- then
- begin
- Gauge.Value := FValue;
- if Gauge.Value = Gauge.MaxValue
- then Form.ModalResult := mrOk;
- end;
- end;
- procedure TspSkinProgressDialog.SetDefaultLabelFont;
- begin
- FDefaultLabelFont.Assign(Value);
- end;
- procedure TspSkinProgressDialog.SetDefaultGaugeFont;
- begin
- FDefaultGaugeFont.Assign(Value);
- end;
- procedure TspSkinProgressDialog.SetDefaultButtonFont;
- begin
- FDefaultButtonFont.Assign(Value);
- end;
- procedure TspSkinProgressDialog.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;
- function TspSkinProgressDialog.Execute;
- const
- WS_EX_LAYERED = $80000;
-
- var
- DSF: TspDynamicSkinForm;
- Prompt: TspSkinStdLabel;
- DialogUnits: TPoint;
- ButtonWidth, ButtonHeight: Integer;
- begin
- Form := TForm.Create(Application);
- Form.BorderStyle := bsDialog;
- Form.Caption := FCaption;
- Form.Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Form);
- DSF.BorderIcons := [];
- DSF.SkinData := SkinData;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.SizeAble := False;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- //
- try
- with Form do
- begin
- Canvas.Font := Font;
- DialogUnits := GetAveCharSize(Canvas);
- ClientWidth := MulDiv(180, DialogUnits.X, 4);
- end;
- Prompt := TspSkinStdLabel.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 := TspSkinGauge.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 TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'Cancel';
- 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 Form.ShowModal = mrOk then Result := True else Result := False;
- FExecute := False;
- finally
- Form.Free;
- Gauge := nil;
- Form := nil;
- end;
- end;
- constructor TspFontDlgForm.Create(AOwner: TComponent);
- begin
- inherited CreateNew(AOwner);
- KeyPreview := True;
- BorderStyle := bsDialog;
- Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Self);
- FontColorLabel := TspSkinStdLabel.Create(Self);
- with FontColorLabel do
- begin
- Left := 5;
- Top := 50;
- Caption := 'Color:';
- AutoSize := True;
- Parent := Self;
- end;
- FontColorBox := TspSkinColorComboBox.Create(Self);
- with FontColorBox do
- begin
- Left := 5;
- Top := 65;
- Width := 200;
- DefaultHeight := 21;
- Parent := Self;
- ExStyle := [spcbCustomColor, spcbPrettyNames, spcbStandardColors];
- OnChange := FontColorChange;
- end;
- FontNameLabel := TspSkinStdLabel.Create(Self);
- with FontNameLabel do
- begin
- Left := 5;
- Top := 5;
- Caption := 'Name:';
- AutoSize := True;
- Parent := Self;
- end;
- FontNameBox := TspSkinFontComboBox.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 := TspSkinStdLabel.Create(Self);
- with FontSizeLabel do
- begin
- Left := 5;
- Top := 95;
- Caption := 'Size:';
- AutoSize := True;
- Parent := Self;
- end;
- FontSizeEdit := TspSkinSpinEdit.Create(Self);
- with FontSizeEdit do
- begin
- MinValue := -100;
- MaxValue := 100;
- Left := 5;
- Top := 110;
- Parent := Self;
- Width := 95;
- OnChange := FontSizeChange;
- end;
- FontHeightLabel := TspSkinStdLabel.Create(Self);
- with FontHeightLabel do
- begin
- Left := 110;
- Top := 95;
- Caption := 'Height:';
- AutoSize := True;
- Parent := Self;
- end;
- FontHeightEdit := TspSkinSpinEdit.Create(Self);
- with FontHeightEdit do
- begin
- MinValue := -500;
- MaxValue := 500;
- Left := 110;
- Top := 110;
- Width := 95;
- Parent := Self;
- OnChange := FontHeightChange;
- end;
- FontExLabel := TspSkinStdLabel.Create(Self);
- with FontExLabel do
- begin
- Left := 210;
- Top := 50;
- Caption := 'Example:';
- AutoSize := True;
- Parent := Self;
- end;
- FontExamplePanel := TspSkinPanel.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 := TspSkinButton.Create(Self);
- with OkButton do
- begin
- Caption := 'Ok';
- CanFocused := True;
- Left := 230;
- Top := 155;
- Width := 75;
- DefaultHeight := 25;
- Parent := Self;
- ModalResult := mrOk;
- end;
- CancelButton := TspSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := 'Cancel';
- CanFocused := True;
- Left := 320;
- Top := 155;
- Width := 75;
- DefaultHeight := 25;
- Parent := Self;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- FontStyleLabel := TspSkinStdLabel.Create(Self);
- with FontStyleLabel do
- begin
- Left := 210;
- Top := 5;
- Caption := 'Style:';
- AutoSize := True;
- Parent := Self;
- end;
- BoldButton := TspSkinSpeedButton.Create(Self);
- with BoldButton do
- begin
- Parent := Self;
- AllowAllUp := True;
- DefaultWidth := 25;
- DefaultHeight := 25;
- SkinDataName := 'toolbutton';
- GroupIndex := 1;
- NumGlyhps := 1;
- Left := 210;
- Top := 20;
- Glyph.LoadFromResourceName(HInstance, 'SP_BOLD');
- OnClick := BoldButtonClick;
- end;
- ItalicButton := TspSkinSpeedButton.Create(Self);
- with ItalicButton do
- begin
- Parent := Self;
- AllowAllUp := True;
- DefaultWidth := 25;
- DefaultHeight := 25;
- SkinDataName := 'toolbutton';
- GroupIndex := 1;
- NumGlyhps := 1;
- Left := 240;
- Top := 20;
- Glyph.LoadFromResourceName(HInstance, 'SP_ITALIC');
- OnClick := ItalicButtonClick;
- end;
- UnderLineButton := TspSkinSpeedButton.Create(Self);
- with UnderLineButton do
- begin
- Parent := Self;
- AllowAllUp := True;
- DefaultWidth := 25;
- DefaultHeight := 25;
- SkinDataName := 'toolbutton';
- GroupIndex := 1;
- NumGlyhps := 1;
- Left := 270;
- Top := 20;
- Glyph.LoadFromResourceName(HInstance, 'SP_UNDERLINE');
- OnClick := UnderLineButtonClick;
- end;
- StrikeOutButton := TspSkinSpeedButton.Create(Self);
- with StrikeOutButton do
- begin
- Parent := Self;
- AllowAllUp := True;
- DefaultWidth := 25;
- DefaultHeight := 25;
- SkinDataName := 'toolbutton';
- GroupIndex := 1;
- NumGlyhps := 1;
- Left := 300;
- Top := 20;
- Glyph.LoadFromResourceName(HInstance, 'SP_STRIKEOUT');
- OnClick := StrikeOutButtonClick;
- end;
- end;
- procedure TspFontDlgForm.FontSizeChange(Sender: TObject);
- begin
- FontExampleLabel.Font.Size := Trunc(FontSizeEdit.Value);
- FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
- end;
- procedure TspFontDlgForm.FontHeightChange(Sender: TObject);
- begin
- FontExampleLabel.Font.Height := Trunc(FontHeightEdit.Value);
- FontSizeEdit.SimpleSetValue(FontExampleLabel.Font.Size);
- end;
- procedure TspFontDlgForm.FontNameChange(Sender: TObject);
- begin
- FontExampleLabel.Font.Name := FontNameBox.FontName;
- end;
- procedure TspFontDlgForm.FontColorChange(Sender: TObject);
- begin
- FontExampleLabel.Font.Color := FontColorBox.Selected;
- end;
- procedure TspFontDlgForm.BoldButtonClick(Sender: TObject);
- begin
- if BoldButton.Down
- then
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsBold]
- else
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsBold];
- end;
- procedure TspFontDlgForm.ItalicButtonClick(Sender: TObject);
- begin
- if ItalicButton.Down
- then
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsItalic]
- else
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsItalic];
- end;
- procedure TspFontDlgForm.StrikeOutButtonClick(Sender: TObject);
- begin
- if StrikeOutButton.Down
- then
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsStrikeOut]
- else
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsStrikeOut];
- end;
- procedure TspFontDlgForm.UnderLineButtonClick(Sender: TObject);
- begin
- if UnderLineButton.Down
- then
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style + [fsUnderLine]
- else
- FontExampleLabel.Font.Style := FontExampleLabel.Font.Style - [fsUnderLine];
- end;
- constructor TspSkinFontDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- FTitle := 'Font';
- FDefaultFont := TFont.Create;
- FFont := TFont.Create;
- with FDefaultFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- FShowSizeEdit := True;
- FShowHeightEdit := True;
- end;
- destructor TspSkinFontDialog.Destroy;
- begin
- FDefaultFont.Free;
- FFont.Free;
- inherited Destroy;
- end;
- procedure TspSkinFontDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TspSkinFontDialog.SetFont;
- begin
- FFont.Assign(Value);
- end;
- procedure TspSkinFontDialog.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;
- function TspSkinFontDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TspSkinFontDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TspSkinFontDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TspSkinFontDialog.Execute: Boolean;
- var
- FW, FH: Integer;
- begin
- FDlgFrm := TspFontDlgForm.Create(Application);
- with FDlgFrm do
- try
- Caption := Self.Title;
- DSF.BorderIcons := [];
- DSF.SkinData := FSD;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- //
- FontNameBox.SkinData := FCtrlFSD;
- FontColorBox.SkinData := FCtrlFSD;
- FontSizeEdit.SkinData := FCtrlFSD;
- FontHeightEdit.SkinData := FCtrlFSD;
- FontExamplePanel.SkinData := FCtrlFSD;
- OkButton.SkinData := FCtrlFSD;
- CancelButton.SkinData := FCtrlFSD;
- BoldButton.SkinData := FCtrlFSD;
- ItalicButton.SkinData := FCtrlFSD;
- UnderLineButton.SkinData := FCtrlFSD;
- StrikeOutButton.SkinData := FCtrlFSD;
- //
- FontHeightLabel.SkinData := FCtrlFSD;
- FontSizeLabel.SkinData := FCtrlFSD;
- FontStyleLabel.SkinData := FCtrlFSD;
- FontNameLabel.SkinData := FCtrlFSD;
- FontColorLabel.SkinData := FCtrlFSD;
- FontExLabel.SkinData := FCtrlFSD;
- //
- FontExampleLabel.Font.Assign(Self.Font);
- FontNameBox.FontName := FontExampleLabel.Font.Name;
- FontColorBox.Selected := FontExampleLabel.Font.Color;
- FontSizeEdit.SimpleSetValue(FontExampleLabel.Font.Size);
- FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
- FontSizeEdit.Visible := FShowSizeEdit;
- FontHeightEdit.Visible := FShowHeightEdit;
- FontHeightLabel.Visible := FShowHeightEdit;
- FontSizeLabel.Visible := FShowSizeEdit;
- //
- if fsBold in FontExampleLabel.Font.Style
- then
- BoldButton.Down := True;
- if fsItalic in FontExampleLabel.Font.Style
- then
- ItalicButton.Down := True;
- if fsStrikeOut in FontExampleLabel.Font.Style
- then
- StrikeOutButton.Down := True;
- if fsUnderLine in FontExampleLabel.Font.Style
- then
- UnderLineButton.Down := True;
- //
- FW := 400;
- FH := 190;
- if (SkinData <> nil) and not SkinData.Empty
- then
- begin
- if FW < DSF.GetMinWidth then FW := DSF.GetMinWidth;
- if FH < DSF.GetMinHeight then FH := DSF.GetMinHeight;
- end;
- ClientWidth := FW;
- ClientHeight := FH;
- //
- Result := (ShowModal = mrOk);
- if Result
- then
- begin
- Self.Font.Assign(FontExampleLabel.Font);
- Change;
- end;
- finally
- Free;
- FDlgFrm := nil;
- end;
- end;
- constructor TspSkinTextDialog.Create;
- begin
- inherited Create(AOwner);
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- Memo := nil;
- FSkinOpenDialog := nil;
- FSkinSaveDialog := nil;
- FClientWidth := 350;
- FClientHeight := 200;
- FLines := TStringList.Create;
- FCaption := 'Input text';
- FButtonSkinDataName := 'button';
- FMemoSkinDataName := 'memo';
- FDefaultButtonFont := TFont.Create;
- FDefaultMemoFont := TFont.Create;
- FUseSkinFont := True;
- ShowToolBar := True;
- with FDefaultButtonFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- with FDefaultMemoFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- end;
- destructor TspSkinTextDialog.Destroy;
- begin
- FDefaultMemoFont.Free;
- FDefaultButtonFont.Free;
- FLines.Free;
- inherited;
- end;
- procedure TspSkinTextDialog.NewButtonClick(Sender: TObject);
- begin
- Memo.Clear;
- end;
- procedure TspSkinTextDialog.OpenButtonClick(Sender: TObject);
- var
- OD: TOpenDialog;
- begin
- if FSkinOpenDialog <> nil
- then
- begin
- if FSkinOpenDialog.Execute
- then Memo.Lines.LoadFromFile(FSkinOpenDialog.FileName);
- end
- else
- begin
- OD := TOpenDialog.Create(Self);
- OD.Filter := '*.txt|*.txt|*.*|*.*';
- if OD.Execute then Memo.Lines.LoadFromFile(OD.FileName);
- OD.Free;
- end;
- end;
- procedure TspSkinTextDialog.SaveButtonClick(Sender: TObject);
- var
- SD: TSaveDialog;
- begin
- if FSkinSaveDialog <> nil
- then
- begin
- if FSkinSaveDialog.Execute
- then Memo.Lines.LoadFromFile(FSkinSaveDialog.FileName);
- end
- else
- begin
- SD := TSaveDialog.Create(Self);
- SD.Filter := '*.txt|*.txt|*.*|*.*';
- if SD.Execute then Memo.Lines.SaveToFile(SD.FileName);
- SD.Free;
- end;
- end;
- procedure TspSkinTextDialog.CopyButtonClick(Sender: TObject);
- begin
- Memo.CopyToClipboard;
- end;
- procedure TspSkinTextDialog.CutButtonClick(Sender: TObject);
- begin
- Memo.CutToClipboard;
- end;
- procedure TspSkinTextDialog.PasteButtonClick(Sender: TObject);
- begin
- Memo.PasteFromClipboard;
- end;
- procedure TspSkinTextDialog.DeleteButtonClick(Sender: TObject);
- begin
- Memo.ClearSelection;
- end;
- procedure TspSkinTextDialog.SetLines(Value: TStrings);
- begin
- FLines.Assign(Value);
- end;
- procedure TspSkinTextDialog.SetClientWidth(Value: Integer);
- begin
- if Value > 0 then FClientWidth := Value;
- end;
- procedure TspSkinTextDialog.SetClientHeight(Value: Integer);
- begin
- if Value > 0 then FClientHeight := Value;
- end;
- procedure TspSkinTextDialog.SetDefaultMemoFont;
- begin
- FDefaultMemoFont.Assign(Value);
- end;
- procedure TspSkinTextDialog.SetDefaultButtonFont;
- begin
- FDefaultButtonFont.Assign(Value);
- end;
- procedure TspSkinTextDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- if (Operation = opRemove) and (AComponent = FSkinOpenDialog) then FSkinOpenDialog := nil;
- if (Operation = opRemove) and (AComponent = FSkinSaveDialog) then FSkinSaveDialog := nil;
- end;
- function TspSkinTextDialog.Execute: Boolean;
- var
- Form: TForm;
- DSF: TspDynamicSkinForm;
- ButtonWidth, ButtonHeight: Integer;
- Panel: TspSkinPanel;
- HMemoScrollBar, VMemoScrollBar: TspSkinScrollBar;
- ToolPanel: TspSkinPanel;
- begin
- Form := TForm.Create(Application);
- Form.BorderStyle := bsDialog;
- Form.Caption := FCaption;
- Form.Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Form);
- DSF.BorderIcons := [];
- DSF.SkinData := SkinData;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.SizeAble := False;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- try
- with Form do
- begin
- ClientWidth := FClientWidth;
- ClientHeight := FClientHeight;
- ButtonWidth := 80;
- ButtonHeight := 25;
- with TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'OK';
- DefaultHeight := ButtonHeight;
- ModalResult := mrOk;
- Default := True;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- SetBounds(FClientWidth - ButtonWidth * 2 - 20, FClientHeight - Height - 10,
- ButtonWidth, Height);
- end;
- with TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'Cancel';
- DefaultHeight := ButtonHeight;
- ModalResult := mrCancel;
- Cancel := True;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- SetBounds(FClientWidth - ButtonWidth - 10, FClientHeight - Height - 10,
- ButtonWidth, Height);
- ButtonHeight := Height;
- end;
- Panel := TspSkinPanel.Create(Form);
- with Panel do
- begin
- Parent := Form;
- Align := alTop;
- SkinData := CtrlSkinData;
- end;
- if FShowToolBar
- then
- begin
- ToolPanel := TspSkinPanel.Create(Form);
- with ToolPanel do
- begin
- Parent := Form;
- Align := alTop;
- DefaultHeight := 25;
- SkinDataName := 'toolpanel';
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := NewButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_NEW');
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := OpenButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_OPEN');
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := SaveButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_SAVE');
- SkinData := CtrlSkinData;
- end;
- with TspSkinBevel.Create(Form) do
- begin
- Parent := ToolPanel;
- Width := 24;
- Align := alLeft;
- DividerMode := True;
- Shape := bsLeftLine;
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := CopyButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_COPY');
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := CutButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_CUT');
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := PasteButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_PASTE');
- SkinData := CtrlSkinData;
- end;
- with TspSkinSpeedButton.Create(Form) do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := DeleteButtonClick;
- NumGlyhps := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_DELETE');
- SkinData := CtrlSkinData;
- end;
- end;
- with Panel do
- begin
- if FShowToolBar
- then
- Height := FClientHeight - ButtonHeight - 20 - ToolPanel.Height
- else
- Height := FClientHeight - ButtonHeight - 20;
- end;
- VMemoScrollBar := TspSkinScrollBar.Create(Form);
- with VMemoScrollBar do
- begin
- Kind := sbVertical;
- Parent := Panel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- SkinData := CtrlSkinData;
- end;
- HMemoScrollBar := TspSkinScrollBar.Create(Form);
- with HMemoScrollBar do
- begin
- Parent := Panel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- Both := True;
- SkinDataName := 'bothhscrollbar';
- SkinData := CtrlSkinData;
- end;
- Memo := TspSkinMemo2.Create(Form);
- with Memo do
- begin
- Parent := Panel;
- Lines.Assign(Self.Lines);
- Align := alClient;
- HScrollBar := HMemoScrollBar;
- VScrollBar := VMemoScrollBar;
- SkinData := CtrlSkinData;
- end;
- end;
-
- if Form.ShowModal = mrOk
- then
- begin
- Self.Lines.Assign(Memo.Lines);
- Result := True;
- end
- else
- Result := False;
- finally
- Form.Free;
- end;
- end;
- constructor TspSkinPasswordDialog.Create;
- begin
- inherited Create(AOwner);
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- LoginMode := False;
- FCaption := 'Password';
- FPasswordCaption := 'Password:';
- FPassword := '';
- FPasswordChar := '*';
- FLoginCaption := 'Login name:';
- FLogin := '';
- FButtonSkinDataName := 'button';
- FLabelSkinDataName := 'stdlabel';
- FEditSkinDataName := 'edit';
- FDefaultLabelFont := TFont.Create;
- FDefaultButtonFont := TFont.Create;
- FDefaultEditFont := 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 FDefaultEditFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- end;
- destructor TspSkinPasswordDialog.Destroy;
- begin
- FDefaultLabelFont.Free;
- FDefaultButtonFont.Free;
- FDefaultEditFont.Free;
- inherited;
- end;
- procedure TspSkinPasswordDialog.SetDefaultLabelFont;
- begin
- FDefaultLabelFont.Assign(Value);
- end;
- procedure TspSkinPasswordDialog.SetDefaultEditFont;
- begin
- FDefaultEditFont.Assign(Value);
- end;
- procedure TspSkinPasswordDialog.SetDefaultButtonFont;
- begin
- FDefaultButtonFont.Assign(Value);
- end;
- procedure TspSkinPasswordDialog.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;
- function TspSkinPasswordDialog.Execute: Boolean;
- var
- Form: TForm;
- DSF: TspDynamicSkinForm;
- Image: TImage;
- LoginLabel, PasswordLabel: TspSkinStdLabel;
- LoginEdit, PasswordEdit: TspSkinEdit;
- DialogUnits: TPoint;
- ButtonTop, ButtonWidth, ButtonHeight: Integer;
- LeftOffset: Integer;
- begin
- Form := TForm.Create(Application);
- Form.BorderStyle := bsDialog;
- Form.Caption := FCaption;
- Form.Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Form);
- DSF.BorderIcons := [];
- DSF.SkinData := SkinData;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- try
- with Form do
- begin
- Canvas.Font := Font;
- DialogUnits := GetAveCharSize(Canvas);
- Image := TImage.Create(Form);
- with Image do
- begin
- Parent := Form;
- Top := MulDiv(8, DialogUnits.Y, 8);
- Left := MulDiv(8, DialogUnits.X, 4);
- AutoSize := True;
- Transparent := True;
- Picture.Bitmap.Handle := LoadBitMap(HInstance, 'SP_KEY');
- end;
- LeftOffset := Image.Width + Image.Left;
- ClientWidth := LeftOffset + MulDiv(180, DialogUnits.X, 4);
- end;
- if FLoginMode
- then
- begin
- LoginLabel := TspSkinStdLabel.Create(Form);
- with LoginLabel do
- begin
- Parent := Form;
- Left := LeftOffset + MulDiv(8, DialogUnits.X, 4);
- Top := MulDiv(8, DialogUnits.Y, 8);
- Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinDataName := FLabelSkinDataName;
- SkinData := CtrlSkinData;
- Caption := FLoginCaption;
- end;
- LoginEdit := TspSkinMaskEdit.Create(Form);
- with LoginEdit do
- begin
- Parent := Form;
- DefaultFont := DefaultEditFont;
- UseSkinFont := Self.UseSkinFont;
- Left := LoginLabel.Left;
- Top := LoginLabel.Top + LoginLabel.Height + 5;
- DefaultWidth := MulDiv(164, DialogUnits.X, 4);
- MaxLength := 255;
- Text := FLogin;
- SelectAll;
- SkinDataName := FEditSkinDataName;
- SkinData := CtrlSkinData;
- end;
- end;
- PasswordLabel := TspSkinStdLabel.Create(Form);
- with PasswordLabel do
- begin
- Parent := Form;
- Left := LeftOffset + MulDiv(8, DialogUnits.X, 4);
- if FLoginMode and (LoginEdit <> nil)
- then
- Top := LoginEdit.Top + LoginEdit.Height + 5
- else
- Top := MulDiv(8, DialogUnits.Y, 8);
- Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinDataName := FLabelSkinDataName;
- SkinData := CtrlSkinData;
- Caption := FPasswordCaption;
- end;
- PasswordEdit := TspSkinMaskEdit.Create(Form);
- with PasswordEdit do
- begin
- Parent := Form;
- EditPasswordChar := Self.PasswordChar;
- DefaultFont := DefaultEditFont;
- UseSkinFont := Self.UseSkinFont;
- Left := PasswordLabel.Left;
- Top := PasswordLabel.Top + PasswordLabel.Height + 5;
- DefaultWidth := MulDiv(164, DialogUnits.X, 4);
- MaxLength := 255;
- Text := FPassword;
- SelectAll;
- SkinDataName := FEditSkinDataName;
- SkinData := CtrlSkinData;
- end;
- ButtonTop := PasswordEdit.Top + PasswordEdit.Height + 15;
- ButtonWidth := MulDiv(50, DialogUnits.X, 4);
- ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
- with TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'OK';
- ModalResult := mrOk;
- Default := True;
- SetBounds(LeftOffset + MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
- ButtonHeight);
- DefaultHeight := ButtonHeight;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- end;
- with TspSkinButton.Create(Form) do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := 'Cancel';
- ModalResult := mrCancel;
- Cancel := True;
- SetBounds(LeftOffset + MulDiv(92, DialogUnits.X, 4), PasswordEdit.Top + PasswordEdit.Height + 15,
- ButtonWidth, ButtonHeight);
- DefaultHeight := ButtonHeight;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- Form.ClientHeight := Top + Height + 13;
- Image.Top := Form.ClientHeight div 2 - Image.Height div 2;
- end;
- if Form.ShowModal = mrOk
- then
- begin
- if FLoginMode then FLogin := LoginEdit.Text;
- FPassword := PasswordEdit.Text;
- Result := True;
- end
- else
- Result := False;
- finally
- Form.Free;
- end;
- end;
- end.