cxhinteditor.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 453 行 · 第 1/2 页

PAS
453
字号

{********************************************************************}
{                                                                    }
{       Developer Express Visual Component Library                   }
{       ExpressEditors                                               }
{                                                                    }
{       Copyright (c) 1998-2008 Developer Express Inc.               }
{       ALL RIGHTS RESERVED                                          }
{                                                                    }
{   The entire contents of this file is protected by U.S. and        }
{   International Copyright Laws. Unauthorized reproduction,         }
{   reverse-engineering, and distribution of all or any portion of   }
{   the code contained in this file is strictly prohibited and may   }
{   result in severe civil and criminal penalties and will be        }
{   prosecuted to the maximum extent possible under the law.         }
{                                                                    }
{   RESTRICTIONS                                                     }
{                                                                    }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES            }
{   (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE     }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS    }
{   LICENSED TO DISTRIBUTE THE EXPRESSEDITORS AND ALL                }
{   ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
{                                                                    }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED       }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE         }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE        }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT   }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                       }
{                                                                    }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON        }
{   ADDITIONAL RESTRICTIONS.                                         }
{                                                                    }
{********************************************************************}

unit cxHintEditor;

{$I cxVer.inc}

interface

uses
{$IFDEF DELPHI6}
  Variants,
{$ENDIF}
  Windows, Classes, ComCtrls, Controls, Dialogs, ExtCtrls, Forms, Graphics,
  Messages, StdCtrls, SysUtils, cxButtons, cxCheckBox, cxCheckListBox,
  cxColorComboBox, cxContainer, cxControls, cxDropDownEdit, cxEdit,
  cxExtEditConsts, cxFontNameComboBox, cxGroupBox, cxHint, cxLabel, cxListBox,
  cxListView, cxLookAndFeelPainters, cxLookandFeels, cxMaskEdit, cxMemo,
  cxRadioGroup, cxSpinButton, cxSpinEdit, cxSplitter, cxTextEdit, cxTrackBar;

type
  TcxHintStyleEditor = class(TForm)
    cxBtnOk: TcxButton;
    cxBtnCancel: TcxButton;
    cxCbStandard: TcxCheckBox;
    cxGbHintFont: TcxGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    cxFnHint: TcxFontNameComboBox;
    cxClbHintFontStyles: TcxCheckListBox;
    cxLbHfSize: TcxListBox;
    cxCcbHintFontColour: TcxColorComboBox;
    cxgbHintCapFont: TcxGroupBox;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    cxFnHinCap: TcxFontNameComboBox;
    cxClbHintCapFontStyles: TcxCheckListBox;
    cxLbHcfSize: TcxListBox;
    cxCcbHintCapColor: TcxColorComboBox;
    cxGbHintShape: TcxGroupBox;
    Label7: TLabel;
    Label8: TLabel;
    cxCbHintCalloutPos: TcxComboBox;
    cxcbHintRounded: TcxCheckBox;
    cxSeHintRadius: TcxSpinEdit;
    cxGbHintIcons: TcxGroupBox;
    Label11: TLabel;
    cxCbHintIconType: TcxComboBox;
    cxRbHIDef: TcxRadioButton;
    cxRbHILarge: TcxRadioButton;
    cxRbHISmall: TcxRadioButton;
    cxGbHintPause: TcxGroupBox;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    cxSeHintHidePause: TcxSpinEdit;
    cxSeHintPause: TcxSpinEdit;
    cxSeShortHintPause: TcxSpinEdit;
    lblHintColour: TLabel;
    cxCcbHintColour: TcxColorComboBox;
    cxGbHintAnimation: TcxGroupBox;
    Label9: TLabel;
    Label10: TLabel;
    cxCbHintAniStyle: TcxComboBox;
    cxSeHintDelay: TcxSpinEdit;
    cxGbPreview: TcxGroupBox;
    cxHsc: TcxHintStyleController;
    pnlPreview: TPanel;
    cxEditStyleController1: TcxEditStyleController;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure cxFnHintClick(Sender: TObject);
    procedure cxCbHintCalloutPosClick(Sender: TObject);
    procedure cxSeHintRadiusPropertiesChange(Sender: TObject);
    procedure cxcbHintRoundedPropertiesChange(Sender: TObject);
    procedure cxCbHintAniStylePropertiesChange(Sender: TObject);
    procedure cxSeHintDelayPropertiesChange(Sender: TObject);
    procedure cxCbHintIconTypeClick(Sender: TObject);
    procedure cxRbHIDefClick(Sender: TObject);
    procedure cxSeHintHidePausePropertiesChange(Sender: TObject);
    procedure cxSeHintPausePropertiesChange(Sender: TObject);
    procedure cxSeShortHintPausePropertiesEditValueChanged(Sender: TObject);
    procedure cxClbHintFontStylesClickCheck(Sender: TObject;
      AIndex: Integer; APrevState, ANewState: TcxCheckBoxState);
    procedure cxCcbHintFontColourClick(Sender: TObject);
    procedure cxCcbHintCapColorClick(Sender: TObject);
    procedure cxFnHintPropertiesChange(Sender: TObject);
    procedure cxLbHfSizeClick(Sender: TObject);
    procedure cxLbHcfSizeClick(Sender: TObject);
    procedure cxFnHinCapPropertiesChange(Sender: TObject);
    procedure cxCbStandardClick(Sender: TObject);
    procedure cxFnHinCapClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure cxCcbHintColourPropertiesEditValueChanged(Sender: TObject);
  private
    fViewerFontSizes: TStringList;
    fHintHorz: Integer;
    fHintVert: Integer;
    fFormLoaded: Boolean;
    procedure SetHsc(const Value: TcxHintStyleController);
    procedure RefreshHint;
    procedure WMActivate(var Message: TWMActivate); message WM_ACTIVATE;
    procedure WMMove(var Message: TWMMove); message WM_MOVE;
  public
    procedure SetHintController(aDest: TcxHintStyleController);
    procedure LoadHintCtrls;
    property HintController: TCxHintStyleController read cxHsc write SetHsc;
  end;

var
  cxHintStyleEditor: TcxHintStyleEditor;

procedure ShowHintStyleEditor(AHintStyleController: TcxHintStyleController);

implementation

{$R *.dfm}

resourcestring
  SHintCaption = 'Example';
  SHintText    = 'Preview Hint';

procedure ShowHintStyleEditor(AHintStyleController: TcxHintStyleController);
var
  AHintStyleEditor: TcxHintStyleEditor;
  AOwnerCaption: string;
  APrevApplicationOnShowHint: TShowHintEvent;
begin
  APrevApplicationOnShowHint := Application.OnShowHint;
  AHintStyleEditor := TcxHintStyleEditor.Create(Application);
  with AHintStyleEditor do
  try
    HintController := AHintStyleController;
    if AHintStyleController.Owner <> nil then
      AOwnerCaption := AHintStyleController.Owner.Name + '.'
    else
      AOwnerCaption := '';
    Caption := Format('%s%s - Hint Editor',[AOwnerCaption, AHintStyleController.Name]);

    if ShowModal = mrOK then
    begin
      AHintStyleController.Assign(cxHsc);
      SetDesignerModified(AHintStyleController);
    end;

    HintController.HideHint;
  finally
    Application.OnShowHint := APrevApplicationOnShowHint;
    Free;
  end;
end;

procedure TcxHintStyleEditor.FormCreate(Sender: TObject);
begin
  fViewerFontSizes := TStringList.Create;
  SetControlLookAndFeel(Self, cxEditStyleController1.Style.LookAndFeel);
end;

procedure TcxHintStyleEditor.FormDestroy(Sender: TObject);
begin
  cxHsc.HideHint;
  fViewerFontSizes.Free;
end;

procedure TcxHintStyleEditor.cxCbStandardClick(Sender: TObject);
begin
  cxHsc.HintStyle.Standard := cxCbStandard.Checked;
  RefreshHint;
end;

procedure TcxHintStyleEditor.cxFnHintClick(Sender: TObject);
begin
  cxHsc.HintStyle.Font.Name := cxFnHint.FontName;
  RefreshHint;
end;

procedure TcxHintStyleEditor.cxFnHinCapClick(Sender: TObject);
begin
  cxHsc.HintStyle.CaptionFont.Name := cxFnHinCap.FontName;
  RefreshHint;
end;

procedure TcxHintStyleEditor.cxCbHintCalloutPosClick(Sender: TObject);
begin
  cxHsc.HintStyle.CallOutPosition := TcxCallOutPosition(cxCbHintCalloutPos.ItemIndex);
  RefreshHint;
end;

procedure TcxHintStyleEditor.cxSeHintRadiusPropertiesChange(Sender: TObject);
begin
  cxHsc.HintStyle.RoundRadius := cxSeHintRadius.Value;
  RefreshHint;

⌨️ 快捷键说明

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