Change the button color at Runtime depending on property when VCL Styles are applied - custom-component

I am working with VCL styles in Delphi 10.2.
I have a MyButtonStyle property on a custom button component - TMyButton, which inherits from TButton.
type
MyButtonStyle = ('Default', 'Red', 'Yellow', 'Green');
Based on the MyButtonStyle property values:
When a VCL Style is applied, I want to change the color of TMyButton to either: Default (default selected style color), Red, Yellow, or Green.
Any idea how this can be achieved?
I tried using the Bitmap Style Designer in Delphi. But it allows selecting a color only at design-time. How to achieve this at runtime?

Related

Where can vscode view the default colors for parts that you don't define

I sometimes wonder what vscode's default widget color is. For example: when I use a github theme, I find that it only defines one part of the color internally, so where is the other part defined, and how do I view it.
For example, when I look at the color scheme of the topic by Developer : generator color theme... command, the undefined part is always shown in the form of comments(e.g "activityBar.activeBackground": null,). How can I see the color of this annotated section?

How to get standard system colours for custom widget

I am writing a custom widget using gtkmm and I would like to use the standard selection colour when part of my widget is selected. For example when you select text in a text box, the background colour goes (for me) dark blue, so I want to obtain this same dark blue colour.
I have tried this, but I only get black or white, not the actual colours in use:
bool MyWidget::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
Gdk::Cairo::set_source_rgba(cr,
get_style_context()->get_color(Gtk::STATE_FLAG_SELECTED));
}
What is the correct way to obtain the standard colours with gtkmm, such that if the user changes their colour theme, the changes will also be reflected here?
Or is it considered best practice to define some new CSS styles which inherit from the standard system ones, so that people can override colours for just my widget if they desire, without affecting others?
Turns out the answer to this is that what I was doing in the question was correct, except there were no styles applied to the widget so the colours were just black and white.
I had to add this in the widget's constructor:
this->get_style_context()->add_class(GTK_STYLE_CLASS_ENTRY);
To get text entry styles. Of course this made render_background() as suggested by ebassi render a text entry background instead, which isn't what I wanted (I just wanted a solid colour.) So instead I changed the above line (in the constructor) to:
this->get_style_context()->add_class(GTK_STYLE_CLASS_DEFAULT);
And in my render function, temporarily set text-entry styles just to get the colour:
auto cxStyle = this->get_style_context();
cxStyle->context_save();
cxStyle->add_class(GTK_STYLE_CLASS_ENTRY);
Gdk::Cairo::set_source_rgba(cr, cxStyle->get_background_color(Gtk::STATE_FLAG_SELECTED));
cr->fill();
cxStyle->context_restore();
This way I was able to obtain the text selection colour and fill a rectangle behind the area of my custom widget that should be shown as currently selected.
I couldn't use render_background() here because it would have drawn the background of a text control which I don't want, I just wanted a solid filled rectangle.
The proper way to render the background of a widget is to use gtk_render_background(). This function will take into account widget state and style.
Your code above becomes:
bool
MyWidget::on_draw (const Cairo::RefPtr<Cairo::Context>& cr)
{
double w = get_allocated_width(), h = get_allocated_height();
Glib::RefPtr<Gtk::StyleContext> context = get_style_context();
context->render_background(cr, 0, 0, w, h);
return true;
}
This way your widget will always be updated to reflect the theme.
If you want to control the color and style of your widget you should use an additional Gtk::StyleProvider for your application to load a custom CSS fragment with the desired style classes.

Custom Colours in Color Picker

I'm using the inline editor for TinyMCE4 and I'm trying to replace the colours in the colour picker.
I've managed to do this using the following:
textcolor_map: [
"204292", "Pantone Blue 072",
"00a88F", "Pantone Green",
"F48C2D", "Pantone Orange 021",
"231F20", "Pantone Process Black" ,
"0095CE","Pantone Process Blue"
],
The problem is, there is no more link to 'More Colors'. This option is availble in TinyMCE3, but not 4...
Has anyone come across this?
Thanks
There's a custom plugin with for any custom color available at:
http://www.tinymce.com/forum/viewtopic.php?id=31419
With the standard color picker, add the following in your init:
theme_concrete_text_colors : "436EB2,3CB54B,3b2315,ffffff,000000",
Replace concrete with the theme name, ie. theme_advanced_text_colors
http://youtu.be/hiaP3Y9wVdA

Reference for phClr in openxml

I am trying to find value for phClr, but no results.
Slide master is not having mapping for phClr.
I am aware that phClr is just a passed-in color value, but what exactly is its color reference?
Is it bg2 or anything else?
http://msdn.microsoft.com/en-us/library/cc964302(v=office.12).aspx
Blockquote
The scheme color value is set to placeholder color (the value phClr). This value appears throughout the fill, line, effect, and background styles and indicates that the settings are applied to the theme color applicable for a given style. This allows the same fill, line, and effect styles to populate across the theme colors that appear in the OfficeArt galleries.
“phClr” is a kind of placeholder color

Change color of a node in Zest

I'm using Zest to draw a graph. However, I want to change the default color of the graphnode to another color based on its label. For example: Label: red => color of the node is red.
If you are using the GraphViewer API of Zest (similar to JFace viewers), let your LabelProvider extend IEntityStyleProvider that provides the necessary getBackgroundColor() callback method (among others).
However, if you are using the base Graph API, then you have to set the color of all the nodes manually using the GraphNodes set*Color methods.