简体   繁体   English

Pharo Smalltalk自定义字体大小,样式和背景

[英]Pharo Smalltalk customizing font sizes, styles and backgrounds

Basically I am having 2 problems, I am trying to code a simple GUI using Pharo 4.0 Smalltalk. 基本上我有两个问题,我正在尝试使用Pharo 4.0 Smalltalk编写一个简单的GUI。 I am not able to change font size/style in pharo for my labels or text areas/button. 我无法在标签或文本区域/按钮的pharo中更改字体大小/样式。 I am also not able to change their background colors and border widths. 我也无法更改背景颜色和边框宽度。 I have tried all ways: 我已经尝试过各种方法:

font1 := (TextFontReference toFont: 
                (StrikeFont familyName: 'Atlanta' size: 22)).
TextMorph  new contents: ('test' asText addAttribute: font1); 
color: Color blue; 
autoFit: true; 
borderColor: Color green; 
borderWidth: 2.

SimpleButtonMorph new target: self;
label: 'test1';
actionSelector: #test1click; 
basicBorderColor: Color green; 
basicBorderWidth: 2; 
highlightColor: Color green.

TextMorph  new contents: 'test2'; 
color: Color blue; 
autoFit: true; 
borderColor: Color green; 
borderWidth: 2; 
font:'Atlanta' / fontName: 'Atlanta' pointSize: 22 / fontName: 'Arial' size: 32.

None of the above options work. 以上选项都不起作用。 basically I need to customize my fonts and backgrounds for buttons and labels. 基本上我需要为按钮和标签自定义我的字体和背景。 How should I go about this? 我该怎么办呢?

The color should be a text attribute (TextColor) in a TextMorph, a font is not a text attribute (see class side of Text). 颜色应该是TextMorph中的文本属性(TextColor),字体不是文本属性(请参阅Text的类侧)。 Is Atlanta a StrikeFont or a truetype? 亚特兰大是StrikeFont还是truetype? StrikeFonts are the old bitmap fonts. StrikeFonts是旧的位图字体。 For some simple code showing custom colors, fonts and borders, you might want to load CardsMorphic from the Configuration Browser 对于显示自定义颜色,字体和边框的一些简单代码,您可能希望从配置浏览器加载CardsMorphic

As for the background colors and border widths it works fine is you add openInWorld . 至于背景颜色和边框宽度,它可以正常添加openInWorld

SimpleButtonMorph new target: self;
label: 'test1';
actionSelector: #test1click; 
basicBorderColor: Color green; 
basicBorderWidth: 2; 
highlightColor: Color green;
openInWorld 

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM