From b7db3ec73d4d64c2689c7773e63ef5b267cc8293 Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Fri, 4 Nov 2005 10:14:16 +0000 Subject: [PATCH] make new window fit in outer window / screen --- Ed/EdWindow.icl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Ed/EdWindow.icl b/Ed/EdWindow.icl index c3f3446..bbbf2cb 100644 --- a/Ed/EdWindow.icl +++ b/Ed/EdWindow.icl @@ -6,9 +6,20 @@ import StdInt, StdClass, StdList import StdWindow, StdControlReceiver, StdIOBasic import EdMessage, EdMonad, EdLook, EdVisualText, EdState import ioutil - +from StdProcess import getProcessWindowSize //--- +determine_default_window_size :: !Int !*(IOSt *a) -> (!Size,!*(IOSt *a)) +determine_default_window_size lineHeight io + # ({w=process_window_width,h=process_window_height},io) = getProcessWindowSize io + default_window_width = process_window_width-40 + default_window_width = if (default_window_width>800) 800 + (if (default_window_width<100) 100 default_window_width) + process_window_lines = (process_window_height-60) / lineHeight + default_window_lines = if (process_window_lines>40) 40 + (if (process_window_lines<5) 5 process_window_lines) + = ({w=default_window_width,h=default_window_lines*lineHeight},io) + openEditWindow :: Id .Title String Text !Font (Int,Bool,Bool,Bool,Bool) Int SyntaxColours Id [.WindowAttribute *(EditState,*PSt *b)] !*(PSt *b) -> *PSt *b | Editor b openEditWindow uId title pathName text font tabs margin syncols windowId atts ps # (editorState,ps) = getEditorState ps @@ -23,8 +34,11 @@ openEditWindow uId title pathName text font tabs margin syncols windowId atts ps (viewDomain, (editState, ps)) = computeViewDomain (editState, ps) // setup the window attributes editLook = editWindowLook editState + (default_window_size,io) = determine_default_window_size fontInfo.FontInfo.lineHeight ps.io + ps = {ps & io=io} windowAttrs = atts ++ // in this order so that new attributes override default atts - [ WindowViewSize { w = 800, h = fontInfo.FontInfo.lineHeight * 40 } + [ + WindowViewSize default_window_size , WindowHMargin 0 0 , WindowVMargin 0 0 , WindowId windowId -- GitLab