lcl: implement ClientToParent, ParentToClient based on patch of David Jenkins (issue #0021763)

git-svn-id: trunk@36775 -
This commit is contained in:
paul 2012-04-14 14:18:08 +00:00
parent a2ae31d2a0
commit c11192b6a5
24 changed files with 116 additions and 10 deletions

View File

@ -1523,6 +1523,8 @@ type
function ClientToScreen(const APoint: TPoint): TPoint; function ClientToScreen(const APoint: TPoint): TPoint;
function ScreenToControl(const APoint: TPoint): TPoint; function ScreenToControl(const APoint: TPoint): TPoint;
function ControlToScreen(const APoint: TPoint): TPoint; function ControlToScreen(const APoint: TPoint): TPoint;
function ClientToParent(const Point: TPoint; AParent: TWinControl = nil): TPoint;
function ParentToClient(const Point: TPoint; AParent: TWinControl = nil): TPoint;
function GetChildsRect(Scrolled: boolean): TRect; virtual; function GetChildsRect(Scrolled: boolean): TRect; virtual;
procedure Show; procedure Show;
procedure Update; virtual; procedure Update; virtual;
@ -2864,6 +2866,8 @@ begin
Include(Result, ssAlt); Include(Result, ssAlt);
if ((GetKeyState(VK_LWIN) and $8000) <> 0) or ((GetKeyState(VK_RWIN) and $8000) <> 0) then if ((GetKeyState(VK_LWIN) and $8000) <> 0) or ((GetKeyState(VK_RWIN) and $8000) <> 0) then
Include(Result, ssMeta); Include(Result, ssMeta);
if (GetKeyState(VK_LWIN) < 0) or (GetKeyState(VK_RWIN) < 0) then
Include(Result, ssMeta);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -1525,6 +1525,24 @@ begin
Result.Y := APoint.Y + P.Y; Result.Y := APoint.Y + P.Y;
end; end;
function TControl.ClientToParent(const Point: TPoint; AParent: TWinControl): TPoint;
begin
if not Assigned(AParent) then
AParent := Parent;
if not AParent.IsParentOf(Self) then
raise EInvalidOperation.CreateFmt(rsControlIsNotAParent, [AParent.Name, Name]);
Result := AParent.ScreenToClient(ClientToScreen(Point));
end;
function TControl.ParentToClient(const Point: TPoint; AParent: TWinControl): TPoint;
begin
if not Assigned(AParent) then
AParent := Parent;
if not AParent.IsParentOf(Self) then
raise EInvalidOperation.CreateFmt(rsControlIsNotAParent, [AParent.Name, Name]);
Result := ScreenToClient(AParent.ClientToScreen(Point));
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TControl.DblClick TControl.DblClick
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -4938,20 +4956,19 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TControl.IsParentOf(AControl: TControl): boolean; function TControl.IsParentOf(AControl: TControl): boolean;
begin begin
Result:=false; Result := False;
while AControl<>nil do begin while Assigned(AControl) do
begin
AControl := AControl.Parent; AControl := AControl.Parent;
if Self=AControl then begin if Self = AControl then
Result:=true; Exit(True);
exit;
end;
end; end;
end; end;
function TControl.GetTopParent: TControl; function TControl.GetTopParent: TControl;
begin begin
Result := Self; Result := Self;
while Result.Parent<>nil do while Assigned(Result.Parent) do
Result := Result.Parent; Result := Result.Parent;
end; end;

View File

@ -374,6 +374,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -374,6 +374,10 @@ msgstr "Prvek třídy '%s' nemůže mít prvek třídy '%s' jako dítě"
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Prvek '%s' nemá rodičovské okno" msgstr "Prvek '%s' nemá rodičovské okno"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Krémová" msgstr "Krémová"

View File

@ -376,6 +376,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Cremefarbig" msgstr "Cremefarbig"

View File

@ -373,6 +373,10 @@ msgstr "El control de clase '%s' no puede tener al control de clase '%s' como hi
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "El control '%s' no tiene ventana padre" msgstr "El control '%s' no tiene ventana padre"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Crema" msgstr "Crema"

View File

@ -367,6 +367,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -376,6 +376,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -372,6 +372,10 @@ msgstr "פקד של המחלקה '%s' לא יכול לקבל פקד של מחל
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "לפקד s% אין חלון הורה" msgstr "לפקד s% אין חלון הורה"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "קרמי" msgstr "קרמי"

View File

@ -375,6 +375,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -376,6 +376,10 @@ msgstr "Un controllo di classe '%s' non può avere figli di classe '%s'"
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Il controllo '%s' non ha finestra padre" msgstr "Il controllo '%s' non ha finestra padre"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Crema" msgstr "Crema"

View File

@ -375,6 +375,10 @@ msgstr "„%s“ klasės valdiklis negali būti „%s“ klasės valdiklio tėva
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "„%s“ valdiklis neturi tėvinio lango" msgstr "„%s“ valdiklis neturi tėvinio lango"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Kreminė" msgstr "Kreminė"

View File

@ -376,6 +376,10 @@ msgstr "Control of klasse '%s' kan control of klasse '%s' niet als kind hebben"
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Control '%s' heeft geen venster als ouder" msgstr "Control '%s' heeft geen venster als ouder"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Cream" msgstr "Cream"

View File

@ -374,6 +374,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -378,6 +378,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -367,6 +367,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -374,6 +374,10 @@ msgstr "Controle de classe '%s' não pode ter controle de classe '%s' como filho
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Controle '%s' não possui janela pai" msgstr "Controle '%s' não possui janela pai"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Creme" msgstr "Creme"

View File

@ -373,6 +373,10 @@ msgstr "Controle de classe '%s' não pode ter controle de classe '%s' como filho
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Controle '%s' não possui janela pai" msgstr "Controle '%s' não possui janela pai"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Creme" msgstr "Creme"

View File

@ -374,6 +374,10 @@ msgstr "Элемент управления класса '%s' не может и
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Элемент управления '%s' не имеет родительского окна" msgstr "Элемент управления '%s' не имеет родительского окна"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Кремовый" msgstr "Кремовый"

View File

@ -377,6 +377,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -374,6 +374,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -374,6 +374,10 @@ msgstr "Елемент управління класу '%s' не може мат
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "Елемент управління '%s' не має батьківського вінка" msgstr "Елемент управління '%s' не має батьківського вінка"
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "Кремовий" msgstr "Кремовий"

View File

@ -377,6 +377,10 @@ msgstr ""
msgid "Control '%s' has no parent window" msgid "Control '%s' has no parent window"
msgstr "" msgstr ""
#: lclstrconsts.rscontrolisnotaparent
msgid "'%s' is not a parent of '%s'"
msgstr ""
#: lclstrconsts.rscreamcolorcaption #: lclstrconsts.rscreamcolorcaption
msgid "Cream" msgid "Cream"
msgstr "" msgstr ""

View File

@ -253,6 +253,7 @@ resourceString
rsCreatingGdbCatchableError = 'Creating gdb catchable error:'; rsCreatingGdbCatchableError = 'Creating gdb catchable error:';
rsAControlCanNotHaveItselfAsParent = 'A control can''t have itself as a parent'; rsAControlCanNotHaveItselfAsParent = 'A control can''t have itself as a parent';
rsControlHasNoParentWindow = 'Control ''%s'' has no parent window'; rsControlHasNoParentWindow = 'Control ''%s'' has no parent window';
rsControlIsNotAParent = '''%s'' is not a parent of ''%s''';
rsControlClassCantContainChildClass = 'Control of class ''%s'' can''t have control of class ''%s'' as a child'; rsControlClassCantContainChildClass = 'Control of class ''%s'' can''t have control of class ''%s'' as a child';
lisLCLResourceSNotFound = 'Resource %s not found'; lisLCLResourceSNotFound = 'Resource %s not found';
rsFormResourceSNotFoundForResourcelessFormsCreateNew = 'Form resource %s ' rsFormResourceSNotFoundForResourcelessFormsCreateNew = 'Form resource %s '