You've already forked lazarus-ccr
TRxDateRangeEdit - add Quarter and HalfYear
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3260 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -89,10 +89,22 @@ msgstr ""
|
||||
msgid "File specified is not an executable file, dynamic-link library, or icon file"
|
||||
msgstr "Fichero especificado no es un fichero ejecutable, vinculo dinamico, o fichero de icono"
|
||||
|
||||
#: rxconst.sfirsthalfofyear
|
||||
msgid "First half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfirstquarter
|
||||
msgid "First quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sflatbuttons
|
||||
msgid "Flat buttons"
|
||||
msgstr "Botones planos"
|
||||
|
||||
#: rxconst.sfourthquarter
|
||||
msgid "Fourth quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfpcversion
|
||||
msgid "FPC version : "
|
||||
msgstr ""
|
||||
@ -169,6 +181,14 @@ msgstr ""
|
||||
msgid "Error. Expected value for filed %s."
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.ssecondhalfofyear
|
||||
msgid "Second half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.ssecondquarter
|
||||
msgid "Second quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sshowcaption
|
||||
msgid "Show caption"
|
||||
msgstr "Mostrar titulo"
|
||||
@ -185,6 +205,10 @@ msgstr ""
|
||||
msgid "Target OS : "
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sthirdquarter
|
||||
msgid "Third quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.stocurdate
|
||||
msgid "Set current date"
|
||||
msgstr "Poner fecha actual"
|
||||
|
@ -89,10 +89,22 @@ msgstr ""
|
||||
msgid "File specified is not an executable file, dynamic-link library, or icon file"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfirsthalfofyear
|
||||
msgid "First half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfirstquarter
|
||||
msgid "First quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sflatbuttons
|
||||
msgid "Flat buttons"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfourthquarter
|
||||
msgid "Fourth quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfpcversion
|
||||
msgid "FPC version : "
|
||||
msgstr ""
|
||||
@ -169,6 +181,14 @@ msgstr ""
|
||||
msgid "Error. Expected value for filed %s."
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.ssecondhalfofyear
|
||||
msgid "Second half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.ssecondquarter
|
||||
msgid "Second quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sshowcaption
|
||||
msgid "Show caption"
|
||||
msgstr ""
|
||||
@ -185,6 +205,10 @@ msgstr ""
|
||||
msgid "Target OS : "
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sthirdquarter
|
||||
msgid "Third quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.stocurdate
|
||||
msgid "Set current date"
|
||||
msgstr ""
|
||||
|
@ -89,10 +89,22 @@ msgstr "Элемент управления не найден в валидат
|
||||
msgid "File specified is not an executable file, dynamic-link library, or icon file"
|
||||
msgstr "Указанный файл не исполняемый, не библиотека и не иконка"
|
||||
|
||||
#: rxconst.sfirsthalfofyear
|
||||
msgid "First half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfirstquarter
|
||||
msgid "First quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sflatbuttons
|
||||
msgid "Flat buttons"
|
||||
msgstr "Плавающие кнопки"
|
||||
|
||||
#: rxconst.sfourthquarter
|
||||
msgid "Fourth quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfpcversion
|
||||
msgid "FPC version : "
|
||||
msgstr "Версия FPC : "
|
||||
@ -169,6 +181,14 @@ msgstr "Графический интерфейс QT"
|
||||
msgid "Error. Expected value for filed %s."
|
||||
msgstr "Поле %s. Требуется значение"
|
||||
|
||||
#: rxconst.ssecondhalfofyear
|
||||
msgid "Second half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.ssecondquarter
|
||||
msgid "Second quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sshowcaption
|
||||
msgid "Show caption"
|
||||
msgstr "Отображать заголовок"
|
||||
@ -185,6 +205,10 @@ msgstr "Целевой процессор : "
|
||||
msgid "Target OS : "
|
||||
msgstr "Целевая ОС : "
|
||||
|
||||
#: rxconst.sthirdquarter
|
||||
msgid "Third quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.stocurdate
|
||||
msgid "Set current date"
|
||||
msgstr "Установть текущую дату"
|
||||
|
@ -98,10 +98,22 @@ msgstr "Елемент управління не знайдений в валі
|
||||
msgid "File specified is not an executable file, dynamic-link library, or icon file"
|
||||
msgstr "Вказаний файл не виконуваний, не бібліотека і не іконка"
|
||||
|
||||
#: rxconst.sfirsthalfofyear
|
||||
msgid "First half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfirstquarter
|
||||
msgid "First quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sflatbuttons
|
||||
msgid "Flat buttons"
|
||||
msgstr "Плаваючі кнопки"
|
||||
|
||||
#: rxconst.sfourthquarter
|
||||
msgid "Fourth quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sfpcversion
|
||||
msgid "FPC version : "
|
||||
msgstr "Версія FPC : "
|
||||
@ -178,6 +190,14 @@ msgstr "Набір віджетів QT"
|
||||
msgid "Error. Expected value for filed %s."
|
||||
msgstr "Поле %s. Вимагається значення"
|
||||
|
||||
#: rxconst.ssecondhalfofyear
|
||||
msgid "Second half of year"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.ssecondquarter
|
||||
msgid "Second quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.sshowcaption
|
||||
msgid "Show caption"
|
||||
msgstr "Показати заголовок"
|
||||
@ -194,6 +214,10 @@ msgstr "Цільовий CPU : "
|
||||
msgid "Target OS : "
|
||||
msgstr "Цільова OS : "
|
||||
|
||||
#: rxconst.sthirdquarter
|
||||
msgid "Third quarter"
|
||||
msgstr ""
|
||||
|
||||
#: rxconst.stocurdate
|
||||
msgid "Set current date"
|
||||
msgstr "Встановити поточну дату"
|
||||
|
@ -47,10 +47,17 @@ procedure Register;
|
||||
implementation
|
||||
uses
|
||||
PropEdits, folderlister, duallist, RxHistoryNavigator,
|
||||
curredit, rxswitch, rxdice, rxtoolbar, rxxpman, PageMngr, RxAppIcon,
|
||||
Dialogs, ComponentEditors, DBPropEdits, DB, rxctrls,
|
||||
RxCustomChartPanel, AutoPanel, pickdate, rxconst, tooledit, rxclock,
|
||||
rxpopupunit, rxspin, RxTimeEdit, rxDateRangeEditUnit,
|
||||
curredit, rxswitch, rxdice, rxtoolbar,
|
||||
{$IFDEF USE_TRXXPManifest}
|
||||
rxxpman,
|
||||
{$ENDIF}
|
||||
PageMngr,
|
||||
{$IFDEF USE_TRxAppIcon}
|
||||
RxAppIcon,
|
||||
{$ENDIF}
|
||||
Dialogs, ComponentEditors, DBPropEdits, rxctrls,
|
||||
RxCustomChartPanel, AutoPanel, pickdate, tooledit, rxclock,
|
||||
rxspin, RxTimeEdit, rxDateRangeEditUnit,
|
||||
RxAboutDialog, RxViewsPanel, RxMDI;
|
||||
|
||||
{$IFDEF USE_TRxAppIcon}
|
||||
|
@ -128,6 +128,14 @@ resourcestring
|
||||
sCloseAllExceptThis = 'Close all except this';
|
||||
sCloseAllWindows = 'Close all windows';
|
||||
|
||||
{ TRxDateRangeEdit }
|
||||
sFirstQuarter = 'First quarter';
|
||||
sSecondQuarter = 'Second quarter';
|
||||
sThirdQuarter = 'Third quarter';
|
||||
sFourthQuarter = 'Fourth quarter';
|
||||
sFirstHalfOfYear = 'First half of year';
|
||||
sSecondHalfOfYear = 'Second half of year';
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
@ -7,6 +7,10 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, types, Controls, Buttons, StdCtrls, Spin;
|
||||
|
||||
type
|
||||
TRxDateRangeEditOption = (reoMonth, reoQuarter, reoHalfYear);
|
||||
TRxDateRangeEditOptions = set of TRxDateRangeEditOption;
|
||||
|
||||
type
|
||||
|
||||
{ TRxCustomDateRangeEdit }
|
||||
@ -18,6 +22,7 @@ type
|
||||
FOnEditClick: TNotifyEvent;
|
||||
FOnEditEnter: TNotifyEvent;
|
||||
FOnEditExit: TNotifyEvent;
|
||||
FOptions: TRxDateRangeEditOptions;
|
||||
FsbDecYear: TSpeedButton;
|
||||
FsbDecMonth: TSpeedButton;
|
||||
FsbIncYear: TSpeedButton;
|
||||
@ -28,12 +33,18 @@ type
|
||||
procedure DoIncYear(Sender: TObject);
|
||||
procedure DoDecMonth(Sender: TObject);
|
||||
procedure DoDecYear(Sender: TObject);
|
||||
function GetHalfYear: word;
|
||||
function GetMonth: word;
|
||||
function GetPeriod: TDateTime;
|
||||
function GetPeriodEnd: TDateTime;
|
||||
function GetQuarter: word;
|
||||
function GetYear: word;
|
||||
procedure SetFlat(AValue: Boolean);
|
||||
procedure SetHalfYear(AValue: word);
|
||||
procedure SetMonth(AValue: word);
|
||||
procedure SetOptions(AValue: TRxDateRangeEditOptions);
|
||||
procedure SetPeriod(AValue: TDateTime);
|
||||
procedure SetQuarter(AValue: word);
|
||||
procedure SetYear(AValue: word);
|
||||
procedure InternalOnEditChange(Sender: TObject);
|
||||
procedure InternalOnEditClick(Sender: TObject);
|
||||
@ -50,10 +61,15 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
property Quarter:word read GetQuarter write SetQuarter;
|
||||
property HalfYear:word read GetHalfYear write SetHalfYear;
|
||||
property Flat: Boolean read FFlat write SetFlat default False;
|
||||
property Year:word read GetYear write SetYear;
|
||||
property Month:word read GetMonth write SetMonth;
|
||||
property Period:TDateTime read GetPeriod write SetPeriod;
|
||||
property PeriodEnd:TDateTime read GetPeriodEnd;
|
||||
property Options:TRxDateRangeEditOptions read FOptions write SetOptions default [reoMonth];
|
||||
property OnChange: TNotifyEvent read FOnEditChange write FOnEditChange;
|
||||
property OnClick: TNotifyEvent read FOnEditClick write FOnEditClick;
|
||||
property OnEnter: TNotifyEvent read FOnEditEnter write FOnEditEnter;
|
||||
@ -63,30 +79,29 @@ type
|
||||
type
|
||||
TRxDateRangeEdit = class(TRxCustomDateRangeEdit)
|
||||
published
|
||||
property Autosize default True;
|
||||
property Align;
|
||||
property Anchors;
|
||||
property Autosize default True;
|
||||
property BiDiMode;
|
||||
property BorderSpacing;
|
||||
property BorderStyle default bsNone;
|
||||
property Constraints;
|
||||
property Color;
|
||||
property Constraints;
|
||||
property Cursor;
|
||||
property Enabled;
|
||||
property Flat;
|
||||
property Year;
|
||||
property Month;
|
||||
property Hint;
|
||||
property Month;
|
||||
property Options;
|
||||
property ParentBiDiMode;
|
||||
property ParentColor;
|
||||
property ParentFont;
|
||||
property PopupMenu;
|
||||
// property ReadOnly;
|
||||
property ShowHint;
|
||||
property TabOrder;
|
||||
property TabStop;
|
||||
// property Text;
|
||||
property Visible;
|
||||
property Year;
|
||||
|
||||
property OnChange;
|
||||
property OnClick;
|
||||
@ -95,18 +110,51 @@ type
|
||||
end;
|
||||
|
||||
implementation
|
||||
uses dateutil, rxconst;
|
||||
|
||||
{ TRxCustomDateRangeEdit }
|
||||
|
||||
procedure TRxCustomDateRangeEdit.DoIncMonth(Sender: TObject);
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
if FEditMonth.ItemIndex < 11 then
|
||||
FEditMonth.ItemIndex := FEditMonth.ItemIndex + 1
|
||||
if FEditMonth.ItemIndex>=0 then
|
||||
begin
|
||||
i:=PtrInt(FEditMonth.Items.Objects[FEditMonth.ItemIndex]);
|
||||
|
||||
if I in [17, 18] then
|
||||
begin
|
||||
if i = 18 then
|
||||
begin
|
||||
i:=17;
|
||||
Year:=Year + 1;
|
||||
end
|
||||
else
|
||||
i:=18;
|
||||
end
|
||||
else
|
||||
if i in [13..16] then
|
||||
begin
|
||||
inc(i);
|
||||
if i> 16 then
|
||||
begin
|
||||
i:=13;
|
||||
Year:=Year + 1;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FEditMonth.ItemIndex := 0;
|
||||
FEditYear.Value:=FEditYear.Value + 1;
|
||||
inc(i);
|
||||
if i > 12 then
|
||||
begin
|
||||
i:=1;
|
||||
Year:=Year + 1;
|
||||
end;
|
||||
end;
|
||||
FEditMonth.ItemIndex := i - 1;
|
||||
end
|
||||
else
|
||||
FEditMonth.ItemIndex := 0;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.DoIncYear(Sender: TObject);
|
||||
@ -115,14 +163,46 @@ begin
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.DoDecMonth(Sender: TObject);
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
if FEditMonth.ItemIndex > 0 then
|
||||
FEditMonth.ItemIndex := FEditMonth.ItemIndex - 1
|
||||
if FEditMonth.ItemIndex>=0 then
|
||||
begin
|
||||
i:=PtrInt(FEditMonth.Items.Objects[FEditMonth.ItemIndex]);
|
||||
|
||||
if I in [17, 18] then
|
||||
begin
|
||||
if i = 18 then
|
||||
begin
|
||||
i:=17;
|
||||
Year:=Year - 1;
|
||||
end
|
||||
else
|
||||
i:=18;
|
||||
end
|
||||
else
|
||||
if i in [13..16] then
|
||||
begin
|
||||
Dec(i);
|
||||
if i> 13 then
|
||||
begin
|
||||
i:=16;
|
||||
Year:=Year - 1;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
FEditMonth.ItemIndex := 11;
|
||||
FEditYear.Value:=FEditYear.Value - 1;
|
||||
Dec(i);
|
||||
if i < 1 then
|
||||
begin
|
||||
i:=12;
|
||||
Year:=Year - 1;
|
||||
end;
|
||||
end;
|
||||
FEditMonth.ItemIndex := i - 1;
|
||||
end
|
||||
else
|
||||
FEditMonth.ItemIndex := 0;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.DoDecYear(Sender: TObject);
|
||||
@ -130,9 +210,30 @@ begin
|
||||
FEditYear.Value:=FEditYear.Value - 1;
|
||||
end;
|
||||
|
||||
function TRxCustomDateRangeEdit.GetMonth: word;
|
||||
function TRxCustomDateRangeEdit.GetHalfYear: word;
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
Result:=FEditMonth.ItemIndex+1;
|
||||
Result:=0;
|
||||
if reoHalfYear in FOptions then
|
||||
begin
|
||||
i:=PtrInt(FEditMonth.Items.Objects[FEditMonth.ItemIndex]);
|
||||
if i in [17..18] then
|
||||
Result:=i - 16;
|
||||
end
|
||||
end;
|
||||
|
||||
function TRxCustomDateRangeEdit.GetMonth: word;
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
Result:=0;
|
||||
if (reoMonth in FOptions) or (FOptions = []) then
|
||||
begin
|
||||
i:=PtrInt(FEditMonth.Items.Objects[FEditMonth.ItemIndex]);
|
||||
if i in [1..12] then
|
||||
Result:=i;
|
||||
end
|
||||
end;
|
||||
|
||||
function TRxCustomDateRangeEdit.GetPeriod: TDateTime;
|
||||
@ -140,6 +241,24 @@ begin
|
||||
Result:=EncodeDate(Year, Month, 1);
|
||||
end;
|
||||
|
||||
function TRxCustomDateRangeEdit.GetPeriodEnd: TDateTime;
|
||||
begin
|
||||
Result:=EncodeDate(Year, Month, DaysPerMonth(Year, Month));
|
||||
end;
|
||||
|
||||
function TRxCustomDateRangeEdit.GetQuarter: word;
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
Result:=0;
|
||||
if reoQuarter in FOptions then
|
||||
begin
|
||||
i:=PtrInt(FEditMonth.Items.Objects[FEditMonth.ItemIndex]);
|
||||
if i in [13..16] then
|
||||
Result:=i - 12;
|
||||
end
|
||||
end;
|
||||
|
||||
function TRxCustomDateRangeEdit.GetYear: word;
|
||||
begin
|
||||
Result:=FEditYear.Value;
|
||||
@ -155,12 +274,24 @@ begin
|
||||
FsbIncYear.Flat:=FFlat;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetHalfYear(AValue: word);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetMonth(AValue: word);
|
||||
begin
|
||||
if (AValue>0) and (AValue < 13) then
|
||||
FEditMonth.ItemIndex:=AValue-1;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetOptions(AValue: TRxDateRangeEditOptions);
|
||||
begin
|
||||
if FOptions=AValue then Exit;
|
||||
FOptions:=AValue;
|
||||
FillMonthNames;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetPeriod(AValue: TDateTime);
|
||||
var
|
||||
Y, M, D: word;
|
||||
@ -170,6 +301,11 @@ begin
|
||||
FEditYear.Value:=Y;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetQuarter(AValue: word);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetYear(AValue: word);
|
||||
begin
|
||||
FEditYear.Value:=AValue;
|
||||
@ -203,10 +339,40 @@ end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.FillMonthNames;
|
||||
var
|
||||
i: Integer;
|
||||
i, k: Integer;
|
||||
begin
|
||||
FEditMonth.Items.BeginUpdate;
|
||||
FEditMonth.Items.Clear;
|
||||
if (reoMonth in FOptions) or (FOptions = []) then
|
||||
begin
|
||||
for i:=1 to 12 do
|
||||
FEditMonth.Items.Add(DefaultFormatSettings.LongMonthNames[i]);
|
||||
begin
|
||||
k:=FEditMonth.Items.Add(DefaultFormatSettings.LongMonthNames[i]);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(i));
|
||||
end;
|
||||
end;
|
||||
|
||||
if (reoQuarter in FOptions) or (FOptions = []) then
|
||||
begin
|
||||
k:=FEditMonth.Items.Add(sFirstQuarter);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(13));
|
||||
k:=FEditMonth.Items.Add(sSecondQuarter);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(14));
|
||||
k:=FEditMonth.Items.Add(sThirdQuarter);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(15));
|
||||
k:=FEditMonth.Items.Add(sFourthQuarter);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(16));
|
||||
end;
|
||||
|
||||
if (reoHalfYear in FOptions) or (FOptions = []) then
|
||||
begin
|
||||
k:=FEditMonth.Items.Add(sFirstHalfOfYear);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(17));
|
||||
k:=FEditMonth.Items.Add(sSecondHalfOfYear);
|
||||
FEditMonth.Items.Objects[K]:=TObject(Pointer(18));
|
||||
end;
|
||||
FEditMonth.ItemIndex:=0;
|
||||
FEditMonth.Items.EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TRxCustomDateRangeEdit.SetAutoSize(AValue: Boolean);
|
||||
@ -241,12 +407,14 @@ end;
|
||||
constructor TRxCustomDateRangeEdit.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FOptions:=[reoMonth];
|
||||
|
||||
FEditYear:=TSpinEdit.Create(Self);
|
||||
FEditMonth:=TComboBox.Create(Self);
|
||||
FEditMonth.Style:=csDropDownList;
|
||||
FEditMonth.DropDownCount:=12;
|
||||
FEditYear.Width:=70;
|
||||
FEditMonth.Width:=80;
|
||||
FEditMonth.Width:=100;
|
||||
|
||||
FsbDecYear:=TSpeedButton.Create(Self);
|
||||
FsbDecMonth:=TSpeedButton.Create(Self);
|
||||
|
Reference in New Issue
Block a user