This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,11 @@
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without srolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations and menubars. The idea is to determine the physical display parameters for the maximum height and width of the usable display area in pixels (without scrolling). The values calculated should represent the usable desktop area of a window maximized to fit the the screen.
=== Considerations ===
==== Multiple Monitors ====
For multiple monitors, the values calculated should represent the size of the usable display area on the monitor which is related to the task (ie the monitor which would display a window if such instructions were given).
==== Tiling Window Managers ====
For a tiling window manager, the values calculated should represent the maximum height and width of the display area of the maximum size a window can be created (without scrolling). This would typically be a full screen window (minus any areas occupied by desktop bars), unless the window manager has restrictions that prevents the creation of a full screen window, in which case the values represent the usable area of the desktop that occupies the maximum permissible window size (without scrolling).

View file

@ -0,0 +1,4 @@
---
note: GUI
requires:
- Graphics

View file

@ -0,0 +1,27 @@
with Gtk.Main;
with Glib;
with Gtk.Window; use Gtk.Window;
with Gtk.Enums; use Gtk.Enums;
with Ada.Text_IO; use Ada.Text_IO;
procedure Max_Size is
Win : Gtk_Window;
Win_W, Win_H : Glib.Gint;
package Int_Io is new Integer_IO (Glib.Gint);
Hid : Gtk.Main.Quit_Handler_Id;
begin
Gtk.Main.Init;
Gtk_New (Win);
Initialize (Win, Window_Toplevel);
Maximize (Win);
Show (Win);
Get_Size (Win, Win_W, Win_H);
Put ("Maximum dimensions of window : W ");
Int_Io.Put (Win_W, Width => 4);
Put (" x H ");
Int_Io.Put (Win_H, Width => 4);
New_Line;
Hid := Gtk.Main.Quit_Add_Destroy (0, Win);
end Max_Size;

View file

@ -0,0 +1,5 @@
SPI_GETWORKAREA = 48
DIM rc{l%,t%,r%,b%}
SYS "SystemParametersInfo", SPI_GETWORKAREA, 0, rc{}, 0
PRINT "Maximum width = " ; rc.r% - rc.l%
PRINT "Maximum height = " ; rc.b% - rc.t%

View file

@ -0,0 +1,5 @@
browser Browser{};
bvh int = browser.getViewportHeight();
bvw int = browser.getViewportWidth();
SysLib.writeStdout("ViewportHeight: " + bvh);
SysLib.writeStdout("ViewportWidth: " + bvw);

View file

@ -0,0 +1,2 @@
FMain.Maximized = True
FMain.Visible = False ' The form can be invisible

View file

@ -0,0 +1,7 @@
PUBLIC SUB _new()
END
PUBLIC SUB Form_Open()
END

View file

@ -0,0 +1,3 @@
PUBLIC SUB Form_Resize()
PRINT "The maximum window size that can be used without scrolling is "; FMain.Width; " x "; FMain.Height
END

View file

@ -0,0 +1,52 @@
import Graphics.UI.Gtk
import Control.Monad (when)
import Control.Monad.Trans (liftIO)
maximumWindowDimensions :: IO ()
maximumWindowDimensions = do
-- initialize the internal state of the GTK toolkit
initGUI
-- create a window
window <- windowNew
-- quit the application when the window is closed
on window objectDestroy mainQuit
-- query the size of the window when its dimensions change
on window configureEvent printSize
-- get the screen the window will be drawn upon
screen <- windowGetScreen window
-- get the size of the screen
x <- screenGetWidth screen
y <- screenGetHeight screen
-- print the dimensions of the screen
putStrLn ("The screen is " ++ show x ++ " pixels wide and " ++
show y ++ " pixels tall for an undecorated fullscreen window.")
-- maximize the window and show it. printSize will then be called
windowMaximize window
widgetShowAll window
-- run the main GTK loop.
-- close the window manually.
mainGUI
-- On my Xfce4 desktop, the configure_event is called three times when a
-- top level window is maximized. The first time, the window size
-- returned is the size prior to maximizing, and the last two times
-- it is the size after maximizing.
-- If the window is (un)maximized manually, the size returned is always
-- the size of the unmaximized window.
-- That means: either GTK or Xfce4 does not handle window maximization
-- correctly, or the GTK bindings for Haskell are buggy, or there is an
-- error in this program.
printSize :: EventM EConfigure Bool
printSize = do
-- get the window that has been resized
w <- eventWindow
-- is the window maximized?
s <- liftIO $ drawWindowGetState w
when (WindowStateMaximized `elem` s) $ do
-- get the size of the window that has been resized
(x, y) <- eventSize
-- print the dimensions out
liftIO $ putStrLn ("The inner window region is now " ++ show x ++
" pixels wide and " ++ show y ++ " pixels tall.")
return True

View file

@ -0,0 +1,11 @@
link graphics
procedure main() # Window size
W := WOpen("canvas=hidden")
dh := WAttrib("displayheight")
dw := WAttrib("displaywidth")
WClose(W)
write("The display size is w=",dw,", h=",dh)
end

View file

@ -0,0 +1,2 @@
Differences@Transpose@SystemInformation["Devices"][[1, 2, 1, 1, 2]]
->{{1260, 951}}

View file

@ -0,0 +1,8 @@
use strict;
use warnings;
use Tk;
sub get_size {
my $mw = MainWindow->new();
return ($mw->maxsize);
}

View file

@ -0,0 +1,9 @@
(let Frame (java "javax.swing.JFrame" T "Window")
(java Frame 'setExtendedState
(java (public "javax.swing.JFrame" 'MAXIMIZED_BOTH)) )
(java Frame 'setVisible T)
(wait 200)
(let Size (java (java Frame 'getContentPane) 'getSize)
(prinl "Width: " (java (public Size 'width)))
(prinl "Height: " (java (public Size 'height))) )
(java Frame 'dispose) )

View file

@ -0,0 +1,11 @@
package require Tk
proc maxSize {} {
# Need a dummy window; max window can be changed by scripts
set top .__defaultMaxSize__
if {![winfo exists $top]} {
toplevel $top
wm withdraw $top
}
# Default max size of window is value we want
return [wm maxsize $top]
}

View file

@ -0,0 +1,15 @@
TYPE syswindowstru
screenheight AS INTEGER
screenwidth AS INTEGER
maxheight AS INTEGER
maxwidth AS INTEGER
END TYPE
DIM syswindow AS syswindowstru
' Determine the height and width of the screen
syswindow.screenwidth = Screen.Width / Screen.TwipsPerPixelX
syswindow.screenheight=Screen.Height / Screen.TwipsPerPixelY
' Make adjustments for window decorations and menubars