You've already forked lazarus-ccr
cleaner message handling
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@345 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -225,6 +225,8 @@ type
|
|||||||
default True;
|
default True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TVpDayView }
|
||||||
|
|
||||||
TVpDayView = class(TVpLinkableControl)
|
TVpDayView = class(TVpLinkableControl)
|
||||||
protected{ private }
|
protected{ private }
|
||||||
FGranularity : TVpGranularity;
|
FGranularity : TVpGranularity;
|
||||||
@ -368,19 +370,14 @@ type
|
|||||||
procedure dvScrollVertical(Lines: Integer);
|
procedure dvScrollVertical(Lines: Integer);
|
||||||
procedure CreateParams(var Params: TCreateParams); override;
|
procedure CreateParams(var Params: TCreateParams); override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
|
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
|
||||||
|
procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
|
||||||
|
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X,Y:Integer); override;
|
||||||
{$IFNDEF LCL}
|
{$IFNDEF LCL}
|
||||||
procedure WMLButtonDown(var Msg : TWMLButtonDown); message WM_LBUTTONDOWN;
|
|
||||||
procedure WMRButtonDown(var Msg : TWMRButtonDown); message WM_RBUTTONDOWN;
|
|
||||||
procedure WMLButtonUp(var Msg: TWMLButtonUp); message WM_LBUTTONUP;
|
|
||||||
procedure WMLButtonDblClk(var Msg : TWMLButtonDblClk);
|
procedure WMLButtonDblClk(var Msg : TWMLButtonDblClk);
|
||||||
message WM_LBUTTONDBLCLK;
|
message WM_LBUTTONDBLCLK;
|
||||||
procedure WMMouseMove(var Msg : TWMMouseMove); message WM_MOUSEMOVE;
|
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
procedure WMLButtonDown(var Msg : TLMLButtonDown); message LM_LBUTTONDOWN;
|
|
||||||
procedure WMRButtonDown(var Msg : TLMRButtonDown); message LM_RBUTTONDOWN;
|
|
||||||
procedure WMLButtonUp(var Msg: TLMLButtonUp); message LM_LBUTTONUP;
|
|
||||||
procedure WMLButtonDblClk(var Msg : TLMLButtonDblClk); message LM_LBUTTONDBLCLK;
|
procedure WMLButtonDblClk(var Msg : TLMLButtonDblClk); message LM_LBUTTONDBLCLK;
|
||||||
procedure WMMouseMove(var Msg : TLMMouseMove); message LM_MOUSEMOVE;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
procedure SetActiveEventByCoord (APoint : TPoint);
|
procedure SetActiveEventByCoord (APoint : TPoint);
|
||||||
function EditEventAtCoord(Point: TPoint): Boolean;
|
function EditEventAtCoord(Point: TPoint): Boolean;
|
||||||
@ -1321,10 +1318,8 @@ begin
|
|||||||
DragObject := TVpEventDragObject.Create(Self);
|
DragObject := TVpEventDragObject.Create(Self);
|
||||||
TVpEventDragObject(DragObject).Event := FActiveEvent;
|
TVpEventDragObject(DragObject).Event := FActiveEvent;
|
||||||
end
|
end
|
||||||
{$IFNDEF LCL}
|
|
||||||
else
|
else
|
||||||
EndDrag(false);
|
DragObject.Free;//EndDrag(false);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
@ -1399,9 +1394,7 @@ begin
|
|||||||
|
|
||||||
{ Invalidate; }
|
{ Invalidate; }
|
||||||
end;
|
end;
|
||||||
{$IFNDEF LCL}
|
// TVpEventDragObject(Source).EndDrag(False);
|
||||||
EndDrag(False);
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
@ -1913,58 +1906,78 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
PostMessage (Handle, Vp_DayViewInit, 0, 0);
|
PostMessage (Handle, Vp_DayViewInit, 0, 0);
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
|
||||||
{$IFNDEF LCL}
|
|
||||||
procedure TVpDayView.WMLButtonDown(var Msg : TWMLButtonDown);
|
procedure TVpDayView.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
|
||||||
{$ELSE}
|
Y: Integer);
|
||||||
procedure TVpDayView.WMLButtonDown(var Msg : TLMLButtonDown);
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited MouseUp(Button, Shift, X, Y);
|
||||||
|
if Button = mbLeft then
|
||||||
dvMouseDownPoint := Point(Msg.XPos, Msg.YPos);
|
begin
|
||||||
dvMouseDown := true;
|
dvMouseDownPoint := Point(0, 0);
|
||||||
|
dvMouseDown := false;
|
||||||
{ if the mouse was pressed down in the client area, then select the cell. }
|
dvDragging := false;
|
||||||
if not focused then SetFocus;
|
end
|
||||||
|
else
|
||||||
if (Msg.XPos > dvRowHeadWidth - 9) and (Msg.YPos > dvColHeadHeight) then
|
begin
|
||||||
begin
|
end;
|
||||||
{ The mouse click landed inside the client area }
|
|
||||||
dvSetActiveColByCoord(Point(Msg.XPos, Msg.YPos));
|
|
||||||
dvSetActiveRowByCoord(Point(Msg.XPos, Msg.YPos), True);
|
|
||||||
if not ReadOnly then
|
|
||||||
EditEventAtCoord(Point(Msg.XPos, Msg.YPos));
|
|
||||||
end else if Msg.YPos > dvColHeadHeight then
|
|
||||||
dvSetActiveRowByCoord (Point (Msg.XPos, Msg.YPos), True);
|
|
||||||
|
|
||||||
if Assigned(OnClick) then
|
|
||||||
OnClick(self);
|
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
|
||||||
{$IFNDEF LCL}
|
procedure TVpDayView.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
procedure TVpDayView.WMRButtonDown(var Msg : TWMRButtonDown);
|
begin
|
||||||
{$ELSE}
|
inherited MouseMove(Shift, X, Y);
|
||||||
procedure TVpDayView.WMRButtonDown(var Msg : TLMRButtonDown);
|
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
||||||
{$ENDIF}
|
if (not dvDragging) and dvMouseDown
|
||||||
|
and ((dvMouseDownPoint.x <> x) or (dvMouseDownPoint.y <> y))
|
||||||
|
then begin
|
||||||
|
dvDragging := true;
|
||||||
|
dvClickTimer.Enabled := false;
|
||||||
|
BeginDrag(true);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpDayView.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
var
|
var
|
||||||
ClientOrigin : TPoint;
|
ClientOrigin : TPoint;
|
||||||
i : Integer;
|
i : Integer;
|
||||||
begin
|
begin
|
||||||
{ if the mouse was pressed down in the client area, then select the cell. }
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
|
if Button = mbLeft then
|
||||||
|
begin
|
||||||
|
dvMouseDownPoint := Point(x, y);
|
||||||
|
dvMouseDown := true;
|
||||||
|
|
||||||
|
{ if the mouse was pressed down in the client area, then select the cell. }
|
||||||
|
if not focused then SetFocus;
|
||||||
|
|
||||||
|
if (x > dvRowHeadWidth - 9) and (y > dvColHeadHeight) then
|
||||||
|
begin
|
||||||
|
{ The mouse click landed inside the client area }
|
||||||
|
dvSetActiveColByCoord(Point(x, y));
|
||||||
|
dvSetActiveRowByCoord(Point(x, y), True);
|
||||||
|
if not ReadOnly then
|
||||||
|
EditEventAtCoord(Point(x, y));
|
||||||
|
end else if y > dvColHeadHeight then
|
||||||
|
dvSetActiveRowByCoord (Point (x, y), True);
|
||||||
|
|
||||||
|
if Assigned(OnClick) then
|
||||||
|
OnClick(self);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
if not focused then
|
if not focused then
|
||||||
SetFocus;
|
SetFocus;
|
||||||
|
|
||||||
if (Msg.XPos > dvRowHeadWidth - 9) and (Msg.YPos > dvColHeadHeight) then
|
if (x > dvRowHeadWidth - 9) and (y > dvColHeadHeight) then
|
||||||
begin
|
begin
|
||||||
{ The mouse click landed inside the client area }
|
{ The mouse click landed inside the client area }
|
||||||
dvSetActiveColByCoord(Point(Msg.XPos, Msg.YPos));
|
dvSetActiveColByCoord(Point(x, y));
|
||||||
dvSetActiveRowByCoord(Point(Msg.XPos, Msg.YPos), True);
|
dvSetActiveRowByCoord(Point(x, y), True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
EditEventAtCoord (Point (Msg.XPos, Msg.YPos));
|
EditEventAtCoord (Point (x, y));
|
||||||
dvClickTimer.Enabled := false;
|
dvClickTimer.Enabled := false;
|
||||||
|
|
||||||
if not Assigned (PopupMenu) then begin
|
if not Assigned (PopupMenu) then begin
|
||||||
@ -1972,32 +1985,19 @@ begin
|
|||||||
|
|
||||||
if not Assigned (FActiveEvent) then
|
if not Assigned (FActiveEvent) then
|
||||||
for i := 0 to FDefaultPopup.Items.Count - 1 do begin
|
for i := 0 to FDefaultPopup.Items.Count - 1 do begin
|
||||||
if (FDefaultPopup.Items[i].Tag = 1) or (ReadOnly) then
|
if (FDefaultPopup.Items[i].Tag = 1) or (ReadOnly) then
|
||||||
FDefaultPopup.Items[i].Enabled := False;
|
FDefaultPopup.Items[i].Enabled := False;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i := 0 to FDefaultPopup.Items.Count - 1 do
|
for i := 0 to FDefaultPopup.Items.Count - 1 do
|
||||||
FDefaultPopup.Items[i].Enabled := True;
|
FDefaultPopup.Items[i].Enabled := True;
|
||||||
|
|
||||||
FDefaultPopup.Popup (Msg.XPos + ClientOrigin.x,
|
FDefaultPopup.Popup (x + ClientOrigin.x,
|
||||||
Msg.YPos + ClientOrigin.y);
|
y + ClientOrigin.y);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
inherited;
|
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
|
||||||
{$IFNDEF LCL}
|
|
||||||
procedure TVpDayView.WMLButtonUp(var Msg: TWMLButtonUp);
|
|
||||||
{$ELSE}
|
|
||||||
procedure TVpDayView.WMLButtonUp(var Msg: TLMLButtonUp);
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
|
||||||
dvMouseDownPoint := Point(0, 0);
|
|
||||||
dvMouseDown := false;
|
|
||||||
dvDragging := false;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
{$IFNDEF LCL}
|
{$IFNDEF LCL}
|
||||||
@ -2039,27 +2039,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
{$IFNDEF LCL}
|
|
||||||
procedure TVpDayView.WMMouseMove(var Msg : TWMMouseMove);
|
|
||||||
{$ELSE}
|
|
||||||
procedure TVpDayView.WMMouseMove(var Msg : TLMMouseMove);
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
|
||||||
|
|
||||||
if (FActiveEvent <> nil) and (not ReadOnly) then begin
|
|
||||||
if (not dvDragging) and dvMouseDown
|
|
||||||
and ((dvMouseDownPoint.x <> Msg.XPos) or (dvMouseDownPoint.y <> Msg.YPos))
|
|
||||||
then begin
|
|
||||||
dvDragging := true;
|
|
||||||
dvClickTimer.Enabled := false;
|
|
||||||
BeginDrag(true);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
{=====}
|
|
||||||
|
|
||||||
procedure TVpDayView.EditSelectedEvent;
|
procedure TVpDayView.EditSelectedEvent;
|
||||||
begin
|
begin
|
||||||
if ReadOnly then
|
if ReadOnly then
|
||||||
|
Reference in New Issue
Block a user