grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / intuition / windowlimits.c
blobb198e507e1c6752219b66647bbc0561832eb97a7
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Set the minimum and maximum size of a window.
7 */
9 #include "intuition_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <exec/types.h>
15 #include <intuition/intuition.h>
16 #include <proto/intuition.h>
18 AROS_LH5(BOOL, WindowLimits,
20 /* SYNOPSIS */
21 AROS_LHA(struct Window *, window, A0),
22 AROS_LHA(WORD, MinWidth, D0),
23 AROS_LHA(WORD, MinHeight, D1),
24 AROS_LHA(UWORD, MaxWidth, D2),
25 AROS_LHA(UWORD, MaxHeight, D3),
27 /* LOCATION */
28 struct IntuitionBase *, IntuitionBase, 53, Intuition)
30 /* FUNCTION
31 This function sets the minimum and maximum sizes of a window.
33 INPUTS
34 window - window to change
35 MinWidth, MinHeight - the minimum size, may be 0 for no change
36 MaxWidth, MaxHeight - the maximum size, may be 0 for no change,
37 may be -1 for no maximum size
39 RESULT
40 A boolean. FALSE is returned if any of the provided sizes is out
41 of range. Note that the other sizes take effect, though. TRUE if
42 all sizes could be set.
44 NOTES
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 OpenWindow()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
59 BOOL retval = TRUE;
61 DEBUG_WINDOWLIMITS(dprintf("WindowLimits(Window 0x%lx MinWidth %ld MinHeight %ld MaxWidth %ld MaxHeight %ld)\n",window,MinWidth,MinHeight,MaxWidth,MaxHeight));
63 IntuitionBase = IntuitionBase; /* shut up the compiler */
65 SANITY_CHECKR(window,FALSE)
67 /* convert -1 to screen width/height */
68 if ((WORD)MaxWidth == -1) MaxWidth = window->WScreen->Width;
69 if ((WORD)MaxHeight == -1) MaxHeight = window->WScreen->Height;
71 /* crop maxwidth/height to screen width/height */
72 if (MaxWidth > window->WScreen->Width) MaxWidth = window->WScreen->Width;
73 if (MaxHeight > window->WScreen->Height) MaxHeight = window->WScreen->Height;
75 if (MinWidth)
77 if(window->Width >= MinWidth)
78 window->MinWidth = MinWidth;
79 else
80 retval = FALSE;
83 if (MinHeight)
85 if(window->Height >= MinHeight)
86 window->MinHeight = MinHeight;
87 else
88 retval = FALSE;
91 if (MaxWidth)
93 if(window->Width <= MaxWidth)
94 window->MaxWidth = MaxWidth;
95 else
96 retval = FALSE;
99 if (MaxHeight)
101 if(window->Height <= MaxHeight)
102 window->MaxHeight = MaxHeight;
103 else
104 retval = FALSE;
107 return retval;
109 AROS_LIBFUNC_EXIT
111 } /* WindowLimits */