Page 1 of 2

Textsize

Posted: Mon Mar 04, 2013 1:17 am
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 ...

Re: Textsize

Posted: Mon Mar 04, 2013 1:59 am
by Tom
Try

Code: Select all

DC_GraQueryTextBox(cText,cFont)

Re: Textsize

Posted: Mon Mar 04, 2013 3:40 am
by c-tec
Hello Tom,
thank you, exact what I was looking for.
regards
Rudolf

Re: Textsize

Posted: Mon Mar 04, 2013 5:39 am
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

Re: Textsize

Posted: Mon Mar 04, 2013 5:53 am
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.

Re: Textsize

Posted: Mon Mar 04, 2013 6:58 am
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

Re: Textsize

Posted: Mon Mar 04, 2013 9:47 am
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.

Re: Textsize

Posted: Mon Mar 04, 2013 10:34 am
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

Re: Textsize

Posted: Tue Mar 05, 2013 2:56 am
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

Re: Textsize

Posted: Tue Mar 05, 2013 7:25 am
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.