Difference between revisions of "TLabel/ja"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{TLabel}} {{ Japanese Menu}} '''TLabel''' image:tlabel.png is a component that creates a text-item with one or more lines on another component. A TLabel is a descendan...")
 
 
(14 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
{{ Japanese Menu}}
 
{{ Japanese Menu}}
  
'''TLabel''' [[image:tlabel.png]] is a component that creates a text-item with one or more lines on another component.  A TLabel is a descendant of [[TGraphicControl]] and is available under the [[Standard tab]] of the [[Component Palette]].
+
'''TLabel''' [[image:tlabel.png]]は1、あるいは複数行のテキストアイテムを他のコンポーネントに作るコンポーネントである。TLabelは[[TGraphicControl]]より派生し、[[Component Palette/ja|コンポーネントパレット]][[Standard tab/ja|Standardタブ]]より利用できる。
  
==Usage==
+
==使い方==
A TLabel is one of the most basic components that can be used on [[TForm|forms]]. Most labels are the marking of other components, such as [[TEdit|Edit fields]], [[TMemo|Memos]], [[TStringGrid|StringGrids]] and so on. TLabels provide a variety of events available to you but not required in most cases.
+
TLabelは[[TForm|forms]]で用いることのできるもっとも基本的なコンポーネントの1つである。ほとんどのラベルは、例えば、[[TEdit|Edit fields]][[TMemo|Memos]][[TStringGrid|StringGrids]]などといった他のコンポーネントのマーキングである。TLabelは様々な利用可能なイベントをもたらすが、ほとんどの場合必要とされない。
  
You can add a label to your form, by clicking the TLabel (text symbol Abc) on the Standard component palette and place it with a click on your form.
+
StandardコンポーネントのTLabel(テキストシンボルAbc)をクリックすることにより、フォームにラベルを加えることができ、フォーム上にクリックして配置することができる。
  
To change the default label ''Label'' of a new inserted TLabel on a form, you can proceed as follows:
+
フォームに新しく挿入された、デフォルトラベル''Label''を変更するために、以下のように進めることができる:
* On your form with one click, select the TLabel.
+
* フォーム上で1度クリックし、TLabelを選択する。
* Go on properties in the Object Inspector tab.
+
* オブジェクトインスペクタタブのプロパティに移動する。
* Select the property '''Caption''' and change it in the next edit field.
+
* プロパティ、'''Caption'''を選択し、隣の編集フィールドで変更する。
* In the same way, you can select the property '''Name''' and give the label a better name.
+
* 同様にしてプロパティ、'''Name'''を選択し、よりよい名前に変更する。
  
==Change caption at run time==
+
==実行時にキャプションを変更する==
Of course, you can change the caption (the text displayed) during run time.
+
もちろん、実行中にキャプション(表示されるテキスト)を変えることができる。
  
The following example demonstrates this:
+
以下の例はこれを示している:
* Create a new [[Form_Tutorial#The_first_GUI_application|GUI application]] with the form ''Form1''. Add this form still a [[TButton]] ''Button1'' and a TLabel ''Label1'' by selecting the appropriate components on the Standard Component Tab and clicking on ''Form1'' (the label should be above the button).
+
* 新しい[[Form_Tutorial/ja#初めてのGUIアプリケーション|GUIアプリケーション]]フォーム、''Form1''を作る。このフォームにStandardコンポーネントタブでふさわしいコンポーネント、[[TButton/ja|TButton]]''Button1''と[[TLabel/ja|TLabel]]、''Label1''を選択し、''Form1''上でクリックする(ラベルはボタンの上にあるはずである)
* Create now a [[Event_order|event handler]] for ''Button1'', by simply double clicking on ''Button1''.
+
* ''Button1''上で単にダブルクリックすることで、''Button1''に対する[[Event_order|イベントハンドラ]]を作る。
* Insert following lines of code in the OnClick event handler of ''Button1'':
+
* ''Button1''のOnClickイベントハンドラのコードに以下の行を挿入する:
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
 
procedure TForm1.Button1Click(Sender: TObject);
 
procedure TForm1.Button1Click(Sender: TObject);
const Cnt: Integer = 0;                    //Counter to determine how many times the button has been clicked
+
const Cnt: Integer = 0;                    //何回ボタンがクリックされたか決めるカウンタ
 
begin
 
begin
   inc(Cnt);                                //Increment the counter by 1
+
   inc(Cnt);                                //カウンタを1インクリメント
   Label1.Caption:='Button was clicked ' +  //Write the text on the caption of Label1
+
   Label1.Caption:='Button was clicked ' +  //Label1のキャプションにテキストをを書き込む
 
     IntToStr(Cnt) + ' times';
 
     IntToStr(Cnt) + ' times';
 
end;
 
end;
 
</syntaxhighlight>
 
</syntaxhighlight>
* Start your program and test the change of the label caption by clicking the button.
+
* プログラムを起動しボタンをクリックすることでラベルが変わることを試そう。
  
==Delphi incompatibility for right-aligned labels==
+
== 右揃えしたラベルのDelphiとの非互換性==
* In Delphi, autosized labels with Alignment=taRightJustify but Anchors=[akLeft,...] grow to left. In LCL they grow to to right, starting with Lazarus 2.3.0.
+
* Delphiでは Alignment=taRightJustify で自動的にサイズ変更されるが、Anchors=[akLeft,...]は左向きに伸びる。LCLでは、Lazarus 2.3.0からそれらは右向きに伸びる。
*Reason: It wasn't possible to implement the behavior also for hidden labels without significant extensions in the LCL. The LCL has a different and more generic feature of control-based anchoring that delivers the same effect (see Remedy down), so it is not needed and wanted to double this feature and make the LCL code more complex and prone to bugs.
+
* 理由: LCLでは大きな伸長なしに不可視のラベルに対してもまた、その振る舞いを実装することが不可能であった。LCLは同様の効果をもたらすコーントロールに基づく異なる、より一般的な特徴を持たせてある(以下の救済策を見ること)。そのため、この機能を移殖して、LCLコードをいたずらに複雑かつ、バグの元とにする、必要も要求もないとした。
* Remedy: Use the LCL anchoring to a secondary control. Anchor the right side of the label to another control. Then the autosized label will grow to the left but won't move to the right when the parent is resized like it is done with a simple akRight anchor without a reference control.
+
* 救済策: 第2のコントロールにLCLアンカリングを使う。ラベルの右側を他のコントロールにアンカーさせる。そうすると自動サイズ化されたラベルが左に伸長するが、手本となるコントロールなしに、親が、単純なakRightアンカーを終えたようにリサイズされるとき、右には移動しない。
  
==Comments==
+
==コメント==
To represent a multiline text, you need to insert at the appropriate place in the string a ''[[End of Line|LineEnding]]'' as a word wrap signal.
+
複数行のテキストを表すため、行の折り返しの目印として、ふさわしい場所に''[[End of Line|LineEnding]]''を配置することができる。
Example:  
+
 
 +
:
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
 
Label1.Caption := 'This' + LineEnding + 'is' + LineEnding + 'a' + LineEnding + 'multiline' + LineEnding + 'text';
 
Label1.Caption := 'This' + LineEnding + 'is' + LineEnding + 'a' + LineEnding + 'multiline' + LineEnding + 'text';
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==See also==
+
==以下も参照のこと==
 
* [[doc:/lcl/stdctrls/tlabel.html|TLabel doc]]
 
* [[doc:/lcl/stdctrls/tlabel.html|TLabel doc]]
 
* [[TStaticText]]
 
* [[TStaticText]]
  
{{LCL Components}}
+
{{LCL Components/ja}}

Latest revision as of 06:48, 20 March 2024

Deutsch (de) English (en) suomi (fi) français (fr) 日本語 (ja) русский (ru)

日本語版メニュー
メインページ - Lazarus Documentation日本語版 - 翻訳ノート - 日本語障害情報

TLabel tlabel.pngは1、あるいは複数行のテキストアイテムを他のコンポーネントに作るコンポーネントである。TLabelはTGraphicControlより派生し、コンポーネントパレットStandardタブより利用できる。

使い方

TLabelはformsで用いることのできるもっとも基本的なコンポーネントの1つである。ほとんどのラベルは、例えば、Edit fieldsMemosStringGridsなどといった他のコンポーネントのマーキングである。TLabelは様々な利用可能なイベントをもたらすが、ほとんどの場合必要とされない。

StandardコンポーネントのTLabel(テキストシンボルAbc)をクリックすることにより、フォームにラベルを加えることができ、フォーム上にクリックして配置することができる。

フォームに新しく挿入された、デフォルトラベルLabelを変更するために、以下のように進めることができる:

  • フォーム上で1度クリックし、TLabelを選択する。
  • オブジェクトインスペクタタブのプロパティに移動する。
  • プロパティ、Captionを選択し、隣の編集フィールドで変更する。
  • 同様にしてプロパティ、Nameを選択し、よりよい名前に変更する。

実行時にキャプションを変更する

もちろん、実行中にキャプション(表示されるテキスト)を変えることができる。

以下の例はこれを示している:

  • 新しいGUIアプリケーションフォーム、Form1を作る。このフォームにStandardコンポーネントタブでふさわしいコンポーネント、TButtonButton1TLabelLabel1を選択し、Form1上でクリックする(ラベルはボタンの上にあるはずである)。
  • Button1上で単にダブルクリックすることで、Button1に対するイベントハンドラを作る。
  • Button1のOnClickイベントハンドラのコードに以下の行を挿入する:
procedure TForm1.Button1Click(Sender: TObject);
const Cnt: Integer = 0;                     //何回ボタンがクリックされたか決めるカウンタ
begin
  inc(Cnt);                                 //カウンタを1インクリメント
  Label1.Caption:='Button was clicked ' +   //Label1のキャプションにテキストをを書き込む
    IntToStr(Cnt) + ' times';
end;
  • プログラムを起動しボタンをクリックすることでラベルが変わることを試そう。

右揃えしたラベルのDelphiとの非互換性

  • Delphiでは Alignment=taRightJustify で自動的にサイズ変更されるが、Anchors=[akLeft,...]は左向きに伸びる。LCLでは、Lazarus 2.3.0からそれらは右向きに伸びる。
  • 理由: LCLでは大きな伸長なしに不可視のラベルに対してもまた、その振る舞いを実装することが不可能であった。LCLは同様の効果をもたらすコーントロールに基づく異なる、より一般的な特徴を持たせてある(以下の救済策を見ること)。そのため、この機能を移殖して、LCLコードをいたずらに複雑かつ、バグの元とにする、必要も要求もないとした。
  • 救済策: 第2のコントロールにLCLアンカリングを使う。ラベルの右側を他のコントロールにアンカーさせる。そうすると自動サイズ化されたラベルが左に伸長するが、手本となるコントロールなしに、親が、単純なakRightアンカーを終えたようにリサイズされるとき、右には移動しない。

コメント

複数行のテキストを表すため、行の折り返しの目印として、ふさわしい場所にLineEndingを配置することができる。

例:

Label1.Caption := 'This' + LineEnding + 'is' + LineEnding + 'a' + LineEnding + 'multiline' + LineEnding + 'text';

以下も参照のこと


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn/ja • TSpeedButton/ja • TStaticText/ja • TImage/ja • TShape/ja • TBevel/ja • TPaintBox/ja • TNotebook/ja • TLabeledEdit/ja • TSplitter/ja • TTrayIcon/ja • TControlBar/ja • TFlowPanel/ja • TMaskEdit/ja • TCheckListBox/ja • TScrollBox/ja • TApplicationProperties/ja • TStringGrid/ja • TDrawGrid/ja • TPairSplitter/ja • TColorBox/ja • TColorListBox/ja • TValueListEditor/ja
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator/ja • TDBText/ja • TDBEdit/ja • TDBMemo/ja • TDBImage/ja • TDBListBox/ja • TDBLookupListBox/ja • TDBComboBox/ja • TDBLookupComboBox/ja • TDBCheckBox/ja • TDBRadioGroup/ja • TDBCalendar/ja • TDBGroupBox/ja • TDBGrid/ja • TDBDateTimePicker/ja
Data Access TDataSource/ja • TCSVDataSet/ja • TSdfDataSet/ja • TBufDataset/ja • TFixedFormatDataSet/ja • TDbf/ja • TMemDataset/ja
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery/ja • TSQLTransaction/ja • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection/ja • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu