Centering Text Vertically Within Same Text Field 
Author Message
 Centering Text Vertically Within Same Text Field

I am trying to center text in a text string on a report vertically
inside of the background for the text.  I know how to center the text
horizontally within the brackground and I know how to position the
string on the page, but I do not know how to center text vertically
within the background of the same text object.  Any ideas would be
appreciated.

Robert Keathley



Fri, 02 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Robert,
    Well, unlike the horizontal centering control for the report, there
is no vertical centering control, so, it's up to you. You can do this
manually, or write some code to do it.
    Manual: Get the report properties "position" values (assuming you
want it centered on the printable part of the page - otherwise get the
detail band or whatever controls define your "outer limit" of position).
Use the height to determine "center." Note, if you have other controls on
the page, you might want to take that into account (remember, controls
are all listed with positions relative to the detail band X/Y corner, not
the edge of the page or even the report properties.). Also, remember that
controls are positioned by the upper left corner position, so you have to
account for the control height to get center.
    Automatic: Once you figure out how to do the above, you might play
with the PROP: function, get the information you need and "adjust" the
position of the control you want to move. I have done this with screen
stuff, but not with the report. The only advice I can give you is to
remember that the report will never be the default target unless you tell
it to be. So you have to use the SETTARGET command or prefix everything
with the "Report$" (where "Report" is the name of your report, usually,
but not always the case) designator. I.e.,
"Report$?ThisControl{prop:Ypos} = Report$0{prop:Height}/2". Note: I don't
know if Report$0 will give you what you're looking for. On a screen,
control 0 is always the screen itself. Another note: when you fool around
with the Prop: stuff, there are very few warnings or error messages. For
the most part the compiler and the application are "fat, dumb and happy"
about almost anything you put in there, so don't think that because you
haven't received any errors, it's got to be right.
    Anyway, I hope this helps.

    Regards,

    kurtt

Quote:

> I am trying to center text in a text string on a report vertically
> inside of the background for the text.  I know how to center the text
> horizontally within the brackground and I know how to position the
> string on the page, but I do not know how to center text vertically
> within the background of the same text object.  Any ideas would be
> appreciated.

> Robert Keathley



Fri, 02 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Sounds like you will want to use the property syntax to set the position of
the string within the report.  You can embed code like:

TotalHeight = 9000                ! 9000 Dialog Units high
StringLength = 4 * LEN(CLIP((MYFILE:MyField))    ! Assume 4 dialog units per
character
MYFILE:Myfield{PROP:Xpos} = (TotalHeight / 2) - StringLength

You will need to calculate the number of dialog units and assign to
TotalHeight, and the StringLength should be set to the number of dialog
units for the string.  You will need to experiment a bit with the
multipliers to determine how many dialog units represent each character
based upon which font and point size you are using.  Trial and error are
probably the easiest way.  Keep playing with the numbers until it is
centered up.

--
Best Regards,
Jerry P. Ray - Hard at Work
Computer Discount Center
Home of the Computer Doctors

Quote:

>I am trying to center text in a text string on a report vertically
>inside of the background for the text.  I know how to center the text
>horizontally within the brackground and I know how to position the
>string on the page, but I do not know how to center text vertically
>within the background of the same text object.  Any ideas would be
>appreciated.

>Robert Keathley



Sat, 03 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Hi Robert,


Quote:

>I am trying to center text in a text string on a report vertically
>inside of the background for the text.  I know how to center the text
>horizontally within the brackground and I know how to position the
>string on the page, but I do not know how to center text vertically
>within the background of the same text object.  Any ideas would be
>appreciated.

As far as I know this is not possible.  String controls are always top
aligned.  The only way to center a string on a background would be to
put a box control on the window/report and then center the string
within the box and use the transparent attribute for the string.
Something like:

 ?MyString{Prop:Xpos} = ?MyBox{Prop:Xpos} + |
                       (?MyBox{Prop:Width} - ?MyString{Prop:Width}) / 2
 ?MyString{Prop:Ypos} = ?MyBox{Prop:Ypos} + |
                       (?MyBox{Prop:Height} - ?MyString{Prop:Height}) / 2

Best regards,

Arnor Baldvinsson
Allerup Edb
Tel: +45 4675 7122
Fax: +45 4675 7144
Denmark


http://www.icetips.com
UIN nr.: 2428601



Sat, 03 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Hi Robert,

On Tue, 16 Dec 1997 12:31:44 -0500, "Computer Discount Center"

Quote:

>TotalHeight = 9000                ! 9000 Dialog Units high
>StringLength = 4 * LEN(CLIP((MYFILE:MyField))    ! Assume 4 dialog units per
>character
>MYFILE:Myfield{PROP:Xpos} = (TotalHeight / 2) - StringLength

>You will need to calculate the number of dialog units and assign to
>TotalHeight, and the StringLength should be set to the number of dialog
>units for the string.  You will need to experiment a bit with the
>multipliers to determine how many dialog units represent each character
>based upon which font and point size you are using.  Trial and error are
>probably the easiest way.  Keep playing with the numbers until it is
>centered up.

Using the length of the string in characters is going to get you into
trouble very soon<g>  Use ?MyString{Prop:Width}  You can never
determine the size correctly by using the string and try to convert it
to dialog units (or any other units) without api calls.  BTW:  A 9000
du high report based on Arial 10pt, would extend a few meters;)

I have just posted a small code sample on how to center a string
within a box and it could just as well be applied to a report detail
or whatever.

Best regards,

Arnor Baldvinsson
Allerup Edb
Tel: +45 4675 7122
Fax: +45 4675 7144
Denmark


http://www.icetips.com
UIN nr.: 2428601



Sat, 03 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Thanks for the help guys.  Again your answers have given me severial
good ideas.

Robert Keathley


Quote:

>I am trying to center text in a text string on a report vertically
>inside of the background for the text.  I know how to center the text
>horizontally within the brackground and I know how to position the
>string on the page, but I do not know how to center text vertically
>within the background of the same text object.  Any ideas would be
>appreciated.

>Robert Keathley



Sat, 03 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Arnor,
    Wouldn't centering horizontally be simpler? Just make the text box large
enough so you know it will always contain the string, mark it as centered text
and then center the box on the form? Did I miss something?

    Regards,

    kurtt

Quote:

> Using the length of the string in characters is going to get you into
> trouble very soon<g>  Use ?MyString{Prop:Width}  You can never
> determine the size correctly by using the string and try to convert it
> to dialog units (or any other units) without api calls.  BTW:  A 9000
> du high report based on Arial 10pt, would extend a few meters;)



Sat, 03 Jun 2000 03:00:00 GMT  
 Centering Text Vertically Within Same Text Field

Hi Kurt,

On Tue, 16 Dec 1997 22:20:03 -0600, Kurt Pawlikowski

Quote:

>    Wouldn't centering horizontally be simpler? Just make the text box large
>enough so you know it will always contain the string, mark it as centered text
>and then center the box on the form? Did I miss something?

Horizontal centering is not a problem, vertical is.  The text in a
string control always follows the upper edge.  So if you want to have
a coloured background for a text and the text centered within the
background vertically as well as horizontally, the only way is to put
a coloured box or a region behind it and center the string on it.

Best regards,

Arnor Baldvinsson
Allerup Edb
Tel: +45 4675 7122
Fax: +45 4675 7144
Denmark


http://www.icetips.com
UIN nr.: 2428601



Sun, 04 Jun 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Center text in edit field

2. Hypertext links within text fields / memos

3. Find First/Next Occurrence within a text/memo field

4. Tk bug? Text within text

5. C4/Stretching text in a text field.

6. RTF-text format in text fields ?

7. Text widget, scroll vertically, expand horizontally

8. How to write text vertically?

9. How to display text vertically in canvas...

10. How to write text vertically?

11. Some questions on elided text in the text widget (and a few other text widget questions)

12. center caption text on a screen

 

 
Powered by phpBB® Forum Software