From: Ketmar Dark Date: Tue, 26 Sep 2017 06:27:29 +0000 (+0300) Subject: HolmesUI: "position" property for windows X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=313f52c372a4fe70cdfb3fdfaf845b95e05be9d4;p=d2df-sdl.git HolmesUI: "position" property for windows --- diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas index 46bbbf6..ee54d5c 100644 --- a/src/gx/gh_ui.pas +++ b/src/gx/gh_ui.pas @@ -216,6 +216,7 @@ type mWaitingClose: Boolean; mInClose: Boolean; mFreeOnClose: Boolean; // default: false + mDoCenter: Boolean; // after layouting protected procedure activated (); override; @@ -464,6 +465,11 @@ begin lay.layout(); //writeln('=== final ==='); lay.dump(); + if (ctl.mParent = nil) and (ctl is THTopWindow) and (THTopWindow(ctl).mDoCenter) then + begin + THTopWindow(ctl).centerInScreen(); + end; + finally FreeAndNil(lay); end; @@ -1420,6 +1426,14 @@ begin result := true; exit; end; + if (strEquCI1251(prname, 'position')) then + begin + if (par.eatIdOrStr('default', false)) then mDoCenter := false + else if (par.eatIdOrStr('center', false)) then mDoCenter := true + else par.error('`center` or `default` expected'); + result := true; + exit; + end; if (parseOrientation(prname, par)) then begin result := true; exit; end; result := inherited parseProperty(prname, par); end; diff --git a/src/shared/xparser.pas b/src/shared/xparser.pas index 0f2c2ec..a3e39ce 100644 --- a/src/shared/xparser.pas +++ b/src/shared/xparser.pas @@ -112,6 +112,7 @@ type procedure expectId (const aid: AnsiString; caseSens: Boolean=true); function eatId (const aid: AnsiString; caseSens: Boolean=true): Boolean; function eatIdOrStr (const aid: AnsiString; caseSens: Boolean=true): Boolean; + function eatIdOrStrCI (const aid: AnsiString): Boolean; inline; function expectStr (allowEmpty: Boolean=false): AnsiString; function expectInt (): Integer; @@ -710,6 +711,12 @@ begin end; +function TTextParser.eatIdOrStrCI (const aid: AnsiString): Boolean; inline; +begin + result := eatIdOrStr(aid, false); +end; + + function TTextParser.expectStr (allowEmpty: Boolean=false): AnsiString; begin if (mTokType <> TTStr) then raise Exception.Create('string expected');