ksskinmenuform.pas

来自「小区水费管理系统源代码水费收费管理系统 水费收费管理系统」· PAS 代码 · 共 146 行

PAS
146
字号
{==============================================================================

  SkinEngine's MenuForm
  Copyright (C) 2000-2002 by Evgeny Kryukov
  All rights reserved

  All conTeThements of this file and all other files included in this archive
  are Copyright (C) 2002 Evgeny Kryukov. Use and/or distribution of
  them requires acceptance of the License Agreement.

  See License.txt for licence information

  $Id: KsSkinMenuForm.pas,v 1.6 2002/10/28 21:04:21 Evgeny Exp $

===============================================================================}

unit KsSkinMenuForm;

{$I se_define.inc}
{$T-,W-,X+,P+}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
  se_controls, KsSkinObjects, KsSkinSource, KsSkinEngine;

type

{ TSeSkinPopupForm }

  TSeSkinPopupForm = class(TSePopupForm)
  private
    function UseSkin: boolean;
  protected
    function GetClientBounds: TRect; override;
    procedure PaintNonClientArea(Canvas: TCanvas); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

{ TSeSkinPopupWindow class }

  TSeSkinPopupWindow = class(TSePopupWindow)
  private
    FSkinEngine: TSeSkinEngine;
  protected
    class function GetFormClass: TSePopupFormClass; override;
  public
    constructor CreatePopupWindow(AOwner: TComponent; AItems: TSeCustomItem;
      AParentView: TSeItemView); override;
    destructor Destroy; override;

    property SkinEngine: TSeSkinEngine read FSkinEngine write FSkinEngine;
  end;

implementation {===============================================================}

uses KsSkinItems;

{ TSeSkinPopupForm ================================================================}

constructor TSeSkinPopupForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
end;

destructor TSeSkinPopupForm.Destroy;
begin
  inherited;
end;

function TSeSkinPopupForm.UseSkin: boolean;
begin
  Result := false;
  if PopupWindow = nil then Exit;

  with TSeSkinPopupWindow(PopupWindow) do
    if (FSkinEngine <> nil) and (FSkinEngine.SkinSource <> nil) and
       (not FSkinEngine.SkinSource.IsChanging) and
       (FSkinEngine.SkinSource.Count > 0) and
       (FSkinEngine.SkinSource.GetObjectByName('PopupMenu') <> nil)
    then
      Result := true;
end;

function TSeSkinPopupForm.GetClientBounds: TRect;
var
  SkinObject: TSeSkinObject;
begin
  if UseSkin then
  begin
    SkinObject := TSeSkinPopupWindow(PopupWindow).SkinEngine.SkinSource.GetObjectByName('PopupMenu');
    SkinObject := SkinObject.FindObjectByName('Frame');
    if SkinObject <> nil then
      with SkinObject do
        Result := Rect(MarginLeft, MarginTop, Self.Width - MarginRight, Self.Height - MarginBottom)
    else
      Result := Rect(3, 3, Width - 3, Height - 3)
  end
  else
    Result := inherited GetClientBounds;
end;

procedure TSeSkinPopupForm.PaintNonClientArea(Canvas: TCanvas);
var
  SkinObject: TSeSkinObject;
begin
  if UseSkin then
  begin
    SkinObject := TSeSkinPopupWindow(PopupWindow).SkinEngine.SkinSource.GetObjectByName('PopupMenu');
    SkinObject := SkinObject.FindObjectByName('Frame');

    if SkinObject <> nil then
      with SkinObject do
      begin
        BoundsRect := Rect(0, 0, Self.Width, Self.Height);
        Draw(Canvas);
      end
  end
  else
    inherited;
end;

{ TSeSkinPopupWindow ===============================================================}

constructor TSeSkinPopupWindow.CreatePopupWindow(AOwner: TComponent;
  AItems: TSeCustomItem; AParentView: TSeItemView);
begin
  inherited CreatePopupWindow(AOwner, AItems, AParentView);
  FSkinEngine := TSeSkinItem(AItems).SkinEngine;
end;

destructor TSeSkinPopupWindow.Destroy;
begin
  inherited Destroy;
end;

class function TSeSkinPopupWindow.GetFormClass: TSePopupFormClass;
begin
  Result := TSeSkinPopupForm;
end;

end.

⌨️ 快捷键说明

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