Source

delQuery / demo / main.pas

Full commit
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, AppEvnts, Buttons;

type
  TForm1 = class(TForm)
    pnlTop: TPanel;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    pnlRight: TPanel;
    edSearch: TEdit;
    Button5: TButton;
    Button6: TButton;
    CheckBox3: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox1: TCheckBox;
    Panel1: TPanel;
    Memo2: TMemo;
    Panel3: TPanel;
    Memo1: TMemo;
    Button1: TButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    pnlBottom: TPanel;
    SpeedButton10: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton11: TSpeedButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Shape1: TShape;
    procedure FormCreate(Sender: TObject);
  private
    OldWindowProc: TWndMethod;
    procedure OnDEBUGWindowProc(var Message: TMessage);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  delQuery, jclGraphics, JvPaintFX;

{$R *.dfm}

type
  TWinControlAccessHack = class(TWinControl);
  TMove = reference to procedure;

procedure MakeLavaLamp(labels: TdelQuery; shape: TShape);
var
  move: TMove;
  selected: TControl;
begin
  move := procedure
          begin

          end;

  shape.SendToBack; // we don't want the shape ON the labels

  labels.mouseenter(procedure(event:dqevent)
                           var target: TRect;
                           begin
                             target := event.sender.BoundsRect;
                             InflateRect(target, 5, 5);
                             target.Right := target.Right - target.Left; // right -> width
                             target.Bottom := target.Bottom - target.Top; // bottom -> height

                             dq(shape).{stop().}animate(['Left', target.Left, 'Width', target.Right,
                                                         'Top', target.Top, 'Height', target.Bottom],
                                                        'fast', ease_swing);
                           end)
        .mouseleave(procedure(event:dqevent)
                           var target: TRect;
                           begin
                             target := labels.get[0].BoundsRect;
                             InflateRect(target, 5, 5);
                             target.Right := target.Right - target.Left; // right -> width
                             target.Bottom := target.Bottom - target.Top; // bottom -> height

                             dq(shape).stop().animate(['Left', target.Left, 'Width', target.Right,
                                                         'Top', target.Top, 'Height', target.Bottom],
                                                        'fast', ease_swing);
                           end)
        .click(procedure(event:dqevent)
                           begin
                             selected := event.sender;
                             ShowMessage(event.sender.Name);
                           end);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  dq(TSpeedButton, pnlTop).mouseenter(procedure(event:dqevent)
                           begin
                             event.this.animate(['Left', '-=5', 'Width', '+=10',
                                                 'Top', '-=5', 'Height', '+=10'
                                                ], '100');
                           end)
                          .mouseleave(procedure(event:dqevent)
                           begin
                             event.this.animate(['Left', '+=5', 'Width', '-=10',
                                                 'Top', '+=5', 'Height', '-=10'
                                                ], '100');
                           end)
                          .click(procedure(event:dqevent)
                           begin
                             Showmessage(event.Sender.Name);
                           end);

  dq(TButton, self).mouseenter(procedure(event:dqevent)
                    begin
                      event.this.animate(['Width', '+=60'], '100');
                    end)
                   .mouseleave(procedure(event:dqevent)
                    begin
                      event.this.animate(['Width', '-=60'], '100');
                    end)
                   .click(procedure(event:dqevent)
                    begin
                      event.this.animate(['Left', '+=300'], 'slow', ease_outbounce,
                        procedure(event: dqevent)
                        begin
                          event.this.prop('caption', 'coming back!')
                                    .animate(['Left', '-=300'], 'slow', ease_swing);
                        end);
                    end);

  dq(edSearch).prop('text', 'Search')
              .prop('font.color', clGray)
              .enter(procedure(event:dqevent)
                 begin
                     event.this.prop('text', '');
                     event.this.prop('font.color', clBlack);
                 end)
              .exit_(procedure(event:dqevent)
                begin
                     event.this.prop('text', 'Search');
                     event.this.prop('font.color', clGray);
                end );

  dq(pnlRight).prop('Caption', '')
              .prop('Width', 20)
              .mouseenter(procedure(event:dqevent)
               begin
                 event.this.animate(['Width', '200'], 'slow', ease_outbounce);
               end)
              .mouseleave(procedure(event:dqevent)
               begin
                 event.this.animate(['Width', '20'], 'fast');
               end)
              .click(procedure(event:dqevent)
               begin
                 Showmessage(event.sender.Name);
               end);

  dq(TCheckBox, self, True).mouseenter(procedure(event:dqevent)
                            begin
                              event.this.prop('caption', uppercase(event.this.prop('caption').AsString));
                            end)
                           .mouseleave(procedure(event:dqevent)
                            begin
                              event.this.prop('caption', lowercase(event.this.prop('caption').AsString));
                            end);

  dq(TSpeedButton, pnlBottom).mouseenter(procedure(event:dqevent)
                           begin
                             event.this.animate(['Left', '-=5', 'Width', '+=10',
                                                 'Top', '-=15', 'Height', '+=10'
                                                ], '100');
                           end)
                          .mouseleave(procedure(event:dqevent)
                           begin
                             event.this.animate(['Left', '+=5', 'Width', '-=10',
                                                 'Top', '+=15', 'Height', '-=10'
                                                ], '100');
                           end)
                          .click(procedure(event:dqevent)
                           begin
                             Showmessage(event.sender.Name);
                           end);

  MakeLavaLamp(dq(TLabel, pnlBottom), Shape1);
//   OldWindowProc := TWinControlAccessHack(pnlRight).WindowProc;
//   TWinControlAccessHack(pnlRight).WindowProc := OnWindowProc;
end;

procedure TForm1.OnDEBUGWindowProc(var Message: TMessage);
begin
  if Message.Msg = CM_MOUSELEAVE then
  begin
    Memo2.Lines.append(Format('LEAVE %d %d', [Message.WParam, Message.LParam]));
  end;
  if Message.Msg = CM_MOUSEENTER then
  begin
    Memo2.Lines.append(Format('ENTER %d %d', [Message.WParam, Message.LParam]));
  end;
  OldWindowProc(Message);
end;

end.