wxWidgets: wxButton with both bitmap and text - button

I want my wxButton to have a black background and white text for it's label. I tried this sample code only I also tried it with wxButton and SetBitmapLabel.
All I could manage was to get the bitmap to display, however I also want the button's text (label) to be displayed over the bitmap at the same time. How could I do this?

It's not clear what do you want to use a bitmap at all if just want to display the text. What's wrong with just doing
wxButton* b = new wxButton(...); // possibly use wxBORDER_NONE style
b->SetBackgroundColour(*wxBLACK);
b->SetForegroundColour(*wxWHITE);
?
Also notice that since wxWidgets 3.0 the functionality of wxBitmapButton is available in wxButton itself, i.e. you can set a bitmap for any button and it will be displayed in addition to the text.

Related

QLabel auto multiple lines

For example, we have a QLabel with MaximumWidth set to 400.
When we try to display some text with pixel width more than 400, it's shown cut off.
Is there any way to make QLabel display this string in multiple lines without using QFontMetrics or the like?
If I understood your question correctly, you should use the setWordWrap function for your label, with true as its parameter.
QLabel lbl("long long string");
lbl.setWordWrap(true);
In order to show multiple lines in QLabel, right click on QLabel and select 'change rich text'. This brings up dialog where you can type the text as you want to see including enter key. Setting the word wrap is not required for this.
If you set the word wrap as well (in QLabel properties) than it will wrap each individual line in the Qlabel if it was longer than the real estate.
As another option to wrap text using Qt Designer, you can check the box under Property Editor for a QLabel:

textinput box with inline image

Is there any way to create a textInput box for flex mobile with inline image without using textflow ?
Basically i need a text input component , so that user can just use it as normal text input box but to it images can also be entered inline with text. To enter images user can select the image from list and that image will get inserted at the current cursor position.
If you look at any platform, there is no user experience (as far as I've seen) that lets you add images in the text input box. It's always been straight text, except for android which replaces certain text with icons (like :-) becomes an android icon). I don't think your users would expect that behaviour. If you really do need it, I would recommend you create a custom skin for your textinput box and add that feature into it, but it won't be easy to do.

ASP.Net ImageButton: How to hide the red cross when no ImageUrl is present and just show the AlternateText

I have an Imagebutton with an empty ImageUrl but there is some text in the AlternateText. In IE, it is displayed with a red cross and the alternatetext next to the red cross. In FF, only the alternatetext appears with no red cross image and that is what I want. Plz, I need to work with Imagebutton...dont suggest replacing it with linkbutton or anything else.
So how can I get rid of the red cross thing in IE.
THanks
Ignoring the questionable scenario of having to work with the ImageButton, the only solution I see is creating a transparent 1x1 gif and assign this URL instead of an empty URL in case no image should be displayed, but the alt text still shown.
That said, if you are after the tooltip text I'd strongly recommend using a div or an other suitable element with the title attribute set instead.
Eventually, I did two images for the Image button with the alternate Text as the text inside the images. One image had an underline for the text. Added mouseover and mouseout events where the src of the images changes. So it appears as a link.

Flex htmlText cuts off multiple lines from the bottom if you add an <img />

For some reason, if you add an image to htmlText, like the following:
myText.htmlText = "<img src='"+dataProvider.bodyImage.getUrl('original')+"' align='left' \/>" + dataProvider.bodyText;
The image will be succesfully added to the htmlText, but it seems to measure the sizes completely wrong. At times, the actual text (dataProvider.bodyText) will have part 'hidden' under the image. At other times, there are anywhere from 1 to 4 lines cut off at the bottom. However, if you select the text and drag your mouse down, you can see the bottom lines. It appears the text is all there, but the mx:Text component is not including the image in the textHeight, so it doesnt resize the componenet to the correct size.
Any ideas?
Currently using: Flex 3 (cannot upgrade to 4, unfortunately).
Thanks so much!
The key is you have to specify the width/height of the image in htmlText in order for it to be calculated correctly (or close to it, anyway).

AS3: grouping sprites

I have a handful of sprites that I am attempting to group together via addChild().
Here is some pseudo-code demonstrating what I would like to accomplish:
import nav.text.TextSprite;
spr1:Sprite = new Sprite();
spr1.graphics.clear();
spr1.graphics.beginFill(0x000000);
spr1.graphics.drawRect(0,0,100,100);
txt1:TextSprite = new TextSprite;
txt1.text = "hello";
spr1.addChild(txt1);
//this is what isn't working: the sprite is hidden but not the text
spr1.alpha = 0.0;
For some reason I cannot seem to get the TextSprite to draw correctly... All it is is a Sprite with a TextField added to it. I think everything is working there, but I might have something wrong w/r/t making sure all of TextSprites children are grouped correctly.
I should mention that it does position correctly; but the alpha property won't respond in the way I would expect it to. I.E., the sprite that the TextField is attached to will allow it's alpha to be set but the text remains visible.
Any thoughts?
Most likely you just need to embed the font in your textfield. Try changing the x, y of spr1 and see if txt1 moves along with it. If it truly is a child then it will respond to the new position.
You need to embed the font using textfield.embedFonts = true. If your text is disappearing when you do this, how are you going about embedding the font (using the Flex embed meta tag or using the Flash IDE?), check that you are not changing the font weight (setting the text to bold when you have only embedded the normal weight font) and if you are using a text format, be sure to apply the text format AFTER you set the textfield.text property. You can get around this by using textfield.defaultTextFormat.

Resources