Codename one label text wraping - layout

Is there a way how to wrap text in Label into multiple rows (using with BoxLayout Y container)? Always, i get the text overflow hidden. Especially long text that should split into two or more lines.
I get it working with TextArea component and with TextArea.row set to 2 or more. But the width is a little bit tricky.
How can I set Label or TextArea width or height?

The label is always a single line label the solution based on text area should work just fine if it doesn't I suggest making sure that you added everything on the EDT (you can activate EDT violation detection in the simulator menu) and if you added the component after the form is shown you should use revalidate(). There is no need to define the row count.
Just for completeness here is how this would work:
TextArea lbl = new TextArea("My very long string that should break lines because its really really really really long and just won't end");
lbl.setEditable(false);
lbl.setFocusable(false);
lbl.setUIID("Label");

Related

How to make a vertical slider?

I need a vertical slider similar the standard slider. Is there a way to modify the existing one or do I need to make a new one?
The standard slider would work for me. I just need it to work vertically.
Perhaps I should better clarify my issue with the standard slider.
Yes, I can drag the size of the slider and it will be vertical. The problem is that when you select the value of the slider to show the text gets buried in the low side of the slider when you slide it down all the way. It essentially gets cut off and only shows the top half of the slider value character. I find no way to correct this by moving the shown text up a little so it all shows. I see no way to change text vertical or offset position in the properties setting.
The text settings only allow you to change the text format to right, center and left justify. There is no setting that can move the text up to prevent it from being cut off when the slider is all the way to the lower or down position.
The value text shows ok on the top of the slider. The problem is on the bottom side when you set the slider to be vertical.
It looks like the the show value setting does not place the value on the top layer of the slider and it gets hidden behind something else in the slider object.
LC9, Windows 10
I think I'm understanding your question. If you just resize the horizontal slider control so that the width is narrower than the height, the orientation of the slider control will automatically change to vertical.
Apparently it is a bug in this version of LC. At least in Win which is where I am testing.
Putting the scrollbar vertically cuts the value when it reaches the bottom.
But I found a solution so that it does not cut. Play around with the properties of the font. Such as size and family. In my case it worked fine by lowering the font size by one pixel.
Default: Segoe UI font, size 12
I just set the size to 11 and it doesn't cut anymore.
For what it is worth, I do not see this issue on a Mac. A vertical slider works as advertised. Font size makes no difference.
Are you saying that in the horizontal mode, you do not see this, but when changed to vertical, you do?
Try creating a scrollbar and a text field.
Set the scrollbar's showValue property to false and copy the following script to your scrollbar. Note that your field must be called "scroll value".
on scrollbarDrag pNewPosition
local tLoc
lock screen
# The Current Loc of Field
put the loc of field "scroll value" into tLoc
# New Position of scrollbar
put pNewPosition into field "scroll value"
# New Loc of Field
put the mouseV into the item 2 of tLoc
set the loc of field "scroll value" to tLoc
set the left of field "scroll value" to the right of me
unlock screen
end scrollbarDrag

How can I automatically re-size Draw.io's UML “Class” shape after adding new lines representing extra fields or methods?

It is tedious to extend the height and width of the class shape areas after added new fields or methods to the class representation.
Googling suggests ctrl-shft-y, / Arrange -> Autosize, but this does not appear to work as expected for "Class" shapes. (It works fine on a regular rectangle).
Has anyone found a good way to add extra fields without manual overhead?
Draw IO's class shape with new line not fitting once added
When text is written only in one line,
(when a new row is added)
try to select only that row (not the whole UML shape)
and go to Arrange > Autosize or press Ctrl+Shift+y
​
It should work well.
When the new row is added,
but the text is written in 2 or more lines,
please tick a "Formatted text" in Text tab (Format panel)
and then go to Arrange > Autosize or press Ctrl+Shift+y
It should increase the hight of the row.
If you have a problem with this,
please vote for a Trello feature card I opened here:
https://trello.com/c/NSIxt85Y/424-support-autosize-for-uml-when-new-row-is-added-with-multi-line-text-change-height-correctly
cause there is a possibility that this feature should be improved.
I didn't understand list shapes in Draw.io.
It's explained here https://desk.draw.io/support/solutions/articles/16000054082-adding-entries-in-uml-diagrams
Ctrl-Enter to 'add a new line' (clone a shape in the list) and enter to edit/rename that shape.

TableWrapData: widgets won't left align properly

My program uses TableWrapLayout with numColumns set to 2. I then have the following code: (background colors are set to show you that the widgets aren't using the blank space).
Label label = toolkit.createLabel(container, "Resource Type":);
label.setLayoutData(new TableWrapData(TableWrapData.LEFT,TableWrapData.MIDDLE));
label.setBackground(DiagramSettings.NODE_BACKGROUND_COLOR);
resourceComboMenu = new Combo(container, SWT.READ_ONLY);
resourceComboMenu.setBackground(DiagramSettings.NODE_BACKGROUND_COLOR);
resourceComboMenu.setLayoutData(new TableWrapData(TableWrapData.LEFT,TableWrapData.MIDDLE));
However as you can see in the picture the combo box refuses to left align properly. But that I mean I want it to start right after the label, not have a bunch of blank space.
One workaround would be to put the row inside it's own Composite just like I do Resource Icon and Geolocation. But I feel like I shouldn't need to since the widgets on this row equals the number of columns set by the layout. I've created this workaround for now but would like to understand this TableWrapData behavior for the future.
Any insight would be helpful, thanks.
I pretty much answered my question in the question. The composite that contains everything in the picture had TableWrapData with columns set to 2. TableWrapData essentially draws a straight, vertical line between each column then makes sure widgets from one column don't cross it.
So to fix this (like I mentioned in my question) you simply make another composite with nested widgets (which in the case would be the resource type label and resourceComboMenu). I just didn't realize that is what you're supposed to do.

How to animate TextView

I have a custom class extending TextView (I used this trick to set my custom font).
I've a ListView and its elements are represented with my custom TextView.
Sometimes happens that the text is too long to fit and it starts a new line. I want to avoid this, so i set android:singleLine=true in the XML of my element layout.
I want to know if it's possible to animate the TextView of an element of the list, so that if such element is selected, it first scrolls its text to the left, till it reaches the end of the text, then scroll back to the right till the beginning.
I tried with marquee but it looks like it can only move in one direction and it's not what i want.

Why is Autofit Labeling greyed out?

I Have created a bar chart in a 2007 .xls file, but the data labels cannot be resized. When you go to the "format Data Labels" and then click on alignment, the Autofit and Internal Margin option is grayed out. Anyone know why?
Short version: It is greyed out for chart text, because it the option doesn’t apply.
Long version:
This is because on a chart, chart text do need to use margins, rather you can you can just move the text., and set its X and Y position. For example take the Chart Title, if you want more space to the left, just click and drag the title to the right. If you want the chart title to be bigger you just set a larger font, you have complete control over the title, as well as all other text on that chart, axis titles, legends, data labels, etc.
Internal margins are meant to be used when you don’t have complete control take for example text in a shape. If you insert a shape in your workbook, and add text to it, you cannot just pick the text up and move it to the right if you want more space on the left, so you can set the margin.
Here's a trick that worked for me:
My problem was: I added more text to the axis title and it was too long for it's original shape so some text went into second line.
My solution: I type the complete text somewhere else, copy the text, double click on the axis title and delete the original text -- the cursor would still be there -- now insert the copied text. Done! They are all in one line!
Partial solution to resize label to a single line: Data labels in a chart will often wrap themselves, when you dont want them to. They would often seem better in a vertical single line above the graph item. Reset them to one single line by editing the text in the label, deleting the Excel imposed return, and replace it with a space. The line, and label box, will resize to fit a single line. However because you have "manually interfered with the lable, it will no longer update for changing graph data. You would have to double click each lable then reset it. Most annoying.
A way around it is to make the chart area big. The data label boxes will resize to fit the words in one line. Then make the chart small (not the chart area).
Manually insert a textbox into the bar chart and type in the label that way. It's annoying and labor-intensive, but it works.

Resources