Jump to content


Photo

Auto-Adjust ?


  • Please log in to reply
58 replies to this topic

#1 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 21 February 2007 - 01:31 PM

Or are you automatic adjustment of the cells compared to their contents ?

#2 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 08 March 2007 - 09:55 PM

Are you a solution for this ?

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 08 March 2007 - 10:06 PM

Hello Dergen,

I am sorry, it is not finished. It really need a time.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 10 March 2007 - 12:20 PM

Please sending me a message to prevent me when this function running.

#5 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 27 March 2007 - 05:52 PM

Look this modified procedure:
CODE

function GetCellTextSize(N: TNextDBGrid; ACol, ARow: Integer): TSize;
Const
  Params: TDrawTextParams =(Cbsize: 20; iTabLength: 0; iLeftMargin: 2; iRightMargin: 8; uiLengthDrawn: 0);
var
  r: TRect;
  ws: widestring;
begin
  ws := N.Cells[ACol, ARow];
  r  := N.GetCellRect(ACol, ARow);

  if (N.Columns[ACol].WrapKind = wkWordWrap) then
    Result.cy := DrawTextExW(N.Canvas.Handle, PWidechar(ws), Length(ws), r, DT_LEFT or DT_WORDBREAK or DT_NOPREFIX or DT_CALCRECT, @params) + 6
  else
    Result.cy := DrawTextExW(N.Canvas.Handle, PWidechar(ws), Length(ws), r, DT_LEFT or DT_SINGLELINE or DT_NOPREFIX or DT_CALCRECT, @params) + 6;

  if Result.cy < N.RowSize then
    Result.cy := N.RowSize;

  Result.cx := r.Right - r.Left;
end;


#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 27 March 2007 - 06:33 PM

Hello Dergen,

I will try it now. Thank you.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 05 May 2007 - 09:21 PM

Why the solution which walk is not integrated in the component (the Tlist, procedure and functions) ?

Can one hope that this will be to integrate in the next version !

#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 08 May 2007 - 08:53 PM

Hello Dergen,

I was try to integrate but I have found some problems with this procedure and this stoped me. I was decide to not integrate it yet.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 09 May 2007 - 11:52 AM

QUOTE (Boki (Berg) @ May 8 2007, 09:53 PM) <{POST_SNAPBACK}>
Hello Dergen,

I was try to integrate but I have found some problems with this procedure and this stoped me. I was decide to not integrate it yet.

regards


Ok, and this is very bad new for me...

While waiting, it would be possible to include the TList as well as the routines which correspond in the NextDBGrid, to be able them to call, that even manually would enable me to work well with this superb grid which you have realize !

I suppose that it is the automatic adjustment the height which poses a problem to you and not to put the list in the component…

Me, for example I am on a program which uses more than 20 NextDBgrids and duty to manage the 20 TLists in parallel, it is not simple, especially when it are treated by actions.

#10 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 14 June 2007 - 02:47 PM

Or is you with this, it is a serious problem for me because my solution is not perfect?

#11 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 14 June 2007 - 03:22 PM

Hello Dergen,

AutoSize feature is realy hard to add, and I have try to add it quickly after some testings but it require a lot more time.

I only may say that I will leave one week only for this feature, because I will maybe need to rewrite my own DrawText procedure because DrawText from Windows have bugs with returning text height in some situations.

Maybe some features are to loong on to-do list, but every time I finish some requested feature and fix bugs.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#12 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 23 June 2007 - 08:41 PM

I think of having found a solution reliable has 100%, it can be surely optimized, say to me what you think.

At home, with this new routine, I do not have any more a concern of calculation row height:
CODE
Function CalculTextSize(Phrase: string; AWidth, AMinimum: integer; Police: TFont = nil): TPoint;
var
  DC: HDC;
  Rect: TRect;
  C: TBitmap;
  WordWrapParams: integer;
begin
  C := TBitmap.create;

  if police <> nil then
    C.canvas.Font := police;

  Rect.Left   := 0;
  Rect.Top    :=0;
  Rect.Right  :=AWidth;
  Rect.Bottom :=0;

  DC := GetDC(0);

  C.Canvas.Handle := DC;

  WordWrapParams := 0;
  if (AWidth <> 0) then WordWrapParams := DT_NOPREFIX or DT_WORDBREAK;

  DrawText(C.Canvas.Handle, PChar(Phrase), -1, Rect, WordWrapParams or (DT_EXPANDTABS or DT_CALCRECT));

  C.Canvas.Handle := 0;

  ReleaseDC(0, DC);

  Result.X := Rect.Right - Rect.Left;
  Result.Y := (Rect.Bottom - Rect.Top) + 6;

  if (Result.Y < AMinimum) then
    Result.Y := AMinimum;

  C.Free;
end;

procedure GridAutoHeight(G: TNextDBGrid);
var
  I, U, A: integer;
begin
  // This is array of TList...
  frmMainWICS.iHeight[G.Tag].Clear;

  if (G.RowCount > 0) then
  begin
    for I := 0 to G.RowCount - 1 do
    begin
      A := 0;
      for U := 0 to G.Columns.Count - 1 do
        if (G.Columns[U].ColumnType = ctString) then
                  // New solution
          A := Max(A, CalculTextSize(G.Cells[U, I], (G.GetCellRect(U, I).Right - G.GetCellRect(U, I).Left), G.RowSize, G.Columns[U].Font).Y);

                  // Old solution
          // A := Max(A, GetCellTextSize(G, U, I));

      SetSize(frmMainWICS.iHeight[G.Tag], I, A);
    end;
    G.Invalidate;
    G.RefreshRange(0, G.RowCount);
  end;
end;


#13 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 23 June 2007 - 09:41 PM

Hello Dergen,

Can you please attach and one small example with this code. Maybe I can optimize it.

Thank you.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#14 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 23 June 2007 - 11:18 PM

Look this sample for Auto-Adjust height.

Why TNextGRid.ChangeRowHeight event not dispaly in Windows Events property's in last NextSuite ?

Attached Files



#15 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 23 June 2007 - 11:37 PM

Hello Dergen,

Thank you, I will test it now.

This event only exist in NextDBGrid, but I will add it in NextGrid too.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#16 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 25 June 2007 - 02:07 PM

This example is not exactly the code which I have write I adapted it for will correspond at the request of demonstration on a simple TNextGrid.

My code is pressed on a TNextDBGrid which use Unicode (TNTWare).

In my project this routine gives me whole satisfaction.

#17 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 25 June 2007 - 02:13 PM

Hello Dergen,

Maybe your code can help me somehow. I will try to retreive CellHeight immidiatelly when cell is drawn.

Thanks again, I have add ChangeRowHeight event into NextGrid too.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#18 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 28 January 2008 - 03:38 PM

Or is on the calculation of the proper height of rows in a TNextDBGrid ?

I have a problem of calculating the height if I use TNxHTMLColumn !

#19 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 28 January 2008 - 04:10 PM

Hello Dergen,

Calculating height of html column is not posible at the moment. I will try to add it, but it may be quite hard because content need to be parsed first and then calculated.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#20 Der§en

Der§en
  • Members
  • 167 posts
  • Gender:Male
  • Location:Paris

Posted 06 February 2008 - 01:35 PM

I have a part of the solution by changing my routine for calculating the heights, but I still have the concern that the text did not cut at the right places because tags !

CODE
Function CalculCellTextSize(N: TNextDBGrid; ACol, ARow: Integer): integer;
var
  DC: HDC;
  Rect: TRect;
  C: TBitmap;
  WordWrapParams: integer;
  IsUnicodeSupported: boolean;
begin
  C := TBitmap.create;

  // This is for compatibility in TNextGrid...
  IsUnicodeSupported := (Win32Platform = VER_PLATFORM_WIN32_NT);

  C.canvas.Font := N.Columns[ACol].Font;

  Rect.Left   := 0;
  Rect.Top    := 0;
  Rect.Right  := (N.GetCellRect(ACol, ARow).Right - N.GetCellRect(ACol, ARow).Left) - 5;
  Rect.Bottom := 0;

  DC := GetDC(0);

  C.Canvas.Handle := DC;

  WordWrapParams := 0;

  if (Rect.Right <> 0) then
    WordWrapParams := DT_NOPREFIX or DT_WORDBREAK or DT_WORD_ELLIPSIS;

  if (IsUnicodeSupported) then
  begin
    if (N.Columns[ACol] is TNxDBHtmlColumn) then
      DrawTextW(C.Canvas.Handle, PWideChar(RemoveAllTagsHTML(N.Cells[ACol, ARow])), -1, Rect, WordWrapParams or (DT_EXPANDTABS or DT_CALCRECT))
    else
      DrawTextW(C.Canvas.Handle, PWideChar(N.Cells[ACol, ARow]), -1, Rect, WordWrapParams or (DT_EXPANDTABS or DT_CALCRECT));
  end
  else
    DrawText(C.Canvas.Handle, PChar(string(N.Cells[ACol, ARow])), -1, Rect, WordWrapParams or (DT_EXPANDTABS or DT_CALCRECT));

  C.Canvas.Handle := 0;

  ReleaseDC(0, DC);

  Result := (Rect.Bottom - Rect.Top) + 6;

  if (Result < N.RowSize) then
    Result := N.RowSize;

  C.Free;
end;


And RemoveAllTagsHTML procedure :

CODE
function RemoveAllTagsHTML(FromWhere: WideString): WideString;
var
  IdX: Integer;
  IdY: Integer;
  ForceExit: Boolean;
begin
  Result    := FromWhere;
  ForceExit := False;

  repeat
    IdX := Pos('<', Result);
    IdY := Pos('>', Result);

    if ((IdX > 0) and (IdY > IdX)) then
      Result := Copy(Result, 1, (IdX - 1)) + Copy(Result, (IdY + 1), MaxInt)
    else
      ForceExit := True;
  until ((IdX = 0 ) Or (IdY = 0) Or (ForceExit));
end;


Did you an idea for this ?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users