Ignore:
Timestamp:
May 8, 2013, 1:52:33 PM (12 years ago)
Author:
chronos
Message:
  • Added: Support for mouse move handling. Now forms can be moved by dragging title bar.
  • Fixed: Clearing background during painting in screen and forms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Xvcl/Xvcl.Kernel.pas

    r21 r23  
    88type
    99  TKernel = class;
     10  TScreen = class;
    1011
    1112  TProcessState = (psReady, psRunning, psWaiting, psFinished);
     
    2425    procedure Initialize; virtual;
    2526    procedure Finalize; virtual;
     27  end;
     28
     29  TScreenCanvas = class(TCanvas)
     30    Screen: TScreen;
     31    function GetVideoDevice: TVideoDevice; override;
    2632  end;
    2733
     
    4551  TMouse = class
    4652    Kernel: TKernel;
     53    procedure HandleMove(Position: TPoint);
    4754    procedure HandleDown(Position: TPoint);
    4855    procedure HandleUp(Position: TPoint);
     
    144151  inherited;
    145152  Forms := TList<TForm>.Create;
    146   Canvas := TCanvas.Create;
     153  Canvas := TScreenCanvas.Create;
    147154end;
    148155
     
    158165  Form: TForm;
    159166begin
     167  Canvas.Brush.Color := clWhite;
     168  Canvas.FillRect(TRectangle.Create(0, 0, Size.X, Size.Y));
    160169  for Form in Forms do Form.Paint;
    161170end;
     
    203212var
    204213  Form: TForm;
    205   NewMessage: TMessageMouse;
     214  NewMessage: TMessageMouseDown;
    206215begin
    207216  NewMessage := TMessageMouseDown.Create;
    208217  NewMessage.Position := Position;
    209218  try
    210     for Form in Kernel.Screen.Forms do begin
     219    for Form in Kernel.Screen.Forms do
     220    if Form.Bounds.Contains(Position) then begin
    211221      if Form.HandleMessage(NewMessage) then begin
    212222        Break;
     
    218228end;
    219229
    220 procedure TMouse.HandleUp(Position: TPoint);
    221 var
    222   Form: TForm;
    223   NewMessage: TMessageMouse;
    224 begin
    225   NewMessage := TMessageMouseUp.Create;
     230procedure TMouse.HandleMove(Position: TPoint);
     231var
     232  Form: TForm;
     233  NewMessage: TMessageMouseMove;
     234begin
     235  NewMessage := TMessageMouseMove.Create;
    226236  NewMessage.Position := Position;
    227237  try
    228     for Form in Kernel.Screen.Forms do begin
     238    for Form in Kernel.Screen.Forms do
     239    if Form.Bounds.Contains(Position) then begin
    229240      if Form.HandleMessage(NewMessage) then begin
    230241        Break;
     
    236247end;
    237248
     249procedure TMouse.HandleUp(Position: TPoint);
     250var
     251  Form: TForm;
     252  NewMessage: TMessageMouseUp;
     253begin
     254  NewMessage := TMessageMouseUp.Create;
     255  NewMessage.Position := Position;
     256  try
     257    for Form in Kernel.Screen.Forms do
     258    if Form.Bounds.Contains(Position) then begin
     259      if Form.HandleMessage(NewMessage) then begin
     260        Break;
     261      end;
     262    end;
     263  finally
     264    NewMessage.Destroy;
     265  end;
     266end;
     267
     268{ TScrenCanvas }
     269
     270function TScreenCanvas.GetVideoDevice: TVideoDevice;
     271begin
     272  if Assigned(Screen) then Result := Screen.VideoDevice
     273    else Result := nil;
     274end;
     275
    238276end.
Note: See TracChangeset for help on using the changeset viewer.