Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate actual size needed for a MATLAB uicontrol

I'm trying to calculate the actual size needed for uicontrols in a GUI so the GUI can resize itself appropriately. My problem is that the Extent property of a uicontrol is only the text area, and I can't find a way to determine the size of the surrounding control (such as the down arrow in a popup or the margin of an edit control). Is there a way to get the size of the decorations on a control?

I saw this related question on MATLAB Answers, which looked like it ended with no solution as well.

Edit:

For example, I want to calculate how big this popup should be to avoid cutting off the contents:

uicontrol('style', 'popup', 'string', {'a long string'})

Extent only tells me how big "a long string" is, and I still don't know how big to make the popup. I want a way to determine how much extra space is needed on the user's display (without assuming which OS or font sizes they use).

like image 801
Arthur Ward Avatar asked Nov 13 '22 21:11

Arthur Ward


1 Answers

You can use get(hObject,'extent') to find out how much space the string contained in the uicontrol takes up. You can see if this is larger than the uicontrol's position.

like image 102
Katie Avatar answered Dec 21 '22 23:12

Katie