summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 007b3a8)
raw | patch | inline | side by side (parent: 007b3a8)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 25 Sep 2017 21:09:49 +0000 (00:09 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 25 Sep 2017 21:10:29 +0000 (00:10 +0300) |
src/gx/gh_flexlay.pas | patch | blob | history | |
src/gx/gh_ui.pas | patch | blob | history |
diff --git a/src/gx/gh_flexlay.pas b/src/gx/gh_flexlay.pas
index 9692f0d1353f0319fb407204f7feb37dcf8338de..0f5d9286fe289a96a85d723736c78aff288b7a90 100644 (file)
--- a/src/gx/gh_flexlay.pas
+++ b/src/gx/gh_flexlay.pas
private
type LayControlIdx = Integer;
+ private
+ class function nminX (a, b: Integer): Integer; inline;
+
private
// flags
const
utils;
+// ////////////////////////////////////////////////////////////////////////// //
+class function TFlexLayouterBase.nminX (a, b: Integer): Integer; inline;
+begin
+ if (a < 0) then begin if (b < 0) then result := 0 else result := b; end
+ else if (b < 0) or (a < b) then result := a
+ else result := b;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
procedure TFlexLayouterBase.TLayControl.initialize (); inline;
begin
if (lc.startsize.w < 0) then lc.startsize.w := 0;
if (lc.startsize.h < 0) then lc.startsize.h := 0;
lc.maxsize := msz;
- if (lc.maxsize.w < lc.startsize.w) then lc.maxsize.w := lc.startsize.w;
- if (lc.maxsize.h < lc.startsize.h) then lc.maxsize.h := lc.startsize.h;
+ if (lc.maxsize.w < lc.startsize.w) then begin if (lc.maxsize.w >= 0) then lc.maxsize.w := lc.startsize.w; end;
+ if (lc.maxsize.h < lc.startsize.h) then begin if (lc.maxsize.h >= 0) then lc.maxsize.h := lc.startsize.h; end;
end;
end;
end;
// expand or align
- if (lc.expand) then lc.desiredsize.h := nmin(lc.maxsize.h, lineh) // expand
+ if (lc.expand) then lc.desiredsize.h := nminX(lc.maxsize.h, lineh) // expand
else if (lc.alignBottom) then lc.desiredpos.y := cury+(lineh-lc.desiredsize.h) // bottom align
else if (lc.alignCenter) then lc.desiredpos.y := cury+(lineh-lc.desiredsize.h) div 2; // center
if (not osz.equals(lc.desiredsize)) then
end;
end;
// expand or align
- if (lc.expand) then lc.desiredsize.w := nmin(lc.maxsize.w, me.desiredsize.w-me.margins.vert) // expand
+ if (lc.expand) then lc.desiredsize.w := nminX(lc.maxsize.w, me.desiredsize.w-me.margins.vert) // expand
else if (lc.alignRight) then lc.desiredpos.x := me.desiredsize.w-me.margins.right-lc.desiredsize.w // right align
else if (lc.alignCenter) then lc.desiredpos.x := (me.desiredsize.w-lc.desiredsize.w) div 2; // center
if (not osz.equals(lc.desiredsize)) then
diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas
index 4f4133f84d38bcf13ae95ea22a2f367f0f55ce29..8875f7dd1c82e2102055260da504faf3fd6e4530 100644 (file)
--- a/src/gx/gh_ui.pas
+++ b/src/gx/gh_ui.pas
function parseAnyAlign (par: TTextParser): Integer;
function parseHAlign (par: TTextParser): Integer;
function parseVAlign (par: TTextParser): Integer;
+ function parseOrientation (const prname: AnsiString; par: TTextParser): Boolean;
procedure parseTextAlign (par: TTextParser; var h, v: Integer);
procedure parseChildren (par: TTextParser); // par should be on '{'; final '}' is eaten
// ////////////////////////////////////////////////////////////////////// //
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;
+ // ////////////////////////////////////////////////////////////////////// //
+ THCtlLine = class(THControl)
+ public
+ function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
+
+ procedure drawControl (gx, gy: Integer); override;
+ end;
+
+ THCtlHLine = class(THCtlLine)
+ public
+ procedure AfterConstruction (); override; // so it will be correctly initialized when created from parser
+ end;
+
+ THCtlVLine = class(THCtlLine)
+ public
+ procedure AfterConstruction (); override; // so it will be correctly initialized when created from parser
+ end;
+
// ////////////////////////////////////////////////////////////////////// //
THCtlTextLabel = class(THControl)
private
public
constructor Create (const atext: AnsiString);
- //destructor Destroy (); override;
+
+ procedure AfterConstruction (); override; // so it will be correctly initialized when created from parser
function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
if not wasV and not wasH then par.error('invalid align value');
end;
+function THControl.parseOrientation (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;
+ end
+ else
+ begin
+ result := false;
+ end;
+end;
+
// par should be on '{'; final '}' is eaten
procedure THControl.parseProperties (par: TTextParser);
var
result := true;
exit;
end;
- 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;
+ if (parseOrientation(prname, par)) then begin result := true; exit; end;
result := inherited parseProperty(prname, par);
end;
begin
inherited Create();
mHoriz := ahoriz;
+ mCanFocus := false;
end;
function THCtlBox.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;
+ if (parseOrientation(prname, par)) then begin result := true; exit; end;
if (strEquCI1251(prname, 'frame')) then
begin
mHasFrame := parseBool(par);
begin
inherited AfterConstruction();
mHoriz := false;
+ mCanFocus := false;
end;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THCtlSpan.Create ();
+procedure THCtlSpan.AfterConstruction ();
begin
- inherited Create();
+ inherited AfterConstruction();
mExpand := true;
+ mCanFocus := false;
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;
+ if (parseOrientation(prname, par)) then begin result := true; exit; end;
result := inherited parseProperty(prname, par);
end;
+
procedure THCtlSpan.drawControl (gx, gy: Integer);
begin
end;
-procedure THCtlSpan.AfterConstruction ();
+// ////////////////////////////////////////////////////////////////////// //
+function THCtlLine.parseProperty (const prname: AnsiString; par: TTextParser): Boolean;
begin
- inherited AfterConstruction();
- //mDefSize := TLaySize.Create(0, 8);
+ if (parseOrientation(prname, par)) then begin result := true; exit; end;
+ result := inherited parseProperty(prname, par);
+end;
+
+
+procedure THCtlLine.drawControl (gx, gy: Integer);
+begin
+ if mHoriz then
+ begin
+ drawHLine(gx, gy+(mHeight div 2), mWidth, 255, 255, 255);
+ end
+ else
+ begin
+ drawVLine(gx+(mWidth div 2), gy, mHeight, 255, 255, 255);
+ end;
+ //fillRect(gx, gy, mWidth, mHeight, 255, 0, 0);
+end;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+procedure THCtlHLine.AfterConstruction ();
+begin
+ mHoriz := true;
mExpand := true;
+ mDefSize.h := 1;
+end;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+procedure THCtlVLine.AfterConstruction ();
+begin
+ mHoriz := false;
+ mExpand := true;
+ mDefSize.w := 1;
+ //mDefSize.h := 8;
end;
constructor THCtlTextLabel.Create (const atext: AnsiString);
begin
inherited Create();
- mHAlign := -1;
- mVAlign := 0;
mText := atext;
mDefSize := TLaySize.Create(Length(atext)*8, 8);
end;
+procedure THCtlTextLabel.AfterConstruction ();
+begin
+ inherited AfterConstruction();
+ mHAlign := -1;
+ mVAlign := 0;
+ mCanFocus := false;
+ if (mDefSize.h <= 0) then mDefSize.h := 8;
+end;
+
+
function THCtlTextLabel.parseProperty (const prname: AnsiString; par: TTextParser): Boolean;
begin
if (strEquCI1251(prname, 'title')) or (strEquCI1251(prname, 'caption')) then
initialization
- registerCtlClass(THCtlBox, 'box');
registerCtlClass(THCtlHBox, 'hbox');
registerCtlClass(THCtlVBox, 'vbox');
registerCtlClass(THCtlSpan, 'span');
+ registerCtlClass(THCtlHLine, 'hline');
+ registerCtlClass(THCtlVLine, 'vline');
registerCtlClass(THCtlTextLabel, 'label');
end.