mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 05:36:22 +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 function GetCalendar(const ACalendar: TCustomCalendar): PGtkCalendar; inline;
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
|
||||
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 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 SetDisplaySettings(const ACalendar: TCustomCalendar;
|
||||
|
@ -1250,6 +1250,7 @@ type
|
||||
procedure AttachEvents; override;
|
||||
procedure DetachEvents; override;
|
||||
function calViewportEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||
function HitTest(const APoint: TPoint): byte;
|
||||
|
||||
procedure SignalActivated(ADate: QDateH); cdecl;
|
||||
procedure SignalClicked(ADate: QDateH); cdecl;
|
||||
@ -6869,7 +6870,6 @@ procedure TQtListWidget.SlotMouseCheckListBox(Sender: QObjectH; Event: QEventH
|
||||
); cdecl;
|
||||
var
|
||||
MousePos: TQtPoint;
|
||||
Msg: TLMessage;
|
||||
x: Integer;
|
||||
w: QListWidgetItemH;
|
||||
begin
|
||||
@ -6895,8 +6895,6 @@ end;
|
||||
|
||||
function TQtListWidget.itemViewViewportEventFilter(Sender: QObjectH;
|
||||
Event: QEventH): Boolean; cdecl;
|
||||
var
|
||||
NewEvent: QMouseEventH;
|
||||
begin
|
||||
Result := False;
|
||||
QEvent_accept(Event);
|
||||
@ -7577,7 +7575,6 @@ var
|
||||
AParent: QTreeWidgetItemH;
|
||||
AIndex: Integer;
|
||||
ASubIndex: Integer;
|
||||
i: Integer;
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
FillChar(NMLV, SizeOf(NMLV), #0);
|
||||
@ -7694,8 +7691,6 @@ var
|
||||
NMLV: TNMListView;
|
||||
R: TRect;
|
||||
Pt: TPoint;
|
||||
Index: Integer;
|
||||
AItem: QTreeWidgetItemH;
|
||||
i: Integer;
|
||||
begin
|
||||
// we'll send also which item is clicked ... probably future
|
||||
@ -9028,6 +9023,53 @@ begin
|
||||
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
|
||||
Params: None
|
||||
|
@ -33,9 +33,9 @@ uses
|
||||
qt4,
|
||||
qtwidgets,
|
||||
// LCL
|
||||
SysUtils, DateUtils, Controls, Calendar, LCLType, LCLIntf, LCLProc,
|
||||
SysUtils, Types, DateUtils, Controls, Calendar, LCLType, LCLIntf, LCLProc,
|
||||
// Widgetset
|
||||
WSCalendar, WSLCLClasses;
|
||||
WSProc, WSCalendar, WSLCLClasses;
|
||||
|
||||
type
|
||||
|
||||
@ -43,8 +43,9 @@ type
|
||||
|
||||
TQtWSCustomCalendar = class(TWSCustomCalendar)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 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 SetDisplaySettings(const ACalendar: TCustomCalendar; const ADisplaySettings: TDisplaySettings); override;
|
||||
end;
|
||||
@ -84,6 +85,18 @@ begin
|
||||
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);
|
||||
var
|
||||
QtCalendar: TQtCalendar;
|
||||
|
@ -123,6 +123,7 @@ var
|
||||
HitTestInfo: MCHITTESTINFO;
|
||||
HitPart: DWord;
|
||||
begin
|
||||
Result := cpNoWhere;
|
||||
if not WSCheckHandleAllocated(ACalendar, 'TWin32WSCustomCalendar.HitTest') then
|
||||
Exit;
|
||||
FillChar(HitTestInfo, SizeOf(HitTestInfo), 0);
|
||||
@ -139,8 +140,6 @@ begin
|
||||
MCHT_TITLEYEAR: Result := cpTitleYear;
|
||||
MCHT_TITLEBTNNEXT,
|
||||
MCHT_TITLEBTNPREV: Result := cpTitleBtn;
|
||||
else
|
||||
Result := cpNoWhere;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user