CF - Align text in a Label - compact-framework

Is there a way to align a text in a label to its absolute center (compact framework)?
Not a topCenter but a center of the label.
I want to avoid putting a label into a panel (container)...

The underlying OS (Windows CE) doesn't support vertical centering of statics, which is why it's not supported in the CF. You'll have to eitehr manually center the label or just use DrawText on the "parent" and draw in the text you want without any underlying Label control at all.

Related

Animate NSTextField Alignment

I'm trying to emulate the functionality of the Safari url text field (using NSTextField). I'd like the current text to be displayed centered, but when the user clicks on it the text should highlight and slide to the left. I've got the highlighting working but I'm not sure how to go about animating the text over to the left. Is it possible to animate the Alignment property or would I need to do some sort of custom drawing where I animate the position that the text is drawn?
Unfortunately this (Is there a way to animate changing a UILabel's textAlignment?) won't work, since a text field draws a background and border so animating the frame isn't an option.

OS X chat app with resizable bubbles

I'm building chat application for Mac OS, similar to iMessage. I wonder, how can I implement resizable text views in bubbles. I mean, when I resize chat window bubbles with text will resize to. Any ideas, links will be very useful. Thank you for help)
For text resizing, you use auto layout. If you have an NSScrollView containing MYBubbleViews containing NSTextViews, you can add NSLayoutConstraints using the leftAnchor and rightAnchor properties of the scroll view's content view and those of the bubble view, and add constraints between all edges of the text view and bubble view. Then pin the bubble views to the top/prev view.
Also make sure you set the NSTextView to wrap. The width of the intrinsic size of the text view will be set so that it fills the width and the intrinsic height will be set to fit the whole text.
I previously thought it was about drawing the bubbles, so I first gave this answer:
If you look at Messages.app, you'll see that they're not circular bubbles. They are basically composed of several shapes overlaid on each other. A rectangle with rounded corners, plus a bezier path of the tip.
So you should be able to take a NSTextView for the text, make it a subview of a custom view that draws a rounded rectangle and the tip in its drawRect method, and then use auto layout constraints to make your bubble view resize with the text view and the text view to the window width.
You could probably also have the bubble view host a CALayer with fill and rounded corners, plus one with an image for the tip (or aCAShapeLayer for the tip), but drawRect is the easier approach.

How to center objects in parent with Dock Fill VB.NET

I'm trying to make a RichTextBox have fixed size and blank space flexible (like Word, WordPad), I made this:
Set Dock to Fill
Set MaximumSize to 600,0 (0 is wildcard for sizes) (Width=600 and Height=0 -wildcard)
I got this: blank spaces are flexible and RichTextBox size is fixed, but RichTextBox is not positioned at center.
I have some options:
Set padding to auto (I suppose that it's not possible)
Set margin to auto (I suppose that it's not possible AND margins not works in winforms)
What do I have to do to position RichTextBox to center?
Use anchor instead of dock.
Dock is designed for Size, Anchor is designed for Location
Your problem is based on location, locate your box to center instead of make Dock margins.

Align label in Stetic GUI designer

I currently have the problem that my labels are centered in the parent VBox, which lies in a Fixed Container.
Change the Xalign for the label to be 0. By default it is 0.5 which will center the text. Setting this to 0 will tell Gtk to align the text to the left.
You can find this in the Miscellanous Alignment Properties in the Properties window.
The "Miscellaneous Alignment Properties" list in the designer properties control is where you specify vertical and horizontal justification.
Horizontal (XAlign):
0 is left-aligned
0.5 is centered
1 is right-aligned
Vertical (YAlign):
0 is aligned to the TOP
0.5 is centered
1 is aligned to the BOTTOM
On controls (such as the label) that provide a Justification property in the Stetic designer (which is used by Visual Studio for the Mac) the Justification property is ignored.

How to handle Segoe UI in pixel perfect layout (glyph "margin")

i am fighting with the layout of my windows store app. My problem is with the segoe ui font that I am using for the labels of some textboxes.
I have a borderless label above a textbox with a border like this:
LABEL
_____________
|__TEXTBOX___|
My problem is, that the font of the label does not align perfectly with the left border of the textbox.
First I though that it must be the label padding or something, maybe a padding or margin in the control template. But this is not the case. The true reason is the space around the glyphs within the font itself. Depending on the first letter or the size of the font the gap is bigger or smaller.
Is there a way to perfectly align the label text and the textbox independant of the first letter or the font size? Or do I really have to place every label in a different position to reduce this problem?