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
splitting an image
by
madref
[
Today
at 04:39:31 pm]
Drawing grid lines on a t...
by
KodeZwerg
[
Today
at 04:30:06 pm]
Lazarus features in a non...
by
Laksen
[
Today
at 03:46:15 pm]
Parameter passing odditie...
by
KodeZwerg
[
Today
at 03:41:49 pm]
How to: create DLL file f...
by
KodeZwerg
[
Today
at 03:24:20 pm]
Web Applications with Pas...
by
Nate897
[
Today
at 03:17:43 pm]
Surf Units in Text Mode I...
by
mosquito
[
Today
at 01:58:21 pm]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[
Today
at 01:55:52 pm]
Generics - correct syntax
by
Thaddy
[
Today
at 01:48:32 pm]
FpDebug questions
by
440bx
[
Today
at 01:22:53 pm]
leetcode doesn’t support ...
by
codeninja
[
Today
at 01:16:43 pm]
Can function be used for ...
by
Joanna
[
Today
at 12:48:19 pm]
Access violation when ope...
by
Чебурашка
[
Today
at 12:14:30 pm]
Access violation when re-...
by
Chris Osborne
[
Today
at 11:43:49 am]
how to tweek fpmake to co...
by
marcov
[
Today
at 10:35:11 am]
Why isn't TTIRadioGroup's...
by
egsuh
[
Today
at 08:09:35 am]
Lazarus for Windows on aa...
by
Wallaby
[April 23, 2024, 11:46:56 pm]
(Solved) TIndexedAVLTree ...
by
lainz
[April 23, 2024, 10:49:03 pm]
Demo Scene Picture sinwav...
by
KodeZwerg
[April 23, 2024, 10:26:21 pm]
fkInternalCalc
by
zraja
[April 23, 2024, 09:31:07 pm]
A fairly simple sound sol...
by
KodeZwerg
[April 23, 2024, 09:23:37 pm]
add new targets to make
by
marcov
[April 23, 2024, 08:38:42 pm]
Quirky windows
by
ASerge
[April 23, 2024, 07:07:16 pm]
[Request] Demo Scene Sub ...
by
Gigatron
[April 23, 2024, 06:29:39 pm]
Unlocking Files
by
KodeZwerg
[April 23, 2024, 06:03:08 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Slow Canvas.TextRect (TsWorksheetGrid) (Read 3487 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: 4221
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: 11923
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