From d4c63d5b730e20f02ef0b10666170454ca1f59b6 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Fri, 23 Sep 2011 22:37:57 +0000 Subject: [PATCH] add new components TRxRadioGroup and TRxDBRadioGroup - allow disable any of RadioButton from group git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1993 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/docs/WhatsNew.rus.txt | 3 +- components/rx/registerrx.pas | 28 +++-------------- components/rx/registerrxdb.pas | 25 +++++++++++++-- components/rx/rxctrls.pas | 48 ++++++++++++++++++++++++++--- components/rx/rxdbctrls.pas | 40 +++++++++++++++++++++++- components/rx/vclutils.pas | 10 +++++- 6 files changed, 120 insertions(+), 34 deletions(-) diff --git a/components/rx/docs/WhatsNew.rus.txt b/components/rx/docs/WhatsNew.rus.txt index 187a4a178..6f78a8551 100644 --- a/components/rx/docs/WhatsNew.rus.txt +++ b/components/rx/docs/WhatsNew.rus.txt @@ -66,11 +66,12 @@ добавлено новое свойство KeyStrokes + Добавлен новый компонент RxCurredit + Добавлен новый компонент- TRxViewsPanel - + у компоненты TRxMemoryData убрана зависимость от модуля Forms + Улучшено отображение редактора полей типа TDateTime/TDate в RxDBGrid + У TRxCollumn компоненты TRxDBGrid для стиля cbsPickList добавлено свойство DirectInput. Если оно установлено в false - значения поля можно выбрать только из выпадающего списка + + Добавлены 2 комопненты - TRxRadioGroup и TRxDBRadioGroup. В отличии от стнадартных позваляют выборочно запрещать некоторые RadioButton-ы на + компоненте через свойство ItemEnabled. 22.05.2008 - версия 2.0.0.136 (svn revision 100) + У объекта TRxCustomDBLookupCombo введён контроль на CircularDataLink + У объекта TRxCustomDBLookupCombo ускорена отрисовка данных diff --git a/components/rx/registerrx.pas b/components/rx/registerrx.pas index fb33161d6..44715fe90 100644 --- a/components/rx/registerrx.pas +++ b/components/rx/registerrx.pas @@ -42,8 +42,8 @@ procedure Register; implementation uses - PropEdits, dbdateedit, dbcurredit, rxlookup, folderlister, duallist, - curredit, rxswitch, rxdice, rxdbcomb, rxtoolbar, rxxpman, PageMngr, RxAppIcon, + PropEdits, folderlister, duallist, + curredit, rxswitch, rxdice, rxtoolbar, rxxpman, PageMngr, RxAppIcon, Dialogs, ComponentEditors, DBPropEdits, DB, rxctrls, RxCustomChartPanel, AutoPanel, pickdate, rxconst, tooledit, rxclock, rxceEditLookupFields, rxpopupunit, rxspin, RxTimeEdit, @@ -92,20 +92,6 @@ begin RegisterComponents('RX',[TPageManager]); end; -procedure RegisterUnitDBDateEdit; -begin - RegisterComponents('RX DBAware',[TDBDateEdit, TRxDBCalcEdit, TRxDBCurrEdit]); -end; - -procedure RegisterRXLookup; -begin - RegisterComponents('RX DBAware',[TRXLookupEdit, TRxDBLookupCombo]); -end; - -procedure RegisterRxDBComb; -begin - RegisterComponents('RX DBAware',[TRxDBComboBox]); -end; procedure RegisterDualList; begin @@ -139,7 +125,7 @@ end; procedure RegisterRxCtrls; begin - RegisterComponents('RX',[TRxLabel, TSecretPanel, TRxSpeedButton]); + RegisterComponents('RX',[TRxLabel, TSecretPanel, TRxSpeedButton, TRxRadioGroup]); end; @@ -215,13 +201,7 @@ begin RegisterUnit('RxAboutDialog', @RegisterRxAboutDialog); RegisterUnit('RxViewsPanel', @RegisterRxViewsPanel); - //RX DBAware - RegisterUnit('dbdateedit', @RegisterUnitDBDateEdit); - RegisterUnit('rxlookup', @RegisterRXLookup); - RegisterUnit('rxdbcomb', @RegisterRxDBComb); - - // - +// RegisterPropertyEditor(TypeInfo(string), TPopUpColumn, 'FieldName', TPopUpColumnFieldProperty); RegisterCEEditLookupFields; end; diff --git a/components/rx/registerrxdb.pas b/components/rx/registerrxdb.pas index c764d3931..c6b9a3a66 100644 --- a/components/rx/registerrxdb.pas +++ b/components/rx/registerrxdb.pas @@ -41,7 +41,8 @@ uses procedure Register; implementation uses DB, DBPropEdits, rxdbgrid, RxDBSpinEdit, RxDBTimeEdit, RxDBCtrls, rxmemds, - ComponentEditors, seldsfrm, PropEdits, RxDBColorBox; + ComponentEditors, seldsfrm, PropEdits, RxDBColorBox, dbdateedit, rxdbcomb, + rxlookup, dbcurredit; type @@ -104,7 +105,7 @@ end; procedure RegisterRxDBCtrls; begin - RegisterComponents('RX DBAware',[TRxDBProgressBar, TRxDBTrackBar]); + RegisterComponents('RX DBAware',[TRxDBProgressBar, TRxDBTrackBar, TRxDBRadioGroup]); end; procedure RegisterRxDbGrid; @@ -122,8 +123,28 @@ begin RegisterComponents('RX DBAware',[TRxDBColorBox]); end; +procedure RegisterUnitDBDateEdit; +begin + RegisterComponents('RX DBAware',[TDBDateEdit, TRxDBCalcEdit, TRxDBCurrEdit]); +end; + +procedure RegisterRXLookup; +begin + RegisterComponents('RX DBAware',[TRXLookupEdit, TRxDBLookupCombo]); +end; + +procedure RegisterRxDBComb; +begin + RegisterComponents('RX DBAware',[TRxDBComboBox]); +end; + procedure Register; begin + //RX DBAware + RegisterUnit('dbdateedit', @RegisterUnitDBDateEdit); + RegisterUnit('rxlookup', @RegisterRXLookup); + RegisterUnit('rxdbcomb', @RegisterRxDBComb); + RegisterUnit('RxDBTimeEdit', @RegisterRxDBTimeEdit); RegisterUnit('RxDBSpinEdit', @RegisterRxDBSpinEdit); RegisterUnit('RxDBCtrls', @RegisterRxDBCtrls); diff --git a/components/rx/rxctrls.pas b/components/rx/rxctrls.pas index ac74527b7..323e0abd6 100644 --- a/components/rx/rxctrls.pas +++ b/components/rx/rxctrls.pas @@ -797,14 +797,26 @@ function DrawShadowText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; function CheckBitmap: TBitmap; *) + +type + + { TRxDBRadioGroup } + + { TRxRadioGroup } + + TRxRadioGroup = class(TRadioGroup) + private + function GetItemEnabled(Index: integer): boolean; + procedure SetItemEnabled(Index: integer; AValue: boolean); + public + property ItemEnabled[Index: integer]: boolean read GetItemEnabled write SetItemEnabled; + end; + implementation -uses SysUtils, Dialogs, {CommCtrl,} VCLUtils, Math, RxAppUtils, ImgList, - ActnList, InterfaceBase -(* Consts, {$IFDEF RX_D6}, RTLConsts{$ENDIF} -*) - ; +uses SysUtils, Dialogs, VCLUtils, Math, RxAppUtils, ImgList, + ActnList, InterfaceBase; const Alignments: array [TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER); WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK); @@ -2541,6 +2553,32 @@ begin UnionRect(Rect, RText, RShadow); end; +{ TRxRadioGroup } + +function TRxRadioGroup.GetItemEnabled(Index: integer): boolean; +var + R:TRadioButton; +begin + if (Index < -1) or (Index >= Items.Count) then + RaiseIndexOutOfBounds(Self, Items, Index); + R:=FindComponent('RadioButton'+IntToStr(Index)) as TRadioButton; + if Assigned(R) then + Result:=R.Enabled + else + Result:=False; +end; + +procedure TRxRadioGroup.SetItemEnabled(Index: integer; AValue: boolean); +var + R:TRadioButton; +begin + if (Index < -1) or (Index >= Items.Count) then + RaiseIndexOutOfBounds(Self, Items, Index); + R:=FindComponent('RadioButton'+IntToStr(Index)) as TRadioButton; + if Assigned(R) then + R.Enabled:=AValue; +end; + constructor TRxCustomLabel.Create(AOwner: TComponent); begin inherited Create(AOwner); diff --git a/components/rx/rxdbctrls.pas b/components/rx/rxdbctrls.pas index 1648534c8..e7a5b2a65 100644 --- a/components/rx/rxdbctrls.pas +++ b/components/rx/rxdbctrls.pas @@ -194,8 +194,46 @@ type property Visible; end; +type + + { TRxDBRadioGroup } + + TRxDBRadioGroup = class(TDBRadioGroup) + private + function GetItemEnabled(Index: integer): boolean; + procedure SetItemEnabled(Index: integer; AValue: boolean); + public + property ItemEnabled[Index: integer]: boolean read GetItemEnabled write SetItemEnabled; + end; + implementation -uses dbutils, LCLVersion; +uses dbutils, LCLVersion, vclutils, StdCtrls; + +{ TRxDBRadioGroup } + +function TRxDBRadioGroup.GetItemEnabled(Index: integer): boolean; +var + R:TRadioButton; +begin + if (Index < -1) or (Index >= Items.Count) then + RaiseIndexOutOfBounds(Self, Items, Index); + R:=FindComponent('RadioButton'+IntToStr(Index)) as TRadioButton; + if Assigned(R) then + Result:=R.Enabled + else + Result:=False; +end; + +procedure TRxDBRadioGroup.SetItemEnabled(Index: integer; AValue: boolean); +var + R:TRadioButton; +begin + if (Index < -1) or (Index >= Items.Count) then + RaiseIndexOutOfBounds(Self, Items, Index); + R:=FindComponent('RadioButton'+IntToStr(Index)) as TRadioButton; + if Assigned(R) then + R.Enabled:=AValue; +end; { TCustomRxDBProgressBar } diff --git a/components/rx/vclutils.pas b/components/rx/vclutils.pas index 77c5169b5..fd7ce802b 100644 --- a/components/rx/vclutils.pas +++ b/components/rx/vclutils.pas @@ -74,6 +74,8 @@ function ReallocMemo(fpBlock: Pointer; Size: Longint): Pointer; procedure FreeMemo(var fpBlock: Pointer); } +procedure RaiseIndexOutOfBounds(Control: TControl; Items:TStrings; Index: integer); + {$IFDEF WIN32} type PCursorOrIcon = ^TCursorOrIcon; @@ -100,7 +102,7 @@ procedure OutOfResources; {$ENDIF} implementation -uses LCLProc, LCLIntf, LCLType; +uses LCLProc, LCLIntf, LCLType, LCLStrConsts; function WidthOf(R: TRect): Integer; begin @@ -650,6 +652,12 @@ begin Canvas.Free; end; +procedure RaiseIndexOutOfBounds(Control: TControl; Items:TStrings; Index: integer); +begin + raise Exception.CreateFmt(rsIndexOutOfBounds, + [Control.Name, Index, Items.Count - 1]); +end; + initialization LazarusResources.Add('rxbtn_downarrow','XPM',[ '/* XPM */'#13#10'static char * btn_downarrow_xpm[] = {'#13#10'"5 3 2 1",'#13