View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001510 | JEDI VCL | 00 JVCL Components | public | 2004-03-21 05:31 | 2004-03-21 08:08 |
Reporter | glchapman | Assigned To | user72 | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0001510: JvXPContainer: remove some COMPILER6_UP's | ||||
Description | TJvXPContainer has a couple of properties (EnabledMode and OnEnabledChanged) which were not available in Delphi 5. I think they were left out because D5's SetPropValue does not correctly handle boolean types. The attached diff rewrites HookEnabledChanged to avoid SetPropValue. Also, OnContextPopup is defined for TControl in Delphi 5, so there didn't seem to be any reason for TJvXPContainer to publish it only for Delphi 6+. | ||||
Additional Information | The HookEnabledChanged could be rewritten without using RTTI, since Enabled is a public property of TControl: procedure TJvXPCustomContainer.HookEnabledChanged; var I: Integer; begin inherited HookEnabledChanged; if FEnabledMode = emAffectChilds then for I := 0 to ControlCount - 1 do Controls[I].Enabled:= Enabled; if Assigned(FOnEnabledChanged) then FOnEnabledChanged(Self); end; I believe the above is the correct way to write this sort of thing. However, it might cause problems if a TControl descendant introduces a new property setter for Enabled. It seems to me that introducing a new setter is a poor practice (better to handle CM_ENABLEDCHANGED), but, unfortunately, I found a few Orpheus 4 controls which do this, so I have stuck to using RTTI. | ||||
Tags | No tags attached. | ||||
2004-03-21 05:31
|
JvXPContainer.pas.diff (6,678 bytes)
--- JvXPContainer.pas.orig 2004-01-31 10:50:48.000000000 -0800 +++ JvXPContainer.pas 2004-03-21 05:12:34.000000000 -0800 @@ -30,76 +30,62 @@ {$I jvcl.inc} interface uses - {$IFDEF COMPILER6_UP} TypInfo, - {$ENDIF COMPILER6_UP} Windows, Classes, Controls, Graphics, StdCtrls, JvXPCore, JvXPCoreUtils; type TJvXPPaintEvent = procedure(Sender: TObject; Rect: TRect; ACanvas: TCanvas; AFont: TFont) of object; - {$IFDEF COMPILER6_UP} TJvXPEnabledMode = (emAffectChilds, emNormal); - {$ENDIF COMPILER6_UP} TJvXPCustomContainer = class(TJvXPCustomControl) private FAlignment: TAlignment; FBorderWidth: TBorderWidth; FBoundColor: TColor; FBoundLines: TJvXPBoundLines; - {$IFDEF COMPILER6_UP} FEnabledMode: TJvXPEnabledMode; - {$ENDIF COMPILER6_UP} FFocusable: Boolean; FGlyph: TBitmap; FGlyphLayout: TJvXPGlyphLayout; FLayout: TTextLayout; FShowBoundLines: Boolean; FShowCaption: Boolean; FSpacing: Byte; FWordWrap: Boolean; - {$IFDEF COMPILER6_UP} FOnEnabledChanged: TNotifyEvent; - {$ENDIF COMPILER6_UP} FOnPaint: TJvXPPaintEvent; procedure SetAlignment(Value: TAlignment); procedure SetBorderWidth(Value: TBorderWidth); procedure SetBoundColor(Value: TColor); procedure SetBoundLines(Value: TJvXPBoundLines); - {$IFDEF COMPILER6_UP} procedure SetEnabledMode(Value: TJvXPEnabledMode); - {$ENDIF COMPILER6_UP} procedure SetGlyph(Value: TBitmap); procedure SetGlyphLayout(Value: TJvXPGlyphLayout); procedure SetLayout(Value: TTextLayout); procedure SetShowBoundLines(Value: Boolean); procedure SetShowCaption(Value: Boolean); procedure SetSpacing(Value: Byte); procedure SetWordWrap(Value: Boolean); protected procedure CreateParams(var Params: TCreateParams); override; procedure AdjustClientRect(var Rect: TRect); override; - {$IFDEF COMPILER6_UP} procedure HookEnabledChanged; override; - {$ENDIF COMPILER6_UP} procedure HookMouseDown; override; procedure HookPosChanged; override; procedure Paint; override; property Alignment: TAlignment read FAlignment write SetAlignment default taCenter; property BorderWidth: TBorderWidth read FBorderWidth write SetBorderWidth default 0; property BoundColor: TColor read FBoundColor write SetBoundColor default clGray; property BoundLines: TJvXPBoundLines read FBoundLines write SetBoundLines default []; - {$IFDEF COMPILER6_UP} property EnabledMode: TJvXPEnabledMode read FEnabledMode write SetEnabledMode default emNormal; - {$ENDIF COMPILER6_UP} property Focusable: Boolean read FFocusable write FFocusable default False; property Glyph: TBitmap read FGlyph write SetGlyph; property GlyphLayout: TJvXPGlyphLayout read FGlyphLayout write SetGlyphLayout default glCenter; property Layout: TTextLayout read FLayout write SetLayout default tlCenter; @@ -109,13 +95,11 @@ property ShowCaption: Boolean read FShowCaption write SetShowCaption default False; property Spacing: Byte read FSpacing write SetSpacing default 5; property Width default 185; property WordWrap: Boolean read FWordWrap write SetWordWrap default False; - {$IFDEF COMPILER6_UP} property OnEnabledChanged: TNotifyEvent read FOnEnabledChanged write FOnEnabledChanged; - {$ENDIF COMPILER6_UP} property OnPaint: TJvXPPaintEvent read FOnPaint write FOnPaint; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; @@ -128,25 +112,21 @@ property BoundColor; property BoundLines; property Caption; property Color; property Enabled; - {$IFDEF COMPILER6_UP} property EnabledMode; - {$ENDIF COMPILER6_UP} property Focusable; property Glyph; property GlyphLayout; property Layout; property ParentColor; property ShowBoundLines; property ShowCaption; property Spacing; property WordWrap; - {$IFDEF COMPILER6_UP} property OnEnabledChanged; - {$ENDIF COMPILER6_UP} property OnDblClick; property OnPaint; property OnResize; //property BevelInner; @@ -181,13 +161,13 @@ //property OnStartDock; //property OnUnDock; property OnCanResize; property OnClick; property OnConstrainedResize; - {$IFDEF COMPILER6_UP} + {$IFDEF COMPILER5_UP} property OnContextPopup; - {$ENDIF COMPILER6_UP} + {$ENDIF COMPILER5_UP} property OnDragDrop; property OnDragOver; property OnEndDrag; property OnEnter; property OnExit; @@ -213,13 +193,11 @@ Height := 41; Width := 185; FAlignment := taCenter; FBoundColor := clGray; FBoundLines := []; - {$IFDEF COMPILER6_UP} FEnabledMode := emNormal; - {$ENDIF COMPILER6_UP} FFocusable := False; FGlyph := TBitmap.Create; FGlyph.Assign(nil); FGlyphLayout := glCenter; FLayout := tlCenter; @@ -240,26 +218,29 @@ inherited CreateParams(Params); with Params do WindowClass.Style := WindowClass.Style and not (CS_HREDRAW or CS_VREDRAW); end; -{$IFDEF COMPILER6_UP} procedure TJvXPCustomContainer.HookEnabledChanged; const cEnabled = 'Enabled'; var I: Integer; + control: TControl; + propinfo: PPropInfo; begin inherited HookEnabledChanged; if FEnabledMode = emAffectChilds then - for I := 0 to ControlCount - 1 do - if IsPublishedProp(Controls[I], cEnabled) then - SetPropValue(Controls[I], cEnabled, Enabled); + for I := 0 to ControlCount - 1 do begin + control:= Controls[I]; + propinfo:= GetPropInfo(control, cEnabled, [tkEnumeration]); + if Assigned(propinfo) and (propinfo.PropType^ = typeinfo(Boolean)) then + SetOrdProp(control, propinfo, Ord(Enabled)); + end; if Assigned(FOnEnabledChanged) then FOnEnabledChanged(Self); end; -{$ENDIF COMPILER6_UP} procedure TJvXPCustomContainer.HookMouseDown; begin if FFocusable then inherited HookMouseDown @@ -320,20 +301,18 @@ Realign; InternalRedraw; end; end; -{$IFDEF COMPILER6_UP} procedure TJvXPCustomContainer.SetEnabledMode(Value: TJvXPEnabledMode); begin if Value <> FEnabledMode then begin FEnabledMode := Value; HookEnabledChanged; end; end; -{$ENDIF COMPILER6_UP} procedure TJvXPCustomContainer.SetGlyph(Value: TBitmap); begin if Value <> FGlyph then begin |
|
Updated in CVS |
Date Modified | Username | Field | Change |
---|---|---|---|
2004-03-21 05:31 | glchapman | New Issue | |
2004-03-21 05:31 | glchapman | File Added: JvXPContainer.pas.diff | |
2004-03-21 08:08 |
|
Status | new => resolved |
2004-03-21 08:08 |
|
Resolution | open => fixed |
2004-03-21 08:08 |
|
Assigned To | => user72 |
2004-03-21 08:08 |
|
Note Added: 0003419 |