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
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
generic Class for any Typ...
by
paule32
[
Today
at 02:22:21 pm]
LazProjectGroups: key map...
by
CCRDude
[
Today
at 02:10:05 pm]
Loadfromstream return som...
by
marcov
[
Today
at 02:02:48 pm]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 01:47:23 pm]
"Mario & Luigi" (1994-200...
by
paule32
[
Today
at 01:09:14 pm]
Compare two text lines an...
by
dbannon
[
Today
at 12:29:47 pm]
Setting up an ARM embedde...
by
Ruptor
[
Today
at 12:14:28 pm]
Fpcupdeluxe
by
heejit
[
Today
at 11:51:44 am]
LMath and Components 0.6....
by
wp
[
Today
at 11:40:02 am]
[S]Call anchor editor for...
by
Martin_fr
[
Today
at 11:32:30 am]
Bug if FileListBox.Sorted...
by
hannaconner
[
Today
at 11:19:17 am]
how to create different c...
by
paule32
[
Today
at 10:49:43 am]
new private messages fly ...
by
Nitorami
[
Today
at 10:14:05 am]
[SOLVED] SQLite query to ...
by
Zvoni
[
Today
at 09:30:48 am]
Sharing utilities
by
lucabertoncini
[
Today
at 09:01:00 am]
Triple Gosper Space Filli...
by
Thaddy
[
Today
at 07:17:33 am]
Program vs Simple Program...
by
ASBzone
[
Today
at 06:43:56 am]
Is Lazarus still serious ...
by
dbannon
[
Today
at 06:09:15 am]
replace the Executable St...
by
paule32
[
Today
at 04:25:38 am]
outsource RTTI
by
paule32
[
Today
at 04:22:43 am]
Lazarus Tool for creating...
by
JuhaManninen
[
Today
at 12:39:37 am]
How to control subform: S...
by
madref
[July 13, 2025, 11:35:23 pm]
Building warnings ?
by
madref
[July 13, 2025, 11:26:32 pm]
Need help testing demonst...
by
Gustavo 'Gus' Carreno
[July 13, 2025, 10:41:44 pm]
trunc builtin function is...
by
jamie
[July 13, 2025, 10:01:41 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Slow Canvas.TextRect (TsWorksheetGrid) (Read 3734 times)
xinyiman
Hero Member
Posts: 2258
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: 4443
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: 2258
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: 2258
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: 12910
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