简体   繁体   中英

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. I am not able to change font size/style in pharo for my labels or text areas/button. 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). Is Atlanta a StrikeFont or a truetype? StrikeFonts are the old bitmap fonts. For some simple code showing custom colors, fonts and borders, you might want to load CardsMorphic from the Configuration Browser

As for the background colors and border widths it works fine is you add openInWorld .

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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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