Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
Slow Canvas.TextRect (TsWorksheetGrid)
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Array of structure -> str...
by
Seenkao
[
Today
at 09:44:44 pm]
Very rough version of a s...
by
Hansvb
[
Today
at 08:56:35 pm]
Portable verion of FPC an...
by
backprop
[
Today
at 08:40:34 pm]
GDB 17 for Windows
by
Martin_fr
[
Today
at 08:26:24 pm]
[New Component] ExtTabCtr...
by
ovidio
[
Today
at 08:14:52 pm]
TStringGrid Question
by
J-G
[
Today
at 08:05:52 pm]
FPC Unleashed (inline var...
by
flowCRANE
[
Today
at 07:24:27 pm]
Lazarus Main and Gnome/Wa...
by
zeljko
[
Today
at 05:48:44 pm]
Benchmark: converting arr...
by
LemonParty
[
Today
at 03:25:25 pm]
Read/Parse PDB file to ge...
by
marcov
[
Today
at 02:48:12 pm]
[SOVLED]Curved text in La...
by
paweld
[
Today
at 11:00:52 am]
Fast Canvas Library V1.05...
by
microxa
[
Today
at 07:03:07 am]
"Identifier idents no mem...
by
Thaddy
[
Today
at 05:43:52 am]
[SOLVED] TPrintDialog Pro...
by
spuds
[
Today
at 01:30:20 am]
TPairsplitter could be be...
by
jamie
[
Today
at 12:36:34 am]
FloatToStr issue
by
J-G
[
Today
at 12:06:38 am]
Release ray4laz 6.0
by
Fred vS
[June 05, 2026, 09:06:27 pm]
Pascal for AI Agent CLI T...
by
Martin_fr
[June 05, 2026, 08:01:11 pm]
storing assets for releas...
by
flowCRANE
[June 05, 2026, 07:30:13 pm]
Benchmark aligned vs unal...
by
LeP
[June 05, 2026, 06:33:08 pm]
TstringGrid read cell col...
by
hedgehog
[June 05, 2026, 06:29:11 pm]
Range checks and `Move` o...
by
ASerge
[June 05, 2026, 05:17:19 pm]
Why is var after type in ...
by
Warfley
[June 05, 2026, 02:36:17 pm]
SnapModbus
by
ThomasK
[June 05, 2026, 01:40:22 pm]
Spell checking for IDE so...
by
Martin_fr
[June 05, 2026, 11:48:38 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Slow Canvas.TextRect (TsWorksheetGrid) (Read 3900 times)
xinyiman
Hero Member
Posts: 2261
Slow Canvas.TextRect (TsWorksheetGrid)
«
on:
October 22, 2016, 12:18:45 am »
Hello guys, follow my function that draws on one of the TsWorksheetGrid cells with colored background and a lot of text. If the text is short the program is fast changing in the cell. If the text is long time to change from one cell to another it is long (up to 2 seconds). Can anyone tell me why?
Code: Pascal
[Select]
[+]
[-]
procedure
TAppuntamentiGiornalieri
.
InserisciTestoSplittato
(
Sender
:
TObject
;
aCol
,
aRow
:
Integer
;
aRect
:
TRect
;
aState
:
TGridDrawState
;
stepRow
:
integer
;
indice
:
integer
;
LarghezzaCella
:
integer
;
Shield
:
boolean
)
;
var
i
,
x
,
y
:
Integer
;
txtStyle
,
appStyle
:
TTextStyle
;
Testo
:
string
;
begin
//Vado ad inserire il testo
with
sender as TsWorksheetGrid
do
begin
appStyle
:
=
Canvas
.
TextStyle
;
appStyle
.
Wordbreak
:
=
true
;
appStyle
.
SingleLine
:
=
false
;
appStyle
.
Alignment
:
=
taLeftJustify
;
Canvas
.
Font
.
Name
:
=
'Courier New'
;
Canvas
.
Font
.
Color
:
=
clBlack
;
//clSilver;
Canvas
.
Font
.
Style
:
=
[
]
;
Canvas
.
Font
.
Height
:
=
12
;
y
:
=
aRect
.
Top
;
if
LarghezzaCella>
20
then
x
:
=
aRect
.
Left
+
20
//il + 20 è lo spazio dal bordo sinistro perchè il testo deve iniziare dopo la barra colorata
else
x
:
=
aRect
.
Left
+
1
;
// queste due righe mi permettono di scrivere sul blocco verde senza togliermi gli angoli arrotondati
txtStyle
:
=
Canvas
.
TextStyle
;
txtStyle
.
Opaque
:
=
True
;
//Inserisco il testo
Testo
:
=
Self
.
Dati
[
indice
]
.
TestoAssemblato
;
if
Shield
=
true
then
Testo
:
=
TrasformaTesto
(
Testo
)
;
Canvas
.
TextRect
(
aRect
,
x
,
y
,
Self
.
GetTesto
(
indice
,
Shield
)
,
appStyle
)
;
//reimposto lo stile precedente all'inserimento del testo
Canvas
.
TextStyle
:
=
txtStyle
;
end
;
end
;
Logged
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1
circular
Hero Member
Posts: 4471
Re: Slow Canvas.TextRect (TsWorksheetGrid)
«
Reply #1 on:
October 22, 2016, 08:25:04 am »
Maybe Self.GetTesto is slow?
Logged
Conscience is the debugger of the mind
xinyiman
Hero Member
Posts: 2261
Re: Slow Canvas.TextRect (TsWorksheetGrid)
«
Reply #2 on:
October 22, 2016, 10:09:59 am »
No! Also this is slow (direct string)
Canvas.TextRect(aRect, x, y, 'ciao come stai tante belle parole che non sono coerenti, ciao caio sempronio, servo solo a fare una stringa discretamente lunga...porca paletta', appStyle);
Logged
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1
xinyiman
Hero Member
Posts: 2261
Re: Slow Canvas.TextRect (TsWorksheetGrid)
«
Reply #3 on:
October 22, 2016, 10:23:15 am »
I understood what makes the slow Canvas.TextRect!
It 'option
appStyle.Wordbreak:=true;
In fact, if the comments performance improves. However, if one needs to go to the head? How can it be done?
//appStyle.Wordbreak:=true;
Logged
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1
wp
Hero Member
Posts: 13543
Re: Slow Canvas.TextRect (TsWorksheetGrid)
«
Reply #4 on:
October 22, 2016, 11:53:51 am »
What I don't understand is why you are working with TextStyle.Wordbreak and Fonts at all? All these are built into the WorksheetGrid, you just have to activate the options for the particular cell (see
http://wiki.lazarus.freepascal.org/TsWorksheetGrid#Cell_formatting
):
Code: Pascal
[Select]
[+]
[-]
WorksheetGrid
.
WordWrap
[
gridCol
,
gridRow
]
:
=
true
;
WorksheetGrid
.
CellFontName
[
gridCol
,
gridRow
]
:
=
'Courier'
WorksheetGrid
.
CellFontSize
[
gridCol
,
gridRow
]
:
=
12
;
WorksheetGrid
.
CellFontColor
[
gridCol
,
gridRow
]
:
=
clSilver
;
Could you condense the issue into a simple compilable project so that I can have a look?
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
Slow Canvas.TextRect (TsWorksheetGrid)
TinyPortal
© 2005-2018