IF Computer > IF/Prolog > Manuals > IF/Prolog V4.1 マニュアル > IF/Prolog Interfaces > OSF/Motifインタフェースマニュアル > OSF/Motifによるプログラミング > Prolog言語バインディングによるXtプログラムの例題

Prolog言語バインディングによるXtプログラムの例題

IF/Prolog by Siemens
MINERVA superseeded IF/Prolog. Please see http://www.ifcomputer.co.jp/MINERVA for details.

We discontinued to sell IF/Prolog Dec 31. 2003. For current customers, we continue to provide professional support for IF/Prolog until Dec 31, 2008.

以下のプログラムは、OSF/Motif widgetsを用いたX11 toolkitの概念のいくつかを示しています。これは、ディレクトリ$PROROOT/motif11/demos中のファイルmdialog.proにあります。また、別の例題もここに含まれています。

プログラムの概要:

・xmInitialize/5 によるtoolkitの初期化

・xtCreateManagedWidget/5 によるmanaged widgetの生成

・xtSetValues/2 によるリソ−スの変更

・xtAddCallback/4 によるコ−ルバックの追加

・アクションのトランスレ−ションや使用法の変更

・ユ−ザとの対話処理において生じるイベントによる、手続きの呼び出し

まず、タイトル 'Hello, Please type input:'、テキスト用入力ウインドウ、ユ−ザによるテキストの入力が終了した時に押す2つのボタンからなる、ダイアログwidgetが作られます。テキストの入力は、リタ−ンキ−、あるいは'^C'を入力することによっても終えることができます。この振る舞いはユ−ザ定義のアクションによって起こるもので、テキストwidgetのトランスレ−ションテ−ブルに含まれています。

program :- program_parameters(Pars), xmInitialize(Toplevel, Toplevel, 'XLabel', [], Pars), xtSetValues(Toplevel, [ allowShellResize(true), iconName('Dialog'), title('Dialog') ]), xtAddAction(action), xtCreateManagedWidget(dialog, dialog, xmFormWidgetClass, Toplevel, []), xtCreateManagedWidget(Label, Label, xmLabelWidgetClass, dialog, [ labelString('Hello, please type input:') ]), xtCreateManagedWidget(input, input, xmTextWidgetClass, dialog, [ topAttachment(attach_widget), topWidget(Label) ]), xtCreateManagedWidget(Confirm, Confirm, xmPushButtonWidgetClass, dialog, [ labelString('Confirm'), topAttachment(attach_widget), topWidget(input) ]), xtAddCallback(Confirm, activateCallback, confirm, input), xtCreateManagedWidget(Cancel, Cancel, xmPushButtonWidgetClass, dialog, [ labelString('Cancel'), topAttachment(attach_widget), leftAttachment(attach_widget), topWidget(input), leftWidget(Confirm) ]), xtAddCallback(Cancel, activateCallback, cancel, _), xtOverrideTranslations(input, 'Return: action(confirm)\n\ Ctrl C: action(cancel)'), xtRealizeWidget(Toplevel), xtMainLoop.

confirm(_Widget, Input, _) :- xtGetValue(Input, value(String)), write('String "'), write(String), write('" entered\n'). cancel(_Widget, _ClientData, _CallData) :- exit(0).

action(_Widget, params(confirm)) :- xtGetValue(input, value(String)), write('String "'), write(String), write('" entered\n'). action(_Widget, params(cancel)) :- exit(0).

document: http://www.ifcomputer.co.jp/IFProlog/Manuals/v4.1/advanced_feature/osf_motif/motifprog/example/print_en.html
published 2008/12/1 update 1995/11/6 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS