//winHelp.appendChild(llb);
- winHelp.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winHelp);
winHelp.centerInScreen();
end;
box: TUIVBox;
begin
winLayers := TUITopWindow.Create('layers');
+ winLayers.flHoriz := false;
winLayers.x0 := 10;
winLayers.y0 := 10;
winLayers.flHoriz := false;
addCheckBox(box, '~foreground', @g_rlayer_fore);
winLayers.appendChild(box);
- winLayers.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winLayers);
end;
box: TUIVBox;
begin
winOutlines := TUITopWindow.Create('outlines');
+ winOutlines.flHoriz := false;
winOutlines.x0 := 100;
winOutlines.y0 := 30;
winOutlines.flHoriz := false;
addCheckBox(box, 'con~tours', @g_ol_nice);
winOutlines.appendChild(box);
- winOutlines.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winOutlines);
end;
begin
winOptions := TUITopWindow.Create('Holmes Options');
winOptions.flHoriz := false;
+ winOptions.flHoriz := false;
winOptions.escClose := true;
box := TUIVBox.Create();
addButton(box, '~outline', toggleOutlineWindowCB);
winOptions.appendChild(box);
- winOptions.flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale), trunc(getScrHgt/gh_ui_scale));
uiLayoutCtl(winOptions);
winOptions.centerInScreen();
end;
mInClose: Boolean;
mFreeOnClose: Boolean; // default: false
mDoCenter: Boolean; // after layouting
+ mFitToScreen: Boolean;
protected
procedure activated (); override;
function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
+ procedure flFitToScreen (); // call this before layouting
+
procedure centerInScreen ();
// `sx` and `sy` are screen coordinates
public
property freeOnClose: Boolean read mFreeOnClose write mFreeOnClose;
+ property fitToScreen: Boolean read mFitToScreen write mFitToScreen;
end;
// ////////////////////////////////////////////////////////////////////// //
function parseProperty (const prname: AnsiString; par: TTextParser): Boolean; override;
+ procedure doAction (); override;
+
procedure drawControl (gx, gy: Integer); override;
procedure mouseEvent (var ev: THMouseEvent); override;
procedure mouseEvent (var ev: THMouseEvent); override;
procedure keyEvent (var ev: THKeyEvent); override;
- procedure keyEventPost (var ev: THKeyEvent); override;
end;
// ////////////////////////////////////////////////////////////////////// //
procedure mouseEvent (var ev: THMouseEvent); override;
procedure keyEvent (var ev: THKeyEvent); override;
- procedure keyEventPost (var ev: THKeyEvent); override;
procedure setVar (pvar: PBoolean);
if (ctl = nil) then exit;
lay := TFlexLayouter.Create();
try
+ if (ctl is TUITopWindow) and (TUITopWindow(ctl).fitToScreen) then TUITopWindow(ctl).flFitToScreen();
+
lay.setup(ctl);
//lay.layout();
procedure TUITopWindow.AfterConstruction ();
begin
inherited;
+ mFitToScreen := true;
mFrameWidth := 8;
mFrameHeight := 8;
if (mWidth < mFrameWidth*2+3*8) then mWidth := mFrameWidth*2+3*8;
end;
+procedure TUITopWindow.flFitToScreen ();
+begin
+ flMaxSize := TLaySize.Create(trunc(getScrWdt/gh_ui_scale)-mFrameWidth*2-6, trunc(getScrHgt/gh_ui_scale)-mFrameHeight*2-6);
+end;
+
+
procedure TUITopWindow.centerInScreen ();
begin
if (mWidth > 0) and (mHeight > 0) then
end;
-procedure TUITextLabel.keyEventPost (var ev: THKeyEvent);
+procedure TUITextLabel.doAction ();
var
ctl: TUIControl;
+begin
+ if (assigned(actionCB)) then
+ begin
+ actionCB(self);
+ end
+ else
+ begin
+ ctl := topLevel[mLinkId];
+ if (ctl <> nil) then
+ begin
+ if (ctl.canFocus) then ctl.focused := true;
+ end;
+ end;
+end;
+
+
+procedure TUITextLabel.keyEventPost (var ev: THKeyEvent);
begin
if (not enabled) then exit;
- if (mHotChar = #0) or (Length(mLinkId) = 0) then exit;
+ if (mHotChar = #0) then exit;
if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
+ if (ev.kstate <> ev.ModAlt) then exit;
if (not ev.isHot(mHotChar)) then exit;
- ctl := topLevel[mLinkId];
- if (ctl <> nil) then
- begin
- ev.eat();
- if (ctl.canFocus) then ctl.focused := true;
- end;
+ ev.eat();
+ if (canFocus) then focused := true;
+ doAction();
end;
end;
-procedure TUIButton.keyEventPost (var ev: THKeyEvent);
-begin
- if (not enabled) then exit;
- if (mHotChar = #0) then exit;
- if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
- if (not ev.isHot(mHotChar)) then exit;
- if (not canFocus) then exit;
- ev.eat();
- focused := true;
- doAction();
-end;
-
-
// ////////////////////////////////////////////////////////////////////////// //
procedure TUISwitchBox.AfterConstruction ();
begin
end;
-procedure TUISwitchBox.keyEventPost (var ev: THKeyEvent);
-begin
- if (not enabled) then exit;
- if (mHotChar = #0) then exit;
- if (ev.eaten) or (ev.cancelled) or (not ev.press) then exit;
- if (not ev.isHot(mHotChar)) then exit;
- if (not canFocus) then exit;
- ev.eat();
- focused := true;
- doAction();
-end;
-
-
// ////////////////////////////////////////////////////////////////////////// //
procedure TUICheckBox.AfterConstruction ();
begin