diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas
index c37b1c1dab196c141384ec106d502db9772b663b..85a4a5ff67af8b0dfc792556119c218d9fbbb749 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;
procedure THTopWindow.drawControl (gx, gy: Integer);
begin
- fillRect(gx, gy, mWidth, mHeight, 0, 0, 128);
+ fillRect(gx, gy, mWidth, mHeight, TGxRGBA.Create(0, 0, 128));
end;
begin
if mDragging then
begin
- drawRectUI(mX+4, mY+4, mWidth-8, mHeight-8, r, g, b);
+ drawRectUI(mX+4, mY+4, mWidth-8, mHeight-8, TGxRGBA.Create(r, g, b));
end
else
begin
- drawRectUI(mX+3, mY+3, mWidth-6, mHeight-6, r, g, b);
- drawRectUI(mX+5, mY+5, mWidth-10, mHeight-10, r, g, b);
+ drawRectUI(mX+3, mY+3, mWidth-6, mHeight-6, TGxRGBA.Create(r, g, b));
+ drawRectUI(mX+5, mY+5, mWidth-10, mHeight-10, TGxRGBA.Create(r, g, b));
setScissor(mFrameWidth, 0, 3*8, 8);
- fillRect(mX+mFrameWidth, mY, 3*8, 8, 0, 0, 128);
- drawText8(mX+mFrameWidth, mY, '[ ]', r, g, b);
- if mInClose then drawText8(mX+mFrameWidth+7, mY, '#', 0, 255, 0)
- else drawText8(mX+mFrameWidth+7, mY, '*', 0, 255, 0);
+ fillRect(mX+mFrameWidth, mY, 3*8, 8, TGxRGBA.Create(0, 0, 128));
+ drawText8(mX+mFrameWidth, mY, '[ ]', TGxRGBA.Create(r, g, b));
+ if mInClose then drawText8(mX+mFrameWidth+7, mY, '#', TGxRGBA.Create(0, 255, 0))
+ else drawText8(mX+mFrameWidth+7, mY, '*', TGxRGBA.Create(0, 255, 0));
end;
if (Length(mTitle) > 0) then
begin
setScissor(mFrameWidth+3*8, 0, mWidth-mFrameWidth*2-3*8, 8);
tx := (mX+3*8)+((mWidth-3*8)-Length(mTitle)*8) div 2;
- fillRect(tx-3, mY, Length(mTitle)*8+3+2, 8, 0, 0, 128);
- drawText8(tx, mY, mTitle, r, g, b);
+ fillRect(tx-3, mY, Length(mTitle)*8+3+2, 8, TGxRGBA.Create(0, 0, 128));
+ drawText8(tx, mY, mTitle, TGxRGBA.Create(r, g, b));
end;
inherited drawControlPost(gx, gy);
end;
b := 255;
if (Length(it.title) = 0) then
begin
- drawHLine(gx+4, gy+3, mWidth-8, r, g, b);
+ drawHLine(gx+4, gy+3, mWidth-8, TGxRGBA.Create(r, g, b));
end
else if (tx-3 > gx+4) then
begin
- drawHLine(gx+4, gy+3, tx-3-(gx+3), r, g, b);
- drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, r, g, b);
+ drawHLine(gx+4, gy+3, tx-3-(gx+3), TGxRGBA.Create(r, g, b));
+ drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, TGxRGBA.Create(r, g, b));
end;
end;
- drawText8(tx, gy, it.title, r, g, b);
+ drawText8(tx, gy, it.title, TGxRGBA.Create(r, g, b));
Inc(gy, 8);
end;
end;
for f := 0 to High(mItems) do
begin
it := @mItems[f];
- if (mCurIndex = f) then fillRect(gx, gy, mWidth, 8, 0, 128, 0);
+ if (mCurIndex = f) then fillRect(gx, gy, mWidth, 8, TGxRGBA.Create(0, 128, 0));
if (it.varp <> nil) then
begin
- if it.varp^ then drawText8(gx, gy, '[x]', 255, 255, 255) else drawText8(gx, gy, '[ ]', 255, 255, 255);
- drawText8(gx+3*8+2, gy, it.title, 255, 255, 0);
+ if it.varp^ then drawText8(gx, gy, '[x]', TGxRGBA.Create(255, 255, 255)) else drawText8(gx, gy, '[ ]', TGxRGBA.Create(255, 255, 255));
+ drawText8(gx+3*8+2, gy, it.title, TGxRGBA.Create(255, 255, 0));
end
else if (Length(it.title) > 0) then
begin
tx := gx+(mWidth-Length(it.title)*8) div 2;
if (tx-3 > gx+4) then
begin
- drawHLine(gx+4, gy+3, tx-3-(gx+3), 255, 255, 255);
- drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, 255, 255, 255);
+ drawHLine(gx+4, gy+3, tx-3-(gx+3), TGxRGBA.Create(255, 255, 255));
+ drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, TGxRGBA.Create(255, 255, 255));
end;
- drawText8(tx, gy, it.title, 255, 255, 255);
+ drawText8(tx, gy, it.title, TGxRGBA.Create(255, 255, 255));
end
else
begin
- drawHLine(gx+4, gy+3, mWidth-8, 255, 255, 255);
+ drawHLine(gx+4, gy+3, mWidth-8, TGxRGBA.Create(255, 255, 255));
end;
Inc(gy, 8);
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);
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;
if mHasFrame then
begin
// draw frame
- drawRectUI(gx+3, gy+3, mWidth-6, mHeight-6, r, g, b);
+ drawRectUI(gx+3, gy+3, mWidth-6, mHeight-6, TGxRGBA.Create(r, g, b));
end;
// draw caption
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, TGxRGBA.Create(0, 0, 128));
+ drawText8(tx, gy, mCaption, TGxRGBA.Create(r, g, b));
end;
end;
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, TGxRGBA.Create(255, 255, 255));
+ end
+ else
+ begin
+ drawVLine(gx+(mWidth div 2), gy, mHeight, TGxRGBA.Create(255, 255, 255));
+ end;
+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
xpos, ypos: Integer;
begin
// debug
- fillRect(gx, gy, mWidth, mHeight, 96, 96, 0);
- drawRectUI(gx, gy, mWidth, mHeight, 96, 96, 96);
+ fillRect(gx, gy, mWidth, mHeight, TGxRGBA.Create(96, 96, 0));
+ drawRectUI(gx, gy, mWidth, mHeight, TGxRGBA.Create(96, 96, 96));
if (Length(mText) > 0) then
begin
else if (mVAlign > 0) then ypos := mHeight-8
else ypos := (mHeight-8) div 2;
- drawText8(gx+xpos, gy+ypos, mText, 255, 255, 255);
+ drawText8(gx+xpos, gy+ypos, mText, TGxRGBA.Create(255, 255, 255));
end;
end;
initialization
- registerCtlClass(THCtlBox, 'box');
registerCtlClass(THCtlHBox, 'hbox');
registerCtlClass(THCtlVBox, 'vbox');
registerCtlClass(THCtlSpan, 'span');
+ registerCtlClass(THCtlHLine, 'hline');
+ registerCtlClass(THCtlVLine, 'vline');
registerCtlClass(THCtlTextLabel, 'label');
end.