Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003833 [JEDI VCL] 00 JVCL Components text always 2006-07-25 05:29 2007-01-03 12:52
Reporter Werewolf View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.20
Summary 0003833: TJvDBHTLabel doesn't support painting on TDBCtrlGrid
Description When you have TJvDBHTLabel on DBCtrlGrid in runtime it always paints last updated record on each DBCtrlGrid's panel.
Additional Information
Tags No tags attached.
Attached Files zip file icon TJvDBHTLabel.zip [^] (378,812 bytes) 2006-07-26 01:19
? file icon patch.diff [^] (7,600 bytes) 2006-08-01 06:59
? file icon jvHt.patch [^] (3,551 bytes) 2006-08-25 03:51
? file icon jvHtnew.patch [^] (3,752 bytes) 2006-08-28 00:42

- Relationships

-  Notes
(0009857)
obones (administrator)
2006-07-26 00:44

Please provide the zipped sources of a sample application showing the issue.
(0009862)
Werewolf (reporter)
2006-07-26 01:19

sample application contains 2 forms
first form displays data of clientdataset in dbctrlgrid using TJvDBHTLabel
second form is a simple editor for clientdataset
by the way, when mask of TJvDBHTLabel ends with italic text width of label is calculated incorrectly.
To enable normal painting in DBCtrlGrid component must support different painting in dependence on flag csPaintCopy in ControlState while painting
sample:
-------------------------------------------------
type TMycomp = class(TLabel)
    procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
......

procedure TMycomp.WMPaint(var Message: TWMPaint);
begin
  if not (csPaintCopy in ControlState) then inherited else
  begin
//here data must be taken from FDataLink and not from DataSet/DataSource
  end
----------------------------------------------------

also it can get datalink from dbctrlgrid by implementing code for CM_GETDATALINK message
sample:
----------------------------------------------------
type TMycomp= class(TLabel)
    FDataLink: TFieldDataLink;
    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;

....

procedure TMycomp.CMGetDataLink(var Message: TMessage);
Begin
  Message.Result := Integer(FDataLink);
End;
---------------------------------------------------------------
(0009863)
Werewolf (reporter)
2006-07-26 01:30

You can look how borland's TDBText component is implemented:
 TDBText = class(TCustomLabel)
  private
    FDataLink: TFieldDataLink;
    procedure DataChange(Sender: TObject);
-----------------------------
    function GetFieldText: string;
------------------------
    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
  protected
    function GetLabelText: string; override;//overriden - used in TCustomLabel.DoDrawText
-------------------------------------
function TDBText.GetFieldText: string;
begin
  if FDataLink.Field <> nil then
    Result := FDataLink.Field.DisplayText
  else
    if csDesigning in ComponentState then Result := Name else Result := '';
end;

procedure TDBText.DataChange(Sender: TObject);
begin
  Caption := GetFieldText;
end;

function TDBText.GetLabelText: string;
begin
  if csPaintCopy in ControlState then ////////////////////this is it
    Result := GetFieldText else
    Result := Caption;
end;
(0009865)
obones (administrator)
2006-07-26 01:42

So what is your proposed change?
(0009868)
Werewolf (reporter)
2006-07-26 07:02

changes to JvHtControls.pas procedure TJvCustomHTLabel.Paint
------------------------
procedure TJvCustomHTLabel.Paint;
var
  Rect: TRect;
  Text:string;
begin
  Text:=GetLabelText;
  Canvas.Font := Font;
  Canvas.Brush.Color := Color;
  if Transparent then
    Canvas.Brush.Style := bsClear
  else
    Canvas.Brush.Style := bsSolid;
  Canvas.FillRect(ClientRect);
  Rect := ClientRect;
  case Layout of
    tlTop:
      ;
    tlBottom:
      Rect.Top := Rect.Bottom - ItemHTHeight(Canvas, Text);
    tlCenter:
      Rect.Top := (Rect.Bottom - Rect.Top - ItemHTHeight(Canvas, Text)) div 2;
  end;
  Canvas.Font.Style := []; // only font name and font size is important
  if not Enabled then
  begin
    OffsetRect(Rect, 1, 1);
    Canvas.Font.Color := clBtnHighlight;
    ItemHTDraw(Canvas, Rect, [odDisabled], Text);
    OffsetRect(Rect, -1, -1);
    Canvas.Font.Color := clBtnShadow;
    ItemHTDraw(Canvas, Rect, [odDisabled], Text);
  end
  else
    ItemHTDraw(Canvas, Rect, [], Text);
end;
-----------------------------------------------
changes to JvDBHTLabel.pas methods added
----------------------
 TJvDBHTLabel = class(TJvCustomHTLabel)
private
........................
    procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
  protected
    function GetLabelText: string; override;
    procedure Notification(AComponent: TComponent;
      Operation: TOperation); override;
......................
function TJvDBHTLabel.GetLabelText: string;
begin
  if csPaintCopy in ControlState then
  begin
    if (Assigned(FDataLink) and Assigned(FDataLink.DataSet)) then
      Result := ReplaceFieldNameTag(FMask, FDataLink.DataSet)
    else
      Result := ReplaceFieldNameTag(Mask, nil);
  end
  else
    Result := Caption;
end;

procedure TJvDBHTLabel.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (FDataLink <> nil) and
    (AComponent = DataSource) then
    DataSource := nil;
end;

procedure TJvDBHTLabel.CMGetDataLink(var Message: TMessage);
begin
  Message.Result := Integer(FDataLink);
end;
(0009873)
Werewolf (reporter)
2006-07-27 08:14

So, what's your opinion?
(0009882)
obones (administrator)
2006-07-28 14:37

Please provide a diff file, that would be easier to read for me, and easier to integrate.
(0009918)
Werewolf (reporter)
2006-07-31 01:59

With what tool do you want me to produce diff file?
(0009919)
obones (administrator)
2006-07-31 02:32

diff -u 3 or with TortoiseSVN as described here:

http://homepages.borland.com/jedi/wiki/index.php?title=Create_a_patch_file [^]
(0009929)
Werewolf (reporter)
2006-08-01 02:00
edited on: 2006-08-01 02:01

Give me a hint to configure TortoiseSVN correctly, pls.
(I don't see Create Patch in context menu...)

(0009930)
obones (administrator)
2006-08-01 02:46

You must have checked out the SVN repository as indicated here:

http://homepages.borland.com/jedi/wiki/index.php?title=Repository [^]

and applied your changes in the folder created by the above. Then you will be able to right click on the file and choose "Create Patch" from the Tortoise SVN subdirectory.
(0010004)
Werewolf (reporter)
2006-08-23 06:37

I've uploded diff
so whats your opinion
(0010022)
obones (administrator)
2006-08-25 02:38

A few questions/remarks then:

- Why did you remove two lines of comment at the start?
- The list of changes are NOT to be added. On top of that some sentences are not even complete. This list is to be provided to us OUTSIDE of the unit file.
- What is this "VDBConst" unit?
- What is the point of DataSourceFixed in the overridden SetAutoSize?
- Please respect the coding guide standard. Especially, spaces around ":="

Until such time we get the answers and an updated diff file, this will stay in the "feedback" state.
(0010024)
Werewolf (reporter)
2006-08-25 03:32

>A few questions/remarks then:

>- Why did you remove two lines of comment at the start?

Sorry, it was my first diff =)

>- The list of changes are NOT to be added. On top of that some sentences are >not even complete. This list is to be provided to us OUTSIDE of the unit file.

I'll post changes to issue.

>- What is this "VDBConst" unit?

It's unit that contains resourcestring SDataSourceFixed = 'Operation not allowed in a DBCtrlGrid'; in BDS4

>- What is the point of DataSourceFixed in the overridden SetAutoSize?

DataSourceFixed property of TDataLink indicates whether the DataSource property can be set.
DBCtrlGrid calls Control.Perform(CM_GETDATALINK, 0, 0) to get controls DataLink and Sets it's property DataSourceFixed to true.

So that control can be stil autosized when it's not on DBCtrlGrid
But when you have your control on DBCtrlGrid and set autosize to true DatabaseError(SDataSourceFixed) must be called. (to prevent autosize bug on DBCtrlGrid)

>- Please respect the coding guide standard. Especially, spaces around ":="
I'll do my best =)

>Until such time we get the answers and an updated diff file, this will stay in >the "feedback" state.
(0010032)
obones (administrator)
2006-08-28 10:40

I still don't understand the issue with AutoSize.
I might be dumb, but to me DataSourceFixed is related to the data, AutoSize is related to the user interface.
Why would the data related "fixness" have any impact on the size of the control?
(0010033)
Werewolf (reporter)
2006-08-29 01:09

the Main reason to restrict autosize of TJVDBHTLabel on tdbctrlgrid is:
When you have TJVDBHTLabel on tdbctrlgrid and length of text that TJVDBHTLabel must paint differ from record to record then autosize feature will always return size for active record, but changes will be applied for all TJVDBHTLabel
so when we have records:
aaa
bbbbbbb
ccc
and when we select first or last record label that should display bbbbbbb shows only bbb;
so when you design controls on tdbctrlgrid autosize must be disabled and you must spesify the size you want in design time

and DataSourceFixed here is a flag that shows that control is on tdbctrlgrid
(0010501)
obones (administrator)
2007-01-03 12:52

This is now fixed in SVN.

- Issue History
Date Modified Username Field Change
2006-07-25 05:29 Werewolf New Issue
2006-07-25 05:29 Werewolf Issue Monitored: Werewolf
2006-07-26 00:44 obones Note Added: 0009857
2006-07-26 00:44 obones Status new => feedback
2006-07-26 01:19 Werewolf File Added: TJvDBHTLabel.zip
2006-07-26 01:19 Werewolf Note Added: 0009862
2006-07-26 01:30 Werewolf Note Added: 0009863
2006-07-26 01:42 obones Note Added: 0009865
2006-07-26 07:02 Werewolf Note Added: 0009868
2006-07-27 08:14 Werewolf Note Added: 0009873
2006-07-28 14:37 obones Note Added: 0009882
2006-07-31 01:34 Werewolf Note Added: 0009913
2006-07-31 01:35 Werewolf Note Added: 0009914
2006-07-31 01:37 Werewolf Note Added: 0009915
2006-07-31 01:44 Werewolf Note Deleted: 0009913
2006-07-31 01:44 Werewolf Note Added: 0009916
2006-07-31 01:45 Werewolf Note Deleted: 0009914
2006-07-31 01:46 Werewolf Note Added: 0009917
2006-07-31 01:59 Werewolf Note Added: 0009918
2006-07-31 01:59 Werewolf Note Deleted: 0009917
2006-07-31 01:59 Werewolf Note Deleted: 0009916
2006-07-31 02:00 Werewolf Note Deleted: 0009915
2006-07-31 02:01 Werewolf Issue Monitored: obones
2006-07-31 02:32 obones Note Added: 0009919
2006-08-01 02:00 Werewolf Note Added: 0009929
2006-08-01 02:01 Werewolf Note Edited: 0009929
2006-08-01 02:46 obones Note Added: 0009930
2006-08-01 06:59 Werewolf File Added: patch.diff
2006-08-01 06:59 Werewolf Note Added: 0009931
2006-08-01 06:59 Werewolf Issue End Monitor: Werewolf
2006-08-01 06:59 Werewolf Issue Monitored: Werewolf
2006-08-23 06:37 Werewolf Note Added: 0010004
2006-08-25 02:38 obones Note Added: 0010022
2006-08-25 03:32 Werewolf Note Added: 0010024
2006-08-25 03:51 Werewolf File Added: jvHt.patch
2006-08-25 03:59 Werewolf Note Added: 0010026
2006-08-25 04:00 Werewolf Note Deleted: 0009931
2006-08-25 04:10 Werewolf Note Added: 0010027
2006-08-28 00:42 Werewolf File Added: jvHtnew.patch
2006-08-28 08:28 Werewolf Note Deleted: 0010027
2006-08-28 08:28 Werewolf Note Deleted: 0010026
2006-08-28 10:40 obones Note Added: 0010032
2006-08-29 01:09 Werewolf Note Added: 0010033
2007-01-03 12:52 obones Status feedback => resolved
2007-01-03 12:52 obones Fixed in Version => Daily / SVN
2007-01-03 12:52 obones Resolution open => fixed
2007-01-03 12:52 obones Assigned To => obones
2007-01-03 12:52 obones Note Added: 0010501
2007-03-22 00:14 Werewolf Issue End Monitor: Werewolf


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker