diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lpi b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lpi index ce9ebd2de..b88d963b1 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lpi +++ b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lpi @@ -65,7 +65,7 @@ - + @@ -75,6 +75,9 @@ + + + diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps index b0c70518f..72faff93d 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps +++ b/components/rx/trunk/demos/RxDBVerticalGrid/project1.lps @@ -3,15 +3,13 @@ - + - - - - + + @@ -21,9 +19,9 @@ - - - + + + @@ -32,22 +30,24 @@ - + - - - - + + + + + - - - - + + + + + @@ -69,7 +69,8 @@ - + + @@ -77,7 +78,7 @@ - + @@ -85,84 +86,85 @@ - + - - - - + + + + + - + - + - + - + - + - + - + - + - + - + @@ -170,106 +172,107 @@ - + - - - - + + + + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -277,7 +280,7 @@ - + @@ -291,7 +294,7 @@ - + @@ -299,14 +302,15 @@ - + - - - + + + + @@ -314,14 +318,14 @@ - + - + @@ -329,54 +333,54 @@ - + - + - + - + - + - + - + - + @@ -384,21 +388,21 @@ - + - + - + @@ -428,7 +432,7 @@ - + @@ -436,12 +440,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm index e2f04592b..f30f3ca70 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm +++ b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.lfm @@ -1,19 +1,20 @@ object Form1: TForm1 Left = 517 - Height = 673 + Height = 749 Top = 222 Width = 1206 Caption = 'Form1' - ClientHeight = 673 + ClientHeight = 749 ClientWidth = 1206 OnCreate = FormCreate LCLVersion = '1.9.0.0' object RxDBVerticalGrid1: TRxDBVerticalGrid Left = 440 - Height = 336 + Height = 416 Top = 328 Width = 728 Color = clWindow + GridDefValues.BlobText = '(данные)' DataCoumn.Title.Alignment = taCenter DataCoumn.Title.Caption = 'Данные' DataCoumn.Width = 250 @@ -25,6 +26,7 @@ object Form1: TForm1 LabelCoumn.Title.Caption = 'Заголовок' LabelCoumn.Width = 120 Options = [rxvgColumnTitle] + ReadOnly = True Rows = < item Alignment = taCenter @@ -116,8 +118,54 @@ object Form1: TForm1 WordWrap = False RowHeight = 27 ReadOnly = False + end + item + FieldName = 'TB_CLEINT_TYPE' + RowTitle.Caption = 'Тип 2' + ImageList = ImageList1 + NotInKeyListIndex = 4 + KeyList.Strings = ( + '0=0' + '1=1' + '2=2' + '3=3' + ) + WordWrap = False + RowHeight = 27 + ReadOnly = False + end + item + FieldName = 'TB_CLIENT_IMAGE' + RowTitle.Caption = 'Изображение' + WordWrap = False + RowHeight = 90 + ReadOnly = False + ShowBlobImagesAndMemo = True + end + item + FieldName = 'TB_CLEINT_MEMO' + RowTitle.Caption = 'Описание' + WordWrap = False + RowHeight = 27 + ReadOnly = False end> TitleStyle = tsNative + RowHeights = ( + 20 + 27 + 27 + 27 + 27 + 27 + 20 + 20 + 20 + 20 + 20 + 20 + 90 + 27 + ) end object RxDBGrid1: TRxDBGrid Left = 40 @@ -317,22 +365,68 @@ object Form1: TForm1 end object Button1: TButton Left = 208 - Height = 25 + Height = 36 Top = 430 - Width = 75 - Caption = 'Button1' + Width = 80 + AutoSize = True + Caption = 'Diconnect' OnClick = Button1Click TabOrder = 2 end object Button2: TButton Left = 208 - Height = 25 + Height = 36 Top = 472 - Width = 75 - Caption = 'Button2' + Width = 69 + AutoSize = True + Caption = 'Connect' OnClick = Button2Click TabOrder = 3 end + object CheckBox1: TCheckBox + Left = 28 + Height = 24 + Top = 341 + Width = 110 + Caption = 'Show header' + OnChange = CheckBox1Change + TabOrder = 4 + end + object RadioGroup1: TRadioGroup + Left = 24 + Height = 93 + Top = 400 + Width = 83 + AutoFill = True + AutoSize = True + Caption = 'Image align' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 72 + ClientWidth = 81 + ItemIndex = 0 + Items.Strings = ( + 'Left' + 'Rigth' + 'Center' + ) + OnClick = CheckBox1Change + TabOrder = 5 + end + object CheckBox2: TCheckBox + Left = 28 + Height = 24 + Top = 368 + Width = 111 + Caption = 'Show images' + OnChange = CheckBox1Change + TabOrder = 6 + end object dsData: TDataSource DataSet = rxData Left = 120 @@ -390,7 +484,7 @@ object Form1: TForm1 FieldDefs = < item Name = 'TB_CLIENT_ID' - DataType = ftInteger + DataType = ftAutoInc Precision = -1 end item @@ -440,11 +534,19 @@ object Form1: TForm1 item Name = 'TB_CLEINT_TYPE' DataType = ftInteger + end + item + Name = 'TB_CLIENT_IMAGE' + DataType = ftBlob + end + item + Name = 'TB_CLEINT_MEMO' + DataType = ftMemo end> PacketRecords = 0 Left = 176 Top = 94 - object rxDataTB_CLIENT_ID: TLongintField + object rxDataTB_CLIENT_ID: TAutoIncField FieldKind = fkData FieldName = 'TB_CLIENT_ID' Index = 0 @@ -539,5 +641,192 @@ object Form1: TForm1 ReadOnly = False Required = False end + object rxDataTB_CLIENT_IMAGE: TBlobField + FieldKind = fkData + FieldName = 'TB_CLIENT_IMAGE' + Index = 10 + LookupCache = False + ProviderFlags = [pfInUpdate, pfInWhere] + ReadOnly = False + Required = False + end + object rxDataTB_CLEINT_MEMO: TMemoField + FieldKind = fkData + FieldName = 'TB_CLEINT_MEMO' + Index = 11 + LookupCache = False + ProviderFlags = [pfInUpdate, pfInWhere] + ReadOnly = False + Required = False + BlobType = ftMemo + Transliterate = False + end + end + object ImageList1: TImageList + Left = 1160 + Top = 48 + Bitmap = { + 4C69050000001000000010000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000188532FF178432FF178331FF178231FF168030FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000178532FF168431FF168330FF158130FF14802FFF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000168531FF158430FF14822FFF14812EFF137F2DFF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000158430FF14832FFF13822EFF12802DFF117E2CFF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000158430FF13822EFF12812DFF107F2BFF0F7E2AFF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000014832FFF12812DFF10802CFF0F7E2AFF0E7C29FF00000000000000000000 + 00000000000000000000000000000000000000000000178332FF178331FF1583 + 30FF13822EFF11802CFF0F7E2AFF0D7D29FF0C7B27FF0C7A27FF0C7A27FF0D7A + 28FF000000000000000000000000000000000000000000000000168231FF1581 + 2FFF13802DFF107F2BFF0E7D29FF0C7B27FF0B7A26FF0B7926FF0B7926FF0000 + 0000000000000000000000000000000000000000000000000000000000001480 + 2EFF127F2DFF107E2BFF0E7C29FF0C7A27FF0B7926FF0A7925FF000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000127E2DFF107D2BFF0E7B28FF0C7A27FF0B7926FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000107C2BFF0E7B29FF0D7A27FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000F7B2AFF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000188432FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000178532FF178431FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000178532FF168531FF158430FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000001785 + 32FF168531FF158430FF14832FFF13822EFF12812DFF12802DFF127F2DFF127E + 2DFF137E2DFF0000000000000000000000000000000000000000178432FF1684 + 31FF158430FF13832FFF12812DFF11802CFF107F2BFF107E2BFF107D2BFF107D + 2BFF117D2CFF00000000000000000000000000000000178332FF168331FF1583 + 30FF14822FFF12812DFF11802CFF0F7F2BFF0E7D29FF0E7C29FF0E7C28FF0E7B + 29FF0F7B29FF0000000000000000000000000000000000000000168231FF1581 + 2FFF13802DFF117F2CFF0F7E2AFF0E7D29FF0D7C28FF0C7B27FF0C7A27FF0C7A + 27FF0D7A28FF0000000000000000000000000000000000000000000000001480 + 2FFF127F2DFF107E2BFF0E7C29FF0D7B28FF0B7A26FF0B7A26FF0A7925FF0B79 + 26FF0C7927FF0000000000000000000000000000000000000000000000000000 + 0000127E2CFF107D2BFF0E7B29FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000107C2BFF0E7B29FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000F7B29FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000188332FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000178331FF168231FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000158330FF15812FFF14802EFF000000000000 + 00000000000000000000000000000000000000000000188532FF178532FF1685 + 31FF158430FF158430FF14832FFF13822EFF13802DFF127F2DFF127E2DFF0000 + 00000000000000000000000000000000000000000000178432FF168431FF1584 + 30FF14832FFF13822EFF12812DFF11802CFF107F2BFF107E2BFF107D2BFF107C + 2BFF0000000000000000000000000000000000000000178331FF168330FF1482 + 2FFF13822EFF12812DFF10802CFF0F7E2AFF0E7D29FF0E7C29FF0E7B28FF0E7B + 29FF0F7B2AFF00000000000000000000000000000000168231FF158130FF1481 + 2EFF12802DFF107F2BFF0F7E2AFF0E7D29FF0C7C28FF0C7A27FF0C7A27FF0D7A + 27FF0000000000000000000000000000000000000000168030FF14802FFF137F + 2DFF117E2CFF0F7D2AFF0E7C29FF0C7B27FF0B7A26FF0B7926FF0B7926FF0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000C7A27FF0B7926FF0A7925FF000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000C7A27FF0B7926FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000D7A28FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000178332FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000178432FF168331FF168231FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000178532FF168431FF158330FF15812FFF14802FFF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000001785 + 32FF168531FF158430FF14822FFF13802DFF127F2DFF127E2CFF000000000000 + 0000000000000000000000000000000000000000000000000000178532FF1685 + 31FF158430FF14832FFF12812DFF117F2CFF107E2BFF107D2BFF107C2BFF0000 + 00000000000000000000000000000000000000000000188432FF178431FF1584 + 30FF14832FFF12822EFF11802CFF0F7E2AFF0E7C29FF0E7B29FF0E7B29FF0F7B + 2AFF000000000000000000000000000000000000000000000000000000000000 + 000013822EFF11802CFF0F7F2BFF0E7D29FF0D7B28FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000012802DFF107F2BFF0E7D29FF0D7C28FF0B7A26FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000012802DFF107E2BFF0E7C29FF0C7B27FF0B7A26FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000127F2DFF107D2BFF0E7C28FF0C7A27FF0A7925FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000127E2DFF107D2BFF0E7B29FF0C7A27FF0B7926FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000137E2DFF117C2BFF0F7B29FF0D7A28FF0C7927FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000A46534FF5959F3FF5959F3FF5959 + F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959 + F3FFA46534FF000000000000000000000000A46534FF5959F3FF5959F3FF5959 + F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959F3FF5959 + F3FFA46534FF000000000000000000000000A46534FFECEEEEFFECEEEEFFECEE + EEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEE + EEFFA46534FF000000000000000000000000A46534FFECEEEEFFECEEEEFFECEE + EEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEE + EEFFA46534FF000000000000000000000000A46534FFECEEEEFFECEEEEFFECEE + EEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEE + EEFFA46534FF000000000000000000000000A46534FFECEEEEFFECEEEEFFECEE + EEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEE + EEFFA46534FF000000000000000000000000A46534FFECEEEEFFECEEEEFFECEE + EEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEEEEFFECEE + EEFFA46534FF000000000000000000000000A46534FFA46534FFA46534FFA465 + 34FFA46534FFA46534FFA46534FFA46534FFA46534FFA46534FFA46534FFA465 + 34FFA46534FF000000000000000000000000A46534FFA46534FFA46534FFA465 + 34FFA46534FFA46534FFA46534FFA46534FFA46534FFA46534FFA46534FFA465 + 34FFA46534FF000000000000000000000000A46534FFA46534FFB6BDBAFFB6BD + BAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFA46534FFA46534FFA465 + 34FFA46534FF000000000000000000000000A46534FFA46534FFB6BDBAFFA465 + 34FFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFA46534FFA46534FFA465 + 34FFA46534FF000000000000000000000000A46534FFA46534FFB6BDBAFFA465 + 34FFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFA46534FFA46534FFA465 + 34FFA46534FF000000000000000000000000A46534FFA46534FFB6BDBAFFA465 + 34FFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFA46534FFA46534FFA465 + 34FFA46534FF000000000000000000000000A465347FA46534FFB6BDBAFFB6BD + BAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFB6BDBAFFA46534FFA46534FFA465 + 34FFA46534FF0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000 + } end end diff --git a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas index 2b85445a7..4d3f07859 100644 --- a/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas +++ b/components/rx/trunk/demos/RxDBVerticalGrid/unit1.pas @@ -6,8 +6,8 @@ interface uses Classes, SysUtils, FileUtil, rxdbgrid, - Forms, Controls, Graphics, Dialogs, Grids, StdCtrls, - DBGrids, Menus, db, rxdbverticalgrid, rxmemds, Types; + Forms, Controls, Graphics, Dialogs, StdCtrls, + DBGrids, Menus, ExtCtrls, DbCtrls, db, rxdbverticalgrid, rxmemds; type @@ -16,7 +16,10 @@ type TForm1 = class(TForm) Button1: TButton; Button2: TButton; + CheckBox1: TCheckBox; + CheckBox2: TCheckBox; dsData: TDataSource; + ImageList1: TImageList; MenuItem1: TMenuItem; MenuItem10: TMenuItem; MenuItem11: TMenuItem; @@ -32,12 +35,15 @@ type PopupMenu1: TPopupMenu; PopupMenu2: TPopupMenu; PopupMenu3: TPopupMenu; + RadioGroup1: TRadioGroup; rxDataCREATE_USER_DATE: TDateTimeField; rxDataCREATE_USER_NAME: TStringField; rxDataTB_CLEINT_CODE: TLongintField; + rxDataTB_CLEINT_MEMO: TMemoField; rxDataTB_CLEINT_TYPE: TLongintField; rxDataTB_CLIENT_EMAIL: TStringField; - rxDataTB_CLIENT_ID: TLongintField; + rxDataTB_CLIENT_ID: TAutoIncField; + rxDataTB_CLIENT_IMAGE: TBlobField; rxDataTB_CLIENT_INN: TStringField; rxDataTB_CLIENT_NAME: TStringField; rxDataTB_CLIENT_PHONE: TStringField; @@ -47,6 +53,7 @@ type rxData: TRxMemoryData; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); + procedure CheckBox1Change(Sender: TObject); procedure FormCreate(Sender: TObject); private procedure FillDataBase; @@ -58,6 +65,7 @@ var Form1: TForm1; implementation +uses LazUTF8, LazFileUtils; {$R *.lfm} @@ -66,6 +74,8 @@ implementation procedure TForm1.FormCreate(Sender: TObject); begin FillDataBase; + CheckBox1.Checked:=rxvgColumnTitle in RxDBVerticalGrid1.Options; + CheckBox2.Checked:=RxDBVerticalGrid1.Rows[11].ShowBlobImagesAndMemo; end; procedure TForm1.Button1Click(Sender: TObject); @@ -80,19 +90,66 @@ begin RxDBGrid1.DataSource:=dsData; end; +procedure TForm1.CheckBox1Change(Sender: TObject); +begin + if CheckBox1.Checked then + RxDBVerticalGrid1.Options:=RxDBVerticalGrid1.Options + [rxvgColumnTitle] + else + RxDBVerticalGrid1.Options:=RxDBVerticalGrid1.Options - [rxvgColumnTitle] + ; + + case RadioGroup1.ItemIndex of + 0:RxDBVerticalGrid1.Rows[11].Alignment:=taLeftJustify; + 1:RxDBVerticalGrid1.Rows[11].Alignment:=taRightJustify; + 2:RxDBVerticalGrid1.Rows[11].Alignment:=taCenter; + end; + RxDBVerticalGrid1.Rows[11].ShowBlobImagesAndMemo:=CheckBox2.Checked; + +end; + procedure TForm1.FillDataBase; + +procedure AppendRecord(AType, ACode:Integer; AINN, AName, ADesc, AEmail, APhone, AUser:string; AVip:boolean; AImageName:string); +var + S: String; +begin + rxData.Append; + rxDataTB_CLEINT_TYPE.AsInteger:=AType; + rxDataTB_CLEINT_CODE.AsInteger:=ACode; + rxDataTB_CLIENT_INN.AsString:=AINN; + rxDataTB_CLIENT_NAME.AsString:=AName; + rxDataTB_CLEINT_MEMO.AsString:=ADesc; + rxDataTB_CLIENT_EMAIL.AsString:=AEmail; + rxDataTB_CLIENT_PHONE.AsString:=APhone; + rxDataVIP.AsBoolean:=AVip; + + if AImageName <> '' then + begin + S:=AppendPathDelim(ExpandFileName(AppendPathDelim(ExtractFileDir(ParamStr(0))) + '..'+DirectorySeparator + '..'+DirectorySeparator + '..' + DirectorySeparator + '..')) + 'images' + DirectorySeparator; + //ForceDirectories() + // /usr/local/share/lazarus/components/rxnew/demos/RxDBVerticalGrid + // /usr/local/share/lazarus/images + if FileExistsUTF8(S + AImageName) then + rxDataTB_CLIENT_IMAGE.LoadFromFile(S + AImageName); + end; + + rxDataCREATE_USER_NAME.AsString:=AUser; + rxDataCREATE_USER_DATE.AsDateTime:=Now + (200-Random * 100); + rxData.Post; +end; + begin rxData.Open; - rxData.AppendRecord([1, 1, '01000100101', 'JSC "BOOT"', 'test1@email.com', '5(555)-557-88-77', true, 'alexs', now, 1]); - rxData.AppendRecord([2, 2, '02000100101', 'Wikimedia Foundation, Inc.', 'test2@email.com', '5(555)-557-88-77', false, 'boss', now, 2]); - rxData.AppendRecord([3, 3, '03000100101', 'LLC Pilot ', 'test3@email.com', '5(555)-557-88-77', true, 'master', now, 3]); - rxData.AppendRecord([4, 4, '04000100101', 'Pilot, OOO', 'test4@email.com', '5(555)-557-88-77', true, 'onegin', now, 1]); - rxData.AppendRecord([5, 5, '05000100101', 'JSC "MS"', 'test5@email.com', '5(555)-557-88-77', true, 'alfred', now, 1]); - rxData.AppendRecord([6, 11, '06000100101', 'JSC "AA"', 'test6@email.com', '5(555)-557-88-77', true, 'anna', now, 1]); - rxData.AppendRecord([7, 12, '07000100101', 'JSC "BBBB"', 'test7@email.com', '5(555)-557-88-77', true, 'tux', now, 1]); - rxData.AppendRecord([8, 13, '08000100101', 'JSC "CCCC"', 'test8@email.com', '5(555)-557-88-77', true, 'x-man', now, 4]); - rxData.AppendRecord([9, 14, '09000100101', 'JSC "DDD"', 'test9@email.com', '5(555)-557-88-77', true, 'arny', now, 1]); - rxData.AppendRecord([10, 15, '101000200101', 'JSC "EEEE"', 'test10@email.com', '5(555)-557-88-77', true, 'andy', now, 1]); + AppendRecord(1, 1, '01000100101', 'JSC "BOOT"', 'Описание', 'test1@email.com', '5(555)-557-88-77', 'alexs', true, 'splash_logo.png'); + AppendRecord(2, 2, '02000100101', 'Wikimedia Foundation, Inc.', 'Описание', 'test2@email.com', '5(555)-557-88-77', 'boss', false, 'splash_logo.xpm'); + AppendRecord(3, 3, '03000100101', 'LLC Pilot ', 'Описание', 'test3@email.com', '5(555)-557-88-77', 'master', false, 'powered_by.png'); + AppendRecord(4, 4, '04000100101', 'Pilot, OOO', 'Описание', 'test4@email.com', '5(555)-557-88-77', 'onegin', false, 'folder.png'); + AppendRecord(5, 5, '05000100101', 'JSC "MS"', 'Описание', 'test5@email.com', '5(555)-557-88-77', 'alfred', false, 'splash_source'+DirectorySeparator + 'cheetah.jpg'); + AppendRecord(6, 11, '06000100101', 'JSC "AA"', 'Описание', 'test6@email.com', '5(555)-557-88-77', 'anna', false, 'mimetypes'+DirectorySeparator + 'text-lazarus-project-information.png'); + AppendRecord(7, 12, '07000100101', 'JSC "BBBB"', 'Описание', 'test7@email.com', '5(555)-557-88-77', 'tux', false, 'splash_source'+DirectorySeparator + 'paw.png'); + AppendRecord(8, 13, '08000100101', 'JSC "CCCC"', 'Описание', 'test8@email.com', '5(555)-557-88-77', 'x-man', false, ''); + AppendRecord(9, 14, '09000100101', 'JSC "DDD"', 'Описание', 'test9@email.com', '5(555)-557-88-77', 'arny', false, ''); + AppendRecord(10, 15, '101000200101', 'JSC "EEEE"', 'Описание', 'test10@email.com', '5(555)-557-88-77', 'andy', false, ''); rxData.First; end; diff --git a/components/rx/trunk/rxdb/rxdbverticalgrid.pas b/components/rx/trunk/rxdb/rxdbverticalgrid.pas index 4db13522e..fba422a42 100644 --- a/components/rx/trunk/rxdb/rxdbverticalgrid.pas +++ b/components/rx/trunk/rxdb/rxdbverticalgrid.pas @@ -131,8 +131,10 @@ type FButtonStyle: TColumnButtonStyle; FColor: ^TColor; FAlignment: ^TAlignment; + FNotInKeyListIndex: integer; FPopupMenu: TPopupMenu; FRowHeight: PInteger; + FShowBlobImagesAndMemo: boolean; FValueChecked: PChar; FValueUnchecked: PChar; @@ -180,6 +182,7 @@ type procedure SetGroupName(AValue: string); procedure SetImageList(AValue: TImageList); procedure SetKeyList(AValue: TStrings); + procedure SetNotInKeyListIndex(AValue: integer); procedure SetPickList(AValue: TStrings); procedure SetPopupMenu(AValue: TPopupMenu); procedure SetReadOnly(AValue: Boolean); @@ -189,6 +192,7 @@ type procedure ApplyDisplayFormat; procedure FontChanged(Sender: TObject); procedure KeyListChanged(Sender: TObject); + procedure SetShowBlobImagesAndMemo(AValue: boolean); procedure SetStaticText(AValue: string); procedure SetStyle(AValue: TRxDBVerticalGridRowStyle); procedure SetValueChecked(AValue: string); @@ -225,6 +229,7 @@ type property StaticText:string read FStaticText write SetStaticText; property ImageList: TImageList read FImageList write SetImageList; + property NotInKeyListIndex: integer read FNotInKeyListIndex write SetNotInKeyListIndex default -1; property KeyList: TStrings read GetKeyList write SetKeyList; property PickList: TStrings read GetPickList write SetPickList; property Style : TRxDBVerticalGridRowStyle read FStyle write SetStyle default rxvrData; @@ -234,6 +239,7 @@ type property PopupMenu : TPopupMenu read FPopupMenu write SetPopupMenu; property ValueChecked: string read GetValueChecked write SetValueChecked stored IsValueCheckedStored; property ValueUnchecked: string read GetValueUnchecked write SetValueUnchecked stored IsValueUncheckedStored; + property ShowBlobImagesAndMemo:boolean read FShowBlobImagesAndMemo write SetShowBlobImagesAndMemo default false; end; { TRxDBVerticalGridRows } @@ -274,6 +280,7 @@ type FReadOnly: Boolean; FRows: TRxDBVerticalGridRows; FLinkActive:integer; + FTmpPicture:TPicture; function GetDataCoumn: TGridColumn; function GetDataSource: TDataSource; function GetLabelCoumn: TGridColumn; @@ -286,9 +293,14 @@ type procedure RecordChanged; procedure RowsChanged(aRow: TRxDBVerticalGridRow); protected + procedure OutCaptionCellText(aCol, aRow: integer; const aRect: TRect; + aState: TGridDrawState; const ACaption: string); + procedure DrawCell(aCol,aRow:Integer; aRect:TRect; aState:TGridDrawState); override; procedure DrawDataCell(aCol, aRow:Integer; aRect:TRect; aState:TGridDrawState; AGridRow: TRxDBVerticalGridRow); procedure DrawCheckboxBitmaps(aRect: TRect; AGridRow: TRxDBVerticalGridRow); + procedure DrawCellBitmap(AGridRow: TRxDBVerticalGridRow; aRect: TRect; aState: TGridDrawState; AImageIndex: integer); + procedure DrawDataCellPicture(AGridRow: TRxDBVerticalGridRow; aRect: TRect; aState: TGridDrawState); procedure PrepareCanvas(aCol, aRow: Integer; aState:TGridDrawState); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; @@ -338,7 +350,7 @@ type end; implementation -uses Forms, rxdconst, LCLType, rxlclutils, StdCtrls, Themes; +uses LCLType, Math, Forms, rxdconst, rxlclutils, StdCtrls, Themes, LazUTF8; { TRxDBVerticalGridDefValues } @@ -857,6 +869,13 @@ begin RowChanged; end; +procedure TRxDBVerticalGridRow.SetNotInKeyListIndex(AValue: integer); +begin + if FNotInKeyListIndex=AValue then Exit; + FNotInKeyListIndex:=AValue; + RowChanged; +end; + procedure TRxDBVerticalGridRow.SetPickList(AValue: TStrings); begin FPickList.Assign(AValue); @@ -939,6 +958,13 @@ begin RowChanged; end; +procedure TRxDBVerticalGridRow.SetShowBlobImagesAndMemo(AValue: boolean); +begin + if FShowBlobImagesAndMemo=AValue then Exit; + FShowBlobImagesAndMemo:=AValue; + RowChanged; +end; + procedure TRxDBVerticalGridRow.SetStaticText(AValue: string); begin if FStaticText=AValue then Exit; @@ -1060,6 +1086,7 @@ end; constructor TRxDBVerticalGridRow.Create(ACollection: TCollection); begin inherited Create(ACollection); + FNotInKeyListIndex:=-1; FRowTitle:=TRxDBVerticalGridRowTitle.Create(Self); FKeyList:=TStringList.Create; FKeyList.OnChange:=@KeyListChanged; @@ -1072,6 +1099,7 @@ begin FFont.OnChange := @FontChanged; FButtonStyle:=cbsAuto; FStyle:=rxvrData; + FShowBlobImagesAndMemo:=false; end; destructor TRxDBVerticalGridRow.Destroy; @@ -1124,6 +1152,7 @@ begin Style:=TRxDBVerticalGridRow(Source).Style; Font:=TRxDBVerticalGridRow(Source).Font; FStaticText:=TRxDBVerticalGridRow(Source).StaticText; + FShowBlobImagesAndMemo:=TRxDBVerticalGridRow(Source).ShowBlobImagesAndMemo; end; end; @@ -1144,6 +1173,7 @@ begin if FLinkActive > 0 then Exit; if Assigned(aRow) then + Invalidate else begin if FRows.Count <> RowCount - FixedRows then @@ -1151,6 +1181,26 @@ begin end; end; +procedure TRxCustomDBVerticalGrid.OutCaptionCellText(aCol, aRow: integer; + const aRect: TRect; aState: TGridDrawState; const ACaption: string); +begin + if (TitleStyle = tsNative) then + DrawThemedCell(aCol, aRow, aRect, aState) + else + begin + Canvas.FillRect(aRect); + DrawCellGrid(aCol, aRow, aRect, aState); + end; + + if ACaption <> '' then + begin +{ if not (rdgDisableWordWrapTitles in OptionsRx) then + WriteTextHeader(Canvas, aRect, ACaption, GetColumnAlignment(aCol, True)) + else} + DrawCellText(aCol, aRow, aRect, aState, ACaption); + end; +end; + procedure TRxCustomDBVerticalGrid.DrawCell(aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState); var @@ -1161,9 +1211,10 @@ begin if (rxvgColumnTitle in FOptions) and (aRow = 0) then begin if aCol = 0 then - DrawCellText(aCol, aRow, aRect, aState, LabelCoumn.Title.Caption) + //DrawCellText(aCol, aRow, aRect, aState, LabelCoumn.Title.Caption) + OutCaptionCellText(aCol, aRow, aRect, aState, LabelCoumn.Title.Caption) else - DrawCellText(aCol, aRow, aRect, aState, DataCoumn.Title.Caption) + OutCaptionCellText(aCol, aRow, aRect, aState, DataCoumn.Title.Caption) end else begin @@ -1189,6 +1240,7 @@ procedure TRxCustomDBVerticalGrid.DrawDataCell(aCol, aRow: Integer; var S: String; J: Integer; + AImageIndex: LongInt; begin if AGridRow.Style = rxvrData then begin @@ -1197,6 +1249,13 @@ begin else if Assigned(AGridRow.Field) then begin + if Assigned(AGridRow.ImageList) then + begin + AImageIndex := StrToIntDef(AGridRow.KeyList.Values[AGridRow.Field.AsString], AGridRow.NotInKeyListIndex); + if (AImageIndex > -1) and (AImageIndex < AGridRow.ImageList.Count) then + DrawCellBitmap(AGridRow, aRect, aState, AImageIndex); + end + else if AGridRow.Field.dataType <> ftBlob then begin S := AGridRow.Field.DisplayText; @@ -1208,7 +1267,20 @@ begin end; end else - S := GridDefValues.FBlobText; + begin + if AGridRow.ShowBlobImagesAndMemo then + begin + DrawDataCellPicture(AGridRow, aRect, aState); + exit; + end + else + begin + if AGridRow.Field.IsNull then + S := GridDefValues.FBlobText + else + S := UTF8UpperCase(GridDefValues.FBlobText); + end; + end; WriteTextHeader(Canvas, aRect, S, AGridRow.Alignment); end; @@ -1290,6 +1362,122 @@ begin end; end; +procedure TRxCustomDBVerticalGrid.DrawCellBitmap( + AGridRow: TRxDBVerticalGridRow; aRect: TRect; aState: TGridDrawState; + AImageIndex: integer); +var + H, W: Integer; + ClientSize: TSize; +begin + InflateRect(aRect, -1, -1); + + H := AGridRow.ImageList.Height; + W := AGridRow.ImageList.Width; + + ClientSize.cx := Min(aRect.Right - aRect.Left, W); + ClientSize.cy := Min(aRect.Bottom - aRect.Top, H); + + if ClientSize.cx = W then + begin + aRect.Left := (aRect.Left + aRect.Right - W) div 2; + aRect.Right := aRect.Left + W; + end; + + if ClientSize.cy = H then + begin + aRect.Top := (aRect.Top + aRect.Bottom - H) div 2; + aRect.Bottom := aRect.Top + H; + end; + + AGridRow.ImageList.StretchDraw(Canvas, AImageIndex, aRect); +end; + +procedure TRxCustomDBVerticalGrid.DrawDataCellPicture( + AGridRow: TRxDBVerticalGridRow; aRect: TRect; aState: TGridDrawState); + +function PicDrawRect:TRect; +var + PicWidth, PicHeight: LongInt; + ImgWidth, ImgHeight, w, h, ChangeX, ChangeY: Integer; + PicInside, PicOutside, PicOutsidePartial: Boolean; +begin + PicWidth := FTmpPicture.Width; + PicHeight := FTmpPicture.Height; + ImgWidth := aRect.Width; + ImgHeight := aRect.Height; + if (PicWidth=0) or (PicHeight=0) then Exit(Rect(0, 0, 0, 0)); + + PicInside := (PicWidthImgWidth) and (PicHeight>ImgHeight); + PicOutsidePartial := (PicWidth>ImgWidth) or (PicHeight>ImgHeight); + +{ if Stretch or (Proportional and PicOutsidePartial) then + if (FStretchOutEnabled or PicOutside) and + (FStretchInEnabled or PicInside) then + if Proportional then } + begin + w:=ImgWidth; + h:=(PicHeight*w) div PicWidth; + if h>ImgHeight then + begin + h:=ImgHeight; + w:=(PicWidth*h) div PicHeight; + end; + PicWidth:=w; + PicHeight:=h; + end +{ else begin + PicWidth := ImgWidth; + PicHeight := ImgHeight; + end}; + + Result := Rect(0, 0, PicWidth, PicHeight); + + + case AGridRow.Alignment of + //taLeftJustify, + taRightJustify : + begin + ChangeX := ImgWidth-PicWidth; + ChangeY := ImgHeight-PicHeight; + {if FKeepOriginXWhenClipped and (ChangeX<0) then ChangeX := 0; + if FKeepOriginYWhenClipped and (ChangeY<0) then ChangeY := 0;} + OffsetRect(Result, ChangeX, ChangeY); + end; + taCenter : + begin + ChangeX := (ImgWidth-PicWidth) div 2; + ChangeY := (ImgHeight-PicHeight) div 2; + {if FKeepOriginXWhenClipped and (ChangeX<0) then ChangeX := 0; + if FKeepOriginYWhenClipped and (ChangeY<0) then ChangeY := 0;} + OffsetRect(Result, ChangeX, ChangeY); + end; + end; + OffsetRect(Result, aRect.Left, aRect.Top); + InflateRect(Result, -constCellPadding, -constCellPadding); +end; + +var + St: TStream; +begin + St:=AGridRow.Field.DataSet.CreateBlobStream(AGridRow.Field, bmRead); + if not Assigned(St) then Exit; + try + if St.Size > 0 then + begin + if not Assigned(FTmpPicture) then + FTmpPicture:=TPicture.Create; + + FTmpPicture.LoadFromStream(st); + + if Assigned(FTmpPicture.Graphic) then + Canvas.StretchDraw(PicDrawRect, FTmpPicture.Graphic); + end; + finally + St.Free; + end; +end; + procedure TRxCustomDBVerticalGrid.PrepareCanvas(aCol, aRow: Integer; aState: TGridDrawState); var @@ -1476,6 +1664,8 @@ begin FreeAndNil(FRows); FreeAndNil(FDataLink); FreeAndNil(FGridDefValues); + if Assigned(FTmpPicture) then + FreeAndNil(FTmpPicture); inherited Destroy; end;