Styling a menubar item (Firemonkey) - delphi

I can't seem to figure out how to change the font of a tmenuitem object.
I add a menubar, and add a item to it.
I create a customstyle for the menuitem.
I can change the background color and stroke color etc,etc, but I can NOT change the font of the text part.
If I change the font (size or name or anything) it shows in the style editor but does not show in the form designer or at runtime.
Seems the font somehow default to something.
Has anyone else been able to do this ?

FireMonkey overwrites pretty much any settings you make for fonts (face, size, style) within a style. AFAIK any font changes you want to make have to be done at run time. In the case of a TMenuItem that means by setting the Font property manually after you have created the menu item.
However (and I've never played with this) I seen people saying they can change a font by setting the StyleLookup after a component has been created.
You might want to hook into the OnApplyStyleLookup event to make these updates.

Related

How to style buttons in Firemonkey

Are there special steps for styling a button using stylebook in FMX? because whenever I change my style it works in the viewer only, however when I run the program nothing changes although stylebook setting are properly connected to style files and to the application as well, also if I close the program and start it again I find the same style saved and exists in the view but when run the application I cant find any style, can anyone tell me the exact steps? because I check tutorials, docs, help but still stylebook wont apply the new changes to the app at run time. Thanks.
Screenshot
To modify the default style:
Start with a blank fmx form and add a TButton.
Right-Click on the button and select Edit Default Style ... - the Style Designer opens
In the Structure pane select Buttonstyle - text
In the Object Inspector change the NormalColor property to Crimson. The text of the button changes to Crimson (red) color.
Hit the designer view Close button (X) and confirm to Apply changes ... by clicling Yes when prompted. Note that a Stylebook has been added to the form.
Build and run
The result looks like this on Windows 7
Maybe you have omitted step 5 (just guessing)
With an existing stylebook and style do as follows:
Start with a blank fmx form and add a TButton.
Add a TStyleBook, set its UseStyleManager property, double-click it and load an existing style (e.g. Air)
In the structure pane select buttonstyle - text. Note that available properties are not necessarily the same as when editing the default style.
In the Object Inspector change the Font - FontColor property to Yellow. The text of the button changes to yellow color.
Hit the designer view Close button (X) and confirm to Apply changes ... by clicling Yes when prompted.
Build and run
The result looks like this on Windows 7

FMX progressbar color

Please be kind, I did my best with google, and found some guidance (also on StackOverflow), but none of it works for me.
FMX form with FMX Progressbar;
I only want to change the progressbar color from ugly yellow to cool skyBlue.
So far I've dropped a stylebook on the form;
I've added "progresscellstyle.htrack.hindicator" to the stylesheet designer;
It's the only one that even provides me with a color option (vs everything in "progressbarstyle treeitem") and that color does not influence my progressbar colour.
Please, a next step to decoding this problem if you could be so kind
Drop a TProgressBar on the form. Right click it and select Edit Custom Style. It should give you the style designer with a ProgressBar1Style1 object which contains htrack and vtrack.
htrack contains hindicator. Drop a TRectangle on the hindicator. Set the TRectangle to align Client. Change the Fill color as desired. Change the Stroke Kind to None.
vtrack contains vindicator. Drop a TRectangle on the vindicator. Set the TRectangle to align Client. Change the Fill color as desired. Change the Stroke Kind to None.
Close the style designer and save when it asks. This is one way to do it.
This may be a title old question, but the content about this is so rare that I think will be useful to future generations to have some info here.
To simply put, to change the color that will fill your bar you have to select a area in your BitmapLinks. To do that double click in the SourceLink property in the hindicator (a child of htrack in the tree view).
Then select a are that you will want to use as the filling, if none of the option pleases you, you may add a new BitMap to your StyleBook.
For the background color, just insert a rectangle inside htrack with a Client Alignment

How do I use a button duplicated in my style in FireMonkey?

I've created a style with the Bitmap Style Designer for Delphi XE7.
I've updated the button style to white with a blue border and duplicated it to create an orange button called Button_Copy.
I've exported the style to FireMonkey, but I can't find Button_Copy to assign it to a button on my form. How do I do this?
Also, can I rename Button_Copy to e.g. OrangeButton?
In the Bitmap Style Designer, save the style as a FireMonkey style.
Add a TStyleBook to your form.
Set the StyleBook property to the stylebook.
Double-Click the StyleBook and open your style. Close and Apply.
You can now set the StyleLookup property of a button to Button_Copy and if all is well you will see your new style.
Note that your new style won't appear in the selection list for StyleLookup - the list of available values appears to be hard coded.
And, of course you can change the name - just change the StyleName property of the top level object (probably a TLayout). The normalnaming convention is to append the word 'style', e.g. OrangeButtonStyle.

How to change caption font color on TCheckBox, TRadioButton, TGroupBox?

I don't know what my problem is, but I cannot set the font color in DEx2 for controls like TCheckBox, TRadioButton, TGroubBox, and TRadioGroup. It doesn't matter if I do it in the IDE or programmatically.
I have set my form color to clBlack and want my captions to be clWhite, but they won't render any color but clBlack. When I assign a color on a form's OnShow event and step through it in the debugger, it shows the value I assigned it, but on the screen it is still black.
I am not using styles or anything else. Any ideas?
Here is a sample form:
white on black example http://www.skippix.us/temp/Delphi-Font-Problem.bmp
When you uses the windows themes in an application, most of the custom settings like the font colors are ignored. As workaround and depending of the component you can ownerdraw the control (only when this feature is supported), override the paint method in order to use your own color in the font (TRadioGroup, TGroupBox), and for components like TCheckBox and TRadioButton (which are WinAPI controls wrappers) you must intercept the WM_PAINT windows message and implement your own code to draw the control.
Also starting with Delphi-xe2 you can use the vcl styles which allow you to change the appearance of the controls, from here (and when is possible) you can modify the style hooks to apply your own font colors and other customizations.
A simple and easier workaround is to create a checkbox without caption and add a label after it. You can easily change the label's color. You can also create a new component that binds a label to the checkbox itself. That's what worked for me on Delphi 2007.
It will work under the following setting:
Project Options > Application > Runtime Themes = none

Setting fonts in Firemonkey

Is there a way to set font properties in the firemonkey style editor?
I tried both using a custom style and changing the default style of a TButton.
Each of these layouts have a child TText component which is named text. If I try to change the font settings (e.g. change the bold flag) it looks okay in the designer, but in the form designer as well as at runtime, nothing changes.
Is there also a way to define a default font for all TTextControls? In vcl there is a parentfont property which is not available in Firemonkey. After a closer look to the components code, I think it should be possible by defining the text layout for a TTextControl in the stylebook. But this component is not registered in the component palette.
Update: TMenuItem does not apply font settings at all. At the moment it can only be done at runtime.
This was fixed in XE 2 Update Pack 1. Try downloading the new version. You can now set Font styles.

Resources