Textsize

This forum is for eXpress++ general support.
Message
Author
c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Textsize

#1 Post by c-tec »

Hello,
I need to postion says in front of gets. I only have the position of the get when creating it and must put a label on the left side. So I have to calculate the length of the text and subtract from the position of the get. How is the best way in in eXpress++ ?
regards
Rudolf

Code: Select all

cLabel := "Textfield"
@ 100,300 dcget cText getsize GETSIZE 80,15  PIXEL
nLen := textlen(cLabel) // ??? needed
@ 100,300-nLen-10 dcsay cLabel saysize 0
...
dcread gui ...
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
Tom
Posts: 1172
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Textsize

#2 Post by Tom »

Try

Code: Select all

DC_GraQueryTextBox(cText,cFont)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Textsize

#3 Post by c-tec »

Hello Tom,
thank you, exact what I was looking for.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Textsize

#4 Post by c-tec »

Hello,
it seems that this function expects a fixd size font. The difference is dependet on the length of the textstrings, longer strings result on higher difference in the calculated textlength.
I have tried to use
@ nTop,nLeft DCSAY cLabel saysize 100,20 SAYOPTIONS SAYRIGHT
but it seems that SAYOPTIONS is not accepted in a DCSAY.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
Tom
Posts: 1172
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Textsize

#5 Post by Tom »

Hi, Rudolf.

This:

Code: Select all

? DC_GraQueryTextbox('iiii','8.Tahoma')
results: {8,13}

And this:

Code: Select all

? DC_GraQueryTextbox('WWWW','8.Tahoma')
results: {40,13}

Try "SAYOPTIONS XBPALIGN_RIGHT" with DCSAY.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Textsize

#6 Post by c-tec »

Hello,
with this testprogram I get the attached result:

Code: Select all

#INCLUDE "dcdialog.CH"



function Main()
******************************************************************
local getlist := {},nLeft := 300,cFont := "8.Arial",x
local aLabel := {}
aadd(aLabel,{"abc"             ,,space(50)})
aadd(aLabel,{"abcdefg"         ,,space(50)})
aadd(aLabel,{"abcdefghijk"     ,,space(50)})
aadd(aLabel,{"abcasdfasdfasdf" ,,space(50)})
aadd(aLabel,{"HHHHHH"          ,,space(50)})
aadd(aLabel,{"IIIIII"          ,,space(50)})

for x := 1 to len(aLabel)
     aLabel[x,2] := dc_graquerytextbox(aLabel[x,1],cFont)
next x

@  20,nLeft dcget aLabel[1,3] size 100,18 PIXEL
@  20,nLeft - aLabel[1,2,1] - 19 dcsay aLabel[1,1] saysize aLabel[1,2,1]+30 PIXEL

@  40,nLeft dcget aLabel[2,3] size 00,18 PIXEL
@  40,nLeft - aLabel[2,2,1] - 19 dcsay aLabel[2,1] saysize aLabel[2,2,1]+30 PIXEL

@  60,nLeft dcget aLabel[3,3] size 00,18 PIXEL
@  60,nLeft - aLabel[3,2,1] - 19 dcsay aLabel[3,1] saysize aLabel[3,2,1]+30 PIXEL

@  80,nLeft dcget aLabel[4,3] size 00,18 PIXEL
@  80,nLeft - aLabel[4,2,1] - 19 dcsay aLabel[4,1] saysize aLabel[4,2,1]+30 PIXEL

@ 100,nLeft dcget aLabel[5,3] size 00,18 PIXEL
@ 100,nLeft - aLabel[5,2,1] - 19 dcsay aLabel[5,1] saysize aLabel[5,2,1]+30 PIXEL

@ 120,nLeft dcget aLabel[6,3] size 00,18 PIXEL
@ 120,nLeft - aLabel[6,2,1] - 19 dcsay aLabel[6,1] saysize aLabel[6,2,1]+30 PIXEL

DCREAD GUI TITLE "Test" FIT EVAL {|o|SetAppWindow(o)}
return .t.

PROC appsys
return
regards
Rudolf
Attachments
Zwischenablage01.jpg
Zwischenablage01.jpg (14.01 KiB) Viewed 11836 times
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
Tom
Posts: 1172
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Textsize

#7 Post by Tom »

Hi, Rudolf.

If you calculate the text size based on a special font, you need to use this font for displaying the text aswell. ;) Try this:

Code: Select all

function Main()
******************************************************************
local getlist := {},nLeft := 300,cFont := "8.Tahoma",x
local aLabel := {}
aadd(aLabel,{"abc"             ,,space(50)})
aadd(aLabel,{"abcdefg"         ,,space(50)})
aadd(aLabel,{"abcdefghijk"     ,,space(50)})
aadd(aLabel,{"abcasdfasdfasdf" ,,space(50)})
aadd(aLabel,{"HHHHHH"          ,,space(50)})
aadd(aLabel,{"IIIIII"          ,,space(50)})

for x := 1 to len(aLabel)
   aLabel[x,2] := dc_graquerytextbox(aLabel[x,1],cFont)
	 @  20*x,nLeft-aLabel[x,2,1] dcsay aLabel[x,1] PIXEL size aLabel[x,2,1]+5 font cFont
	 @  20*x,nLeft+30 dcget aLabel[x,3] size 00,18 PIXEL
next x

DCREAD GUI TITLE "Test" FIT EVAL {|o|SetAppWindow(o)}
return .t.
Attachments
fontsize.png
fontsize.png (24.45 KiB) Viewed 11824 times
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Textsize

#8 Post by rdonnay »

Here is a simpler way to do this:

Code: Select all

#INCLUDE "dcdialog.CH"

function Main()

LOCAL Getlist[0], GetOptions, cFont := "8.Arial",i, aLabel := {}, ;
      nMaxWidth := 0, nRow := 0

aadd(aLabel,{"abc"             ,100,space(50)})
aadd(aLabel,{"abcdefg"         ,  0,space(50)})
aadd(aLabel,{"abcdefghijk"     ,  0,space(50)})
aadd(aLabel,{"abcasdfasdfasdf" ,  0,space(50)})
aadd(aLabel,{"HHHHHH"          ,  0,space(50)})
aadd(aLabel,{"IIIIII"            ,0,space(50)})

FOR i := 1 TO Len(aLabel)
  nMaxWidth := Max(nMaxWidth,dc_graquerytextbox(aLabel[i,1],cFont)[1])
  @ nRow += 20, 0 DCSAY aLabel[i,1] GET aLabel[i,3] GETSIZE aLabel[i,2] PIXEL
NEXT

DCGETOPTIONS SAYWIDTH nMaxWidth SAYRIGHTBOTTOM

DCREAD GUI TITLE "Test" FIT SETAPPWINDOW OPTIONS GetOptions

return .t.

PROC appsys ; return
The eXpress train is coming - and it has more cars.

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Textsize

#9 Post by c-tec »

Hello Roger,
thank you, but the problem is that this are very complex dialogs. Each dialog can look different and they are are created from a definition in a XML file and must get optimised for different device, so it is rather complicated to get rid of all things. For exmple for tablet computers it has to look complete different then for standard desktops (and here with different screen size), also for example if it is opend from a RDP on a Android tablet. For now I add 10 points to the lextlenght and it works so fine so far.
Another littel problem is, that checkbox labels are always positioned about 7 pixels to high. Is this normal behaviour ?
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Textsize

#10 Post by rdonnay »

Good luck with this.

It sounds like you are trying to create a rendering engine that works similar to <div> tags and cascading style sheets in HTML. This can be a monumental task. I have written many data-driven apps in the past and I have learned that they become very difficult to maintain. I wrote eXpress++ as a middle-ground abstraction that gives you the power to create any kind of dialog you want. If your app must be data-driven, then you will lose a lot of design flexibility and will be spending all of your time creating the rendering engine instead of the application.
The eXpress train is coming - and it has more cars.

Post Reply