diff --git a/components/rx/docs/WhatsNew.eng.txt b/components/rx/docs/WhatsNew.eng.txt index 75c1ac456..2370387ad 100644 --- a/components/rx/docs/WhatsNew.eng.txt +++ b/components/rx/docs/WhatsNew.eng.txt @@ -14,6 +14,7 @@ - In TCurrencyEdit property BorderSpacing now published + New procedure StrToStrings in module rxstrutils - fill List:TStrings procedure StrToStrings(const S:string; const List:TStrings; const Delims:Char); + + New editor for TField object with Lookup source in TRxDBGrid - base on class TRxDBLookupCombo 29.08.2007 - ўҐабЁп 1.1.5.98 (svn revision 39) + In RxDBgrid - after close dataset list of SelectedRows is cleared + fix resaizing find form for RxDbGrd diff --git a/components/rx/docs/WhatsNew.rus.txt b/components/rx/docs/WhatsNew.rus.txt index 27a89f0eb..f73341c4c 100644 --- a/components/rx/docs/WhatsNew.rus.txt +++ b/components/rx/docs/WhatsNew.rus.txt @@ -21,6 +21,8 @@ TRxLookupEdit и TRxDBLookupCombo + TRxDBLookupCombo реализована поддержка свойства AutoSize + При установке свойства Font у TRxDBLookupCombo выпадающий список использует этот же шрифт + + Если у объекта TField установленый лукапные источники то при редактировании в RxDBGrid + такого поля вызывается редактор на основе TRxDBLookupCombo 29.08.2007 - версия 1.1.5.98 (svn revision 39) + В RxDBGrid После закрытия набора данных список помеченных строк (SelectedRows) очищается diff --git a/components/rx/rxdbgrid.pas b/components/rx/rxdbgrid.pas index 29c591242..d901c914d 100644 --- a/components/rx/rxdbgrid.pas +++ b/components/rx/rxdbgrid.pas @@ -228,6 +228,7 @@ type FVersion: Integer; FPropertyStorageLink:TPropertyStorageLink; + FRxDbGridLookupComboEditor:TCustomControl; function GetColumns: TRxDbGridColumns; function GetPropertyStorage: TCustomPropertyStorage; @@ -279,6 +280,7 @@ type procedure FFilterListEditorOnCloseUp(Sender: TObject); procedure InternalOptimizeColumnsWidth(AColList:TList); function IsDefaultRowHeightStored:boolean; + function EditorByStyle(Style: TColumnButtonStyle): TWinControl; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -390,52 +392,10 @@ type property OnUserCheckboxBitmap; end; -{ -type - PCharArray1 = Array[0..12] of PChar; - - -const - IMGMarkerUp : PCharArray1 = - ( - '10 9 3 1', - '. c None', - '# c #808080', - 'a c #ffffff', - - '..........', - '....#a....', - '...#..a...', - '...#..a...', - '..#....a..', - '..#....a..', - '.#......a.', - '.aaaaaaaa.', - '..........' - ); - - IMGMarkerDown : PCharArray1 = - ( - '10 9 3 1', - '. c None', - '# c #808080', - 'a c #ffffff', - '..........', - '.#######a.', - '.#......a.', - '..#....a..', - '..#....a..', - '...#..a...', - '...#..a...', - '....#a....', - '..........') - ; -} - procedure RegisterExDBGridSortEngine(ExDBGridSortEngineClass:TExDBGridSortEngineClass; DataSetClass:TDataSetClass); implementation -uses Math, rxdconst, rxstrutils, rxdbgrid_findunit, rxdbgrid_columsunit; +uses Math, rxdconst, rxstrutils, rxdbgrid_findunit, rxdbgrid_columsunit, rxlookup; var ExDBGridSortEngineList:TStringList; @@ -460,6 +420,101 @@ begin for I := 0 to Grid.ColCount - 1 do Grid.InvalidateCell(I, Row); end; +type + + { TRxDBGridLookupComboEditor } + + TRxDBGridLookupComboEditor = class(TRxCustomDBLookupCombo) + private + FGrid: TRxDBGrid; + FCol,FRow: Integer; + FLDS:TDataSource; + protected + procedure WndProc(var TheMessage : TLMessage); override; + procedure KeyDown(var Key : Word; Shift : TShiftState); override; + procedure msg_SetGrid(var Msg: TGridMessage); message GM_SETGRID; + procedure msg_SetValue(var Msg: TGridMessage); message GM_SETVALUE; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + +{ TRxDBGridLookupComboEditor } + +procedure TRxDBGridLookupComboEditor.WndProc(var TheMessage: TLMessage); +begin + if TheMessage.msg=LM_KILLFOCUS then + begin + if HWND(TheMessage.WParam) = HWND(Handle) then + begin + // lost the focus but it returns to ourselves + // eat the message. + TheMessage.Result := 0; + exit; + end; + end; + inherited WndProc(TheMessage); +end; + +procedure TRxDBGridLookupComboEditor.KeyDown(var Key: Word; Shift: TShiftState + ); + +procedure doGridKeyDown; +begin + if Assigned(FGrid) then + FGrid.KeyDown(Key, shift); +end; + +begin + case Key of + VK_UP, + VK_DOWN : + if (not PopupVisible) and (not (ssAlt in Shift)) then + begin + doGridKeyDown; + exit; + end; + end; + inherited KeyDown(Key, Shift); +end; + +procedure TRxDBGridLookupComboEditor.msg_SetGrid(var Msg: TGridMessage); +begin + FGrid:=Msg.Grid as TRxDBGrid; + Msg.Options:=EO_AUTOSIZE; +end; + +procedure TRxDBGridLookupComboEditor.msg_SetValue(var Msg: TGridMessage); +var + F, LF:TField; +begin + FCol := Msg.Col; + FRow := Msg.Row; + F:=FGrid.SelectedField; + DataSource:=FGrid.DataSource; + if Assigned(F) then + begin + DataField:=F.FieldName; + LookupDisplay:=F.LookupKeyFields; + LookupField:=F.LookupResultField; + FLDS.DataSet:=F.LookupDataSet; + end; +end; + + +constructor TRxDBGridLookupComboEditor.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FLDS:=TDataSource.Create(nil); + LookupSource:=FLDS; +end; + +destructor TRxDBGridLookupComboEditor.Destroy; +begin + FreeAndNil(FLDS); + inherited Destroy; +end; + { TRxDBGrid } const ALIGN_FLAGS: array[TAlignment] of Integer = @@ -1016,7 +1071,10 @@ begin begin if F.dataType <> ftBlob then begin - S := F.DisplayText; +{ if Assigned(F.LookupDataSet) and (F.LookupResultField<>'') then + S := F.LookupDataSet.FieldByName(F.LookupResultField).DisplayText + else} + S := F.DisplayText; if Assigned(C) and (C.KeyList.Count > 0) and (C.PickList.Count>0) then begin J:=C.KeyList.IndexOf(S); @@ -1545,6 +1603,25 @@ begin Result:=DefaultRowHeight = Canvas.TextHeight('W'); end; +function TRxDBGrid.EditorByStyle(Style: TColumnButtonStyle): TWinControl; +var + F:TField; +begin + if Style = cbsAuto then + begin + F:=SelectedField; + if Assigned(F) then + begin + if Assigned(F.LookupDataSet) and (F.LookupKeyFields<>'') and (F.LookupResultField<>'') and (F.KeyFields<>'') then + begin + Result:=FRxDbGridLookupComboEditor; + exit; + end + end + end; + Result:=inherited EditorByStyle(Style); +end; + procedure TRxDBGrid.CalcStatTotals; var P:TBookmark; @@ -1659,10 +1736,15 @@ begin OnCloseUp := @FFilterListEditorOnCloseUp; end; FColumnResizing := false; + + FRxDbGridLookupComboEditor:=TRxDBGridLookupComboEditor.Create(nil); + FRxDbGridLookupComboEditor.Name:='RxDBGridLookupComboEditor'; + FRxDbGridLookupComboEditor.Visible:=false; end; destructor TRxDBGrid.Destroy; begin + FreeAndNil(FRxDbGridLookupComboEditor); FreeAndNil(FMarkerDown); FreeAndNil(FMarkerUp); FreeAndNil(FPropertyStorageLink); diff --git a/components/rx/rxlookup.pas b/components/rx/rxlookup.pas index bf569febe..a8c55fc4e 100644 --- a/components/rx/rxlookup.pas +++ b/components/rx/rxlookup.pas @@ -175,13 +175,13 @@ type procedure DataLinkActiveChanged; procedure DataLinkRecordChanged(Field: TField); procedure UpdateFieldValues; - procedure ShowList; procedure SetValueKey(const Value: string); procedure UpdateKeyValue; procedure KeyValueChanged; procedure UpdateData; - procedure OnClosePopup(AResult:boolean); protected + procedure ShowList; virtual; + procedure OnClosePopup(AResult:boolean);virtual; procedure DoAutoSize; override; procedure SetEnabled(Value: Boolean); override; procedure KeyDown(var Key: Word; Shift: TShiftState); override; @@ -234,6 +234,8 @@ type { TRxDBLookupCombo } TRxDBLookupCombo = class(TRxCustomDBLookupCombo) + protected + procedure OnClosePopup(AResult:boolean);override; published property AutoSize; property Align; @@ -924,7 +926,7 @@ begin FLookupDataLink.DataSet.First; FRxPopUpForm:=ShowRxDBPopUpForm(Self, FLookupDataLink.DataSet, @OnClosePopup, - FPopUpFormOptions, FLookupDisplay, LookupDisplayIndex, ButtonWidth, Font); + FPopUpFormOptions, FLookupDisplay, LookupDisplayIndex, 0 {ButtonWidth}, Font); end end; @@ -975,11 +977,6 @@ begin FDataLink.Edit; UpdateData; end; - SetFocus; - if (Owner is TWinControl) then - TWinControl(Owner).Repaint - else - Parent.Repaint; end; procedure TRxCustomDBLookupCombo.DoAutoSize; @@ -1326,4 +1323,16 @@ begin FDataControl.LookupDataSetChanged; end; +{ TRxDBLookupCombo } + +procedure TRxDBLookupCombo.OnClosePopup(AResult: boolean); +begin + inherited OnClosePopup(AResult); + SetFocus; + if (Owner is TWinControl) then + TWinControl(Owner).Repaint + else + Parent.Repaint; +end; + end.