How to change the font in the SpTextPresenter? - smalltalk

Pharo 9, Spec 2 -- I have a Spec 2 presenter with a text widget:
initializePresenters
text := self newText.
super initializePresenters
As I understand its type is SpTextPresenter. How to change the font of this text? Font face, size of the all shown text in this widget... For example, to "Courier New", 9.
EDIT 1:
Also I tried:
text addStyle: { SpStyleSTONReader fromString:
'
Font {
#name: "Source Sans Pro",
#size: 12,
#bold: false,
#italic: true
}' }.
but it does not work, the error is: Improper store into indexable object.
EDIT 2:
Also I found this documentation. It seems that the scenario must be:
Read styles as STON
Set styles somwhere (where?) for the all application. They are described under its names in the STON so they can be referred under its names in the application.
Call addStyle: 'the-name' so the widget with a name the-name will refer own styles from the loaded STON.
The problem is in 2. - I have not application, just one presenter which I open with openWithSpec.

I didn't notice this 'till now.
Spec "styles" cannot be added directly to the component but they need to be part of a stylesheet.
Stylesheets are defined in your application (in particular in your application configuration).
You can take a look at StPharoApplication>>resetConfiguration, StPharoMorphicConfiguration>>styleSheet and StPharoMorphicConfiguration>>styleSheetCommon as examples (you will also see there than using STON to declare your styles is just a convenience way, not mandatory).
Here a simplified version of what you will find there:
StPharoApplication >> resetConfiguration
self useBackend: #Morphic with: StPharoMorphicConfiguration new
StPharoMorphicConfiguration >> styleSheet
^ SpStyle defaultStyleSheet, self styleSheetCommon
StPharoMorphicConfiguration >> styleSheetCommon
"Just an example on how to build styles programatically ;)"
^ SpStyleSTONReader fromString: '
.application [
.searchInputField [
Font { #size: 12 }
]
]
'
Then you can add the style to your component:
text addStyle: 'searchInputField'

Related

QML error "Unknown component. (M300)" but the code works

I want to use a custom font in a QML application, and to not have to specify it in every text field, I use a component as suggested in this answer.
I have a DefaultText.qml under a styles prefix in my qml.qrc, which resides in the folder styles.
import QtQuick 2.0
Text {
color: "black"
font.family: myCustomFont.name
font.bold: false
font.italic: false
font.pixelSize: 14
}
I use it, among other places, in a qml named PanelRight.qml, under the prefix Panels in the folder widgets. It's all under the same qml.qrc.
import "qrc:/styles/styles"
Item
{
// ...
DefaultText { text: "xyz" }
}
Interestingly, DefaultText is underlined as an error, with the message "Unknown component. (M300)". However, I can successfully compile and run my application, and the custom font is displayed correctly. However, it's annoying that I have a long list of errors (I intend to use it in a lot of places) and that autocomplete doesn't work.
I searched the Qt forums, this problem was mentioned there in case of custom plugins, which I don't use.
Add relative path of DefaultText.qml in PanelRight.qml file as
import "../styles"
import QtQuick.Controls.Material

How to change color of comment marker for Atom editor?

I was able to change color of comment content with
atom-text-editor::shadow .comment {
color: #E4F4FD;
}
But the color of comment marker stayed unchanged:
How do I change the color of comment marker?
If you place your cursor immediately to the left of the character you want to style and then press Ctrl-Alt-Shift-P all of the scopes for that character will be displayed in an information box:
You can then incorporate this into your stylesheet as you have with the body of the comment:
atom-text-editor::shadow {
.comment {
color: #E4F4FD;
}
.punctuation.definition.comment {
color: #E4F4FD;
}
}
Because it is LESS, it is possible to nest classes which will make your style sheet much cleaner.
Using ATOM version 1.58.0 on Windows 10, I get a depreciation warning. The short version is:
Starting from Atom v1.13.0, the contents of atom-text-editor elements are no longer encapsulated within a shadow DOM boundary. This means you should stop using :host and ::shadow pseudo-selectors, and prepend all your syntax selectors with syntax--.
I had to use:
// Change the color of the comments
atom-text-editor .syntax--comment{ color:#9DA5B3; }
atom-text-editor .syntax--punctuation.syntax--definition.syntax--comment{ color:#9DA5B3; }

Change plain line to arrow line in infovis

How to change plain line to arrow line in infovis?
Currently there are some lines between blocks, I found some css files, but I cannot find which content describing the line behaviour such that I can change the plain line to arrow line.
Thanks.
Generally spoken: You can't (and shouldn't) change it via CSS. Define such properties during the setup.
Here's a brief explanation:
The Code that generates and Edge (which is a line in network visualizations) is generated by the Edge method/function which sits inside Options.Edge.js.
The function Edge is a property/module of the $jit object and works like this:
var viz = new $jit.Viz({
Edge: {
overridable: true,
type: 'line',
color: '#fff',
CanvasStyles: {
: '#ccc',
shadowBlur: 10
}
}
} );
It's important that you define overridable as true as you else can't override anything. The parameter that you're searching for is type. The allowed values are line, hyperline, arrow and I'm pretty sure that bezier will work as well - not sure if this is true for every type of graph. You can as well define custom graph Edge types - an example is missing in the documentation.
To change the Line/Edge style, there's another function that triggers before rendering. You just have to define it during the graph registration $jit.Viz( { /* add here */ } ); - code from the example/Spacetree here:
// This method is called right before plotting
// an edge. It's useful for changing an individual edge
// style properties before plotting it.
// Edge data proprties prefixed with a dollar sign will
// override the Edge global style properties.
onBeforePlotLine: function(adj){
if (adj.nodeFrom.selected && adj.nodeTo.selected) {
adj.data.$color = "#eed";
adj.data.$lineWidth = 3;
}
else {
delete adj.data.$color;
delete adj.data.$lineWidth;
}
}
The final step would now be to inspect what add.data can deliver and then either add the style you want or define a new one using a closure.
There might be another way to go on this: Example for a ForceDirected graph. Take a look at the documentation here.
$jit.ForceDirected.Plot.plotLine( adj, canvas, animating );
Maybe you could even use something like this:
var edge = viz.getEdge('Edge_ID');
edge.setData( property, value, type );
Disclaimer: I got no working copy of theJit/InfoViz library around, so I can't help more than that unless you add a JSFiddle example with your code.
Edit
As I just read that you only want to change to the default arrow type, just enter this type during the configuration of the graph.

Extjs 4.1.1 - Applying custom class to a form field

ExtJs 4.1.1 question
I am trying to apply a custom class to a set of textboxes inside a panel
the way i am doing is specifying fieldCls in defaults attribute of panel so that it applies to all the textboxes inside the panel
Below is a sample code
pnlTest = Ext.create('Ext.panel.Panel', {
width : 600
,height : 190
,defaults: {xtype:'textfield', fieldCls:'my-custom-class'}
,items : [
{name :'name1', fieldLabel:'Name 1' }
,{name :'name2', fieldLabel:'Name 2' }
,{name :'name3', fieldLabel:'Name 3' }
,{name :'name4', fieldLabel:'Name 4' }
]
});
Upon inspecting the generated HTML i see that the input element has 2 classes associated with it
my-custom-class and
x-form-field (exts default class for textbox
input)
i do not want to have x-form-field in my input element as it is overriding my styles
ExtJs documentation states that the default value for fieldCls is 'x-form-field' isnt that suppose to mean that if i provide my fieldCls value it must replace the default instead of appending to it, or am i doing something wrong here.
i did do bit research on this and did not find any bugs or concerns logged onto sencha forum.
can anyone guide me how to use fieldCls attribute of textfield ?
as an workaround currently i am providing fieldStyle to override all the styles but my goal is to use classes as my styles specifications strings are fairly long and dynamic
thankyou
Actually, you are still doing it in a non-standard way, the correct way to get the fieldCls to overwrite is doing it with the 'fieldDefaults' on a form panel according to the docs:
pnlTest = Ext.create('Ext.form.Panel', {
width : 600
,height : 190
,fieldDefaults: {xtype:'textfield', fieldCls:'my-custom-class'}
,items : [
{name :'name1', fieldLabel:'Name 1' }
,{name :'name2', fieldLabel:'Name 2' }
,{name :'name3', fieldLabel:'Name 3' }
,{name :'name4', fieldLabel:'Name 4' }
]
});
While adding the CSS files in HTML, I was including my CSS file and then ESTJS css file
therefore when an element gets multiple classes it gives precedence to the class which is included last (declared later)
so when my ext generated element looked like below
<input type='text' class='my-custom-class x-form-field'>
it was always using the x-form-field css instead of mine
Now i changed the css inclusion order.
i first include extjs css and then include my css file
this way my css declaration takes precedence over extjs css and give me the desired result
thank you all for looking into the question

reStructuredText styles

I found this guide for rst2pdf to find out how to style a reStructuredText file in the resulting pdf document. Having the following in my JSON stylesheet, for example, it is successfully applied to the whole document:
"pageSetup" : {
"size": "A4",
"width": null,
"height": null,
"margin-top": "2cm",
[...]
"margin-gutter": "0cm"
}
How is a particular style applied only to a specific class? For example, how can I apply a particular font the to the h1 class? My immediate difficulty stems from the fact that I'm unsure about whether it's actually called h1, H1, header1, or Header1.
The rst2pdf.py manual does not seem very informative with regards to the style names. However, the section on Styles (chapter 8) has this example:
["heading1" , {
"parent": "normal",
"fontName": "Tuffy_Bold",
"fontSize": 18,
"keepWithNext": true,
"spaceAfter": 6
}],
So it seems that heading1 is the appropriate style name.
One thing to note is that
If your document requires a style that is not defined in your stylesheet, it will print a warning and use bodytext instead.
So presuming that you don't get any warnings when generating your document the styles must be set in the default stylesheet, so have a look through this to get a feel for the style names used.
You can make rst2pdf print the default stylesheet using
rst2pdf --print-stylesheet
If you want to add styles, just create a stylesheet, (or take the standard stylesheet and modify it) and pass it with the -s option
rst2pdf mydoc.txt -s mystyles.txt