From: <ah...@us...> - 2009-11-22 13:51:58
|
Revision: 12608 http://jvcl.svn.sourceforge.net/jvcl/?rev=12608&view=rev Author: ahuser Date: 2009-11-22 13:51:51 +0000 (Sun, 22 Nov 2009) Log Message: ----------- Mantis #5029: JvEnterAsTab is behind other controls Modified Paths: -------------- trunk/jvcl/images/makefile.mak trunk/jvcl/run/JvEnterTab.pas Removed Paths: ------------- trunk/jvcl/images/JvEnterTab.rc trunk/jvcl/images/JvResDESIGNENTERASTAB.bmp trunk/jvcl/resources/JvEnterTab.res Deleted: trunk/jvcl/images/JvEnterTab.rc =================================================================== --- trunk/jvcl/images/JvEnterTab.rc 2009-11-17 21:33:43 UTC (rev 12607) +++ trunk/jvcl/images/JvEnterTab.rc 2009-11-22 13:51:51 UTC (rev 12608) @@ -1 +0,0 @@ -DESIGNENTERASTAB BITMAP "JvResDESIGNENTERASTAB.BMP" Deleted: trunk/jvcl/images/JvResDESIGNENTERASTAB.bmp =================================================================== (Binary files differ) Modified: trunk/jvcl/images/makefile.mak =================================================================== --- trunk/jvcl/images/makefile.mak 2009-11-17 21:33:43 UTC (rev 12607) +++ trunk/jvcl/images/makefile.mak 2009-11-22 13:51:51 UTC (rev 12608) @@ -43,7 +43,6 @@ JvDBControls.res \ JvDBGrid.res \ JvDice.res \ -JvEnterTab.res \ JvErrorIndicator.res \ JvGammaPanel.res \ JvgButton.res \ @@ -119,7 +118,6 @@ JvDBControls.res: JvDBControls.rc JvDBGrid.res: JvDBGrid.rc JvDice.res: JvDice.rc -JvEnterTab.res: JvEnterTab.rc JvErrorIndicator.res: JvErrorIndicator.rc JvGammaPanel.res: JvGammaPanel.rc JvgButton.res: JvgButton.rc Deleted: trunk/jvcl/resources/JvEnterTab.res =================================================================== (Binary files differ) Modified: trunk/jvcl/run/JvEnterTab.pas =================================================================== --- trunk/jvcl/run/JvEnterTab.pas 2009-11-17 21:33:43 UTC (rev 12607) +++ trunk/jvcl/run/JvEnterTab.pas 2009-11-22 13:51:51 UTC (rev 12608) @@ -36,25 +36,22 @@ JclUnitVersioning, {$ENDIF UNITVERSIONING} Windows, Messages, Classes, Graphics, Controls, - JvComponent; + JvComponentBase; type - TJvEnterAsTabEvent = procedure (Sender:TObject; AControl:TWinControl; var Handled:Boolean) of object; - TJvEnterAsTab = class(TJvGraphicControl) + TJvEnterAsTabEvent = procedure (Sender: TObject; AControl: TWinControl; var Handled: Boolean) of object; + + TJvEnterAsTab = class(TJvComponent) private FEnterAsTab: Boolean; FAllowDefault: Boolean; - FBmp: TBitmap; FOnHandleEnter: TJvEnterAsTabEvent; + procedure IgnoreValue(Reader: TReader); protected - function EnterHandled(AControl: TWinControl): Boolean;virtual; - procedure CMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY; - procedure Paint; override; + function EnterHandled(AControl: TWinControl): Boolean; virtual; + procedure DefineProperties(Filer: TFiler); override; public constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; - AHeight: Integer); override; published property EnterAsTab: Boolean read FEnterAsTab write FEnterAsTab default True; property AllowDefault: Boolean read FAllowDefault write FAllowDefault default True; @@ -62,7 +59,7 @@ // Tab key. Only triggered if AllowDefault is true. If no event handler is assigned, // Enter keys will not be converted into Tab if the currently active control is a // TbuttonControl descendant - property OnHandleEnter:TJvEnterAsTabEvent read FOnHandleEnter write FOnHandleEnter; + property OnHandleEnter: TJvEnterAsTabEvent read FOnHandleEnter write FOnHandleEnter; end; {$IFDEF UNITVERSIONING} @@ -80,43 +77,22 @@ uses Forms, StdCtrls; -{$R JvEnterTab.res} +type + TJvEnterAsTabControl = class(TGraphicControl) + protected + procedure CMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY; + end; -constructor TJvEnterAsTab.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - ControlStyle := ControlStyle + [csNoStdEvents, csFixedHeight, csFixedWidth]; - FEnterAsTab := True; - FAllowDefault := True; - if csDesigning in ComponentState then - begin - FBmp := TBitmap.Create; - FBmp.LoadFromResourceName(HInstance, 'DESIGNENTERASTAB'); - end - else - Visible := False; -end; +{ TJvEnterAsTabControl } -destructor TJvEnterAsTab.Destroy; +procedure TJvEnterAsTabControl.CMDialogKey(var Msg: TCMDialogKey); +var + Comp: TJvEnterAsTab; begin - FBmp.Free; - inherited Destroy; -end; - - - -function TJvEnterAsTab.EnterHandled(AControl:TWinControl):Boolean; -begin - Result := AControl is TButtonControl; - if Assigned(FOnHandleEnter) then - FOnHandleEnter(Self, AControl, Result); -end; - -procedure TJvEnterAsTab.CMDialogKey(var Msg: TCMDialogKey); -begin - if (Msg.CharCode = VK_RETURN) and EnterAsTab then + Comp := (Owner as TJvEnterAsTab); + if (Msg.CharCode = VK_RETURN) and Comp.EnterAsTab then begin - if AllowDefault and EnterHandled(GetParentForm(Self).ActiveControl) then + if Comp.AllowDefault and Comp.EnterHandled(GetParentForm(Self).ActiveControl) then inherited else begin @@ -128,25 +104,44 @@ inherited; end; +{ TJvEnterAsTab } - - -procedure TJvEnterAsTab.Paint; +constructor TJvEnterAsTab.Create(AOwner: TComponent); +var + Ctrl: TJvEnterAsTabControl; begin + inherited Create(AOwner); + FEnterAsTab := True; + FAllowDefault := True; if not (csDesigning in ComponentState) then - Exit; - with Canvas do begin - Brush.Color := clBtnFace; - BrushCopy( ClientRect, FBmp, ClientRect, clFuchsia); + Ctrl := TJvEnterAsTabControl.Create(Self); + Ctrl.Visible := False; + Ctrl.Parent := GetParentForm(AOwner as TControl); end; end; -procedure TJvEnterAsTab.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); +procedure TJvEnterAsTab.DefineProperties(Filer: TFiler); begin - inherited SetBounds(ALeft, ATop, 28, 28); + inherited DefineProperties(Filer); + { TJvEnterAsTab was a TJvGraphicControl and now we have to ignore all the + wrong properties. } + Filer.DefineProperty('Width', IgnoreValue, nil, False); + Filer.DefineProperty('Height', IgnoreValue, nil, False); end; +function TJvEnterAsTab.EnterHandled(AControl: TWinControl): Boolean; +begin + Result := AControl is TButtonControl; + if Assigned(FOnHandleEnter) then + FOnHandleEnter(Self, AControl, Result); +end; + +procedure TJvEnterAsTab.IgnoreValue(Reader: TReader); +begin + Reader.SkipValue; +end; + {$IFDEF UNITVERSIONING} initialization RegisterUnitVersion(HInstance, UnitVersioning); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |