Box keeps resizing Interface Builder - xcode

Still a n00b (sorry) and I wondered if there is a solution this rather simple quandry which I cannot find an answer for (probably because it is so simple).
Basically I have a label which is inside a custom box. When I change the box size and then hit run the box size changes back to another random annoying size. It sounds simple enough but can I change it so that it sticks to the definitions I set. I have a series of labels and it would be great if the layout were the same. Thanks.

Turn off 'Live Autoresizing' in the menu.

Related

UIImageView Fit Entire Screen

Note: I looked at the other questions similar to this one, and they were either outdated or not useful.
Unfortunately there are so many different screen sizes and that makes auto layout really confusing for me. I want to have a simple UIImageView to cover the entire screen no matter what screen size it is. So the dimensions of the UIImageView should change accordingly.
I tried adding constraints to squish the image and it worked fine. But an error in the debugger said that there was an error: UIViewAlertForUnsatisfiableConstraints
Is this a big deal? And if it is, how do I get the Image to fill the entire screen?
Edit: The game will have squares going down the screen, which the user must tap
It might be, or it might not be a big deal, depending on what you're doing and if you know what you're trying to accomplish. In my experience, this is usually an issue if you're trying to programmatically alter the frame of a view which already has set constraints (you shouldn't alter the frame by hand unless you really need it).
Without more detail, it's hard to say what the exact issue is.

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).
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.
The uicontrol Position property gives you the height and width of the bounding rectangle for the control. This has always worked for me. Is there a control where this property does not provide enough information?
If the GUI you're building can be assembled exclusively from Java components, you can use MATLAB's Java integration to create and drive a window using Java Swing components (all from M-code). That sidesteps the problem entirely, since the Java layout managers can do UI layout properly.

How to easily crop the same image multiple times

I have a set of really big images out of which I need to crop little snippets. These snippets are all exactly the same size but don't follow a strict pattern so I can't do this programatically.
Ideally I would like to open up one of the big files and be able to point and click on say, the top left corner of a snippet and have that automatically be saved to disk without even having to enter a file name, and then continue on with the rest. (Of course this would be the ideal way which I know is probably way off the real possible way!).
I started doing this in Photoshop CS4 but cropping a snippet, saving, undoing (to get to the full image), and starting over again takes way too long.
Maybe someone has a better way to do this in photoshop or in some other software.
Thanks for reading!
Instead of cropping and undoing, you could:
make (or resize) a selection
copy the selection to a new image
save the image
close the image
You might need to split it into two actions, I don't know enough about programming Photoshop.
Thank you everyone for your input.
I ended up doing this with a suggestion a colleague of mine came up with. It consisted of creating a Photoshop "slice" over the first region I wanted to crop and then cloning that region over the rest of the other sections. After that, using Save For Web (and ofter hitting Continue when PS complained about how that image was way beyond Save For Web's capabilities) I could save all images at once.
This was the fastest and easiest method I could find. Until then I was going with Mark Ransom's method.

How can I add a MyDrawPanel to a program while adding other objects as well?

I am attempting to make a simple game, and I have loaded an image onto a myDrawPanel, which is on the JFrame, successfully. However, I also want to add other things to my GUI, such as buttons, etc. I cannot do this, however, because when I add the myDrawPanel to a JPanel, all I get is a small square in the top center of the window. This is proving to be greatly limiting, and I was wondering if there is an alternative "JObject" that I can add the myDrawPanel to in order to allow for the customization of my GUI. Thanks in advance, and Merry Christmas!
A JPanel (or sub-class) generally obtains its size from the components it contains. If no components are in it, it will be small.
One way to fix that is to call setPreferredSize(Dimension) on the customized panel.
p1.setPreferredSize(new Dimention(1100,800));

Get the word under the mouse cursor in Windows

Greetings everyone,
A friend and I are discussing the possibility of a new project: A translation program that will pop up a translation whenever you hover over any word in any control, even static, non-editable ones. I know there are many browser plugins to do this sort of thing on webpages; we're thinking about how we would do it system-wide (on Windows).
Of course, the key difficulty is figuring out the word the user is hovering over. I'm aware of MSAA and Automation, but as far as I can tell, those things only allow you to get the entire contents of a control, not the specific word the mouse is over.
I stumbled upon this (proprietary) application that does pretty much exactly what we want to do: http://www.gettranslateit.com/
Somehow they are able to get the exact word the user is hovering over in almost any application (It seems to have trouble in a few apps, notably Windows Explorer). It even grabs text out of obviously custom-drawn controls, somehow. At first I thought it must be using OCR. But even when I shrink the font so far down that the text becomes a completely unreadable blob, it can still recognize words perfectly. (And yet, it doesn't recognize anything if I change the font to Wingdings. But maybe that's by design?)
Any ideas as to how it's achieving this seemingly impossible task?
EDIT: It doesn't work with Wingdings, but it does work with some other nonsense fonts, so I've confirmed it can't be OCR.
You could capture the GDI calls that output text to the display, and then figure out which word's bounding box the cursor falls in.
Well, for GDI controls you can get the position and size of the control, and you can usually get the font info. For example, with static text controls you'd use WM_GETFONT. Then once you have that you can get the position of the mouse relative to the position of the control and use one of the font functions, perhaps something like GetTextExtentPoint32 to figure out what is under the cursor. I'm pretty sure the answer lies in that direction...
You can run dumpbin /imports on the other application and see what APIs they are calling.

Resources