Matlab - change height of the text field on the whole figure - matlab

Is there a way to change the height of a text field on the whole figure without changing the x and y position?
To change we must use the position, which requires to change the coordinates. I would like to change only the height, without changing x and y.

Just store the current x and y, and use those in your set call like so:
old_pos = get(text_field_handle,'Position');
set(text_field_handle,'Position',[old_pos(1:2),new_width,new_height]);

Well, you can change the FontSize property, this won't change the coordinates, but will increase width as well as height. See Text Properties in the doc for more details.

I am assuming you are working with uicontrol('style','text').
From the uicontrol properties you have:
Position
position rectangle
*Size and location of uicontrol*. The rectangle defined by this property
specifies the size and location of the control within the parent figure
window, uipanel, or uibuttongroup. Specify Position as:
[left bottom width height]
where left and bottom define the distance from the lower-left corner of the
container to the lower-left corner of the rectangle. width and height are the
dimensions of the uicontrol rectangle.
You can then just change the width and height keeping the original left and bottom.

One can set the Margin property of a text object to increase the height of the object without changing the fontsize, but this influences both the height and the width of the text object. I am not sure what it means to make the height smaller than what Matlab thinks is the text height, so I will assume you are interested in increasing the size.
Increasing the height of the text object is relatively easy if you are willing to use the LaTeX interpreter. You just need to add an "empty" box of whatever height you want:
text(0.5, 0.25, 'Hello World\parbox{\textwidth}{\vspace{1in}}', 'Interpreter', 'LaTeX', 'BackgroundColor',[1, 0, 0]);
This won't increase the height by exactly 1 inch, instead it will be more like 1 inch minus a baseline skip. Determining the actual height increase in displayed units adds even more problems. You might be able to change the height with unicode characters, and hence skip the LaTeX interpreter, but I have no idea how.

Related

How to Calculate the Height and Width of Forms in Powerhsell?

Can someone help me in understanding how to calculate the Height and Width of a Powershell Forms. For Example I Created a blank Powershell form of Height 500 and Width 700 and now If want to place a Text box a little below from the top of the form what will be the height and width that I need to enter? and If I want to place a Button at middle of the Form? what will be the height and width that I need to enter? I am struggling with this calculation.
You should get the screen size and use the ratio to set position. The ratio is useful for different screen size.

How do I copy text inside of the tooltip that appears when hovering over elements?

I'm trying to set min and max dimensions for some elements on a webpage and for elements near the end of the screen, the tooltip is cut off. Usually I would just look at the computed height and width and guess what it could be rounded to, but the width and height are set to auto.
I can't change the size of the viewport, since the size of most of my elements is dependent on viewport width.
I could try to copy the text inside of the tooltip, but I don't know how to get it to stay frozen in place so that I can select the text.
I saw some answers saying to hold F8, but that only works if you have a tooltip applied to the element you're hovering over, it doesn't freeze the inspect tooltip.
An example of what I'm trying to describe.
Source: https://developer.chrome.com/blog/new-in-devtools-75/#A%20detailed%20tooltip.

How do I set a maximum text width for a GtkTextView?

I have a GtkTextView, and I would like to be able to set a maximum line width for the text. If the width of the TextView exceeds the maximum text width, the extra space should be filled with padding on the left and right on the text. Although Gtk supports a min-width CSS property, there appears to be no max-width property. Instead I tried to dynamically set the margins whenever the TextView is resized by connecting size-allocate to
def on_textview_size_allocate(textview, allocation):
width = allocation.width
if width > max_width:
textview.set_left_margin((width - max_width) / 2)
textview.set_right_margin((width - max_width) / 2)
else:
textview.set_left_margin(0)
textview.set_right_margin(0)
This produces the desired text line width for any given TextView width, but leads to strange behavior when resizing the window. Resizing the window to a smaller width happens with a slow delay. Attempting to maximize the window makes the window jump to a width much larger than the screen. size-allocate may not be the correct signal to connect to, but I have not been able to find any other way to dynamically set margins when the TextView is resized.
What is the correct way to achieve a maximum text line width?
I came up with a solution. I created a custom container by inheriting from GtkBin, overrode do_size_allocate, and added my GtkTextView to that container:
class MyContainer(Gtk.Bin):
max_width = 500
def do_size_allocate(self, allocation):
# if container width exceeds max width
if allocation.width > self.max_width:
# calculate extra space
extra_space = allocation.width - self.max_width
# subtract extra space from allocation width
allocation.width -= extra_space
# move allocation to the right so that it is centered
allocation.x += extra_space / 2
# run GtkBin's normal do_size_allocate
Gtk.Bin.do_size_allocate(self, allocation)

GWT - how to precisely set rendered width of TextArea in pixels?

I need to render a TextArea in an exact pixel width for the special purposes of my GUI.
When I set its width to "250px", it comes out as 256px.
Is there a way to override this behavior so I can render it as 250px exactly?
When you use setWidth(), you're effectively setting the element's content width.
To get the offset width use UIObject#getOffsetWidth(). This will return the width including padding and border (but not margins).
References on W3C
Computing widths and margins
The box model

GWT widget on bottom without knowing height/size

I want to have a two widgets to stack up
X
Y
I want Y to take up as much height as it needs (its static in size, roughly 50px depending on browser font, etc) and remain affixed to the bottom of the screen, and X to take the rest of the vertical space.
X happens to be a scrollpanel with VerticalPanel and more inside, Y is a Grid and I've tried putting them in various containers, but they all seem to want a size for Y (ie. DockLayoutPanel & LayoutPanel). If I specify a size for Y it ends up with white space at the bottom on one browser or another. Any advice?
It's just not possible in HTML/CSS. If you absolutely cannot know the height of Y in advance, the way around it would be to:
Attach this widget somewhere off-screen
Measure it's height using yWidget.getOffsetHeight()
Remove it
Add it to your LayoutPanel and setting the 'bottom' coordinate to 0 and 'height' to the measured height.