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

View File

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

View File

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