Jump to content


Photo

Auto-Adjust ?


  • Please log in to reply
58 replies to this topic

#21 Der§en

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

Posted 07 February 2008 - 08:07 PM

I found a routine that might be able to help to force the break lines in the right place in the function ProcessHTML (in NxSharedCommon.pas)

CODE
procedure DrawHTML(r: TRect; aCanvas: TCanvas; const text: string);
var
  p: PChar;
  c: Char;
  x, y, w, wc, hc: Integer;
  code: string;
begin
  p := PChar(text);
  x := r.Left;
  y := r.Top;
  hc := aCanvas.TextHeight('Ag');
  if p <> nil then
    while p^ <> #0 do
    begin
      c := p^;
      if c = '<' then
      begin
        code := '';
        inc(p);
        while (p^ <> '>') and (p^ <> #0) do
        begin
          code := code + uppercase(p^);
          inc(p);
        end;
        if code = 'B' then
          aCanvas.Font.Style :=
              aCanvas.Font.Style + [fsBold]
        else if code = 'I' then
          aCanvas.Font.Style :=
              aCanvas.Font.Style + [fsItalic]
        else if code = 'U' then
          aCanvas.Font.Style :=
              aCanvas.Font.Style + [fsUnderline]
        else if code = '/B' then
          aCanvas.Font.Style :=
              aCanvas.Font.Style _ [fsBold]
        else if code = '/I' then
          aCanvas.Font.Style :=
              aCanvas.Font.Style _ [fsItalic]
        else if code = '/U' then
          aCanvas.Font.Style :=
              aCanvas.Font.Style _ [fsUnderline];
      end
      else if c = #10 then
      begin
        x := r.Left;
        inc(y, hc);
      end
      else if c >= #32 then
      begin
        wc := aCanvas.TextWidth(c);
        if x + wc > r.Right then
        begin x := r.Left; inc(y, hc);
        end;
        if y + hc < r.Bottom then
          aCanvas.TextOut(x, y, c);
        inc(x, wc);
      end;
      if p^>#0 then inc(p);
    end;
end;


This function, I found here: Delphipage

#22 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 07 February 2008 - 10:48 PM

Hello Dergen,

I have work on this issue last 2 days. Only solution is to modify my ProcessHTML procedure to bring me back total Height.

I will need a 1-2 days more for this.

Best regards
Boki (BergSoft)
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.

#23 Der§en

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

Posted 11 February 2008 - 07:14 PM

Good news or not ?

#24 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 11 February 2008 - 09:05 PM

Hello Dergen,

I am near to finish it. It will be done tonight or tomorow.

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.

#25 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 12 February 2008 - 02:02 AM

Hello Dergen,

I have finish it. I will upload it durring tomorow day, just to test it a little bit more.

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.

#26 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 12 February 2008 - 09:01 PM

Hello Dergen,

I have re-upload files (pre-release) on "Members Section" with html column best-fit support.

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.

#27 Der§en

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

Posted 13 February 2008 - 01:55 PM

I just install the pre-release (nextcomps_4281.zip) and I do not see the line break forced into the cell, which must be done as change in my code to make it work?

I attached a Hardcopy to see my problem !

Attached Files



#28 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 13 February 2008 - 07:10 PM

Hello Dergen,

It seems that we didn't understand each other well sad.gif

I have work on best-fit feature last days and finish it. I see now that you are thinking about Word Wrap feature for Html column.

I suggest that you use routine that you have find and custom drawing:

1) Set DrawingOptions of Column to doBackgroundOnly
2) Inside OnCustomDrawCell event place:

CODE
procedure TForm1.NextDBGrid1CustomDrawCell(Sender: TObject; ACol,
  ARow: Integer; CellRect: TRect; CellState: TCellState);
var
  Field: TField;
begin
  Field := NextDBGrid1.Columns[ACol].Field;
  if Field <> nil then
  begin
    DrawHTML(CellRect, NextDBGrid1.Canvas, Field.AsString);
  end;
end;


I hope that this helps.

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.

#29 Der§en

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

Posted 14 February 2008 - 11:39 AM

If we do not understand each other well, this is entirely my fault and my English very bad.

Excuse me for this!

#30 Der§en

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

Posted 14 February 2008 - 11:44 AM

I will test this code!

#31 Der§en

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

Posted 14 February 2008 - 01:23 PM

For my needs are simple, I change the routine like this:

CODE
procedure DrawHTML(aF: TFont; r: TRect; aCanvas: TCanvas; const text: string);
var
  p: PChar;
  c: Char;
  x, y, wc, hc: Integer;
  code: string;

begin
  aCanvas.Font := aF;

  p := PChar(text);
  x := r.Left + 2;
  y := r.Top  + 1;

  hc := GetTextHeight(aCanvas, Text);

  if (p <> nil) then
  while (p^ <> #0) do
  begin
    c := p^;
    if (c = '<') then
    begin
      code := '';
      inc(p);
      while (p^ <> '>') and (p^ <> #0) do
      begin
        code := code + uppercase(p^);
        inc(p);
      end;
    if (code = 'B') then
      aCanvas.Font.Style := aCanvas.Font.Style + [fsBold]
    else if (code = 'I') then
      aCanvas.Font.Style := aCanvas.Font.Style + [fsItalic]
    else if (code = 'U') then
      aCanvas.Font.Style := aCanvas.Font.Style + [fsUnderline]
    else if (code = 'FONT COLOR=RED') then
      aCanvas.Font.Color := clRed
    else if (code = 'FONT COLOR=BLUE') then
      aCanvas.Font.Color := clBlue
    else if (code = 'FONT COLOR=GREEN') then
      aCanvas.Font.Color := clGReen
    else if (code = '/B') then
      aCanvas.Font.Style := aCanvas.Font.Style - [fsBold]
    else if (code = '/I') then
      aCanvas.Font.Style := aCanvas.Font.Style - [fsItalic]
    else if (code = '/U') then
      aCanvas.Font.Style := aCanvas.Font.Style - [fsUnderline]
    else if (code = '/FONT') then
      aCanvas.Font.Color := clWindowText;
    end
    else if (c = #10) then
    begin
      x := r.Left + 2;
      inc(y, hc);
    end
    else if (c >= #32) then
    begin
      wc := GetTextWidth(aCanvas, c) + 1;
      if (x + wc > r.Right) then
      begin
        x := r.Left + 2;
        inc(y, hc);
      end;
      if (y + hc < r.Bottom) then
        aCanvas.TextOut(x, y, c);
      inc(x, wc);
    end;
    if (p^ > #0) then
      inc(p);
  end;
end;


But I hope that you propose a better solution when you can ...

#32 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 14 February 2008 - 02:39 PM

Hello Dergen,

Because you mostly use 3 colors, you may modify code such as:

CODE
    else if (code = 'FONT COLOR=RED') then
      aCanvas.Font.Color := clRed


into

CODE
    else if (code = 'RED') then
      aCanvas.Font.Color := clRed;


and then use next html code:

this is a <red>red colored</red> text.

I hope that this helps.

I will add word-wrap into my ProcessHtml routine but it will take a bit of time.

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.

#33 Der§en

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

Posted 14 February 2008 - 04:39 PM

Great idea to simply put color codes

Otherwise, I expect the added wordwrap forward!

#34 Der§en

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

Posted 22 February 2008 - 08:11 PM

QUOTE (Boki (Berg) @ Feb 14 2008, 02:39 PM) <{POST_SNAPBACK}>
I will add word-wrap into my ProcessHtml routine but it will take a bit of time.


What new for this ?

#35 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 22 February 2008 - 11:15 PM

Hello Dergen,

This feature require a time to be added. I will notify you when it is done.

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.

#36 Der§en

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

Posted 14 March 2008 - 07:36 PM

QUOTE (Boki (Berg) @ Feb 22 2008, 11:15 PM) <{POST_SNAPBACK}>
This feature require a time to be added. I will notify you when it is done.


What new for this ?

#37 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 14 March 2008 - 07:41 PM

Hello Dergen,

It is not ready yet. I will notify you when it is done. Thank you.

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.

#38 Der§en

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

Posted 19 March 2008 - 11:51 AM

It is urgent for my client because the display character, under certain conditions (for example italics) that the display truncated certain characters like O, F, and several others ...

Look picture jointed !

Attached Files



#39 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 19 March 2008 - 12:45 PM

Hello Dersen,

Can you please tell me which font you use? Also, do you use latest release? I have test it now and work correctly.

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.

#40 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 19 March 2008 - 12:50 PM

PS. Can you please give me a screnshot of next text (place it inside cell):

CODE
'this is <font color="#0000ff" name="Verdana"><i>simple italic</i></font> text.'

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users