X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgx%2Fgh_ui.pas;h=4f4133f84d38bcf13ae95ea22a2f367f0f55ce29;hb=007b3a8fcfe260417aa379da9e6b4e84ddc028d4;hp=812fae7bda427e97be0ca26ab906b99376b0e464;hpb=d369479ca2035870351aa379fae1f9aea6a324e6;p=d2df-sdl.git diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas index 812fae7..4f4133f 100644 --- a/src/gx/gh_ui.pas +++ b/src/gx/gh_ui.pas @@ -318,7 +318,19 @@ type procedure AfterConstruction (); override; // so it will be correctly initialized when created from parser end; + // ////////////////////////////////////////////////////////////////////// // + THCtlSpan = class(THControl) + public + constructor Create (); + procedure AfterConstruction (); override; // so it will be correctly initialized when created from parser + + function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override; + + procedure drawControl (gx, gy: Integer); override; + end; + + // ////////////////////////////////////////////////////////////////////// // THCtlTextLabel = class(THControl) private mText: AnsiString; @@ -714,10 +726,10 @@ var ech: AnsiChar = ')'; begin if (par.eatDelim('[')) then ech := ']' else par.expectDelim('('); - result.h := par.expectInt(); - par.eatDelim(','); // optional comma result.w := par.expectInt(); par.eatDelim(','); // optional comma + result.h := par.expectInt(); + par.eatDelim(','); // optional comma par.expectDelim(ech); end; @@ -876,8 +888,13 @@ begin if (strEquCI1251(prname, 'id')) then begin mId := par.expectStrOrId(true); exit; end; // allow empty strings if (strEquCI1251(prname, 'flex')) then begin flex := par.expectInt(); exit; end; // sizes - if (strEquCI1251(prname, 'defsize')) then begin mDefSize := parseSize(par); exit; end; + if (strEquCI1251(prname, 'defsize')) or (strEquCI1251(prname, 'size')) then begin mDefSize := parseSize(par); exit; end; if (strEquCI1251(prname, 'maxsize')) then begin mMaxSize := parseSize(par); exit; end; + if (strEquCI1251(prname, 'defwidth')) or (strEquCI1251(prname, 'width')) then begin mDefSize.w := par.expectInt(); exit; end; + if (strEquCI1251(prname, 'defheight')) or (strEquCI1251(prname, 'height')) then begin mDefSize.h := par.expectInt(); exit; end; + if (strEquCI1251(prname, 'maxwidth')) then begin mMaxSize.w := par.expectInt(); exit; end; + if (strEquCI1251(prname, 'maxheight')) then begin mMaxSize.h := par.expectInt(); exit; end; + // flags if (strEquCI1251(prname, 'wrap')) then begin mCanWrap := parseBool(par); exit; end; if (strEquCI1251(prname, 'linestart')) then begin mLineStart := parseBool(par); exit; end; if (strEquCI1251(prname, 'expand')) then begin mExpand := parseBool(par); exit; end; @@ -1798,7 +1815,7 @@ begin if (strEquCI1251(prname, 'title')) or (strEquCI1251(prname, 'caption')) then begin mCaption := par.expectStrOrId(true); - mDefSize := TLaySize.Create(Length(mCaption)*8+2, 8); + mDefSize := TLaySize.Create(Length(mCaption)*8+3, 8); result := true; exit; end; @@ -1827,9 +1844,9 @@ begin if (Length(mCaption) > 0) then begin setScissor(mFrameWidth+1, 0, mWidth-mFrameWidth-2, 8); - tx := gx+((mWidth-Length(mCaption)*8) div 2)-1; - if mHasFrame then fillRect(tx, gy, Length(mCaption)*8+2, 8, 0, 0, 128); - drawText8(tx+1, gy, mCaption, r, g, b); + tx := gx+((mWidth-Length(mCaption)*8) div 2); + if mHasFrame then fillRect(tx-2, gy, Length(mCaption)*8+3, 8, 0, 0, 128); + drawText8(tx, gy, mCaption, r, g, b); end; end; @@ -1868,6 +1885,40 @@ begin mHoriz := false; end; + +// ////////////////////////////////////////////////////////////////////////// // +constructor THCtlSpan.Create (); +begin + inherited Create(); + mExpand := true; +end; + +function THCtlSpan.parseProperty (const prname: AnsiString; par: TTextParser): Boolean; +begin + if (strEquCI1251(prname, 'orientation')) or (strEquCI1251(prname, 'orient')) then + begin + if (par.eatIdOrStr('horizontal', false)) or (par.eatIdOrStr('horiz', false)) then mHoriz := true + else if (par.eatIdOrStr('vertical', false)) or (par.eatIdOrStr('vert', false)) then mHoriz := false + else par.error('`horizontal` or `vertical` expected'); + result := true; + exit; + end; + result := inherited parseProperty(prname, par); +end; + +procedure THCtlSpan.drawControl (gx, gy: Integer); +begin +end; + + +procedure THCtlSpan.AfterConstruction (); +begin + inherited AfterConstruction(); + //mDefSize := TLaySize.Create(0, 8); + mExpand := true; +end; + + // ////////////////////////////////////////////////////////////////////////// // constructor THCtlTextLabel.Create (const atext: AnsiString); begin @@ -1943,5 +1994,6 @@ initialization registerCtlClass(THCtlBox, 'box'); registerCtlClass(THCtlHBox, 'hbox'); registerCtlClass(THCtlVBox, 'vbox'); + registerCtlClass(THCtlSpan, 'span'); registerCtlClass(THCtlTextLabel, 'label'); end.