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
This commit is contained in:
alexs75
2011-09-23 22:37:57 +00:00
parent 5e72832f78
commit d4c63d5b73
6 changed files with 120 additions and 34 deletions

View File

@ -66,11 +66,12 @@
добавлено новое свойство KeyStrokes добавлено новое свойство KeyStrokes
+ Добавлен новый компонент RxCurredit + Добавлен новый компонент RxCurredit
+ Добавлен новый компонент- TRxViewsPanel + Добавлен новый компонент- TRxViewsPanel
+ у компоненты TRxMemoryData убрана зависимость от модуля Forms + у компоненты TRxMemoryData убрана зависимость от модуля Forms
+ Улучшено отображение редактора полей типа TDateTime/TDate в RxDBGrid + Улучшено отображение редактора полей типа TDateTime/TDate в RxDBGrid
+ У TRxCollumn компоненты TRxDBGrid для стиля cbsPickList добавлено свойство DirectInput. + У TRxCollumn компоненты TRxDBGrid для стиля cbsPickList добавлено свойство DirectInput.
Если оно установлено в false - значения поля можно выбрать только из выпадающего списка Если оно установлено в false - значения поля можно выбрать только из выпадающего списка
+ Добавлены 2 комопненты - TRxRadioGroup и TRxDBRadioGroup. В отличии от стнадартных позваляют выборочно запрещать некоторые RadioButton-ы на
компоненте через свойство ItemEnabled.
22.05.2008 - версия 2.0.0.136 (svn revision 100) 22.05.2008 - версия 2.0.0.136 (svn revision 100)
+ У объекта TRxCustomDBLookupCombo введён контроль на CircularDataLink + У объекта TRxCustomDBLookupCombo введён контроль на CircularDataLink
+ У объекта TRxCustomDBLookupCombo ускорена отрисовка данных + У объекта TRxCustomDBLookupCombo ускорена отрисовка данных

View File

@ -42,8 +42,8 @@ procedure Register;
implementation implementation
uses uses
PropEdits, dbdateedit, dbcurredit, rxlookup, folderlister, duallist, PropEdits, folderlister, duallist,
curredit, rxswitch, rxdice, rxdbcomb, rxtoolbar, rxxpman, PageMngr, RxAppIcon, curredit, rxswitch, rxdice, rxtoolbar, rxxpman, PageMngr, RxAppIcon,
Dialogs, ComponentEditors, DBPropEdits, DB, rxctrls, Dialogs, ComponentEditors, DBPropEdits, DB, rxctrls,
RxCustomChartPanel, AutoPanel, pickdate, rxconst, tooledit, rxclock, RxCustomChartPanel, AutoPanel, pickdate, rxconst, tooledit, rxclock,
rxceEditLookupFields, rxpopupunit, rxspin, RxTimeEdit, rxceEditLookupFields, rxpopupunit, rxspin, RxTimeEdit,
@ -92,20 +92,6 @@ begin
RegisterComponents('RX',[TPageManager]); RegisterComponents('RX',[TPageManager]);
end; 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; procedure RegisterDualList;
begin begin
@ -139,7 +125,7 @@ end;
procedure RegisterRxCtrls; procedure RegisterRxCtrls;
begin begin
RegisterComponents('RX',[TRxLabel, TSecretPanel, TRxSpeedButton]); RegisterComponents('RX',[TRxLabel, TSecretPanel, TRxSpeedButton, TRxRadioGroup]);
end; end;
@ -215,13 +201,7 @@ begin
RegisterUnit('RxAboutDialog', @RegisterRxAboutDialog); RegisterUnit('RxAboutDialog', @RegisterRxAboutDialog);
RegisterUnit('RxViewsPanel', @RegisterRxViewsPanel); RegisterUnit('RxViewsPanel', @RegisterRxViewsPanel);
//RX DBAware
RegisterUnit('dbdateedit', @RegisterUnitDBDateEdit);
RegisterUnit('rxlookup', @RegisterRXLookup);
RegisterUnit('rxdbcomb', @RegisterRxDBComb);
// //
RegisterPropertyEditor(TypeInfo(string), TPopUpColumn, 'FieldName', TPopUpColumnFieldProperty); RegisterPropertyEditor(TypeInfo(string), TPopUpColumn, 'FieldName', TPopUpColumnFieldProperty);
RegisterCEEditLookupFields; RegisterCEEditLookupFields;
end; end;

View File

@ -41,7 +41,8 @@ uses
procedure Register; procedure Register;
implementation implementation
uses DB, DBPropEdits, rxdbgrid, RxDBSpinEdit, RxDBTimeEdit, RxDBCtrls, rxmemds, uses DB, DBPropEdits, rxdbgrid, RxDBSpinEdit, RxDBTimeEdit, RxDBCtrls, rxmemds,
ComponentEditors, seldsfrm, PropEdits, RxDBColorBox; ComponentEditors, seldsfrm, PropEdits, RxDBColorBox, dbdateedit, rxdbcomb,
rxlookup, dbcurredit;
type type
@ -104,7 +105,7 @@ end;
procedure RegisterRxDBCtrls; procedure RegisterRxDBCtrls;
begin begin
RegisterComponents('RX DBAware',[TRxDBProgressBar, TRxDBTrackBar]); RegisterComponents('RX DBAware',[TRxDBProgressBar, TRxDBTrackBar, TRxDBRadioGroup]);
end; end;
procedure RegisterRxDbGrid; procedure RegisterRxDbGrid;
@ -122,8 +123,28 @@ begin
RegisterComponents('RX DBAware',[TRxDBColorBox]); RegisterComponents('RX DBAware',[TRxDBColorBox]);
end; 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; procedure Register;
begin begin
//RX DBAware
RegisterUnit('dbdateedit', @RegisterUnitDBDateEdit);
RegisterUnit('rxlookup', @RegisterRXLookup);
RegisterUnit('rxdbcomb', @RegisterRxDBComb);
RegisterUnit('RxDBTimeEdit', @RegisterRxDBTimeEdit); RegisterUnit('RxDBTimeEdit', @RegisterRxDBTimeEdit);
RegisterUnit('RxDBSpinEdit', @RegisterRxDBSpinEdit); RegisterUnit('RxDBSpinEdit', @RegisterRxDBSpinEdit);
RegisterUnit('RxDBCtrls', @RegisterRxDBCtrls); RegisterUnit('RxDBCtrls', @RegisterRxDBCtrls);

View File

@ -797,14 +797,26 @@ function DrawShadowText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect;
function CheckBitmap: TBitmap; 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 implementation
uses SysUtils, Dialogs, {CommCtrl,} VCLUtils, Math, RxAppUtils, ImgList, uses SysUtils, Dialogs, VCLUtils, Math, RxAppUtils, ImgList,
ActnList, InterfaceBase ActnList, InterfaceBase;
(* Consts, {$IFDEF RX_D6}, RTLConsts{$ENDIF}
*)
;
const const
Alignments: array [TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER); Alignments: array [TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK); WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK);
@ -2541,6 +2553,32 @@ begin
UnionRect(Rect, RText, RShadow); UnionRect(Rect, RText, RShadow);
end; 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); constructor TRxCustomLabel.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);

View File

@ -194,8 +194,46 @@ type
property Visible; property Visible;
end; 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 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 } { TCustomRxDBProgressBar }

View File

@ -74,6 +74,8 @@ function ReallocMemo(fpBlock: Pointer; Size: Longint): Pointer;
procedure FreeMemo(var fpBlock: Pointer); procedure FreeMemo(var fpBlock: Pointer);
} }
procedure RaiseIndexOutOfBounds(Control: TControl; Items:TStrings; Index: integer);
{$IFDEF WIN32} {$IFDEF WIN32}
type type
PCursorOrIcon = ^TCursorOrIcon; PCursorOrIcon = ^TCursorOrIcon;
@ -100,7 +102,7 @@ procedure OutOfResources;
{$ENDIF} {$ENDIF}
implementation implementation
uses LCLProc, LCLIntf, LCLType; uses LCLProc, LCLIntf, LCLType, LCLStrConsts;
function WidthOf(R: TRect): Integer; function WidthOf(R: TRect): Integer;
begin begin
@ -650,6 +652,12 @@ begin
Canvas.Free; Canvas.Free;
end; end;
procedure RaiseIndexOutOfBounds(Control: TControl; Items:TStrings; Index: integer);
begin
raise Exception.CreateFmt(rsIndexOutOfBounds,
[Control.Name, Index, Items.Count - 1]);
end;
initialization initialization
LazarusResources.Add('rxbtn_downarrow','XPM',[ LazarusResources.Add('rxbtn_downarrow','XPM',[
'/* XPM */'#13#10'static char * btn_downarrow_xpm[] = {'#13#10'"5 3 2 1",'#13 '/* XPM */'#13#10'static char * btn_downarrow_xpm[] = {'#13#10'"5 3 2 1",'#13