CalLite: Override built-in popup menu by using custom popup menu.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5374 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-11-22 09:13:07 +00:00
parent f7c12d318b
commit a4e0e87fd5
3 changed files with 53 additions and 16 deletions

View File

@ -60,7 +60,7 @@ object Form1: TForm1
object cbUseHolidays: TCheckBox
Left = 560
Height = 19
Top = 48
Top = 112
Width = 169
Caption = 'Ignore OnGetHolidays event'
OnChange = cbUseHolidaysChange
@ -80,7 +80,7 @@ object Form1: TForm1
object LWidth: TLabel
Left = 560
Height = 15
Top = 89
Top = 50
Width = 32
Caption = 'Width'
ParentColor = False
@ -88,7 +88,7 @@ object Form1: TForm1
object seWidth: TSpinEdit
Left = 617
Height = 23
Top = 87
Top = 48
Width = 66
MaxValue = 1000
MinValue = 120
@ -99,7 +99,7 @@ object Form1: TForm1
object seHeight: TSpinEdit
Left = 617
Height = 23
Top = 120
Top = 81
Width = 66
MaxValue = 1000
MinValue = 120
@ -110,7 +110,7 @@ object Form1: TForm1
object lHeight: TLabel
Left = 560
Height = 15
Top = 120
Top = 81
Width = 36
Caption = 'Height'
ParentColor = False
@ -176,11 +176,11 @@ object Form1: TForm1
end
object GroupBox1: TGroupBox
Left = 376
Height = 352
Height = 384
Top = 40
Width = 160
Caption = 'Colors'
ClientHeight = 332
ClientHeight = 364
ClientWidth = 156
TabOrder = 6
object CbArrowBorder: TColorButton
@ -434,7 +434,7 @@ object Form1: TForm1
object CbPrepareCanvas: TCheckBox
Left = 560
Height = 19
Top = 192
Top = 184
Width = 144
Caption = 'Override font of 1st day'
OnChange = CbPrepareCanvasChange
@ -452,7 +452,7 @@ object Form1: TForm1
object CbDrawCell: TCheckBox
Left = 560
Height = 19
Top = 216
Top = 208
Width = 161
Caption = 'Owner draw (icon, Nov 11)'
OnChange = CbDrawCellChange
@ -461,7 +461,7 @@ object Form1: TForm1
object CbAddHolidayNameToCell: TCheckBox
Left = 560
Height = 19
Top = 168
Top = 136
Width = 152
Caption = 'Add holiday name to cell'
OnChange = CbAddHolidayNameToCellChange
@ -470,7 +470,7 @@ object Form1: TForm1
object CbShowHints: TCheckBox
Left = 560
Height = 19
Top = 240
Top = 232
Width = 92
Caption = 'CbShowHints'
Checked = True
@ -481,7 +481,7 @@ object Form1: TForm1
object CbMultiSelect: TCheckBox
Left = 560
Height = 19
Top = 264
Top = 256
Width = 81
Caption = 'Multi select'
OnChange = CbMultiSelectChange
@ -489,13 +489,24 @@ object Form1: TForm1
end
object SelDateListbox: TListBox
Left = 560
Height = 104
Top = 288
Height = 144
Top = 280
Width = 168
Columns = 2
ItemHeight = 0
TabOrder = 13
end
object CbUseBuiltinPopup: TCheckBox
Left = 560
Height = 19
Top = 160
Width = 153
Caption = 'Use built-in popup menu'
Checked = True
OnChange = CbUseBuiltinPopupChange
State = cbChecked
TabOrder = 14
end
end
object Label1: TLabel
Left = 15
@ -550,4 +561,17 @@ object Form1: TForm1
EF3EFFFFFF00FFFFFF00FFFFFF00
}
end
object PopupMenu1: TPopupMenu
left = 117
top = 465
object MenuItem1: TMenuItem
Caption = 'Dummy item'
end
object MenuItem2: TMenuItem
Caption = 'Another dummy item'
end
object MenuItem3: TMenuItem
Caption = 'Last dummy item'
end
end
end

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, Forms, Graphics, ExtCtrls, StdCtrls, Spin, Dialogs,
Controls, CalendarLite;
Controls, Menus, CalendarLite;
type
@ -34,6 +34,7 @@ type
CbAddHolidayNameToCell: TCheckBox;
CbShowHints: TCheckBox;
CbMultiSelect: TCheckBox;
CbUseBuiltinPopup: TCheckBox;
FontDialog: TFontDialog;
GroupBox1: TGroupBox;
ImageList1: TImageList;
@ -51,6 +52,10 @@ type
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
PopupMenu1: TPopupMenu;
SelDateListbox: TListBox;
LTitle: TLabel;
LWidth: TLabel;
@ -66,6 +71,7 @@ type
procedure CbMultiSelectChange(Sender: TObject);
procedure CbPrepareCanvasChange(Sender: TObject);
procedure CbShowHintsChange(Sender: TObject);
procedure CbUseBuiltinPopupChange(Sender: TObject);
procedure ColorButtonChanged(Sender: TObject);
procedure cbUseHolidaysChange(Sender: TObject);
procedure cgOptionsItemClick(Sender: TObject; Index: integer);
@ -253,6 +259,13 @@ begin
copyCal.Options := demoCal.Options;
end;
procedure TForm1.CbUseBuiltinPopupChange(Sender: TObject);
begin
if CbUseBuiltinPopup.Checked then
demoCal.PopupMenu := nil else
demoCal.PopupMenu := PopupMenu1;
end;
procedure TForm1.CbAddHolidayNameToCellChange(Sender: TObject);
begin
if CbAddHolidayNameToCell.Checked then

View File

@ -1226,7 +1226,7 @@ end;
procedure TCalDrawer.RightClick;
begin
if Assigned(FOwner.FOnGetHolidays) then
if (FOwner.PopupMenu = nil) and Assigned(FOwner.FOnGetHolidays) then
begin
FOwner.PopulateHolidayPopupMenu;
FOwner.FPopupMenu.PopUp(Mouse.CursorPos.x, Mouse.CursorPos.y);