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
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Problema ao Instalar BGRA...
by
Fred vS
[May 18, 2025, 11:46:48 pm]
crtbeginS.o and crtendS.o...
by
Aruna
[May 18, 2025, 11:38:30 pm]
BGRA Controls
by
Fred vS
[May 18, 2025, 11:33:52 pm]
External ACCESS VIOLATION...
by
alpine
[May 18, 2025, 11:30:10 pm]
Compiler raised internal ...
by
Fibonacci
[May 18, 2025, 10:53:17 pm]
Icon file was loaded on m...
by
n7800
[May 18, 2025, 10:26:06 pm]
PascalScada installing
by
jamie
[May 18, 2025, 10:24:44 pm]
Build mode Help button do...
by
440bx
[May 18, 2025, 10:20:17 pm]
Negative offset
by
ASerge
[May 18, 2025, 10:16:37 pm]
Feature request/suggestio...
by
440bx
[May 18, 2025, 10:15:56 pm]
64 bits and PascalScript
by
jamie
[May 18, 2025, 10:10:03 pm]
A little bug in fpsimages...
by
Roni Wolf
[May 18, 2025, 09:38:07 pm]
Please post your ptop con...
by
Crispy Lettuce
[May 18, 2025, 08:29:57 pm]
BGRAGtkBitmap
by
CM630
[May 18, 2025, 08:04:12 pm]
FPC for high-performance ...
by
Fibonacci
[May 18, 2025, 07:55:58 pm]
New version of BGRABitmap
by
circular
[May 18, 2025, 06:28:42 pm]
FPC 3.2.2 - compilerproc ...
by
Thaddy
[May 18, 2025, 05:48:02 pm]
LazUpdateManager – Lazaru...
by
babycode
[May 18, 2025, 04:38:06 pm]
WPARAM definition
by
Thaddy
[May 18, 2025, 04:16:52 pm]
FPC 3.2.2 - Align for Ans...
by
marcov
[May 18, 2025, 03:36:05 pm]
Little Red Riding Hood (t...
by
Lulu
[May 18, 2025, 03:00:19 pm]
Hnefatafl Viking-Chess(ra...
by
Jonax
[May 18, 2025, 11:50:30 am]
[SOLVED] How to "Jump To"...
by
cdbc
[May 18, 2025, 10:13:16 am]
Free Pascal for Windows o...
by
TRon
[May 18, 2025, 02:21:41 am]
Database Locked Exception
by
cdbc
[May 18, 2025, 12:58:51 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Slow Canvas.TextRect (TsWorksheetGrid) (Read 3689 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: 4417
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: 12799
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