Difference between revisions of "LCL Internals - Resizing, Moving/fr"

From Lazarus wiki
Jump to navigationJump to search
(ap)
Line 10: Line 10:
 
   TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);
 
   TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);
  
== How the Interface tells the LCL to resize/move a handle ==
+
== Comment l'interface dit à la bibliothèque LCL de redimensionner / déplacer une poignée ==
  
=== When the client area of a Handle was resized ===
+
=== Quand la zone client d'une poignée a été redimensionnée ===
  
''Note'': If the theme changes the frame of a TGroupBox can change. This leaves the Size and Position of the TGroupBox unchanged, but the client area can change. The interface calls
+
''Note'': Si le thème change le cadre d'un TGroupBox peu changer. Cela laisse la taille et la position du TGroupBox   inchangé, mais l'espace client peut changer. L'interface appelle
 
   LCLControl.InvalidateClientRectCache(false);
 
   LCLControl.InvalidateClientRectCache(false);
and sends a LM_SIZE message as below.
+
et envoie un message LM_SIZE comme ci-dessous.
  
=== When a Handle of a TWinControl was resized/moved ===
+
=== Quand une poignée d'un TWinControl a été redimensionnée / déplacée ===
  
==== First the LCL interface send a LM_WINDOWPOSCHANGED message ====
+
==== Tout d'abord, l'interface de la bibliothèque LCL envoie un message LM_WINDOWPOSCHANGED ====
* x := Left (relative to 0,0 of client area of parent)
+
* x := Left (par rapport à 0,0 de la zone cliente du parent)
 
* y := Top
 
* y := Top
 
* cx := Width
 
* cx := Width
 
* cy := Height
 
* cy := Height
  
==== Then a LM_SIZE message is sent ====
+
==== Ensuite, une message LM SIZE est envoyé ====
  
 
* Width
 
* Width
 
* Height
 
* Height
* SizeType is a bit flag containing Size_SourceIsInterface plus one of the values SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.
+
* SizeType est un drapeau d'un bit contenant Size_SourceIsInterface plus une des valeurs SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.
  
==== Then a LM_MOVE message is sent ====
+
==== Ensuite, une message LM_MOVE est envoyé ====
  
 
* MoveType := Move_SourceIsInterface;
 
* MoveType := Move_SourceIsInterface;
* XPos := Left (relative to 0,0 of client area of parent)
+
* XPos := Left (par rapport à 0,0 de la zone cliente du parent)
 
* YPos := Top
 
* YPos := Top
  
=== When a form is maximized, minimized or restored the interface sends a LM_SIZE message ===
+
=== Quand une form est à son maximum, minimisée ou restaurée l'interface envoie un message LM_SIZE ===
  
 
* Width
 
* Width
 
* Height  
 
* Height  
* SizeType is a bit flag containing Size_SourceIsInterface plus one of the values SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.
+
* SizeType est un drapeau d'un bit contenant Size_SourceIsInterface plus une des valeurs SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.
  
 
== How the LCL gets the current size / position of a LCL interface handle ==
 
== How the LCL gets the current size / position of a LCL interface handle ==

Revision as of 11:41, 15 July 2009

English (en) français (fr)

Présentation

La bibliothèque LCL a beaucoup de propriétés de redimensionnement (Left, Width, Anchors, Align, AnchorSide, AutoSize, Constraints, ChildSizing, ...) et des hooks(points d'encrage) où les applications peut modifier le comportement (OnResize, OnChangeBounds, ...). Toutes ces choses ne peuvent pas être calculés en une seule étape, ainsi les commandes peuvent se déplacer énormément avant les coordonnées finales sortent . Pour réduire le scintillement la bibliothèque LCL n'envoit pas tous les déplacements ou redimensionnement à l'interface de la bibliothèque LCL. Par exemple, au cours des Begin/EndAlign et csLoading aucun move/resize est envoyée à l'interface. Le widgetset va essayer de suivre les conseils de la bibliothèque LCL, mais il y a quelques cas, où il ne les suit pas. Par exemple, les forms (fenêtres de haut niveau) sont limités par les politiques de gestion de fenêtres. Et TPage dépend entièrement de la taille et du thème de TNotebook.

Comment la bibliothèque LCL indique à l'interface de redimensionner / déplacer une poignée(handle)

Dans TWinControl.DoSendBoundsToInterface la fonction widget SetBounds est appelée

 TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);

Comment l'interface dit à la bibliothèque LCL de redimensionner / déplacer une poignée

Quand la zone client d'une poignée a été redimensionnée

Note: Si le thème change le cadre d'un TGroupBox peu changer. Cela laisse la taille et la position du TGroupBox inchangé, mais l'espace client peut changer. L'interface appelle

 LCLControl.InvalidateClientRectCache(false);

et envoie un message LM_SIZE comme ci-dessous.

Quand une poignée d'un TWinControl a été redimensionnée / déplacée

Tout d'abord, l'interface de la bibliothèque LCL envoie un message LM_WINDOWPOSCHANGED

  • x := Left (par rapport à 0,0 de la zone cliente du parent)
  • y := Top
  • cx := Width
  • cy := Height

Ensuite, une message LM SIZE est envoyé

  • Width
  • Height
  • SizeType est un drapeau d'un bit contenant Size_SourceIsInterface plus une des valeurs SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.

Ensuite, une message LM_MOVE est envoyé

  • MoveType := Move_SourceIsInterface;
  • XPos := Left (par rapport à 0,0 de la zone cliente du parent)
  • YPos := Top

Quand une form est à son maximum, minimisée ou restaurée l'interface envoie un message LM_SIZE

  • Width
  • Height
  • SizeType est un drapeau d'un bit contenant Size_SourceIsInterface plus une des valeurs SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.

How the LCL gets the current size / position of a LCL interface handle

LCLIntf.GetWindowSize(Handle, InterfaceWidth, InterfaceHeight)

Returns the current width and height of a Handle.

LCLIntf.GetClientRect(Handle, Result)

Returns the current width and height (left and top are always 0) of the client area of a Handle (= inner area inside the border/frame of a control).

TWSWinControlClass(WidgetSetClass).GetDefaultClientRect(Self, Left, Top, Width, Height, Result)

This function is called first by the LCL to get the ClientRect. If it returns false, the LCL will use GetClientRect if it has already created a handle, otherwise the values loaded from the .lfm. If all this fails, the default is Rect(0,0,Width,Height). GetDefaultClientRect can be used by the LCL interface to reduce flickering by providing good values before the handle is created.

GetWindowRelativePosition(Handle,NewLeft,NewTop)

Returns the current Left, Top of a Handle relative to the client area (0,0) of its parent.

Constraints

The LCL asks the interface for constraints (min, max for width and height) with the function

 GetControlConstraints

For example: Under gtk a horizontal scrollbar has a fixed height.

Preferred Size

To autosize a control (e.g. a TButton or a TLabel) the LCL asks the interface about the minimum size to render a control nicely:

 TWSWinControlClass(WidgetSetClass).GetPreferredSize(Self, PreferredWidth, PreferredHeight, WithThemeSpace);

Scrolling

The LCL scrolls child controls only virtually. That means, their Left,Top properties do not change. To scroll it uses the LCL interface function

 TWSScrollingWinControlClass(WidgetSetClass).ScrollBy(Self, DeltaX, DeltaY);

Miscellaneous

LCLIntf.GetClientBounds(Handle,Result);

Returns the unscrolled client rectangle relative to the top, left of the Handle. In other words it is equivalent to:

 CurClientBounds := GetClientRect(Handle)
 OffsetRect(CurClientBounds,FrameBorderLeft,FrameBorderTop);