wanted to fill in an hour or so, so heres the (partial) proof of concept :)
Hans-Peter Diettrich wrote 15 lines
Vannus schrieb:
layout should have single, dual, etc modes.
>
> if i use my laptop, all windows are on that monitor.
> if i plug monitor into my laptop, and move source editor onto this then
> lazarus should save this as dual mode of the layout.
> every time i use laptop without extra screen it uses single mode, every
> time i plug in monitor it uses dual mode.
>
Please provide the algorithm to select the file to use, taking into account
non-existing files.
layouts:=TStringList.Create;
if FileExists('project/layouts.txt') then // project layouts file
layouts.LoadFromFile('project/layouts.txt')
else if FileExists('layouts.txt') then // app layouts file
layouts.LoadFromFile('layouts.txt')
else begin // embedded layouts file
with layouts do begin
Add('1:Form1'); // single monitor
Add('50'); // Left
Add('50'); // top
Add('500'); // width
Add('100'); // height
Add('2:Form1'); // dual monitor
Add('500'); // Left
Add('500'); // top
Add('500'); // width
Add('100'); // height
// etc...
end;
end;
Say you change your dual layout, then the single layout is not normally
updated. You also have to provide how to find the files that should be
updated as well, and code to perform the update.
i:=layouts.IndexOf(inttostr(screen.MonitorCount)+':'+AForm.Name);
if (i>=0) then
with AForm do begin
Top:=strtoint(layouts.Strings[i+1]);
Left:=strtoint(layouts.Strings[i+2]);
Width:=strtoint(layouts.Strings[i+3]);
Height:=strtoint(layouts.Strings[i+4]);
end;
and layouts.Strings[i+1]:=IntToStr(Left), etc for saving
Show quoted text 14 lines
Also, who specifies which coordinates should be absolute, and which
> should be relative? Do you want to write and use such an editor?
> Whenever a layout is to be saved?
>
>
> an editor in lazarus windows menu where you can select left, top, width,
> height, and possibly even anchors editor.
>
Write that editor, and guarantee that it will not make the files unusable
by accident.
it wont make the files any less usable than above code
Show quoted text 8 lines
you would rarely need to use the editor - windows should 'just remember'
> their relative left, top, width, height positions.
>
That's why the current screen layout can be saved, nothing more. No editing
or other processing of the layout files, that has to be done on screen.
i quite like my simple '1:', '2:', etc solution to multi-monitor layouts :)
Show quoted text 15 lines
Question is not *where* the layouts are, instead *what* the layouts are
> for, i.e. *which* of these files to use.
>
not just use the same as windows/unix PATH's? how did delphi do it?
>
It's not a mather of paths, it's a matter of file names.
DoDi
ive attached my partial proof of concept. the bits i've left incomplete are fairly obvious from rest of code.
(add the others forms to layouts with '1:Form2', etc.) (add saving by reversing IntToStr as mentioned above.)
at this point the code should be moved to a component or something as LoadFromFile is called every time a form reads its layout, rather than when project is opened.
- V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100603/ac82efe7/attachment.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: layouts.zip
Type: application/zip
Size: 3444 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100603/ac82efe7/attachment.zip>