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
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Forum slow
by
Thaddy
[
Today
at 10:45:59 am]
Registers dialog - regist...
by
ccrause
[
Today
at 10:44:26 am]
HeapTrc not showing line ...
by
Martin_fr
[
Today
at 10:40:33 am]
Access violation when ope...
by
JuhaManninen
[
Today
at 10:29:38 am]
Step-into the field sette...
by
ginoo
[
Today
at 07:50:24 am]
Does anyone know why thes...
by
TYDQ
[
Today
at 05:24:32 am]
Arabic text, problem on L...
by
Zaher
[
Today
at 03:29:16 am]
InstallAware Using Lazaru...
by
TRon
[
Today
at 02:55:41 am]
Generics - correct syntax
by
Blaazen
[
Today
at 01:57:40 am]
Demoscene The Champs Crac...
by
Gigatron
[
Today
at 01:05:16 am]
How to use the Event Log?
by
n7800
[
Today
at 12:47:25 am]
v3.99 code completion que...
by
440bx
[
Today
at 12:45:55 am]
FpDebug breakpoint on "be...
by
440bx
[
Today
at 12:36:23 am]
Access violation when re-...
by
TRon
[April 19, 2024, 11:44:51 pm]
[solved] how to get class...
by
jamie
[April 19, 2024, 11:34:44 pm]
Lazarus for Windows on aa...
by
Wallaby
[April 19, 2024, 10:52:25 pm]
Poll: Watches and Display...
by
440bx
[April 19, 2024, 07:13:51 pm]
Who is Indy mattias?
by
paweld
[April 19, 2024, 04:17:53 pm]
I just released a commerc...
by
BrassGear
[April 19, 2024, 03:17:28 pm]
Database standards OR Am ...
by
gidesa
[April 19, 2024, 02:37:56 pm]
How to: create DLL file f...
by
TRon
[April 19, 2024, 02:26:53 pm]
A fairly simple sound sol...
by
paweld
[April 19, 2024, 01:46:11 pm]
AI, NLP and CAI: Text Gen...
by
Dzandaa
[April 19, 2024, 11:03:26 am]
dwindows for Android
by
PierceNg
[April 19, 2024, 10:54:44 am]
create system unit from s...
by
Laksen
[April 19, 2024, 10:53:57 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Slow Canvas.TextRect (TsWorksheetGrid) (Read 3482 times)
xinyiman
Hero Member
Posts: 2256
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: 4220
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: 2256
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: 2256
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: 11916
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