On Sun, 19 May 2019 10:29:54 GMT, Ron Tarrant wrote:
How can I find out which features are implemented and which aren't? Is it a matter of digging through the source, or is there another way?
Forgot to say...
The reason I ask: I'm digging into using CSS and I've had some success with setting colors and fonts for Labels, but for Buttons, I can only affect the font, not the colors, and I'm wondering if it's because not all the CSS properties/attributes are available for the Button widget.
I also can't seem to set the background-color for a window, either.
And that got me wondering about what else hasn't been implemented... if that is that case.
Here's the D code:
// Test Rig Foundation for Learning GtkD Coding
import std.stdio;
import gtk.MainWindow;
import gtk.Main;
import gtk.Box;
import gtk.Widget;
import gtk.Button;
import gtk.Label;
import gtk.CssProvider;
import gtk.StyleContext;
import gdk.Screen;
void main(string[] args)
{
Main.init(args);
TestRigWindow myTestRig = new TestRigWindow("Test Rig");
Main.run();
} // main()
class TestRigWindow : MainWindow
{
AppBox appBox;
string cssName = "mywindow";
Screen screen;
CssProvider cssProvider;
string cssFile = "./theme.css";
StyleContext styleContext;
this(string title)
{
super(title);
setName(cssName);
writeln("window name: ", getName());
screen = getScreen();
cssProvider = new CssProvider();
cssProvider.loadFromPath(cssFile);
styleContext = new StyleContext();
styleContext.addProviderForScreen(screen, cssProvider, STYLE_PROVIDER_PRIORITY_FALLBACK);
addOnDestroy(&quitApp);
appBox = new AppBox();
add(appBox);
showAll();
} // this() CONSTRUCTOR
void quitApp(Widget widget)
{
writeln("Bye.");
Main.quit();
} // quitApp()
} // class myAppWindow
class AppBox : Box
{
CSSButton cssButton1, cssButton2;
CSSLabel cssLabel1, cssLabel2, cssLabel3;
string button1Text = "CSS Button 1", button2Text = "CSS Button 2";
string button1CSSName = "button1", button2CSSName = "button2";
string label1Text = "Hello 1", label2Text = "Hello 2 U", label3Text = "Hello 3";
string label1CSSName = "label1", label2CSSName = "label2",label3CSSName = "label3";
this()
{
super(Orientation.VERTICAL, 25);
cssButton1 = new CSSButton(button1Text, button1CSSName);
cssLabel1 = new CSSLabel(label1Text, label1CSSName);
cssLabel2 = new CSSLabel(label2Text, label2CSSName);
cssLabel3 = new CSSLabel(label3Text, label3CSSName);
cssButton2 = new CSSButton(button2Text, button2CSSName);
setHomogeneous(true);
// packStart(<child object>, false, false, 0); // LEFT justify
add(cssButton1);
add(cssLabel1);
add(cssLabel2);
add(cssLabel3);
add(cssButton2);
// packEnd(<child object>, false, false, 0); // RIGHT justify
} // this()
} // class AppBox
class CSSButton : Button
{
this(string textLabel, string cssName)
{
super(textLabel);
setName(cssName);
} // this()
} // class CSSButton
class CSSLabel : Label
{
this(string textLabel, string cssName)
{
super(textLabel);
setName(cssName);
} // this()
} // class CSSLabel
And here's my CSS file (saved as theme.css in the same folder):
#mywindow
{
font-family: "Times New Roman";
font-size: 12px;
background-color: rgba(233,23,34,1);
}
button.text-button#button2
{
color: green;
background-color: blue;
font-family: "Bodoni MT";
font-size: 20px;
text-decoration: underline;
}
button.text-button#button1
{
font-family: "Comic Sans MS";
font-size: 16px;
color: red;
background-color: yellow;
}
label#label1
{
font-family: "Times New Roman";
color: red;
background-color: yellow;
}
label#label2
{
color: green;
background-color: yellow;
}
label#label3
{
color: blue;
background-color: yellow;
}
Of those attributes I've tested, here's what works:
- for Labels:
-- font-family,
-- color,
-- background-color,
-- font-size, - for Buttons:
-- font-family,
-- font-size,
And from what I've tested so far, here's what does NOT work:
Window:
-- font-family,
-- font-size,
-- background-color.
Although I'm really not sure where I would see CSS font changes in a Window... the titlebar?
According to the examples I've been able to find for other languages, the background-color should be the background of the Window. I tried one example with just a Window and nothing else and the background-color setting still does nothing. Oh. And I tried both named colors (ie. blue, green) as well as the rgba() form. Same results.
And neither do these:
Button:
-- color,
-- background-color,
-- text-decoration.