How can a spark Label be skinned? - apache-flex

I would like to add some fancy drawing beyond the CSS formatting.
How can I put a skin on a spark Label ?
thanks

Wow, +1 for a good question. The approach I would take would be to custom component that wraps a Label with a SkinnableComponent, which then allows you to specify a skin class since the Label component itself is not skinnable. I would then take a look at the Button and ButtonSkin classes to mimic passing the label text into the Label component in your skin. Hope that helps.

Related

Dynamically change QStyle at runtime?

I want to tweak the existing style at runtime, specifically QStyle::PM_ToolBarIconSize. Can this be done? As far as I can tell, you can only inherit QStyle and override pixelMetric().
Edit 1: In the specific case of QStyle::PM_ToolBarIconSize, I could use QToolBar::setIconSize, but that would set the icon size for just a single toolbar instance. I want to change the underlying style hint to affect all toolbars everywhere with one fell swoop. And QStyle::PM_ToolBarIconSize may not be the only style I want to tweak, it's just the first one I'm looking at that just so happens to have a "change this instance's icon size" function.
Edit 2: I can't just make a new style subclass because the current style is already a custom style based on style sheets. There are several styles that a user can choose from. I don't want to create a bunch of new styles just so I can tweak a couple of toolbar icon or menu height size settings.
This is the exact purpose of QProxyStyle.
Why not overriding QStyle then? Your subclass would return an icon size (via pixelMetric) which depends on a settable parameter of your QStyle.
As Qt does not have a dynamic QStyle mechanism, it is better to create a new style instance with the changed icon size, then set it to the QApplication, rather than altering the current style.

QTableWidget: different styles in *one* QTableWidgetItem?

Is it possible to have a two-line element in a cell (QTableWidgetItem) of a QTableWidget with different styles per line? I want to have the first line bold and the second line not bold. Or can I add two QTableWidgetItems in one cell? Do a cellspan somehow?
Cheers
Matthias
Simple way :
Checkout the setCellWidget method of QTableWidget.
If you replace the default widget with QTextEdit, you can get rich text formatting capability.
Better way :
Use a custom QStyledItemDelegate. You can see an example here
I hope this helps.

How to customize accordion and panel look

I want to increase the (height) size and change the color of a spark accordion header, similarly I want to change the color of a spark panel header. Can I do this through mxml properties and css or will I need to use a custom skin?
I recommend creating a custom skin. That was the way Spark was designed to be customized. Specific styles and the sort are almost an afterthought.

Flex - combined bold and normal label in Button component

It is possible to bold some part of label in standard Button? example:
ICON - normal_normal_text BOLD_BOLD_text
Thanks for help :)
I don't think you can do this with a standard label, but FlexLib contains a CanvasButton component (http://flexlib.googlecode.com/svn/trunk/docs/flexlib/controls/CanvasButton.html) that allows you to add multiple children to a button that would work well to have two labels styled differently, or to better control the styling in a single label.
You're probably better off using a Text or a Label and skinning it look like a button. Each of those has an .htmlText property which will take rudimentary tags like <b></b> and <i></i>, etc. Remember to set the .buttonMode and .useHandCursor properties to true and .mouseChildren to false for best button simulation.

Flex LinkBar: how to set a selected button's background color?

I was able to set the text color of a selected LinkBar button by "disabledColor" style of LinkBar. Accordingly, I expect to set the background color of the selected button by "backgroundDisabledColor" style, however, it didn't work; and except "backgroundDisabledColor", I didn't see any other style that could possibly achieve this. Please help. Thanks.
The problem is probably that you're setting the style on the LinkBar itself - try setting the LinkBar's linkButtonStyleName style to a different style selector that contains all of the styles you need for your button. You should be able to set the fillColors style of the buttons themselves there - this will change the default look of the button.
If you need to adjust the "selected" color or if you need something more advanced than just skinning the button background you'll need to write a custom skin class. This isn't too difficult - the Button class has a whole set of "Selected" styles - selectedDownSkin, selectedUpSkin, selectedDisabledSkin, etc. IMO the best practice is to set your button skin to a custom skin class that sets the different individual styles based on state.
David Flately illustrates this method here. Check out his source - that should get you what you need. A good book on this topic that has this sort of thing along with lots of other examples is Juan Sanchez and Andy McIntosh's Creating Visual Experiences with Flex 3.0. I can't post a link to it because my reputation isn't high enough here yet, but you can find it on amazon or barnes and noble or any other online bookstore.
FYI - answer here....
http://dezeloper.wordpress.com/2010/02/24/flex-css-linkbar-togglebuttonbar-selected-text-color/
Haha, was looking for same thing, you can see on the source code of LinkBar:
// Hilite the new selection.
child = Button(getChildAt(selectedIndex));
child.enabled = false;
Which is clever!!! Rather than set selected to true, they disable the selected button ... why not ;-( Took me half an hour to understand the Flex team logical ...
eBuildy, Flex Specialists

Resources