mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:59:31 +02:00
qt: start HitTest implementation for calendar
git-svn-id: trunk@19125 -
This commit is contained in:
parent
0725aa4cca
commit
3215e2c1d2
@ -51,9 +51,8 @@ type
|
|||||||
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
||||||
class function GetCalendar(const ACalendar: TCustomCalendar): PGtkCalendar; inline;
|
class function GetCalendar(const ACalendar: TCustomCalendar): PGtkCalendar; inline;
|
||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
|
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
||||||
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
|
||||||
class function HitTest(const ACalendar: TCustomCalendar; const APoint: TPoint): TCalendarPart; override;
|
class function HitTest(const ACalendar: TCustomCalendar; const APoint: TPoint): TCalendarPart; override;
|
||||||
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
|
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
|
||||||
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar;
|
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar;
|
||||||
|
@ -1250,6 +1250,7 @@ type
|
|||||||
procedure AttachEvents; override;
|
procedure AttachEvents; override;
|
||||||
procedure DetachEvents; override;
|
procedure DetachEvents; override;
|
||||||
function calViewportEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function calViewportEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
|
function HitTest(const APoint: TPoint): byte;
|
||||||
|
|
||||||
procedure SignalActivated(ADate: QDateH); cdecl;
|
procedure SignalActivated(ADate: QDateH); cdecl;
|
||||||
procedure SignalClicked(ADate: QDateH); cdecl;
|
procedure SignalClicked(ADate: QDateH); cdecl;
|
||||||
@ -6869,7 +6870,6 @@ procedure TQtListWidget.SlotMouseCheckListBox(Sender: QObjectH; Event: QEventH
|
|||||||
); cdecl;
|
); cdecl;
|
||||||
var
|
var
|
||||||
MousePos: TQtPoint;
|
MousePos: TQtPoint;
|
||||||
Msg: TLMessage;
|
|
||||||
x: Integer;
|
x: Integer;
|
||||||
w: QListWidgetItemH;
|
w: QListWidgetItemH;
|
||||||
begin
|
begin
|
||||||
@ -6895,8 +6895,6 @@ end;
|
|||||||
|
|
||||||
function TQtListWidget.itemViewViewportEventFilter(Sender: QObjectH;
|
function TQtListWidget.itemViewViewportEventFilter(Sender: QObjectH;
|
||||||
Event: QEventH): Boolean; cdecl;
|
Event: QEventH): Boolean; cdecl;
|
||||||
var
|
|
||||||
NewEvent: QMouseEventH;
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
QEvent_accept(Event);
|
QEvent_accept(Event);
|
||||||
@ -7577,7 +7575,6 @@ var
|
|||||||
AParent: QTreeWidgetItemH;
|
AParent: QTreeWidgetItemH;
|
||||||
AIndex: Integer;
|
AIndex: Integer;
|
||||||
ASubIndex: Integer;
|
ASubIndex: Integer;
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
FillChar(Msg, SizeOf(Msg), #0);
|
FillChar(Msg, SizeOf(Msg), #0);
|
||||||
FillChar(NMLV, SizeOf(NMLV), #0);
|
FillChar(NMLV, SizeOf(NMLV), #0);
|
||||||
@ -7694,8 +7691,6 @@ var
|
|||||||
NMLV: TNMListView;
|
NMLV: TNMListView;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
Pt: TPoint;
|
Pt: TPoint;
|
||||||
Index: Integer;
|
|
||||||
AItem: QTreeWidgetItemH;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
// we'll send also which item is clicked ... probably future
|
// we'll send also which item is clicked ... probably future
|
||||||
@ -9028,6 +9023,53 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtCalendar.HitTest(const APoint: TPoint): byte;
|
||||||
|
var
|
||||||
|
Layout: QLayoutH;
|
||||||
|
CalendarBody: QWidgetH;
|
||||||
|
HeaderRect, BodyRect: TRect;
|
||||||
|
AQtPoint: TQtPoint;
|
||||||
|
Index: QModelIndexH;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
Layout := QWidget_layout(Widget);
|
||||||
|
// layout must have 2 items:
|
||||||
|
// 1 - navigation bar
|
||||||
|
// 2 - calendar model
|
||||||
|
if QLayout_count(Layout) <> 2 then
|
||||||
|
Exit;
|
||||||
|
QLayoutItem_geometry(QLayout_itemAt(Layout, 0), @HeaderRect);
|
||||||
|
QLayoutItem_geometry(QLayout_itemAt(Layout, 1), @BodyRect);
|
||||||
|
if PtInRect(HeaderRect, APoint) then
|
||||||
|
begin
|
||||||
|
// we are in the header
|
||||||
|
Result := 3;
|
||||||
|
// todo: detail result more - button / month / year
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if PtInRect(BodyRect, APoint) then
|
||||||
|
begin
|
||||||
|
CalendarBody := QLayoutItem_widget(QLayout_itemAt(Layout, 1));
|
||||||
|
AQtPoint := QtPoint(APoint.X, APoint.Y);
|
||||||
|
QWidget_mapFrom(CalendarBody, @AQtPoint, Widget, @AQtPoint);
|
||||||
|
Index := QModelIndex_create();
|
||||||
|
try
|
||||||
|
QTableView_indexAt(QTableWidgetH(CalendarBody), Index, @AQtPoint);
|
||||||
|
if (QCalendarWidget_horizontalHeaderFormat(QCalendarWidgetH(Widget)) = QCalendarWidgetNoHorizontalHeader) or
|
||||||
|
(QModelIndex_row(Index) > 0) then
|
||||||
|
begin
|
||||||
|
if (QCalendarWidget_verticalHeaderFormat(QCalendarWidgetH(Widget)) = QCalendarWidgetNoVerticalHeader) or
|
||||||
|
(QModelIndex_column(Index) > 0) then
|
||||||
|
Result := 1
|
||||||
|
else
|
||||||
|
Result := 2;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
QModelIndex_destroy(Index);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtCalendar.SignalActivated
|
Function: TQtCalendar.SignalActivated
|
||||||
Params: None
|
Params: None
|
||||||
|
@ -33,9 +33,9 @@ uses
|
|||||||
qt4,
|
qt4,
|
||||||
qtwidgets,
|
qtwidgets,
|
||||||
// LCL
|
// LCL
|
||||||
SysUtils, DateUtils, Controls, Calendar, LCLType, LCLIntf, LCLProc,
|
SysUtils, Types, DateUtils, Controls, Calendar, LCLType, LCLIntf, LCLProc,
|
||||||
// Widgetset
|
// Widgetset
|
||||||
WSCalendar, WSLCLClasses;
|
WSProc, WSCalendar, WSLCLClasses;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -43,8 +43,9 @@ type
|
|||||||
|
|
||||||
TQtWSCustomCalendar = class(TWSCustomCalendar)
|
TQtWSCustomCalendar = class(TWSCustomCalendar)
|
||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
||||||
|
class function HitTest(const ACalendar: TCustomCalendar; const APoint: TPoint): TCalendarPart; override;
|
||||||
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
|
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
|
||||||
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar; const ADisplaySettings: TDisplaySettings); override;
|
class procedure SetDisplaySettings(const ACalendar: TCustomCalendar; const ADisplaySettings: TDisplaySettings); override;
|
||||||
end;
|
end;
|
||||||
@ -84,6 +85,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TQtWSCustomCalendar.HitTest(const ACalendar: TCustomCalendar;
|
||||||
|
const APoint: TPoint): TCalendarPart;
|
||||||
|
var
|
||||||
|
QtCalendar: TQtCalendar;
|
||||||
|
begin
|
||||||
|
Result := cpNoWhere;
|
||||||
|
if not WSCheckHandleAllocated(ACalendar, 'HitTest') then
|
||||||
|
Exit;
|
||||||
|
QtCalendar := TQtCalendar(ACalendar.Handle);
|
||||||
|
Result := TCalendarPart(QtCalendar.HitTest(APoint))
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TQtWSCustomCalendar.SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime);
|
class procedure TQtWSCustomCalendar.SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime);
|
||||||
var
|
var
|
||||||
QtCalendar: TQtCalendar;
|
QtCalendar: TQtCalendar;
|
||||||
|
@ -123,6 +123,7 @@ var
|
|||||||
HitTestInfo: MCHITTESTINFO;
|
HitTestInfo: MCHITTESTINFO;
|
||||||
HitPart: DWord;
|
HitPart: DWord;
|
||||||
begin
|
begin
|
||||||
|
Result := cpNoWhere;
|
||||||
if not WSCheckHandleAllocated(ACalendar, 'TWin32WSCustomCalendar.HitTest') then
|
if not WSCheckHandleAllocated(ACalendar, 'TWin32WSCustomCalendar.HitTest') then
|
||||||
Exit;
|
Exit;
|
||||||
FillChar(HitTestInfo, SizeOf(HitTestInfo), 0);
|
FillChar(HitTestInfo, SizeOf(HitTestInfo), 0);
|
||||||
@ -139,8 +140,6 @@ begin
|
|||||||
MCHT_TITLEYEAR: Result := cpTitleYear;
|
MCHT_TITLEYEAR: Result := cpTitleYear;
|
||||||
MCHT_TITLEBTNNEXT,
|
MCHT_TITLEBTNNEXT,
|
||||||
MCHT_TITLEBTNPREV: Result := cpTitleBtn;
|
MCHT_TITLEBTNPREV: Result := cpTitleBtn;
|
||||||
else
|
|
||||||
Result := cpNoWhere;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user