fix error in TRxDateEdit - error show calendar grid after 15 day of month

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1848 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2011-08-28 09:57:53 +00:00
parent e0bebc82cd
commit 6a0864d20c
3 changed files with 65 additions and 87 deletions

View File

@ -54,16 +54,16 @@
<MinVersion Major="1" Release="18" Build="56" Valid="True"/> <MinVersion Major="1" Release="18" Build="56" Valid="True"/>
</Item4> </Item4>
</RequiredPackages> </RequiredPackages>
<Units Count="64"> <Units Count="65">
<Unit0> <Unit0>
<Filename Value="RxDBGridDemo.lpr"/> <Filename Value="RxDBGridDemo.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="RxDBGridDemo"/> <UnitName Value="RxDBGridDemo"/>
<EditorIndex Value="1"/> <EditorIndex Value="2"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="5" Y="17"/> <CursorPos X="5" Y="17"/>
<UsageCount Value="53"/> <UsageCount Value="54"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -72,12 +72,11 @@
<ComponentName Value="RxDBGridMainForm"/> <ComponentName Value="RxDBGridMainForm"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridMainUnit"/> <UnitName Value="RxDBGridMainUnit"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="87"/> <TopLine Value="87"/>
<CursorPos X="11" Y="9"/> <CursorPos X="11" Y="9"/>
<UsageCount Value="53"/> <UsageCount Value="54"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@ -396,11 +395,11 @@
<Unit45> <Unit45>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<UnitName Value="rxdbgrid"/> <UnitName Value="rxdbgrid"/>
<EditorIndex Value="2"/> <EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="2537"/> <TopLine Value="2537"/>
<CursorPos X="3" Y="2542"/> <CursorPos X="3" Y="2542"/>
<UsageCount Value="16"/> <UsageCount Value="17"/>
<Bookmarks Count="3"> <Bookmarks Count="3">
<Item0 X="3" Y="2250" ID="3"/> <Item0 X="3" Y="2250" ID="3"/>
<Item1 X="13" Y="1203" ID="1"/> <Item1 X="13" Y="1203" ID="1"/>
@ -524,11 +523,11 @@
<Unit59> <Unit59>
<Filename Value="/usr/local/share/lazarus/lcl/grids.pas"/> <Filename Value="/usr/local/share/lazarus/lcl/grids.pas"/>
<UnitName Value="Grids"/> <UnitName Value="Grids"/>
<EditorIndex Value="3"/> <EditorIndex Value="4"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="3866"/> <TopLine Value="3866"/>
<CursorPos X="1" Y="3891"/> <CursorPos X="1" Y="3891"/>
<UsageCount Value="13"/> <UsageCount Value="14"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit59> </Unit59>
<Unit60> <Unit60>
@ -557,15 +556,26 @@
</Unit62> </Unit62>
<Unit63> <Unit63>
<Filename Value="/usr/local/share/lazarus/lcl/include/canvas.inc"/> <Filename Value="/usr/local/share/lazarus/lcl/include/canvas.inc"/>
<EditorIndex Value="4"/> <EditorIndex Value="5"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1116"/> <TopLine Value="1116"/>
<CursorPos X="1" Y="1132"/> <CursorPos X="1" Y="1132"/>
<UsageCount Value="10"/> <UsageCount Value="11"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit63> </Unit63>
<Unit64>
<Filename Value="../../exsortsql.pas"/>
<UnitName Value="exsortsql"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="49" Y="3"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit64>
</Units> </Units>
<JumpHistory Count="27" HistoryIndex="26"> <JumpHistory Count="28" HistoryIndex="27">
<Position1> <Position1>
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="3141" Column="1" TopLine="3126"/> <Caret Line="3141" Column="1" TopLine="3126"/>
@ -674,6 +684,10 @@
<Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/> <Filename Value="/usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Caret Line="187" Column="49" TopLine="162"/> <Caret Line="187" Column="49" TopLine="162"/>
</Position27> </Position27>
<Position28>
<Filename Value="../../exsortsql.pas"/>
<Caret Line="3" Column="21" TopLine="1"/>
</Position28>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -40,15 +40,7 @@ uses
LCLProc, LMessages, ExtCtrls, StdCtrls, Buttons, Forms, Menus; LCLProc, LMessages, ExtCtrls, StdCtrls, Buttons, Forms, Menus;
{ TRxCalendar } { TRxCalendar }
{
const
//TRxShortDaysWeek: array[0..6] of string = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
TRxShortDaysOfWeek: array[0..6] of string =
('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
TRxLongMonthNames: array[0..11] of string =
('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December');
}
type type
TDayOfWeek = 0..6; TDayOfWeek = 0..6;
@ -270,8 +262,7 @@ const
implementation implementation
uses Messages, RXCtrls, rxconst, ToolEdit, vclutils, math, LCLStrConsts, uses Messages, RXCtrls, rxconst, ToolEdit, vclutils, math, LCLStrConsts,
rxstrutils, LResources {$IFDEF HASVARIANT}, Variants{$ENDIF} rxstrutils, LResources;
;
const const
SBtnGlyphs: array[0..3] of PChar = ('PREV2', 'PREV1', 'NEXT1', 'NEXT2'); SBtnGlyphs: array[0..3] of PChar = ('PREV2', 'PREV1', 'NEXT1', 'NEXT2');
@ -343,13 +334,11 @@ type
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
published published
property AllowTimer default True; property AllowTimer default True;
// property Style default bsWin31;
end; end;
constructor TRxTimerSpeedButton.Create(AOwner: TComponent); constructor TRxTimerSpeedButton.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
// Style := bsWin31;
AllowTimer := True; AllowTimer := True;
ControlStyle := ControlStyle + [csReplicatable]; ControlStyle := ControlStyle + [csReplicatable];
end; end;
@ -402,21 +391,10 @@ begin
with Params do with Params do
begin begin
WindowClass.Style := WindowClass.Style and DWORD(not ClassStylesOff); WindowClass.Style := WindowClass.Style and DWORD(not ClassStylesOff);
Style := Style or WS_VSCROLL or WS_HSCROLL or WS_CLIPCHILDREN; Style := Style or WS_CLIPCHILDREN;
end; end;
end; end;
(*
begin
inherited CreateParams(Params);
Params.Style := Params.Style or WS_BORDER;
Params.ExStyle := Params.ExStyle and not WS_EX_CLIENTEDGE;
{$IFDEF USED_BiDi}
AddBiDiModeExStyle(Params.ExStyle);
{$ENDIF}
end;
*)
procedure TCustomRxCalendar.Change; procedure TCustomRxCalendar.Change;
begin begin
if Assigned(FOnChange) then FOnChange(Self); if Assigned(FOnChange) then FOnChange(Self);
@ -426,8 +404,6 @@ procedure TCustomRxCalendar.Click;
var var
TheCellText: string; TheCellText: string;
begin begin
{ TheCellText := CellText[Col, Row];
if TheCellText <> '' then Day := StrToInt(TheCellText);}
FDate := FDaysArray[Col, Row].DayDate; FDate := FDaysArray[Col, Row].DayDate;
FUseCurrentDate := False; FUseCurrentDate := False;
CalendarUpdate(false); CalendarUpdate(false);
@ -489,26 +465,6 @@ begin
end; end;
end; end;
{
function TCustomRxCalendar.GetCellText(ACol, ARow: Integer): string;
var
DayNum: Integer;
begin
if ARow = 0 then { day names at tops of columns }
Result := ShortDayNames[(Ord(StartOfWeek) + ACol) mod 7 + 1]
else
begin
DayNum := FMonthOffset + ACol + (ARow - 1) * 7;
{ if (DayNum < 1) or (DayNum > DaysThisMonth) then Result := ''}
{ if (DayNum < 1) then
Result := ''
else
if (DayNum > DaysThisMonth) then
Result := ''
else }Result := IntToStr(DayNum);
end;
end;
}
procedure TCustomRxCalendar.KeyDown(var Key: Word; Shift: TShiftState); procedure TCustomRxCalendar.KeyDown(var Key: Word; Shift: TShiftState);
begin begin
if Shift = [] then if Shift = [] then
@ -673,14 +629,15 @@ end;
procedure TCustomRxCalendar.UpdateShortDaysOfWeek; procedure TCustomRxCalendar.UpdateShortDaysOfWeek;
var var
Ind: Integer; Ind: Integer;
//OldNotify: TNotifyEvent; OldNotify: TNotifyEvent;
begin begin
if (FShortDaysOfWeek <> nil) and (FShortDaysOfWeek.Count = 0) then begin if (FShortDaysOfWeek <> nil) and (FShortDaysOfWeek.Count = 0) then
//OldNotify := FDaysOfWeek.OnChange; begin
//TStringList(FShortDays).OnChange := nil; OldNotify := TStringList(FShortDaysOfWeek).OnChange;
TStringList(FShortDaysOfWeek).OnChange := nil;
for Ind := 1 to 7 do for Ind := 1 to 7 do
FShortDaysOfWeek.Add(SysUtils.ShortDayNames[Ind]); FShortDaysOfWeek.Add(SysUtils.ShortDayNames[Ind]);
//FShortDaysOfWeek.OnChange := OldNotify; TStringList(FShortDaysOfWeek).OnChange := OldNotify;
end; end;
end; end;
@ -835,11 +792,9 @@ begin
if FMonthOffset = 2 then FMonthOffset := -5; if FMonthOffset = 2 then FMonthOffset := -5;
FillDaysArray; FillDaysArray;
SelectedColumn; MoveExtend(false, (ADay - FMonthOffset) mod 7, (ADay - FMonthOffset) div 7 + 1);
TopRow:=1; //Правим ошибку для автоскрола календаря после 15 числа...
MoveExtend(False, (ADay - FMonthOffset) mod 7, (ADay - FMonthOffset) div 7 + 1); VisualChange;
LeftCol:=0;
TopRow:=0;
if DayOnly then Update else Invalidate; if DayOnly then Update else Invalidate;
finally finally
@ -996,7 +951,8 @@ begin
// if (csDesigning in ComponentState) then Exit; // if (csDesigning in ComponentState) then Exit;
FMonthNames := TStringList.Create; FMonthNames := TStringList.Create;
if FMonthNames.Count = 0 then begin if FMonthNames.Count = 0 then
begin
for i := Low(LongMonthNames) to High(LongMonthNames) do for i := Low(LongMonthNames) to High(LongMonthNames) do
FMonthNames.Add(LongMonthNames[i]); FMonthNames.Add(LongMonthNames[i]);
end; end;
@ -1052,7 +1008,6 @@ begin
begin begin
Parent := FControlPanel; Parent := FControlPanel;
SetBounds(-1, -1, BtnSide, BtnSide); SetBounds(-1, -1, BtnSide, BtnSide);
// Glyph := LoadBitmapFromLazarusResource('prev2');
//loaded bitmap should be freed as Glyph just takes a copy of it //loaded bitmap should be freed as Glyph just takes a copy of it
TmpBitmap:=LoadBitmapFromLazarusResource('prev2'); TmpBitmap:=LoadBitmapFromLazarusResource('prev2');
Glyph := TmpBitmap; Glyph := TmpBitmap;
@ -1068,7 +1023,6 @@ begin
begin begin
Parent := FControlPanel; Parent := FControlPanel;
SetBounds(BtnSide - 2, -1, BtnSide, BtnSide); SetBounds(BtnSide - 2, -1, BtnSide, BtnSide);
// Glyph:=LoadBitmapFromLazarusResource('prev1');
TmpBitmap:=LoadBitmapFromLazarusResource('prev1'); TmpBitmap:=LoadBitmapFromLazarusResource('prev1');
Glyph := TmpBitmap; Glyph := TmpBitmap;
@ -1084,7 +1038,6 @@ begin
begin begin
Parent := FControlPanel; Parent := FControlPanel;
SetBounds(FControlPanel.Width - 2 * BtnSide + 2, -1, BtnSide, BtnSide); SetBounds(FControlPanel.Width - 2 * BtnSide + 2, -1, BtnSide, BtnSide);
// Glyph:=LoadBitmapFromLazarusResource('next1');
TmpBitmap:=LoadBitmapFromLazarusResource('next1'); TmpBitmap:=LoadBitmapFromLazarusResource('next1');
Glyph := TmpBitmap; Glyph := TmpBitmap;
FreeAndNil(TmpBitmap); FreeAndNil(TmpBitmap);
@ -1098,7 +1051,6 @@ begin
begin begin
Parent := FControlPanel; Parent := FControlPanel;
SetBounds(FControlPanel.Width - BtnSide + 1, -1, BtnSide, BtnSide); SetBounds(FControlPanel.Width - BtnSide + 1, -1, BtnSide, BtnSide);
// Glyph:=LoadBitmapFromLazarusResource('next2');
TmpBitmap:=LoadBitmapFromLazarusResource('next2'); TmpBitmap:=LoadBitmapFromLazarusResource('next2');
Glyph := TmpBitmap; Glyph := TmpBitmap;
FreeAndNil(TmpBitmap); FreeAndNil(TmpBitmap);
@ -1213,9 +1165,6 @@ begin
CR:=ClientRect; CR:=ClientRect;
RxFrame3D(Canvas, CR, clBtnHighlight, clWindowFrame, 1); RxFrame3D(Canvas, CR, clBtnHighlight, clWindowFrame, 1);
RxFrame3D(Canvas, CR, clBtnFace, clBtnShadow, 1); RxFrame3D(Canvas, CR, clBtnFace, clBtnShadow, 1);
{ Canvas.Pen.Color:=clWindowText;
Canvas.Pen.Style := psSolid;
Canvas.Rectangle(0, 0, Width-1, Height-1)}
end; end;
procedure TPopupCalendar.Deactivate; procedure TPopupCalendar.Deactivate;
@ -1252,13 +1201,10 @@ end;
procedure TPopupCalendar.CalendarChange(Sender: TObject); procedure TPopupCalendar.CalendarChange(Sender: TObject);
var var
s: string; //
AYear, AMonth, ADay: Word; AYear, AMonth, ADay: Word;
begin begin
DecodeDate(FCalendar.CalendarDate, AYear, AMonth, ADay); DecodeDate(FCalendar.CalendarDate, AYear, AMonth, ADay);
s := Format('%s, %d', [LongMonthNames[AMonth], AYear]); FTitleLabel.Caption := Format('%s, %d', [LongMonthNames[AMonth], AYear]);
FTitleLabel.Caption := s; //
// FTitleLabel.Caption := FormatDateTime('MMMM, YYYY', FCalendar.CalendarDate);
end; end;
procedure TPopupCalendar.SetDate(const AValue: TDateTime); procedure TPopupCalendar.SetDate(const AValue: TDateTime);
@ -1281,6 +1227,7 @@ var
Control: TWinControl; Control: TWinControl;
MI:TMenuItem; MI:TMenuItem;
i:integer; i:integer;
TmpBitmap:TBitmap;
begin begin
inherited CreateNew(AOwner, 0); inherited CreateNew(AOwner, 0);
Caption := sDateDlgTitle; Caption := sDateDlgTitle;
@ -1327,7 +1274,11 @@ begin
begin begin
Parent := Control; Parent := Control;
SetBounds(3, 3, 16, 16); SetBounds(3, 3, 16, 16);
Glyph:=LoadBitmapFromLazarusResource('prev2');
TmpBitmap:=LoadBitmapFromLazarusResource('prev2');
Glyph := TmpBitmap;
FreeAndNil(TmpBitmap);
OnClick := @PrevYearBtnClick; OnClick := @PrevYearBtnClick;
Hint := sPrevYear; Hint := sPrevYear;
end; end;
@ -1336,7 +1287,11 @@ begin
with FBtns[1] do begin with FBtns[1] do begin
Parent := Control; Parent := Control;
SetBounds(18, 3, 16, 16); SetBounds(18, 3, 16, 16);
Glyph:=LoadBitmapFromLazarusResource('prev1');
TmpBitmap:=LoadBitmapFromLazarusResource('prev1');
Glyph := TmpBitmap;
FreeAndNil(TmpBitmap);
OnClick := @PrevMonthBtnClick; OnClick := @PrevMonthBtnClick;
Hint := sPrevMonth; Hint := sPrevMonth;
end; end;
@ -1346,7 +1301,11 @@ begin
begin begin
Parent := Control; Parent := Control;
SetBounds(188, 3, 16, 16); SetBounds(188, 3, 16, 16);
Glyph:=LoadBitmapFromLazarusResource('next1');
TmpBitmap:=LoadBitmapFromLazarusResource('next1');
Glyph := TmpBitmap;
FreeAndNil(TmpBitmap);
OnClick := @NextMonthBtnClick; OnClick := @NextMonthBtnClick;
Hint := sNextMonth; Hint := sNextMonth;
end; end;
@ -1355,7 +1314,11 @@ begin
with FBtns[3] do begin with FBtns[3] do begin
Parent := Control; Parent := Control;
SetBounds(203, 3, 16, 16); SetBounds(203, 3, 16, 16);
Glyph:=LoadBitmapFromLazarusResource('next2');
TmpBitmap:=LoadBitmapFromLazarusResource('next2');
Glyph := TmpBitmap;
FreeAndNil(TmpBitmap);
OnClick := @NextYearBtnClick; OnClick := @NextYearBtnClick;
Hint := sNextYear; Hint := sNextYear;
end; end;
@ -1547,8 +1510,6 @@ begin
D.Top := Y; D.Top := Y;
D.Date := Date; D.Date := Date;
// D.Calendar.DefaultRowHeight:=Edit.ca;
if D.ShowModal = mrOk then if D.ShowModal = mrOk then
begin begin
Date := D.Date; Date := D.Date;

View File

@ -573,6 +573,9 @@ end;
begin begin
if not Assigned(FPopup) then if not Assigned(FPopup) then
FPopup:=CreatePopupForm; FPopup:=CreatePopupForm;
UpdatePopup;
if (FPopup <> nil) and not (ReadOnly {or FPopupVisible}) then if (FPopup <> nil) and not (ReadOnly {or FPopupVisible}) then
begin begin
P := Parent.ClientToScreen(Point(Left, Top)); P := Parent.ClientToScreen(Point(Left, Top));