LayoutEngine クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
解説
カスタム レイアウトの実行時の動作を作成するには LayoutEngine クラスを使用します。LayoutEngine クラスから独自のクラスを派生し、Layout メソッドをオーバーライドして、カスタム レイアウト動作を定義します。
LayoutEngine クラスを使用してカスタム レイアウト動作を実装する方法を示すコード例を次に示します。
Imports System Imports System.Collections.Generic Imports System.Drawing Imports System.Text Imports System.Windows.Forms Imports System.Windows.Forms.Layout ' This class demonstrates a simple custom layout panel. ' It overrides the LayoutEngine property of the Panel ' control to provide a custom layout engine. Public Class DemoFlowPanel Inherits Panel Private layoutEng As DemoFlowLayout Public Sub New() End Sub Public Overrides ReadOnly Property LayoutEngine() As LayoutEngine Get If layoutEng Is Nothing Then layoutEng = New DemoFlowLayout() End If Return layoutEng End Get End Property End Class ' This class demonstrates a simple custom layout engine. Public Class DemoFlowLayout Inherits LayoutEngine Public Overrides Function Layout( _ ByVal container As Object, _ ByVal layoutEventArgs As LayoutEventArgs) As Boolean Dim parent As Control = container ' Use DisplayRectangle so that parent.Padding is honored. Dim parentDisplayRectangle As Rectangle = parent.DisplayRectangle Dim nextControlLocation As Point = parentDisplayRectangle.Location Dim c As Control For Each c In parent.Controls ' Only apply layout to visible controls. If c.Visible <> True Then Continue For End If ' Respect the margin of the control: ' shift over the left and the top. nextControlLocation.Offset(c.Margin.Left, c.Margin.Top) ' Set the location of the control. c.Location = nextControlLocation ' Set the autosized controls to their ' autosized heights. If c.AutoSize Then c.Size = c.GetPreferredSize(parentDisplayRectangle.Size) End If ' Move X back to the display rectangle origin. nextControlLocation.X = parentDisplayRectangle.X ' Increment Y by the height of the control ' and the bottom margin. nextControlLocation.Y += c.Height + c.Margin.Bottom Next c ' Optional: Return whether or not the container's ' parent should perform layout as a result of this ' layout. Some layout engines return the value of ' the container's AutoSize property. Return False End Function End Class
using System; using System.Collections.Generic; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Windows.Forms.Layout; // This class demonstrates a simple custom layout panel. // It overrides the LayoutEngine property of the Panel // control to provide a custom layout engine. public class DemoFlowPanel : Panel { private DemoFlowLayout layoutEngine; public DemoFlowPanel() { } public override LayoutEngine LayoutEngine { get { if (layoutEngine == null) { layoutEngine = new DemoFlowLayout(); } return layoutEngine; } } } // This class demonstrates a simple custom layout engine. public class DemoFlowLayout : LayoutEngine { public override bool Layout( object container, LayoutEventArgs layoutEventArgs) { Control parent = container as Control; // Use DisplayRectangle so that parent.Padding is honored. Rectangle parentDisplayRectangle = parent.DisplayRectangle; Point nextControlLocation = parentDisplayRectangle.Location; foreach (Control c in parent.Controls) { // Only apply layout to visible controls. if (!c.Visible) { continue; } // Respect the margin of the control: // shift over the left and the top. nextControlLocation.Offset(c.Margin.Left, c.Margin.Top); // Set the location of the control. c.Location = nextControlLocation; // Set the autosized controls to their // autosized heights. if (c.AutoSize) { c.Size = c.GetPreferredSize(parentDisplayRectangle.Size); } // Move X back to the display rectangle origin. nextControlLocation.X = parentDisplayRectangle.X; // Increment Y by the height of the control // and the bottom margin. nextControlLocation.Y += c.Height + c.Margin.Bottom; } // Optional: Return whether or not the container's // parent should perform layout as a result of this // layout. Some layout engines return the value of // the container's AutoSize property. return false; } }
#using <System.Drawing.dll> #using <System.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Collections::Generic; using namespace System::Drawing; using namespace System::Text; using namespace System::Windows::Forms; using namespace System::Windows::Forms::Layout; // This class demonstrates a simple custom layout engine. public ref class DemoFlowLayout : public LayoutEngine { public: virtual bool Layout(Object^ container, LayoutEventArgs^ layoutEventArgs) override { Control^ parent = nullptr; try { parent = (Control ^) container; } catch (InvalidCastException^ ex) { throw gcnew ArgumentException( "The parameter 'container' must be a control", "container", ex); } // Use DisplayRectangle so that parent.Padding is honored. Rectangle parentDisplayRectangle = parent->DisplayRectangle; Point nextControlLocation = parentDisplayRectangle.Location; for each (Control^ currentControl in parent->Controls) { // Only apply layout to visible controls. if (!currentControl->Visible) { continue; } // Respect the margin of the control: // shift over the left and the top. nextControlLocation.Offset(currentControl->Margin.Left, currentControl->Margin.Top); // Set the location of the control. currentControl->Location = nextControlLocation; // Set the autosized controls to their // autosized heights. if (currentControl->AutoSize) { currentControl->Size = currentControl->GetPreferredSize( parentDisplayRectangle.Size); } // Move X back to the display rectangle origin. nextControlLocation.X = parentDisplayRectangle.X; // Increment Y by the height of the control // and the bottom margin. nextControlLocation.Y += currentControl->Height + currentControl->Margin.Bottom; } // Optional: Return whether or not the container's // parent should perform layout as a result of this // layout. Some layout engines return the value of // the container's AutoSize property. return false; } }; // This class demonstrates a simple custom layout panel. // It overrides the LayoutEngine property of the Panel // control to provide a custom layout engine. public ref class DemoFlowPanel : public Panel { private: DemoFlowLayout^ layoutEngine; public: DemoFlowPanel() { layoutEngine = gcnew DemoFlowLayout(); } public: virtual property System::Windows::Forms::Layout::LayoutEngine^ LayoutEngine { System::Windows::Forms::Layout::LayoutEngine^ get() override { if (layoutEngine == nullptr) { layoutEngine = gcnew DemoFlowLayout(); } return layoutEngine; } } };
System.Windows.Forms.Layout.LayoutEngine
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
LayoutEngine コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
解説
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
LayoutEngine メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
InitLayout | レイアウト エンジンを初期化します。 | |
Layout | レイアウト エンジンにレイアウト操作の実行を要求します。 | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
LayoutEngine メンバ
レイアウト エンジンを実装するための基本クラスを提供します。
LayoutEngine データ型で公開されるメンバを以下の表に示します。
プロテクト コンストラクタ
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
InitLayout | レイアウト エンジンを初期化します。 | |
Layout | レイアウト エンジンにレイアウト操作の実行を要求します。 | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
レンダリングエンジン
(LayoutEngine から転送)
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2021/07/28 10:03 UTC 版)
ナビゲーションに移動 検索に移動レンダリングエンジン (rendering engine) とは、レンダリングを行うソフトウェア部品。情報(データ)を読み込んで、特定のルールにしたがい適切な表現に変換する役割を担う。レイアウトエンジン (layout engine)、レンダラー (renderer) ともいう。
情報がデジタルデータの場合、適切にレンダリングを行うためには、レンダラーの書式(フォーマット)に従って保存されていることが必要となり、また一般的にデータの名前やデータ中のヘッダーにレンダラーの条件が付けられる。例えばコンピュータにおいて、記憶装置中に格納されたある領域に羅列するデータ列が、書式に従ってデータの名前、形式、データの始まり、データの終わり、エラー訂正のための冗長情報などが書かれていれば、これを適切なレンダラーが読み込むことで、「ファイル」として認識することができる。この場合の書式はファイルシステムが定義しており、「ファイラー」がレンダリングエンジンとして機能している。
アプリケーション・ソフトウェア内部に組み込まれていることもあるが、独立したライブラリとして提供されたり、ソフトウェアどうしの連携によって外部から利用されることもある。多くのコンピューターで、上記の「ファイル」として認識されたデータをさらに別のレンダラーが連携で読み込み利用している。
実例
関連項目
- LayoutEngineのページへのリンク