how to get the rendered width of internationalized button text in GWT? - gwt

While testing our app with a new set of translations, I found that the translated text for some of the buttons are significantly wider than the english. The result is that the button text wraps to a 2nd line, which is either cut off by the button, or floating below on a 2nd line. It seems like I need to get the rendered width of the text in order to dynamically resize the buttons, assuming there's space in the layout for a wider button.
Is there a way to get the width of the rendered text of a button?

Unless you are using a monospace font for the buttons (why not do so, actually?), and render it using CSS en / em / ex units, you cant really predict the text width, only make an educated guess.

Related

How to find count of rows from textArea which has a content in GWT

I have one TextArea in GWT, TextArea inside Scrollable panel is filled with content which comes from API. Sometime the content can be less or more. I want to make my Textarea to shirnk if content is less, so how do I count the total number of lines of text inside text area?
TextArea is with fixed height applied through CSS.
The number of lines will be different depending on the system font, font size selected by a user (it will override the font size you set in CSS), and the browser. Besides, you are talking about a TextArea, so a user can type or paste more text.
The standard design approach is to keep the TextArea size constant.
If you do want to adjust it, the solution is to create a hidden element. See the details:
http://blog.gaijindesign.com/jquery-scrolltop-to-a-hidden-element/

Textfield Spacing with "Stretch on Overflow" buggy?

I am currently designing a report using iReport 4.7.0. At the moment I am trying to figure out how to dynamically adjust the height of a textField, if its contents is too big for the initial height. It seems, that the option Stretch on overflow achieves this. But I am having problems with that.
If a textField is not stretched, the spacing before and after the text is good, because its achieved by setting the textField height higher than the font size. But if the textField gets dynamically bigger because the containing text is to long to display with the initial height, the lines seem awfully packed, there is no spacing whatsoever.
I tried so resolve this by setting Spacing before and Spacing after for the specific textField but this seems to end in JasperReports thinking, that the textField doesn't need to re-size at all, even if the text is not fitting.
Is it possible, that the size created by the Spacing before and Spacing after option is taken into account on calculating, if a textField needs to be resized on overflow? Or am I doing something wrong here?
Use padding:
Right-click an element
Select Padding and Borders
-or-
Right-click an element
Select Show Properties
Click the Borders tab
Set padding values as required
This should provide a constant spacing even if box resizes. For complex layouts, experiment with float position of elements, as described here.

SWT: widths of toolbar items

We are using toolbar items with text below. Especially for short texts, this looks quite odd, because the toolbar items are much narrower than high. Is there a way to tell SWT to increase the toolbar items widths, e.g., to a minimum size which is as wide as the buttons are high?
What do you mean text below? Is the text inside the items? Then they should behave in a .pack() manner. You can't really change the width of the items (only separators) but have you tried adding spaces or tabs to the text? And if there is an image you can just edit the images to be the width you want...

jQuery Mobile/ jqTouch Image width

I want to have a static footer image with 5 buttons for navigation in my mobile phone website. The image is here http://www.pintum.com.au/jm/footer3a.jpg. The blue icons should be the default, the yellow icon should only be visible for the hover or active state.
I want to know how can I make this image scale to the correct width on all mobile devices (landscape and portrait) and have links to other pages and make the current/active pages icon the yellow color?
What I have tried so far
I first tried to make a CSS Sprite but that go ugly (complex) quickly. Painful working with widths everywhere so the image scales correctly as I had no way of knowing the height in pixels since the width is dynamic. I could use JS to find the width and calculate height on the fly. But this sounds like overkill.
Next I tried to have a single image with a width of 100% then place div overlays on top of the image. But with this solution I could not figure out how to navigate pages using JavaScript click event, or figure out how I would be able to change the image icon on the selected page http://jsbin.com/uraya5/3/ . And detrmining the correct height for the div
Last I tried to make each button a seperate image. These seems like the easist soultion. But jQuery Mobile adds a bunch of extra styles to the button I do not know how to remove. See http://jsbin.com/uraya5/4
So whats the best/easiest way to do this?
How can I remove the style around
links?
Or can I use a single image CSS sliding door method? To reduce HTTP request.
Ok I figured it out
See soultion here http://jsbin.com/uraya5/10/
I had to:
Set width to 19% of each button for
some reason there is spacing between
each button so 20% does not work.
Set ui-bar-a background to black so
it hides the spaces between my
images
Use this JS code to navigate pages $.mobile.changePage($("#about"),
"flip", true, true);
I would still like to use a single image instead of having 5 different images to reduce http calls. So if anyone finds a eligant soultion for this please let me know.

How do I prevent a font from extending off the top of a textbox?

I'm using a barcode font (IDAutomationMC39H) in an SSRS 2005 report I'm developing, and while it renders fine in the preview in BIDS, if I export the results to PDF, print the results, or do any of the above (including preview) in Report Manager, the barcode font is extending off the top of the textbox. The barcode itself is nearly 20px tall, even at only a 12pt size. I've tried changing the CanGrow value for the textbox, but it seems that even with that set off the barcode isn't pushing the bottom edge of the textbox downwards, it's simply extending over the top of the box. I've also tried resizing the textbox to allow it to contain the entire height of the font, but even with the VerticalAlign set to Bottom the barcode still sticks to the top of the textbox and overflows out the top.
See screenshot here:
http://imgur.com/JDC4Z.png
Does anyone know how to force the font to be bound by the top of the box, instead of overlapping it?
I tried with no real success to get font-based barcoding to work. Ended up getting the boss to pay for NeoDynamic BarCode Professional which works great and has a lot more flexibility than fonts.