GUIKit`
GUIKit`
"FontChooser"
GUIKitで提供されていた機能は,組込みのWolfram言語にネイティブのインターフェース構造およびコントロール関数で利用できるようになった.
Widget["FontChooser"]
名前,スタイル,大きさに基づいてフォントを選ぶパネルを提供する.
詳細
- Widget["FontChooser"]を使用する際は,まずNeeds["GUIKit`"]を使って GUIKit をロードする必要がある.
- Widget["FontChooser"]のインスタンスは任意のユーザインターフェースの定義内に置くことができるので,チューザの"selectionModel"とバインドして現行選択のフォントが変更された場合に通知させることができる.
- 使用可能なプロパティ:
-
"selectionModel" DefaultFontSelectionModel ユーザインターフェースとデータ間の選択操作を仲介するモデル "font" 12-point plain serif 現行選択フォント "showLogicalFonts" True 論理フォント名を選択肢として表示するかどうか "showPhysicalFonts" True 物理フォント名を選択肢として表示するかどうか "sizes" 8,9,10,11,12,14,16,18,20,24,28,32,36,48,72 表示するフォントサイズの選択肢 "allowAnySize" True 任意サイズが入力できるのか,リストに表示された値だけが選べるのか "familyNames" Null 表示するフォントファミリ名の選択肢 "previewPanel" DefaultPreviewPanel プレビューパネル表示ウィジェット - "selectionModel"プロパティで"change"イベントとバインドし,選択色の変更が分かるようにできる.
例題
すべて開く すべて閉じる例 (1)
Needs["GUIKit`"]ref = GUIRun[
Widget["FontChooser"]
];GUIScreenShot[ ref]一般化と拡張 (1)
現行選択のフォントとバインドしてWolfram言語スタイルフォントプリミティブを得る:
Needs["GUIKit`"]GUIRunModal[
Widget["Panel", {
Widget["FontChooser", {
"showLogicalFonts" -> False,
PropertyValue[{"chooser", "selectionModel"}, Name -> "fontSelectionModel"], BindEvent[{"fontSelectionModel", "change"},
Script[updateFont[]]]
}, Name -> "chooser"],
Widget["TextField", {"text" -> ""}, Name -> "myTextField"],
Script[
fontExpr = {};
updateFont[] := Module[{newFont},
newFont = PropertyValue[{"fontSelectionModel", "selectedFont"}];
fontExpr = {
FontFamily -> PropertyValue[{newFont, "family"}],
FontSize -> PropertyValue[{newFont, "size"}], FontWeight -> If[PropertyValue[{newFont, "bold"}], "Bold", "Plain"],
FontSlant -> If[PropertyValue[{newFont, "italic"}], "Italic", "Plain"]
};
SetPropertyValue[{"myTextField", "text"}, ToString[fontExpr]];
];
],
BindEvent["endModal", Script[ fontExpr]]
}]
]